Skip to content

Commit 9c9c623

Browse files
committed
style changes and other changes
1 parent d591dab commit 9c9c623

5 files changed

Lines changed: 79 additions & 82 deletions

File tree

src/backend.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -72,58 +72,58 @@ void DevTools::setupPlatform() {
7272
#ifdef GEODE_IS_MOBILE
7373

7474
class DevToolsIMEDelegate : public CCIMEDelegate {
75-
protected:
76-
bool m_attached = false;
77-
std::string m_text;
78-
public:
79-
bool attachWithIME() override {
80-
if (CCIMEDelegate::attachWithIME()) {
81-
// being anywhere but end of line ends up messing up the text, so this sends it to the end of the line
82-
#ifdef GEODE_IS_ANDROID
83-
ImGui::GetIO().AddKeyEvent(ImGuiKey_End, true);
84-
ImGui::GetIO().AddKeyEvent(ImGuiKey_End, false);
85-
#endif
86-
m_attached = true;
87-
CCEGLView::get()->setIMEKeyboardState(true);
88-
return true;
89-
}
90-
return false;
91-
}
92-
93-
bool detachWithIME() override {
94-
if (CCIMEDelegate::detachWithIME()) {
95-
m_attached = false;
96-
CCEGLView::get()->setIMEKeyboardState(false);
97-
ImGui::ClearActiveID();
98-
return true;
99-
}
100-
return false;
101-
}
75+
protected:
76+
bool m_attached = false;
77+
std::string m_text;
78+
public:
79+
bool attachWithIME() override {
80+
if (CCIMEDelegate::attachWithIME()) {
81+
// being anywhere but end of line ends up messing up the text, so this sends it to the end of the line
82+
#ifdef GEODE_IS_ANDROID
83+
ImGui::GetIO().AddKeyEvent(ImGuiKey_End, true);
84+
ImGui::GetIO().AddKeyEvent(ImGuiKey_End, false);
85+
#endif
86+
m_attached = true;
87+
CCEGLView::get()->setIMEKeyboardState(true);
88+
return true;
89+
}
90+
return false;
91+
}
92+
93+
bool detachWithIME() override {
94+
if (CCIMEDelegate::detachWithIME()) {
95+
m_attached = false;
96+
CCEGLView::get()->setIMEKeyboardState(false);
97+
ImGui::ClearActiveID();
98+
return true;
99+
}
100+
return false;
101+
}
102102

103-
bool canAttachWithIME() override {
104-
return true;
105-
}
103+
bool canAttachWithIME() override {
104+
return true;
105+
}
106106

107-
bool canDetachWithIME() override {
108-
return true;
109-
}
107+
bool canDetachWithIME() override {
108+
return true;
109+
}
110110

111-
char const* getContentText() override {
112-
m_text = "";
113-
for (auto str : ImGui::GetInputTextState(ImGui::GetFocusID())->TextA) {
114-
m_text += str;
115-
}
116-
return m_text.c_str();
117-
}
111+
char const* getContentText() override {
112+
m_text = "";
113+
for (auto str : ImGui::GetInputTextState(ImGui::GetFocusID())->TextA) {
114+
m_text += str;
115+
}
116+
return m_text.c_str();
117+
}
118118

119-
bool isAttached() {
120-
return m_attached;
121-
}
119+
bool isAttached() {
120+
return m_attached;
121+
}
122122

123-
static DevToolsIMEDelegate* get() {
124-
static DevToolsIMEDelegate* instance = new DevToolsIMEDelegate();
125-
return instance;
126-
}
123+
static DevToolsIMEDelegate* get() {
124+
static DevToolsIMEDelegate* instance = new DevToolsIMEDelegate();
125+
return instance;
126+
}
127127
};
128128

129129
#endif
@@ -393,7 +393,7 @@ class $modify(CCTouchDispatcher) {
393393
touch->m_point = pos;
394394
if (type == CCTOUCHBEGAN) {
395395
// makes the start location in the touch correct
396-
touch->m_startPoint = CCPoint{pos.x, pos.y};
396+
touch->m_startPoint = pos;
397397
}
398398
CCTouchDispatcher::touches(touches, event, type);
399399

src/main.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,13 @@ class $modify(CCKeyboardDispatcher) {
3333
};
3434

3535
#ifdef GEODE_IS_MOBILE
36-
// lol
37-
#include <Geode/modify/MenuLayer.hpp>
38-
class $modify(MenuLayer) {
39-
bool init() {
40-
if (!MenuLayer::init()) return false;
41-
static bool first = true;
42-
if (first) {
43-
first = false;
44-
DragButton::get();
45-
}
46-
return true;
47-
}
48-
};
36+
37+
#include <Geode/loader/GameEvent.hpp>
38+
$execute {
39+
new EventListener<GameEventFilter>(+[](GameEvent*) {
40+
DragButton::get();
41+
}, GameEventFilter(GameEventType::Loaded));
42+
}
4943

5044
#include <Geode/modify/CCScene.hpp>
5145
class $modify(CCScene) {
@@ -61,6 +55,8 @@ class $modify(CCScene) {
6155

6256
#endif
6357

58+
59+
6460
class $modify(CCDirector) {
6561
void willSwitchToScene(CCScene* scene) {
6662
CCDirector::willSwitchToScene(scene);

src/nodes/DragButton.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void DragButton::update(float dt) {
8888
}
8989

9090
DragButton* DragButton::get() {
91-
static DragButton* instance;
91+
static DragButton* instance = nullptr;
9292
if (!instance) {
9393
auto spr = CircleButtonSprite::createWithSprite("devtools.png"_spr, 1, CircleBaseColor::Green, CircleBaseSize::MediumAlt);
9494
spr->setScale(.8f);

src/nodes/DragButton.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#include "Geode/cocos/touch_dispatcher/CCTouchDelegateProtocol.h"
55

66
class DragButton : public cocos2d::CCLayer {
7-
protected:
8-
std::function<void()> m_onPress;
9-
cocos2d::CCPoint m_diff = cocos2d::CCPoint{0, 0};
7+
protected:
8+
std::function<void()> m_onPress;
9+
cocos2d::CCPoint m_diff = cocos2d::CCPoint{0, 0};
1010

11-
bool init(cocos2d::CCNode* node, std::function<void()>);
12-
bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
13-
void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
14-
void ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
15-
void ccTouchCancelled(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
11+
bool init(cocos2d::CCNode* node, std::function<void()>);
12+
bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
13+
void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
14+
void ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
15+
void ccTouchCancelled(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) override;
1616

17-
void registerWithTouchDispatcher() override;
17+
void registerWithTouchDispatcher() override;
1818

19-
void update(float dt) override;
20-
public:
21-
void setCallback(std::function<void()> onPress);
22-
std::function<void()> getCallback();
19+
void update(float dt) override;
20+
public:
21+
void setCallback(std::function<void()> onPress);
22+
std::function<void()> getCallback();
2323

24-
static DragButton* create(cocos2d::CCNode* node, std::function<void()> onPress);
25-
static DragButton* get();
24+
static DragButton* create(cocos2d::CCNode* node, std::function<void()> onPress);
25+
static DragButton* get();
2626
};

src/pages/Tree.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
3030
}
3131

3232
if (m_searchQuery.empty()) {
33-
ImGui::SetNextItemOpen(m_nodeOpen.contains(node) ? m_nodeOpen[node] : false);
33+
ImGui::SetNextItemOpen(m_nodeOpen.contains(node) && m_nodeOpen[node]);
3434
}
3535
else if (m_searchQuery != m_prevQuery) {
3636
ImGui::SetNextItemOpen(true);
@@ -91,7 +91,8 @@ void DevTools::drawTree() {
9191
ImGui::Dummy({0.f, 60.f});
9292
#endif
9393
m_prevQuery = m_searchQuery;
94-
ImGui::InputText("Search Tree", &m_searchQuery, 256);
94+
ImGui::SetNextItemWidth(-1.f);
95+
ImGui::InputTextWithHint("", U8STR(FEATHER_SEARCH " Search for a node..."), &m_searchQuery, ImGuiInputTextFlags_EnterReturnsTrue);
9596

9697
this->drawTreeBranch(CCDirector::get()->getRunningScene(), 0);
9798
}
@@ -103,9 +104,9 @@ bool DevTools::searchBranch(CCNode* node) {
103104
std::string id = node->getID();
104105
std::string query = m_searchQuery;
105106

106-
std::ranges::transform(name, name.begin(), ::tolower);
107-
std::ranges::transform(id.begin(), id.end(), id.begin(), ::tolower);
108-
std::ranges::transform(query.begin(), query.end(), query.begin(), ::tolower);
107+
utils::string::toLowerIP(name);
108+
utils::string::toLowerIP(id);
109+
utils::string::toLowerIP(query);
109110

110111
if (name.find(query) != std::string::npos || id.find(query) != std::string::npos) {
111112
return true;

0 commit comments

Comments
 (0)