Skip to content

Commit

Permalink
Merge pull request #6 from RayDeeUx/master
Browse files Browse the repository at this point in the history
fix all the bugs
  • Loading branch information
mishpro-programm authored Dec 29, 2024
2 parents e02bde1 + 132ebcf commit 9d67801
Showing 1 changed file with 22 additions and 77 deletions.
99 changes: 22 additions & 77 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,97 +1,42 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/PauseLayer.hpp>
#include <Geode/modify/LevelInfoLayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/PauseLayer.hpp>
#include <Geode/modify/PlayLayer.hpp>
#include <Geode/modify/CCLayer.hpp>
#include <Geode/modify/LevelInfoLayer.hpp>
class $modify(MyPauseLayer, PauseLayer) {
void customSetup(){
void customSetup() {
PauseLayer::customSetup();
auto menu = this->getChildByID("right-button-menu");
if (!menu) return;
auto sprite = CCSprite::createWithSpriteFrameName("GJ_chatBtn_001.png");
sprite->setScale(0.65f);
auto btn = CCMenuItemSpriteExtra::create(sprite, this, menu_selector(MyPauseLayer::onLevelInfo));
menu->setLayout(ColumnLayout::create()->setAxisAlignment(AxisAlignment::End));
auto btn = CCMenuItemSpriteExtra::create(sprite, this, menu_selector(MyPauseLayer::onCommentsButton));
btn->setID("level-info-button"_spr);
menu->addChild(btn);
btn->setID("level-info-button");
menu->updateLayout();
}
void onLevelInfo(CCObject* sender){
auto playLayer = GameManager::get()->getPlayLayer();
if(!playLayer){
FLAlertLayer::create("Error", "Could not get PlayLayer", "OK")->show();
return;
}
auto level = playLayer->m_level;
auto infoLayer = InfoLayer::create(level, nullptr, nullptr);
infoLayer->setZOrder(11);
#ifndef GEODE_IS_MACOS
infoLayer->setScale(0.f);
auto scaleAction = CCScaleTo::create(0.3f, 1.f);
auto action = CCEaseBackOut::create(scaleAction);
infoLayer->runAction(action);
#endif
auto scene = CCDirector::sharedDirector()->getRunningScene();
scene->addChild(infoLayer);
void onCommentsButton(CCObject* sender) {
if (!CCScene::get()->getChildByType<PauseLayer>(0)) return;
const auto pl = PlayLayer::get();
if (!pl) return;
const auto level = pl->m_level;
if (!level) return;
const auto infoLayer = InfoLayer::create(level, nullptr, nullptr);
if (!infoLayer) return;
infoLayer->show(); // the other two need to be nullptr so robtop knows which InfoLayer to generate
}
};
//i copied this code from globed (tysm dankmeme)
class $modify(FixedPlayLayer, PlayLayer) {
bool isCurrentPlayLayer(){
auto playLayer = cocos2d::CCScene::get()->getChildByType<PlayLayer>(0);
return playLayer == this;
}
bool isPaused(bool checkCurrent){
if(checkCurrent && !isCurrentPlayLayer()) return false;

for(CCNode* child : CCArrayExt<CCNode*>(this->getParent()->getChildren())) {
if(typeinfo_cast<PauseLayer*>(child)) {
return true;
}
}

return false;
}
void onEnterH(){
auto weRunningScene = this->getParent() == CCScene::get();

if(weRunningScene){
CCLayer::onEnter();
return;
}

Loader::get()->queueInMainThread([self = Ref(this)] {
if (!self->isPaused(false)) {
self->CCLayer::onEnter();
}
});
}
};
class $modify(MyCCLayer, CCLayer){
void onEnter(){
if(reinterpret_cast<void*>(PlayLayer::get()) == reinterpret_cast<void*>(this)){
auto pl = reinterpret_cast<FixedPlayLayer*>(static_cast<CCLayer*>(this));
pl->onEnterH();
} else {
CCLayer::onEnter();
}
}
};
class $modify(LevelInfoLayer) {
void onPlay(CCObject* s){
if(PlayLayer::get()){
FLAlertLayer::create("Error", "Can't open level while already in another level", "OK")->show();
return;
}
void showError(const std::string& s) {
FLAlertLayer::create("Error", s, "OK")->show();
}
void onPlay(CCObject* s) {
if (PlayLayer::get()) return showError("Can't open level while already in another level");
LevelInfoLayer::onPlay(s);
}
void tryCloneLevel(CCObject* s){
if(PlayLayer::get()){
FLAlertLayer::create("Error", "Can't clone level while already in another level", "OK")->show();
return;
}
void tryCloneLevel(CCObject* s) {
if (PlayLayer::get()) return showError("Can't clone level while already in another level");
LevelInfoLayer::tryCloneLevel(s);
}
};

0 comments on commit 9d67801

Please sign in to comment.