From: TimePath Date: Tue, 22 Dec 2015 09:06:53 +0000 (+1100) Subject: vcall gui X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fdbc4ff2eb97088d45460fa1e70e39af93d3c771;p=xonotic%2Fxonotic-data.pk3dir.git vcall gui --- diff --git a/binds-xonotic.cfg b/binds-xonotic.cfg index 361621c6a..0545f15f8 100644 --- a/binds-xonotic.cfg +++ b/binds-xonotic.cfg @@ -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" diff --git a/commands.cfg b/commands.cfg index d009e13d6..15666d3a3 100644 --- a/commands.cfg +++ b/commands.cfg @@ -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" diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc index be3ac5645..3c5db0b65 100644 --- a/qcsrc/client/commands/cl_cmd.qc +++ b/qcsrc/client/commands/cl_cmd.qc @@ -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() \ diff --git a/qcsrc/client/defs.qh b/qcsrc/client/defs.qh index 3e959b084..db34febbc 100644 --- a/qcsrc/client/defs.qh +++ b/qcsrc/client/defs.qh @@ -4,7 +4,6 @@ // Additional OPTIONAL Fields and Globals //float intermission; float scoreboard_showscores; -float scoreboard_showaccuracy; .string message; .int renderflags; // float coop; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 05a11080b..a1f73068a 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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); diff --git a/qcsrc/menu/classes.inc b/qcsrc/menu/classes.inc index 3aa3e4305..f6e61d2cd 100644 --- a/qcsrc/menu/classes.inc +++ b/qcsrc/menu/classes.inc @@ -101,6 +101,7 @@ #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" @@ -133,5 +134,6 @@ #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 index 000000000..6afb61224 --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_vcall.qc @@ -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 diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index 4f1c74e81..184bd964f 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -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")); diff --git a/qcsrc/menu/xonotic/mainwindow.qc b/qcsrc/menu/xonotic/mainwindow.qc index 3d4110448..0c70a215c 100644 --- a/qcsrc/menu/xonotic/mainwindow.qc +++ b/qcsrc/menu/xonotic/mainwindow.qc @@ -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 index 000000000..91fc4e10f --- /dev/null +++ b/qcsrc/menu/xonotic/votelist.qc @@ -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 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index d3d14a5cf..8abcc210f 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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()