Added bind script and checkbox mask option.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@193 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
6c21b642a7
commit
52a00cab7d
5 changed files with 73 additions and 40 deletions
|
@ -207,11 +207,21 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
|
|||
if (option->check.func)
|
||||
on = option->check.func(option, CHK_CHECKED);
|
||||
else if (!option->check.var)
|
||||
on = option->check.value;
|
||||
else if (option->check.var->latched_string)
|
||||
on = atof(option->check.var->latched_string);
|
||||
on = option->check.value;
|
||||
else if (option->check.bits) //bits is a bitmask for use with cvars (users can be clumsy, so bittage of 0 uses non-zero as true, but sets only bit 1)
|
||||
{
|
||||
if (option->check.var->latched_string)
|
||||
on = atoi(option->check.var->latched_string)&option->check.bits;
|
||||
else
|
||||
on = (int)(option->check.var->value)&option->check.bits;
|
||||
}
|
||||
else
|
||||
on = option->check.var->value;
|
||||
{
|
||||
if (option->check.var->latched_string)
|
||||
on = !!atof(option->check.var->latched_string);
|
||||
else
|
||||
on = !!option->check.var->value;
|
||||
}
|
||||
|
||||
if (option->check.text)
|
||||
{
|
||||
|
@ -527,7 +537,7 @@ menucustom_t *MC_AddCustom(menu_t *menu, int x, int y, const char *data)
|
|||
return n;
|
||||
}
|
||||
|
||||
menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t *var)
|
||||
menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t *var, int bits)
|
||||
{
|
||||
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
|
||||
n->common.type = mt_checkbox;
|
||||
|
@ -539,6 +549,7 @@ menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t
|
|||
n->text = (char *)(n+1);
|
||||
strcpy((char *)(n+1), text);
|
||||
n->var = var;
|
||||
n->bits = bits;
|
||||
|
||||
n->common.next = menu->options;
|
||||
menu->options = (menuoption_t *)n;
|
||||
|
@ -758,10 +769,26 @@ void MC_CheckBox_Key(menucheck_t *option, int key)
|
|||
option->value = !option->value;
|
||||
else
|
||||
{
|
||||
if (option->var->latched_string)
|
||||
Cvar_SetValue(option->var, !atof(option->var->latched_string));
|
||||
if (option->bits)
|
||||
{
|
||||
int old;
|
||||
if (option->var->latched_string)
|
||||
old = atoi(option->var->latched_string);
|
||||
else
|
||||
old = option->var->value;
|
||||
|
||||
if (old & option->bits)
|
||||
Cvar_SetValue(option->var, old&~option->bits);
|
||||
else
|
||||
Cvar_SetValue(option->var, old|option->bits);
|
||||
}
|
||||
else
|
||||
Cvar_SetValue(option->var, !option->var->value);
|
||||
{
|
||||
if (option->var->latched_string)
|
||||
Cvar_SetValue(option->var, !atof(option->var->latched_string));
|
||||
else
|
||||
Cvar_SetValue(option->var, !option->var->value);
|
||||
}
|
||||
S_LocalSound ("misc/menu2.wav");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,7 +355,7 @@ void M_Menu_GameOptions_f (void)
|
|||
info->deathmatch = MC_AddCombo (menu, 64, y, " Deathmatch", (const char **)deathmatchoptions, deathmatch.value);y+=8;
|
||||
info->teamplay = MC_AddCombo (menu, 64, y, " Teamplay", (const char **)teamplayoptions, teamplay.value);y+=8;
|
||||
info->skill = MC_AddCombo (menu, 64, y, " Skill", (const char **)skilloptions, skill.value);y+=8;
|
||||
info->rundedicated = MC_AddCheckBox(menu, 64, y, " dedicated", NULL);y+=8;
|
||||
info->rundedicated = MC_AddCheckBox(menu, 64, y, " dedicated", NULL, 0);y+=8;
|
||||
y+=8;
|
||||
info->timelimit = MC_AddCombo (menu, 64, y, " Time Limit", (const char **)timelimitoptions, timelimit.value/5);y+=8;
|
||||
info->fraglimit = MC_AddCombo (menu, 64, y, " Frag Limit", (const char **)fraglimitoptions, fraglimit.value/10);y+=8;
|
||||
|
|
|
@ -76,13 +76,13 @@ void M_Menu_Options_f (void)
|
|||
|
||||
MC_AddSlider(menu, 16, y, " Mouse Speed", &sensitivity, 1, 10); y+=8;
|
||||
|
||||
MC_AddCheckBox(menu, 16, y, " Always Run", NULL)->func = M_Options_AlwaysRun; y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Invert Mouse", NULL)->func = M_Options_InvertMouse; y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Lookspring", &lookspring); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Lookstrafe", &lookstrafe); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Use old status bar", &cl_sbar); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " HUD on left side", &cl_hudswap); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Old-style chatting", &cl_standardchat);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Always Run", NULL,0)->func = M_Options_AlwaysRun; y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Invert Mouse", NULL,0)->func = M_Options_InvertMouse; y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Lookspring", &lookspring,0); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Lookstrafe", &lookstrafe,0); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Use old status bar", &cl_sbar,0); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " HUD on left side", &cl_hudswap,0); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Old-style chatting", &cl_standardchat,0);y+=8;
|
||||
y+=4;MC_AddEditCvar(menu, 16, y, " Imitate FPS", "cl_netfps"); y+=8+4;
|
||||
|
||||
MC_AddConsoleCommand(menu, 16, y, " Video Options", "menu_video\n"); y+=8;
|
||||
|
@ -93,7 +93,7 @@ void M_Menu_Options_f (void)
|
|||
if (!vid_isfullscreen)
|
||||
#endif
|
||||
{
|
||||
MC_AddCheckBox(menu, 16, y, " Use Mouse", &_windowed_mouse); y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Use Mouse", &_windowed_mouse,0); y+=8;
|
||||
}
|
||||
|
||||
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 200, 32, NULL, false);
|
||||
|
@ -266,11 +266,11 @@ void M_Menu_Audio_f (void)
|
|||
MC_AddSlider(menu, 16, y, " CD Music Volume", &bgmvolume, 0, 1);y+=8;
|
||||
MC_AddSlider(menu, 16, y, " Sound Volume", &volume, 0, 1);y+=8;
|
||||
MC_AddSlider(menu, 16, y, " Ambient Volume", &ambient_level, 0, 1);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " no sound", &nosound);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " precache", &precache);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Low Quality Sound", &loadas8bit);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Flip Sound", &snd_leftisright);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Experimental EAX 2", &snd_eax);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " no sound", &nosound,0);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " precache", &precache,0);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Low Quality Sound", &loadas8bit,0);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Flip Sound", &snd_leftisright,0);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Experimental EAX 2", &snd_eax,0);y+=8;
|
||||
MC_AddCvarCombo(menu, 16, y, " Speaker setup", &snd_speakers, speakeroptions, speakervalues);y+=8;
|
||||
MC_AddCvarCombo(menu, 16, y, " Sound speed", &snd_khz, soundqualityoptions, soundqualityvalues);y+=8;
|
||||
MC_AddConsoleCommand(menu, 16, y, " Restart sound", "snd_restart\n");y+=8;
|
||||
|
@ -333,7 +333,7 @@ void M_Menu_Particles_f (void)
|
|||
|
||||
menu->selecteditem = (union menuoption_s *)
|
||||
|
||||
MC_AddCheckBox(menu, 16, y, " sparks bounce", &r_bouncysparks);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " sparks bounce", &r_bouncysparks,0);y+=8;
|
||||
MC_AddSlider(menu, 16, y, " exp spark count", &r_particles_in_explosion, 16, 1024);y+=8;
|
||||
MC_AddCvarCombo(menu, 16, y, " rain effect", &r_part_rain, r_part_rain_options, r_part_rain_values);y+=8;
|
||||
|
||||
|
@ -342,7 +342,7 @@ void M_Menu_Particles_f (void)
|
|||
{
|
||||
MC_AddCvarCombo(menu, 16, y, " WallTorch effect", &gl_part_torch, gl_part_effects_ops, gl_part_effects_vals);y+=8;
|
||||
MC_AddCvarCombo(menu, 16, y, " Open flame effect", &gl_part_flame, gl_part_effects_ops, gl_part_effects_vals);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Trifan Sparks", &gl_part_trifansparks);y+=8;
|
||||
MC_AddCheckBox(menu, 16, y, " Trifan Sparks", &gl_part_trifansparks,0);y+=8;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -377,32 +377,32 @@ void M_Menu_FPS_f (void)
|
|||
|
||||
MC_AddConsoleCommand(menu, 48, y, " Particle Options", "menu_particles\n"); y+=8;
|
||||
|
||||
MC_AddCheckBox(menu, 48, y, " Show FPS", &show_fps);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Show FPS", &show_fps,0);y+=8;
|
||||
|
||||
MC_AddCheckBox(menu, 48, y, " Content blend", &v_contentblend);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Dynamic lights", &r_dynamic);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Stainmaps", &r_stains);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Content blend", &v_contentblend,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Dynamic lights", &r_dynamic,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Stainmaps", &r_stains,0);y+=8;
|
||||
|
||||
switch(qrenderer)
|
||||
{
|
||||
#ifdef RGLQUAKE
|
||||
case QR_OPENGL:
|
||||
MC_AddCheckBox(menu, 48, y, " Blood stains", &r_bloodstains);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Load .lit files", &r_loadlits);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Flashblending", &r_flashblend);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Detailmaps", &gl_detail);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Bumpmaps", &gl_bump);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Tex Compression", &gl_compress);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, "Other Water Effect", &gl_waterripples);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Blood stains", &r_bloodstains,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Load .lit files", &r_loadlits,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Flashblending", &r_flashblend,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Detailmaps", &gl_detail,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Bumpmaps", &gl_bump,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " Tex Compression", &gl_compress,0);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, "Other Water Effect", &gl_waterripples,0);y+=8;
|
||||
MC_AddSlider(menu, 48, y, " 2D resolution", &gl_2dscale, 0, 1);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " 32 bit textures", &gl_load24bit);y+=8;
|
||||
MC_AddCheckBox(menu, 48, y, " 32 bit textures", &gl_load24bit,0);y+=8;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SWQUAKE
|
||||
case QR_SOFTWARE:
|
||||
if (r_pixbytes == 4)
|
||||
{MC_AddCheckBox(menu, 48, y, " Load .lit files", &r_loadlits);y+=8;}
|
||||
MC_AddCheckBox(menu, 48, y, " Texture Smoothing", &d_smooth);y+=8;
|
||||
{MC_AddCheckBox(menu, 48, y, " Load .lit files", &r_loadlits,0);y+=8;}
|
||||
MC_AddCheckBox(menu, 48, y, " Texture Smoothing", &d_smooth,0);y+=8;
|
||||
MC_AddSlider(menu, 48, y, " Mipmap scale", &d_mipscale, 0.1, 3);y+=8;
|
||||
MC_AddSlider(menu, 48, y, " Mipmap Capping", &d_mipcap, 0, 3);y+=8;
|
||||
break;
|
||||
|
|
|
@ -105,6 +105,7 @@ void M_MenuS_CheckBox_f (void)
|
|||
int y = atoi(Cmd_Argv(2));
|
||||
char *text = Cmd_Argv(3);
|
||||
char *cvarname = Cmd_Argv(4);
|
||||
int bitmask = atoi(Cmd_Argv(5));
|
||||
cvar_t *cvar;
|
||||
|
||||
if (!menu_script)
|
||||
|
@ -115,7 +116,7 @@ void M_MenuS_CheckBox_f (void)
|
|||
cvar = Cvar_Get(cvarname, text, 0, "User variables");
|
||||
if (!cvar)
|
||||
return;
|
||||
MC_AddCheckBox(menu_script, x, y, text, cvar);
|
||||
MC_AddCheckBox(menu_script, x, y, text, cvar, bitmask);
|
||||
}
|
||||
|
||||
void M_MenuS_Slider_f (void)
|
||||
|
|
|
@ -97,6 +97,7 @@ typedef struct {
|
|||
menucommon_t common;
|
||||
const char *text;
|
||||
cvar_t *var;
|
||||
int bits;
|
||||
float value;
|
||||
qboolean (*func) (union menuoption_s *option, chk_set_t set);
|
||||
} menucheck_t;
|
||||
|
@ -191,7 +192,7 @@ menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, char *picname);
|
|||
menupicture_t *MC_AddCenterPicture(menu_t *menu, int y, char *picname);
|
||||
menupicture_t *MC_AddCursor(menu_t *menu, int x, int y);
|
||||
menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t *var, float min, float max);
|
||||
menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t *var);
|
||||
menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t *var, int cvarbitmask);
|
||||
menubutton_t *MC_AddConsoleCommand(menu_t *menu, int x, int y, const char *text, const char *command);
|
||||
menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*command) (union menuoption_s *,struct menu_s *,int));
|
||||
|
||||
|
@ -288,3 +289,7 @@ void M_DrawCharacter (int cx, int line, unsigned int num);
|
|||
void M_Print (int cx, int cy, qbyte *str);
|
||||
void M_PrintWhite (int cx, int cy, qbyte *str);
|
||||
void M_DrawPic (int x, int y, qpic_t *pic);
|
||||
|
||||
|
||||
void M_FindKeysForCommand (char *command, int *twokeys);
|
||||
void M_UnbindCommand (char *command);
|
||||
|
|
Loading…
Reference in a new issue