Browse Source

Refactored narrative comments

master
Christopher 9 years ago
parent
commit
f94e46e42d
  1. 5
      Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs
  2. 12
      Assets/Fungus/Narrative/Scripts/Character.cs
  3. 5
      Assets/Fungus/Narrative/Scripts/Commands/ClearMenu.cs
  4. 5
      Assets/Fungus/Narrative/Scripts/Commands/ControlStage.cs
  5. 4
      Assets/Fungus/Narrative/Scripts/Commands/Conversation.cs
  6. 5
      Assets/Fungus/Narrative/Scripts/Commands/Menu.cs
  7. 6
      Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs
  8. 21
      Assets/Fungus/Narrative/Scripts/Commands/Portrait.cs
  9. 9
      Assets/Fungus/Narrative/Scripts/Commands/Say.cs
  10. 4
      Assets/Fungus/Narrative/Scripts/Commands/SetLanguage.cs
  11. 5
      Assets/Fungus/Narrative/Scripts/Commands/SetMenuDialog.cs
  12. 5
      Assets/Fungus/Narrative/Scripts/Commands/SetSayDialog.cs
  13. 6
      Assets/Fungus/Narrative/Scripts/ConversationManager.cs
  14. 11
      Assets/Fungus/Narrative/Scripts/CustomTag.cs
  15. 23
      Assets/Fungus/Narrative/Scripts/DialogInput.cs
  16. 110
      Assets/Fungus/Narrative/Scripts/Localization.cs
  17. 9
      Assets/Fungus/Narrative/Scripts/MenuDialog.cs
  18. 23
      Assets/Fungus/Narrative/Scripts/PortraitController.cs
  19. 18
      Assets/Fungus/Narrative/Scripts/SayDialog.cs
  20. 15
      Assets/Fungus/Narrative/Scripts/Stage.cs

5
Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs

@ -4,13 +4,14 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using Fungus; using Fungus;
using MoonSharp.Interpreter; using MoonSharp.Interpreter;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Executes a Lua code chunk using a Lua Environment.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Execute Lua", "Execute Lua",
"Executes a Lua code chunk using a Lua Environment.")] "Executes a Lua code chunk using a Lua Environment.")]

12
Assets/Fungus/Narrative/Scripts/Character.cs

@ -5,47 +5,41 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// A Character that can be used in dialogue via the Say, Conversation and Portrait commands.
/// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
public class Character : MonoBehaviour, ILocalizable public class Character : MonoBehaviour, ILocalizable
{ {
[SerializeField] protected string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad") [SerializeField] protected string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad")
public string NameText { get { return nameText; } } public string NameText { get { return nameText; } }
[SerializeField] protected Color nameColor = Color.white; [SerializeField] protected Color nameColor = Color.white;
public Color NameColor { get { return nameColor; } } public Color NameColor { get { return nameColor; } }
[SerializeField] protected AudioClip soundEffect; [SerializeField] protected AudioClip soundEffect;
public AudioClip SoundEffect { get { return soundEffect; } } public AudioClip SoundEffect { get { return soundEffect; } }
[SerializeField] protected Sprite profileSprite; [SerializeField] protected Sprite profileSprite;
public Sprite ProfileSprite { get { return profileSprite; } set { profileSprite = value; } } public Sprite ProfileSprite { get { return profileSprite; } set { profileSprite = value; } }
[SerializeField] protected List<Sprite> portraits; [SerializeField] protected List<Sprite> portraits;
public List<Sprite> Portraits { get { return portraits; } } public List<Sprite> Portraits { get { return portraits; } }
[SerializeField] protected FacingDirection portraitsFace; [SerializeField] protected FacingDirection portraitsFace;
public FacingDirection PortraitsFace { get { return portraitsFace; } } public FacingDirection PortraitsFace { get { return portraitsFace; } }
[SerializeField] protected PortraitState state = new PortraitState(); [SerializeField] protected PortraitState state = new PortraitState();
public PortraitState State { get { return state; } } public PortraitState State { get { return state; } }
[Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")] [Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")]
[SerializeField] protected SayDialog setSayDialog; [SerializeField] protected SayDialog setSayDialog;
public SayDialog SetSayDialog { get { return setSayDialog; } } public SayDialog SetSayDialog { get { return setSayDialog; } }
[FormerlySerializedAs("notes")] [FormerlySerializedAs("notes")]

