Skip to content

Commit 0c17876

Browse files
committed
Closes #37
1 parent a8d9621 commit 0c17876

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

frontend/config.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ void Config::load(App *app)
3333
{
3434
LOG(LOGLEVEL_ERROR) << "Config - Couldn't load config file " << filename;
3535
}
36-
37-
initialize();
38-
load_recents(app);
39-
40-
app->set_dimensions({(float)_store.main_window_width, (float)_store.main_window_height});
41-
app->set_position({(float)_store.main_window_x_pos, (float)_store.main_window_y_pos});
42-
43-
app->gui()->_comlynx_visible = _store.comlynx_visisble;
44-
app->gui()->_console_visible = _store.console_visible;
45-
app->gui()->_sessionscontrol_visible = _store.sessionscontrol_visible;
46-
Console::get_instance().set_log_level(_store.log_level);
4736
}
4837

4938
void Config::save_recents(App *app)
@@ -66,7 +55,22 @@ void Config::load_recents(App *app)
6655
}
6756
}
6857

69-
void Config::initialize()
58+
void Config::initialize(App *app)
59+
{
60+
load_recents(app);
61+
62+
app->set_dimensions({(float)_store.main_window_width, (float)_store.main_window_height});
63+
app->set_position({(float)_store.main_window_x_pos, (float)_store.main_window_y_pos});
64+
65+
app->gui()->_comlynx_visible = _store.comlynx_visisble;
66+
app->gui()->_console_visible = _store.console_visible;
67+
app->gui()->_sessionscontrol_visible = _store.sessionscontrol_visible;
68+
Console::get_instance().set_log_level(_store.log_level);
69+
70+
update_ui_settings();
71+
}
72+
73+
void Config::update_ui_settings()
7074
{
7175
apply_theme();
7276
// apply_font(); // https://github.com/ocornut/imgui/pull/3761
@@ -471,7 +475,7 @@ void Config::apply_font(float scale)
471475

472476
io.Fonts->Clear();
473477

474-
int font_size = scale * 16;
478+
int font_size = (store().ui_scale > 0 ? store().ui_scale : scale) * 16;
475479

476480
ImFontConfig cfg;
477481
cfg.MergeMode = true;

frontend/gui/app.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ void App::close_session(std::string session_identifier)
7676

7777
void App::initialize()
7878
{
79+
Config::get_instance().load(this);
80+
7981
_gui = std::make_shared<GUI>();
8082
_gui->initialize();
8183
_gui->sessions_control().set_app(shared_from_this());
@@ -90,7 +92,7 @@ void App::initialize()
9092

9193
_renderer->setTitle(APP_NAME " " APP_VERSION);
9294

93-
Config::get_instance().load(this);
95+
Config::get_instance().initialize(this);
9496

9597
if (!sound_initialize())
9698
{

frontend/gui/settings.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Settings::~Settings()
1515

1616
bool Settings::render()
1717
{
18-
ImGui::AlignTextToFramePadding();
18+
ImGui::AlignTextToFramePadding();
1919

2020
if (ImGui::BeginTable("#settingstable", 2, ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp))
2121
{
@@ -34,6 +34,16 @@ bool Settings::render()
3434
Config::get_instance().store().theme = "light";
3535
}
3636

37+
ImGui::TableNextColumn();
38+
ImGui::Text("UI Scale");
39+
40+
ImGui::TableNextColumn();
41+
float scale = Config::get_instance().store().ui_scale;
42+
if (ImGui::SliderFloat("float", &scale, 0.0f, 10.0f, "%.1f"))
43+
{
44+
Config::get_instance().store().ui_scale = scale;
45+
}
46+
3747
ImGui::TableNextColumn();
3848
ImGui::Text("Lynx ROM");
3949

frontend/include/config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct ConfigStore
156156
std::string theme = "dark";
157157
std::string last_rom_folder = ".";
158158
std::string lynx_rom_file = "./lynxboot.img";
159+
float ui_scale = 0;
159160
bool break_on_undocumented_opcode = false;
160161
int main_window_x_pos = 10, main_window_y_pos = 10;
161162
int main_window_width = 800, main_window_height = 600;
@@ -176,6 +177,7 @@ struct ConfigStore
176177
archive(CEREAL_NVP(last_rom_folder));
177178
archive(CEREAL_NVP(lynx_rom_file));
178179
archive(CEREAL_NVP(break_on_undocumented_opcode));
180+
archive(CEREAL_NVP(ui_scale));
179181
archive(CEREAL_NVP(main_window_x_pos));
180182
archive(CEREAL_NVP(main_window_y_pos));
181183
archive(CEREAL_NVP(main_window_width));
@@ -209,7 +211,8 @@ class Config
209211
void apply_font(float scale);
210212
void load_recents(App *app);
211213
void save_recents(App *app);
212-
void initialize();
214+
void initialize(App *app);
215+
void update_ui_settings();
213216

214217
void save_sessions(std::vector<std::shared_ptr<SessionGUI>> sessions);
215218
void load_session(std::shared_ptr<SessionGUI> session);

frontend/renderer/vk_renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL debug_callback(VkDebugUtilsMessageSeverity
1414
}
1515
else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT)
1616
{
17-
L_WARNING << messageType << ": " << pCallbackData->pMessage;
17+
LOG(LOGLEVEL_WARN) << messageType << ": " << pCallbackData->pMessage;
1818
}
1919
else
2020
{
@@ -731,8 +731,8 @@ void VulkanRenderer::render_ImGui(std::shared_ptr<GUI> ui)
731731

732732
if (ui->menu().settings().update_pending())
733733
{
734-
Config::get_instance().initialize();
735734
ui->menu().settings().set_update_pending(false);
735+
Config::get_instance().update_ui_settings();
736736
}
737737

738738
ImGui_ImplVulkan_NewFrame();

0 commit comments

Comments
 (0)