Browse Source

Moved all public static methods to Public method region

master
Christopher 8 years ago
parent
commit
5053d2fc4a
  1. 2
      Assets/Fungus/Scripts/Commands/Menu.cs
  2. 4
      Assets/Fungus/Scripts/Commands/Say.cs
  3. 2
      Assets/Fungus/Scripts/Commands/SetMenuDialog.cs
  4. 2
      Assets/Fungus/Scripts/Commands/SetSayDialog.cs
  5. 31
      Assets/Fungus/Scripts/Components/CameraController.cs
  6. 6
      Assets/Fungus/Scripts/Components/DialogInput.cs
  7. 38
      Assets/Fungus/Scripts/Components/Flowchart.cs
  8. 40
      Assets/Fungus/Scripts/Components/Localization.cs
  9. 67
      Assets/Fungus/Scripts/Components/MenuDialog.cs
  10. 2
      Assets/Fungus/Scripts/Components/MusicController.cs
  11. 29
      Assets/Fungus/Scripts/Components/PortraitController.cs
  12. 78
      Assets/Fungus/Scripts/Components/SayDialog.cs
  13. 7
      Assets/Fungus/Scripts/Components/Stage.cs
  14. 102
      Assets/Fungus/Scripts/Components/Writer.cs
  15. 2
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaUtils.cs
  16. 4
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Utils/FungusPrefs.cs

2
Assets/Fungus/Scripts/Commands/Menu.cs

@ -41,7 +41,7 @@ namespace Fungus.Commands
if (setMenuDialog != null)
{
// Override the active menu dialog
MenuDialog.activeMenuDialog = setMenuDialog;
MenuDialog.ActiveMenuDialog = setMenuDialog;
}
bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0);

4
Assets/Fungus/Scripts/Commands/Say.cs

@ -69,12 +69,12 @@ namespace Fungus.Commands
// Override the active say dialog if needed
if (character != null && character.SetSayDialog != null)
{
SayDialog.activeSayDialog = character.SetSayDialog;
SayDialog.ActiveSayDialog = character.SetSayDialog;
}
if (setSayDialog != null)
{
SayDialog.activeSayDialog = setSayDialog;
SayDialog.ActiveSayDialog = setSayDialog;
}
var sayDialog = SayDialog.GetSayDialog();

2
Assets/Fungus/Scripts/Commands/SetMenuDialog.cs

@ -21,7 +21,7 @@ namespace Fungus.Commands
{
if (menuDialog != null)
{
MenuDialog.activeMenuDialog = menuDialog;
MenuDialog.ActiveMenuDialog = menuDialog;
}
Continue();

2
Assets/Fungus/Scripts/Commands/SetSayDialog.cs

@ -21,7 +21,7 @@ namespace Fungus.Commands
{
if (sayDialog != null)
{
SayDialog.activeSayDialog = sayDialog;
SayDialog.ActiveSayDialog = sayDialog;
}
Continue();

31
Assets/Fungus/Scripts/Components/CameraController.cs

@ -68,20 +68,6 @@ namespace Fungus
return instance;
}
public static Texture2D CreateColorTexture(Color color, int width, int height)
{
Color[] pixels = new Color[width * height];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = color;
}
Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
texture.SetPixels(pixels);
texture.Apply();
return texture;
}
protected virtual void OnGUI()
{
if (swipePanActive)
@ -366,6 +352,23 @@ namespace Fungus
#region Public methods
/// <summary>
/// Creates a flat colored texture.
/// </summary>
public static Texture2D CreateColorTexture(Color color, int width, int height)
{
Color[] pixels = new Color[width * height];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = color;
}
Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
texture.SetPixels(pixels);
texture.Apply();
return texture;
}
/// <summary>
/// Full screen texture used for screen fade effect.
/// </summary>

6
Assets/Fungus/Scripts/Components/DialogInput.cs

