Skip to content

Commit

Permalink
fix there may be a voice line in the input of fancy say
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Apr 23, 2024
1 parent 6575a01 commit 8368107
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions fancy_demo/fancy.asc
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,32 @@ void _fancy_say_setup(Character* c, FancyConfig* config, int width, Fancy9Piece*
_say_char_head_y = _get_character_top_head_y(c);
}

void _fancy_say(bool typed, Character* c, const string text, FancyConfig* config, int width, Fancy9Piece* f9p)
int _get_voice_txt_end_pos(String text)
{
int len = text.Length;
if(!(len>1 && text.Chars[0] == '&' && text.Chars[1] >= '0' && text.Chars[1] <= '9'))
{
return -1; // no voice line
}

int k=1;
while(text.Chars[k] >= '0' && text.Chars[k] <= '9' && k < len) k++;
if(k < len && text.Chars[k] == ' ') k++;
return k;
}

void _fancy_say(bool typed, Character* c, String text, FancyConfig* config, int width, Fancy9Piece* f9p)
{
if(String.IsNullOrEmpty(text))
return;

int voice_txt_end_pos = _get_voice_txt_end_pos(text);
String voice_str = "";
if(voice_txt_end_pos > 0) {
voice_str = text.Substring(0, voice_txt_end_pos);
text = text.Substring(voice_txt_end_pos, text.Length - voice_txt_end_pos);
}

_fancy_say_setup(c, config, width, f9p);
_sayft.Clear();
if(typed) {
Expand All @@ -1154,14 +1175,14 @@ void _fancy_say(bool typed, Character* c, const string text, FancyConfig* config
_say_is_room_coords = Speech.Style == eSpeechLucasarts || c.SpeechView == 0;

String plain_text = _sayft.get_PlainText();
String plain_text_with_voice = voice_str.Append(plain_text);

c.Say(plain_text.Append(" o o o"));
c.Say(plain_text_with_voice.Append(" o o o"));
if(typed && _sayft.get_IsTextBeingTyped()) {
_sayft.Skip();
c.Say(plain_text.Append(" o o o"));
}
_sayft.set_Text(null);

_sayft.set_Text(null);
}

void FancySay(this Character*, const string text, FancyConfig* config, int width, Fancy9Piece* f9p)
Expand Down

0 comments on commit 8368107

Please sign in to comment.