METHOD(Label, setText, void(entity, string))
METHOD(Label, toString, string(entity))
METHOD(Label, recalcPositionWithText, void(entity, string))
+ ATTRIB(Label, isBold, float, 0)
ATTRIB(Label, text, string, string_null)
+ ATTRIB(Label, currentText, string, string_null)
ATTRIB(Label, fontSize, float, 8)
ATTRIB(Label, align, float, 0.5)
ATTRIB(Label, allowCut, float, 0)
void Label_setText(entity me, string txt)
{
me.text = txt;
- me.recalcPos = 1;
+ if(txt != me.currentText)
+ {
+ if(me.currentText)
+ strunzone(me.currentText);
+ me.currentText = strzone(txt);
+ me.recalcPos = 1;
+ }
}
void Label_recalcPositionWithText(entity me, string t)
{
float spaceAvail;
spaceAvail = 1 - me.keepspaceLeft - me.keepspaceRight;
+ if(me.isBold)
+ draw_beginBoldFont();
+
float spaceUsed;
spaceUsed = draw_TextWidth(t, me.allowColors, me.realFontSize);
me.realOrigin_y = 0.5 * (1 - lines * me.realFontSize_y);
}
+ if(me.isBold)
+ draw_endBoldFont();
+
me.recalcPos = 0;
}
void Label_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
if(me.textEntity)
{
t = me.textEntity.toString(me.textEntity);
- me.recalcPos = 1;
+ if(t != me.currentText)
+ {
+ if(me.currentText)
+ strunzone(me.currentText);
+ me.currentText = strzone(t);
+ me.recalcPos = 1;
+ }
}
else
t = me.text;
vector dfs;
vector fs;
+ if(me.isBold)
+ draw_beginBoldFont();
+
// set up variables to draw in condensed size, but use hinting for original size
fs = me.realFontSize;
fs_x *= me.condenseFactor;
draw_Text(me.realOrigin, t, fs, me.colorL, me.alpha, me.allowColors);
draw_fontscale = dfs;
+
+ if(me.isBold)
+ draw_endBoldFont();
}
SUPER(Label).draw(me);