Skip to content

Commit c27a060

Browse files
authored
Remember window size + fix font size on object explorer window (#1529)
1 parent a79c9f0 commit c27a060

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

src/REFramework.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,8 @@ void REFramework::draw_ui() {
16411641
m_windows_message_hook->window_toggle_cursor(true);
16421642
}
16431643

1644-
ImGui::SetNextWindowPos(ImVec2(50, 50), ImGuiCond_::ImGuiCond_Once);
1645-
ImGui::SetNextWindowSize(ImVec2(300, 500), ImGuiCond_::ImGuiCond_Once);
1644+
ImGui::SetNextWindowPos(ImVec2(50, 50), ImGuiCond_::ImGuiCond_FirstUseEver);
1645+
ImGui::SetNextWindowSize(ImVec2(300, 500), ImGuiCond_::ImGuiCond_FirstUseEver);
16461646

16471647
ImGui::PushFont(m_default_font, m_font_size);
16481648
static const auto REF_NAME = std::format("REFramework [{}+{}-{:.8}]", REF_TAG, REF_COMMITS_PAST_TAG, REF_COMMIT_HASH);

src/REFramework.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class REFramework {
159159
}
160160

161161
auto get_font_size() const { return m_font_size; }
162+
auto get_default_font() const { return m_default_font; }
162163

163164
void set_font(std::string path) {
164165
m_default_font_file = path;

src/mods/REFrameworkConfig.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,25 @@ void REFrameworkConfig::on_draw_ui() {
4040

4141
ImGui::TreePush("Configuration");
4242

43-
m_menu_key->draw("Menu Key");
44-
m_show_cursor_key->draw("Show Cursor Key");
45-
m_remember_menu_state->draw("Remember Menu Open/Closed State");
46-
m_always_show_cursor->draw("Draw Cursor With Menu Open");
43+
bool changed = false;
44+
45+
changed |= m_menu_key->draw("Menu Key");
46+
changed |= m_show_cursor_key->draw("Show Cursor Key");
47+
changed |= m_remember_menu_state->draw("Remember Menu Open/Closed State");
48+
changed |= m_always_show_cursor->draw("Draw Cursor With Menu Open");
4749

4850
if (m_font_file->draw("Font")) {
4951
g_framework->set_font(m_font_file->value());
52+
changed = true;
5053
}
5154

5255
if (m_font_size->draw("Font Size")) {
5356
g_framework->set_font_size(m_font_size->value());
57+
changed = true;
58+
}
59+
60+
if (changed) {
61+
g_framework->request_save_config();
5462
}
5563

5664
ImGui::TreePop();

src/mods/tools/ObjectExplorer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,8 @@ void ObjectExplorer::on_frame() {
727727
bool open = true;
728728

729729
ImGui::SetNextWindowSize(ImVec2(200, 400), ImGuiCond_::ImGuiCond_Once);
730+
ImGui::PushFont(g_framework->get_default_font(), g_framework->get_font_size());
731+
730732
if (ImGui::Begin("Read Listeners", &open)) {
731733
std::shared_lock _{m_veh_state.listener_mtx};
732734

@@ -747,6 +749,8 @@ void ObjectExplorer::on_frame() {
747749
}
748750
}
749751

752+
ImGui::PopFont();
753+
750754
if (!open) {
751755
m_veh_state.clear_all_hardware_breakpoints();
752756
}
@@ -759,12 +763,16 @@ void ObjectExplorer::on_frame() {
759763
// the pinned objects in a separate window
760764

761765
ImGui::SetNextWindowSize(ImVec2(200, 400), ImGuiCond_::ImGuiCond_Once);
766+
ImGui::PushFont(g_framework->get_default_font(), g_framework->get_font_size());
767+
762768
if (ImGui::Begin("Pinned objects", &open)) {
763769
display_pins();
764770

765771
ImGui::End();
766772
}
767773

774+
ImGui::PopFont();
775+
768776
if (!open) {
769777
m_pinned_objects.clear();
770778
}
@@ -777,12 +785,16 @@ void ObjectExplorer::on_frame() {
777785
// the pinned objects in a separate window
778786

779787
ImGui::SetNextWindowSize(ImVec2(400, 800), ImGuiCond_::ImGuiCond_Once);
788+
ImGui::PushFont(g_framework->get_default_font(), g_framework->get_font_size());
789+
780790
if (ImGui::Begin("Hooked methods", &open)) {
781791
display_hooks();
782792

783793
ImGui::End();
784794
}
785795

796+
ImGui::PopFont();
797+
786798
if (!open) {
787799
for (auto& h : m_hooked_methods) {
788800
g_hookman.remove(h.method, h.hook_id);

0 commit comments

Comments
 (0)