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:
nillerusr
2022-01-09 17:04:47 +03:00
committed by GitHub
co-authored by JusicP
parent 1f3436945f
commit 9d77bb17c5
20 changed files with 296 additions and 150 deletions
+41 -33
View File
@@ -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();
}