r4472 - in trunk/data: . qcsrc/client qcsrc/menu/nexuiz
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Sep 19 12:56:02 EDT 2008
Author: esteel
Date: 2008-09-19 12:56:02 -0400 (Fri, 19 Sep 2008)
New Revision: 4472
Modified:
trunk/data/defaultNexuiz.cfg
trunk/data/qcsrc/client/Defs.qc
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/client/View.qc
trunk/data/qcsrc/client/csqc_builtins.qc
trunk/data/qcsrc/client/main.qh
trunk/data/qcsrc/client/sbar.qc
trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
Log:
crude way to display keybinds in the hud, currently used for the info in the upper right corner.
NEEDS !!! DP revision 8506 to work. As the next release will include that build i see no reason to add a check for this DP extention
Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/defaultNexuiz.cfg 2008-09-19 16:56:02 UTC (rev 4472)
@@ -1097,6 +1097,8 @@
alias sbar_font "loadfont user1 $*; loadfont user2 ${*}-big; sbar_columns_set"
seta sbar_columns default
sbar_font gfx/vera-sans
+seta sbar_showbinds 1 // 0 disables display of keybinds, 1 enables it, 2 displays longer strings
+seta sbar_showbinds_limit 2 // display so many found keybinds, 0 for unlimited
// these entities are not referenced by anything directly, they just represent
// teams and are found by find() when needed
Modified: trunk/data/qcsrc/client/Defs.qc
===================================================================
--- trunk/data/qcsrc/client/Defs.qc 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/Defs.qc 2008-09-19 16:56:02 UTC (rev 4472)
@@ -174,6 +174,7 @@
float vid_conwidth, vid_conheight;
float configdb;
+float binddb;
string shortmapname;
// QUALIFYING
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/Main.qc 2008-09-19 16:56:02 UTC (rev 4472)
@@ -72,6 +72,7 @@
CSQC_CheckEngine();
configdb = db_create();
+ binddb = db_create();
compressShortVector_init();
drawfont = 0;
@@ -127,6 +128,7 @@
remove(teams);
remove(players);
db_close(configdb);
+ db_close(binddb);
cvar_settemp_restore();
}
@@ -872,3 +874,45 @@
print("^1Please update to a newer version.\n");
}
}
+
+string getcommandkey(string text, string command)
+{
+ string keys;
+ float n, j, k, l;
+
+ if (!sbar_showbinds)
+ return text;
+
+ keys = db_get(binddb, command);
+ if (!keys)
+ {
+ n = tokenize(findkeysforcommand(command));
+ for(j = 0; j < n; ++j)
+ {
+ k = stof(argv(j));
+ if(k != -1)
+ {
+ if ("" == keys)
+ keys = keynumtostring(k);
+ else
+ keys = strcat(keys, ", ", keynumtostring(k));
+
+ ++l;
+ if (sbar_showbinds_limit > 0 && sbar_showbinds_limit >= l) break;
+ }
+
+ }
+ db_put(binddb, command, keys);
+ }
+
+ if ("" == keys) {
+ if (sbar_showbinds > 1)
+ return strcat(text, " (not bound)");
+ else
+ return text;
+ }
+ else if (sbar_showbinds > 1)
+ return strcat(text, " (", keys, ")");
+ else
+ return keys;
+}
Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/View.qc 2008-09-19 16:56:02 UTC (rev 4472)
@@ -246,6 +246,10 @@
vid_conwidth = cvar("vid_conwidth");
vid_conheight = cvar("vid_conheight");
+ // fetch this one only once per frame
+ sbar_showbinds = cvar("sbar_showbinds");
+ sbar_showbinds_limit = cvar("sbar_showbinds_limit");
+
// Update the mouse position
/*
mousepos_x = vid_conwidth;
Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/csqc_builtins.qc 2008-09-19 16:56:02 UTC (rev 4472)
@@ -268,3 +268,6 @@
string(string info, string key) infoget = #227;
string(string info, string key, string value, ...) infoadd = #226;
string(string in) uri_escape = #510;
+
+string keynumtostring(float keynum) = #520;
+string findkeysforcommand(string command) = #521;
Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/main.qh 2008-09-19 16:56:02 UTC (rev 4472)
@@ -126,3 +126,6 @@
float weaponimpulse[24];
float angles_held_status[24];
+string getcommandkey(string text, string command);
+float sbar_showbinds;
+float sbar_showbinds_limit;
Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/client/sbar.qc 2008-09-19 16:56:02 UTC (rev 4472)
@@ -1335,7 +1335,7 @@
if(warmup_stage)
{
- s = "^1Press ^3ready^1 to end warmup";
+ s = strcat("^1Press ^3", getcommandkey("ready", "ready"), "^1 to end warmup");
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
drawcolorcodedstring(
o - sbar_fontsize_x * '2 0 0' * stringwidth(s, TRUE),
@@ -1364,9 +1364,9 @@
o += sbar_fontsize_y * '0 1 0';
if(spectatee_status == -1)
- s = "^1Press ^3primary fire^1 to spectate";
+ s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
else
- s = "^1Press ^3primary fire^1 for another player";
+ s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
drawcolorcodedstring(
o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
@@ -1378,9 +1378,9 @@
o += sbar_fontsize_y * '0 1 0';
if(spectatee_status == -1)
- s = "^1Use ^3weapon switching^1 to change the speed";
+ s = strcat("^1Use ^3", getcommandkey("next-weapon", "weapnext"), "^1 or ^3", getcommandkey("previous-weapon", "weapprev"), "^1 to change the speed");
else
- s = "^1Press ^3secondary fire^1 to observe";
+ s = strcat("^1Press ^3", getcommandkey("secondary fire", "+altattack"), getcommandkey("", "weapprev"), "^1 to observe");
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
drawcolorcodedstring(
o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
@@ -1402,10 +1402,10 @@
else if(sk.(scores[ps_primary]) > 0)
s = "^1You have no more lives left";
else
- s = "^1Press ^7jump^1 to join";
+ s = strcat("^1Press ^7", getcommandkey("jump", "+jump"), "^1 to join");
}
else
- s = "^1Press ^7jump^1 to join";
+ s = strcat("^1Press ^7", getcommandkey("jump", "+jump"), "^1 to join");
dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
drawcolorcodedstring(
o - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
Modified: trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c 2008-09-19 11:56:13 UTC (rev 4471)
+++ trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c 2008-09-19 16:56:02 UTC (rev 4472)
@@ -118,6 +118,12 @@
me.TD(me, 1, 2.8, e = makeNexuizCheckBox(0, "sbar_hudselector", "Use alternate HUD layout"));
setDependent(e, "viewsize", 0, 110);
me.TR(me);
+ me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Show Binds:"));
+ me.TD(me, 1, 2, e = makeNexuizTextSlider("sbar_showbinds"));
+ e.addValue(e, "None", "0");
+ e.addValue(e, "Short", "1");
+ e.addValue(e, "Long", "2");
+ e.configureNexuizTextSliderValues(e);
me.TR(me);
me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Show names:"));
me.TD(me, 1, 2, e = makeNexuizTextSlider("cl_shownames"));
More information about the nexuiz-commits
mailing list