5
Assets/Fungus/Narrative/Scripts/Commands/ClearMenu.cs

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Clears the options from a menu dialogue.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Clear Menu", "Clear Menu",
"Clears the options from a menu dialogue")] "Clears the options from a menu dialogue")]

5
Assets/Fungus/Narrative/Scripts/Commands/ControlStage.cs

@ -23,6 +23,9 @@ namespace Fungus
DimNonSpeakingPortraits DimNonSpeakingPortraits
} }
/// <summary>
/// Controls the stage on which character portraits are displayed.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Control Stage", "Control Stage",
"Controls the stage on which character portraits are displayed.")] "Controls the stage on which character portraits are displayed.")]
@ -30,7 +33,6 @@ namespace Fungus
{ {
[Tooltip("Stage to display characters on")] [Tooltip("Stage to display characters on")]
[SerializeField] protected Stage stage; [SerializeField] protected Stage stage;
public Stage _Stage { get { return stage; } } public Stage _Stage { get { return stage; } }
[Tooltip("Stage to swap with")] [Tooltip("Stage to swap with")]
@ -38,7 +40,6 @@ namespace Fungus
[Tooltip("Use Default Settings")] [Tooltip("Use Default Settings")]
[SerializeField] protected bool useDefaultSettings = true; [SerializeField] protected bool useDefaultSettings = true;
public bool UseDefaultSettings { get { return useDefaultSettings; } } public bool UseDefaultSettings { get { return useDefaultSettings; } }
[Tooltip("Fade Duration")] [Tooltip("Fade Duration")]

4
Assets/Fungus/Narrative/Scripts/Commands/Conversation.cs

@ -4,11 +4,13 @@
*/ */
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using System.Collections; using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [: Story text].
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Conversation", "Conversation",
"Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [: Story text]")] "Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [: Story text]")]

5
Assets/Fungus/Narrative/Scripts/Commands/Menu.cs

@ -5,12 +5,13 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Displays a button in a multiple choice menu.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Menu", "Menu",
"Displays a button in a multiple choice menu")] "Displays a button in a multiple choice menu")]

6
Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs

@ -5,13 +5,13 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using UnityEngine.EventSystems;
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Displays a timer bar and executes a target block if the player fails to select a menu option in time.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Menu Timer", "Menu Timer",
"Displays a timer bar and executes a target block if the player fails to select a menu option in time.")] "Displays a timer bar and executes a target block if the player fails to select a menu option in time.")]

21
Assets/Fungus/Narrative/Scripts/Commands/Portrait.cs

