Browse Source

GameUI: fix propotional scale

sanitize
nillerusr 3 years ago
parent
commit
0772ca1063
  1. 5
      engine/vgui_baseui_interface.cpp
  2. 12
      gameui/BasePanel.cpp
  3. 2
      gameui/GameConsoleDialog.cpp
  4. 8
      gameui/GameUI_Interface.cpp
  5. 4
      gameui/OptionsSubAudio.cpp
  6. 10
      gameui/OptionsSubKeyboard.cpp
  7. 3
      gameui/OptionsSubVideo.cpp
  8. 11
      gameui/matchmaking/achievementsdialog.cpp
  9. 2
      public/vgui/VGUI.h
  10. 21
      vgui2/vgui_controls/Panel.cpp
  11. 6
      vgui2/vgui_controls/ScrollBar.cpp
  12. 9
      vgui2/vgui_controls/Slider.cpp

5
engine/vgui_baseui_interface.cpp

@ -696,10 +696,9 @@ void CEngineVGui::Init()
COM_TimestampedLog( "Building Panels (staticGameUIPanel)" ); COM_TimestampedLog( "Building Panels (staticGameUIPanel)" );
staticGameUIPanel = new CEnginePanel( staticPanel, "GameUI Panel" ); staticGameUIPanel = new CEnginePanel( staticPanel, "GameUI Panel" );
if (IsAndroid() || CommandLine()->CheckParm("-gameuiproportionality"))
{ if(NeedProportional())
staticGameUIPanel->SetProportional(true); staticGameUIPanel->SetProportional(true);
}
staticGameUIPanel->SetBounds( 0, 0, videomode->GetModeUIWidth(), videomode->GetModeUIHeight() ); staticGameUIPanel->SetBounds( 0, 0, videomode->GetModeUIWidth(), videomode->GetModeUIHeight() );
staticGameUIPanel->SetPaintBorderEnabled(false); staticGameUIPanel->SetPaintBorderEnabled(false);

12
gameui/BasePanel.cpp

