From f9c6da61fda7624c9218ca336a705d6840a65369 Mon Sep 17 00:00:00 2001 From: e Date: Sun, 21 Apr 2024 14:22:17 -0300 Subject: [PATCH] more fancy say position/limits adjustments --- fancy_demo/fancy.asc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fancy_demo/fancy.asc b/fancy_demo/fancy.asc index 168393d..138131e 100644 --- a/fancy_demo/fancy.asc +++ b/fancy_demo/fancy.asc @@ -43,9 +43,10 @@ int _get_character_height(Character* c) return ((Game.SpriteHeight[vf.Graphic] + c.z) * c.Scaling)/100; } -int _adjust_speech_y(int y) // meant to avoid occluding player head if possible +int _adjust_speech_y(int y, int height) // meant to avoid occluding player head if possible { - return _clamp_i(y, _clamp_i(_say_char_head_y-_sayspr.Height, Screen.Height, _sayspr.Height + 5), 0); + y = _clamp_i(y, _clamp_i(_say_char_head_y-_sayspr.Height, Screen.Height, _sayspr.Height + 5), 0); + return _clamp_i(_clamp_i(y + height, Screen.Height-5, 5) - height, Screen.Height-5, 5); } int _adjust_speech_x(int x, int width) // avoids text going outside screen @@ -56,7 +57,7 @@ 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.Y = _adjust_speech_y(curSpeech.Y, curSpeech.Height); curSpeech.X = _adjust_speech_x(curSpeech.X, curSpeech.Width); } @@ -613,12 +614,11 @@ int _get_speech_width(Character* c, int width) vf = Game.GetViewFrame(speech_view, 0, 0); } if(vf != null) { - portrait_added_width = Game.SpriteWidth[vf.Frame] + 15; + portrait_added_width = Game.SpriteWidth[vf.Frame]; } } - if(portrait_added_width == 0) - portrait_added_width = 25; + portrait_added_width += 35; width = _clamp_i(width, Screen.Width - portrait_added_width, 0); @@ -962,6 +962,9 @@ protected void FancyTextBase::_set_text(String text) int font = this._cfg.Font; int color = this._cfg.TextColor; if(this._fs.MaxTextWidth <= 0) { this._fs.MaxTextWidth = FANCY_INFINITE_WIDTH; } + if(this._f9p != null) { + this._fs.MaxTextWidth -= (this._f9p.BorderLeft + this._f9p.BorderRight); + } FancyTextToken* tk_arr[] = _NewTxtTok(); int tk_count = _process_fancy_string(tk_arr, this._fs, text, this._cfg);