Skip to content

Commit

Permalink
MainScreen: Prevent grid game buttons from becoming too wide if the p…
Browse files Browse the repository at this point in the history
…ng has the wrong dimensions.

Happens with Doom Legacy homebrew.
  • Loading branch information
hrydgard committed Oct 7, 2019
1 parent eb2109a commit 1c8ac05
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions UI/MainScreen.cpp
Expand Up @@ -255,8 +255,8 @@ void GameButton::Draw(UIContext &dc) {
float th = texture->Height(); float th = texture->Height();


// Adjust position so we don't stretch the image vertically or horizontally. // 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. // Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode.
float nw = h * tw / th; float nw = std::min(h * tw / th, 144.0f);
x += (w - nw) / 2.0f; x += (w - nw) / 2.0f;
w = nw; w = nw;
} }
Expand Down Expand Up @@ -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()->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(); dc.Draw()->Flush();
} }
}


if (texture) {
dc.Draw()->Flush(); dc.Draw()->Flush();
dc.GetDrawContext()->BindTexture(0, texture); dc.GetDrawContext()->BindTexture(0, texture);
if (holdStart_ != 0.0) { if (holdStart_ != 0.0) {
Expand Down Expand Up @@ -383,7 +381,6 @@ class DirButton : public UI::Button {
} }


private: private:

std::string path_; std::string path_;
bool absolute_; bool absolute_;
}; };
Expand Down

0 comments on commit 1c8ac05

Please sign in to comment.