Skip to content

Commit

Permalink
Adv: Make advanced view persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Dec 12, 2023
1 parent abf6460 commit 4c42247
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
25 changes: 18 additions & 7 deletions src/Framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,18 +1151,23 @@ void Framework::draw_ui() {
ImGui::Checkbox("Transparency", &m_ui_option_transparent);
ImGui::SameLine();
ImGui::Text("(?)");
if (ImGui::IsItemHovered())
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Makes the UI transparent when not focused.");
}
ImGui::Checkbox("Input Passthrough", &m_ui_passthrough);
ImGui::SameLine();
ImGui::Text("(?)");
if (ImGui::IsItemHovered())
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Allows mouse and keyboard inputs to register to the game while the UI is focused.");
ImGui::Checkbox("Show Advanced Options", &m_advanced_view_enabled);
}

FrameworkConfig::get()->get_advanced_mode()->draw("Show Advanced Options");

ImGui::SameLine();
ImGui::Text("(?)");
if (ImGui::IsItemHovered())
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show additional options for greater control over various settings.");
}

if (m_mods_fully_initialized) {
if (ImGui::Button("Reset to Default Settings")) {
Expand Down Expand Up @@ -1220,8 +1225,10 @@ void Framework::draw_ui() {

std::vector<Info> mod_sidebar_ranges{};

const auto is_advanced_mode = is_advanced_view_enabled();

for (auto& mod : m_mods->get_mods()) {
if (mod->is_advanced_mod() && !m_advanced_view_enabled) {
if (mod->is_advanced_mod() && !is_advanced_mode) {
continue;
}

Expand All @@ -1230,7 +1237,7 @@ void Framework::draw_ui() {
if (!entries.empty()) {
size_t displayed_entries = 0;
for (auto& entry : entries) {
if (entry.m_advanced_entry && !m_advanced_view_enabled) {
if (entry.m_advanced_entry && !is_advanced_mode) {
continue;
}

Expand All @@ -1248,7 +1255,7 @@ void Framework::draw_ui() {
}

for (size_t i = 1; i < sidebar_entries.size(); ++i) {
if (m_advanced_view_enabled || !sidebar_entries[i].m_advanced_entry) {
if (is_advanced_mode || !sidebar_entries[i].m_advanced_entry) {
for (const auto& range : mod_sidebar_ranges) {
if (i == range.mn) {
// Set first entry as default ("Runtime" entry of VR mod)
Expand Down Expand Up @@ -1995,3 +2002,7 @@ void Framework::deinit_d3d12() {
ImGui::GetIO().BackendRendererUserData = nullptr;
m_d3d12 = {};
}

bool Framework::is_advanced_view_enabled() const {
return FrameworkConfig::get()->is_advanced_mode();
}
5 changes: 1 addition & 4 deletions src/Framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ class Framework {
m_last_page_dec_time = now;
}

bool is_advanced_view_enabled() const {
return m_advanced_view_enabled;
}
bool is_advanced_view_enabled() const;

private:
void consume_input();
Expand Down Expand Up @@ -253,7 +251,6 @@ class Framework {
// UI
bool m_has_frame{false};
bool m_wants_device_object_cleanup{false};
bool m_advanced_view_enabled{false};
bool m_draw_ui{true};
bool m_last_draw_ui{m_draw_ui};
bool m_is_ui_focused{false};
Expand Down
14 changes: 14 additions & 0 deletions src/mods/FrameworkConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class FrameworkConfig : public Mod {
return m_always_show_cursor->value();
}

bool is_advanced_mode() const {
return m_advanced_mode->value();
}

void toggle_advanced_mode() {
m_advanced_mode->toggle();
}

auto& get_advanced_mode() {
return m_advanced_mode;
}

int32_t get_font_size() {
return m_font_size->value();
}
Expand All @@ -47,6 +59,7 @@ class FrameworkConfig : public Mod {
ModToggle::Ptr m_remember_menu_state{ ModToggle::create(generate_name("RememberMenuState"), false) };
ModToggle::Ptr m_enable_l3_r3_toggle{ ModToggle::create(generate_name("EnableL3R3Toggle"), true) };
ModToggle::Ptr m_always_show_cursor{ ModToggle::create(generate_name("AlwaysShowCursor"), false) };
ModToggle::Ptr m_advanced_mode{ ModToggle::create(generate_name("AdvancedMode"), false) };
ModKey::Ptr m_show_cursor_key{ ModKey::create(generate_name("ShowCursorKey")) };
ModInt32::Ptr m_font_size{ModInt32::create(generate_name("FontSize"), 16)};

Expand All @@ -56,6 +69,7 @@ class FrameworkConfig : public Mod {
*m_menu_open,
*m_remember_menu_state,
*m_enable_l3_r3_toggle,
*m_advanced_mode,
*m_always_show_cursor,
*m_font_size,
};
Expand Down

0 comments on commit 4c42247

Please sign in to comment.