Skip to content

Commit 1ac7fc2

Browse files
committed
SaveStateSelectorUI: Scale save state selector to LayoutScale
And some minor visual polish.
1 parent 073335c commit 1ac7fc2

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

src/core/imgui_overlays.cpp

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ void SaveStateSelectorUI::RefreshHotkeyLegend()
10891089
{
10901090
auto format_legend_entry = [](SmallString binding, std::string_view caption) {
10911091
InputManager::PrettifyInputBinding(binding, &ImGuiFullscreen::GetControllerIconMapping);
1092-
return fmt::format("{} - {}", binding, caption);
1092+
return fmt::format("{} {}", binding, caption);
10931093
};
10941094

10951095
s_state.load_legend = format_legend_entry(Host::GetSmallStringSettingValue("Hotkeys", "LoadSelectedSaveState"),
@@ -1189,25 +1189,27 @@ void SaveStateSelectorUI::InitializePlaceholderListEntry(ListEntry* li, const st
11891189
void SaveStateSelectorUI::Draw()
11901190
{
11911191
using ImGuiFullscreen::DarkerColor;
1192+
using ImGuiFullscreen::LayoutScale;
11921193
using ImGuiFullscreen::UIStyle;
11931194

11941195
static constexpr float SCROLL_ANIMATION_TIME = 0.25f;
11951196
static constexpr float BG_ANIMATION_TIME = 0.15f;
11961197

11971198
const auto& io = ImGui::GetIO();
1198-
const float scale = ImGuiManager::GetGlobalScale();
1199-
const float width = (640.0f * scale);
1200-
const float height = (450.0f * scale);
1199+
const float width = LayoutScale(640.0f);
1200+
const float height = LayoutScale(480.0f);
12011201

1202-
const float padding_and_rounding = 18.0f * scale;
1202+
const float padding_and_rounding = LayoutScale(18.0f);
12031203
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, padding_and_rounding);
12041204
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(padding_and_rounding, padding_and_rounding));
1205-
ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarRounding, 0.0f);
1205+
ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarSize, LayoutScale(14.0f));
1206+
ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarRounding, LayoutScale(10.0f));
1207+
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, LayoutScale(8.0f, 4.0f));
1208+
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, LayoutScale(4.0f, 2.0f));
12061209
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, UIStyle.PrimaryColor);
12071210
ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, UIStyle.BackgroundColor);
12081211
ImGui::PushStyleColor(ImGuiCol_WindowBg, DarkerColor(UIStyle.PopupBackgroundColor));
12091212
ImGui::PushStyleColor(ImGuiCol_Text, UIStyle.BackgroundTextColor);
1210-
ImGui::PushFont(ImGuiManager::GetTextFont(), ImGuiManager::GetOSDFontSize(), 0.0f);
12111213
ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_Always);
12121214
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always,
12131215
ImVec2(0.5f, 0.5f));
@@ -1217,17 +1219,19 @@ void SaveStateSelectorUI::Draw()
12171219
ImGuiWindowFlags_NoScrollbar))
12181220
{
12191221
// Leave 2 lines for the legend
1220-
const float legend_margin = ImGui::GetFontSize() * 2.0f + ImGui::GetStyle().ItemSpacing.y * 3.0f;
1221-
const float padding = 12.0f * scale;
1222+
const ImGuiStyle& style = ImGui::GetStyle();
1223+
const float padding = LayoutScale(12.0f);
1224+
const float legend_margin =
1225+
UIStyle.MediumFontSize * 2.0f + padding + style.ItemSpacing.y * 2.0f + style.CellPadding.y * 2.0f;
12221226

12231227
ImGui::BeginChild("##item_list", ImVec2(0, -legend_margin), false,
12241228
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar |
12251229
ImGuiWindowFlags_NoBackground);
12261230
{
12271231
const s32 current_slot = GetCurrentSlot();
12281232
const bool current_slot_global = IsCurrentSlotGlobal();
1229-
const ImVec2 image_size = ImVec2(128.0f * scale, (128.0f / (4.0f / 3.0f)) * scale);
1230-
const float item_width = std::floor(width - (padding_and_rounding * 2.0f) - ImGui::GetStyle().ScrollbarSize);
1233+
const ImVec2 image_size = LayoutScale(128.0f, (128.0f / (4.0f / 3.0f)));
1234+
const float item_width = std::floor(width - (padding_and_rounding * 2.0f) - style.ScrollbarSize);
12311235
const float item_height = std::floor(image_size.y + padding * 2.0f);
12321236
const float text_indent = image_size.x + padding + padding;
12331237

@@ -1292,17 +1296,27 @@ void SaveStateSelectorUI::Draw()
12921296

12931297
ImGui::Indent(text_indent);
12941298

1299+
ImGui::PushFont(ImGuiManager::GetTextFont(), UIStyle.MediumLargeFontSize, UIStyle.BoldFontWeight);
1300+
12951301
ImGui::TextUnformatted(TinyString::from_format(entry.global ?
12961302
TRANSLATE_FS("SaveStateSelectorUI", "Global Slot {}") :
12971303
TRANSLATE_FS("SaveStateSelectorUI", "Game Slot {}"),
12981304
entry.slot)
12991305
.c_str());
1306+
ImGui::PopFont();
1307+
1308+
ImGui::PushFont(ImGuiManager::GetTextFont(), UIStyle.MediumFontSize, UIStyle.NormalFontWeight);
1309+
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiFullscreen::DarkerColor(style.Colors[ImGuiCol_Text]));
1310+
13001311
if (entry.global)
1301-
ImGui::TextUnformatted(entry.game_details.c_str(), entry.game_details.c_str() + entry.game_details.length());
1302-
ImGui::TextUnformatted(entry.summary.c_str(), entry.summary.c_str() + entry.summary.length());
1303-
ImGui::PushFont(ImGuiManager::GetFixedFont(), 0.0f, 0.0f);
1304-
ImGui::TextUnformatted(entry.filename.data(), entry.filename.data() + entry.filename.length());
1312+
ImGui::TextUnformatted(IMSTR_START_END(entry.game_details));
1313+
1314+
ImGui::TextUnformatted(IMSTR_START_END(entry.summary));
1315+
1316+
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiFullscreen::DarkerColor(style.Colors[ImGuiCol_Text]));
1317+
ImGui::TextUnformatted(IMSTR_START_END(entry.filename));
13051318
ImGui::PopFont();
1319+
ImGui::PopStyleColor(2);
13061320

13071321
ImGui::Unindent(text_indent);
13081322
ImGui::SetCursorPosY(y_start);
@@ -1316,10 +1330,13 @@ void SaveStateSelectorUI::Draw()
13161330
}
13171331
ImGui::EndChild();
13181332

1333+
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + padding);
1334+
13191335
ImGui::BeginChild("##legend", ImVec2(0, 0), false,
13201336
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar |
13211337
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBackground);
13221338
{
1339+
ImGui::PushFont(ImGuiManager::GetTextFont(), UIStyle.MediumFontSize, UIStyle.BoldFontWeight);
13231340
ImGui::SetCursorPosX(padding);
13241341
if (ImGui::BeginTable("table", 2))
13251342
{
@@ -1334,13 +1351,13 @@ void SaveStateSelectorUI::Draw()
13341351

13351352
ImGui::EndTable();
13361353
}
1354+
ImGui::PopFont();
13371355
}
13381356
ImGui::EndChild();
13391357
}
13401358
ImGui::End();
13411359

1342-
ImGui::PopFont();
1343-
ImGui::PopStyleVar(3);
1360+
ImGui::PopStyleVar(6);
13441361
ImGui::PopStyleColor(4);
13451362

13461363
// auto-close

0 commit comments

Comments
 (0)