From 02d0d74982f4d4e331f45ef4b0edae51cb5b0d90 Mon Sep 17 00:00:00 2001
From: Christopher <chrisgregan@gmail.com>
Date: Mon, 12 Sep 2016 13:19:41 +0100
Subject: [PATCH] Moved all public methods to IMenuDialog

---
 .../Fungus/Narrative/Scripts/IMenuDialog.cs   | 23 ++++++
 Assets/Fungus/Narrative/Scripts/MenuDialog.cs | 78 ++++++++++---------
 2 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/Assets/Fungus/Narrative/Scripts/IMenuDialog.cs b/Assets/Fungus/Narrative/Scripts/IMenuDialog.cs
index 383a298b..a909cd5f 100644
--- a/Assets/Fungus/Narrative/Scripts/IMenuDialog.cs
+++ b/Assets/Fungus/Narrative/Scripts/IMenuDialog.cs
@@ -1,4 +1,5 @@
 using UnityEngine;
+using UnityEngine.UI;
 
 namespace Fungus
 {
@@ -7,11 +8,33 @@ namespace Fungus
     /// </summary>
     public interface IMenuDialog
     {
+        /// <summary>
+        /// A cached list of button objects in the menu dialog.
+        /// </summary>
+        /// <value>The cached buttons.</value>
+        Button[] CachedButtons { get; }
+
+        /// <summary>
+        /// A cached slider object used for the timer in the menu dialog.
+        /// </summary>
+        /// <value>The cached slider.</value>
+        Slider CachedSlider { get; }
+
         /// <summary>
         /// Sets the active state of the Menu Dialog gameobject.
         /// </summary>
         void SetActive(bool state);
 
+        /// <summary>
+        /// Clear all displayed options in the Menu Dialog.
+        /// </summary>
+        void Clear();
+
+        /// <summary>
+        /// Hides any currently displayed Say Dialog.
+        /// </summary>
+        void HideSayDialog();
+
         /// <summary>
         /// Adds the option to the list of displayed options.
         /// Will cause the Menu dialog to become visible if it is not already visible.
diff --git a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs
index 0af34784..53e07209 100644
--- a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs
+++ b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs
@@ -18,10 +18,8 @@ namespace Fungus
         [SerializeField] protected bool autoSelectFirstButton = false;
 
         protected Button[] cachedButtons;
-        public virtual Button[] CachedButtons { get { return cachedButtons; } }
 
         protected Slider cachedSlider;
-        public virtual Slider CachedSlider { get { return cachedSlider; } }
 
         public static IMenuDialog GetMenuDialog()
         {
@@ -51,7 +49,7 @@ namespace Fungus
             return activeMenuDialog;
         }
 
-        public virtual void Awake()
+        protected virtual void Awake()
         {
             Button[] optionButtons = GetComponentsInChildren<Button>();
             cachedButtons = optionButtons;
@@ -66,47 +64,13 @@ namespace Fungus
             }
         }
 
-        public virtual void OnEnable()
+        protected virtual void OnEnable()
         {
             // The canvas may fail to update if the menu dialog is enabled in the first game frame.
             // To fix this we just need to force a canvas update when the object is enabled.
             Canvas.ForceUpdateCanvases();
         }
 
-        public virtual void Clear()
-        {
-            StopAllCoroutines();
-
-            Button[] optionButtons = GetComponentsInChildren<Button>();                     
-            foreach (UnityEngine.UI.Button button in optionButtons)
-            {
-                button.onClick.RemoveAllListeners();
-            }
-            
-            foreach (UnityEngine.UI.Button button in optionButtons)
-            {
-                if (button != null)
-                {
-                    button.gameObject.SetActive(false);
-                }
-            }
-
-            Slider timeoutSlider = GetComponentInChildren<Slider>();
-            if (timeoutSlider != null)
-            {
-                timeoutSlider.gameObject.SetActive(false);
-            }
-        }
-
-        public virtual void HideSayDialog()
-        {
-            ISayDialog sayDialog = SayDialog.GetSayDialog();
-            if (sayDialog != null)
-            {
-                sayDialog.FadeWhenDone = true;
-            }
-        }
-
         protected virtual IEnumerator WaitForTimeout(float timeoutDuration, Block targetBlock)
         {
             float elapsedTime = 0;
@@ -139,11 +103,49 @@ namespace Fungus
 
         #region IMenuDialog implementation
 
+        public virtual Button[] CachedButtons { get { return cachedButtons; } }
+
+        public virtual Slider CachedSlider { get { return cachedSlider; } }
+
         public virtual void SetActive(bool state)
         {
             gameObject.SetActive(state);
         }
 
+        public virtual void Clear()
+        {
+            StopAllCoroutines();
+
+            Button[] optionButtons = GetComponentsInChildren<Button>();                     
+            foreach (UnityEngine.UI.Button button in optionButtons)
+            {
+                button.onClick.RemoveAllListeners();
+            }
+
+            foreach (UnityEngine.UI.Button button in optionButtons)
+            {
+                if (button != null)
+                {
+                    button.gameObject.SetActive(false);
+                }
+            }
+
+            Slider timeoutSlider = GetComponentInChildren<Slider>();
+            if (timeoutSlider != null)
+            {
+                timeoutSlider.gameObject.SetActive(false);
+            }
+        }
+
+        public virtual void HideSayDialog()
+        {
+            ISayDialog sayDialog = SayDialog.GetSayDialog();
+            if (sayDialog != null)
+            {
+                sayDialog.FadeWhenDone = true;
+            }
+        }
+            
         public virtual bool AddOption(string text, bool interactable, Block targetBlock)
         {
             bool addedOption = false;