Skip to content

Commit

Permalink
Remove Node IDs dependency, fixes and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Jun 27, 2024
1 parent 9c43724 commit a4f6ada
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 44 deletions.
12 changes: 2 additions & 10 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"gd": {
"win": "2.206"
},
"version": "v0.6.7",
"version": "v0.6.8",
"id": "zalphalaneous.minecraft",
"name": "Minecraftify!",
"developer": "Alphalaneous",
Expand All @@ -21,13 +21,5 @@
"assets/shaders/blur/*",
"assets/logo.ico"
]
},

"dependencies": [
{
"id": "geode.node-ids",
"version": ">=v1.12.0-beta.2",
"importance": "required"
}
]
}
}
1 change: 0 additions & 1 deletion src/ui/hooks/CCDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class $modify(MyCCDirector, CCDirector){


bool replaceScene(CCScene *pScene){

if(!GlobalVars::getSharedInstance()->isInitialLaunch){
Expand Down
14 changes: 14 additions & 0 deletions src/ui/hooks/CCMenuItemSpriteExtra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/CCMenuItemSpriteExtra.hpp>

class $modify(MyCCMenuItemSpriteExtra, CCMenuItemSpriteExtra){

struct Fields {
cocos2d::SEL_MenuHandler m_buttonCallback;
};

bool init(cocos2d::CCNode* p0, cocos2d::CCNode* p1, cocos2d::CCObject* p2, cocos2d::SEL_MenuHandler p3){
m_fields->m_buttonCallback = p3;
return CCMenuItemSpriteExtra::init(p0, p1, p2, p3);
}
};
85 changes: 56 additions & 29 deletions src/ui/hooks/CreatorLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
#include <Geode/modify/CreatorLayer.hpp>
#include "../nodes/MCButton.h"
#include "../nodes/MCLabel.h"
#include "../layers/MCScrollLayer.h"
#include "CCMenuItemSpriteExtra.h"

#define convertToMCButton(id, text) \
if(auto origButton = this->getChildByIDRecursive(id)){\
if(MyCCMenuItemSpriteExtra* myButton = static_cast<MyCCMenuItemSpriteExtra*>(origButton)){\
MCButton* button = MCButton::create(text, 38.1f, this, myButton->m_fields->m_buttonCallback);\
minecraftButtonMenu->addChild(button);\
}\
}

class $modify(MyCreatorLayer, CreatorLayer){

Expand All @@ -15,8 +25,14 @@ class $modify(MyCreatorLayer, CreatorLayer){
return false;
}

if(!Loader::get()->isModLoaded("geode.node-ids")) return true;

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

MCScrollLayer* scrollLayer = MCScrollLayer::create("Online Levels");

CCLayer* content = CCLayer::create();

CCNode* background = this->getChildByID("background");
background->setVisible(false);

Expand All @@ -27,28 +43,30 @@ class $modify(MyCreatorLayer, CreatorLayer){
this->getChildByIDRecursive("vault-button")->setVisible(false);
this->getChildByIDRecursive("exit-button")->setVisible(false);

this->addChild(Utils::generateDirtBG());
//this->addChild(Utils::generateDirtBG());

MCButton* createButton = MCButton::create("Create", 38.1f, this, menu_selector(CreatorLayer::onMyLevels));
MCButton* searchButton = MCButton::create("Search", 38.1f, this, menu_selector(CreatorLayer::onOnlineLevels));

MCButton* createButton = MCButton::create("Create", 39.1f, this, menu_selector(CreatorLayer::onMyLevels));
MCButton* searchButton = MCButton::create("Search", 39.1f, this, menu_selector(CreatorLayer::onOnlineLevels));
MCButton* featuredButton = MCButton::create("Featured", 38.1f, this, menu_selector(CreatorLayer::onFeaturedLevels));
MCButton* dailyButton = MCButton::create("Daily", 38.1f, this, menu_selector(CreatorLayer::onDailyLevel));
MCButton* weeklyButton = MCButton::create("Weekly", 38.1f, this, menu_selector(CreatorLayer::onWeeklyLevel));
MCButton* scoresButton = MCButton::create("Leaderboard", 38.1f, this, menu_selector(CreatorLayer::onLeaderboards));
MCButton* savedButton = MCButton::create("Saved", 38.1f, this, menu_selector(CreatorLayer::onSavedLevels));

MCButton* featuredButton = MCButton::create("Featured", 39.1f, this, menu_selector(CreatorLayer::onFeaturedLevels));
MCButton* dailyButton = MCButton::create("Daily", 39.1f, this, menu_selector(CreatorLayer::onDailyLevel));
MCButton* weeklyButton = MCButton::create("Weekly", 39.1f, this, menu_selector(CreatorLayer::onWeeklyLevel));
MCButton* scoresButton = MCButton::create("Leaderboard", 39.1f, this, menu_selector(CreatorLayer::onLeaderboards));
MCButton* savedButton = MCButton::create("Saved", 39.1f, this, menu_selector(CreatorLayer::onSavedLevels));
MCButton* questsButton = MCButton::create("Quests", 38.1f, this, menu_selector(CreatorLayer::onChallenge));
MCButton* gauntletsButton = MCButton::create("Gauntlets", 38.1f, this, menu_selector(CreatorLayer::onGauntlets));
MCButton* pathsButton = MCButton::create("Paths", 38.1f, this, menu_selector(CreatorLayer::onPaths));
MCButton* listsButton = MCButton::create("Lists", 38.1f, this, menu_selector(CreatorLayer::onTopLists));
MCButton* mapPacksButton = MCButton::create("Map Packs", 38.1f, this, menu_selector(CreatorLayer::onMapPacks));
MCButton* vaultButton = MCButton::create("Vault", 38.1f, this, menu_selector(CreatorLayer::onSecretVault));
MCButton* treasureButton = MCButton::create("Treasure", 38.1f, this, menu_selector(CreatorLayer::onTreasureRoom));

MCButton* questsButton = MCButton::create("Quests", 39.1f, this, menu_selector(CreatorLayer::onChallenge));
MCButton* gauntletsButton = MCButton::create("Gauntlets", 39.1f, this, menu_selector(CreatorLayer::onGauntlets));
MCButton* pathsButton = MCButton::create("Paths", 39.1f, this, menu_selector(CreatorLayer::onPaths));
MCButton* listsButton = MCButton::create("Lists", 39.1f, this, menu_selector(CreatorLayer::onTopLists));
MCButton* mapPacksButton = MCButton::create("Map Packs", 39.1f, this, menu_selector(CreatorLayer::onMapPacks));
MCButton* vaultButton = MCButton::create("Vault", 39.1f, this, menu_selector(CreatorLayer::onSecretVault));
MCButton* treasureButton = MCButton::create("Treasure", 39.1f, this, menu_selector(CreatorLayer::onTreasureRoom));
float gap = 58.0f;

CCMenu* importantButtonMenu = CCMenu::create();
importantButtonMenu->setContentSize({400, 60});
importantButtonMenu->setPosition({winSize.width/2, winSize.height - 70});
importantButtonMenu->setContentSize({300, gap});
importantButtonMenu->setPosition({winSize.width/2, 30});
importantButtonMenu->setID("important-menu"_spr);

ColumnLayout* columnLayout = ColumnLayout::create();
Expand All @@ -66,8 +84,8 @@ class $modify(MyCreatorLayer, CreatorLayer){

CCMenu* minecraftButtonMenu = CCMenu::create();

minecraftButtonMenu->setContentSize({400, 300});
minecraftButtonMenu->setPosition({winSize.width/2, winSize.height - 170});
minecraftButtonMenu->setContentSize({300, 300});
minecraftButtonMenu->setPosition({winSize.width/2, gap});
minecraftButtonMenu->setID("creator-buttons-menu"_spr);

ColumnLayout* columnLayout2 = ColumnLayout::create();
Expand All @@ -78,7 +96,7 @@ class $modify(MyCreatorLayer, CreatorLayer){


minecraftButtonMenu->setLayout(columnLayout2);

minecraftButtonMenu->setAnchorPoint({0.5, 1});

minecraftButtonMenu->addChild(dailyButton);
minecraftButtonMenu->addChild(weeklyButton);
Expand All @@ -93,27 +111,36 @@ class $modify(MyCreatorLayer, CreatorLayer){
minecraftButtonMenu->addChild(vaultButton);
minecraftButtonMenu->addChild(treasureButton);

convertToMCButton("super-expert-button", "Super Expert");
convertToMCButton("spaghettdev.gd-roulette/roulette-button", "Roulette");
convertToMCButton("demon-progression-button", "Demon Progression");
convertToMCButton("cvolton.betterinfo/main-button", "BetterInfo");

minecraftButtonMenu->updateLayout();

this->addChild(minecraftButtonMenu);
this->addChild(importantButtonMenu);
content->addChild(minecraftButtonMenu);
content->addChild(importantButtonMenu);

CCMenu* doneMenu = CCMenu::create();

MCButton* doneButton = MCButton::create("Done", 49.1f, this, menu_selector(CreatorLayer::onBack));
doneMenu->addChild(doneButton);
doneMenu->setPosition({winSize.width/2, 50});
doneMenu->setID("done-menu"_spr);
doneMenu->ignoreAnchorPointForPosition(false);

this->addChild(doneMenu);
doneButton->setPosition({winSize.width/2, 16});
doneButton->setID("done-button"_spr);

scrollLayer->addChild(doneButton);

MCLabel* titleText = MCLabel::create("Online Levels", "minecraft.fnt"_spr);
titleText->setScale(0.4f);
titleText->setPosition({winSize.width/2, winSize.height-30});

this->addChild(titleText);
//this->addChild(titleText);
titleText->setID("title-text"_spr);

content->setContentSize({content->getContentSize().width, importantButtonMenu->getContentSize().height + minecraftButtonMenu->getContentSize().height + gap});

scrollLayer->addContent(content);
this->addChild(scrollLayer);

return true;
}
};
9 changes: 8 additions & 1 deletion src/ui/hooks/MenuLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class $modify(MenuLayer){
rightSideMenu->setUserObject("orientation", CCInteger::create(1));
}
}

return true;
}
};
Expand Down Expand Up @@ -257,7 +258,13 @@ class $modify(MyMenuLayer, MenuLayer) {

void setAllVisible(float dt){


if(!Loader::get()->isModLoaded("geode.node-ids")) {
createQuickPopup("Node IDs", "Install Node IDs to get the full Minecraftify! experience", "Cancel", "Okay", [](FLAlertLayer*, bool p0){
if(p0) {
geode::openModsList();
}
}, true);
}

CCMenu* menu = typeinfo_cast<CCMenu*>(this->getChildByID("minecraft-menu"_spr));

Expand Down
17 changes: 14 additions & 3 deletions src/ui/layers/MCScrollLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ bool MCScrollLayer::init(std::string title, float topHeight, float bottomHeight)

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

this->addChild(Utils::generateDirtBG());
CCNode* dirtBG = Utils::generateDirtBG();

dirtBG->setID("dirt-background"_spr);

this->addChild(dirtBG);

ScrollLayer* scrollLayer = ScrollLayer::create({0, bottomHeight, winSize.width, winSize.height - (topHeight + bottomHeight)}, true, true);
scrollLayer->setID("scroll-layer"_spr);
Expand All @@ -41,6 +45,7 @@ bool MCScrollLayer::init(std::string title, float topHeight, float bottomHeight)
gradientTop->setAnchorPoint({0, 1});
gradientTop->setPosition({0, winSize.height - topHeight});
gradientTop->setFlipY(true);
gradientTop->setID("gradient-top"_spr);

addChild(gradientTop);

Expand All @@ -51,6 +56,7 @@ bool MCScrollLayer::init(std::string title, float topHeight, float bottomHeight)
gradientBottom->setZOrder(10);
gradientBottom->setAnchorPoint({0, 0});
gradientBottom->setPosition({0, bottomHeight});
gradientBottom->setID("gradient-bottom"_spr);

addChild(gradientBottom);

Expand All @@ -59,8 +65,6 @@ bool MCScrollLayer::init(std::string title, float topHeight, float bottomHeight)

addChild(scrollLayer);



setKeypadEnabled(true);

return true;
Expand All @@ -84,6 +88,13 @@ void MCScrollLayer::addContent(CCLayer* content){
CCSprite* dirtBG = Utils::generateDirtBG({winSize.width, content->getContentSize().height});
dirtBG->setID("background"_spr);
dirtBG->setColor({100,100,100});
dirtBG->setFlipY(true);

content->setScaleY(-1);

for(CCNode* node : CCArrayExt<CCNode*>(content->getChildren())){
node->setScaleY(-1);
}

content->addChild(dirtBG);
scrollLayer->m_contentLayer->setContentSize(content->getContentSize());
Expand Down

0 comments on commit a4f6ada

Please sign in to comment.