1
0
Fork 0
forked from fte/fteqw

Menusys changes:

Added autorun setting.
Fixed greying of options that are not supported by the engine.
Fixed keyboard navigation for general widgets (special menus might still be annoying).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5285 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-08-04 15:09:18 +00:00
parent 0b2be8f4ba
commit 60afec2445
14 changed files with 248 additions and 82 deletions

View file

@ -44,33 +44,31 @@ nonstatic void(mitem_desktop desktop) M_Options_Audio =
//ambient fade
fr.add(menuitemcheck_spawn(_("Static Sounds"), "cl_staticsounds", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("Mix in Background"),"s_inactive", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("+voip"))
{
pos += 8;
fr.add(menuitemcombo_spawn(_("Microphone Device"), "cl_voip_capturedevice", '280 8', cvar_string("_cl_voip_capturedevice_opts")),
fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("VOIP Playback Vol"),"cl_voip_play", '0 2 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("VOIP Test"), "cl_voip_test", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("VOIP Record Vol"), "cl_voip_micamp", '0 4 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcombo_spawn(_("VOIP Mode"), "cl_voip_send", '280 8', _(
"0 \"Push-To-Talk\" 1 "
"\"Voice Activation\" "
"2 \"Continuous\""
)), fl, [0, pos], [0, 8]); pos += 8;
//VAD threshhold
//ducking
//noise cancelation
fr.add(menuitemcombo_spawn(_("VOIP Codec"), "cl_voip_codec", '280 8',_(
"0 \"speex (narrow 11khz)\" "
//"1 \"raw (wasteful)\" "
"2 \"opus\" "
"3 \"speex (narrow 8khz)\" "
"4 \"speex (wide 16khz)\" "
"5 \"speex (ultrawide 32khz)\" "
)), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Opus bitrate"), "cl_voip_bitrate", '0.5 128 0.5','280 8'), fl, [0, pos], [0, 8]); pos += 8;
}
pos += 8;
fr.add(menuitemcombo_spawn(_("Microphone Device"), "cl_voip_capturedevice", '280 8', cvar_string("_cl_voip_capturedevice_opts")),
fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("VOIP Playback Vol"),"cl_voip_play", '0 2 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("VOIP Test"), "cl_voip_test", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("VOIP Record Vol"), "cl_voip_micamp", '0 4 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcombo_spawn(_("VOIP Mode"), "cl_voip_send", '280 8', _(
"0 \"Push-To-Talk\" 1 "
"\"Voice Activation\" "
"2 \"Continuous\""
)), fl, [0, pos], [0, 8]); pos += 8;
//VAD threshhold
//ducking
//noise cancelation
fr.add(menuitemcombo_spawn(_("VOIP Codec"), "cl_voip_codec", '280 8',_(
"0 \"speex (narrow 11khz)\" "
//"1 \"raw (wasteful)\" "
"2 \"opus\" "
"3 \"speex (narrow 8khz)\" "
"4 \"speex (wide 16khz)\" "
"5 \"speex (ultrawide 32khz)\" "
)), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Opus bitrate"), "cl_voip_bitrate", '0.5 128 0.5','280 8'), fl, [0, pos], [0, 8]); pos += 8;
addmenuback(m);
};

View file

@ -1,7 +1,6 @@
class mitem_playerpreview : mitem_spinnymodel
{
#if defined(FTE_QC_CUSTOMSKINS)
#if 1//defined(FTE_QC_CUSTOMSKINS)
virtual void(vector pos) item_draw =
{
//if you wanted to get more advanced, you could use q3 skins here.
@ -39,12 +38,16 @@ class options_basic : mitem_exmenu
{
if (key == "m_pitchsign")
return TRUE;
if (key == "cl_run")
return TRUE;
return super::isvalid(key);
};
virtual string(string key) get =
{
if (key == "m_pitchsign")
return (autocvar_m_pitch<0)?"1":"0";
if (key == "cl_run")
return (stof(super::get("cl_forwardspeed")) > 200)?"1":"0";
return super::get(key);
};
virtual void(string key, string newval) set =
@ -59,6 +62,27 @@ class options_basic : mitem_exmenu
if (invert)
cvar_set("m_pitch", ftos(-autocvar_m_pitch));
}
else if (key == "cl_run")
{
float setbackspeed = (super::get("cl_backspeed") != "");
if (stof(newval))
{
super::set("cl_forwardspeed", "400");
super::set("cl_sidespeed", "400");
if (setbackspeed)
super::set("cl_backspeed", "400");
super::set("cl_movespeedkey", "0.5"); //makes +speed act like +walk
}
else
{
//these are the defaults from winquake.
super::set("cl_forwardspeed", "200");
super::set("cl_sidespeed", "350");
if (setbackspeed)
super::set("cl_backspeed", "200");
super::set("cl_movespeedkey", "2.0");
}
}
else
super::set(key, newval);
};
@ -87,14 +111,14 @@ nonstatic void(mitem_desktop desktop) M_Options_Basic =
fr.add(menuitemcombo_spawn(_("Player Skin"), "skin", '280 8', skinopts()), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("topcolor"))
fr.add(menuitemcolour_spawn(_("Upper Colour"), "topcolor", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("bottomcolor"))
fr.add(menuitemcolour_spawn(_("Lower Colour"), "bottomcolor", '280 8'), fl, [0, pos], [0, 8]); pos += 8; /*aka: arse colour*/
fr.add(menuitemcolour_spawn(_("Upper Colour"), "topcolor", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcolour_spawn(_("Lower Colour"), "bottomcolor", '280 8'), fl, [0, pos], [0, 8]); pos += 8; /*aka: arse colour*/
pos += 8;
fr.add(menuitemcheck_spawn (_("Always Run"), "cl_run", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn (_("Invert Mouse"), "m_pitchsign", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Sensitivity"), "sensitivity", '3 20 1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Fov"), "fov", '80 130 5', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Viewmodel Fov"), "r_viewmodel_fov", '80 130 5', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Gamma"), dp("v_gamma", "gamma"), '0.4 1.3 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Contrast"), dp("v_contrast", "contrast"), '0.8 1.8 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemslider_spawn(_("Brightness"), dp("v_brightness", "brightness"),'0.0 0.5 0.1', '280 8'), fl, [0, pos], [0, 8]); pos += 8;

View file

@ -18,10 +18,8 @@ nonstatic void(mitem_desktop desktop) M_Options_Effects =
fr.add(menuitemcheck_spawn(_("Show Framerate"), dp("showfps", "show_fps"), '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("Bloom"), "r_bloom", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("r_drawflat"))
fr.add(menuitemcheck_spawn(_("Simple Textures"), "r_drawflat", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("r_softwarebanding"))
fr.add(menuitemcheck_spawn(_("Colourmapped Rendering"), "r_softwarebanding", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("Simple Textures"), "r_drawflat", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("Paletted Rendering"), "r_softwarebanding", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("HDR"), "r_hdr_irisadaptation", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("Coronas"), "r_coronas", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
fr.add(menuitemcheck_spawn(_("High Res Textures"), "gl_load24bit", '280 8'), fl, [0, pos], [0, 8]); pos += 8;
@ -37,8 +35,7 @@ nonstatic void(mitem_desktop desktop) M_Options_Effects =
"2 \"Ripples\" "
"3 \"Reflections\" "
)), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("r_projection"))
fr.add(menuitemcombo_spawn(_("View Projection"), "r_projection", '280 8', _(
fr.add(menuitemcombo_spawn(_("View Projection"), "r_projection", '280 8', _(
"0 \"Standard\" "
"1 \"Stereographic / Pannini\" "
"2 \"Fish-Eye\" "
@ -46,8 +43,7 @@ nonstatic void(mitem_desktop desktop) M_Options_Effects =
"4 \"Lambert Azimuthal Equal-Area\" "
"5 \"Equirectangular\" "
)), fl, [0, pos], [0, 8]); pos += 8;
if (assumefalsecheckcommand("ffov"))
fr.add(menuitemcombo_spawn(_("View Projection Angle"), "ffov", '280 8', _(
fr.add(menuitemcombo_spawn(_("View Projection Fov"), "ffov", '280 8', _(
"90 \"Normal\" "
"180 \"180 degrees\" "
"270 \"270 degrees\" "

View file

@ -51,6 +51,15 @@ class mitem_check : mitem
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
};
virtual void() item_resized =
{
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
else
item_flags &= ~IF_SELECTABLE;
super::item_resized();
};
};
//optional, can spawn direcly

View file

@ -8,6 +8,15 @@ class mitem_colours : mitem
{
virtual void(vector pos) item_draw;
virtual float(vector pos, float scan, float char, float down) item_keypress;
virtual void() item_resized =
{
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
else
item_flags &= ~IF_SELECTABLE;
super::item_resized();
};
};
//http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
@ -93,7 +102,31 @@ static vector(string v) hextorgb =
return r;
}
else
return '0 0 0';
{
float legacycolour = stof(v);
switch(legacycolour)
{
case 0: return [0xeb, 0xeb, 0xeb]/255;
case 1: return [0x8f, 0x6f, 0x23]/255;
case 2: return [0x8b, 0x8b, 0xcb]/255;
case 3: return [0x6b, 0x6b, 0x0f]/255;
case 4: return [0x7f, 0x00, 0x00]/255;
case 5: return [0xaf, 0x67, 0x23]/255;
case 6: return [0xff, 0xf3, 0x1b]/255;
case 7: return [0xe3, 0xb3, 0x97]/255;
case 8: return [0xab, 0x8b, 0xa3]/255;
case 9: return [0xbb, 0x73, 0x97]/255;
case 10: return [0xdb, 0xc3, 0xbb]/255;
case 11: return [0x6f, 0x83, 0x7b]/255;
case 12: return [0xff, 0xf3, 0x1b]/255;
case 13: return [0x00, 0x00, 0xff]/255;
//14+15 are fullbrights, so not valid.
default:
return '0 0 0';
}
}
};
static string(vector v) rgbtohex =
{
@ -136,6 +169,8 @@ void(vector pos) mitem_colours::item_draw =
for (step = 0; step < STEPS; step += 1, pos_x += stride)
{
rgb = hsvtorgb([step/STEPS, 1, 1]);
if (!(item_flags & IF_SELECTABLE))
rgb *= 0.2;
ui.drawfill(pos, [stride, item_size_y-2], rgb, item_alpha, 0);
}
#else

View file

@ -23,6 +23,15 @@ class mitem_combo : mitem
float visrows;
virtual void() item_remove;
virtual void() item_resized =
{
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
else
item_flags &= ~IF_SELECTABLE;
super::item_resized();
};
};
class mitem_combo_popup : mitem
@ -222,8 +231,14 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
i = 0;
curval = argv(i);
}
else if (scan == K_MOUSE1)
else if (scan == K_MOUSE1 || scan == K_ENTER)
{
if (scan == K_ENTER && cfriend)
{
cfriend.item_remove();
return TRUE;
}
visrows = ((c>18)?18/2:c/2);
if (!cfriend)
{
@ -245,7 +260,7 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
cfriend.item_flags |= IF_SELECTABLE;
cfriend.totop();
if (cfriend.item_flags & IF_MFOCUSED)
if (scan == K_MOUSE1 && (cfriend.item_flags & IF_MFOCUSED))
{
//if they clicked inside the popup, change the selected item.
f = ui.mousepos[1] - (pos_y + item_size_y);
@ -258,6 +273,8 @@ float(vector pos, float scan, float char, float down) mitem_combo::item_keypress
cfriend.item_flags &~= IF_SELECTABLE;
cfriend.item_size = cfriend.maxs = '0 0';
item_parent.item_focuschange(this, IF_MFOCUSED|IF_KFOCUSED);
cfriend.item_remove();
}
}
}

View file

@ -8,6 +8,15 @@ class mitem_edit : mitem
virtual float(vector pos, float scan, float char, float down) item_keypress;
virtual void() item_remove;
float spos;
virtual void() item_resized =
{
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
else
item_flags &= ~IF_SELECTABLE;
super::item_resized();
};
};
void() mitem_edit::item_remove =

View file

@ -24,9 +24,9 @@ class mitem_exmenu : mitem_frame
item_remove();
}
else if (scan == K_UPARROW && down)
this.item_focuschange(menu_nextitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, TRUE);
else if (scan == K_DOWNARROW && down)
this.item_focuschange(menu_previousitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, FALSE);
else if (scan >= K_F1 && scan <= K_F12) //allow f1-f12 to work, but every other button event gets canceled.
ret = FALSE;
}

View file

@ -356,43 +356,117 @@ void() mitem_vslider::mitem_vslider =
item_size[1] = 128;
};
mitem(mitem_frame menu, mitem item) menu_previousitem =
//does NOT wrap.
//does NOT pass go.
static mitem(mitem item, float upwards) menu_simplenextitem =
{
if (!item)
item = menu.item_children;
local mitem stop = item;
local mitem prev;
if (!stop)
return stop;
while(1)
mitem_frame menu = item.item_parent;
mitem prev;
if (upwards)
{
if (item)
{
item = item.item_next;
if (!item)
return __NULL__;
return item;
}
else
return __NULL__;
}
else
{
for(prev = menu.item_children; prev.item_next; prev = prev.item_next)
{
if (prev.item_next == item)
break;
return prev;
}
if (prev == stop || (prev.item_flags & IF_SELECTABLE))
return prev;
item = prev;
return __NULL__;
}
};
mitem(mitem_frame menu, mitem item) menu_nextitem =
{
if (!item)
item = menu.item_children;
local mitem stop = item;
if (!stop)
return stop;
while(1)
{
item = item.item_next;
if (!item)
item = menu.item_children;
if (item == stop || (item.item_flags & IF_SELECTABLE))
//finds the next/prev item through multiple children, returning NULL when it runs out of items in the sequence.
//call this with item==null to find the first item in the sequence (to handle wraps).
static mitem(mitem_frame menu, float upwards, mitem item) menu_findnextitem =
{
mitem_frame frame;
mitem citem;
if (item && (item.item_flags & IF_ISFRAME))
{
frame = (mitem_frame)item;
citem = menu_findnextitem(frame, upwards, frame.item_kactivechild?frame.item_kactivechild:frame.item_mactivechild);
if (citem)
return citem;
}
for(;;)
{
if (!item)
{ //we go for the opposite end here, as we assume to be starting/unfocused
item = menu.item_children;
if (!upwards && item)
{
while(item.item_next)
item = item.item_next;
}
}
else
item = menu_simplenextitem(item, upwards);
if (!item)
{ //we reached the end of the list, let the parent frame try its next
return __NULL__;
}
if (item.item_flags & IF_ISFRAME)
{ //if the next item is a frame, try and select its first element instead
frame = (mitem_frame)item;
citem = menu_findnextitem(frame, upwards, __NULL__);
if (citem)
return citem;
}
if (item.item_flags & IF_INVISIBLE)
continue;
if (item.item_flags & IF_SELECTABLE)
return item;
}
};
static void(mitem item) menu_deselectitem =
{
if (!item)
return;
if (item && (item.item_flags & IF_ISFRAME))
{
mitem_frame frame = (mitem_frame)item;
if (frame.item_kactivechild)
menu_deselectitem(frame.item_kactivechild);
}
item.item_focuschange(__NULL__, IF_KFOCUSED); //deselect the previous one
};
static void(mitem item) menu_selectitem =
{
if (!item)
return;
mitem_frame menu = item.item_parent;
if (menu)
{
if (menu.item_kactivechild != item)
menu_deselectitem(menu.item_kactivechild);
menu_selectitem(menu);
menu.item_focuschange(item, IF_KFOCUSED); //focus on the new
}
};
void(mitem_frame rootmenu, float upwards) menu_selectnextitem =
{
mitem item = menu_findnextitem(rootmenu, upwards, rootmenu.item_kactivechild?rootmenu.item_kactivechild:rootmenu.item_mactivechild);
if (!item)
item = menu_findnextitem(rootmenu, upwards, __NULL__);
menu_selectitem(item);
item.item_focuschange(item, IF_KFOCUSED); //focus on the new
};
float(vector pos, float scan, float char, float down) mitem_frame::item_keypress =

View file

@ -197,9 +197,9 @@ float(vector pos, float scan, float char, float down) mitem_menu::item_keypress
}
}
else if (scan == K_UPARROW && down)
this.item_focuschange(menu_nextitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, TRUE);
else if (scan == K_DOWNARROW && down)
this.item_focuschange(menu_previousitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, FALSE);
else if (scan == K_MOUSE2 && down && !(this.item_flags & IF_NOKILL))
{ //unhandled right click closes menus, if we're allowed
localcmd(strcat(item_command, "\n")); //console command to exec if someone clicks the close button.

View file

@ -8,6 +8,15 @@ class mitem_hslider : mitem
virtual float(vector pos, float scan, float char, float down) item_keypress;
vector item_slidercontrols; //min, max, step
virtual void() item_resized =
{
if (isvalid(item_command))
item_flags |= IF_SELECTABLE;
else
item_flags &= ~IF_SELECTABLE;
super::item_resized();
};
};
void(vector pos) mitem_hslider::item_draw =
{

View file

@ -21,9 +21,9 @@ class mitem_tab : mitem_frame
virtual float(vector pos, float scan, float char, float down) item_keypress =
{
if (scan == K_UPARROW && down)
this.item_focuschange(menu_nextitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, TRUE);
else if (scan == K_DOWNARROW && down)
this.item_focuschange(menu_previousitem(this, item_kactivechild?item_kactivechild:item_mactivechild), IF_KFOCUSED);
menu_selectnextitem(this, FALSE);
else if (super::item_keypress(pos, scan, char, down))
return TRUE;
else

View file

@ -103,11 +103,6 @@ class mitem
mitem_frame item_parent; //the item that contains us. make mitem_frame?
mitem item_next; //the next child within the parent
#ifdef MENU
// vector mins; //gravity mins
// vector maxs; //gravity mins
#endif
float resizeflags;