@ -242,8 +242,12 @@ public:
{ {
BaseClass::ApplySchemeSettings(pScheme); BaseClass::ApplySchemeSettings(pScheme);
int height = atoi(pScheme->GetResourceString("MainMenu.MenuItemHeight"));
if( IsProportional() )
height = scheme()->GetProportionalScaledValue( height );
// make fully transparent // make fully transparent
SetMenuItemHeight(atoi(pScheme->GetResourceString("MainMenu.MenuItemHeight"))); SetMenuItemHeight(height);
SetBgColor(Color(0, 0, 0, 0)); SetBgColor(Color(0, 0, 0, 0));
SetBorder(NULL); SetBorder(NULL);
} }
@ -292,7 +296,6 @@ public:
MenuItem *item = new CGameMenuItem(this, itemName); MenuItem *item = new CGameMenuItem(this, itemName);
item->AddActionSignalTarget(target); item->AddActionSignalTarget(target);
item->SetCommand(command); item->SetCommand(command);
item->SetProportional(true);
item->SetText(itemText); item->SetText(itemText);
item->SetUserData(userData); item->SetUserData(userData);
return BaseClass::AddMenuItem(item); return BaseClass::AddMenuItem(item);
@ -303,7 +306,6 @@ public:
MenuItem *item = new CGameMenuItem(this, itemName); MenuItem *item = new CGameMenuItem(this, itemName);
item->AddActionSignalTarget(target); item->AddActionSignalTarget(target);
item->SetCommand(command); item->SetCommand(command);
item->SetProportional(true);
item->SetText(itemText); item->SetText(itemText);
item->SetUserData(userData); item->SetUserData(userData);
return BaseClass::AddMenuItem(item); return BaseClass::AddMenuItem(item);
@ -659,7 +661,6 @@ void CGameMenu::OnCursorEnteredMenuItem(int VPanel)
static CBackgroundMenuButton* CreateMenuButton( CBasePanel *parent, const char *panelName, const wchar_t *panelText ) static CBackgroundMenuButton* CreateMenuButton( CBasePanel *parent, const char *panelName, const wchar_t *panelText )
{ {
CBackgroundMenuButton *pButton = new CBackgroundMenuButton( parent, panelName ); CBackgroundMenuButton *pButton = new CBackgroundMenuButton( parent, panelName );
pButton->SetProportional(true);
pButton->SetCommand("OpenGameMenu"); pButton->SetCommand("OpenGameMenu");
pButton->SetText(panelText); pButton->SetText(panelText);
@ -673,6 +674,9 @@ bool g_bIsCreatingNewGameMenuForPreFetching = false;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CBasePanel::CBasePanel() : Panel(NULL, "BaseGameUIPanel") CBasePanel::CBasePanel() : Panel(NULL, "BaseGameUIPanel")
{ {
if( NeedProportional() )
SetProportional( true );
g_pBasePanel = this; g_pBasePanel = this;
m_bLevelLoading = false; m_bLevelLoading = false;
m_eBackgroundState = BACKGROUND_INITIAL; m_eBackgroundState = BACKGROUND_INITIAL;

2
gameui/GameConsoleDialog.cpp

@ -12,6 +12,7 @@
#include "vgui/KeyCode.h" #include "vgui/KeyCode.h"
#include "LoadingDialog.h" #include "LoadingDialog.h"
#include "IGameUIFuncs.h" #include "IGameUIFuncs.h"
#include "tier0/icommandline.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
@ -24,6 +25,7 @@ using namespace vgui;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false ) CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false )
{ {
if( NeedProportional() ) SetProportional(true);
AddActionSignalTarget( this ); AddActionSignalTarget( this );
} }

8
gameui/GameUI_Interface.cpp

@ -203,6 +203,8 @@ void CGameUI::Initialize( CreateInterfaceFn factory )
Error( "CGameUI::Initialize() failed to get necessary interfaces\n" ); Error( "CGameUI::Initialize() failed to get necessary interfaces\n" );
} }
vgui::VPANEL rootpanel = enginevguifuncs->GetPanel( PANEL_GAMEUIDLL );
// setup base panel // setup base panel
staticPanel = new CBasePanel(); staticPanel = new CBasePanel();
staticPanel->SetBounds(0, 0, 400, 300 ); staticPanel->SetBounds(0, 0, 400, 300 );
@ -212,9 +214,7 @@ void CGameUI::Initialize( CreateInterfaceFn factory )
staticPanel->SetVisible( true ); staticPanel->SetVisible( true );
staticPanel->SetMouseInputEnabled( false ); staticPanel->SetMouseInputEnabled( false );
staticPanel->SetKeyBoardInputEnabled( false ); staticPanel->SetKeyBoardInputEnabled( false );
staticPanel->SetParent(rootpanel);
vgui::VPANEL rootpanel = enginevguifuncs->GetPanel( PANEL_GAMEUIDLL );
staticPanel->SetParent( rootpanel );
} }
void CGameUI::PostInit() void CGameUI::PostInit()
@ -1282,4 +1282,4 @@ void CGameUI::SendMainMenuCommand( const char *pszCommand )
{ {
pBasePanel->RunMenuCommand( pszCommand ); pBasePanel->RunMenuCommand( pszCommand );
} }
} }

4
gameui/OptionsSubAudio.cpp

@ -362,10 +362,6 @@ void COptionsSubAudio::OnCommand( const char *command )
RunTestSpeakers(); RunTestSpeakers();
} }
} }
else if ( !stricmp( command, "ShowThirdPartyAudioCredits" ) )
{
OpenThirdPartySoundCreditsDialog();
}
BaseClass::OnCommand( command ); BaseClass::OnCommand( command );
} }

10
gameui/OptionsSubKeyboard.cpp

