Skip to content

Commit 4182189

Browse files
committed
Fixes
1 parent 1747160 commit 4182189

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.0.20
2+
- Fix some hover bugs
3+
- Fix onQuit crashes
4+
15
# 2.0.19
26
- Fixed a bug that caused UI modifications to not actually modify the UI haha
37

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"mac": "2.2074",
77
"ios": "2.2074"
88
},
9-
"version": "v2.0.19",
9+
"version": "v2.0.20",
1010
"id": "alphalaneous.happy_textures",
1111
"name": "Happy Textures :3",
1212
"developer": "Alphalaneous",

src/Callbacks.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,28 @@ struct MenuLayerCallbacks : public CCNode {
3636
CCDirector::get()->pushScene(CCTransitionFade::create(0.5, GJGarageLayer::scene()));
3737
}
3838

39+
void onQuit(CCObject* obj) {
40+
createQuickPopup("Quit Game", "Are you sure you want to <cr>quit</c>?", "Cancel", "Yes", [](auto, bool selected) {
41+
if (selected) {
42+
utils::game::exit(true);
43+
}
44+
}, true);
45+
}
46+
3947
};
4048

4149
void Callbacks::generateMenuLayerCallbacks() {
4250
CREATE_NORMAL(MenuLayer);
4351
m_callbacks["MenuLayer"]["onPlay"] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(MenuLayerCallbacks::onPlay));
4452
m_callbacks["MenuLayer"]["onGarage"] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(MenuLayerCallbacks::onGarage));
4553
m_callbacks["MenuLayer"]["onCreator"] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(MenuLayerCallbacks::onCreator));
54+
m_callbacks["MenuLayer"]["onQuit"] = std::pair<CCNode*, cocos2d::SEL_MenuHandler>(self, menu_selector(MenuLayerCallbacks::onQuit));
4655
REGISTER_CALLBACK(MenuLayer, onAchievements);
4756
REGISTER_CALLBACK(MenuLayer, onDaily);
4857
REGISTER_CALLBACK(MenuLayer, onMoreGames);
4958
REGISTER_CALLBACK(MenuLayer, onMyProfile);
5059
REGISTER_CALLBACK(MenuLayer, onOptions);
5160
REGISTER_CALLBACK(MenuLayer, onStats);
52-
REGISTER_CALLBACK(MenuLayer, onQuit);
5361
}
5462

5563
void Callbacks::generateCreatorLayerCallbacks() {

src/HPTCCNode.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ struct TouchObject : public CCNode, CCTouchDelegate {
8181
return lastAlert;
8282
}
8383

84-
bool isHoverable(CCNode* node, CCPoint point) {
84+
bool isHoverable(CCNode* node) {
8585
if (!CCScene::get() || !node || isLastAlert()) return false;
86+
auto worldPos = node->convertToWorldSpaceAR(CCPointZero);
8687

8788
auto sceneChild = getSceneChildContainingNode();
8889
if (!sceneChild) return false;
8990

9091
for (auto child : CCArrayExt<CCNode*>(CCScene::get()->getChildren())) {
9192
if (child->getZOrder() <= sceneChild->getZOrder()) continue;
92-
if (child->boundingBox().containsPoint(point) && nodeIsVisible(child)) {
93+
if (child->boundingBox().containsPoint(worldPos) && nodeIsVisible(child)) {
9394
return false;
9495
}
9596
}
@@ -100,8 +101,9 @@ struct TouchObject : public CCNode, CCTouchDelegate {
100101
if (!nodeIsVisible(m_self)) return;
101102
if (!m_self->getParent()) return;
102103

103-
auto worldPos = m_self->convertToWorldSpaceAR(CCPointZero);
104-
bool isValid = nodeIsVisible(m_self) && m_self->boundingBox().containsPoint(getMousePos()) && isHoverable(m_self, worldPos);
104+
auto nodeMouse = m_self->getParent()->convertToNodeSpace(getMousePos());
105+
106+
bool isValid = m_self->boundingBox().containsPoint(nodeMouse) && isHoverable(m_self);
105107

106108
checkTouch(!isValid);
107109
}

src/nodes/CCMenu.hpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <Geode/Geode.hpp>
44
#include "CCMenuItemSpriteExtra.hpp"
55
#include "../UIModding.hpp"
6-
#include "../Utils.hpp"
76
#include "../Macros.hpp"
87
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
98

@@ -52,15 +51,16 @@ class $nodeModify(MyCCMenu, cocos2d::CCMenu) {
5251
}
5352

5453

55-
bool isHoverable(CCNode* node, CCPoint point) {
54+
bool isHoverable(CCNode* node) {
5655
if (!CCScene::get() || !node || isLastAlert(node)) return false;
56+
auto worldPos = node->convertToWorldSpaceAR(CCPointZero);
5757

5858
auto sceneChild = getSceneChildContainingNode(node);
5959
if (!sceneChild) return false;
6060

61-
for (auto child : CCArrayExt<CCNode*>(CCScene::get()->getChildren())) {
61+
for (auto child : CCScene::get()->getChildrenExt()) {
6262
if (child->getZOrder() <= sceneChild->getZOrder()) continue;
63-
if (child->boundingBox().containsPoint(point) && nodeIsVisible(child)) {
63+
if (child->boundingBox().containsPoint(worldPos) && nodeIsVisible(child)) {
6464
return false;
6565
}
6666
}
@@ -72,11 +72,16 @@ class $nodeModify(MyCCMenu, cocos2d::CCMenu) {
7272

7373
auto mousePos = getMousePos();
7474
for (auto child : CCArrayExt<CCNode*>(getChildren())) {
75+
if (!nodeIsVisible(child)) continue;
7576
auto realItem = typeinfo_cast<CCMenuItemSpriteExtra*>(child);
7677
if (!realItem) continue;
78+
7779
if (EventCCMenuItemSpriteExtra* button = static_cast<EventCCMenuItemSpriteExtra*>(realItem)) {
78-
auto worldPos = button->convertToWorldSpaceAR(CCPointZero);
79-
bool isValid = nodeIsVisible(button) && button->boundingBox().containsPoint(mousePos) && isHoverable(button, worldPos);
80+
auto worldPos = button->convertToWorldSpace(CCPointZero);
81+
82+
auto nodeMouse = convertToNodeSpace(mousePos);
83+
84+
bool isValid = button->boundingBox().containsPoint(nodeMouse) && isHoverable(button);
8085
button->checkTouch(!isValid);
8186
}
8287
}

0 commit comments

Comments
 (0)