Skip to content

Commit

Permalink
reorganize _fancy_say_update for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Apr 21, 2024
1 parent 42a3e0d commit c76e3fe
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions fancy_demo/fancy.asc
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ DynamicSprite* FancyTypedText::CreateTypedSprite()

bool get_IsTextBeingTyped(this FancyTypedText*)
{
return !String.IsNullOrEmpty(this._text) && (this._typed_token_count < this._tk_count && this._typed_token_len != -1);
return !String.IsNullOrEmpty(this._text) && !(this._typed_token_count == this._tk_count && this._typed_token_len == -1);
}

void FancyTypedText::Skip()
Expand Down Expand Up @@ -1140,59 +1140,62 @@ void FancySayTyped(this Character*, const string text, FancyConfig* config, int

void _fancy_say_update()
{
bool started_speech;
Overlay* curSpeech = Speech.TextOverlay;

if(_say_delay_end)

// Hack to avoid blink when skipping typed text
if (_say_delay_end)
{
if(_say_ovr_tmp != null) {
if (_say_ovr_tmp)
_say_ovr_tmp.Remove();
_say_ovr_tmp = null;
}
_say_ovr_tmp = null;
_say_delay_end = false;
}

bool is_fancy_say = !String.IsNullOrEmpty(_sayft.get_Text());

if (_say_last_speech == null && curSpeech != null)
{
// speech has started
if(!String.IsNullOrEmpty(_sayft.get_Text()))
{
started_speech = true;
}
}
else if (_say_last_speech != null && curSpeech == null)
bool speech_started = _say_last_speech == null && curSpeech != null;
bool speech_ended = _say_last_speech != null && curSpeech == null;
bool speech_changed = _say_last_speech != null && curSpeech != null && curSpeech != _say_last_speech;
_say_last_speech = curSpeech;

if (speech_ended)
{
// speech is over
_say_started = false;
_say_delay_end = true;
if(_say_ovr_tmp)
_say_delay_end = true; // To avoid blinking, we will show _say_ovr_tmp and remove it on the next frame
if (_say_ovr_tmp)
_say_ovr_tmp.Transparency = 0;
}
else if (_say_last_speech != null && curSpeech != _say_last_speech)
{
// speech changed to the next line
if(!String.IsNullOrEmpty(_sayft.get_Text()))
return;
}

if (curSpeech == null)
return; // no speech to display, exit

if (is_fancy_say && (speech_started || speech_changed))
{
if (_sayft._is_typed_text)
{
started_speech = true;
_sayspr = _sayft.CreateTypedSprite();
_fancy_say_set_overlay(curSpeech);
}
}
_say_last_speech = curSpeech;

if(started_speech) {
_say_started = true;
if(!_sayft._is_typed_text)
else
{
_sayspr = _sayft.CreateTextBoxSprite();
_fancy_say_set_overlay(curSpeech);
}
}
if(_say_started && _sayft._is_typed_text)

if (is_fancy_say && _sayft._is_typed_text)
{
_sayft.Tick();
}

if (_sayft.get_IsTextBeingTyped())
{
_sayspr = _sayft.CreateTypedSprite();
_fancy_say_set_overlay(curSpeech);
_say_ovr_tmp = Overlay.CreateGraphical(curSpeech.X, curSpeech.Y, _sayspr.Graphic, true, true);
if (_say_ovr_tmp)
_say_ovr_tmp.Remove();
_say_ovr_tmp = Overlay.CreateGraphical(curSpeech.X, curSpeech.Y, _sayspr.Graphic, true, true); // Hack to avoid blink when skipping typed text
_say_ovr_tmp.Transparency = 100;
}
}
Expand Down

0 comments on commit c76e3fe

Please sign in to comment.