Menu/Client/Server: Background map support for menus. This should be handled differently in that SV_ShouldPause ought to control Singleplayer as well. Engine hardcodes suck
This commit is contained in:
parent
54f0c5d24c
commit
57cc661c86
|
@ -150,6 +150,12 @@ CSQC_UpdateView(float w, float h, float focus)
|
||||||
video_res[0] = w;
|
video_res[0] = w;
|
||||||
video_res[1] = h;
|
video_res[1] = h;
|
||||||
|
|
||||||
|
cvar_set("_background", serverkey("background"));
|
||||||
|
|
||||||
|
if (serverkeyfloat("background") == 1) {
|
||||||
|
setpause(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_iCubeProcess == TRUE) {
|
if (g_iCubeProcess == TRUE) {
|
||||||
clearscene();
|
clearscene();
|
||||||
setproperty(VF_DRAWWORLD, TRUE);
|
setproperty(VF_DRAWWORLD, TRUE);
|
||||||
|
@ -430,13 +436,17 @@ CSQC_Input_Frame(void)
|
||||||
int s = (float)getproperty(VF_ACTIVESEAT);
|
int s = (float)getproperty(VF_ACTIVESEAT);
|
||||||
pSeat = &g_seats[s];
|
pSeat = &g_seats[s];
|
||||||
|
|
||||||
// If we are inside a VGUI, don't let the client do stuff outside
|
/* If we are inside a VGUI, don't let the client do stuff outside */
|
||||||
if (g_vguiWidgetCount > 0) {
|
if (g_vguiWidgetCount > 0) {
|
||||||
input_impulse = 0;
|
input_impulse = 0;
|
||||||
input_buttons = 0;
|
input_buttons = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* background maps have no input */
|
||||||
|
if (serverkeyfloat("background") == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
/* The HUD needs more time */
|
/* The HUD needs more time */
|
||||||
if ((pSeat->m_iHUDWeaponSelected) && (input_buttons & INPUT_BUTTON0)) {
|
if ((pSeat->m_iHUDWeaponSelected) && (input_buttons & INPUT_BUTTON0)) {
|
||||||
HUD_DrawWeaponSelect_Trigger();
|
HUD_DrawWeaponSelect_Trigger();
|
||||||
|
|
|
@ -33,6 +33,7 @@ int g_lastmousepos[2];
|
||||||
int g_active;
|
int g_active;
|
||||||
float g_btnofs;
|
float g_btnofs;
|
||||||
float frametime;
|
float frametime;
|
||||||
|
var int g_background = FALSE;
|
||||||
|
|
||||||
/* Font IDs */
|
/* Font IDs */
|
||||||
int font_label;
|
int font_label;
|
||||||
|
|
|
@ -95,6 +95,7 @@ m_init(void)
|
||||||
print("\n\n");
|
print("\n\n");
|
||||||
|
|
||||||
registercommand("menu_customgame");
|
registercommand("menu_customgame");
|
||||||
|
registercommand("map_background");
|
||||||
font_console = loadfont("font", "", "12", -1);
|
font_console = loadfont("font", "", "12", -1);
|
||||||
font_label = loadfont("label", "gfx/shell/mssansserif.ttf", "10 12 14", -1);
|
font_label = loadfont("label", "gfx/shell/mssansserif.ttf", "10 12 14", -1);
|
||||||
font_arial = loadfont("label", "gfx/shell/arial.ttf", "14 11 12", -1);
|
font_arial = loadfont("label", "gfx/shell/arial.ttf", "14 11 12", -1);
|
||||||
|
@ -181,15 +182,24 @@ m_draw(vector screensize)
|
||||||
Menu_AutoScale();
|
Menu_AutoScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_background = cvar("_background");
|
||||||
|
|
||||||
|
if (g_background) {
|
||||||
|
setkeydest(KEY_MENU);
|
||||||
|
setmousetarget(TARGET_MENU);
|
||||||
|
setcursormode(TRUE, "gfx/cursor");
|
||||||
|
}
|
||||||
|
|
||||||
/* to prevent TCP timeouts */
|
/* to prevent TCP timeouts */
|
||||||
menu_chatrooms_keepalive();
|
menu_chatrooms_keepalive();
|
||||||
|
|
||||||
if (!g_active) {
|
if (!g_active && !g_background) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientstate() == 2) {
|
if (clientstate() == 2) {
|
||||||
drawfill([0,0], screensize, [0,0,0], 0.75f);
|
if (!g_background)
|
||||||
|
drawfill([0,0], screensize, [0,0,0], 0.75f);
|
||||||
} else {
|
} else {
|
||||||
drawfill([0,0], screensize, [0,0,0], 1.0f);
|
drawfill([0,0], screensize, [0,0,0], 1.0f);
|
||||||
drawpic([g_menuofs[0],g_menuofs[1]], g_bmp[SPLASH],
|
drawpic([g_menuofs[0],g_menuofs[1]], g_bmp[SPLASH],
|
||||||
|
@ -226,7 +236,7 @@ Menu_InputEvent(float evtype, float scanx, float chary, float devid)
|
||||||
switch (evtype) {
|
switch (evtype) {
|
||||||
case IE_KEYDOWN:
|
case IE_KEYDOWN:
|
||||||
if (chary == K_ESCAPE) {
|
if (chary == K_ESCAPE) {
|
||||||
if (clientstate() == 2) {
|
if (clientstate() == 2 && !g_background) {
|
||||||
m_toggle(0);
|
m_toggle(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,6 +311,10 @@ m_consolecommand(string cmd)
|
||||||
case "togglemenu":
|
case "togglemenu":
|
||||||
m_display();
|
m_display();
|
||||||
break;
|
break;
|
||||||
|
case "map_background":
|
||||||
|
localcmd(sprintf("maxplayers 2\nset coop 1\nset sv_background 1\nmap %s\n",
|
||||||
|
argv(1)));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ menu_main_init(void)
|
||||||
void
|
void
|
||||||
menu_main_draw(void)
|
menu_main_draw(void)
|
||||||
{
|
{
|
||||||
if (clientstate() == 2) {
|
if (clientstate() == 2 && !g_background) {
|
||||||
Widget_Draw(fn_main2);
|
Widget_Draw(fn_main2);
|
||||||
WLabel_Static(235, 216, m_reslbl[IDS_MAIN_RETURNHELP], 10, 10,
|
WLabel_Static(235, 216, m_reslbl[IDS_MAIN_RETURNHELP], 10, 10,
|
||||||
col_help,1.0f, 0, font_label);
|
col_help,1.0f, 0, font_label);
|
||||||
|
@ -429,7 +429,7 @@ menu_main_input(float evtype, float scanx, float chary, float devid)
|
||||||
if (main_quitdialog) {
|
if (main_quitdialog) {
|
||||||
Widget_Input(main_dgQuit, evtype, scanx, chary, devid);
|
Widget_Input(main_dgQuit, evtype, scanx, chary, devid);
|
||||||
} else {
|
} else {
|
||||||
if (clientstate() == 2) {
|
if (clientstate() == 2 && !g_background) {
|
||||||
Widget_Input(fn_main2, evtype, scanx, chary, devid);
|
Widget_Input(fn_main2, evtype, scanx, chary, devid);
|
||||||
} else {
|
} else {
|
||||||
Widget_Input(fn_main, evtype, scanx, chary, devid);
|
Widget_Input(fn_main, evtype, scanx, chary, devid);
|
||||||
|
|
|
@ -36,7 +36,8 @@ void Background_Init ( void )
|
||||||
void Background_Draw ( vector vecSize )
|
void Background_Draw ( vector vecSize )
|
||||||
{
|
{
|
||||||
if ( clientstate() == 2 ) {
|
if ( clientstate() == 2 ) {
|
||||||
drawfill( [ 0, 0 ], vecSize, [ 0, 0, 0 ], 0.5f );
|
if (!g_background)
|
||||||
|
drawfill( [ 0, 0 ], vecSize, [ 0, 0, 0 ], 0.5f );
|
||||||
} else {
|
} else {
|
||||||
if ( g_iBackgroundLoaded == TRUE ) {
|
if ( g_iBackgroundLoaded == TRUE ) {
|
||||||
drawpic( [ 0, 0 ], BACKGROUND_IMG, vecSize, [ 1, 1, 1 ], 1.0f );
|
drawpic( [ 0, 0 ], BACKGROUND_IMG, vecSize, [ 1, 1, 1 ], 1.0f );
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
int g_iMenuActive;
|
int g_iMenuActive;
|
||||||
vector video_res;
|
vector video_res;
|
||||||
|
var int g_background = FALSE;
|
||||||
|
|
||||||
var float frametime;
|
var float frametime;
|
||||||
var float lasttime;
|
var float lasttime;
|
||||||
|
|
|
@ -41,6 +41,7 @@ void m_init ( void )
|
||||||
|
|
||||||
registercommand( "menu_quit" );
|
registercommand( "menu_quit" );
|
||||||
registercommand( "menu_music" );
|
registercommand( "menu_music" );
|
||||||
|
registercommand( "map_background" );
|
||||||
Menu_AutoScale();
|
Menu_AutoScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +63,15 @@ void m_draw ( vector vecScreensize )
|
||||||
Menu_AutoScale();
|
Menu_AutoScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !g_iMenuActive ) {
|
g_background = cvar("_background");
|
||||||
|
|
||||||
|
if (g_background) {
|
||||||
|
setkeydest(KEY_MENU);
|
||||||
|
setmousetarget(TARGET_MENU);
|
||||||
|
setcursormode(TRUE, "gfx/cursor");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !g_iMenuActive && !g_background ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,26 +83,57 @@ void m_draw ( vector vecScreensize )
|
||||||
Desktop_Draw();
|
Desktop_Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
float Menu_InputEvent ( float flEvType, float flScanX, float flCharY, float flDevID )
|
float Menu_InputEvent ( float evtype, float scanx, float chary, float devid )
|
||||||
{
|
{
|
||||||
g_uiDesktop.Input( flEvType, flScanX, flCharY, flDevID );
|
switch (evtype) {
|
||||||
|
case IE_KEYDOWN:
|
||||||
|
if (chary == K_ESCAPE) {
|
||||||
|
if (clientstate() == 2 && !g_background) {
|
||||||
|
m_toggle(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_uiDesktop.Input( evtype, scanx, chary, devid );
|
||||||
return (float)g_iMenuActive;
|
return (float)g_iMenuActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void m_toggle ( float flWantMode )
|
void
|
||||||
|
m_display(void)
|
||||||
{
|
{
|
||||||
dprint( sprintf( "[MENU] m_toggle: %d\n", flWantMode ) );
|
g_iMenuActive = TRUE;
|
||||||
|
setkeydest(KEY_MENU);
|
||||||
|
setmousetarget(TARGET_MENU);
|
||||||
|
setcursormode(TRUE, "gfx/cursor");
|
||||||
|
}
|
||||||
|
|
||||||
if ( flWantMode == 0 ) {
|
/*
|
||||||
g_iMenuActive = FALSE;
|
=================
|
||||||
setkeydest( KEY_GAME );
|
m_hide
|
||||||
setmousetarget( TARGET_CLIENT );
|
=================
|
||||||
setcursormode( FALSE );
|
*/
|
||||||
|
void
|
||||||
|
m_hide(void)
|
||||||
|
{
|
||||||
|
g_iMenuActive = FALSE;
|
||||||
|
setkeydest(KEY_GAME);
|
||||||
|
setmousetarget(TARGET_CLIENT);
|
||||||
|
setcursormode(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
m_toggle
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
m_toggle(float fMode)
|
||||||
|
{
|
||||||
|
if (fMode == FALSE) {
|
||||||
|
m_hide();
|
||||||
} else {
|
} else {
|
||||||
g_iMenuActive = TRUE;
|
m_display();
|
||||||
setkeydest( KEY_MENU );
|
|
||||||
setmousetarget( TARGET_MENU );
|
|
||||||
setcursormode( TRUE, "gfx/cursor" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,17 +143,21 @@ float m_consolecommand ( string strCommand )
|
||||||
tokenize( strCommand );
|
tokenize( strCommand );
|
||||||
|
|
||||||
switch ( argv( 0 ) ) {
|
switch ( argv( 0 ) ) {
|
||||||
case "menu_quit":
|
case "menu_quit":
|
||||||
UI_QuitGame_Show();
|
UI_QuitGame_Show();
|
||||||
break;
|
break;
|
||||||
case "menu_music":
|
case "menu_music":
|
||||||
UI_MusicPlayer_Show();
|
UI_MusicPlayer_Show();
|
||||||
break;
|
break;
|
||||||
case "showconsole":
|
case "showconsole":
|
||||||
UI_Console_Show();
|
UI_Console_Show();
|
||||||
break;
|
break;
|
||||||
default:
|
case "map_background":
|
||||||
return FALSE;
|
localcmd(sprintf("maxplayers 2\nset coop 1\nset sv_background 1\nmap %s\n",
|
||||||
|
argv(1)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -243,6 +243,14 @@ void initents(void)
|
||||||
entity respawntimer = spawn();
|
entity respawntimer = spawn();
|
||||||
respawntimer.think = init_respawn;
|
respawntimer.think = init_respawn;
|
||||||
respawntimer.nextthink = time + 0.1f;
|
respawntimer.nextthink = time + 0.1f;
|
||||||
|
|
||||||
|
/* menu background lock */
|
||||||
|
if (cvar("sv_background") == 1) {
|
||||||
|
forceinfokey(world, "background", "1");
|
||||||
|
localcmd("sv_background 0\n");
|
||||||
|
} else {
|
||||||
|
forceinfokey(world, "background", "0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void worldspawn(void)
|
void worldspawn(void)
|
||||||
|
@ -268,3 +276,12 @@ float ConsoleCmd(string cmd)
|
||||||
player pl = (player)self;
|
player pl = (player)self;
|
||||||
return g_grMode.ConsoleCommand(pl, cmd);
|
return g_grMode.ConsoleCommand(pl, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SV_ShouldPause(float newstatus)
|
||||||
|
{
|
||||||
|
if (serverkeyfloat("background") == 1) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newstatus;
|
||||||
|
}
|
||||||
|
|
|
@ -54,12 +54,12 @@ void CUIMenuButton::CUIMenuButton(void)
|
||||||
void CUIMenuButton::Draw(void)
|
void CUIMenuButton::Draw(void)
|
||||||
{
|
{
|
||||||
// If we're not ingame
|
// If we're not ingame
|
||||||
if (clientstate() != 2) {
|
if (clientstate() == 2 && !g_background) {
|
||||||
if (!(m_iFlags & MBUTTON_SHOWOFFLINE)) {
|
if (!(m_iFlags & MBUTTON_SHOWSP)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(m_iFlags & MBUTTON_SHOWSP)) {
|
if (!(m_iFlags & MBUTTON_SHOWOFFLINE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue