Browse Source

Moved global constants to FungusConstants static class.

master
Christopher 8 years ago
parent
commit
245500fd25
  1. 7
      Assets/Fungus/Scripts/Components/Block.cs
  2. 18
      Assets/Fungus/Scripts/Components/Flowchart.cs
  3. 2
      Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
  4. 2
      Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs
  5. 6
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  6. 23
      Assets/Fungus/Scripts/Utils/FungusConstants.cs
  7. 12
      Assets/Fungus/Scripts/Utils/FungusConstants.cs.meta

7
Assets/Fungus/Scripts/Components/Block.cs

@ -44,11 +44,6 @@ namespace Fungus
protected int jumpToCommandIndex = -1;
/// <summary>
/// Duration of fade for executing icon displayed beside blocks & commands.
/// </summary>
public const float executingIconFadeTime = 0.5f;
protected int executionCount;
protected bool executionInfoSet = false;
@ -224,7 +219,7 @@ namespace Fungus
command.IsExecuting = true;
// This icon timer is managed by the FlowchartWindow class, but we also need to
// set it here in case a command starts and finishes execution before the next window update.
command.ExecutingIconTimer = Time.realtimeSinceStartup + executingIconFadeTime;
command.ExecutingIconTimer = Time.realtimeSinceStartup + FungusConstants.ExecutingIconFadeTime;
command.Execute();
// Wait until the executing command sets another command to jump to via Command.Continue()

18
Assets/Fungus/Scripts/Components/Flowchart.cs

@ -19,16 +19,6 @@ namespace Fungus
[ExecuteInEditMode]
public class Flowchart : MonoBehaviour, IFlowchart, ISubstitutionHandler
{
/// <summary>
/// The current version of the Flowchart. Used for updating components.
/// </summary>
public const int CURRENT_VERSION = 1;
/// <summary>
/// The name of the initial block in a new flowchart.
/// </summary>
public const string DEFAULT_BLOCK_NAME = "New Block";
[HideInInspector]
[SerializeField] protected int version = 0; // Default to 0 to always trigger an update for older versions of Fungus.
@ -177,7 +167,7 @@ namespace Fungus
protected virtual void UpdateVersion()
{
if (version == CURRENT_VERSION)
if (version == FungusConstants.CurrentVersion)
{
// No need to update
return;
@ -189,11 +179,11 @@ namespace Fungus
IUpdateable u = component as IUpdateable;
if (u != null)
{
u.UpdateToVersion(version, CURRENT_VERSION);
u.UpdateToVersion(version, FungusConstants.CurrentVersion);
}
}
version = CURRENT_VERSION;
version = FungusConstants.CurrentVersion;
}
protected virtual void OnDisable()
@ -500,7 +490,7 @@ namespace Fungus
// No empty keys allowed
if (baseKey.Length == 0)
{
baseKey = "New Block";
baseKey = FungusConstants.DefaultBlockName;
}
var blocks = GetComponents<IBlock>();

2
Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs

@ -416,7 +416,7 @@ namespace Fungus
Color storeColor = GUI.color;
float alpha = (command.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
float alpha = (command.ExecutingIconTimer - Time.realtimeSinceStartup) / FungusConstants.ExecutingIconFadeTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(1f, 1f, 1f, alpha);

2
Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs

@ -18,7 +18,7 @@ namespace Fungus
var flowchart = go.GetComponent<Flowchart>();
if (flowchart != null)
{
flowchart.Version = Flowchart.CURRENT_VERSION;
flowchart.Version = FungusConstants.CurrentVersion;
}
// Only the first created Flowchart in the scene should have a default GameStarted block

6
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -369,8 +369,8 @@ namespace Fungus
{
if (b.IsExecuting())
{
b.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
b.ActiveCommand.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
b.ExecutingIconTimer = Time.realtimeSinceStartup + FungusConstants.ExecutingIconFadeTime;
b.ActiveCommand.ExecutingIconTimer = Time.realtimeSinceStartup + FungusConstants.ExecutingIconFadeTime;
forceRepaintCount = 6;
}
@ -385,7 +385,7 @@ namespace Fungus
if (!b.IsExecuting())
{
float alpha = (b.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
float alpha = (b.ExecutingIconTimer - Time.realtimeSinceStartup) / FungusConstants.ExecutingIconFadeTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(1f, 1f, 1f, alpha);
}

23
Assets/Fungus/Scripts/Utils/FungusConstants.cs

@ -0,0 +1,23 @@
namespace Fungus
{
/// <summary>
/// Global constants used in various parts of Fungus.
/// </summary>
public static class FungusConstants
{
/// <summary>
/// Duration of fade for executing icon displayed beside blocks & commands.
/// </summary>
public const float ExecutingIconFadeTime = 0.5f;
/// <summary>
/// The current version of the Flowchart. Used for updating components.
/// </summary>
public const int CurrentVersion = 1;
/// <summary>
/// The name of the initial block in a new flowchart.
/// </summary>
public const string DefaultBlockName = "New Block";
}
}

12
Assets/Fungus/Scripts/Utils/FungusConstants.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f5c033627e6d6426ebdf267bb6b6a242
timeCreated: 1474040740
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save