mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 06:06:50 +00:00
Add proportionality support for GameUI panels (#35)
* Add proportionality support for GameUI panels * Add Android platform define * Fix button wrong state on fast clicking Co-authored-by: JusicP <slender87844@gmail.com>
This commit is contained in:
parent
1f3436945f
commit
9d77bb17c5
@ -53,20 +53,20 @@ CCvarSlider::CCvarSlider( Panel *parent, const char *panelName, char const *capt
|
||||
void CCvarSlider::SetupSlider( float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange )
|
||||
{
|
||||
// make sure min/max don't go outside cvar range if there's one
|
||||
ConVarRef var( cvarname, true );
|
||||
if ( var.IsValid() )
|
||||
{
|
||||
float flCVarMin;
|
||||
if ( var.GetMin( flCVarMin ) )
|
||||
{
|
||||
minValue = m_bUseConVarMinMax ? flCVarMin : MAX( minValue, flCVarMin );
|
||||
}
|
||||
float flCVarMax;
|
||||
if ( var.GetMax( flCVarMax ) )
|
||||
{
|
||||
maxValue = m_bUseConVarMinMax ? flCVarMax : MIN( maxValue, flCVarMax );
|
||||
}
|
||||
}
|
||||
//ConVarRef var( cvarname, true );
|
||||
//if ( var.IsValid() )
|
||||
//{
|
||||
// float flCVarMin;
|
||||
// if ( var.GetMin( flCVarMin ) )
|
||||
// {
|
||||
// minValue = m_bUseConVarMinMax ? flCVarMin : MAX( minValue, flCVarMin );
|
||||
// }
|
||||
// float flCVarMax;
|
||||
// if ( var.GetMax( flCVarMax ) )
|
||||
// {
|
||||
// maxValue = m_bUseConVarMinMax ? flCVarMax : MIN( maxValue, flCVarMax );
|
||||
// }
|
||||
//}
|
||||
|
||||
m_flMinValue = minValue;
|
||||
m_flMaxValue = maxValue;
|
||||
|
@ -696,6 +696,11 @@ void CEngineVGui::Init()
|
||||
COM_TimestampedLog( "Building Panels (staticGameUIPanel)" );
|
||||
|
||||
staticGameUIPanel = new CEnginePanel( staticPanel, "GameUI Panel" );
|
||||
if (IsAndroid() || CommandLine()->CheckParm("-gameuiproportionality"))
|
||||
{
|
||||
staticGameUIPanel->SetProportional(true);
|
||||
}
|
||||
|
||||
staticGameUIPanel->SetBounds( 0, 0, videomode->GetModeUIWidth(), videomode->GetModeUIHeight() );
|
||||
staticGameUIPanel->SetPaintBorderEnabled(false);
|
||||
staticGameUIPanel->SetPaintBackgroundEnabled(false);
|
||||
|
@ -1983,12 +1983,14 @@ void CBasePanel::RunMenuCommand(const char *command)
|
||||
{
|
||||
if ( IsPC() )
|
||||
{
|
||||
#ifndef NO_STEAM
|
||||
if ( !steamapicontext->SteamUser() || !steamapicontext->SteamUser()->BLoggedOn() )
|
||||
{
|
||||
vgui::MessageBox *pMessageBox = new vgui::MessageBox("#GameUI_Achievements_SteamRequired_Title", "#GameUI_Achievements_SteamRequired_Message");
|
||||
vgui::MessageBox *pMessageBox = new vgui::MessageBox("#GameUI_Achievements_SteamRequired_Title", "#GameUI_Achievements_SteamRequired_Message", this);
|
||||
pMessageBox->DoModal();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
OnOpenAchievementsDialog();
|
||||
}
|
||||
else
|
||||
|
@ -34,7 +34,16 @@ CCreateMultiplayerGameDialog::CCreateMultiplayerGameDialog(vgui::Panel *parent)
|
||||
{
|
||||
m_bBotsEnabled = false;
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSize(348, 460);
|
||||
|
||||
int w = 348;
|
||||
int h = 460;
|
||||
if (IsProportional())
|
||||
{
|
||||
w = scheme()->GetProportionalScaledValueEx(GetScheme(), w);
|
||||
h = scheme()->GetProportionalScaledValueEx(GetScheme(), h);
|
||||
}
|
||||
|
||||
SetSize(w, h);
|
||||
|
||||
SetTitle("#GameUI_CreateServer", true);
|
||||
SetOKButtonText("#GameUI_Start");
|
||||
|
@ -148,6 +148,13 @@ void CGameConsole::SetParent( int parent )
|
||||
return;
|
||||
|
||||
m_pConsole->SetParent( static_cast<vgui::VPANEL>( parent ));
|
||||
|
||||
// apply proportionality from parent
|
||||
if (vgui::ipanel()->IsProportional(static_cast<vgui::VPANEL>(parent)))
|
||||
{
|
||||
m_pConsole->SetProportional(true);
|
||||
m_pConsole->InvalidateLayout(true, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -161,16 +161,6 @@ public:
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
|
||||
// the image has the same name as the config file
|
||||
char szMaterial[ MAX_PATH ];
|
||||
Q_snprintf( szMaterial, sizeof(szMaterial), "chapters/%s", chapterConfigFile );
|
||||
char *ext = strstr( szMaterial, "." );
|
||||
if ( ext )
|
||||
{
|
||||
*ext = 0;
|
||||
}
|
||||
m_pLevelPic->SetImage( szMaterial );
|
||||
|
||||
KeyValues *pKeys = NULL;
|
||||
if ( GameUI().IsConsoleUI() )
|
||||
{
|
||||
@ -178,6 +168,16 @@ public:
|
||||
}
|
||||
LoadControlSettings( "Resource/NewGameChapterPanel.res", NULL, pKeys );
|
||||
|
||||
// the image has the same name as the config file
|
||||
char szMaterial[MAX_PATH];
|
||||
Q_snprintf(szMaterial, sizeof(szMaterial), "chapters/%s", chapterConfigFile);
|
||||
char* ext = strstr(szMaterial, ".");
|
||||
if (ext)
|
||||
{
|
||||
*ext = 0;
|
||||
}
|
||||
m_pLevelPic->SetImage(szMaterial);
|
||||
|
||||
int px, py;
|
||||
m_pLevelPicBorder->GetPos( px, py );
|
||||
SetSize( m_pLevelPicBorder->GetWide(), py + m_pLevelPicBorder->GetTall() );
|
||||
|
@ -45,7 +45,17 @@ using namespace vgui;
|
||||
COptionsDialog::COptionsDialog(vgui::Panel *parent) : PropertyDialog(parent, "OptionsDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetBounds(0, 0, 512, 406);
|
||||
|
||||
int w = 512;
|
||||
int h = 406;
|
||||
if (IsProportional())
|
||||
{
|
||||
w = scheme()->GetProportionalScaledValueEx(GetScheme(), w);
|
||||
h = scheme()->GetProportionalScaledValueEx(GetScheme(), h);
|
||||
}
|
||||
|
||||
SetBounds(0, 0, w, h);
|
||||
|
||||
SetSizeable( false );
|
||||
|
||||
SetTitle("#GameUI_Options", true);
|
||||
|
@ -383,39 +383,47 @@ void COptionsSubAudio::RunTestSpeakers()
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubAudioThirdPartyCreditsDlg : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubAudioThirdPartyCreditsDlg, vgui::Frame );
|
||||
DECLARE_CLASS_SIMPLE(COptionsSubAudioThirdPartyCreditsDlg, vgui::Frame);
|
||||
public:
|
||||
COptionsSubAudioThirdPartyCreditsDlg( vgui::VPANEL hParent ) : BaseClass( NULL, NULL )
|
||||
{
|
||||
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
|
||||
COptionsSubAudioThirdPartyCreditsDlg(vgui::VPANEL hParent) : BaseClass(NULL, NULL)
|
||||
{
|
||||
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
|
||||
int w = 500;
|
||||
int h = 200;
|
||||
if (ipanel()->IsProportional(hParent))
|
||||
{
|
||||
SetProportional(true);
|
||||
w = scheme()->GetProportionalScaledValueEx(GetScheme(), w);
|
||||
h = scheme()->GetProportionalScaledValueEx(GetScheme(), h);
|
||||
}
|
||||
|
||||
SetTitle("#GameUI_ThirdPartyAudio_Title", true);
|
||||
SetSize( 500, 200 );
|
||||
LoadControlSettings( "resource/OptionsSubAudioThirdPartyDlg.res" );
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable( false );
|
||||
SetDeleteSelfOnClose( true );
|
||||
}
|
||||
SetTitle("#GameUI_ThirdPartyAudio_Title", true);
|
||||
SetSize(w, h);
|
||||
LoadControlSettings("resource/OptionsSubAudioThirdPartyDlg.res");
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable(false);
|
||||
SetDeleteSelfOnClose(true);
|
||||
}
|
||||
|
||||
virtual void Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
virtual void Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
|
||||
void OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
void OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -424,9 +432,9 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OpenThirdPartySoundCreditsDialog()
|
||||
{
|
||||
if (!m_OptionsSubAudioThirdPartyCreditsDlg.Get())
|
||||
{
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg = new COptionsSubAudioThirdPartyCreditsDlg(GetVParent());
|
||||
}
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg->Activate();
|
||||
if (!m_OptionsSubAudioThirdPartyCreditsDlg.Get())
|
||||
{
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg = new COptionsSubAudioThirdPartyCreditsDlg(GetVParent());
|
||||
}
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg->Activate();
|
||||
}
|
||||
|
@ -1714,39 +1714,47 @@ void COptionsSubVideo::LaunchBenchmark()
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubVideoThirdPartyCreditsDlg : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubVideoThirdPartyCreditsDlg, vgui::Frame );
|
||||
DECLARE_CLASS_SIMPLE(COptionsSubVideoThirdPartyCreditsDlg, vgui::Frame);
|
||||
public:
|
||||
COptionsSubVideoThirdPartyCreditsDlg( vgui::VPANEL hParent ) : BaseClass( NULL, NULL )
|
||||
{
|
||||
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
|
||||
COptionsSubVideoThirdPartyCreditsDlg(vgui::VPANEL hParent) : BaseClass(NULL, NULL)
|
||||
{
|
||||
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
|
||||
int w = 500;
|
||||
int h = 200;
|
||||
if (ipanel()->IsProportional(hParent))
|
||||
{
|
||||
SetProportional(true);
|
||||
w = scheme()->GetProportionalScaledValueEx(GetScheme(), w);
|
||||
h = scheme()->GetProportionalScaledValueEx(GetScheme(), h);
|
||||
}
|
||||
|
||||
SetTitle("#GameUI_ThirdPartyVideo_Title", true);
|
||||
SetSize( 500, 200 );
|
||||
LoadControlSettings( "resource/OptionsSubVideoThirdPartyDlg.res" );
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable( false );
|
||||
SetDeleteSelfOnClose( true );
|
||||
}
|
||||
SetTitle("#GameUI_ThirdPartyVideo_Title", true);
|
||||
SetSize(w, h);
|
||||
LoadControlSettings("resource/OptionsSubVideoThirdPartyDlg.res");
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable(false);
|
||||
SetDeleteSelfOnClose(true);
|
||||
}
|
||||
|
||||
virtual void Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
virtual void Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
|
||||
void OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
void OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1755,9 +1763,9 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubVideo::OpenThirdPartyVideoCreditsDialog()
|
||||
{
|
||||
if (!m_OptionsSubVideoThirdPartyCreditsDlg.Get())
|
||||
{
|
||||
m_OptionsSubVideoThirdPartyCreditsDlg = new COptionsSubVideoThirdPartyCreditsDlg(GetVParent());
|
||||
}
|
||||
m_OptionsSubVideoThirdPartyCreditsDlg->Activate();
|
||||
if (!m_OptionsSubVideoThirdPartyCreditsDlg.Get())
|
||||
{
|
||||
m_OptionsSubVideoThirdPartyCreditsDlg = new COptionsSubVideoThirdPartyCreditsDlg(GetVParent());
|
||||
}
|
||||
m_OptionsSubVideoThirdPartyCreditsDlg->Activate();
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ CTGAImagePanel::CTGAImagePanel( vgui::Panel *parent, const char *name ) : BaseCl
|
||||
m_bHasValidTexture = false;
|
||||
m_bLoadedTexture = false;
|
||||
m_szTGAName[0] = 0;
|
||||
m_iImageWidth = 0;
|
||||
m_iImageHeight = 0;
|
||||
m_iImageRealWidth = 0;
|
||||
m_iImageRealHeight = 0;
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
}
|
||||
@ -63,8 +67,19 @@ void CTGAImagePanel::Paint()
|
||||
// set the textureID
|
||||
surface()->DrawSetTextureRGBA( m_iTextureID, tga.Base(), m_iImageWidth, m_iImageHeight, false, true );
|
||||
m_bHasValidTexture = true;
|
||||
|
||||
surface()->DrawGetTextureSize(m_iTextureID, m_iImageRealWidth, m_iImageRealHeight);
|
||||
if (IsProportional())
|
||||
{
|
||||
m_iImageRealWidth = scheme()->GetProportionalScaledValueEx(GetScheme(), m_iImageRealWidth);
|
||||
m_iImageRealHeight = scheme()->GetProportionalScaledValueEx(GetScheme(), m_iImageRealHeight);
|
||||
|
||||
m_iImageWidth = scheme()->GetProportionalScaledValueEx(GetScheme(), m_iImageWidth);
|
||||
m_iImageHeight = scheme()->GetProportionalScaledValueEx(GetScheme(), m_iImageHeight);
|
||||
}
|
||||
|
||||
// set our size to be the size of the tga
|
||||
SetSize( m_iImageWidth, m_iImageHeight );
|
||||
SetSize(m_iImageWidth, m_iImageHeight);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -77,10 +92,9 @@ void CTGAImagePanel::Paint()
|
||||
int wide, tall;
|
||||
if ( m_bHasValidTexture )
|
||||
{
|
||||
surface()->DrawGetTextureSize( m_iTextureID, wide, tall );
|
||||
surface()->DrawSetTexture( m_iTextureID );
|
||||
surface()->DrawSetColor( 255, 255, 255, 255 );
|
||||
surface()->DrawTexturedRect( 0, 0, wide, tall );
|
||||
surface()->DrawTexturedRect( 0, 0, m_iImageRealWidth, m_iImageRealHeight );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
private:
|
||||
int m_iTextureID;
|
||||
int m_iImageWidth, m_iImageHeight;
|
||||
int m_iImageRealWidth, m_iImageRealHeight;
|
||||
bool m_bHasValidTexture, m_bLoadedTexture;
|
||||
char m_szTGAName[256];
|
||||
};
|
||||
|
@ -245,6 +245,11 @@ typedef signed char int8;
|
||||
#define IsPlatform64Bits() false
|
||||
#endif
|
||||
|
||||
#ifdef _ANDROID
|
||||
#define IsAndroid() true
|
||||
#else
|
||||
#define IsAndroid() false
|
||||
#endif
|
||||
// From steam/steamtypes.h
|
||||
// RTime32
|
||||
// We use this 32 bit time representing real world time.
|
||||
|
@ -5,7 +5,7 @@
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
|
||||
//========= Copyright <EFBFBD> 1996-2003, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
|
@ -71,7 +71,6 @@ void Button::Init()
|
||||
_keyFocusBorder = NULL;
|
||||
m_bSelectionStateSaved = false;
|
||||
m_bStaySelectedOnClick = false;
|
||||
m_bStaySelectedOnClick = false;
|
||||
m_bStayArmedOnClick = false;
|
||||
m_sArmedSoundName = UTL_INVAL_SYMBOL;
|
||||
m_sDepressedSoundName = UTL_INVAL_SYMBOL;
|
||||
@ -140,11 +139,12 @@ void Button::SetSelected( bool state )
|
||||
InvalidateLayout(false);
|
||||
}
|
||||
|
||||
if ( !m_bStayArmedOnClick && state && _buttonFlags.IsFlagSet( ARMED ) )
|
||||
{
|
||||
_buttonFlags.SetFlag( ARMED, false );
|
||||
InvalidateLayout(false);
|
||||
}
|
||||
// Jusic: idk what is it for
|
||||
//if (!m_bStayArmedOnClick && state && _buttonFlags.IsFlagSet(ARMED))
|
||||
//{
|
||||
// _buttonFlags.SetFlag( ARMED, false );
|
||||
// InvalidateLayout(false);
|
||||
//}
|
||||
}
|
||||
|
||||
void Button::SetBlink( bool state )
|
||||
@ -877,7 +877,11 @@ void Button::ApplySettings( KeyValues *inResourceData )
|
||||
SetReleasedSound(sound);
|
||||
}
|
||||
|
||||
_activationType = (ActivationType_t)inResourceData->GetInt( "button_activation_type", ACTIVATE_ONRELEASED );
|
||||
int iButtonActivationType = inResourceData->GetInt( "button_activation_type", -1 );
|
||||
if (iButtonActivationType != -1)
|
||||
{
|
||||
_activationType = (ActivationType_t)iButtonActivationType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1224,12 +1224,24 @@ void Frame::PerformLayout()
|
||||
// move everything into place
|
||||
int wide, tall;
|
||||
GetSize(wide, tall);
|
||||
|
||||
|
||||
float scale = 1;
|
||||
if (IsProportional())
|
||||
{
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize(screenW, screenH);
|
||||
|
||||
int proW, proH;
|
||||
surface()->GetProportionalBase(proW, proH);
|
||||
|
||||
scale = ((float)(screenH) / (float)(proH));
|
||||
}
|
||||
|
||||
#if !defined( _X360 )
|
||||
int DRAGGER_SIZE = GetDraggerSize();
|
||||
int CORNER_SIZE = GetCornerSize();
|
||||
int CORNER_SIZE2 = CORNER_SIZE * 2;
|
||||
int BOTTOMRIGHTSIZE = GetBottomRightSize();
|
||||
int BOTTOMRIGHTSIZE = GetBottomRightSize() * scale;
|
||||
|
||||
_topGrip->SetBounds(CORNER_SIZE, 0, wide - CORNER_SIZE2, DRAGGER_SIZE);
|
||||
_leftGrip->SetBounds(0, CORNER_SIZE, DRAGGER_SIZE, tall - CORNER_SIZE2);
|
||||
@ -1260,18 +1272,6 @@ void Frame::PerformLayout()
|
||||
_minimizeToSysTrayButton->MoveToFront();
|
||||
_menuButton->SetBounds(5+2, 5+3, GetCaptionHeight()-5, GetCaptionHeight()-5);
|
||||
#endif
|
||||
|
||||
float scale = 1;
|
||||
if (IsProportional())
|
||||
{
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize( screenW, screenH );
|
||||
|
||||
int proW,proH;
|
||||
surface()->GetProportionalBase( proW, proH );
|
||||
|
||||
scale = ( (float)( screenH ) / (float)( proH ) );
|
||||
}
|
||||
|
||||
#if !defined( _X360 )
|
||||
int offset_start = (int)( 20 * scale );
|
||||
|
@ -90,6 +90,21 @@ void ImagePanel::SetImage(const char *imageName)
|
||||
m_pszImageName = new char[ len ];
|
||||
Q_strncpy(m_pszImageName, imageName, len );
|
||||
InvalidateLayout(false, true); // force applyschemesettings to run
|
||||
|
||||
if (IsProportional() && m_pImage && !m_bScaleImage)
|
||||
{
|
||||
float scale = 1;
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize(screenW, screenH);
|
||||
|
||||
int proW, proH;
|
||||
surface()->GetProportionalBase(proW, proH);
|
||||
|
||||
scale = ((float)(screenH) / (float)(proH));
|
||||
|
||||
m_fScaleAmount = scale;
|
||||
m_bScaleImage = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -145,9 +145,15 @@ void MessageBox::ApplySchemeSettings(IScheme *pScheme)
|
||||
int wide, tall;
|
||||
m_pMessageLabel->GetContentSize(wide, tall);
|
||||
m_pMessageLabel->SetSize(wide, tall);
|
||||
|
||||
int indent = 100;
|
||||
if (IsProportional())
|
||||
{
|
||||
indent = scheme()->GetProportionalScaledValueEx(GetScheme(), 100);
|
||||
}
|
||||
|
||||
wide += 100;
|
||||
tall += 100;
|
||||
wide += indent;
|
||||
tall += indent;
|
||||
SetSize(wide, tall);
|
||||
|
||||
if ( m_bShowMessageBoxOverCursor )
|
||||
@ -243,7 +249,7 @@ void MessageBox::ShowWindow(Frame *pFrameOver)
|
||||
// Purpose: Put the text and OK buttons in correct place
|
||||
//-----------------------------------------------------------------------------
|
||||
void MessageBox::PerformLayout()
|
||||
{
|
||||
{
|
||||
int x, y, wide, tall;
|
||||
GetClientArea(x, y, wide, tall);
|
||||
wide += x;
|
||||
@ -255,38 +261,51 @@ void MessageBox::PerformLayout()
|
||||
int oldWide, oldTall;
|
||||
m_pOkButton->GetSize(oldWide, oldTall);
|
||||
|
||||
// calc proportionality scale
|
||||
float scale = 1;
|
||||
if (IsProportional())
|
||||
{
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize(screenW, screenH);
|
||||
|
||||
int proW, proH;
|
||||
surface()->GetProportionalBase(proW, proH);
|
||||
|
||||
scale = ((float)(screenH) / (float)(proH));
|
||||
}
|
||||
|
||||
int btnWide, btnTall;
|
||||
m_pOkButton->GetContentSize(btnWide, btnTall);
|
||||
btnWide = max(oldWide, btnWide + 10);
|
||||
btnTall = max(oldTall, btnTall + 10);
|
||||
btnWide = max(oldWide, btnWide + 10 * scale);
|
||||
btnTall = max(oldTall, btnTall + 10 * scale);
|
||||
m_pOkButton->SetSize(btnWide, btnTall);
|
||||
|
||||
|
||||
int btnWide2 = 0, btnTall2 = 0;
|
||||
if ( m_pCancelButton->IsVisible() )
|
||||
{
|
||||
m_pCancelButton->GetSize(oldWide, oldTall);
|
||||
|
||||
m_pCancelButton->GetContentSize(btnWide2, btnTall2);
|
||||
btnWide2 = max(oldWide, btnWide2 + 10);
|
||||
btnTall2 = max(oldTall, btnTall2 + 10);
|
||||
m_pCancelButton->SetSize(btnWide2, btnTall2);
|
||||
btnWide2 = max(oldWide, btnWide2 + 10 * scale);
|
||||
btnTall2 = max(oldTall, btnTall2 + 10 * scale);
|
||||
m_pCancelButton->SetSize(btnWide2, boxTall);
|
||||
}
|
||||
|
||||
boxWidth = max(boxWidth, m_pMessageLabel->GetWide() + 100);
|
||||
boxWidth = max(boxWidth, (btnWide + btnWide2) * 2 + 30);
|
||||
boxWidth = max(boxWidth, m_pMessageLabel->GetWide() + 100 * scale);
|
||||
boxWidth = max(boxWidth, (btnWide + btnWide2) * 2 + 30 * scale);
|
||||
SetSize(boxWidth, boxTall);
|
||||
|
||||
GetSize(boxWidth, boxTall);
|
||||
|
||||
m_pMessageLabel->SetPos((wide/2)-(m_pMessageLabel->GetWide()/2) + x, y + 5 );
|
||||
m_pMessageLabel->SetPos((wide/2)-(m_pMessageLabel->GetWide()/2) + x, y + 5 * scale);
|
||||
if ( !m_pCancelButton->IsVisible() )
|
||||
{
|
||||
m_pOkButton->SetPos((wide/2)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15);
|
||||
m_pOkButton->SetPos((wide/2)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15 * scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pOkButton->SetPos((wide/4)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15);
|
||||
m_pCancelButton->SetPos((3*wide/4)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15);
|
||||
m_pOkButton->SetPos((wide/4)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15 * scale);
|
||||
m_pCancelButton->SetPos((3*wide/4)-(m_pOkButton->GetWide()/2) + x, tall - m_pOkButton->GetTall() - 15 * scale);
|
||||
}
|
||||
|
||||
BaseClass::PerformLayout();
|
||||
|
@ -115,24 +115,36 @@ void PropertyDialog::PerformLayout()
|
||||
GetClientArea(x, y, wide, tall);
|
||||
_propertySheet->SetBounds(x, y, wide, tall - iBottom);
|
||||
|
||||
// calc button size and indent for proportionality
|
||||
int iBtnWide = 72;
|
||||
int iBtnTall = 24;
|
||||
int iWideIndent = 8;
|
||||
int iTallIndent = 4;
|
||||
if (IsProportional())
|
||||
{
|
||||
iBtnWide = scheme()->GetProportionalScaledValueEx(GetScheme(), iBtnWide);
|
||||
iBtnTall = scheme()->GetProportionalScaledValueEx(GetScheme(), iBtnTall);
|
||||
iWideIndent = scheme()->GetProportionalScaledValueEx(GetScheme(), iWideIndent);
|
||||
iTallIndent = scheme()->GetProportionalScaledValueEx(GetScheme(), iTallIndent);
|
||||
}
|
||||
|
||||
// move the buttons to the bottom-right corner
|
||||
int xpos = x + wide - 80;
|
||||
int ypos = tall + y - 28;
|
||||
int xpos = x + wide - iBtnWide - iWideIndent;
|
||||
int ypos = tall + y - iBtnTall - iTallIndent;
|
||||
|
||||
if (_applyButton->IsVisible())
|
||||
{
|
||||
_applyButton->SetBounds(xpos, ypos, 72, 24);
|
||||
xpos -= 80;
|
||||
_applyButton->SetBounds(xpos, ypos, iBtnWide, iBtnTall);
|
||||
xpos -= iBtnWide + iWideIndent;
|
||||
}
|
||||
|
||||
if (_cancelButton->IsVisible())
|
||||
{
|
||||
_cancelButton->SetBounds(xpos, ypos, 72, 24);
|
||||
xpos -= 80;
|
||||
_cancelButton->SetBounds(xpos, ypos, iBtnWide, iBtnTall);
|
||||
xpos -= iBtnWide + iWideIndent;
|
||||
}
|
||||
|
||||
_okButton->SetBounds(xpos, ypos, 72, 24);
|
||||
_okButton->SetBounds(xpos, ypos, iBtnWide, iBtnTall);
|
||||
|
||||
_propertySheet->InvalidateLayout(); // tell the propertysheet to redraw!
|
||||
Repaint();
|
||||
|
@ -9,6 +9,7 @@
|
||||
//=============================================================================//
|
||||
|
||||
#include <vgui/KeyCode.h>
|
||||
#include <vgui/ISurface.h>
|
||||
|
||||
#include <vgui_controls/QueryBox.h>
|
||||
#include <vgui_controls/TextImage.h>
|
||||
@ -89,10 +90,23 @@ void QueryBox::PerformLayout()
|
||||
int oldWide, oldTall;
|
||||
m_pCancelButton->GetSize(oldWide, oldTall);
|
||||
|
||||
// calc proportionality scale
|
||||
float scale = 1;
|
||||
if (IsProportional())
|
||||
{
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize(screenW, screenH);
|
||||
|
||||
int proW, proH;
|
||||
surface()->GetProportionalBase(proW, proH);
|
||||
|
||||
scale = ((float)(screenH) / (float)(proH));
|
||||
}
|
||||
|
||||
int btnWide, btnTall;
|
||||
m_pCancelButton->GetContentSize(btnWide, btnTall);
|
||||
btnWide = max(oldWide, btnWide + 10);
|
||||
btnTall = max(oldTall, btnTall + 10);
|
||||
btnWide = max(oldWide, btnWide + 10 * scale);
|
||||
btnTall = max(oldTall, btnTall + 10 * scale);
|
||||
m_pCancelButton->SetSize(btnWide, btnTall);
|
||||
|
||||
//nt boxWidth, boxTall;
|
||||
@ -100,8 +114,8 @@ void QueryBox::PerformLayout()
|
||||
// wide = max(wide, btnWide * 2 + 100);
|
||||
// SetSize(wide, tall);
|
||||
|
||||
m_pOkButton->SetPos((wide/2)-(m_pOkButton->GetWide())-1 + x, tall - m_pOkButton->GetTall() - 15);
|
||||
m_pCancelButton->SetPos((wide/2) + x+16, tall - m_pCancelButton->GetTall() - 15);
|
||||
m_pOkButton->SetPos((wide/2)-(m_pOkButton->GetWide())-1 + x, tall - m_pOkButton->GetTall() - 15 * scale);
|
||||
m_pCancelButton->SetPos((wide/2) + x+16*scale, tall - m_pCancelButton->GetTall() - 15 * scale);
|
||||
|
||||
}
|
||||
|
||||
|
@ -844,12 +844,24 @@ void CConsolePanel::PerformLayout()
|
||||
|
||||
if ( !m_bStatusVersion )
|
||||
{
|
||||
const int inset = 8;
|
||||
const int entryHeight = 24;
|
||||
const int topHeight = 4;
|
||||
const int entryInset = 4;
|
||||
const int submitWide = 64;
|
||||
const int submitInset = 7; // x inset to pull the submit button away from the frame grab
|
||||
float scale = 1;
|
||||
if (IsProportional())
|
||||
{
|
||||
int screenW, screenH;
|
||||
surface()->GetScreenSize(screenW, screenH);
|
||||
|
||||
int proW, proH;
|
||||
surface()->GetProportionalBase(proW, proH);
|
||||
|
||||
scale = ((float)(screenH) / (float)(proH));
|
||||
}
|
||||
|
||||
const int inset = 8 * scale;
|
||||
const int entryHeight = 24 * scale;
|
||||
const int topHeight = 4 * scale;
|
||||
const int entryInset = 4 * scale;
|
||||
const int submitWide = 64 * scale;
|
||||
const int submitInset = 7 * scale; // x inset to pull the submit button away from the frame grab
|
||||
|
||||
m_pHistory->SetPos(inset, inset + topHeight);
|
||||
m_pHistory->SetSize(wide - (inset * 2), tall - (entryInset * 2 + inset * 2 + topHeight + entryHeight));
|
||||
@ -931,6 +943,7 @@ void CConsolePanel::ApplySchemeSettings(IScheme *pScheme)
|
||||
m_DPrintColor = GetSchemeColor("Console.DevTextColor", pScheme);
|
||||
m_pHistory->SetFont( pScheme->GetFont( "ConsoleText", IsProportional() ) );
|
||||
m_pCompletionList->SetFont( pScheme->GetFont( "DefaultSmall", IsProportional() ) );
|
||||
m_pEntry->SetFont( pScheme->GetFont( "DefaultSmall", IsProportional() ) );
|
||||
InvalidateLayout();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user