]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/master' into terencehill/clear_button
authorSamual Lenks <samual@xonotic.org>
Wed, 8 May 2013 00:24:09 +0000 (20:24 -0400)
committerSamual Lenks <samual@xonotic.org>
Wed, 8 May 2013 00:24:09 +0000 (20:24 -0400)
20 files changed:
gfx/menu/luminos/clearbutton_c.tga [new file with mode: 0644]
gfx/menu/luminos/clearbutton_f.tga [new file with mode: 0644]
gfx/menu/luminos/clearbutton_n.tga [new file with mode: 0644]
gfx/menu/luminos/skinvalues.txt
gfx/menu/wickedx/clearbutton_c.tga [new file with mode: 0644]
gfx/menu/wickedx/clearbutton_f.tga [new file with mode: 0644]
gfx/menu/wickedx/clearbutton_n.tga [new file with mode: 0644]
gfx/menu/wickedx/skinvalues.txt
gfx/menu/xaw/clearbutton_c.tga [new file with mode: 0644]
gfx/menu/xaw/clearbutton_f.tga [new file with mode: 0644]
gfx/menu/xaw/clearbutton_n.tga [new file with mode: 0644]
gfx/menu/xaw/skinvalues.txt
qcsrc/menu/item/inputbox.c
qcsrc/menu/skin-customizables.inc
qcsrc/menu/xonotic/dialog_multiplayer_demo.c
qcsrc/menu/xonotic/dialog_multiplayer_join.c
qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c
qcsrc/menu/xonotic/dialog_settings_misc.c
qcsrc/menu/xonotic/dialog_settings_misc_cvars.c
qcsrc/menu/xonotic/inputbox.c

diff --git a/gfx/menu/luminos/clearbutton_c.tga b/gfx/menu/luminos/clearbutton_c.tga
new file mode 100644 (file)
index 0000000..3de1ccb
Binary files /dev/null and b/gfx/menu/luminos/clearbutton_c.tga differ
diff --git a/gfx/menu/luminos/clearbutton_f.tga b/gfx/menu/luminos/clearbutton_f.tga
new file mode 100644 (file)
index 0000000..be0939c
Binary files /dev/null and b/gfx/menu/luminos/clearbutton_f.tga differ
diff --git a/gfx/menu/luminos/clearbutton_n.tga b/gfx/menu/luminos/clearbutton_n.tga
new file mode 100644 (file)
index 0000000..57d76c4
Binary files /dev/null and b/gfx/menu/luminos/clearbutton_n.tga differ
index 316ae273f8a88f29dab82696785e8e33a879eb85..e79dba0e099fd157d28f4c8f7ad7692b3568f7c1 100755 (executable)
@@ -189,6 +189,13 @@ COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
 
+// item: clear button
+//   uses "clearbutton" images
+OFFSET_CLEARBUTTON              -0.3
+COLOR_CLEARBUTTON_N                '1 1 1'
+COLOR_CLEARBUTTON_C                '1 1 1'
+COLOR_CLEARBUTTON_F                '1 1 1'
+
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 1'
 ALPHA_KEYGRABBER_TITLES         1
diff --git a/gfx/menu/wickedx/clearbutton_c.tga b/gfx/menu/wickedx/clearbutton_c.tga
new file mode 100644 (file)
index 0000000..26bc0ef
Binary files /dev/null and b/gfx/menu/wickedx/clearbutton_c.tga differ
diff --git a/gfx/menu/wickedx/clearbutton_f.tga b/gfx/menu/wickedx/clearbutton_f.tga
new file mode 100644 (file)
index 0000000..e857381
Binary files /dev/null and b/gfx/menu/wickedx/clearbutton_f.tga differ
diff --git a/gfx/menu/wickedx/clearbutton_n.tga b/gfx/menu/wickedx/clearbutton_n.tga
new file mode 100644 (file)
index 0000000..26bc0ef
Binary files /dev/null and b/gfx/menu/wickedx/clearbutton_n.tga differ
index 3259d7122afe644cccbbcfd775cef69a60c2bc73..15605128588e79c4e3c73c4f647a3e518837ea50 100755 (executable)
@@ -189,6 +189,13 @@ COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
 
+// item: clear button
+//   uses "clearbutton" images
+OFFSET_CLEARBUTTON              -0.5
+COLOR_CLEARBUTTON_N                '1 1 1'
+COLOR_CLEARBUTTON_C                '1 1 1'
+COLOR_CLEARBUTTON_F                '1 1 1'
+
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 1'
 ALPHA_KEYGRABBER_TITLES         1
