Skip to content

Instantly share code, notes, and snippets.

@zturtleman
Last active August 29, 2015 14:01
Show Gist options
  • Save zturtleman/108c2a935534bf369ee2 to your computer and use it in GitHub Desktop.
Save zturtleman/108c2a935534bf369ee2 to your computer and use it in GitHub Desktop.
Per-player menu drawing for mint-arena. Doesn't handle /separate/ menus, draws the same menu in all viewports.
diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c
index 148011a..d985645 100644
--- a/code/cgame/cg_main.c
+++ b/code/cgame/cg_main.c
@@ -2687,14 +2687,15 @@ void CG_Refresh( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback
UI_SetActiveMenu( UIMENU_MAIN );
}
- if ( state >= CA_LOADING && state != CA_CINEMATIC && !UI_IsFullscreen() ) {
+ if ( state >= CA_LOADING && state != CA_CINEMATIC ) {
#ifdef MISSIONPACK_HUD
Init_Display(&cgDC);
#endif
CG_DrawActiveFrame( serverTime, stereoView, demoPlayback );
}
- if ( ( state > CA_DISCONNECTED && state <= CA_LOADING ) || (trap_Key_GetCatcher() & KEYCATCH_UI) ) {
+ // main menu or loading
+ if ( ( state > CA_DISCONNECTED && state <= CA_LOADING ) || ( state == CA_DISCONNECTED && trap_Key_GetCatcher() & KEYCATCH_UI) ) {
if ( ui_stretch.integer ) {
CG_SetScreenPlacement( PLACE_STRETCH, PLACE_STRETCH );
} else {
diff --git a/code/cgame/cg_view.c b/code/cgame/cg_view.c
index be24e98..7427446 100644
--- a/code/cgame/cg_view.c
+++ b/code/cgame/cg_view.c
@@ -31,6 +31,7 @@ Suite 120, Rockville, Maryland 20850 USA.
// cg_view.c -- setup all the parameters (position, angle, etc)
// for a 3D rendering
#include "cg_local.h"
+#include "../ui/ui_public.h"
/*
@@ -1080,6 +1081,11 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
inwater = CG_CalcViewValues();
CG_SetupFrustum();
+ // skip world scene if fullscreen menu (after calling CG_CalcVrect via CG_CalcViewValues)
+ if ( UI_IsFullscreen() ) {
+ goto menusonly;
+ }
+
CG_DrawSkyBoxPortal();
// first person blend blobs, done after AnglesToAxis
@@ -1137,6 +1143,17 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
// actually issue the rendering calls
CG_DrawActive( stereoView );
+
+menusonly:
+ // draw menus
+ if ( (trap_Key_GetCatcher() & KEYCATCH_UI) ) {
+ if ( ui_stretch.integer ) {
+ CG_SetScreenPlacement( PLACE_STRETCH, PLACE_STRETCH );
+ } else {
+ CG_SetScreenPlacement( PLACE_CENTER, PLACE_CENTER );
+ }
+ UI_Refresh( cg.realTime );
+ }
}
cg.cur_localClientNum = -1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment