]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
vcall gui
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Dec 2015 09:06:53 +0000 (20:06 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Dec 2015 09:12:03 +0000 (20:12 +1100)
binds-xonotic.cfg
commands.cfg
qcsrc/client/commands/cl_cmd.qc
qcsrc/client/defs.qh
qcsrc/client/main.qc
qcsrc/menu/classes.inc
qcsrc/menu/xonotic/dialog_vcall.qc [new file with mode: 0644]
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/votelist.qc [new file with mode: 0644]
qcsrc/server/cl_client.qc

index 361621c6a83b413a270f1458f56a4ab362ffd338..0545f15f844987651a7405c1def58fc2ad1a92a1 100644 (file)
@@ -1,12 +1,3 @@
-// alias for switching the teamselect menu
-bind f5 menu_showteamselect
-
-bind f6 team_auto
-
-bind f7 menu_showsandboxtools
-
-bind f9 "cl_cmd hud minigame"
-
 // movement
 bind w +forward
 bind a +moveleft
@@ -17,8 +8,8 @@ bind LEFTARROW +moveleft
 bind DOWNARROW +back
 bind RIGHTARROW +moveright
 bind SHIFT +crouch
-bind ENTER +jump
 bind SPACE +jump
+bind ENTER +jump
 
 // weapons
 bind 0 weapon_group_0
@@ -40,8 +31,8 @@ bind MOUSE5 +hook
 bind MWHEELUP weapnext
 bind MWHEELDOWN weapprev
 bind r reload
-bind BACKSPACE dropweapon
 bind g dropweapon
+bind BACKSPACE dropweapon
 bind f +use
 bind v +button8 // drag object
 
@@ -59,14 +50,23 @@ bind m +hud_panel_radar_maximized
 bind b "quickmenu"
 bind i +show_info
 bind PAUSE pause
+
+bind F1 vyes
+bind F2 vno
+bind F3 spec // used for spectate/observer mode
+bind F4 ready
+
+bind f5 menu_showteamselect // alias for switching the teamselect menu
+bind f6 team_auto
+bind f7 menu_showsandboxtools
+bind f8 menu_showvcall
+
 bind F9 "cl_cmd hud minigame"
 bind F10 menu_showquitdialog
 bind F11 disconnect
 bind F12 screenshot
-bind F4 ready
-bind ALT +showaccuracy
 
-// Gamepad defaults. Tested with Logitech Rumblepad 2, I hope similar ones works as well.
+// Gamepad defaults. Tested with Logitech Rumblepad 2, I hope similar ones work as well.
 bind JOY1 "+crouch"
 bind JOY2 "+jump"
 bind JOY3 "weapprev"
@@ -114,12 +114,6 @@ bind kp_enter "+userbind 16"
 bind kp_plus "+userbind 17"
 bind kp_minus "+userbind 18"
 
-bind F1 vyes
-bind F2 vno
-
-//used for spectate/observer mode
-bind F3 spec
-
 // usercommands. These can be edited and bound by the menu.
 seta "userbind1_press" "say_team quad soon";  seta "userbind1_release" "";  seta "userbind1_description" "team: quad soon"
 seta "userbind2_press" "say_team free item %x^7 (l:%y^7); g_waypointsprite_team_here_p";  seta "userbind2_release" "";  seta "userbind2_description" "team: free item, icon"
@@ -156,4 +150,4 @@ seta "userbind31_press" ""; seta "userbind31_release" ""; seta "userbind31_descr
 seta "userbind32_press" ""; seta "userbind32_release" ""; seta "userbind32_description" ""
 alias _userbind_call "${$1}"
 alias +userbind "_userbind_call userbind${1}_press"
-alias -userbind "_userbind_call userbind${1}_release"
\ No newline at end of file
+alias -userbind "_userbind_call userbind${1}_release"
index d009e13d67df48e5224ac7488b28834650762ff4..15666d3a3364fa6647690cbd9fcd3a478a242f47 100644 (file)
@@ -102,6 +102,7 @@ alias menu_showteamselect "menu_cmd directmenu TeamSelect"
 alias menu_showhudexit "menu_cmd directmenu HUDExit"
 alias menu_showhudoptions "menu_cmd directpanelhudmenu ${* ?}"
 alias menu_showsandboxtools "menu_cmd directmenu SandboxTools"
+alias menu_showvcall "menu_cmd directmenu Vcall"
 alias menu_showquitdialog "menu_cmd directmenu Quit"
 alias menu_showmonstertools "menu_cmd directmenu MonsterTools"
 
index be3ac56450b170dcc0806bcca54bc16bd1556a8d..3c5db0b654ed2b5e8e5cd444bb37bb1bd963100b 100644 (file)
@@ -593,8 +593,6 @@ void GameCommand(string command)
 #define CONSOLE_COMMANDS_NORMAL() \
        CONSOLE_COMMAND("+showscores", { scoreboard_showscores = true; }) \
        CONSOLE_COMMAND("-showscores", { scoreboard_showscores = false; }) \
-       CONSOLE_COMMAND("+showaccuracy", { scoreboard_showaccuracy = true; }) \
-       CONSOLE_COMMAND("-showaccuracy", { scoreboard_showaccuracy = false; }) \
        /* nothing */
 
 #define CONSOLE_COMMANDS_MOVEMENT() \
index 3e959b084ef753251abe18a338253d14f38896c9..db34febbc631d871450155343b06bd72750829fb 100644 (file)
@@ -4,7 +4,6 @@
 // Additional OPTIONAL Fields and Globals
 //float                intermission;
 float          scoreboard_showscores;
-float          scoreboard_showaccuracy;
 .string                message;
 .int           renderflags;
 // float               coop;
index 05a11080b98bd458e22244109d06f3ded6af6c8b..a1f73068acee87dc19685628eb61c3e186adb2bd 100644 (file)
@@ -914,6 +914,16 @@ NET_HANDLE(ENT_CLIENT_INIT, bool isnew)
 
        g_trueaim_minrange = ReadCoord();
 
+       #define X(out) MACRO_BEGIN { \
+               out = ""; for (string s; (s = ReadString()) != ""; ) out = cons(out, s); \
+       } MACRO_END
+       string votes; X(votes);
+       localcmd("\nset __vcall \"", votes, "\"\n");
+       string maps; X(maps);
+       localcmd("\nset __vcall_chmap \"", maps, "\"\n");
+       localcmd("\nset __vcall_gotomap \"", maps, "\"\n");
+       localcmd("\nset __vcall_nextmap \"", maps, "\"\n");
+       #undef X
        return = true;
 
        MUTATOR_CALLHOOK(Ent_Init);
