From 1c8ac05b06047d1559794094f3637b74b202c8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 7 Oct 2019 23:58:23 +0200 Subject: [PATCH] MainScreen: Prevent grid game buttons from becoming too wide if the png has the wrong dimensions. Happens with Doom Legacy homebrew. --- UI/MainScreen.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index bc2884a3c02e..86afd47b5ed2 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -255,8 +255,8 @@ void GameButton::Draw(UIContext &dc) { float th = texture->Height(); // Adjust position so we don't stretch the image vertically or horizontally. - // TODO: Add a param to specify fit? The below assumes it's never too wide. - float nw = h * tw / th; + // Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode. + float nw = std::min(h * tw / th, 144.0f); x += (w - nw) / 2.0f; w = nw; } @@ -291,9 +291,7 @@ void GameButton::Draw(UIContext &dc) { dc.Draw()->DrawImage4Grid(dc.theme->dropShadow4Grid, x - dropsize, y - dropsize*0.5f, x+w + dropsize, y+h+dropsize*1.5, alphaMul(shadowColor, 0.5f), 1.0f); dc.Draw()->Flush(); } - } - if (texture) { dc.Draw()->Flush(); dc.GetDrawContext()->BindTexture(0, texture); if (holdStart_ != 0.0) { @@ -383,7 +381,6 @@ class DirButton : public UI::Button { } private: - std::string path_; bool absolute_; };