@ -4,28 +4,23 @@
*/ */
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Controls a character portrait.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Portrait", "Portrait",
"Controls a character portrait. ")] "Controls a character portrait.")]
public class Portrait : ControlWithDisplay<DisplayType> public class Portrait : ControlWithDisplay<DisplayType>
{ {
[Tooltip("Stage to display portrait on")] [Tooltip("Stage to display portrait on")]
[SerializeField] protected Stage stage; [SerializeField] protected Stage stage;
public Stage _Stage { get { return stage; } set { stage = value; } } public Stage _Stage { get { return stage; } set { stage = value; } }
[Tooltip("Character to display")] [Tooltip("Character to display")]
[SerializeField] protected Character character; [SerializeField] protected Character character;
public Character _Character { get { return character; } set { character = value; } } public Character _Character { get { return character; } set { character = value; } }
[Tooltip("Character to swap with")] [Tooltip("Character to swap with")]
@ -33,32 +28,26 @@ namespace Fungus
[Tooltip("Portrait to display")] [Tooltip("Portrait to display")]
[SerializeField] protected Sprite portrait; [SerializeField] protected Sprite portrait;
public Sprite _Portrait { get { return portrait; } set { portrait = value; } } public Sprite _Portrait { get { return portrait; } set { portrait = value; } }
[Tooltip("Move the portrait from/to this offset position")] [Tooltip("Move the portrait from/to this offset position")]
[SerializeField] protected PositionOffset offset; [SerializeField] protected PositionOffset offset;
public PositionOffset Offset { get { return offset; } set { offset = value; } } public PositionOffset Offset { get { return offset; } set { offset = value; } }
[Tooltip("Move the portrait from this position")] [Tooltip("Move the portrait from this position")]
[SerializeField] protected RectTransform fromPosition; [SerializeField] protected RectTransform fromPosition;
public RectTransform FromPosition { get { return fromPosition; } set { fromPosition = value;} } public RectTransform FromPosition { get { return fromPosition; } set { fromPosition = value;} }
[Tooltip("Move the portrait to this positoin")] [Tooltip("Move the portrait to this positoin")]
[SerializeField] protected RectTransform toPosition; [SerializeField] protected RectTransform toPosition;
public RectTransform ToPosition { get { return toPosition; } set { toPosition = value;} } public RectTransform ToPosition { get { return toPosition; } set { toPosition = value;} }
[Tooltip("Direction character is facing")] [Tooltip("Direction character is facing")]
[SerializeField] protected FacingDirection facing; [SerializeField] protected FacingDirection facing;
public FacingDirection Facing { get { return facing; } set { facing = value; } } public FacingDirection Facing { get { return facing; } set { facing = value; } }
[Tooltip("Use Default Settings")] [Tooltip("Use Default Settings")]
[SerializeField] protected bool useDefaultSettings = true; [SerializeField] protected bool useDefaultSettings = true;
public bool UseDefaultSettings { get { return useDefaultSettings; } set { useDefaultSettings = value; } } public bool UseDefaultSettings { get { return useDefaultSettings; } set { useDefaultSettings = value; } }
[Tooltip("Fade Duration")] [Tooltip("Fade Duration")]
@ -72,12 +61,10 @@ namespace Fungus
[Tooltip("Move")] [Tooltip("Move")]
[SerializeField] protected bool move; [SerializeField] protected bool move;
public bool Move { get { return move; } set { move = value; } } public bool Move { get { return move; } set { move = value; } }
[Tooltip("Start from offset")] [Tooltip("Start from offset")]
[SerializeField] protected bool shiftIntoPlace; [SerializeField] protected bool shiftIntoPlace;
public bool ShiftIntoPlace { get { return shiftIntoPlace; } set { shiftIntoPlace = value; } } public bool ShiftIntoPlace { get { return shiftIntoPlace; } set { shiftIntoPlace = value; } }
[Tooltip("Wait until the tween has finished before executing the next command")] [Tooltip("Wait until the tween has finished before executing the next command")]

9
Assets/Fungus/Narrative/Scripts/Commands/Say.cs

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Writes text in a dialog box.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Say", "Say",
"Writes text in a dialog box.")] "Writes text in a dialog box.")]
@ -25,12 +25,10 @@ namespace Fungus
[Tooltip("Character that is speaking")] [Tooltip("Character that is speaking")]
[SerializeField] protected Character character; [SerializeField] protected Character character;
public Character _Character { get { return character; } } public Character _Character { get { return character; } }
[Tooltip("Portrait that represents speaking character")] [Tooltip("Portrait that represents speaking character")]
[SerializeField] protected Sprite portrait; [SerializeField] protected Sprite portrait;
public Sprite Portrait { get { return portrait; } set { portrait = value; } } public Sprite Portrait { get { return portrait; } set { portrait = value; } }
[Tooltip("Voiceover audio to play when writing the text")] [Tooltip("Voiceover audio to play when writing the text")]
@ -44,7 +42,6 @@ namespace Fungus
[Tooltip("Type this text in the previous dialog box.")] [Tooltip("Type this text in the previous dialog box.")]
[SerializeField] protected bool extendPrevious = false; [SerializeField] protected bool extendPrevious = false;
public bool ExtendPrevious { get { return extendPrevious; } } public bool ExtendPrevious { get { return extendPrevious; } }
[Tooltip("Fade out the dialog box when writing has finished and not waiting for input.")] [Tooltip("Fade out the dialog box when writing has finished and not waiting for input.")]

4
Assets/Fungus/Narrative/Scripts/Commands/SetLanguage.cs

@ -5,10 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Set the active language for the scene. A Localization object with a localization file must be present in the scene.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Set Language", "Set Language",
"Set the active language for the scene. A Localization object with a localization file must be present in the scene.")] "Set the active language for the scene. A Localization object with a localization file must be present in the scene.")]

5
Assets/Fungus/Narrative/Scripts/Commands/SetMenuDialog.cs

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets a custom menu dialog to use when displaying multiple choice menus.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Set Menu Dialog", "Set Menu Dialog",
"Sets a custom menu dialog to use when displaying multiple choice menus")] "Sets a custom menu dialog to use when displaying multiple choice menus")]

