Skip to content

Commit

Permalink
add global Fancy9Piece for global replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Apr 21, 2024
1 parent c246ef2 commit db2152f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
30 changes: 26 additions & 4 deletions fancy_demo/fancy.asc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int _fancybtn_count;
Dictionary* _tvdict;
FancyConfig* _default_cfg;
Fancy9Piece* _default_f9p;
Fancy9Piece* _default_default_f9p;
FancyTypedText _sayft;
DynamicSprite* _sayspr;
Overlay* _say_last_speech;
Expand Down Expand Up @@ -789,6 +790,8 @@ static Fancy9Piece* Fancy9Piece::CreateFromTextWindowGui(GUI* text_window_gui)

void Fancy9Piece::Set(Fancy9Piece* v)
{
if(v == null) v = Fancy9Piece.CreateFrom9Sprites(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

this.B = v.B; this.B_h = v.B_h; this.B_w = v.B_w;
this.L = v.L; this.L_h = v.L_h; this.L_w = v.L_w;
this.R = v.R; this.R_h = v.R_h; this.R_w = v.R_w;
Expand All @@ -808,6 +811,22 @@ Fancy9Piece* Fancy9Piece::Clone()
return f9p;
}

static Fancy9Piece* Fancy::get_Fancy9Piece()
{
return _default_f9p;
}

static void Fancy::set_Fancy9Piece(Fancy9Piece* value)
{
if(value == null) {
value = _default_default_f9p.Clone();
}
if(_default_f9p == null) {
_default_f9p = value.Clone();
}
_default_f9p.Set(value);
}

void DrawFancyString(this DrawingSurface*, int x, int y, const string text, FancyConfig* config, int width)
{
FancyTextToken* tk_arr[] = _NewTxtTok();
Expand Down Expand Up @@ -1016,11 +1035,13 @@ void FancyTextBox::set_Fancy9Piece(Fancy9Piece* value)
if(value == null && _default_f9p != null) {
value = _default_f9p.Clone();
}
if(this._f9p == null && _default_f9p != null) {
this._f9p = _default_f9p.Clone();
if(this._f9p == null && value != null) {
this._f9p = value;
return;
}
if(this._f9p == null && value == null) return;
if(this._f9p == null) this._f9p = value;
if(this._f9p == null)
this._f9p = Fancy9Piece.CreateFrom9Sprites(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

this._f9p.Set(value);
}

Expand Down Expand Up @@ -1209,6 +1230,7 @@ void game_start()
{
_tvdict = Dictionary.Create(eSorted, eCaseInsensitive);
_default_f9p = Fancy9Piece.CreateFromTextWindowGui(null);
_default_default_f9p = Fancy9Piece.CreateFromTextWindowGui(null);
}

function late_repeatedly_execute_always() {
Expand Down
6 changes: 6 additions & 0 deletions fancy_demo/fancy.ash
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ builtin managed struct Fancy {
#ifndef SCRIPT_EXT_AGS4
import static FancyConfig* get_FancyConfig(); // $AUTOCOMPLETEIGNORE$
import static void set_FancyConfig(FancyConfig* value); // $AUTOCOMPLETEIGNORE$
#endif
/// Global default 9-piece for the Text Box creation when one not specified
import static attribute Fancy9Piece* Fancy9Piece;
#ifndef SCRIPT_EXT_AGS4
import static Fancy9Piece* get_Fancy9Piece(); // $AUTOCOMPLETEIGNORE$
import static void set_Fancy9Piece(Fancy9Piece* value); // $AUTOCOMPLETEIGNORE$
#endif
};

Expand Down
1 change: 1 addition & 0 deletions fancy_demo/room1.asc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function room_AfterFadeIn()
{
Fancy.AddAlias("red", 64493);
Fancy.FancyConfig.Font = eFontNormal;
Fancy.Fancy9Piece = Fancy9Piece.CreateFromTextWindowGui(gTextBorder);

// surface extension
DrawingSurface* surf = Room.GetDrawingSurfaceForBackground();
Expand Down

0 comments on commit db2152f

Please sign in to comment.