Skip to content

Commit

Permalink
Added SceneApi (universal version of Manager.Scene)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Jul 18, 2021
1 parent 562937e commit 65e9ed8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/Shared.Core/SceneApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace KKAPI
{
/// <summary>
/// Game-agnostic version of Manager.Scene. It allows using the same code in all games without any #if directives.
/// </summary>
public static class SceneApi
{
/// <summary>
/// Get name of the currently loaded overlay scene (eg. exit game box, config, confirmation dialogs).
/// </summary>
public static string GetAddSceneName()
{
#if HS2 || KKS
return Manager.Scene.AddSceneName;
#else
return Manager.Scene.Instance.AddSceneName;
#endif
}

/// <summary>
/// Get name of the currently loaded game scene (eg. maker, h, adv).
/// </summary>
public static string GetLoadSceneName()
{
#if HS2 || KKS
return Manager.Scene.LoadSceneName;
#else
return Manager.Scene.Instance.LoadSceneName;
#endif
}

/// <summary>
/// True if loading screen is being displayed, or if screen is currently fading in or out.
/// </summary>
public static bool GetIsNowLoadingFade()
{
#if HS2 || KKS
return Manager.Scene.IsNowLoadingFade;
#else
return Manager.Scene.Instance.IsNowLoadingFade;
#endif
}

/// <summary>
/// True if loading screen is being displayed.
/// </summary>
public static bool GetIsNowLoading()
{
#if HS2 || KKS
return Manager.Scene.IsNowLoading;
#else
return Manager.Scene.Instance.IsNowLoading;
#endif
}

/// <summary>
/// True if screen is currently fading in or out.
/// </summary>
public static bool GetIsFadeNow()
{
#if HS2 || KKS
return Manager.Scene.IsFadeNow;
#else
return Manager.Scene.Instance.IsFadeNow;
#endif
}
}
}
1 change: 1 addition & 0 deletions src/Shared.Core/Shared.Core.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Maker\UI\BaseEditableGuiEntry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Maker\UI\BaseGuiEntry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Maker\UI\Sidebar\ISidebarControl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SceneApi.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\ConfigurationManagerAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\CoroutineUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\HSceneUtils.cs" />
Expand Down

0 comments on commit 65e9ed8

Please sign in to comment.