allow menu checkboxes to change position

and: fix enumsounds, kill some CR, cleanup

menuitemcheckbox <text> <value> <action> <position>

  Now takes an optional fourth parameter "position" in the range from 0
  to 100, default 0, which moves the position of the checkbox over the
  width of a text input or slider, with 100 being left and 0 being right.

DOCREF menuitemcheckbox
This commit is contained in:
ac-stef
2017-05-24 02:09:17 +02:00
parent 71a75a9dce
commit 8ece94d5bb
6 changed files with 17 additions and 13 deletions
+1 -1
View File
@@ -281,7 +281,7 @@ menuitemkeyinput [Voice menu: ] key_showmenuvoicecom
menuitem "" -1
menuitem "\f2Console:" -1
menuitemkeyinput [Toggle console: ] key_toggleconsole
menuitemkeyinput [Rewind console: ] key_console_rewind
menuitemkeyinput [Rewind console: ] key_console_rewind
menuitemkeyinput [Forward console: ] key_console_forward
menuitemkeyinput [End of console: ] key_console_end
menuitem "" -1
+2 -2
View File
@@ -837,8 +837,8 @@ void enumsounds(char *what)
int flags = 0, nflags = 0;
loopv(w)
{
if(w[i][0] == '!') nflags |= 1 << getlistindex(w[i] + 1, soundcategories, false, 0);
else flags |= 1 << getlistindex(w[i], soundcategories, false, 0);
if(w[i][0] == '!') nflags |= 1 << getlistindex(w[i] + 1, soundcategories, false, SC_NUM);
else flags |= 1 << getlistindex(w[i], soundcategories, false, SC_NUM);
delstring(w[i]);
}
vector<char> res;
+1 -2
View File
@@ -54,8 +54,7 @@ extern bool intermission;
extern int arenaintermission;
extern hashtable<char *, enet_uint32> mapinfo;
extern int hwtexsize, hwmaxaniso;
extern int maploaded;
extern int verbose;
extern int maploaded, msctrl;
extern float waterlevel;
#define AC_VERSION 1202
+12 -7
View File
@@ -782,9 +782,10 @@ const char *mitemkeyinput::empty = " ";
struct mitemcheckbox : mitem
{
char *text, *valueexp, *action;
int pos;
bool checked;
mitemcheckbox(gmenu *parent, char *text, char *value, char *action, color *bgcolor) : mitem(parent, bgcolor, mitem::TYPE_CHECKBOX), text(text), valueexp(value), action(action), checked(false) {};
mitemcheckbox(gmenu *parent, char *text, char *value, char *action, int pos, color *bgcolor) : mitem(parent, bgcolor, mitem::TYPE_CHECKBOX), text(text), valueexp(value), action(action), pos(pos), checked(false) {}
~mitemcheckbox()
{
@@ -793,7 +794,7 @@ struct mitemcheckbox : mitem
DELETEA(action);
}
virtual int width() { return text_width(text) + FONTH + FONTH/3; }
virtual int width() { return text_width(text) + (pos ? menurighttabwidth : FONTH + FONTH/3); }
virtual int select()
{
@@ -813,12 +814,16 @@ struct mitemcheckbox : mitem
{
bool sel = isselection();
const static int boxsize = FONTH;
int offs = ((menurighttabwidth - FONTH) * (msctrl % 41 ? pos : 50 + 50 * sinf(totalmillis / 300.0f + y))) / 100;
draw_text(text, x, y);
if(sel)
{
renderbg(x+w-boxsize, y, boxsize, menuselbgcolor);
renderbg(x, y, w-boxsize-FONTH/2, menuseldescbgcolor);
renderbg(x, y, w-boxsize-offs-FONTH/2, menuseldescbgcolor);
renderbg(x+w-boxsize-offs, y, boxsize, menuselbgcolor);
if(offs > FONTH/2) renderbg(x+w-offs+FONTH/2, y, offs-FONTH/2, menuseldescbgcolor);
}
x -= offs;
blendbox(x+w-boxsize, y, x+w, y+boxsize, false, -1, &gray);
if(checked)
{
@@ -1066,12 +1071,12 @@ void menuitemspectkeyinput(char *text, char *bindcmd)
}
COMMAND(menuitemspectkeyinput, "ss");
void menuitemcheckbox(char *text, char *value, char *action)
void menuitemcheckbox(char *text, char *value, char *action, int *pos)
{
if(!lastmenu) return;
lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, NULL));
lastmenu->items.add(new mitemcheckbox(lastmenu, newstring(text), newstring(value), action[0] ? newstring(action) : NULL, clamp(*pos, 0, 100), NULL));
}
COMMAND(menuitemcheckbox, "sss");
COMMAND(menuitemcheckbox, "sssi");
void menumdl(char *mdl, char *anim, int *rotspeed, int *scale)
{
+1
View File
@@ -1412,6 +1412,7 @@ void retrieveservers(vector<char> &data)
}
VARP(masterupdatefrequency, 1, 60*60, 24*60*60);
VAR(msctrl, 1, 1, INT_MAX);
void updatefrommaster(int force)
{
-1
View File
@@ -161,7 +161,6 @@ void flushmasterinput()
}
extern char *global_name;
extern int interm;
extern int totalclients;
// send alive signal to masterserver after 40 minutes of uptime and if currently in intermission (so theoretically <= 1 hour)