diff --git a/neo/sys/sys_imgui.cpp b/neo/sys/sys_imgui.cpp index 353b380e..0a23ff1e 100644 --- a/neo/sys/sys_imgui.cpp +++ b/neo/sys/sys_imgui.cpp @@ -39,6 +39,7 @@ #include "renderer/qgl.h" #include "renderer/tr_local.h" // glconfig #include "ui/DeviceContext.h" +#include "ui/UserInterface.h" extern void Com_DrawDhewm3SettingsMenu(); // in framework/dhewm3SettingsMenu.cpp extern void Com_OpenCloseDhewm3SettingsMenu( bool open ); // ditto @@ -487,7 +488,7 @@ bool ShouldShowCursor() } // if scaling Doom3 menus to 4:3 is enabled and the cursor is currently // in a black bar (Doom3 cursor is not drawn there), show the ImGui cursor - if ( r_scaleMenusTo43.GetBool() ) { + if ( idUserInterface::IsUserInterfaceScaledTo43( sessLocal.GetActiveMenu() ) ) { ImVec2 mousePos = ImGui::GetMousePos(); float w = glConfig.winWidth; float h = glConfig.winHeight; diff --git a/neo/ui/UserInterface.cpp b/neo/ui/UserInterface.cpp index 01208acd..beda9a29 100644 --- a/neo/ui/UserInterface.cpp +++ b/neo/ui/UserInterface.cpp @@ -339,6 +339,31 @@ bool idUserInterfaceLocal::InitFromFile( const char *qpath, bool rebuild, bool c return true; } +// static +bool idUserInterface::IsUserInterfaceScaledTo43( const idUserInterface* ui_ ) +{ + const idUserInterfaceLocal* ui = (const idUserInterfaceLocal*)ui_; + if ( ui == NULL ) { + assert( 0 && "why do you call this without a ui?!" ); + return false; + } + idWindow* win = ui->GetDesktop(); + if ( win == NULL ) { + return false; + } + int winFlags = win->GetFlags(); + if ( (winFlags & WIN_MENUGUI) == 0 || !r_scaleMenusTo43.GetBool() ) { + // if the window is no fullscreen menu (but an ingame menu or noninteractive like the HUD) + // or scaling menus to 4:3 by default (r_scaleMenusTo43) is disabled, + // they only get scaled if they explicitly requested it with "scaleto43 1" + return (winFlags & WIN_SCALETO43) != 0; + } else { + // if it's a fullscreen menu and r_scaleMenusTo43 is enabled, + // they get scaled to 4:3 unless they explicitly disable it with "scaleto43 0" + return (winFlags & WIN_NO_SCALETO43) == 0; + } +} + const char *idUserInterfaceLocal::HandleEvent( const sysEvent_t *event, int _time, bool *updateVisuals ) { time = _time; @@ -366,7 +391,7 @@ const char *idUserInterfaceLocal::HandleEvent( const sysEvent_t *event, int _tim const float realW = w; const float realH = h; - if(r_scaleMenusTo43.GetBool()) { + if ( IsUserInterfaceScaledTo43(this) ) { // in case we're scaling menus to 4:3, we need to take that into account // when scaling the mouse events. // no, we can't just call uiManagerLocal.dc.GetFixScaleForMenu() or sth like that, diff --git a/neo/ui/UserInterface.h b/neo/ui/UserInterface.h index 2b5eb0a1..539b1cae 100644 --- a/neo/ui/UserInterface.h +++ b/neo/ui/UserInterface.h @@ -114,6 +114,10 @@ public: virtual void SetCursor( float x, float y ) = 0; virtual float CursorX() = 0; virtual float CursorY() = 0; + + // DG: making this static so it doesn't change the vtable (and thus ABI) + // returns true if the ui's window is *not* being scaled to 4:3 + static bool IsUserInterfaceScaledTo43( const idUserInterface* ui ); };