@ -102,9 +102,9 @@ namespace Fungus
if (ignoreMenuClicks)
{
// Ignore input events if a Menu is being displayed
if (MenuDialog.activeMenuDialog != null &&
MenuDialog.activeMenuDialog.IsActive() &&
MenuDialog.activeMenuDialog.DisplayedOptionsCount > 0)
if (MenuDialog.ActiveMenuDialog != null &&
MenuDialog.ActiveMenuDialog.IsActive() &&
MenuDialog.ActiveMenuDialog.DisplayedOptionsCount > 0)
{
dialogClickedFlag = false;
nextLineInputFlag = false;

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

@ -86,28 +86,12 @@ 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 List<Flowchart> cachedFlowcharts = new List<Flowchart>();
protected static bool eventSystemPresent;
protected StringSubstituter stringSubstituer;
/// <summary>
/// Cached list of flowchart objects in the scene for fast lookup.
/// </summary>
public static List<Flowchart> cachedFlowcharts = new List<Flowchart>();
/// <summary>
/// Sends a message to all Flowchart objects in the current scene.
/// Any block with a matching MessageReceived event handler will start executing.
/// </summary>
public static void BroadcastFungusMessage(string messageName)
{
MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>();
foreach (MessageReceived eventHandler in eventHandlers)
{
eventHandler.OnSendFungusMessage(messageName);
}
}
#if UNITY_5_4_OR_NEWER
protected virtual void Awake()
{
@ -288,6 +272,24 @@ namespace Fungus
#region Public methods
/// <summary>
/// Cached list of flowchart objects in the scene for fast lookup.
/// </summary>
public static List<Flowchart> CachedFlowcharts { get { return cachedFlowcharts; } }
/// <summary>
/// Sends a message to all Flowchart objects in the current scene.
/// Any block with a matching MessageReceived event handler will start executing.
/// </summary>
public static void BroadcastFungusMessage(string messageName)
{
MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>();
foreach (MessageReceived eventHandler in eventHandlers)
{
eventHandler.OnSendFungusMessage(messageName);
}
}
/// <summary>
/// Scroll position of Flowchart editor window.
/// </summary>

40
Assets/Fungus/Scripts/Components/Localization.cs

@ -93,26 +93,6 @@ namespace Fungus
initialized = true;
}
/// <summary>
/// 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.
/// Return null if the string is not found.
/// </summary>
public static string GetLocalizedString(string stringId)
{
if (localizedStrings == null)
{
return null;
}
if (localizedStrings.ContainsKey(stringId))
{
return localizedStrings[stringId];
}
return null;
}
// Build a cache of all the localizeable objects in the scene
protected virtual void CacheLocalizeableObjects()
{
@ -249,6 +229,26 @@ namespace Fungus
#region Public methods
/// <summary>
/// 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.
/// Return null if the string is not found.
/// </summary>
public static string GetLocalizedString(string stringId)
{
if (localizedStrings == null)
{
return null;
}
if (localizedStrings.ContainsKey(stringId))
{
return localizedStrings[stringId];
}
return null;
}
/// <summary>
/// Language to use at startup, usually defined by a two letter language code (e.g DE = German).
/// </summary>

67
Assets/Fungus/Scripts/Components/MenuDialog.cs

@ -22,37 +22,6 @@ namespace Fungus
protected Slider cachedSlider;
// Currently active Menu Dialog used to display Menu options
public static MenuDialog activeMenuDialog;
public static MenuDialog GetMenuDialog()
{
if (activeMenuDialog == null)
{
// Use first Menu Dialog found in the scene (if any)
var md = GameObject.FindObjectOfType<MenuDialog>();
if (md != null)
{
activeMenuDialog = md;
}
if (activeMenuDialog == null)
{
// Auto spawn a menu dialog object from the prefab
GameObject prefab = Resources.Load<GameObject>("Prefabs/MenuDialog");
if (prefab != null)
{
GameObject go = Instantiate(prefab) as GameObject;
go.SetActive(false);
go.name = "MenuDialog";
activeMenuDialog = go.GetComponent<MenuDialog>();
}
}
}
return activeMenuDialog;
}
protected virtual void Awake()
{
Button[] optionButtons = GetComponentsInChildren<Button>();
@ -107,6 +76,42 @@ namespace Fungus
#region Public methods
/// <summary>
/// Currently active Menu Dialog used to display Menu options
/// </summary>
public static MenuDialog ActiveMenuDialog { get; set; }
/// <summary>
/// Returns a menu dialog by searching for one in the scene or creating one if none exists.
/// </summary>
public static MenuDialog GetMenuDialog()
{
if (ActiveMenuDialog == null)
{
// Use first Menu Dialog found in the scene (if any)
var md = GameObject.FindObjectOfType<MenuDialog>();
if (md != null)
{
ActiveMenuDialog = md;
}
if (ActiveMenuDialog == null)
{
// Auto spawn a menu dialog object from the prefab
GameObject prefab = Resources.Load<GameObject>("Prefabs/MenuDialog");
if (prefab != null)
{
GameObject go = Instantiate(prefab) as GameObject;
go.SetActive(false);
go.name = "MenuDialog";
ActiveMenuDialog = go.GetComponent<MenuDialog>();
}
}
}
return ActiveMenuDialog;
}
/// <summary>
/// A cached list of button objects in the menu dialog.
/// </summary>

2
Assets/Fungus/Scripts/Components/MusicController.cs

@ -35,7 +35,7 @@ namespace Fungus
GetComponent<AudioSource>().playOnAwake = false;
GetComponent<AudioSource>().loop = true;
}
#region Public methods
/// <summary>

29
Assets/Fungus/Scripts/Components/PortraitController.cs

@ -63,19 +63,6 @@ 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<Stage>();
@ -294,6 +281,22 @@ namespace Fungus
#region Public methods
/// <summary>
/// Performs a deep copy of all values from one RectTransform to another.
/// </summary>
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;
}
/// <summary>
/// Using all portrait options available, run any portrait command.
/// </summary>

78
Assets/Fungus/Scripts/Components/SayDialog.cs

@ -49,40 +49,9 @@ namespace Fungus
protected Sprite currentCharacterImage;
// Currently active Say Dialog used to display Say text
public static SayDialog activeSayDialog;
// Most recent speaking character
public static Character speakingCharacter;
protected static Character speakingCharacter;
public static SayDialog GetSayDialog()
{
if (activeSayDialog == null)
{
// Use first Say Dialog found in the scene (if any)
SayDialog sd = GameObject.FindObjectOfType<SayDialog>();
if (sd != null)
{
activeSayDialog = sd;
}
if (activeSayDialog == null)
{
// Auto spawn a say dialog object from the prefab
GameObject prefab = Resources.Load<GameObject>("Prefabs/SayDialog");
if (prefab != null)
{
GameObject go = Instantiate(prefab) as GameObject;
go.SetActive(false);
go.name = "SayDialog";
activeSayDialog = go.GetComponent<SayDialog>();
}
}
}
return activeSayDialog;
}
protected Writer GetWriter()
{
if (writer != null)
@ -213,6 +182,47 @@ namespace Fungus
}
}
#region Public methods
/// <summary>
/// Currently active Say Dialog used to display Say text
/// </summary>
public static SayDialog ActiveSayDialog { get; set; }
/// <summary>
/// Returns a SayDialog by searching for one in the scene or creating one if none exists.
/// </summary>
public static SayDialog GetSayDialog()
{
if (ActiveSayDialog == null)
{
// Use first Say Dialog found in the scene (if any)
SayDialog sd = GameObject.FindObjectOfType<SayDialog>();
if (sd != null)
{
ActiveSayDialog = sd;
}
if (ActiveSayDialog == null)
{
// Auto spawn a say dialog object from the prefab
GameObject prefab = Resources.Load<GameObject>("Prefabs/SayDialog");
if (prefab != null)
{
GameObject go = Instantiate(prefab) as GameObject;
go.SetActive(false);
go.name = "SayDialog";
ActiveSayDialog = go.GetComponent<SayDialog>();
}
}
}
return ActiveSayDialog;
}
/// <summary>
/// Stops all active portrait tweens.
/// </summary>
public static void StopPortraitTweens()
{
// Stop all tweening portraits
@ -223,7 +233,7 @@ namespace Fungus
if (LeanTween.isTweening(c.State.portraitImage.gameObject))
{
LeanTween.cancel(c.State.portraitImage.gameObject, true);
PortraitController.SetRectTransform(c.State.portraitImage.rectTransform, c.State.position);
if (c.State.dimmed == true)
{
@ -238,8 +248,6 @@ namespace Fungus
}
}
#region Public methods
/// <summary>
/// Sets the active state of the Say Dialog gameobject.
/// </summary>

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

@ -65,6 +65,11 @@ namespace Fungus
}
}
#region Public methods
/// <summary>
/// Returns the currently active stage.
/// </summary>
public static Stage GetActiveStage()
{
if (Stage.activeStages == null ||
@ -76,8 +81,6 @@ namespace Fungus
return Stage.activeStages[0];
}
#region Public methods
/// <summary>
/// Canvas object containing the stage positions.
/// </summary>

102
Assets/Fungus/Scripts/Components/Writer.cs

@ -75,51 +75,6 @@ namespace Fungus
protected string hiddenColorOpen = "";
protected string hiddenColorClose = "";
public virtual string text
{
get
{
if (textUI != null)
{
return textUI.text;
}
else if (inputField != null)
{
return inputField.text;
}
else if (textMesh != null)
{
return textMesh.text;
}
else if (textProperty != null)
{
return textProperty.GetValue(textComponent, null) as string;
}
return "";
}
set
{
if (textUI != null)
{
textUI.text = value;
}
else if (inputField != null)
{
inputField.text = value;
}
else if (textMesh != null)
{
textMesh.text = value;
}
else if (textProperty != null)
{
textProperty.SetValue(textComponent, value, null);
}
}
}
protected virtual void Awake()
{
GameObject go = targetTextObject;
@ -346,7 +301,7 @@ namespace Fungus
break;
case TokenType.Clear:
text = "";
Text = "";
break;
case TokenType.SpeedStart:
@ -500,7 +455,7 @@ namespace Fungus
param = param.TrimStart(' ', '\t', '\r', '\n');
}
string startText = text;
string startText = Text;
UpdateOpenMarkup();
UpdateCloseMarkup();
@ -516,7 +471,7 @@ namespace Fungus
PartitionString(writeWholeWords, param, i);
ConcatenateString(startText);
text = outputString.ToString();
Text = outputString.ToString();
NotifyGlyph();
@ -716,7 +671,6 @@ namespace Fungus
}
}
protected virtual void NotifyStart(AudioClip audioClip)
{
foreach (IWriterListener writerListener in writerListeners)
@ -759,6 +713,54 @@ namespace Fungus
#region Public methods
/// <summary>
/// Gets or sets the text property of the attached text object.
/// </summary>
public virtual string Text
{
get
{
if (textUI != null)
{
return textUI.text;
}
else if (inputField != null)
{
return inputField.text;
}
else if (textMesh != null)
{
return textMesh.text;
}
else if (textProperty != null)
{
return textProperty.GetValue(textComponent, null) as string;
}
return "";
}
set
{
if (textUI != null)
{
textUI.text = value;
}
else if (inputField != null)
{
inputField.text = value;
}
else if (textMesh != null)
{
textMesh.text = value;
}
else if (textProperty != null)
{
textProperty.SetValue(textComponent, value, null);
}
}
}
/// <summary>
/// This property is true when the writer is writing text or waiting (i.e. still processing tokens).
/// </summary>
@ -793,7 +795,7 @@ namespace Fungus
{
if (clear)
{
this.text = "";
this.Text = "";
}
if (!HasTextObject())

2
Assets/Fungus/Thirdparty/FungusLua/Scripts/Components/LuaUtils.cs vendored

@ -432,7 +432,7 @@ namespace Fungus
public void SetSayDialog(SayDialog sayDialog)
{
SayDialog.activeSayDialog = sayDialog;
SayDialog.ActiveSayDialog = sayDialog;
}
#endregion

4
Assets/Fungus/Thirdparty/FungusLua/Scripts/Utils/FungusPrefs.cs vendored

@ -11,6 +11,8 @@ namespace Fungus
/// </summary>
public static class FungusPrefs
{
#region Public methods
/// <summary>
/// Deletes all saved values for all slots.
/// </summary>
@ -106,5 +108,7 @@ namespace Fungus
{
return slot.ToString() + ":" + key;
}
#endregion
}
}
Loading…
Cancel
Save