fteqw/quakec/menusys/menu.src

169 lines
5.7 KiB
Text

#pragma progs_dat "../menu.dat"
//#pragma target fte
#define MENU //select the module
#include "fteextensions.qc" //also sets up system defs
#includelist
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
//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)
#define concommandslist \
cmd("m_main", M_Main, menu/main.qc, "Main Menu") \
cmd("m_pop", M_Pop, , __NULL__) \
cmd("m_options", M_Options, menu/options.qc, __NULL__) \
cmd("m_keys", M_Options_Keys, menu/options_keys.qc, "Fix up the stupid default key bindings.") \
cmd("m_basicopts", M_Options_Basic, menu/options_basic.qc, "Change your public player settings, like name.") \
cmd("m_video", M_Options_Video, menu/options_video.qc, "Change video modes and devices.") \
cmd("m_effects", M_Options_Effects, menu/options_effects.qc, __NULL__) \
cmd("m_audio", M_Options_Audio, menu/options_audio.qc, "Tweak audio/voip devices+volumes+etc.") \
cmd("m_particles", M_Options_Particles, menu/options_particles.qc, __NULL__) \
cmd("m_hud", M_Options_Hud, menu/options_hud.qc, "Select which HUD layout to use") \
cmd("m_load", M_Load, menu/loadsave.qc, "Load a saved game") \
cmd("m_save", M_Save, , "Save the game for later, or for retconnoisseur purposes.") \
cmd("m_quit", M_Quit, menu/quit.qc, "Choose the cowards option") \
cmd("m_mods", M_Menu_Mods, menu/mods.qc, "Switch mod") \
cmd("m_updates", M_Menu_Updates, menu/updates.qc, __NULL__) \
cmd("m_cvars", M_Menu_Cvars, menu/cvars.qc, "Advanced confguration of all settings.") \
cmd("m_newgame", M_NewGame, menu/newgame.qc, "Start a new game!") \
cmd("m_servers", M_Servers, menu/servers.qc, "Join someone else's game") \
cmd("m_configs", M_Configs, menu/options_configs.qc, __NULL__) \
cmd("m_reset", M_Reset, , __NULL__) \
cmd("m_dir", M_Dir, , "Debug command to list data files (from qc's perspective).") \
cmd("m_cat", M_FOpen, , "Debug command to display the contents of data files (with qc's access rights).") \
cmd("m_preset", M_Preset, menu/presets.qc, __NULL__)
//make sure all the right files are included
#define cmd(n,fnc,inc,desc) inc
#includelist
concommandslist
#endlist
#undef cmd
mitem_desktop desktop;
void() m_shutdown = {};
void(vector screensize) m_draw =
{
if (dp_workarounds)
cltime = gettime(0);
items_draw(desktop, screensize);
};
float(float evtype, float scanx, float chary, float devid) Menu_InputEvent = {
if (scanx == K_TOUCH)
return TRUE; //always report this as handled. we'll not get fake mouse events then, and can handle K_TOUCHLONG/K_TOUCHTAP/etc without worry of conflicts.
return items_keypress(desktop, evtype, scanx, chary, devid);
};
void(float scan, float chr) m_keydown = {ui.mousepos = getmousepos();queryscreensize();items_keypress(desktop, IE_KEYDOWN, scan, chr, 0);}; //for DP compat.
void(float scan, float chr) m_keyup = {ui.mousepos = getmousepos();queryscreensize();items_keypress(desktop, IE_KEYUP, scan, chr, 0);}; //for DP compat.
void(float mode) m_toggle
{ //mode is stupid. 1=enable,0=disable,-1=actually toggle.
if (mode < 0)
mode = !desktop.item_kactivechild;
if (mode)
M_Main(desktop);
else while(desktop.item_kactivechild)
{
mitem it = desktop.item_kactivechild;
if (it.item_flags & IF_NOKILL)
break;
it.item_remove();
}
items_updategrabs(TRUE);
};
float(string cstr) m_consolecommand =
{ //for properly registered commands
tokenize_console(cstr);
string cmd = argv(0);
switch(cmd)
{
//switch on the known commands.
#define cmd(n,f,inc,desc) case n: f(desktop); break;
concommandslist
#undef cmd
default:
return FALSE;
}
items_updategrabs(TRUE);
return TRUE;
}
void(string cstr) GameCommand =
{ //'menu_cmd' hack for compat with DP, used via aliases and mess, instead of using the m_consolecommand entrypoint.
tokenize_console(cstr);
string cmd = argv(0);
switch(cmd)
{
//switch on the known commands.
#define cmd(n,f,inc,desc) case n: f(desktop); break;
concommandslist
#undef cmd
default:
print("unknown command ", cmd, "\n");
return;
}
items_updategrabs(TRUE);
};
var float autocvar_dp_workarounds = FALSE;
void() m_init =
{
FingerprintEngine();
desktop = spawn(mitem_desktop);
if (checkbuiltin(registercommand))
{
#define cmd(n,f,inc,desc) registercommand(n,desc);
concommandslist
#undef cmd
}
else
{
//register the console commands via the alias command. ugly.
#define cmd(n,f,inc,desc) localcmd("alias " n " \"menu_cmd " n " $*\"\n");
concommandslist
#undef cmd
}
//work around some dp differences/bugs.
if (autocvar(dp_workarounds, 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);
};