Skip to content

Commit 8368107

Browse files
committed
fix there may be a voice line in the input of fancy say
1 parent 6575a01 commit 8368107

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

fancy_demo/fancy.asc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,11 +1139,32 @@ void _fancy_say_setup(Character* c, FancyConfig* config, int width, Fancy9Piece*
11391139
_say_char_head_y = _get_character_top_head_y(c);
11401140
}
11411141

1142-
void _fancy_say(bool typed, Character* c, const string text, FancyConfig* config, int width, Fancy9Piece* f9p)
1142+
int _get_voice_txt_end_pos(String text)
1143+
{
1144+
int len = text.Length;
1145+
if(!(len>1 && text.Chars[0] == '&' && text.Chars[1] >= '0' && text.Chars[1] <= '9'))
1146+
{
1147+
return -1; // no voice line
1148+
}
1149+
1150+
int k=1;
1151+
while(text.Chars[k] >= '0' && text.Chars[k] <= '9' && k < len) k++;
1152+
if(k < len && text.Chars[k] == ' ') k++;
1153+
return k;
1154+
}
1155+
1156+
void _fancy_say(bool typed, Character* c, String text, FancyConfig* config, int width, Fancy9Piece* f9p)
11431157
{
11441158
if(String.IsNullOrEmpty(text))
11451159
return;
11461160

1161+
int voice_txt_end_pos = _get_voice_txt_end_pos(text);
1162+
String voice_str = "";
1163+
if(voice_txt_end_pos > 0) {
1164+
voice_str = text.Substring(0, voice_txt_end_pos);
1165+
text = text.Substring(voice_txt_end_pos, text.Length - voice_txt_end_pos);
1166+
}
1167+
11471168
_fancy_say_setup(c, config, width, f9p);
11481169
_sayft.Clear();
11491170
if(typed) {
@@ -1154,14 +1175,14 @@ void _fancy_say(bool typed, Character* c, const string text, FancyConfig* config
11541175
_say_is_room_coords = Speech.Style == eSpeechLucasarts || c.SpeechView == 0;
11551176

11561177
String plain_text = _sayft.get_PlainText();
1178+
String plain_text_with_voice = voice_str.Append(plain_text);
11571179

1158-
c.Say(plain_text.Append(" o o o"));
1180+
c.Say(plain_text_with_voice.Append(" o o o"));
11591181
if(typed && _sayft.get_IsTextBeingTyped()) {
11601182
_sayft.Skip();
11611183
c.Say(plain_text.Append(" o o o"));
11621184
}
1163-
_sayft.set_Text(null);
1164-
1185+
_sayft.set_Text(null);
11651186
}
11661187

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

0 commit comments

Comments
 (0)