Skip to content

Commit

Permalink
more code duplication reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Apr 21, 2024
1 parent 545c9b6 commit da4c997
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions fancy_demo/fancy.asc
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,13 @@ int _get_speech_width(Character* c, int width)
return width;
}

DynamicSprite* _create_textbox_from_text_spr(DynamicSprite* text_spr, Fancy9Piece* f9p)
{
if(f9p == null)
return text_spr;
return _create_textbox_from_textgraphic(f9p, text_spr.Width, text_spr.Height, text_spr.Graphic);
}

DynamicSprite* _create_text_sprite(FancyTextToken* tk_arr[], int tk_count, FancyState* fs, String text, int typed_token_len, int width, FancyConfig* cfg)
{
DynamicSprite* text_spr = DynamicSprite.Create(fs.BoxWidth, fs.BoxHeight, true);
Expand Down Expand Up @@ -1044,20 +1051,8 @@ DynamicSprite* FancyTextBox::CreateTextBoxSprite()
if(this._cfg == null) this._cfg = _default_cfg.Clone();

DynamicSprite* text_spr = _create_text_sprite(this._tk_arr, this._tk_count, this._fs, this._text, -1, this._width, this._cfg);

if(this._f9p == null) return text_spr;

int w = text_spr.Width;
int h = text_spr.Height;

DynamicSprite* box_spr = _create_textbox(w, h, this._f9p);
DrawingSurface* surf = box_spr.GetDrawingSurface();

surf.DrawImage(this._f9p.BorderLeft, this._f9p.BorderTop, text_spr.Graphic);
surf.Release();

text_spr.Delete();
return box_spr;
return _create_textbox_from_text_spr(text_spr, this._f9p);
}

DynamicSprite* FancyTypedText::CreateTypedSprite()
Expand All @@ -1067,19 +1062,7 @@ DynamicSprite* FancyTypedText::CreateTypedSprite()

DynamicSprite* text_spr = _create_text_sprite(this._tk_arr, this._typed_token_count, this._fs, this._text, this._typed_token_len, this._width, this._cfg);

if(this._f9p == null) return text_spr;

int w = text_spr.Width;
int h = text_spr.Height;

DynamicSprite* box_spr = _create_textbox(w, h, this._f9p);
DrawingSurface* surf = box_spr.GetDrawingSurface();

surf.DrawImage(this._f9p.BorderLeft, this._f9p.BorderTop, text_spr.Graphic);
surf.Release();

text_spr.Delete();
return box_spr;
return _create_textbox_from_text_spr(text_spr, this._f9p);
}

bool get_IsTextBeingTyped(this FancyTypedText*)
Expand Down

0 comments on commit da4c997

Please sign in to comment.