Skip to content

Commit 2ff1357

Browse files
committed
Cleaned up creating a path
1 parent d68318b commit 2ff1357

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

src/ButtonActionManager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class $modify(DifferentThing, CCMenuItemSpriteExtra){
7474
}
7575

7676
void selected(){
77-
log::debug("2");
7877
ButtonActionManager::get()->actions.selected(this);
7978
}
8079
void activate(){

src/NodeFinder.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ Node Path
1111
List of NodeAddresses
1212
array
1313
vector???
14+
*/
15+
/*
16+
17+
We need to have a map of top layer IDs to a list of paths along with callbacks.
18+
When run is called with a top layer, we check if there are any registered callbacks for that top layer.
19+
If there are, we go through each path and try to find the node.
20+
Then we call the callback with the found node (or nullptr if not found).
21+
22+
This means we need a way to represent the path to a node or just the node ID and search recursively.
23+
24+
sum types would be nice
25+
c++ has
26+
copilot what the fuck why do you hate variants
27+
28+
1429
*/
1530

1631
//does this need to be a singleton can it just be a static class?

src/NodePath.hpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ struct NodeID {
1919
// return os << ((p.idName != "") ? p.idName : std::to_string(p.idIndex));
2020
// }
2121
std::string to_string() {
22-
return (idName != "") ? idName : std::format("num{}",idIndex);
22+
//return (idName != "") ? idName : std::format("num{}",idIndex);
23+
return std::format("{}[{}]", idName, idIndex);
2324
}
2425

2526
bool operator< (const NodeID& other) const { // why tf is this here
@@ -50,11 +51,24 @@ struct NodePath {
5051
return result;
5152
}
5253

53-
54-
static int getNumID(CCNode* node) {
54+
// Gets index of node among its siblings with same
55+
static int getNumID(CCNode* node) {
56+
std::string id = node->getID();
5557
auto parent = node->getParent();
56-
auto siblings = parent->getChildren();
57-
return siblings->indexOfObject(node);
58+
auto siblings = parent->getChildrenExt(); //?????
59+
//ext works with iterators
60+
// std::vector<CCNode*> filtered;
61+
62+
// for (auto sibling : siblings) {
63+
// if (sibling->getID() == id) {
64+
// filtered.push_back(sibling);
65+
// }
66+
// }
67+
68+
auto filtered = utils::ranges::filter(siblings, [id](CCNode* sibling){
69+
return sibling->getID() == id;
70+
});
71+
return std::distance(filtered.begin(), std::find(filtered.begin(), filtered.end(), node)); // why is this what c++ does for indexOf
5872
}
5973

6074
std::string to_string() {

0 commit comments

Comments
 (0)