2016-01-18 05:22:07 +00:00
#pragma progs_dat "../menu.dat"
2020-07-13 21:11:22 +00:00
2016-01-18 05:22:07 +00:00
//#pragma target fte
#define MENU //select the module
#includelist
fteextensions.qc //also sets up system defs
menusys/mitems.qc //root item type
menusys/mitems_common.qc //basic types
menusys/mitem_desktop.qc //other sort of root item
menusys/mitem_exmenu.qc //fullscreen/exclusive menus
menusys/mitem_edittext.qc //simple text editor
menusys/mitem_tabs.qc //tabs
menusys/mitem_colours.qc //colour picker
menusys/mitem_checkbox.qc //checkbox (boolean thingies)
menusys/mitem_slider.qc //scrollbars
menusys/mitem_combo.qc //multiple-choice thingies
menusys/mitem_bind.qc //key binding thingie
menusys/mitem_spinnymodel.qc //menu art
#endlist
2020-07-13 21:11:22 +00:00
enum
{
E_FTE,
E_QSS,
} engine; //For use ONLY with known possible cvar values.
2016-01-18 05:22:07 +00:00
//might as well put this here.
void(mitem_desktop desktop) M_Pop =
{
mitem it = desktop.item_kactivechild;
if (it)
it.item_remove();
};
//define the commands.
//cmd argments are: Name, Function, Sourcefile(may be empty)
2016-07-12 00:40:13 +00:00
#define concommandslist \
2016-01-18 05:22:07 +00:00
cmd("m_main", M_Main, menu/main.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_pop", M_Pop, ) \
2016-01-18 05:22:07 +00:00
cmd("m_options", M_Options, menu/options.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_keys", M_Options_Keys, menu/options_keys.qc) \
cmd("m_basicopts", M_Options_Basic, menu/options_basic.qc) \
cmd("m_video", M_Options_Video, menu/options_video.qc) \
2016-01-18 05:22:07 +00:00
cmd("m_effects", M_Options_Effects, menu/options_effects.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_audio", M_Options_Audio, menu/options_audio.qc) \
2016-01-18 05:22:07 +00:00
cmd("m_particles", M_Options_Particles, menu/options_particles.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_hud", M_Options_Hud, menu/options_hud.qc) \
2016-01-18 05:22:07 +00:00
cmd("m_load", M_Load, menu/loadsave.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_save", M_Save, ) \
2016-01-18 05:22:07 +00:00
cmd("m_quit", M_Quit, menu/quit.qc) \
2020-04-19 03:56:01 +00:00
cmd("m_mods", M_Menu_Mods, menu/mods.qc) \
cmd("m_updates", M_Menu_Updates, menu/updates.qc) \
cmd("m_cvars", M_Menu_Cvars, menu/cvars.qc) \
2016-01-18 05:22:07 +00:00
cmd("m_newgame", M_NewGame, menu/newgame.qc) \
cmd("m_servers", M_Servers, menu/servers.qc) \
cmd("m_configs", M_Configs, menu/options_configs.qc) \
2016-07-12 00:40:13 +00:00
cmd("m_reset", M_Reset, ) \
cmd("m_preset", M_Preset, menu/presets.qc)
2016-01-18 05:22:07 +00:00
//make sure all the right files are included
#define cmd(n,fnc,inc) inc
#includelist
concommandslist
#endlist
#undef cmd
mitem_desktop desktop;
void() m_shutdown = {};
2020-04-19 03:56:01 +00:00
void(vector screensize) m_draw =
{
if (dp_workarounds)
cltime = gettime(0);
2020-07-01 05:06:13 +00:00
items_draw(desktop, screensize);
2020-04-19 03:56:01 +00:00
};
2016-01-18 05:22:07 +00:00
void(float scan, float chr) m_keydown = {items_keypress(desktop, scan, chr, TRUE);};
void(float scan, float chr) m_keyup = {items_keypress(desktop, scan, chr, FALSE);};
2016-07-12 00:40:13 +00:00
void(float mode) m_toggle
{ //mode is stupid. 1=enable,0=disable,-1=actually toggle.
if (mode < 0)
mode = !desktop.item_kactivechild;
2016-01-18 05:22:07 +00:00
if (mode)
M_Main(desktop);
2016-07-12 00:40:13 +00:00
else while(desktop.item_kactivechild)
{
mitem it = desktop.item_kactivechild;
if (it.item_flags & IF_NOKILL)
break;
it.item_remove();
}
items_updategrabs(TRUE);
2016-01-18 05:22:07 +00:00
};
2020-04-19 03:56:01 +00:00
float(string cstr) m_consolecommand =
{
tokenize(cstr);
string cmd = argv(0);
switch(cmd)
{
//switch on the known commands.
#define cmd(n,f) case n: f(desktop); break;
concommandslist
#undef cmd
default:
return FALSE;
}
items_updategrabs(TRUE);
return TRUE;
}
2016-01-18 05:22:07 +00:00
var float autocvar_dp_workarounds_allow = TRUE;
var float autocvar_dp_workarounds_force = FALSE;
void() m_init =
{
2020-07-13 21:11:22 +00:00
string e = cvar_string("pr_engine");
if (!strncmp(e, "QSS ", 4))
engine = E_QSS;
else
engine = E_FTE;
2016-01-18 05:22:07 +00:00
desktop = spawn(mitem_desktop);
2020-04-19 03:56:01 +00:00
if (checkbuiltin(registercommand))
{
#define cmd(n,f) registercommand(n);
concommandslist
#undef cmd
}
else
{
2016-01-18 05:22:07 +00:00
//register the console commands via the alias command.
#define cmd(n,f) localcmd("alias " n " \"menu_cmd " n " $*\"\n");
2020-04-19 03:56:01 +00:00
concommandslist
2016-01-18 05:22:07 +00:00
#undef cmd
2020-04-19 03:56:01 +00:00
}
2016-01-18 05:22:07 +00:00
//work around some dp differences/bugs.
//this check identifies one significant bug in DP.
//if anyone actually cares to fix DP, then there is no reason they cannot do so by just removing DP_QC_RENDERSCENE and then fixing anything else that arises.
if (checkextension("DP_QC_RENDER_SCENE") && !checkextension("DP_CON_SET"))
dp_workarounds = autocvar(dp_workarounds_allow, TRUE);
if (autocvar(dp_workarounds_force, FALSE))
dp_workarounds = TRUE;
if (dp_workarounds)
print("^1WORKING AROUND DP BUGS\n");
//for compat with DP, 'none' is the default cursor in menuqc.
//naturally this is not ideal.
if (checkextension("FTE_QC_HARDWARECURSORS"))
setcursormode(TRUE, "");
else
print("No hardware cursors\n");
if (clientstate() == 1) //disconnected==1, supposedly
m_toggle(1);
};
void(string cstr) GameCommand =
{
tokenize(cstr);
string cmd = argv(0);
switch(cmd)
{
//switch on the known commands.
#define cmd(n,f) case n: f(desktop); break;
concommandslist
#undef cmd
default:
print("unknown command ", cmd, "\n");
break;
}
2016-07-12 00:40:13 +00:00
items_updategrabs(TRUE);
2016-01-18 05:22:07 +00:00
};
2020-07-13 21:11:22 +00:00