]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/item/inputbox.c
Merge remote-tracking branch 'origin/Mario/teams_override'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item / inputbox.c
index 83bb916dad2363dc389fd8db05bb54a6565bdfa2..1c1bf5189bc34a48a824a46f132e96e79e2f83cb 100644 (file)
@@ -34,6 +34,9 @@ CLASS(InputBox) EXTENDS(Label)
        ATTRIB(InputBox, cb_width, float, 0)
        ATTRIB(InputBox, cb_pressed, float, 0)
        ATTRIB(InputBox, cb_focused, float, 0)
+       ATTRIB(InputBox, cb_color, vector, '1 1 1')
+       ATTRIB(InputBox, cb_colorF, vector, '1 1 1')
+       ATTRIB(InputBox, cb_colorC, vector, '1 1 1')
 ENDCLASS(InputBox)
 void InputBox_Clear_Click(entity btn, entity me);
 #endif
@@ -217,6 +220,9 @@ void InputBox_draw(entity me)
        if(me.pressed)
                me.mouseDrag(me, me.dragScrollPos); // simulate mouseDrag event
 
+       if(me.recalcPos)
+               me.recalcPositionWithText(me, me.text);
+
        me.focusable = !me.disabled;
        if(me.disabled)
                draw_alpha *= me.disabledAlpha;
@@ -254,11 +260,11 @@ void InputBox_draw(entity me)
                vector p;
                vector theTempColor;
                float component;
-               
+
                p = me.realOrigin - eX * me.scrollPos;
                theColor = '1 1 1';
                theAlpha = 1;    //theVariableAlpha = 1; // changes when ^ax found
-               
+
                n = strlen(me.text);
                for(i = 0; i < n; ++i)
                {
@@ -294,25 +300,24 @@ void InputBox_draw(entity me)
                                else if(ch2 == "x") // ^x found
                                {
                                        theColor = '1 1 1';
-                                       theTempColor = '0 0 0';
-                                       
+
                                        component = HEXDIGIT_TO_DEC(substring(me.text, i+2, 1));
                                        if (component >= 0) // ^xr found
                                        {
                                                theTempColor_x = component/15;
-                                               
+
                                                component = HEXDIGIT_TO_DEC(substring(me.text, i+3, 1));
                                                if (component >= 0) // ^xrg found
                                                {
                                                        theTempColor_y = component/15;
-                                                       
+
                                                        component = HEXDIGIT_TO_DEC(substring(me.text, i+4, 1));
                                                        if (component >= 0) // ^xrgb found
                                                        {
                                                                theTempColor_z = component/15;
                                                                theColor = theTempColor;
                                                                w = draw_TextWidth(substring(me.text, i, 5), 0, me.realFontSize);
-                                                               
+
                                                                draw_Fill(p, eX * w + eY * me.realFontSize_y, '1 1 1', 0.5);
                                                                draw_Text(p, substring(me.text, i, 5), me.realFontSize, theColor, 1, 0);    // theVariableAlpha instead of 1 using alpha tags ^ax
                                                                i += 3;
@@ -368,11 +373,11 @@ void InputBox_draw(entity me)
        if (me.text != "")
        {
                if(me.focused && me.cb_pressed)
-                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_c"), eX * me.cb_width + eY, '1 1 1', 1);
+                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_c"), eX * me.cb_width + eY, me.cb_colorC, 1);
                else if(me.focused && me.cb_focused)
-                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_f"), eX * me.cb_width + eY, '1 1 1', 1);
+                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_f"), eX * me.cb_width + eY, me.cb_colorF, 1);
                else
-                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_n"), eX * me.cb_width + eY, '1 1 1', 1);
+                       draw_Picture(eX * (1 + me.cb_offset - me.cb_width), strcat(me.cb_src, "_n"), eX * me.cb_width + eY, me.cb_color, 1);
        }
 
        // skipping SUPER(InputBox).draw(me);