]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/clear_button
authorterencehill <piuntn@gmail.com>
Wed, 25 Jan 2012 17:14:40 +0000 (18:14 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 25 Jan 2012 17:14:40 +0000 (18:14 +0100)
20 files changed:
gfx/menu/default/clearbutton_c.tga [new file with mode: 0644]
gfx/menu/default/clearbutton_f.tga [new file with mode: 0644]
gfx/menu/default/clearbutton_n.tga [new file with mode: 0644]
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/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_cvars.c
qcsrc/menu/xonotic/dialog_settings_network.c
qcsrc/menu/xonotic/inputbox.c

diff --git a/gfx/menu/default/clearbutton_c.tga b/gfx/menu/default/clearbutton_c.tga
new file mode 100644 (file)
index 0000000..26bc0ef
Binary files /dev/null and b/gfx/menu/default/clearbutton_c.tga differ
diff --git a/gfx/menu/default/clearbutton_f.tga b/gfx/menu/default/clearbutton_f.tga
new file mode 100644 (file)
index 0000000..e857381
Binary files /dev/null and b/gfx/menu/default/clearbutton_f.tga differ
diff --git a/gfx/menu/default/clearbutton_n.tga b/gfx/menu/default/clearbutton_n.tga
new file mode 100644 (file)
index 0000000..26bc0ef
Binary files /dev/null and b/gfx/menu/default/clearbutton_n.tga differ
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 b4102234acd4e8bc06eef8253bfcc90d83538333..c9d958e9586564faf39f5da1103f4541b3492229 100755 (executable)
@@ -184,6 +184,7 @@ COLOR_DIALOG_CVARS              '1 0 0'
 COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
+OFFSET_CLEARBUTTON              -0.3
 
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 1'
index d6b7197a1d32c099a1ffbff4fdee06210e066455..ed8ff8ad15ace6cf33d48f8f181081ccc9371999 100755 (executable)
@@ -184,6 +184,7 @@ COLOR_DIALOG_CVARS              '1 0 0'
 COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
+OFFSET_CLEARBUTTON              -0.5
 
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 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 5afcb09cfe3751cd5efedde9758be73cd512e864..d5b7a47916a8782d284ed6f99e1abcf10f5c296a 100644 (file)
@@ -124,6 +124,7 @@ HEIGHT_DIALOGBORDER             1
 COLOR_INPUTBOX_N                '1 1 1'
 COLOR_INPUTBOX_F                '1 1 1'
 MARGIN_INPUTBOX_CHARS           1
+OFFSET_CLEARBUTTON              0
 
 // item: key grabber
 COLOR_KEYGRABBER_TITLES         '1 1 1'
index 5b07afd4eef2997d11b9ec5057379fd5ec89d478..e057991e176c8ddad0c874dd2168c7d3c174944b 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,12 @@ 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)
 ENDCLASS(InputBox)
 void InputBox_Clear_Click(entity btn, entity me);
 #endif
@@ -37,6 +45,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 +68,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 +129,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)
@@ -292,6 +363,17 @@ void InputBox_draw(entity me)
                draw_Text(me.realOrigin + eX * (cursorPosInWidths - me.scrollPos), CURSOR, me.realFontSize, '1 1 1', 1, 0);
 
        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, '1 1 1', 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);
+               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);
+       }
 }
 
 void InputBox_showNotify(entity me)
index e8cfba3689a7bcca7ed0fe1fa1eaffa4549dd904..948b2311e8d95ca381aeac37823b021e38f1558c 100644 (file)
@@ -160,6 +160,8 @@ SKINBEGIN
        SKINSTRING(GFX_INPUTBOX, "inputbox");
        SKINVECTOR(COLOR_INPUTBOX_N, '1 1 1');
        SKINVECTOR(COLOR_INPUTBOX_F, '1 1 1');
+       SKINSTRING(GFX_CLEARBUTTON, "clearbutton");
+       SKINFLOAT(OFFSET_CLEARBUTTON, 0);
        SKINFLOAT(MARGIN_INPUTBOX_CHARS, 1);
 
        // item: key grabber
index 99f5a179b5ca6ab2bf6711bf20ea1a705c1ff291..bfcd1f2567ad49a9714a4328b342e2c15aa26416 100644 (file)
@@ -20,9 +20,7 @@ entity makeXonoticDemoBrowserTab()
 }
 void XonoticDemoBrowserTab_fill(entity me)
 {
-       entity e;
-       entity btn;
-       entity dlist;
+       entity e, dlist;
 
        me.TR(me);
                me.TD(me, 1, me.columns, e = makeXonoticCheckBox(0, "cl_autodemo", _("Record demos while playing")));
@@ -30,12 +28,9 @@ void XonoticDemoBrowserTab_fill(entity me)
        dlist = makeXonoticDemoList();
        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, me.columns - 1, e = makeXonoticInputBox(0, string_null));
+               me.TD(me, 1, me.columns - 0.5, e = makeXonoticInputBox(0, string_null));
                        e.onChange = DemoList_Filter_Change;
                        e.onChangeEntity = dlist;
-                       btn.onClickEntity = e;
                        dlist.controlledTextbox = e;
        me.TR(me);
                me.TD(me, me.rows - 4, me.columns, dlist);
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 6365081658c2553d69f566d710c9bbe8e3562e56..a57dd6ea40a113a2a944a47bded1e7861daa0bfb 100644 (file)
@@ -48,6 +48,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 be2b64259cf15bf615835df26f44833247873dae..dbf0e4a65b149703d4818fd4fbc6547083feb89e 100644 (file)
@@ -17,16 +17,13 @@ void XonoticCvarsDialog_showNotify(entity me)
 }
 void XonoticCvarsDialog_fill(entity me)
 {
-       entity e, cvarlist, btn;
+       entity e, cvarlist;
        cvarlist = makeXonoticCvarList();
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Cvar filter:")));
-               me.TD(me, 1, 0.5, btn = makeXonoticButton(_("Clear"), '0 0 0'));
                me.TD(me, 1, me.columns - 1.5, e = makeXonoticInputBox(0, string_null));
                        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);
index 9f489a84506731fbcf2674ed47f453ef86bd6153..886c9b74a5f33d98006b267485edc2bc54651cca 100644 (file)
@@ -60,5 +60,6 @@ void XonoticNetworkSettingsTab_fill(entity me)
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Client UDP port:")));
                me.TD(me, 1, 0.64, e = makeXonoticInputBox(0, "cl_port"));
+                       e.enableClearButton = 0;
 }
 #endif
index 2a9c094b8eb07a74ac6752562b3eecfb87cd200a..9e42f3bf6fc0fa61c56f54f5bd92e2ab80612223 100644 (file)
@@ -16,6 +16,10 @@ 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, cvarName, string, string_null)
        METHOD(XonoticInputBox, loadCvars, void(entity))
        METHOD(XonoticInputBox, saveCvars, void(entity))