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;
/**
* 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.

35
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
{

6
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);
}

BIN
Assets/FungusExample/Scenes/Example.unity

Binary file not shown.
Loading…
Cancel
Save