5
Assets/Fungus/Narrative/Scripts/Commands/SetSayDialog.cs

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets a custom say dialog to use when displaying story text.
/// </summary>
[CommandInfo("Narrative", [CommandInfo("Narrative",
"Set Say Dialog", "Set Say Dialog",
"Sets a custom say dialog to use when displaying story text")] "Sets a custom say dialog to use when displaying story text")]

6
Assets/Fungus/Narrative/Scripts/ConversationManager.cs

@ -1,5 +1,4 @@
using System; using System.Collections;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using UnityEngine; using UnityEngine;
@ -7,6 +6,9 @@ using System.Text;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Helper class to manage parsing and executing the conversation format.
/// </summary>
public class ConversationManager public class ConversationManager
{ {
protected struct ConversationItem protected struct ConversationItem

11
Assets/Fungus/Narrative/Scripts/CustomTag.cs

@ -4,30 +4,26 @@
*/ */
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Create custom tags for use in Say text.
/// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
public class CustomTag : MonoBehaviour public class CustomTag : MonoBehaviour
{ {
[SerializeField] protected string tagStartSymbol; [SerializeField] protected string tagStartSymbol;
public string TagStartSymbol { get { return tagStartSymbol; } } public string TagStartSymbol { get { return tagStartSymbol; } }
[SerializeField] protected string tagEndSymbol; [SerializeField] protected string tagEndSymbol;
public string TagEndSymbol { get { return tagEndSymbol; } } public string TagEndSymbol { get { return tagEndSymbol; } }
[SerializeField] protected string replaceTagStartWith; [SerializeField] protected string replaceTagStartWith;
public string ReplaceTagStartWith { get { return replaceTagStartWith; } } public string ReplaceTagStartWith { get { return replaceTagStartWith; } }
[SerializeField] protected string replaceTagEndWith; [SerializeField] protected string replaceTagEndWith;
public string ReplaceTagEndWith { get { return replaceTagEndWith; } } public string ReplaceTagEndWith { get { return replaceTagEndWith; } }
static public List<CustomTag> activeCustomTags = new List<CustomTag>(); static public List<CustomTag> activeCustomTags = new List<CustomTag>();
@ -45,5 +41,4 @@ namespace Fungus
activeCustomTags.Remove(this); activeCustomTags.Remove(this);
} }
} }
} }

23
Assets/Fungus/Narrative/Scripts/DialogInput.cs

@ -5,15 +5,20 @@
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Interface for listening for dialogue input events.
/// </summary>
public interface IDialogInputListener public interface IDialogInputListener
{ {
void OnNextLineEvent(); void OnNextLineEvent();
} }
/// <summary>
/// Input handler for say dialogues.
/// </summary>
public class DialogInput : MonoBehaviour public class DialogInput : MonoBehaviour
{ {
public enum ClickMode public enum ClickMode
@ -44,17 +49,17 @@ namespace Fungus
protected StandaloneInputModule currentStandaloneInputModule; protected StandaloneInputModule currentStandaloneInputModule;
/** /// <summary>
* Trigger next line input event from script. /// Trigger next line input event from script.
*/ /// </summary>
public void SetNextLineFlag() public void SetNextLineFlag()
{ {
nextLineInputFlag = true; nextLineInputFlag = true;
} }
/** /// <summary>
* Set the dialog clicked flag (usually from an Event Trigger component in the dialog UI) /// Set the dialog clicked flag (usually from an Event Trigger component in the dialog UI).
*/ /// </summary>
public void SetDialogClickedFlag() public void SetDialogClickedFlag()
{ {
// Ignore repeat clicks for a short time to prevent accidentally clicking through the character dialogue // Ignore repeat clicks for a short time to prevent accidentally clicking through the character dialogue
@ -157,6 +162,4 @@ namespace Fungus
} }
} }
} }
} }

110
Assets/Fungus/Narrative/Scripts/Localization.cs

