Skip to content

Commit 925c278

Browse files
committed
2 parents 29a0cb7 + f6f3843 commit 925c278

15 files changed

Lines changed: 163 additions & 53 deletions

File tree

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@ jobs:
1515
- name: Windows
1616
os: windows-latest
1717

18-
- name: macOS
19-
os: macos-latest
18+
#- name: macOS
19+
# os: macos-latest
20+
21+
- name: Android32
22+
os: ubuntu-latest
23+
target: Android32
24+
25+
- name: Android64
26+
os: ubuntu-latest
27+
target: Android64
2028

2129
name: ${{ matrix.config.name }}
2230
runs-on: ${{ matrix.config.os }}
@@ -27,7 +35,9 @@ jobs:
2735
- name: Build the mod
2836
uses: geode-sdk/build-geode-mod@main
2937
with:
38+
sdk: nightly
3039
combine: true
40+
target: ${{ matrix.config.target }}
3141

3242
package:
3343
name: Package builds

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ Source/Geode/pkg/uber-apk-signer.jar
1818
imgui/**
1919
imgui
2020

21-
**/.DS_Store
21+
**/.DS_Store
22+
.cache/

README.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` to open up the dev tools.
5+
Press `F11` (`F10` for MacOS) to open up the dev tools.
66

77
## Features
88

mod.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"geode": "v1.0.0",
3-
"version": "v1.2.2",
2+
"geode": "v2.0.0",
3+
"version": "v1.4.0",
4+
"gd": "*",
45
"id": "geode.devtools",
56
"name": "DevTools",
67
"developer": "Geode Team",

src/DevTools.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ bool DevTools::pausedGame() const {
2424
return m_pauseGame;
2525
}
2626

27+
bool DevTools::isSetup() const {
28+
return m_setup;
29+
}
30+
31+
bool DevTools::shouldOrderChildren() const {
32+
return m_orderChildren;
33+
}
34+
2735
CCNode* DevTools::getSelectedNode() const {
2836
return m_selectedNode;
2937
}
@@ -178,6 +186,11 @@ void DevTools::setup() {
178186

179187
this->setupFonts();
180188
this->setupPlatform();
189+
190+
#ifdef GEODE_IS_MOBILE
191+
ImGui::GetIO().FontGlobalScale = 3.f;
192+
ImGui::GetStyle().ScrollbarSize = 60.f;
193+
#endif
181194
}
182195

183196
void DevTools::show(bool visible) {

src/DevTools.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class DevTools {
3131
bool m_showModGraph = false;
3232
bool m_showModIndex = false;
3333
bool m_pauseGame = false;
34+
bool m_orderChildren = true;
3435
std::string m_theme = DARK_THEME;
3536
ImGuiID m_dockspaceID;
3637
ImFont* m_defaultFont = nullptr;
@@ -71,6 +72,8 @@ class DevTools {
7172

7273
bool shouldPopGame() const;
7374
bool pausedGame() const;
75+
bool isSetup() const;
76+
bool shouldOrderChildren() const;
7477

7578
CCNode* getSelectedNode() const;
7679
void selectNode(CCNode* node);

src/backend.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ void DevTools::newFrame() {
4949
);
5050
io.DeltaTime = director->getDeltaTime();
5151

52+
#ifdef GEODE_IS_DESKTOP
5253
const auto mousePos = toVec2(geode::cocos::getMousePos());
5354
io.AddMousePosEvent(mousePos.x, mousePos.y);
55+
#endif
5456

5557
// TODO: text input
5658

@@ -141,6 +143,8 @@ static float SCROLL_SENSITIVITY = 10;
141143

142144
class $modify(CCMouseDispatcher) {
143145
bool dispatchScrollMSG(float y, float x) {
146+
if(!DevTools::get()->isSetup()) return true;
147+
144148
auto& io = ImGui::GetIO();
145149
io.AddMouseWheelEvent(x / SCROLL_SENSITIVITY, -y / SCROLL_SENSITIVITY);
146150

@@ -212,10 +216,10 @@ class $modify(CCTouchDispatcher) {
212216
};
213217

214218
class $modify(CCIMEDispatcher) {
215-
void dispatchInsertText(const char* text, int len) {
219+
void dispatchInsertText(const char* text, int len, enumKeyCodes key) {
216220
auto& io = ImGui::GetIO();
217221
if (!io.WantCaptureKeyboard) {
218-
CCIMEDispatcher::dispatchInsertText(text, len);
222+
CCIMEDispatcher::dispatchInsertText(text, len, key);
219223
}
220224
std::string str(text, len);
221225
io.AddInputCharactersUTF8(str.c_str());

src/main.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,43 @@
44
#include <Geode/modify/AchievementNotifier.hpp>
55
#include <Geode/modify/CCDirector.hpp>
66
#include <Geode/modify/CCEGLView.hpp>
7+
#include <Geode/modify/CCNode.hpp>
78
#include "DevTools.hpp"
89
#include <imgui.h>
910
#include "ImGui.hpp"
1011

1112
using namespace geode::prelude;
1213

14+
class $modify(CCNode) {
15+
void sortAllChildren() override {
16+
if (DevTools::get()->shouldOrderChildren()) {
17+
CCNode::sortAllChildren();
18+
}
19+
}
20+
};
21+
1322
// todo: use shortcuts api once Geode has those
1423
class $modify(CCKeyboardDispatcher) {
15-
bool dispatchKeyboardMSG(enumKeyCodes key, bool down) {
24+
bool dispatchKeyboardMSG(enumKeyCodes key, bool down, bool arr) {
1625
if (down && (key == KEY_F11 GEODE_MACOS(|| key == KEY_F10))) {
1726
DevTools::get()->toggle();
1827
return true;
1928
}
20-
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down);
29+
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, arr);
2130
}
2231
};
2332

33+
#ifdef GEODE_IS_MOBILE
34+
// lol
35+
#include <Geode/modify/MenuLayer.hpp>
36+
class $modify(MenuLayer) {
37+
void onMoreGames(CCObject*) {
38+
DevTools::get()->toggle();
39+
}
40+
};
41+
42+
#endif
43+
2444
class $modify(AchievementNotifier) {
2545
void willSwitchToScene(CCScene* scene) {
2646
AchievementNotifier::willSwitchToScene(scene);

src/pages/Advanced.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ void DevTools::drawModGraphNode(Mod* node) {
164164
ImColor color = ImColor(1.f, 1.f, 1.f);
165165
if (node->isUninstalled())
166166
color = ImColor(0.1f, 0.1f, 0.1f);
167-
else if (!node->isLoaded())
168-
color = ImColor(1.f, 0.f, 0.f);
169167
else if (!node->isEnabled())
170168
color = ImColor(0.7f, 0.7f, 0.7f);
171169

@@ -178,10 +176,8 @@ void DevTools::drawModGraphNode(Mod* node) {
178176

179177
node->setMetadata(this->inputMetadata(node, node->getMetadata()));
180178

181-
ImGui::Text("supportsDisabling: %s", node->supportsDisabling() ? "true" : "false");
179+
ImGui::Text("isInternal: %s", node->isInternal() ? "true" : "false");
182180
ImGui::Text("early: %s", node->needsEarlyLoad() ? "true" : "false");
183-
ImGui::Text("canEnable: %s", node->canEnable() ? "true" : "false");
184-
ImGui::Text("canDisable: %s", node->canDisable() ? "true" : "false");
185181
ImGui::Text("hasUnresolvedDependencies: %s", node->hasUnresolvedDependencies() ? "true" : "false");
186182
ImGui::Text("hasUnresolvedIncompatibilities: %s", node->hasUnresolvedIncompatibilities() ? "true" : "false");
187183

src/pages/Attributes.cpp

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void DevTools::drawNodeAttributes(CCNode* node) {
3535
if (ImGui::Button("Deselect")) {
3636
return this->selectNode(nullptr);
3737
}
38-
ImGui::Text("Address: 0x%p", node);
38+
ImGui::Text("Address: %s", fmt::to_string(fmt::ptr(node)).c_str());
3939
ImGui::SameLine();
4040
if (ImGui::Button(U8STR(FEATHER_COPY " Copy"))) {
4141
clipboard::write(
@@ -48,11 +48,16 @@ void DevTools::drawNodeAttributes(CCNode* node) {
4848

4949
if (auto menuItemNode = typeinfo_cast<CCMenuItem*>(node)) {
5050
const auto selector = menuItemNode->m_pfnSelector;
51-
const auto addr = formatAddressIntoOffset(addresser::getNonVirtual(selector));
52-
ImGui::Text("CCMenuItem selector: %s", addr.c_str());
53-
ImGui::SameLine();
54-
if (ImGui::Button(U8STR(FEATHER_COPY " Copy##copymenuitem"))) {
55-
clipboard::write(addr);
51+
if (!selector) {
52+
std::string addr = "N/A";
53+
ImGui::Text("CCMenuItem selector: %s", addr.c_str());
54+
} else {
55+
const auto addr = formatAddressIntoOffset(addresser::getNonVirtual(selector));
56+
ImGui::Text("CCMenuItem selector: %s", addr.c_str());
57+
ImGui::SameLine();
58+
if (ImGui::Button(U8STR(FEATHER_COPY " Copy##copymenuitem"))) {
59+
clipboard::write(addr);
60+
}
5661
}
5762
}
5863

@@ -111,25 +116,51 @@ void DevTools::drawNodeAttributes(CCNode* node) {
111116
&CCNode::ignoreAnchorPointForPosition
112117
);
113118

114-
if (auto rgbaNode = dynamic_cast<CCRGBAProtocol*>(node)) {
119+
if (auto rgbaNode = typeinfo_cast<CCRGBAProtocol*>(node)) {
115120
auto color = rgbaNode->getColor();
116121
float _color[4] = { color.r / 255.f, color.g / 255.f, color.b / 255.f, rgbaNode->getOpacity() / 255.f };
117-
ImGui::ColorEdit4("Color", _color);
118-
rgbaNode->setColor({
119-
static_cast<GLubyte>(_color[0] * 255),
120-
static_cast<GLubyte>(_color[1] * 255),
121-
static_cast<GLubyte>(_color[2] * 255)
122-
});
123-
rgbaNode->setOpacity(static_cast<GLubyte>(_color[3] * 255));
122+
if (ImGui::ColorEdit4("Color", _color)) {
123+
rgbaNode->setColor({
124+
static_cast<GLubyte>(_color[0] * 255),
125+
static_cast<GLubyte>(_color[1] * 255),
126+
static_cast<GLubyte>(_color[2] * 255)
127+
});
128+
129+
rgbaNode->setOpacity(static_cast<GLubyte>(_color[3] * 255));
130+
}
124131
}
125132

126-
if (auto labelNode = dynamic_cast<CCLabelProtocol*>(node)) {
133+
if (auto labelNode = typeinfo_cast<CCLabelProtocol*>(node)) {
127134
std::string str = labelNode->getString();
128135
if (ImGui::InputText("Text", &str, 256)) {
129136
labelNode->setString(str.c_str());
130137
}
131138
}
132139

140+
if (auto textureProtocol = typeinfo_cast<CCTextureProtocol*>(node)) {
141+
if (auto texture = textureProtocol->getTexture()) {
142+
auto* cachedTextures = CCTextureCache::sharedTextureCache()->m_pTextures;
143+
for (auto [key, obj] : CCDictionaryExt<std::string, CCTexture2D*>(cachedTextures)) {
144+
if (obj == texture) {
145+
ImGui::TextWrapped("Texture name: %s", key.c_str());
146+
break;
147+
}
148+
}
149+
150+
if (auto spriteNode = typeinfo_cast<CCSprite*>(node)) {
151+
auto* cachedFrames = CCSpriteFrameCache::sharedSpriteFrameCache()->m_pSpriteFrames;
152+
const auto rect = spriteNode->getTextureRect();
153+
for (auto [key, frame] : CCDictionaryExt<std::string, CCSpriteFrame*>(cachedFrames)) {
154+
if (frame->getTexture() == texture && frame->getRect() == rect) {
155+
ImGui::Text("Frame name: %s", key.c_str());
156+
break;
157+
}
158+
}
159+
}
160+
161+
}
162+
}
163+
133164
ImGui::NewLine();
134165
ImGui::Separator();
135166
ImGui::NewLine();

0 commit comments

Comments
 (0)