diff --git a/gfx/menu/xaw/clearbutton_c.tga b/gfx/menu/xaw/clearbutton_c.tga
new file mode 100644 (file)
index 0000000..d8bfea5
Binary files /dev/null and b/gfx/menu/xaw/clearbutton_c.tga differ
diff --git a/gfx/menu/xaw/clearbutton_f.tga b/gfx/menu/xaw/clearbutton_f.tga
new file mode 100644 (file)
index 0000000..338ac1f
Binary files /dev/null and b/gfx/menu/xaw/clearbutton_f.tga differ
diff --git a/gfx/menu/xaw/clearbutton_n.tga b/gfx/menu/xaw/clearbutton_n.tga
new file mode 100644 (file)
index 0000000..60ee8c8
Binary files /dev/null and b/gfx/menu/xaw/clearbutton_n.tga differ
index 36db25d5cd7cf18f8a538437059360214194d49e..3bd555f031ed32255e35cec19596893bfc5597dc 100644 (file)
@@ -129,6 +129,13 @@ COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
 
+// item: clear button
+//   uses "clearbutton" images
+OFFSET_CLEARBUTTON              0
+COLOR_CLEARBUTTON_N                '1 1 1'
+COLOR_CLEARBUTTON_C                '1 1 1'
+COLOR_CLEARBUTTON_F                '1 1 1'
+
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 1'
 ALPHA_KEYGRABBER_TITLES         1
index 572d3a0710dd866bef056667cb2862165d80cf0b..614f6d557679a465861e400a8e3cb9e1deebee1a 100644 (file)
@@ -5,10 +5,12 @@ CLASS(InputBox) EXTENDS(Label)
        METHOD(InputBox, setText, void(entity, string))
        METHOD(InputBox, enterText, void(entity, string))
        METHOD(InputBox, keyDown, float(entity, float, float, float))
+       METHOD(InputBox, mouseMove, float(entity, vector))
        METHOD(InputBox, mouseRelease, float(entity, vector))
        METHOD(InputBox, mousePress, float(entity, vector))
        METHOD(InputBox, mouseDrag, float(entity, vector))
        METHOD(InputBox, showNotify, void(entity))
+       METHOD(InputBox, resizeNotify, void(entity, vector, vector, vector, vector))
 
        ATTRIB(InputBox, src, string, string_null)
 
@@ -26,6 +28,15 @@ CLASS(InputBox) EXTENDS(Label)
        ATTRIB(InputBox, color, vector, '1 1 1')
        ATTRIB(InputBox, colorF, vector, '1 1 1')
        ATTRIB(InputBox, maxLength, float, 255) // if negative, it counts bytes, not chars
+
+       ATTRIB(InputBox, enableClearButton, float, 1)
+       ATTRIB(InputBox, clearButton, entity, NULL)
+       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
@@ -37,6 +48,16 @@ void InputBox_configureInputBox(entity me, string theText, float theCursorPos, f
        me.src = gfx;
        me.cursorPos = theCursorPos;
 }
+void InputBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+       SUPER(InputBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+       if (me.enableClearButton)
+       {
+               me.cb_width = absSize_y / absSize_x;
+               me.cb_offset = bound(-1, me.cb_offset, 0) * me.cb_width; // bound to range -1, 0
+               me.keepspaceRight = me.keepspaceRight - me.cb_offset + me.cb_width;
+       }
+}
 
 void InputBox_setText(entity me, string txt)
 {
@@ -50,18 +71,60 @@ void InputBox_Clear_Click(entity btn, entity me)
        me.setText(me, "");
 }
 
+float over_ClearButton(entity me, vector pos)
+{
+       if (pos_x >= 1 + me.cb_offset - me.cb_width)
+       if (pos_x < 1 + me.cb_offset)
+       if (pos_y >= 0)
+       if (pos_y < 1)
+               return 1;
+       return 0;
+}
+
+float InputBox_mouseMove(entity me, vector pos)
+{
+       if (me.enableClearButton)
+       {
+               if (over_ClearButton(me, pos))
+               {
+                       me.cb_focused = 1;
+                       return 1;
+               }
+               me.cb_focused = 0;
+       }
+       return 1;
+}
+
 float InputBox_mouseDrag(entity me, vector pos)
 {
        float p;
-       me.dragScrollPos = pos;
-       p = me.scrollPos + pos_x - me.keepspaceLeft;
-       me.cursorPos = draw_TextLengthUpToWidth(me.text, p, 0, me.realFontSize);
-       me.lastChangeTime = time;
+       if(me.pressed)
+       {
+               me.dragScrollPos = pos;
+               p = me.scrollPos + pos_x - me.keepspaceLeft;
+               me.cursorPos = draw_TextLengthUpToWidth(me.text, p, 0, me.realFontSize);
+               me.lastChangeTime = time;
+       }
+       else if (me.enableClearButton)
+       {
+               if (over_ClearButton(me, pos))
+               {
+                       me.cb_pressed = 1;
+                       return 1;
+               }
+       }
+       me.cb_pressed = 0;
        return 1;
 }
 
 float InputBox_mousePress(entity me, vector pos)
 {
+       if (me.enableClearButton)
+       if (over_ClearButton(me, pos))
+       {
+               me.cb_pressed = 1;
+               return 1;
+       }
        me.dragScrollTimer = time;
        me.pressed = 1;
        return InputBox_mouseDrag(me, pos);
@@ -69,8 +132,19 @@ float InputBox_mousePress(entity me, vector pos)
 
 float InputBox_mouseRelease(entity me, vector pos)
 {
+       if(me.cb_pressed)
+       if (over_ClearButton(me, pos))
+       {
+               me.cb_pressed = 0;
+               InputBox_Clear_Click(world, me);
+               return 1;
+       }
+       float r = InputBox_mouseDrag(me, pos);
+       //reset cb_pressed after mouseDrag, mouseDrag could set cb_pressed in this case:
+       //mouse press out of the clear button, drag and then mouse release over the clear button
+       me.cb_pressed = 0;
        me.pressed = 0;
-       return InputBox_mouseDrag(me, pos);
+       return r;
 }
 
 void InputBox_enterText(entity me, string ch)
@@ -295,6 +369,17 @@ void InputBox_draw(entity me)
 
        draw_ClearClip();
 
+       if (me.enableClearButton)
+       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, 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, 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, me.cb_color, 1);
+       }
+
        // skipping SUPER(InputBox).draw(me);
        Item_draw(me);
 }
