diff --git a/fancy_demo/fancy.asc b/fancy_demo/fancy.asc index eb845b4..a2f8ff1 100644 --- a/fancy_demo/fancy.asc +++ b/fancy_demo/fancy.asc @@ -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) { @@ -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)