Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/DevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,23 @@ DevTools* DevTools::get() {
return inst;
}

void DevTools::loadSettings() { m_settings = Mod::get()->getSavedValue<Settings>("settings"); }
void DevTools::saveSettings() { Mod::get()->setSavedValue("settings", m_settings); }
// i wish i didnt have to do this but none of the lead devs have 4k monitors apparently!?!?!?
void DevTools::loadSettings() {
if (!m_mod) {
m_mod = Mod::get();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for caching the mod?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure its because it would spam mod::get() otherwise while holding the slider

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod::get() is just reading a global variable so you can call it a million times a second

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait hold on am i being a dumbass

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mod::get() is just reading a global variable so you can call it a million times a second

are you fucking with me
this whole time i thought caching mattered when accessing it a lot

}

m_settings = m_mod->getSavedValue<Settings>("settings");
m_settings.fontScale = m_mod->getSavedValue<float>("font-scale", m_settings.fontScale);
}
void DevTools::saveSettings() {
if (!m_mod) {
m_mod = Mod::get();
}

m_mod->setSavedValue("settings", m_settings);
m_mod->setSavedValue("font-scale", m_settings.fontScale);
}
Settings DevTools::getSettings() { return m_settings; }
void DevTools::setBallPosition(CCPoint pos) { m_settings.buttonPos = std::move(pos); }

Expand Down Expand Up @@ -321,6 +336,7 @@ void DevTools::setup() {
ImGui::CreateContext();

auto& io = ImGui::GetIO();
io.FontGlobalScale = m_settings.fontScale;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// if this is true then it just doesnt work :( why
io.ConfigDockingWithShift = false;
Expand All @@ -331,7 +347,6 @@ void DevTools::setup() {
this->setupPlatform();

#ifdef GEODE_IS_MOBILE
ImGui::GetIO().FontGlobalScale = 2.f;
ImGui::GetStyle().ScrollbarSize = 60.f;
// ImGui::GetStyle().TabBarBorderSize = 60.f;
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ struct Settings {
bool buttonInGame = false;
bool buttonEnabled = false;
bool treeDragReorder = false;
#ifdef GEODE_IS_MOBILE
float fontScale = 2.f;
#else
float fontScale = 1.f;
#endif
};

class DevTools {
Expand All @@ -47,6 +52,7 @@ class DevTools {
bool m_showModGraph = false;
bool m_pauseGame = false;
Settings m_settings;
Mod* m_mod = nullptr;
ImGuiID m_dockspaceID;
ImFont* m_defaultFont = nullptr;
ImFont* m_smallFont = nullptr;
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ void DevTools::drawSettings() {

ImGui::Separator();

ImGui::DragFloat("Font Size", &ImGui::GetIO().FontGlobalScale, 0.01f, 1.0f, 3.0f);
if (ImGui::DragFloat("Font Size", &m_settings.fontScale, 0.01f, 1.0f, 3.0f)) {
ImGui::GetIO().FontGlobalScale = m_settings.fontScale;
DevTools::get()->saveSettings();
}
if (ImGui::IsItemActive()) {
ImGui::GetIO().FontGlobalScale = m_settings.fontScale;
}

#ifdef GEODE_IS_DESKTOP

Expand Down Expand Up @@ -272,3 +278,4 @@ void DevTools::drawSettings() {
}
};*/


Loading