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
+19 -6
View File
@@ -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();
}