mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-07 17:29:36 +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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -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);
|
||||
|
||||
+41
-33
@@ -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();
|
||||
}
|
||||
|
||||
+41
-33
@@ -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];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user