X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fitem%2Flabel.c;h=592c3a7ac59c7a479666f03f34fb4461f0d1e6ae;hb=121eb6e110924d6b9d95e1b353050d92c70bd0d6;hp=378e74adbcb1268ddaa34d7c33af0bb9031bce2e;hpb=c5121d69899c57253362a5a8d98d6a1435a5fb47;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/item/label.c b/qcsrc/menu/item/label.c index 378e74adb..592c3a7ac 100644 --- a/qcsrc/menu/item/label.c +++ b/qcsrc/menu/item/label.c @@ -8,6 +8,7 @@ CLASS(Label) EXTENDS(Item) 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) @@ -19,7 +20,7 @@ CLASS(Label) EXTENDS(Item) ATTRIB(Label, realFontSize, vector, '0 0 0') ATTRIB(Label, realOrigin, vector, '0 0 0') ATTRIB(Label, alpha, float, 0.7) - ATTRIB(Label, colorL, vector, '1 1 1') + ATTRIB(Label, colorL, vector, SKINCOLOR_TEXT) ATTRIB(Label, disabled, float, 0) ATTRIB(Label, disabledAlpha, float, 0.3) ATTRIB(Label, textEntity, entity, NULL) @@ -39,7 +40,13 @@ string Label_toString(entity me) 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) { @@ -72,7 +79,7 @@ void Label_recalcPositionWithText(entity me, string t) me.realOrigin_x = me.keepspaceLeft; if(!me.overrideCondenseFactor) me.condenseFactor = spaceAvail / spaceUsed; - dprint(sprintf(_("NOTE: label text %s too wide for label, condensed by factor %f\n"), t, me.condenseFactor)); + dprintf("NOTE: label text %s too wide for label, condensed by factor %f\n", t, me.condenseFactor); } if(!me.overrideRealOrigin_y) @@ -146,7 +153,13 @@ void Label_draw(entity me) 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;