@ -7,17 +7,13 @@
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
#endif #endif
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Text; using System.Text;
using System.IO;
using Ideafixxxer.CsvParser; using Ideafixxxer.CsvParser;
namespace Fungus namespace Fungus
{ {
public interface ILocalizable public interface ILocalizable
{ {
string GetStandardText(); string GetStandardText();
@ -26,26 +22,25 @@ namespace Fungus
string GetStringId(); string GetStringId();
} }
/** /// <summary>
* Multi-language localization support. /// Multi-language localization support.
*/ /// </summary>
public class Localization : MonoBehaviour, StringSubstituter.ISubstitutionHandler public class Localization : MonoBehaviour, StringSubstituter.ISubstitutionHandler
{ {
/** /// <summary>
* Language to use at startup, usually defined by a two letter language code (e.g DE = German) /// Language to use at startup, usually defined by a two letter language code (e.g DE = German).
*/ /// </summary>
[Tooltip("Language to use at startup, usually defined by a two letter language code (e.g DE = German)")] [Tooltip("Language to use at startup, usually defined by a two letter language code (e.g DE = German)")]
[SerializeField] protected string activeLanguage = ""; [SerializeField] protected string activeLanguage = "";
public string ActiveLanguage { get { return activeLanguage; } } public string ActiveLanguage { get { return activeLanguage; } }
protected static Dictionary<string, string> localizedStrings = new Dictionary<string, string>(); protected static Dictionary<string, string> localizedStrings = new Dictionary<string, string>();
protected Dictionary<string, ILocalizable> localizeableObjects = new Dictionary<string, ILocalizable>(); protected Dictionary<string, ILocalizable> localizeableObjects = new Dictionary<string, ILocalizable>();
/** /// <summary>
* Temp storage for a single item of standard text and its localizations /// Temp storage for a single item of standard text and its localizations.
*/ /// </summary>
protected class TextItem protected class TextItem
{ {
public string description = ""; public string description = "";
@ -53,17 +48,17 @@ namespace Fungus
public Dictionary<string, string> localizedStrings = new Dictionary<string, string>(); public Dictionary<string, string> localizedStrings = new Dictionary<string, string>();
} }
/** /// <summary>
* CSV file containing localization data which can be easily edited in a spreadsheet tool. /// CSV file containing localization data which can be easily edited in a spreadsheet tool.
*/ /// </summary>
[Tooltip("CSV file containing localization data which can be easily edited in a spreadsheet tool")] [Tooltip("CSV file containing localization data which can be easily edited in a spreadsheet tool")]
[SerializeField] protected TextAsset localizationFile; [SerializeField] protected TextAsset localizationFile;
public TextAsset LocalizationFile { get { return localizationFile; } set { localizationFile = value; } } public TextAsset LocalizationFile { get { return localizationFile; } set { localizationFile = value; } }
/** /// <summary>
* Stores any notification message from export / import methods. /// Stores any notification message from export / import methods.
*/ /// </summary>
protected string notificationText = ""; protected string notificationText = "";
public string NotificationText { get { return notificationText; } set { notificationText = value; } } public string NotificationText { get { return notificationText; } set { notificationText = value; } }
@ -99,10 +94,10 @@ namespace Fungus
Init(); Init();
} }
/** /// <summary>
* String subsitution can happen during the Start of another component, so we /// String subsitution can happen during the Start of another component, so we
* may need to call Init() from other methods. /// may need to call Init() from other methods.
*/ /// </summary>
protected virtual void Init() protected virtual void Init()
{ {
if (initialized) if (initialized)
@ -140,11 +135,11 @@ namespace Fungus
} }
} }
/** /// <summary>
* Looks up the specified string in the localized strings table. /// Looks up the specified string in the localized strings table.
* For this to work, a localization file and active language must have been set previously. /// For this to work, a localization file and active language must have been set previously.
* Return null if the string is not found. /// Return null if the string is not found.
*/ /// </summary>
public static string GetLocalizedString(string stringId) public static string GetLocalizedString(string stringId)
{ {
if (localizedStrings == null) if (localizedStrings == null)
@ -160,9 +155,9 @@ namespace Fungus
return null; return null;
} }
/** /// <summary>
* Convert all text items and localized strings to an easy to edit CSV format. /// Convert all text items and localized strings to an easy to edit CSV format.
*/ /// </summary>
public virtual string GetCSVData() public virtual string GetCSVData()
{ {
// Collect all the text items present in the scene // Collect all the text items present in the scene
@ -222,9 +217,9 @@ namespace Fungus
return csvData; return csvData;
} }
/** /// <summary>
* Builds a dictionary of localizable text items in the scene. /// Builds a dictionary of localizable text items in the scene.
*/ /// </summary>
protected Dictionary<string, TextItem> FindTextItems() protected Dictionary<string, TextItem> FindTextItems()
{ {
Dictionary<string, TextItem> textItems = new Dictionary<string, TextItem>(); Dictionary<string, TextItem> textItems = new Dictionary<string, TextItem>();
@ -275,9 +270,9 @@ namespace Fungus
return textItems; return textItems;
} }
/** /// <summary>
* Adds localized strings from CSV file data to a dictionary of text items in the scene. /// Adds localized strings from CSV file data to a dictionary of text items in the scene.
*/ /// </summary>
protected virtual void AddCSVDataItems(Dictionary<string, TextItem> textItems, string csvData) protected virtual void AddCSVDataItems(Dictionary<string, TextItem> textItems, string csvData)
{ {
CsvParser csvParser = new CsvParser(); CsvParser csvParser = new CsvParser();
@ -342,10 +337,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Scan a localization CSV file and copies the strings for the specified language code /// Scan a localization CSV file and copies the strings for the specified language code
* into the text properties of the appropriate scene objects. /// into the text properties of the appropriate scene objects.
*/ /// </summary>
public virtual void SetActiveLanguage(string languageCode, bool forceUpdateSceneText = false) public virtual void SetActiveLanguage(string languageCode, bool forceUpdateSceneText = false)
{ {
if (!Application.isPlaying) if (!Application.isPlaying)
@ -438,9 +433,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Populates the text property of a single scene object with a new text value. /// Populates the text property of a single scene object with a new text value.
*/ /// </summary>
public virtual bool PopulateTextProperty(string stringId, string newText) public virtual bool PopulateTextProperty(string stringId, string newText)
{ {
// Ensure that all localizeable objects have been cached // Ensure that all localizeable objects have been cached
@ -460,10 +455,10 @@ namespace Fungus
return false; return false;
} }
/** /// <summary>
* Returns all standard text for localizeable text in the scene using an /// Returns all standard text for localizeable text in the scene using an
* easy to edit custom text format. /// easy to edit custom text format.
*/ /// </summary>
public virtual string GetStandardText() public virtual string GetStandardText()
{ {
// Collect all the text items present in the scene // Collect all the text items present in the scene
@ -485,9 +480,9 @@ namespace Fungus
return textData; return textData;
} }
/** /// <summary>
* Sets standard text on scene objects by parsing a text data file. /// Sets standard text on scene objects by parsing a text data file.
*/ /// </summary>
public virtual void SetStandardText(string textData) public virtual void SetStandardText(string textData)
{ {
string[] lines = textData.Split('\n'); string[] lines = textData.Split('\n');
@ -532,10 +527,10 @@ namespace Fungus
notificationText = "Updated " + updatedCount + " standard text items."; notificationText = "Updated " + updatedCount + " standard text items.";
} }
/** /// <summary>
* Implementation of StringSubstituter.ISubstitutionHandler. /// Implementation of StringSubstituter.ISubstitutionHandler.
* Relaces tokens of the form {$KeyName} with the localized value corresponding to that key. /// Replaces tokens of the form {$KeyName} with the localized value corresponding to that key.
*/ /// </summary>
public virtual bool SubstituteStrings(StringBuilder input) public virtual bool SubstituteStrings(StringBuilder input)
{ {
// This method could be called from the Start method of another component, so we // This method could be called from the Start method of another component, so we
@ -565,5 +560,4 @@ namespace Fungus
return modified; return modified;
} }
} }
} }