@ -30,6 +30,7 @@
#include <vstdlib/IKeyValuesSystem.h> #include <vstdlib/IKeyValuesSystem.h>
#include "tier2/tier2.h" #include "tier2/tier2.h"
#include "inputsystem/iinputsystem.h" #include "inputsystem/iinputsystem.h"
#include "tier0/icommandline.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
@ -760,8 +761,15 @@ public:
{ {
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below) // parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
if( NeedProportional() )
SetProportional(true);
SetTitle("#GameUI_KeyboardAdvanced_Title", true); SetTitle("#GameUI_KeyboardAdvanced_Title", true);
SetSize( 280, 140 ); if( IsProportional() )
SetSize( scheme()->GetProportionalScaledValue( 280 ), scheme()->GetProportionalScaledValue( 140 ) );
else
SetSize( 280, 140 );
LoadControlSettings( "resource/OptionsSubKeyboardAdvancedDlg.res" ); LoadControlSettings( "resource/OptionsSubKeyboardAdvancedDlg.res" );
MoveToCenterOfScreen(); MoveToCenterOfScreen();
SetSizeable( false ); SetSizeable( false );

3
gameui/OptionsSubVideo.cpp

@ -1030,7 +1030,8 @@ COptionsSubVideo::COptionsSubVideo(vgui::Panel *parent) : PropertyPage(parent, N
m_pBenchmark = new Button( this, "BenchmarkButton", "#GameUI_LaunchBenchmark" ); m_pBenchmark = new Button( this, "BenchmarkButton", "#GameUI_LaunchBenchmark" );
m_pBenchmark->SetCommand(new KeyValues("LaunchBenchmark")); m_pBenchmark->SetCommand(new KeyValues("LaunchBenchmark"));
m_pThirdPartyCredits = new URLButton(this, "ThirdPartyVideoCredits", "#GameUI_ThirdPartyTechCredits"); m_pThirdPartyCredits = new URLButton(this, "ThirdPartyVideoCredits", "#GameUI_ThirdPartyTechCredits");
m_pThirdPartyCredits->SetCommand(new KeyValues("OpenThirdPartyVideoCreditsDialog")); // m_pThirdPartyCredits->SetCommand(new KeyValues("OpenThirdPartyVideoCreditsDialog"));
m_pThirdPartyCredits->SetVisible(false);
m_pHDContent = new CheckButton( this, "HDContentButton", "#GameUI_HDContent" ); m_pHDContent = new CheckButton( this, "HDContentButton", "#GameUI_HDContent" );
char pszAspectName[3][64]; char pszAspectName[3][64];

11
gameui/matchmaking/achievementsdialog.cpp

@ -366,7 +366,12 @@ void CAchievementsDialog_XBox::OnClose()
CAchievementsDialog::CAchievementsDialog(vgui::Panel *parent) : BaseClass(parent, "AchievementsDialog") CAchievementsDialog::CAchievementsDialog(vgui::Panel *parent) : BaseClass(parent, "AchievementsDialog")
{ {
SetDeleteSelfOnClose(true); SetDeleteSelfOnClose(true);
SetBounds(0, 0, 512, 384);
if( IsProportional() )
SetBounds(0, 0, scheme()->GetProportionalScaledValue(512), scheme()->GetProportionalScaledValue(384));
else
SetBounds(0, 0, 512, 384);
SetMinimumSize( 256, 300 ); SetMinimumSize( 256, 300 );
SetSizeable( true ); SetSizeable( true );
@ -506,7 +511,8 @@ void CAchievementsDialog::CreateNewAchievementGroup( int iMinRange, int iMaxRang
//---------------------------------------------------------- //----------------------------------------------------------
void CAchievementsDialog::ApplySettings( KeyValues *pResourceData ) void CAchievementsDialog::ApplySettings( KeyValues *pResourceData )
{ {
m_iFixedWidth = pResourceData->GetInt( "wide", 512 ); int width = pResourceData->GetInt( "wide", 512 );
m_iFixedWidth = IsProportional() ? scheme()->GetProportionalScaledValue(width) : width;
BaseClass::ApplySettings( pResourceData ); BaseClass::ApplySettings( pResourceData );
} }
@ -1073,3 +1079,4 @@ void CAchievementDialogItemPanel::OnCheckButtonChecked(Panel *panel)
m_pSourceAchievement->SetShowOnHUD( m_pShowOnHUDCheck->IsSelected() ); m_pSourceAchievement->SetShowOnHUD( m_pShowOnHUDCheck->IsSelected() );
} }
} }

2
public/vgui/VGUI.h

@ -14,6 +14,8 @@
#define null 0L #define null 0L
#define NeedProportional() (IsAndroid() || CommandLine()->CheckParm("-gameuiproportionality"))
#ifndef NULL #ifndef NULL
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0

21
vgui2/vgui_controls/Panel.cpp

@ -226,7 +226,6 @@ KeyBindingMap_t::~KeyBindingMap_t()
class CKeyBindingsMgr class CKeyBindingsMgr
{ {
public: public:
CKeyBindingsMgr() : CKeyBindingsMgr() :
m_Bindings( 0, 0, KeyBindingContextHandleLessFunc ), m_Bindings( 0, 0, KeyBindingContextHandleLessFunc ),
m_nKeyBindingContexts( 0 ) m_nKeyBindingContexts( 0 )
@ -1450,8 +1449,10 @@ void Panel::SetParent(Panel *newParent)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Panel::SetParent(VPANEL newParent) void Panel::SetParent(VPANEL newParent)
{ {
if (newParent) if (newParent)
{ {
ipanel()->SetParent(GetVPanel(), newParent); ipanel()->SetParent(GetVPanel(), newParent);
} }
else else
@ -1459,19 +1460,19 @@ void Panel::SetParent(VPANEL newParent)
ipanel()->SetParent(GetVPanel(), NULL); ipanel()->SetParent(GetVPanel(), NULL);
} }
if (GetVParent() && !IsPopup()) if (GetVParent() )
{ {
SetProportional(ipanel()->IsProportional(GetVParent())); if( ipanel()->IsProportional(GetVParent()) )
SetProportional(true);
// most of the time KBInput == parents kbinput if( IsPopup() )
if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
{ {
SetKeyBoardInputEnabled(ipanel()->IsKeyBoardInputEnabled(GetVParent())); // most of the time KBInput == parents kbinput
} if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
SetKeyBoardInputEnabled(ipanel()->IsKeyBoardInputEnabled(GetVParent()));
if (ipanel()->IsMouseInputEnabled(GetVParent()) != IsMouseInputEnabled()) if (ipanel()->IsMouseInputEnabled(GetVParent()) != IsMouseInputEnabled())
{ SetMouseInputEnabled(ipanel()->IsMouseInputEnabled(GetVParent()));
SetMouseInputEnabled(ipanel()->IsMouseInputEnabled(GetVParent()));
} }
} }

6
vgui2/vgui_controls/ScrollBar.cpp

@ -149,6 +149,8 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
m_pOverriddenButtons[0] = NULL; m_pOverriddenButtons[0] = NULL;
m_pOverriddenButtons[1] = NULL; m_pOverriddenButtons[1] = NULL;
int width = IsProportional() ? scheme()->GetProportionalScaledValue(SCROLLBAR_DEFAULT_WIDTH) : SCROLLBAR_DEFAULT_WIDTH;
if (vertical) if (vertical)
{ {
// FIXME: proportional changes needed??? // FIXME: proportional changes needed???
@ -158,7 +160,7 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
_button[0]->SetTextInset(0, 1); _button[0]->SetTextInset(0, 1);
_button[1]->SetTextInset(0, -1); _button[1]->SetTextInset(0, -1);
SetSize(SCROLLBAR_DEFAULT_WIDTH, 64); SetSize(width, 64);
} }
else else
{ {
@ -168,7 +170,7 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
_button[0]->SetTextInset(0, 0); _button[0]->SetTextInset(0, 0);
_button[1]->SetTextInset(0, 0); _button[1]->SetTextInset(0, 0);
SetSize(64, SCROLLBAR_DEFAULT_WIDTH); SetSize(64, width);
} }
Panel::SetPaintBorderEnabled(true); Panel::SetPaintBorderEnabled(true);

9
vgui2/vgui_controls/Slider.cpp

@ -230,7 +230,6 @@ void Slider::SetInverted( bool bInverted )
m_bInverted = bInverted; m_bInverted = bInverted;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Send a message to interested parties when the slider moves // Purpose: Send a message to interested parties when the slider moves
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -386,9 +385,9 @@ void Slider::GetTrackRect( int& x, int& y, int& w, int& h )
GetPaintSize( wide, tall ); GetPaintSize( wide, tall );
x = 0; x = 0;
y = 8; y = IsProportional() ? scheme()->GetProportionalScaledValue( 8.f ) : 8;;
w = wide - (int)_nobSize; w = wide - (int)_nobSize;
h = 4; h = IsProportional() ? scheme()->GetProportionalScaledValue( 4.f ) : 4;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -524,7 +523,7 @@ void Slider::DrawNob()
#endif #endif
surface()->DrawSetColor(col); surface()->DrawSetColor(col);
int nobheight = 16; int nobheight = IsProportional() ? scheme()->GetProportionalScaledValue( 16.f ) : 16.f;
surface()->DrawFilledRect( surface()->DrawFilledRect(
_nobPos[0], _nobPos[0],
@ -941,7 +940,7 @@ void Slider::SetButtonOffset(int buttonOffset)
void Slider::SetThumbWidth( int width ) void Slider::SetThumbWidth( int width )
{ {
_nobSize = (float)width; _nobSize = IsProportional() ? scheme()->GetProportionalScaledValue( (float)width) : (float)width;
} }

Loading…
Cancel
Save