@@ -1979,20 +1979,21 @@ namespace UI
19791979 textinfo info;
19801980 int fontid, lastchange;
19811981 int fancy; // 0 = none, 1 = shadow, 2 = outline, 3 = shadow+outline
1982+ int align, justify;
19821983 char *language;
19831984 bool changed;
19841985 uint crc; // string hash used for change detection
19851986
19861987 Text () : info({0 , 0 , 0 }), lastchange(0 ), fancy(0 ), language(NULL ), crc(0 ) {}
19871988
1988- void setup (float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, const char *language_ = "")
1989+ void setup (float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, int align_ = -1, int justify_ = 0, const char *language_ = "")
19891990 {
19901991 Object::setup ();
19911992 changed = false ;
19921993 float newscale = scale_ * uiscale;
19931994
19941995 int curfontid = getcurfontid ();
1995- if (newscale != scale || wrap_ != wrap || fontid != curfontid || fancy_ != fancy || (!language || strcmp (language_, language)) || (color_.r != color.r || color_.g != color.g || color_.b != color.b ))
1996+ if (newscale != scale || wrap_ != wrap || fontid != curfontid || fancy_ != fancy || align_ != align || justify_ != justify || (!language || strcmp (language_, language)) || (color_.r != color.r || color_.g != color.g || color_.b != color.b ))
19961997 {
19971998 changed = true ;
19981999 lastchange = totalmillis;
@@ -2002,6 +2003,8 @@ namespace UI
20022003 color = color_;
20032004 wrap = wrap_;
20042005 fancy = fancy_;
2006+ align = align_;
2007+ justify = justify_;
20052008 SETSTR (language, language_);
20062009 fontid = curfontid;
20072010 }
@@ -2069,7 +2072,7 @@ namespace UI
20692072
20702073 if (!info.tex )
20712074 {
2072- prepare_text (text, info, int (wrap/k), bvec (color.r , color.g , color.b ), -1 , fancy >= 2 ? 1.0 : 0 , bvec (0 , 0 , 0 ), language);
2075+ prepare_text (text, info, int (wrap/k), bvec (color.r , color.g , color.b ), -1 , fancy >= 2 ? 1.0 : 0 , bvec (0 , 0 , 0 ), align, justify, language);
20732076 }
20742077 w = max (w, info.w *k);
20752078 h = max (h, info.h *k);
@@ -2083,9 +2086,9 @@ namespace UI
20832086 TextString () : str(NULL ) {}
20842087 ~TextString () { delete[] str; }
20852088
2086- void setup (const char *str_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, const char *language_ = "")
2089+ void setup (const char *str_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, int align_ = -1, int justify_ = 0, const char *language_ = "")
20872090 {
2088- Text::setup (scale_, color_, wrap_, fancy_, language_);
2091+ Text::setup (scale_, color_, wrap_, fancy_, align_, justify_, language_);
20892092
20902093 SETSTR (str, str_);
20912094 }
@@ -2103,9 +2106,9 @@ namespace UI
21032106
21042107 TextInt () : val(0 ) { str[0 ] = ' 0' ; str[1 ] = ' \0 ' ; }
21052108
2106- void setup (int val_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, const char *language_ = "")
2109+ void setup (int val_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, int align_ = -1, int justify_ = 0, const char *language_ = "")
21072110 {
2108- Text::setup (scale_, color_, wrap_, fancy_, language_);
2111+ Text::setup (scale_, color_, wrap_, fancy_, align_, justify_, language_);
21092112
21102113 if (val != val_) { val = val_; intformat (str, val, sizeof (str)); }
21112114 }
@@ -2123,9 +2126,9 @@ namespace UI
21232126
21242127 TextFloat () : val(0 ) { memcpy (str, " 0.0" , 4 ); }
21252128
2126- void setup (float val_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, const char *language_ = "")
2129+ void setup (float val_, float scale_ = 1 , const Color &color_ = Color(255 , 255 , 255 ), float wrap_ = -1, int fancy_ = 0, int align_ = -1, int justify_ = 0, const char *language_ = "")
21272130 {
2128- Text::setup (scale_, color_, wrap_, fancy_, language_);
2131+ Text::setup (scale_, color_, wrap_, fancy_, align_, justify_, language_);
21292132
21302133 if (val != val_) { val = val_; floatformat (str, val, sizeof (str)); }
21312134 }
@@ -3541,25 +3544,25 @@ namespace UI
35413544 ICOMMAND (uimodcircle, " ife" , (int *c, float *size, uint *children),
35423545 BUILD(Circle, o, o->setup (Color(*c), *size, Circle::MODULATE), children));
35433546
3544- static inline void buildtext (tagval &t, float scale, float scalemod, const Color &color, float wrap, uint *children, int fancy, const char *language)
3547+ static inline void buildtext (tagval &t, float scale, float scalemod, const Color &color, float wrap, uint *children, int fancy, int align, int justify, const char *language)
35453548 {
35463549 if (scale <= 0 ) scale = 1 ;
35473550 scale *= scalemod;
35483551 if (!language) language = " " ;
35493552 switch (t.type )
35503553 {
35513554 case VAL_INT:
3552- BUILD (TextInt, o, o->setup (t.i , scale, color, wrap, fancy, language), children);
3555+ BUILD (TextInt, o, o->setup (t.i , scale, color, wrap, fancy, align, justify, language), children);
35533556 break ;
35543557 case VAL_FLOAT:
3555- BUILD (TextFloat, o, o->setup (t.f , scale, color, wrap, fancy, language), children);
3558+ BUILD (TextFloat, o, o->setup (t.f , scale, color, wrap, fancy, align, justify, language), children);
35563559 break ;
35573560 case VAL_CSTR:
35583561 case VAL_MACRO:
35593562 case VAL_STR:
35603563 if (t.s [0 ])
35613564 {
3562- BUILD (TextString, o, o->setup (t.s , scale, color, wrap, fancy, language), children);
3565+ BUILD (TextString, o, o->setup (t.s , scale, color, wrap, fancy, align, justify, language), children);
35633566 break ;
35643567 }
35653568 // fall-through
@@ -3570,34 +3573,34 @@ namespace UI
35703573 }
35713574
35723575 ICOMMAND (uicolortext, " tifise" , (tagval *text, int *c, float *scale, int *fancy, const char *language, uint *children),
3573- buildtext(*text, *scale, uitextscale, Color(*c), -1, children, *fancy, language));
3576+ buildtext(*text, *scale, uitextscale, Color(*c), -1, children, *fancy, -1, 0, language));
35743577
35753578 ICOMMAND (uitext, " tfise" , (tagval *text, float *scale, int *fancy, const char *language, uint *children),
3576- buildtext(*text, *scale, uitextscale, Color(255 , 255 , 255 ), -1, children, *fancy, language));
3579+ buildtext(*text, *scale, uitextscale, Color(255 , 255 , 255 ), -1, children, *fancy, -1, 0, language));
35773580
35783581 ICOMMAND (uitextfill, " ffe" , (float *minw, float *minh, uint *children),
35793582 BUILD(Filler, o, o->setup (*minw * uitextscale*0 .5f , *minh * uitextscale), children));
35803583
3581- ICOMMAND (uiwrapcolortext, " tfifse " , (tagval *text, float *wrap, int *c, float *scale, int *fancy, const char *language, uint *children),
3582- buildtext(*text, *scale, uitextscale, Color(*c), *wrap, children, *fancy, language));
3584+ ICOMMAND (uiwrapcolortext, " tfifiiise " , (tagval *text, float *wrap, int *c, float *scale, int *fancy, int *align, int *justify , const char *language, uint *children),
3585+ buildtext(*text, *scale, uitextscale, Color(*c), *wrap, children, *fancy, *align, *justify, language));
35833586
3584- ICOMMAND (uiwraptext, " tffse " , (tagval *text, float *wrap, float *scale, int *fancy, const char *language, uint *children),
3585- buildtext(*text, *scale, uitextscale, Color(255 , 255 , 255 ), *wrap, children, *fancy, language));
3587+ ICOMMAND (uiwraptext, " tffiiise " , (tagval *text, float *wrap, float *scale, int *fancy, int *align, int *justify , const char *language, uint *children),
3588+ buildtext(*text, *scale, uitextscale, Color(255 , 255 , 255 ), *wrap, children, *fancy, *align, *justify, language));
35863589
35873590 ICOMMAND (uicolorcontext, " tife" , (tagval *text, int *c, float *scale, uint *children),
3588- buildtext(*text, *scale, FONTH*uicontextscale, Color(*c), -1, children, 0, ""));
3591+ buildtext(*text, *scale, FONTH*uicontextscale, Color(*c), -1, children, 0, -1, 0, ""));
35893592
35903593 ICOMMAND (uicontext, " tfe" , (tagval *text, float *scale, uint *children),
3591- buildtext(*text, *scale, FONTH*uicontextscale, Color(255 , 255 , 255 ), -1, children, 0, ""));
3594+ buildtext(*text, *scale, FONTH*uicontextscale, Color(255 , 255 , 255 ), -1, children, 0, -1, 0, ""));
35923595
35933596 ICOMMAND (uicontextfill, " ffe" , (float *minw, float *minh, uint *children),
35943597 BUILD(Filler, o, o->setup (*minw * FONTH*uicontextscale*0 .5f , *minh * FONTH*uicontextscale), children));
35953598
35963599 ICOMMAND (uiwrapcolorcontext, " tfife" , (tagval *text, float *wrap, int *c, float *scale, uint *children),
3597- buildtext(*text, *scale, FONTH*uicontextscale, Color(*c), *wrap, children, 0, ""));
3600+ buildtext(*text, *scale, FONTH*uicontextscale, Color(*c), *wrap, children, 0, -1, 0, ""));
35983601
35993602 ICOMMAND (uiwrapcontext, " tffe" , (tagval *text, float *wrap, float *scale, uint *children),
3600- buildtext(*text, *scale, FONTH*uicontextscale, Color(255 , 255 , 255 ), *wrap, children, 0, ""));
3603+ buildtext(*text, *scale, FONTH*uicontextscale, Color(255 , 255 , 255 ), *wrap, children, 0, -1, 0, ""));
36013604
36023605 ICOMMAND (uitexteditor, " siifsie" , (char *name, int *length, int *height, float *scale, char *initval, int *mode, uint *children),
36033606 BUILD(TextEditor, o, o->setup (name, *length, *height, (*scale <= 0 ? 1 : *scale) * uitextscale, initval, *mode <= 0 ? EDITORFOREVER : *mode), children));
0 commit comments