diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 28bb1843..8328e213 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -92,6 +92,10 @@ namespace Fungus [Tooltip("The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.")] [SerializeField] protected string luaBindingName = "flowchart"; + protected static bool eventSystemPresent; + + protected StringSubstituter stringSubstituer; + /// /// Cached list of flowchart objects in the scene for fast lookup. /// @@ -110,10 +114,6 @@ namespace Fungus } } - protected static bool eventSystemPresent; - - protected StringSubstituter stringSubstituer; - #if UNITY_5_4_OR_NEWER protected virtual void Awake() { diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs index 38f53bc3..5b776e43 100644 --- a/Assets/Fungus/Scripts/Components/Localization.cs +++ b/Assets/Fungus/Scripts/Components/Localization.cs @@ -17,13 +17,6 @@ namespace Fungus /// public class Localization : MonoBehaviour, ILocalization, ISubstitutionHandler { - [Tooltip("Language to use at startup, usually defined by a two letter language code (e.g DE = German)")] - [SerializeField] protected string activeLanguage = ""; - - protected static Dictionary localizedStrings = new Dictionary(); - - protected Dictionary localizeableObjects = new Dictionary(); - /// /// Temp storage for a single item of standard text and its localizations. /// @@ -34,13 +27,20 @@ namespace Fungus public Dictionary localizedStrings = new Dictionary(); } + [Tooltip("Language to use at startup, usually defined by a two letter language code (e.g DE = German)")] + [SerializeField] protected string activeLanguage = ""; + [Tooltip("CSV file containing localization data which can be easily edited in a spreadsheet tool")] [SerializeField] protected TextAsset localizationFile; + protected Dictionary localizeableObjects = new Dictionary(); + protected string notificationText = ""; protected bool initialized; + protected static Dictionary localizedStrings = new Dictionary(); + #if UNITY_5_4_OR_NEWER protected virtual void Awake() { diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index 841e9bc6..3a081fd0 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -12,9 +12,6 @@ namespace Fungus { public class MenuDialog : MonoBehaviour, IMenuDialog { - // Currently active Menu Dialog used to display Menu options - public static IMenuDialog activeMenuDialog; - [Tooltip("Automatically select the first interactable button when the menu is shown.")] [SerializeField] protected bool autoSelectFirstButton = false; @@ -22,6 +19,9 @@ namespace Fungus protected Slider cachedSlider; + // Currently active Menu Dialog used to display Menu options + public static IMenuDialog activeMenuDialog; + public static IMenuDialog GetMenuDialog() { if (activeMenuDialog == null) diff --git a/Assets/Fungus/Scripts/Components/PortraitController.cs b/Assets/Fungus/Scripts/Components/PortraitController.cs index e723ef03..c68c0a08 100644 --- a/Assets/Fungus/Scripts/Components/PortraitController.cs +++ b/Assets/Fungus/Scripts/Components/PortraitController.cs @@ -19,6 +19,19 @@ namespace Fungus protected Stage stage; + public static void SetRectTransform(RectTransform oldRectTransform, RectTransform newRectTransform) + { + oldRectTransform.eulerAngles = newRectTransform.eulerAngles; + oldRectTransform.position = newRectTransform.position; + oldRectTransform.rotation = newRectTransform.rotation; + oldRectTransform.anchoredPosition = newRectTransform.anchoredPosition; + oldRectTransform.sizeDelta = newRectTransform.sizeDelta; + oldRectTransform.anchorMax = newRectTransform.anchorMax; + oldRectTransform.anchorMin = newRectTransform.anchorMin; + oldRectTransform.pivot = newRectTransform.pivot; + oldRectTransform.localScale = newRectTransform.localScale; + } + protected virtual void Awake() { stage = GetComponentInParent(); @@ -207,19 +220,6 @@ namespace Fungus } } - public static void SetRectTransform(RectTransform oldRectTransform, RectTransform newRectTransform) - { - oldRectTransform.eulerAngles = newRectTransform.eulerAngles; - oldRectTransform.position = newRectTransform.position; - oldRectTransform.rotation = newRectTransform.rotation; - oldRectTransform.anchoredPosition = newRectTransform.anchoredPosition; - oldRectTransform.sizeDelta = newRectTransform.sizeDelta; - oldRectTransform.anchorMax = newRectTransform.anchorMax; - oldRectTransform.anchorMin = newRectTransform.anchorMin; - oldRectTransform.pivot = newRectTransform.pivot; - oldRectTransform.localScale = newRectTransform.localScale; - } - protected virtual void DoMoveTween(Character character, RectTransform fromPosition, RectTransform toPosition, float moveDuration, Boolean waitUntilFinished) { PortraitOptions options = new PortraitOptions(true); diff --git a/Assets/Fungus/Scripts/Utils/ConversationManager.cs b/Assets/Fungus/Scripts/Utils/ConversationManager.cs index f2b83cc4..42437fab 100644 --- a/Assets/Fungus/Scripts/Utils/ConversationManager.cs +++ b/Assets/Fungus/Scripts/Utils/ConversationManager.cs @@ -23,6 +23,53 @@ namespace Fungus protected bool exitSayWait; + /// + /// Splits the string passed in by the delimiters passed in. + /// Quoted sections are not split, and all tokens have whitespace + /// trimmed from the start and end. + protected static string[] Split(string stringToSplit) + { + var results = new List(); + + bool inQuote = false; + var currentToken = new StringBuilder(); + for (int index = 0; index < stringToSplit.Length; ++index) + { + char currentCharacter = stringToSplit[index]; + if (currentCharacter == '"') + { + // When we see a ", we need to decide whether we are + // at the start or send of a quoted section... + inQuote = !inQuote; + } + else if (char.IsWhiteSpace(currentCharacter) && !inQuote) + { + // We've come to the end of a token, so we find the token, + // trim it and add it to the collection of results... + string result = currentToken.ToString().Trim( new [] { ' ', '\n', '\t', '\"'} ); + if (result != "") results.Add(result); + + // We start a new token... + currentToken = new StringBuilder(); + } + else + { + // We've got a 'normal' character, so we add it to + // the curent token... + currentToken.Append(currentCharacter); + } + } + + // We've come to the end of the string, so we add the last token... + string lastResult = currentToken.ToString().Trim(); + if (lastResult != "") + { + results.Add(lastResult); + } + + return results.ToArray(); + } + protected ISayDialog GetSayDialog(Character character) { ISayDialog sayDialog = null; @@ -208,53 +255,6 @@ namespace Fungus return item; } - /// - /// Splits the string passed in by the delimiters passed in. - /// Quoted sections are not split, and all tokens have whitespace - /// trimmed from the start and end. - protected static string[] Split(string stringToSplit) - { - var results = new List(); - - bool inQuote = false; - var currentToken = new StringBuilder(); - for (int index = 0; index < stringToSplit.Length; ++index) - { - char currentCharacter = stringToSplit[index]; - if (currentCharacter == '"') - { - // When we see a ", we need to decide whether we are - // at the start or send of a quoted section... - inQuote = !inQuote; - } - else if (char.IsWhiteSpace(currentCharacter) && !inQuote) - { - // We've come to the end of a token, so we find the token, - // trim it and add it to the collection of results... - string result = currentToken.ToString().Trim( new [] { ' ', '\n', '\t', '\"'} ); - if (result != "") results.Add(result); - - // We start a new token... - currentToken = new StringBuilder(); - } - else - { - // We've got a 'normal' character, so we add it to - // the curent token... - currentToken.Append(currentCharacter); - } - } - - // We've come to the end of the string, so we add the last token... - string lastResult = currentToken.ToString().Trim(); - if (lastResult != "") - { - results.Add(lastResult); - } - - return results.ToArray(); - } - #region IConversationManager public void PopulateCharacterCache() diff --git a/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs b/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs index 4747a5ad..39a411e0 100644 --- a/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs +++ b/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs @@ -27,17 +27,17 @@ namespace Fungus [SerializeField] public Animator animatorVal; - public AnimatorData(Animator v) - { - animatorVal = v; - animatorRef = null; - } - public static implicit operator Animator(AnimatorData animatorData) { return animatorData.Value; } + public AnimatorData(Animator v) + { + animatorVal = v; + animatorRef = null; + } + public Animator Value { get { return (animatorRef == null) ? animatorVal : animatorRef.Value; } diff --git a/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs b/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs index a3e4bb34..5727e4a4 100644 --- a/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs +++ b/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs @@ -27,16 +27,16 @@ namespace Fungus [SerializeField] public AudioSource audioSourceVal; + public static implicit operator AudioSource(AudioSourceData audioSourceData) + { + return audioSourceData.Value; + } + public AudioSourceData(AudioSource v) { audioSourceVal = v; audioSourceRef = null; } - - public static implicit operator AudioSource(AudioSourceData audioSourceData) - { - return audioSourceData.Value; - } public AudioSource Value {