index 3aa3e43057447ea63b43a8bb996d5881b36369f4..f6e61d2cddfd4c1d32083ba2242c2b1438dc5858 100644 (file)
 #include "xonotic/dialog_singleplayer.qc"
 #include "xonotic/dialog_singleplayer_winner.qc"
 #include "xonotic/dialog_teamselect.qc"
+#include "xonotic/dialog_vcall.qc"
 #include "xonotic/gametypelist.qc"
 #include "xonotic/hudskinlist.qc"
 #include "xonotic/image.qc"
 #include "xonotic/tab.qc"
 #include "xonotic/textlabel.qc"
 #include "xonotic/textslider.qc"
+#include "xonotic/votelist.qc"
 #include "xonotic/weaponarenacheckbox.qc"
 #include "xonotic/weaponslist.qc"
diff --git a/qcsrc/menu/xonotic/dialog_vcall.qc b/qcsrc/menu/xonotic/dialog_vcall.qc
new file mode 100644 (file)
index 0000000..6afb612
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef DIALOG_VCALL_H
+#define DIALOG_VCALL_H
+#include "rootdialog.qc"
+CLASS(XonoticVcallDialog, XonoticRootDialog)
+       ATTRIB(XonoticVcallDialog, title, string, _("Call a vote"))
+       ATTRIB(XonoticVcallDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
+       ATTRIB(XonoticVcallDialog, intendedWidth, float, 1)
+       ATTRIB(XonoticVcallDialog, rows, float, 16)
+       ATTRIB(XonoticVcallDialog, columns, float, 20)
+       ATTRIB(XonoticVcallDialog, name, string, "Vcall")
+
+       ATTRIB(XonoticVcallDialog, voteList, entity, NULL)
+       ATTRIB(XonoticVcallDialog, optionList, entity, NULL)
+       ATTRIB(XonoticVcallDialog, inputBox, entity, NULL)
+
+       METHOD(XonoticVcallDialog, fill, void(XonoticVcallDialog this));
+       METHOD(XonoticVcallDialog, setFocus, void(XonoticVcallDialog this, entity a));
+ENDCLASS(XonoticVcallDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+METHOD(XonoticVcallDialog, setFocus, void(XonoticVcallDialog this, entity a))
+{
+       SUPER(XonoticVcallDialog).setFocus(this, a);
+       entity vlist = this.voteList;
+       vlist.refilter(vlist);
+}
+
+STATIC_METHOD(XonoticVcallDialog, Send, void(entity, XonoticVcallDialog this))
+{
+       localcmd("vcall ", this.inputBox.text, "\n");
+       this.close(this);
+}
+
+STATIC_METHOD(XonoticVcallDialog, Change, void(entity, XonoticVcallDialog this))
+{
+       entity vlist = this.voteList;
+       entity options = this.optionList;
+       vlist.source.getEntry(vlist.source, vlist.selectedItem, XonoticVoteList_cb);
+       string vote = XonoticVoteList_cb_name;
+       options.source.getEntry(options.source, options.selectedItem, XonoticVoteList_cb);
+       string option = XonoticVoteList_cb_name;
+       string s = (option != "") ? strcat(vote, " ", option) : vote;
+       entity t = this.inputBox;
+       t.setText(t, s);
+       t.cursorPos = strlen(s);
+}
+
+STATIC_METHOD(XonoticVcallDialog, ChangeVote, void(entity, XonoticVcallDialog this))
+{
+       entity vlist = this.voteList;
+       entity entries = this.optionList;
+       int i = vlist.selectedItem;
+       vlist.source.getEntry(vlist.source, i, XonoticVoteList_cb);
+       if (entries.source.CvarStringSource_cvar) strunzone(entries.source.CvarStringSource_cvar);
+       entries.source.CvarStringSource_cvar = strzone(strcat("__vcall_", XonoticVoteList_cb_name));
+       entries.refilter(entries);
+       entries.setSelected(entries, 0);
+       XonoticVcallDialog_Change(NULL, this);
+}
+
+METHOD(XonoticVcallDialog, fill, void(XonoticVcallDialog this))
+{
+       entity vlist, olist;
+       this.TR(this);
+       {
+               this.TD(this, 1, 10, makeXonoticTextLabel(0, _("Available votes:")));
+               this.TD(this, 1, 10, makeXonoticTextLabel(0, _("Available options:")));
+       }
+       this.TR(this);
+       {
+               DataSource votes = NEW(CvarStringSource, "__vcall", " ");
+               this.TD(this, 13, 10, vlist = this.voteList = NEW(XonoticVoteList, votes));
+               {
+                       vlist.onChange = XonoticVcallDialog_ChangeVote;
+                       vlist.onChangeEntity = this;
+               }
+               DataSource options = NEW(CvarStringSource, string_null, " ");
+               this.TD(this, 13, 10, olist = this.optionList = NEW(XonoticVoteList, options));
+               {
+                       olist.onChange = XonoticVcallDialog_Change;
+                       olist.onChangeEntity = this;
+               }
+               this.gotoRC(this, this.rows - 2, 0);
+               this.TD(this, 1, 20, this.inputBox = makeXonoticInputBox(1, string_null));
+       }
+       this.TR(this);
+       {
+               entity e;
+               this.TD(this, 1, 10, e = makeXonoticButton(_("Call the vote"), '0 0 0'));
+               {
+                       e.onClick = XonoticVcallDialog_Send;
+                       e.onClickEntity = this;
+               }
+               this.TD(this, 1, 10, e = makeXonoticCommandButton(_("Cancel"), '0 0 0', "", 1));
+               {
+                       e.onClick = Dialog_Close;
+                       e.onClickEntity = this;
+               }
+       }
+}
+#endif
index 4f1c74e8156eba07a6e78ccf7637c185d39b3171..184bd964f2e1dcd2b288539c5ace07ef7e30ac90 100644 (file)
@@ -112,6 +112,7 @@ void Xonotic_KeyBinds_Read()
        KEYBIND_DEF("messagemode"                           , _("public chat"));
        KEYBIND_DEF("messagemode2"                          , _("team chat"));
        KEYBIND_DEF("+con_chat_maximize"                    , _("show chat history"));
+       KEYBIND_DEF("menu_showvcall"                        , _("call a vote"));
        KEYBIND_DEF("vyes"                                  , _("vote YES"));
        KEYBIND_DEF("vno"                                   , _("vote NO"));
        KEYBIND_DEF("ready"                                 , _("ready"));
index 3d41104488085fe1c629fc8980f728a055b921d6..0c70a215c213005606184f727ab3350a0885fa35 100644 (file)
@@ -209,6 +209,9 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
 
+       i = NEW(XonoticVcallDialog);
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
        // main dialogs/windows
        me.mainNexposee = n = NEW(XonoticNexposee);
diff --git a/qcsrc/menu/xonotic/votelist.qc b/qcsrc/menu/xonotic/votelist.qc
new file mode 100644 (file)
index 0000000..91fc4e1
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef VOTELIST_H
+#define VOTELIST_H
+
+#include "listbox.qc"
+CLASS(XonoticVoteList, XonoticListBox)
+       METHOD(XonoticVoteList, resizeNotify, void(XonoticVoteList this, vector relOrigin, vector relSize, vector absOrigin, vector absSize))
+       {
+               SUPER(XonoticVoteList).resizeNotify(this, relOrigin, relSize, absOrigin, absSize);
+               this.realFontSize_y = this.fontSize / (absSize.y * this.itemHeight);
+               this.realFontSize_x = this.fontSize / (absSize.x * (1 - this.controlWidth));
+       }
+
+       ATTRIB(XonoticVoteList, source, DataSource, NULL)
+
+       METHOD(XonoticVoteList, refilter, void(XonoticVoteList this));
+       METHOD(XonoticVoteList, setSelected, void(XonoticVoteList this, int i));
+       METHOD(XonoticVoteList, drawListBoxItem, void(XonoticVoteList this, int i, vector absSize, bool isSelected, bool isFocused));
+
+       CONSTRUCTOR(XonoticVoteList, DataSource _source)
+       {
+               CONSTRUCT(XonoticVoteList);
+               this.source = _source;
+               this.refilter(this);
+       }
+
+ENDCLASS(XonoticVoteList)
+
+string XonoticVoteList_cb_name;
+void XonoticVoteList_cb(string _name, string _icon) { XonoticVoteList_cb_name = _name; }
+
+#endif
+
+#ifdef IMPLEMENTATION
+
+METHOD(XonoticVoteList, refilter, void(XonoticVoteList this))
+{
+       if (!this.source)
+       {
+               this.nItems = 0;
+               return;
+       }
+       this.nItems = this.source.reload(this.source, "");
+}
+
+METHOD(XonoticVoteList, setSelected, void(XonoticVoteList this, int i))
+{
+       SUPER(XonoticVoteList).setSelected(this, i);
+       if (!this.source.getEntry(this.source, i, XonoticVoteList_cb)) return;
+       if (this.onChange) this.onChange(this, this.onChangeEntity);
+}
+
+METHOD(XonoticVoteList, drawListBoxItem, void(XonoticVoteList this, int i, vector absSize, bool isSelected, bool isFocused))
+{
+       if (!this.source.getEntry(this.source, i, XonoticVoteList_cb)) return;
+       if (isSelected) draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+       string s = XonoticVoteList_cb_name;
+       draw_Text(this.realUpperMargin * eY + this.columnNameOrigin * eX, s, this.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+}
+
+#endif
index d3d14a5cfb5118b180e52eeaf1e7a148897cf779..8abcc210f3ce98bf65fe71d0f12dcd87b0958d0a 100644 (file)
@@ -653,6 +653,20 @@ bool ClientInit_SendEntity(entity this, entity to, int sf)
        ClientInit_misc();
        MUTATOR_CALLHOOK(Ent_Init);
 }
+
+string vcall_maps()
+{
+       static string it;
+       if (it) return it;
+       for (int i = 0; i < MapInfo_count; ++i)
+       {
+               if ((MapInfo_Get_ByID(i)) && !(MapInfo_Map_flags & MapInfo_ForbiddenFlags()))
+                       it = cons(it, MapInfo_Map_bspname);
+       }
+       MapInfo_ClearTemps();
+       return it = strzone(it);
+}
+
 void ClientInit_misc()
 {
        int channel = MSG_ONE;
@@ -674,6 +688,16 @@ void ClientInit_misc()
        WriteByte(channel, self.count * 255.0); // g_balance_armor_blockpercent
        WriteByte(channel, serverflags); // client has to know if it should zoom or not
        WriteCoord(channel, autocvar_g_trueaim_minrange);
+       #define X(list) \
+               MACRO_BEGIN { \
+                       FOREACH_WORD(list, true, { \
+                               WriteString(channel, it); \
+                       }); \
+                       WriteString(channel, ""); \
+               } MACRO_END
+       X(autocvar_sv_vote_commands);
+       X(vcall_maps());
+       #undef X
 }
 
 void ClientInit_CheckUpdate()