diff --git a/fancy_demo/fancy.asc b/fancy_demo/fancy.asc index 58f61aa..eb845b4 100644 --- a/fancy_demo/fancy.asc +++ b/fancy_demo/fancy.asc @@ -27,6 +27,7 @@ Overlay* _say_ovr_tmp; bool _say_started; bool _say_delay_end; int _say_char_head_y; +bool _say_is_room_coords; int _clamp_i(int v, int max, int min) { @@ -58,8 +59,26 @@ int _adjust_speech_x(int x, int width) // avoids text going outside screen void _fancy_say_set_overlay(Overlay* curSpeech) { curSpeech.Graphic = _sayspr.Graphic; - curSpeech.Y = _adjust_speech_y(curSpeech.Y, curSpeech.Height); - curSpeech.X = _adjust_speech_x(curSpeech.X, curSpeech.Width); + + int screen_x = curSpeech.X; + int screen_y = curSpeech.Y; + screen_x = _adjust_speech_x(screen_x, curSpeech.Width); + screen_y = _adjust_speech_y(screen_y, curSpeech.Height); + + // there's a bug in AGS we will workaround : https://github.com/adventuregamestudio/ags/issues/1180 + // The text overlay may be using room coordinates if Speech Style is lucasarts or is Sierra but the + // but the character has no speech view! We do this check in _fancy_say function. + int x = screen_x; + int y = screen_y; + if(_say_is_room_coords) + { + Point* p = Screen.Viewport.ScreenToRoomPoint(x, y, false); + x = p.x; + y = p.y; + } + + curSpeech.Y = y; + curSpeech.X = x; } int _get_character_top_head_y(Character* c) @@ -1120,38 +1139,39 @@ void _fancy_say_setup(Character* c, FancyConfig* config, int width, Fancy9Piece* _say_char_head_y = _get_character_top_head_y(c); } -void FancySay(this Character*, const string text, FancyConfig* config, int width, Fancy9Piece* f9p) +void _fancy_say(bool typed, Character* c, const string text, FancyConfig* config, int width, Fancy9Piece* f9p) { if(String.IsNullOrEmpty(text)) return; - _fancy_say_setup(this, config, width, f9p); + _fancy_say_setup(c, config, width, f9p); _sayft.Clear(); - _sayft.set_Text(text); + if(typed) { + _sayft.Start(text); + } else { + _sayft.set_Text(text); + } + _say_is_room_coords = Speech.Style == eSpeechLucasarts || c.SpeechView == 0; String plain_text = _sayft.get_PlainText(); - this.Say(plain_text.Append(" o o o")); + c.Say(plain_text.Append(" o o o")); + if(typed && _sayft.get_IsTextBeingTyped()) { + _sayft.Skip(); + c.Say(plain_text.Append(" o o o")); + } _sayft.set_Text(null); + +} + +void FancySay(this Character*, const string text, FancyConfig* config, int width, Fancy9Piece* f9p) +{ + _fancy_say(false, this, text, config, width, f9p); } void FancySayTyped(this Character*, const string text, FancyConfig* config, int width, Fancy9Piece* f9p) { - if(String.IsNullOrEmpty(text)) - return; - - _fancy_say_setup(this, config, width, f9p); - _sayft.Clear(); - _sayft.Start(text); - - String plain_text = _sayft.get_PlainText(); - - this.Say(plain_text.Append(" o o o")); - if(_sayft.get_IsTextBeingTyped()) { - _sayft.Skip(); - this.Say(plain_text.Append(" o o o")); - } - _sayft.set_Text(null); + _fancy_say(true, this, text, config, width, f9p); } void _fancy_say_update()