Skip to content

Commit

Permalink
more fancy say position/limits adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Apr 21, 2024
1 parent 62ec25a commit f9c6da6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fancy_demo/fancy.asc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f9c6da6

Please sign in to comment.