Skip to content

Commit d4fe17b

Browse files
committed
Merge branch 'main' of https://github.com/geode-sdk/DevTools into main
2 parents efaa7b3 + 63cb762 commit d4fe17b

25 files changed

+575
-189
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
needs: ['build']
4545

4646
steps:
47-
- uses: geode-sdk/build-geode-mod@combine
47+
- uses: geode-sdk/build-geode-mod/combine@main
4848
id: build
4949

5050
- uses: actions/upload-artifact@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Source/Geode/pkg/uber-apk-signer.jar
88

99
# Ignore build folders
1010
**/build
11+
build-*/
1112

1213
# ILY vscode
1314
**/.vscode

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
cmake_minimum_required(VERSION 3.21)
22
set(CMAKE_CXX_STANDARD 20)
33
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
45

56
project(DevTools VERSION 1.0.0)
67

78
file(GLOB_RECURSE SOURCES
89
src/*.cpp
910
)
1011

11-
add_library(${PROJECT_NAME} SHARED ${SOURCES} src/platform/Mac.mm src/platform/retina.mm)
12+
add_library(${PROJECT_NAME} SHARED ${SOURCES} src/platform/Mac.mm)
1213

1314
set_source_files_properties(src/platform/Mac.mm PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
14-
set_source_files_properties(src/platform/retina.mm PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
1515

1616
if (NOT DEFINED ENV{GEODE_SDK})
1717
message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode")
@@ -21,7 +21,7 @@ endif()
2121

2222
add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)
2323

24-
CPMAddPackage("gh:ocornut/imgui#c191faf")
24+
CPMAddPackage("gh:ocornut/imgui@1.91.0-docking")
2525

2626
target_include_directories(${PROJECT_NAME} PRIVATE ${imgui_SOURCE_DIR})
2727

about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Browser-like developer tools for Geode.
44

5-
Press `F11` (or `F10` on mac) to open up the dev tools.
5+
Press `F11` (or `F10` on Mac or `More Games` on Android) to open up the dev tools.
66

77
## Features
88

changelog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## v1.7.1
2+
* Added support for Intel Mac
3+
* Disabled GD hooks that were still enabled on Windows
4+
5+
## v1.7.0
6+
7+
* Support for 2.206
8+
* Bump to Geode `v3.0.0-beta.1`
9+
* Fixes for 64-bit
10+
* Make the time format for memory dumps better
11+
* Remove logs for GL extension string
12+
* Actually save the settings used
13+
14+
## v1.6.0
15+
16+
* Adds Node IDs into the Attributes menu, along with a button to copy them
17+
* Adds a way to create and modify an AnchorLayout
18+
* Removes the Show Mod Index option in preparation for the new index

mod.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
2-
"geode": "v2.0.0-beta.23",
3-
"version": "v1.6.0",
2+
"geode": "4.0.0",
3+
"version": "v1.7.1",
44
"gd": {
55
"win": "*",
66
"android": "*",
7-
"mac": "2.200"
7+
"mac": "2.206"
88
},
99
"id": "geode.devtools",
1010
"name": "DevTools",
1111
"developer": "Geode Team",
1212
"description": "Developer tools for Geode",
13-
"repository": "https://github.com/geode-sdk/DevTools",
13+
"links": {
14+
"source": "https://github.com/geode-sdk/DevTools"
15+
},
1416
"issues": {
1517
"url": "https://github.com/geode-sdk/DevTools/issues",
1618
"info": "If you encounter an issue using DevTools, please report it to the GitHub issues page."

src/DevTools.cpp

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,51 @@
1111
#include <Geode/loader/Mod.hpp>
1212
#include "ImGui.hpp"
1313

14+
template<>
15+
struct matjson::Serialize<Settings> {
16+
static Result<Settings> fromJson(const matjson::Value& value) {
17+
Settings defaults;
18+
19+
return Ok(Settings {
20+
.GDInWindow = value["game_in_window"].asBool().unwrapOr(std::move(defaults.GDInWindow)),
21+
.attributesInTree = value["attributes_in_tree"].asBool().unwrapOr(std::move(defaults.attributesInTree)),
22+
.alwaysHighlight = value["always_highlight"].asBool().unwrapOr(std::move(defaults.alwaysHighlight)),
23+
.highlightLayouts = value["highlight_layouts"].asBool().unwrapOr(std::move(defaults.highlightLayouts)),
24+
.arrowExpand = value["arrow_expand"].asBool().unwrapOr(std::move(defaults.arrowExpand)),
25+
.orderChildren = value["order_children"].asBool().unwrapOr(std::move(defaults.orderChildren)),
26+
.advancedSettings = value["advanced_settings"].asBool().unwrapOr(std::move(defaults.advancedSettings)),
27+
.showMemoryViewer = value["show_memory_viewer"].asBool().unwrapOr(std::move(defaults.showMemoryViewer)),
28+
.theme = value["theme"].asString().unwrapOr(std::move(defaults.theme)),
29+
});
30+
}
31+
32+
static matjson::Value toJson(const Settings& settings) {
33+
return matjson::makeObject({
34+
{ "game_in_window", settings.GDInWindow },
35+
{ "attributes_in_tree", settings.attributesInTree },
36+
{ "always_highlight", settings.alwaysHighlight },
37+
{ "highlight_layouts", settings.highlightLayouts },
38+
{ "arrow_expand", settings.arrowExpand },
39+
{ "order_children", settings.orderChildren },
40+
{ "advanced_settings", settings.advancedSettings },
41+
{ "show_memory_viewer", settings.showMemoryViewer },
42+
{ "theme", settings.theme },
43+
});
44+
}
45+
};
46+
47+
$on_mod(DataSaved) { DevTools::get()->saveSettings(); }
48+
1449
DevTools* DevTools::get() {
15-
static auto inst = new DevTools;
50+
static auto inst = new DevTools();
1651
return inst;
1752
}
1853

54+
void DevTools::loadSettings() { m_settings = Mod::get()->getSavedValue<Settings>("settings"); }
55+
void DevTools::saveSettings() { Mod::get()->setSavedValue("settings", m_settings); }
56+
1957
bool DevTools::shouldPopGame() const {
20-
return m_visible && m_GDInWindow;
58+
return m_visible && m_settings.GDInWindow;
2159
}
2260

2361
bool DevTools::pausedGame() const {
@@ -29,7 +67,7 @@ bool DevTools::isSetup() const {
2967
}
3068

3169
bool DevTools::shouldOrderChildren() const {
32-
return m_orderChildren;
70+
return m_settings.orderChildren;
3371
}
3472

3573
CCNode* DevTools::getSelectedNode() const {
@@ -51,17 +89,9 @@ void DevTools::drawPage(const char* name, void(DevTools::*pageFun)()) {
5189
ImGui::End();
5290
}
5391

54-
#ifndef GEODE_IS_MACOS
55-
56-
float DevTools::retinaFactor() {
57-
return 1.f;
58-
}
59-
60-
#endif
61-
6292
void DevTools::drawPages() {
6393
const auto size = CCDirector::sharedDirector()->getOpenGLView()->getFrameSize();
64-
94+
6595
if ((!Mod::get()->setSavedValue("layout-loaded", true) || m_shouldRelayout)) {
6696
m_shouldRelayout = false;
6797

@@ -97,7 +127,7 @@ void DevTools::drawPages() {
97127
&DevTools::drawSettings
98128
);
99129

100-
if (m_advancedSettings) {
130+
if (m_settings.advancedSettings) {
101131
this->drawPage(
102132
U8STR(FEATHER_SETTINGS " Advanced Settings###devtools/advanced/settings"),
103133
&DevTools::drawAdvancedSettings
@@ -109,10 +139,13 @@ void DevTools::drawPages() {
109139
&DevTools::drawAttributes
110140
);
111141

142+
// TODO: fix preview tab
143+
#if 0
112144
this->drawPage(
113145
U8STR(FEATHER_DATABASE " Preview###devtools/preview"),
114146
&DevTools::drawPreview
115147
);
148+
#endif
116149

117150
if (m_showModGraph) {
118151
this->drawPage(
@@ -121,23 +154,20 @@ void DevTools::drawPages() {
121154
);
122155
}
123156

124-
if (m_showModIndex) {
125-
this->drawPage(
126-
U8STR(FEATHER_LIST " Mod Index###devtools/advanced/mod-index"),
127-
&DevTools::drawModIndex
128-
);
157+
if (m_settings.showMemoryViewer) {
158+
this->drawPage("Memory viewer", &DevTools::drawMemory);
129159
}
130160
}
131161

132162
void DevTools::draw(GLRenderCtx* ctx) {
133163
if (m_visible) {
134164
if (m_reloadTheme) {
135-
applyTheme(m_theme);
165+
applyTheme(m_settings.theme);
136166
m_reloadTheme = false;
137167
}
138168

139169
m_dockspaceID = ImGui::DockSpaceOverViewport(
140-
nullptr, ImGuiDockNodeFlags_PassthruCentralNode
170+
0, nullptr, ImGuiDockNodeFlags_PassthruCentralNode
141171
);
142172

143173
ImGui::PushFont(m_defaultFont);
@@ -154,7 +184,7 @@ void DevTools::setupFonts() {
154184
static const ImWchar icon_ranges[] = { FEATHER_MIN_FA, FEATHER_MAX_FA, 0 };
155185
static const ImWchar box_ranges[] = { BOX_DRAWING_MIN_FA, BOX_DRAWING_MAX_FA, 0 };
156186
static const ImWchar* def_ranges = ImGui::GetIO().Fonts->GetGlyphRangesDefault();
157-
187+
158188
static constexpr auto add_font = [](
159189
void* font, size_t realSize, float size, const ImWchar* range
160190
) {
@@ -182,16 +212,16 @@ void DevTools::setup() {
182212
m_setup = true;
183213

184214
IMGUI_CHECKVERSION();
185-
215+
186216
auto ctx = ImGui::CreateContext();
187-
217+
188218
auto& io = ImGui::GetIO();
189219
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
190220
// if this is true then it just doesnt work :( why
191221
io.ConfigDockingWithShift = false;
192222
// io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
193223
io.ConfigWindowsResizeFromEdges = true;
194-
224+
195225
this->setupFonts();
196226
this->setupPlatform();
197227

@@ -202,6 +232,15 @@ void DevTools::setup() {
202232
#endif
203233
}
204234

235+
void DevTools::destroy() {
236+
if (!m_setup) return;
237+
m_setup = false;
238+
m_visible = false;
239+
240+
// crashes :(
241+
// ImGui::DestroyContext();
242+
}
243+
205244
void DevTools::show(bool visible) {
206245
m_visible = visible;
207246
}

src/DevTools.hpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
#include "themes.hpp"
66
#include <cocos2d.h>
77
#include <Geode/utils/cocos.hpp>
8+
#include <Geode/utils/addresser.hpp>
9+
#include <Geode/loader/Loader.hpp>
10+
#include <Geode/loader/ModMetadata.hpp>
811
#include <unordered_map>
9-
#include <Geode/loader/Index.hpp>
1012

1113
using namespace geode::prelude;
1214

@@ -16,23 +18,27 @@ enum class HighlightMode {
1618
Layout,
1719
};
1820

21+
struct Settings {
22+
bool GDInWindow = true;
23+
bool attributesInTree = false;
24+
bool alwaysHighlight = true;
25+
bool highlightLayouts = false;
26+
bool arrowExpand = false;
27+
bool orderChildren = true;
28+
bool advancedSettings = false;
29+
bool showMemoryViewer = false;
30+
std::string theme = DARK_THEME;
31+
};
32+
1933
class DevTools {
2034
protected:
2135
bool m_visible = false;
2236
bool m_setup = false;
2337
bool m_reloadTheme = true;
24-
bool m_GDInWindow = true;
25-
bool m_attributesInTree = false;
26-
bool m_alwaysHighlight = true;
2738
bool m_shouldRelayout = false;
28-
bool m_highlightLayouts = false;
29-
bool m_arrowExpand = false;
30-
bool m_advancedSettings = false;
3139
bool m_showModGraph = false;
32-
bool m_showModIndex = false;
3340
bool m_pauseGame = false;
34-
bool m_orderChildren = true;
35-
std::string m_theme = DARK_THEME;
41+
Settings m_settings;
3642
ImGuiID m_dockspaceID;
3743
ImFont* m_defaultFont = nullptr;
3844
ImFont* m_smallFont = nullptr;
@@ -58,10 +64,9 @@ class DevTools {
5864
void drawModGraph();
5965
void drawModGraphNode(Mod* node);
6066
ModMetadata inputMetadata(void* treePtr, ModMetadata metadata);
61-
void drawModIndex();
62-
void drawIndexItem(IndexItemHandle const& node);
6367
void drawPage(const char* name, void(DevTools::* fun)());
6468
void drawPages();
69+
void drawMemory();
6570
void draw(GLRenderCtx* ctx);
6671

6772
void newFrame();
@@ -70,8 +75,12 @@ class DevTools {
7075

7176
bool hasExtension(const std::string& ext) const;
7277

78+
DevTools() { loadSettings(); }
79+
7380
public:
7481
static DevTools* get();
82+
void loadSettings();
83+
void saveSettings();
7584

7685
bool shouldUseGDWindow() const;
7786

@@ -85,12 +94,12 @@ class DevTools {
8594
void highlightNode(CCNode* node, HighlightMode mode);
8695

8796
void sceneChanged();
88-
static float retinaFactor();
8997

9098
void render(GLRenderCtx* ctx);
9199

92100
// setup ImGui & DevTools
93101
void setup();
102+
void destroy();
94103

95104
void show(bool visible);
96105
void toggle();

src/backend.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ void DevTools::setupPlatform() {
2121
// this is a lie hehe
2222
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;
2323

24+
// use static since imgui does not own the pointer!
25+
static const auto iniPath = (Mod::get()->getSaveDir() / "imgui.ini").u8string();
26+
io.IniFilename = reinterpret_cast<const char*>(iniPath.c_str());
27+
2428
unsigned char* pixels;
2529
int width, height;
2630
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
@@ -39,7 +43,7 @@ void DevTools::newFrame() {
3943

4044
auto* director = CCDirector::sharedDirector();
4145
const auto winSize = director->getWinSize();
42-
const auto frameSize = director->getOpenGLView()->getFrameSize() * DevTools::retinaFactor();
46+
const auto frameSize = director->getOpenGLView()->getFrameSize() * geode::utils::getDisplayFactor();
4347

4448
// glfw new frame
4549
io.DisplaySize = ImVec2(frameSize.width, frameSize.height);
@@ -83,7 +87,6 @@ bool DevTools::hasExtension(const std::string& ext) const {
8387
}
8488

8589
std::string extsStr(exts);
86-
log::debug("{}", extsStr);
8790
return extsStr.find(ext) != std::string::npos;
8891
}
8992

0 commit comments

Comments
 (0)