From c38e9151194228a39129e341f17c5aefb0a88b1d Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 23 Jun 2014 11:50:19 +0100 Subject: [PATCH] Fixed buttons not hiding when new Dialog is writing text. Added IDialog.GetDialogMode() to query current Dialog state. --- Assets/Fungus/Legacy/PageController.cs | 23 ++++++++++++++ Assets/Fungus/Scripts/Dialog.cs | 35 ++++++++++++++-------- Assets/Fungus/Scripts/Game.cs | 6 ++-- Assets/FungusExample/Scenes/Example.unity | Bin 95656 -> 95616 bytes 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/Assets/Fungus/Legacy/PageController.cs b/Assets/Fungus/Legacy/PageController.cs index 695c03a7..395f8522 100644 --- a/Assets/Fungus/Legacy/PageController.cs +++ b/Assets/Fungus/Legacy/PageController.cs @@ -142,6 +142,29 @@ namespace Fungus float quickContinueTimer; + /** + * Translates the PageController specific Mode to the more generic DialogMode. + */ + public DialogMode GetDialogMode() + { + switch(mode) + { + case Mode.Say: + case Mode.Choose: + if (FinishedWriting()) + { + return DialogMode.Waiting; + } + else + { + return DialogMode.Writing; + } + case Mode.Idle: + default: + return DialogMode.Idle; + } + } + /** * Calculate a screen space rectangle given normalized screen space coords. * The resulting rect is clamped to always be on-screen. diff --git a/Assets/Fungus/Scripts/Dialog.cs b/Assets/Fungus/Scripts/Dialog.cs index 0c654c22..f7d11803 100644 --- a/Assets/Fungus/Scripts/Dialog.cs +++ b/Assets/Fungus/Scripts/Dialog.cs @@ -5,12 +5,30 @@ using System.Collections.Generic; namespace Fungus { + /** + * Permitted states for Dialogs. + */ + public enum DialogMode + { + /// Dialog has no pending content to display so is not shown. + Idle, + /// Dialog is currently writing out content. + Writing, + /// Dialog has finished writing out content and is waiting for player input. + Waiting + } + /** * Interface for Dialog implementations. * This allows us to introduce new types of Dialog in future. */ public interface IDialog { + /** + * Returns the current state of the Dialog. + */ + DialogMode GetDialogMode(); + /** * Display a line of story text. * If any options have previously been added using AddOption(), these will be displayed and the @@ -228,21 +246,12 @@ namespace Fungus */ public GUIStyle buttonStyle; - /** - * Allowed states for dialog - */ - public enum DialogMode + DialogMode dialogMode; + + public DialogMode GetDialogMode() { - Idle, - Writing, - Waiting + return dialogMode; } - - /** - * Current state of dialog - */ - [HideInInspector] - public DialogMode dialogMode; class Option { diff --git a/Assets/Fungus/Scripts/Game.cs b/Assets/Fungus/Scripts/Game.cs index 85dc9fb5..a78d81a3 100644 --- a/Assets/Fungus/Scripts/Game.cs +++ b/Assets/Fungus/Scripts/Game.cs @@ -154,8 +154,10 @@ namespace Fungus return false; } - if (pageController == null || - pageController.mode == PageController.Mode.Idle) + IDialog dialog = GetDialog(); + + if (dialog == null || + dialog.GetDialogMode() == DialogMode.Idle) { return (autoHideButtonTimer > 0f); } diff --git a/Assets/FungusExample/Scenes/Example.unity b/Assets/FungusExample/Scenes/Example.unity index c39fa2e31a3908fe718f1e0bd5b4350bae07299d..90db1f79881f1a09a4e7fb833cf60bac311e82db 100644 GIT binary patch delta 2009 zcmZA1Uu;uV9KiA4b(=7RP-P~=5VMe&%ow#Qu+Fhi6Smapx^5tJ$e+UgSQ5dpFxjTv zZ6d}^5f?R)7vd6M?t_^#)s^@(70n)qR5uc0DlUkoGGX0dWC~+`?|QDB>%&QIKmDEa z`<-)s_ga$$@yP;@7)!^+=!lC*A#`MYG+J{Web&9;d)NTBRV(I;*_z#RnBH(- zV$m8cj{GtVj({Pa|53Y3VxH&RNyhiTxu@4Q?X-EUptdqng3)g{Gr_H)W_qZ^C9QS})>f^0X?j1+y?cNh>A|?&E(6^I>{p{_y>U z)**}>x%c0`=d+-9i^%IdJKdVH12O$Rf5bAFzTi(-gi4~!&8h;g@0^d0V*2Yji1>jJ#2p>b)qsHA>7SngK42!mitRrSl6}U2(9~;1E8)tXo!R9cg|JT$rTmFbe tT18TJfy;U2?A@$AxV*=ktj;si1t0Yn8cULE3yndq{g|Ijmm6m){smg3=fnU2 delta 2050 zcmZA1TTC2P7{Kvwx~wj>O;^PPjTd5Kf-&l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