UI: Prevent stretching game icons on detail.

Also, make them a bit bigger in the save data screen.
This commit is contained in:
Unknown W. Brackets committed 2020-03-23 17:43:58 -07:00
1 parent 03cd1d5c5e
commit dbb19d169f
4 files changed
+12 -7

No files matched your search

+7 -3
View File
@@ -228,8 +228,8 @@ void GameIconView::Draw(UIContext &dc) {
return;
}
textureWidth_ = info->icon.texture->Width();
textureHeight_ = info->icon.texture->Height();
textureWidth_ = info->icon.texture->Width() * scale_;
textureHeight_ = info->icon.texture->Height() * scale_;
// Fade icon with the backgrounds.
double loadTime = info->icon.timeLoaded;
@@ -241,9 +241,13 @@ void GameIconView::Draw(UIContext &dc) {
}
uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3));
// Adjust size so we don't stretch the image vertically or horizontally.
// Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode.
float nw = std::min(bounds_.h * textureWidth_ / textureHeight_, (float)bounds_.w);
dc.Flush();
dc.GetDrawContext()->BindTexture(0, info->icon.texture->GetTexture());
dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color);
dc.Draw()->Rect(bounds_.x, bounds_.y, nw, bounds_.h, color);
dc.Flush();
dc.RebindTexture();
}