Skip to content

Commit

Permalink
Update main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
OmgRod authored Aug 6, 2024
1 parent 1ede194 commit 9632a27
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class BtnLayer : public CCLayer {
CCPoint touchStartPos;
CCPoint btnStartPos;
CCPoint position;
CCPoint initialPosition;

public:
void toggleModMenu(CCObject* pSender) {
Expand All @@ -190,15 +191,18 @@ class BtnLayer : public CCLayer {

auto winSize = CCDirector::sharedDirector()->getWinSize();

initialPosition = { static_cast<float>((winSize.width * -0.5f) + (btn->getContentWidth() / 2) + (winSize.width * 0.02f)), 0.f };
position = initialPosition;

menu = CCMenu::create();
menu->setPosition(ccp(0, 0));
menu->setPosition(position);
btn = CCMenuItemSpriteExtra::create(
CCSprite::create("modMenuBtn_001.png"_spr),
this,
menu_selector(BtnLayer::toggleModMenu)
);

btnOverlay = CCSprite::create("modMenuBtn_001.png"_spr);
btnOverlay = CCSprite::create("qolmodButtonOverlay.png"_spr);
btn->addChild(btnOverlay);

menu->addChild(btn);
Expand Down Expand Up @@ -255,6 +259,10 @@ class BtnLayer : public CCLayer {

btn->runAction(scale);
doingThing = false;

// Save the position if needed
// Mod::get()->setSavedValue("posX", position.x);
// Mod::get()->setSavedValue("posY", position.y);
}
}

Expand All @@ -271,9 +279,12 @@ class BtnLayer : public CCLayer {
CREATE_FUNC(BtnLayer);
};

$execute {
auto btnLayer = BtnLayer::create();
CCDirector::sharedDirector()->getRunningScene()->addChild(btnLayer);
}
class $modify (CCScene) {
void onEnter() {
CCScene::onEnter();
auto btnLayer = BtnLayer::create();
this->addChild(btnLayer, 9999); // Ensure the button layer is always on top
}
};

#endif

0 comments on commit 9632a27

Please sign in to comment.