Skip to content

Commit 572dc9e

Browse files
committed
counters
1 parent b3efa7a commit 572dc9e

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

mod.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
"name": "Vertical in 1 Player Mode",
2929
"description": "Disables the vertical input while in 1 player mode, as they're registered as left and right.",
3030
"default": true
31-
}
31+
},
32+
"counters": {
33+
"type": "bool",
34+
"name": "Change Counters",
35+
"description": "Changes counter 3740 for horizontal and 3741 for vertical if a text object with \"--joystick-counters\"",
36+
"default": true
37+
}
3238
}
3339
}

src/JoystickNode.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
11
#include "JoystickNode.hpp"
22
#include "utils.hpp"
33

4+
#include <Geode/modify/GJBaseGameLayer.hpp>
5+
#include <Geode/modify/PlayLayer.hpp>
6+
#include <Geode/modify/LevelEditorLayer.hpp>
7+
8+
bool enableCounters = false;
9+
10+
class $modify(JSPL, PlayLayer) {
11+
void setupHasCompleted() {
12+
enableCounters = false;
13+
if (fastGetSetting<"counters", bool>()) {
14+
for (auto obj : CCArrayExt<GameObject*>(m_objects)) {
15+
if (obj->m_objectID == 914) {
16+
if (auto txt = static_cast<TextGameObject*>(obj); txt && txt->m_text == "--joystick-counters") {
17+
//removeObject(obj, true);
18+
enableCounters = true;
19+
}
20+
}
21+
}
22+
}
23+
PlayLayer::setupHasCompleted();
24+
}
25+
};
26+
27+
class $modify(JSLEL, LevelEditorLayer) {
28+
void onPlaytest() {
29+
enableCounters = false;
30+
if (fastGetSetting<"counters", bool>()) {
31+
for (auto obj : CCArrayExt<GameObject*>(m_objects)) {
32+
if (obj->m_objectID == 914) {
33+
if (auto txt = static_cast<TextGameObject*>(obj); txt && txt->m_text == "--joystick-counters") {
34+
//removeObject(obj, true);
35+
enableCounters = true;
36+
}
37+
}
38+
}
39+
}
40+
LevelEditorLayer::onPlaytest();
41+
}
42+
};
43+
444
bool JoystickNode::init() {
545
if (!CCMenu::init()) return false;
646
setContentSize({100, 100});
@@ -57,12 +97,14 @@ void JoystickNode::handleInput(GJBaseGameLayer *layer, CCPoint input, CCPoint ol
5797
} else if (input.x == -1) {
5898
layer->queueButton(2, true, false);
5999
}
100+
if (enableCounters) layer->updateCounters(3740, input.x);
60101
if (!fastGetSetting<"disable-updown", bool>() || m_twoPlayer) {
61102
if (input.y == 1) {
62103
layer->queueButton(3, true, true);
63104
} else if (input.y == -1) {
64105
layer->queueButton(2, true, true);
65106
}
107+
if (enableCounters) layer->updateCounters(3741, input.y);
66108
}
67109
}
68110

0 commit comments

Comments
 (0)