index d30ac7248d0294ac557d8fe4b38a9a96b1814ad1..6b5cac042ca970af7df0cc83c1c4e9f5e5e14585 100644 (file)
@@ -166,6 +166,13 @@ SKINBEGIN
        SKINVECTOR(COLOR_INPUTBOX_F, '1 1 1');
        SKINFLOAT(MARGIN_INPUTBOX_CHARS, 1);
 
+       // item: clear button
+       SKINSTRING(GFX_CLEARBUTTON, "clearbutton");
+       SKINFLOAT(OFFSET_CLEARBUTTON, 0);
+       SKINVECTOR(COLOR_CLEARBUTTON_N, '1 1 1');
+       SKINVECTOR(COLOR_CLEARBUTTON_F, '1 1 1');
+       SKINVECTOR(COLOR_CLEARBUTTON_C, '1 1 1');
+
        // item: key grabber
        SKINVECTOR(COLOR_KEYGRABBER_TITLES, '1 1 1');
        SKINFLOAT(ALPHA_KEYGRABBER_TITLES, 1);
index bb4b969c4c80e5e07f073ab972f57e719d30e3af..84115f1ed651fcaac7852871657b170b478eb9e4 100644 (file)
@@ -20,22 +20,17 @@ entity makeXonoticDemoBrowserTab()
 }
 void XonoticDemoBrowserTab_fill(entity me)
 {
-       entity e;
-       entity btn;
-       entity dlist;
+       entity e, dlist;
 
        me.TR(me);
                me.TD(me, 1, 4, e = makeXonoticCheckBox(0, "cl_autodemo", _("Automatically record demos while playing")));
        me.TR(me);
        me.TR(me);
                me.TD(me, 1, 0.5, e = makeXonoticTextLabel(0, _("Filter:")));
-               me.TD(me, 1, 0.5, btn = makeXonoticButton(_("Clear"), '0 0 0'));
-                       btn.onClick = InputBox_Clear_Click;     
-               me.TD(me, 1, 3, e = makeXonoticInputBox(0, string_null));
+               me.TD(me, 1, 3.5, e = makeXonoticInputBox(0, string_null));
                        dlist = makeXonoticDemoList();
                        e.onChange = DemoList_Filter_Change;
                        e.onChangeEntity = dlist;
-                       btn.onClickEntity = e;
                        dlist.controlledTextbox = e;
                        
        me.TR(me);
index ee451744fb8899942380f76248d7ff8bfa638f51..02d3b410209a0af2bdf371309a45ea7325f57906 100644 (file)
@@ -20,18 +20,15 @@ entity makeXonoticServerListTab()
 }
 void XonoticServerListTab_fill(entity me)
 {
-       entity e, slist, btn;
+       entity e, slist;
 
        slist  = makeXonoticServerList();
 
        me.TR(me);
                me.TD(me, 1, 0.4, e = makeXonoticTextLabel(0, _("Filter:")));
-               me.TD(me, 1, 0.6, btn = makeXonoticButton(_("Clear"), '0 0 0'));
-                       btn.onClick = InputBox_Clear_Click;
-               me.TD(me, 1, me.columns - 0.6 * 4 - 0.4, e = makeXonoticInputBox(0, string_null));
+               me.TD(me, 1, me.columns - 0.6 * 3 - 0.4, e = makeXonoticInputBox(0, string_null));
                        e.onChange = ServerList_Filter_Change;
                        e.onChangeEntity = slist;
-                       btn.onClickEntity = e;
                        slist.controlledTextbox = e;
                me.TD(me, 1, 0.6, e = makeXonoticCheckBox(0, "menu_slist_showempty", ZCTX(_("SRVS^Empty"))));
                        slist.filterShowEmpty = e.checked;
index ef930b4e1490fe879c28ca7a83a191f191610777..21beeca6f48ea94472869ba69d7ac98742cad660 100644 (file)
@@ -45,6 +45,7 @@ void XonoticPlayerSettingsTab_fill(entity me)
                        box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved
                        box.maxLength = -127; // negative means encoded length in bytes
                        box.saveImmediately = 1;
+                       box.enableClearButton = 0;
                        label.textEntity = box;
        me.TR(me);
                me.TD(me, 5, 1, e = makeXonoticColorpicker(box));
index b9aab55ab74dda5cf007353946118592572a78f1..37effe93256e3415ac97140777ee7bda1062669e 100644 (file)
@@ -49,6 +49,7 @@ void XonoticMiscSettingsTab_fill(entity me)
                me.TDempty(me, 0.2);
                me.TD(me, 1, 1.8, e = makeXonoticTextLabel(0, _("Client UDP port:")));
                me.TD(me, 1, 1, e = makeXonoticInputBox(0, "cl_port"));
+                       e.enableClearButton = 0;
        me.TR(me);
        me.TR(me);
                me.TDempty(me, 0.2);
index 7ebca4162ce78174a5c9e6a93ffcbaeb8bb09b94..5db6d35c62c3d6522a9bd1c222947d4dcc16e37b 100644 (file)
@@ -17,26 +17,27 @@ void XonoticCvarsDialog_showNotify(entity me)
 }
 void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIST_CONTROLS to color ALL controls 
 {
-       entity e, cvarlist, btn;
-       
+
+       entity e, cvarlist;
+
        cvarlist = makeXonoticCvarList();
-       
+
        cvarlist.color = 
                cvarlist.colorF = 
                cvarlist.color2 = 
                cvarlist.colorC = 
                SKINCOLOR_CVARLIST_CONTROLS;
-       
+
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Cvar filter:")));
-               me.TD(me, 1, 0.5, btn = makeXonoticButton(_("Clear"), SKINCOLOR_CVARLIST_CONTROLS));
-               me.TD(me, 1, me.columns - 1.5, e = makeXonoticInputBox(0, string_null));
+               me.TD(me, 1, me.columns - 1, e = makeXonoticInputBox(0, string_null));
                        e.color = SKINCOLOR_CVARLIST_CONTROLS;
                        e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
                        e.onChange = CvarList_Filter_Change;
                        e.onChangeEntity = cvarlist;
-                       btn.onClick = InputBox_Clear_Click;
-                       btn.onClickEntity = e;
                        cvarlist.controlledTextbox = e; // this COULD also be the Value box, but this leads to accidentally editing stuff
        me.TR(me);
                me.TD(me, me.rows - me.currentRow - 7, me.columns, cvarlist);
@@ -54,6 +55,9 @@ void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIS
                        cvarlist.cvarValueBox = e;
                        e.color = SKINCOLOR_CVARLIST_CONTROLS;
                        e.colorF = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_color = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_colorC = SKINCOLOR_CVARLIST_CONTROLS;
+                       e.cb_colorF = SKINCOLOR_CVARLIST_CONTROLS;
                        e.onChange = CvarList_Value_Change;
                        e.onChangeEntity = cvarlist;
                        e.onEnter = CvarList_End_Editing;
index dbbcc7b0c495af9609cae5dfac612b2ef4da9f74..56aa9702c67170c82e286d62eed7cec004221999 100644 (file)
@@ -16,6 +16,13 @@ CLASS(XonoticInputBox) EXTENDS(InputBox)
 
        ATTRIB(XonoticInputBox, alpha, float, SKINALPHA_TEXT)
 
+       // Clear button attributes
+       ATTRIB(XonoticInputBox, cb_offset, float, SKINOFFSET_CLEARBUTTON) // bound to range -1, 0
+       ATTRIB(XonoticInputBox, cb_src, string, SKINGFX_CLEARBUTTON)
+       ATTRIB(XonoticInputBox, cb_color, vector, SKINCOLOR_CLEARBUTTON_N)
+       ATTRIB(XonoticInputBox, cb_colorF, vector, SKINCOLOR_CLEARBUTTON_F)
+       ATTRIB(XonoticInputBox, cb_colorC, vector, SKINCOLOR_CLEARBUTTON_C)
+
        ATTRIB(XonoticInputBox, cvarName, string, string_null)
        METHOD(XonoticInputBox, loadCvars, void(entity))
        METHOD(XonoticInputBox, saveCvars, void(entity))