2016-01-18 05:22:07 +00:00
/*
The main / root menu .
Just a load of text with console commands attached .
Choice of buttons available is somewhat dynamic .
There ' s also some generic kludge crap in here , like menu background tints
*/
2020-08-13 10:09:39 +00:00
enum
{
E_FTE ,
E_QSS ,
} engine ; //For use ONLY with known possible cvar values.
void ( ) FingerprintEngine =
{ //this is evil.
//different engines have different values/meanings for different cvars.
//basically we end up having no choice but to guess which engine we're running in, otherwise we can't tailor all the options properly.
string e = cvar_string ( " pr_engine " ) ;
if ( strstrofs ( e , " QSS " ) > = 0 )
engine = E_QSS ;
else if ( strstrofs ( e , " FTE " ) > = 0 )
engine = E_FTE ;
else
engine = E_FTE ; //don't really know.
} ;
2016-01-18 05:22:07 +00:00
/*
Adds a background tint to a ( typically ) exmenu parent .
In FTE , we use built - in stuff to give a sepia effect .
In DP , we just tint it black .
*/
nonstatic void ( mitem_frame m ) addmenuback =
{
if ( iscachedpic ( " menutint " ) ) //fte internal hacks! meh, admit it. its cool.
m . add ( spawn ( mitem_pic , item_text : " menutint " , item_alpha : 0.5 ) ,
RS_X_MIN_PARENT_MIN | RS_Y_MIN_PARENT_MIN | RS_X_MAX_PARENT_MAX | RS_Y_MAX_PARENT_MAX , [ 0 , 0 ] , [ 0 , 0 ] ) ;
else
m . add ( spawn ( mitem_fill , item_rgb : ' 0 0 0.01 ' , item_alpha : 0.5 ) ,
RS_X_MIN_PARENT_MIN | RS_Y_MIN_PARENT_MIN | RS_X_MAX_PARENT_MAX | RS_Y_MAX_PARENT_MAX , [ 0 , 0 ] , [ 0 , 0 ] ) ;
} ;
/*
helper functions to avoid blowing up in older clients .
*/
2020-07-01 05:06:13 +00:00
# define cv2(dpc,qwc) (cvar_type(dpc)?dpc:qwc)
# define cv3(dpc,qs,qwc) (cvar_type(dpc)?dpc:(cvar_type(qs)?qs:qwc))
# ifdef CSQC
# define ISMENUQC FALSE
# else
# define ISMENUQC TRUE
# endif
float ( string cmd , float assumption ) checkcommand2 =
2016-01-18 05:22:07 +00:00
{
2021-04-08 19:16:34 +00:00
__using checkcommand ;
2016-01-18 05:22:07 +00:00
if ( ! checkextension ( " FTE_QC_CHECKCOMMAND " ) )
2020-07-01 05:06:13 +00:00
return assumption ;
2016-01-18 05:22:07 +00:00
return checkcommand ( cmd ) ;
} ;
2020-04-19 03:56:01 +00:00
float ( __variant cmd , float assumption ) checkbuiltin2 =
{
2020-07-01 05:06:13 +00:00
if ( ! checkbuiltin ( checkbuiltin ) ) //teehee. if the #0 stuff isn't working (DP) then it ends up calling an OP_DONE(0) instruction giving a return false.
2020-04-19 03:56:01 +00:00
return assumption ;
return checkbuiltin ( cmd ) ;
} ;
2021-04-08 19:16:34 +00:00
# define checkbuiltin2(c,a) ((a)?checkbuiltin2(c,a):checkbuiltin(c))
2016-01-18 05:22:07 +00:00
2020-07-01 05:06:13 +00:00
# ifdef CSQC
float ( ) clientstate =
{
if ( serverkey ( " constate " ) ! = " disconnected " )
return 2 ;
return 1 ;
} ;
# endif
2016-01-18 05:22:07 +00:00
nonstatic void ( mitem_desktop desktop ) M_Main =
{
local float y ;
local mitem_exmenu m ;
//no dupes please.
2016-02-10 23:23:43 +00:00
m = ( mitem_exmenu ) desktop . findchildtext ( _ ( " Main Menu " ) ) ;
2016-01-18 05:22:07 +00:00
if ( m )
{
m . totop ( ) ;
return ;
}
//create a fullscreen frame
m = spawn ( mitem_exmenu , item_text : _ ( " Main Menu " ) , item_flags : IF_SELECTABLE ) ;
desktop . add ( m , RS_X_MIN_PARENT_MIN | RS_Y_MIN_PARENT_MIN | RS_X_MAX_PARENT_MAX | RS_Y_MAX_PARENT_MAX , ' 0 0 ' , ' 0 0 ' ) ;
desktop . item_focuschange ( m , IF_KFOCUSED ) ;
m . totop ( ) ;
// m.item_flags |= IF_NOKILL;
// m.adda(menuitempic_spawn ("gfx/qplaque.lmp", '32 144'), '16 4');
y = 7 * - 16 / 2 ;
//draw title art above the options
mitem_pic banner = spawn ( mitem_pic , item_text : " gfx/ttl_main.lmp " , item_size_y : 24 , item_flags : IF_CENTERALIGN ) ;
m . add ( banner , RS_X_MIN_PARENT_MID | RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID | RS_Y_MAX_PARENT_MID , [ ( 160 - banner . item_size_x ) * 0.5 , y - 32 ] , [ ( 160 + banner . item_size_x ) * 0.5 , y - 8 ] ) ;
//a macro, in a desperate attempt at readability
# define menuitemtext_cladd16(m,t,c,y) m.addm(spawn(mitem_text, item_text:t, item_command:c, item_scale:16, item_flags:IF_CENTERALIGN), [0, y], [160, y+16])
Added sys_openfile console command(and menu option) to web and flatpak(via cmake+dbus) builds, to 'install' packages on sandboxed systems a bit more easily.
Cmake: Add FTE_WERROR option, defaults to true in debug builds and off in release builds (in case future compilers have issues).
Cmake: Pull in libXscreensaver so we don't get interrupted by screensavers when playing demos.
Make: Added `make webcl-rel` for a web build without server bloat (eg for sites focused on demo playback. Yes, this means you XantoM).
fteqcc: Include the decompiler in fteqcc (non-gui) builds ('-d' arg).
fteqcc: Decompiler can now mostly handle hexen2 mods without any unknown opcodes.
Allow ezHud and OpenSSL to be compiled as in-engine plugins, potentially for web and windows ports respectively.
Web: Fix support for ogg vorbis. Add support for voip.
Web: Added basic support for WebXR.
QTV: Don't try seeking on unseekable qtv streams. Don't spam when developer 1 is set.
QTV: add support for some eztv extensions.
MVD: added hack to use ktx's vweps in mvd where mvdsv doesn't bother to record the info.
qwfwd: hack around a hack in qwfwd, allowing it to work again.
recording: favour qwd in single player, instead of mvd.
Protocol: reduce client memory used for precache names. Bump maximum precache counts - some people are just abusive, yes you Orl.
hexen2: add enough clientside protocol compat to play the demo included with h2mp. lacks effects.
in_xflip: restored this setting.
fs_hidesyspaths: new cvar, defaults to enabled so you won't find your username or whatever turning up in screenshots or the like. change it to 0 before debuging stuff eg via 'path'.
gl_overbright_models: Added cvar to match QS.
netchan: Added MTU determination, we'll no longer fail to connect when routers stupidly drop icmp packets.
Win: try a few other versions of xinput too.
CSQC: Added a CSQC_GenerateMaterial function, to give the csqc a chance to generate custom materials.
MenuQC: Added support for the skeletal objects API.
2024-04-09 17:13:59 +00:00
if ( clientstate ( ) = = 2 ) { menuitemtext_cladd16 ( m , isdemo ( ) ? _ ( " Return To Demo " ) : _ ( " Return To Game " ) ,
" m_pop " , y ) ; y + = 16 ; }
if ( clientstate ( ) = = 2 ) { menuitemtext_cladd16 ( m , isdemo ( ) ? _ ( " End Demo " ) : ( isserver ? _ ( " End Game " ) : _ ( " Disconnect " ) ) ,
" m_pop;disconnect " , y ) ; y + = 16 ; }
if ( isserver ( ) ! = 1 & & checkbuiltin2 ( gethostcacheindexforkey , ISMENUQC ) ) { menuitemtext_cladd16 ( m , _ ( " Join Server " ) ,
" m_pop;m_servers " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " map " , TRUE ) ) { menuitemtext_cladd16 ( m , _ ( " New Game " ) , " m_pop;m_newgame " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " menu_demo " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Demos " ) , " m_pop;menu_demo " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " save " , TRUE ) & & ( isserver ( ) | | dp_workarounds ) ) { menuitemtext_cladd16 ( m , _ ( " Save " ) , " m_pop;m_save " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " load " , TRUE ) ) { menuitemtext_cladd16 ( m , _ ( " Load " ) , " m_pop;m_load " , y ) ; y + = 16 ; }
2020-07-01 05:06:13 +00:00
if ( checkcommand2 ( " cef " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Browser " ) , " m_pop;cef google.com " , y ) ; y + = 16 ; }
Added sys_openfile console command(and menu option) to web and flatpak(via cmake+dbus) builds, to 'install' packages on sandboxed systems a bit more easily.
Cmake: Add FTE_WERROR option, defaults to true in debug builds and off in release builds (in case future compilers have issues).
Cmake: Pull in libXscreensaver so we don't get interrupted by screensavers when playing demos.
Make: Added `make webcl-rel` for a web build without server bloat (eg for sites focused on demo playback. Yes, this means you XantoM).
fteqcc: Include the decompiler in fteqcc (non-gui) builds ('-d' arg).
fteqcc: Decompiler can now mostly handle hexen2 mods without any unknown opcodes.
Allow ezHud and OpenSSL to be compiled as in-engine plugins, potentially for web and windows ports respectively.
Web: Fix support for ogg vorbis. Add support for voip.
Web: Added basic support for WebXR.
QTV: Don't try seeking on unseekable qtv streams. Don't spam when developer 1 is set.
QTV: add support for some eztv extensions.
MVD: added hack to use ktx's vweps in mvd where mvdsv doesn't bother to record the info.
qwfwd: hack around a hack in qwfwd, allowing it to work again.
recording: favour qwd in single player, instead of mvd.
Protocol: reduce client memory used for precache names. Bump maximum precache counts - some people are just abusive, yes you Orl.
hexen2: add enough clientside protocol compat to play the demo included with h2mp. lacks effects.
in_xflip: restored this setting.
fs_hidesyspaths: new cvar, defaults to enabled so you won't find your username or whatever turning up in screenshots or the like. change it to 0 before debuging stuff eg via 'path'.
gl_overbright_models: Added cvar to match QS.
netchan: Added MTU determination, we'll no longer fail to connect when routers stupidly drop icmp packets.
Win: try a few other versions of xinput too.
CSQC: Added a CSQC_GenerateMaterial function, to give the csqc a chance to generate custom materials.
MenuQC: Added support for the skeletal objects API.
2024-04-09 17:13:59 +00:00
if ( checkcommand2 ( " xmpp " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Social " ) , " m_pop;xmpp " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " irc " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " IRC " ) , " m_pop;irc /info " , y ) ; y + = 16 ; }
/*if (checkbuiltin2(getpackagemanagerinfo,FALSE)) {menuitemtext_cladd16(m, _("Updates+Packages"), "m_pop;m_updates", y); y += 16;}
else */ if ( checkcommand2 ( " menu_download " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Updates+Packages " ) , " m_pop;menu_download " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " qi " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Quake Injector " ) , " m_pop;qi " , y ) ; y + = 16 ; }
if ( checkbuiltin2 ( getgamedirinfo , TRUE ) ) { menuitemtext_cladd16 ( m , _ ( " Mods " ) , " m_pop;m_mods " , y ) ; y + = 16 ; }
if ( checkcommand2 ( " sys_openfile " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Open/Add External File " ) , " m_pop;sys_openfile " , y ) ; y + = 16 ; } //opens a file chooser dialog in eg chromium.
if ( checkcommand2 ( " xr_toggle " , FALSE ) ) { menuitemtext_cladd16 ( m , _ ( " Toggle VR " ) , " m_pop;xr_toggle " , y ) ; y + = 16 ; } //for webxr support
{ menuitemtext_cladd16 ( m , _ ( " Options " ) , " m_pop;m_options " , y ) ; y + = 16 ; }
{ menuitemtext_cladd16 ( m , _ ( " Quit " ) , " m_pop;m_quit " , y ) ; y + = 16 ; }
2016-01-18 05:22:07 +00:00
//spinny quad/pent, for the luls
local string it = ( random ( ) < 0.9 ) ? " progs/quaddama.mdl " : " progs/invulner.mdl " ;
m . add ( spawn ( mitem_spinnymodel , item_text : it ) , RS_X_MIN_PARENT_MID | RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID | RS_Y_MAX_PARENT_MID , [ - 160 , 12 * - 16 / 2 ] , [ 0 , 12 * 16 / 2 ] ) ;
2024-04-14 03:45:33 +00:00
# ifdef REVISION
# define MENUSYS_REVISION REVISION
# else
# define MENUSYS_REVISION "<UNKNOWN>"
# endif
2020-08-13 10:09:39 +00:00
# ifdef CSQC
2024-04-14 03:45:33 +00:00
# define MODLEPOSTFIX "-CSQC"
2020-08-13 10:09:39 +00:00
# else
2024-04-14 03:45:33 +00:00
# define MODLEPOSTFIX "-MQC"
2020-08-13 10:09:39 +00:00
# endif
2024-04-14 03:45:33 +00:00
m . add ( spawn ( mitem_text , item_text : strcat ( " MenuSys " MENUSYS_REVISION MODLEPOSTFIX " ; " , cvar_string ( " pr_engine " ) ) , item_scale : 8 ) , RS_X_MIN_PARENT_MIN | RS_Y_MIN_PARENT_MAX | RS_X_MAX_PARENT_MAX | RS_Y_MAX_PARENT_MAX , [ 0 , - 8 ] , [ 0 , 0 ] ) ;
2016-01-18 05:22:07 +00:00
addmenuback ( m ) ;
} ;