9
Assets/Fungus/Narrative/Scripts/MenuDialog.cs

@ -5,16 +5,15 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using System.Linq; using System.Linq;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Presents multiple choice buttons to the players.
/// </summary>
public class MenuDialog : MonoBehaviour public class MenuDialog : MonoBehaviour
{ {
// Currently active Menu Dialog used to display Menu options // Currently active Menu Dialog used to display Menu options
@ -24,11 +23,9 @@ namespace Fungus
[SerializeField] protected bool autoSelectFirstButton = false; [SerializeField] protected bool autoSelectFirstButton = false;
protected Button[] cachedButtons; protected Button[] cachedButtons;
public Button[] CachedButtons { get { return cachedButtons; } } public Button[] CachedButtons { get { return cachedButtons; } }
protected Slider cachedSlider; protected Slider cachedSlider;
public Slider CachedSlider { get { return cachedSlider; } } public Slider CachedSlider { get { return cachedSlider; } }
public static MenuDialog GetMenuDialog() public static MenuDialog GetMenuDialog()

23
Assets/Fungus/Narrative/Scripts/PortraitController.cs

@ -4,11 +4,9 @@
*/ */
using UnityEngine; using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI; using UnityEngine.UI;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using MoonSharp.Interpreter; using MoonSharp.Interpreter;
namespace Fungus namespace Fungus
@ -57,11 +55,6 @@ namespace Fungus
moveDuration = 1f; moveDuration = 1f;
this.useDefaultSettings = useDefaultSettings; this.useDefaultSettings = useDefaultSettings;
} }
public override string ToString()
{
return base.ToString();
}
} }
public class PortraitState public class PortraitState
@ -170,7 +163,7 @@ namespace Fungus
} }
private void FinishCommand(PortraitOptions options) protected void FinishCommand(PortraitOptions options)
{ {
if (options.onComplete != null) if (options.onComplete != null)
{ {
@ -194,7 +187,7 @@ namespace Fungus
/// </summary> /// </summary>
/// <param name="options"></param> /// <param name="options"></param>
/// <returns></returns> /// <returns></returns>
private PortraitOptions CleanPortraitOptions(PortraitOptions options) protected PortraitOptions CleanPortraitOptions(PortraitOptions options)
{ {
// Use default stage settings // Use default stage settings
if (options.useDefaultSettings) if (options.useDefaultSettings)
@ -285,7 +278,7 @@ namespace Fungus
/// </summary> /// </summary>
/// <param name="character"></param> /// <param name="character"></param>
/// <param name="fadeDuration"></param> /// <param name="fadeDuration"></param>
private void CreatePortraitObject(Character character, float fadeDuration) protected void CreatePortraitObject(Character character, float fadeDuration)
{ {
// Create a new portrait object // Create a new portrait object
GameObject portraitObj = new GameObject(character.name, GameObject portraitObj = new GameObject(character.name,
@ -312,7 +305,7 @@ namespace Fungus
character.State.portraitImage = portraitImage; character.State.portraitImage = portraitImage;
} }
private IEnumerator WaitUntilFinished(float duration, Action onComplete = null) protected IEnumerator WaitUntilFinished(float duration, Action onComplete = null)
{ {
// Wait until the timer has expired // Wait until the timer has expired
// Any method can modify this timer variable to delay continuing. // Any method can modify this timer variable to delay continuing.
@ -330,7 +323,7 @@ namespace Fungus
} }
} }
private void SetupPortrait(PortraitOptions options) protected void SetupPortrait(PortraitOptions options)
{ {
SetRectTransform(options.character.State.portraitImage.rectTransform, options.fromPosition); SetRectTransform(options.character.State.portraitImage.rectTransform, options.fromPosition);
@ -653,8 +646,8 @@ namespace Fungus
/// <summary> /// <summary>
/// Util functions that I wanted to keep the main class clean of /// Util functions that I wanted to keep the main class clean of
/// </summary> /// </summary>
public class PortraitUtil { public class PortraitUtil
{
/// <summary> /// <summary>
/// Convert a Moonsharp table to portrait options /// Convert a Moonsharp table to portrait options
/// If the table returns a null for any of the parameters, it should keep the defaults /// If the table returns a null for any of the parameters, it should keep the defaults
@ -732,7 +725,6 @@ namespace Fungus
options.shiftIntoPlace = table.Get("shiftIntoPlace").CastToBool(); options.shiftIntoPlace = table.Get("shiftIntoPlace").CastToBool();
} }
//TODO: Make the next lua command wait when this options is true
if (!table.Get("waitUntilFinished").IsNil()) if (!table.Get("waitUntilFinished").IsNil())
{ {
options.waitUntilFinished = table.Get("waitUntilFinished").CastToBool(); options.waitUntilFinished = table.Get("waitUntilFinished").CastToBool();
@ -740,6 +732,5 @@ namespace Fungus
return options; return options;
} }
} }
} }

18
Assets/Fungus/Narrative/Scripts/SayDialog.cs

@ -7,11 +7,12 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Presents story text to the player in a dialogue box.
/// </summary>
public class SayDialog : MonoBehaviour public class SayDialog : MonoBehaviour
{ {
// Currently active Say Dialog used to display Say text // Currently active Say Dialog used to display Say text
@ -20,17 +21,24 @@ namespace Fungus
// Most recent speaking character // Most recent speaking character
public static Character speakingCharacter; public static Character speakingCharacter;
[Tooltip("Duration to fade dialogue in/out")]
[SerializeField] protected float fadeDuration = 0.25f; [SerializeField] protected float fadeDuration = 0.25f;
[Tooltip("The continue button UI object")]
[SerializeField] protected Button continueButton; [SerializeField] protected Button continueButton;
[Tooltip("The canvas UI object")]
[SerializeField] protected Canvas dialogCanvas; [SerializeField] protected Canvas dialogCanvas;
[Tooltip("The name text UI object")]
[SerializeField] protected Text nameText; [SerializeField] protected Text nameText;
[SerializeField] protected Text storyText;
[Tooltip("The story text UI object")]
[SerializeField] protected Text storyText;
public Text StoryText { get { return storyText; } } public Text StoryText { get { return storyText; } }
[Tooltip("The character UI object")]
[SerializeField] protected Image characterImage; [SerializeField] protected Image characterImage;
public Image CharacterImage { get { return characterImage; } } public Image CharacterImage { get { return characterImage; } }
[Tooltip("Adjust width of story text when Character Image is displayed (to avoid overlapping)")] [Tooltip("Adjust width of story text when Character Image is displayed (to avoid overlapping)")]

15
Assets/Fungus/Narrative/Scripts/Stage.cs

@ -5,53 +5,44 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.Events;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Define a set of screen positions where character sprites can be displayed.
/// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
public class Stage : PortraitController public class Stage : PortraitController
{ {
[SerializeField] protected Canvas portraitCanvas; [SerializeField] protected Canvas portraitCanvas;
public Canvas PortraitCanvas { get { return portraitCanvas; } } public Canvas PortraitCanvas { get { return portraitCanvas; } }
[SerializeField] protected bool dimPortraits; [SerializeField] protected bool dimPortraits;
public bool DimPortraits { get { return dimPortraits; } set { dimPortraits = value; } } public bool DimPortraits { get { return dimPortraits; } set { dimPortraits = value; } }
[SerializeField] protected float fadeDuration = 0.5f; [SerializeField] protected float fadeDuration = 0.5f;
public float FadeDuration { get { return fadeDuration; } set { fadeDuration = value; } } public float FadeDuration { get { return fadeDuration; } set { fadeDuration = value; } }
[SerializeField] protected float moveDuration = 1f; [SerializeField] protected float moveDuration = 1f;
public float MoveDuration { get { return moveDuration; } set { moveDuration = value; } } public float MoveDuration { get { return moveDuration; } set { moveDuration = value; } }
[SerializeField] protected LeanTweenType fadeEaseType; [SerializeField] protected LeanTweenType fadeEaseType;
public LeanTweenType FadeEaseType { get { return fadeEaseType; } } public LeanTweenType FadeEaseType { get { return fadeEaseType; } }
[SerializeField] protected Vector2 shiftOffset; [SerializeField] protected Vector2 shiftOffset;
public Vector2 ShiftOffset { get { return shiftOffset; } } public Vector2 ShiftOffset { get { return shiftOffset; } }
[SerializeField] protected Image defaultPosition; [SerializeField] protected Image defaultPosition;
public Image DefaultPosition { get { return defaultPosition; } } public Image DefaultPosition { get { return defaultPosition; } }
[SerializeField] protected List<RectTransform> positions; [SerializeField] protected List<RectTransform> positions;
public List<RectTransform> Positions { get { return positions; } } public List<RectTransform> Positions { get { return positions; } }
[SerializeField] protected RectTransform[] cachedPositions; [SerializeField] protected RectTransform[] cachedPositions;
protected List<Character> charactersOnStage = new List<Character>(); protected List<Character> charactersOnStage = new List<Character>();
[SerializeField] public List<Character> CharactersOnStage { get { return charactersOnStage; } } [SerializeField] public List<Character> CharactersOnStage { get { return charactersOnStage; } }
static public List<Stage> activeStages = new List<Stage>(); static public List<Stage> activeStages = new List<Stage>();

Loading…
Cancel
Save