Browse Source

Added WriterGlyph signal

master
Christopher 8 years ago
parent
commit
06942b0583
  1. 2
      Assets/Fungus/Scripts/Components/Writer.cs
  2. 7
      Assets/Fungus/Scripts/Signals/WriterSignals.cs
  3. 13
      Assets/Tests/Signals/WriterSignalsTester.cs

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

@ -736,6 +736,8 @@ namespace Fungus
protected virtual void NotifyGlyph()
{
WriterSignals.DoWriterGlyph(this);
foreach (IWriterListener writerListener in writerListeners)
{
writerListener.OnGlyph();

7
Assets/Fungus/Scripts/Signals/WriterSignals.cs

@ -32,6 +32,13 @@ namespace Fungus
public static event WriterInputHandler OnWriterInput;
public static void DoWriterInput(Writer writer) { if (OnWriterInput != null) OnWriterInput(writer); }
/// <summary>
/// WriterGlyph signal. Sent when the writer writes out a glyph.
/// </summary>
public delegate void WriterGlyphHandler(Writer writer);
public static event WriterGlyphHandler OnWriterGlyph;
public static void DoWriterGlyph(Writer writer) { if (OnWriterGlyph != null) OnWriterGlyph(writer); }
#endregion
}
}

13
Assets/Tests/Signals/WriterSignalsTester.cs

@ -11,12 +11,14 @@ namespace Fungus
{
int correctTagCount = 0;
bool receivedInput = false;
int glyphCount = 0;
void OnEnable()
{
WriterSignals.OnTextTagToken += OnTextTagToken;
WriterSignals.OnWriterState += OnWriterState;
WriterSignals.OnWriterInput += OnWriterInput;
WriterSignals.OnWriterGlyph += OnWriterGlyph;
}
void OnDisable()
@ -24,6 +26,7 @@ namespace Fungus
WriterSignals.OnTextTagToken -= OnTextTagToken;
WriterSignals.OnWriterState -= OnWriterState;
WriterSignals.OnWriterInput -= OnWriterInput;
WriterSignals.OnWriterGlyph -= OnWriterGlyph;
}
void OnTextTagToken(Writer writer, TextTagToken token, int index, int maxIndex)
@ -72,6 +75,11 @@ namespace Fungus
IntegrationTest.Fail();
}
if (glyphCount != 6)
{
IntegrationTest.Fail();
}
IntegrationTest.Pass();
}
}
@ -80,5 +88,10 @@ namespace Fungus
{
receivedInput = true;
}
void OnWriterGlyph(Writer writer)
{
glyphCount++;
}
}
}
Loading…
Cancel
Save