Browse Source

Fixed buttons not hiding when new Dialog is writing text.

Added IDialog.GetDialogMode() to query current Dialog state.
master
chrisgregan 11 years ago
parent
commit
c38e915119
  1. 23
      Assets/Fungus/Legacy/PageController.cs
  2. 35
      Assets/Fungus/Scripts/Dialog.cs
  3. 6
      Assets/Fungus/Scripts/Game.cs
  4. BIN
      Assets/FungusExample/Scenes/Example.unity

23
Assets/Fungus/Legacy/PageController.cs

@ -142,6 +142,29 @@ namespace Fungus
float quickContinueTimer; 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. * Calculate a screen space rectangle given normalized screen space coords.
* The resulting rect is clamped to always be on-screen. * The resulting rect is clamped to always be on-screen.

35
Assets/Fungus/Scripts/Dialog.cs

@ -5,12 +5,30 @@ using System.Collections.Generic;
namespace Fungus 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. * Interface for Dialog implementations.
* This allows us to introduce new types of Dialog in future. * This allows us to introduce new types of Dialog in future.
*/ */
public interface IDialog public interface IDialog
{ {
/**
* Returns the current state of the Dialog.
*/
DialogMode GetDialogMode();
/** /**
* Display a line of story text. * Display a line of story text.
* If any options have previously been added using AddOption(), these will be displayed and the * If any options have previously been added using AddOption(), these will be displayed and the
@ -228,22 +246,13 @@ namespace Fungus
*/ */
public GUIStyle buttonStyle; public GUIStyle buttonStyle;
/** DialogMode dialogMode;
* Allowed states for dialog
*/ public DialogMode GetDialogMode()
public enum DialogMode
{ {
Idle, return dialogMode;
Writing,
Waiting
} }
/**
* Current state of dialog
*/
[HideInInspector]
public DialogMode dialogMode;
class Option class Option
{ {
public string optionText; public string optionText;

6
Assets/Fungus/Scripts/Game.cs

@ -154,8 +154,10 @@ namespace Fungus
return false; return false;
} }
if (pageController == null || IDialog dialog = GetDialog();
pageController.mode == PageController.Mode.Idle)
if (dialog == null ||
dialog.GetDialogMode() == DialogMode.Idle)
{ {
return (autoHideButtonTimer > 0f); return (autoHideButtonTimer > 0f);
} }

BIN
Assets/FungusExample/Scenes/Example.unity

Binary file not shown.
Loading…
Cancel
Save