Skip to content

Commit

Permalink
GauntletNode, GauntletSelectLayer, LevelPage, LevelSelectLayer and Mo…
Browse files Browse the repository at this point in the history
…reOptionsLayer (#33)

* GauntletSelectLayer, LevelPage, LevelSelectLayer and MoreOptionsLayer

* GauntletNode, missing GauntletSelectLayer nodeIDs and typo fixe

* Fix duplicate node and MOL on android

* Fix epic compiler error

* sorru

* GauntletSelectLayer conflict
  • Loading branch information
SpaghettDev authored Apr 12, 2024
1 parent ad79860 commit d49e19b
Show file tree
Hide file tree
Showing 6 changed files with 674 additions and 4 deletions.
5 changes: 5 additions & 0 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Has IDs for:
- EditorPauseLayer
- EditorUI
- FLAlertLayer
- GauntletNode
- GauntletSelectLayer
- GJCommentListLayer
- GJGarageLayer
- GJScoreCell
Expand All @@ -27,7 +29,10 @@ Has IDs for:
- LevelEditorLayer
- LevelInfoLayer
- LevelLeaderboard
- LevelPage
- LevelSearchLayer
- LevelSelectLayer
- MoreOptionsLayer
- OptionsLayer
- PauseLayer
- PlayLayer
Expand Down
89 changes: 89 additions & 0 deletions src/GauntletNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <Geode/Geode.hpp>
#include <Geode/binding/GauntletNode.hpp>
#include <Geode/modify/GauntletNode.hpp>
#include <Geode/utils/NodeIDs.hpp>

using namespace geode::prelude;
using namespace geode::node_ids;

struct GauntletNodeIDs : Modify<GauntletNodeIDs, GauntletNode> {
GJMapPack* m_gauntlet;

static void onModify(auto& self) {
if (!self.setHookPriority("GauntletNode::init", GEODE_ID_PRIORITY)) {
log::warn("Failed to set GauntletNode::init hook priority, node IDs may not work properly");
}
}

bool init(GJMapPack* gauntlet) {
if (!GauntletNode::init(gauntlet)) return false;

m_fields->m_gauntlet = gauntlet;

NodeIDs::get()->provide(this);

return true;
}
};

$register_ids(GauntletNode) {
const auto GSM = GameStatsManager::sharedState();
auto self = reinterpret_cast<GauntletNodeIDs*>(this);

if (self->m_fields->m_gauntlet->hasCompletedMapPack()) {
setIDs(
this,
0,
"gauntlet-info-node",
"empty-node",
"background",
"gauntlet-name-label",
"gauntlet-label",
"gauntlet-name-shadow-label",
"gauntlet-shadow-label",
"checkmark-sprite",
"checkmark-shadow-sprite"
);
} else {
setIDs(
this,
0,
"gauntlet-info-node",
"empty-node",
"background",
"gauntlet-name-label",
"gauntlet-label",
"gauntlet-name-shadow-label",
"gauntlet-shadow-label"
);
}

if (auto gauntletInfoNode = this->getChildByID("gauntlet-info-node")) {
if (
self->m_fields->m_gauntlet->hasCompletedMapPack() &&
GSM->isSpecialChestUnlocked(GSM->getGauntletRewardKey(self->m_fields->m_gauntlet->m_packID))
) {
setIDs(
gauntletInfoNode,
0,
"gauntlet-sprite",
"gauntlet-shadow-sprite",
"gauntlet-progress-label",
"gauntlet-progress-shadow-label"
);
} else {
setIDs(
gauntletInfoNode,
0,
"gauntlet-sprite",
"gauntlet-shadow-sprite",
"gauntlet-progress-label",
"gauntlet-progress-shadow-label",
"reward-label",
"reward-shadow-label",
"chest-sprite",
"chest-shadow-sprite"
);
}
}
}
72 changes: 68 additions & 4 deletions src/GauntletSelectLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#include <Geode/Bindings.hpp>
#include <Geode/Geode.hpp>
#include <Geode/binding/GauntletSelectLayer.hpp>
#include <Geode/modify/GauntletSelectLayer.hpp>
#include <Geode/utils/cocos.hpp>
#include <Geode/utils/NodeIDs.hpp>

using namespace geode::prelude;
using namespace geode::node_ids;

$register_ids(GauntletSelectLayer) {
this->setID("main-layer");

getChildOfType<CCSprite>(this, 0)->setID("background");
getChildOfType<CCSprite>(this, 1)->setID("title-sprite");

setIDs(
this,
0,
Expand All @@ -21,20 +26,79 @@ using namespace geode::node_ids;
"loading-circle",
"try-again-text"
);

if (auto arrowsMenu = this->getChildByID("scroll-buttons-menu")) {
setIDs(
arrowsMenu,
0,
"left-button",
"right-button"
);
}

if (auto miscMenu = this->getChildByID("left-menu")) {
setIDs(
miscMenu,
0,
"back-button",
"info-button",
"reload-button"
);
}
}

struct GauntletSelectLayerIDs : Modify<GauntletSelectLayerIDs, GauntletSelectLayer> {
static void onModify(auto& self) {
if (!self.setHookPriority("GauntletSelectLayer::init", GEODE_ID_PRIORITY)) {
log::warn("Failed to set GauntletSelectLayer::init hook priority, node IDs may not work properly");
}
if (!self.setHookPriority("GauntletSelectLayer::setupGauntlets", GEODE_ID_PRIORITY)) {
log::warn("Failed to set GauntletSelectLayer::setupGauntlets hook priority, node IDs may not work properly");
}
}

bool init(int idk) {
if (!GauntletSelectLayer::init(idk)) return false;
bool init(int p0) {
if (!GauntletSelectLayer::init(p0)) return false;

NodeIDs::get()->provide(this);

return true;
}

void setupGauntlets() {
GauntletSelectLayer::setupGauntlets();

if (auto gauntletsList = getChildOfType<BoomScrollLayer>(this, 0)) {
gauntletsList->setID("gauntlets-list");

if (auto gauntletPages = getChildOfType<ExtendedLayer>(gauntletsList, 0)) {
gauntletPages->setID("gauntlet-pages");

auto gauntletPagesArray = CCArrayExt<CCLayer*>(gauntletPages->getChildren());
for (int i = 0; i < gauntletPagesArray.size(); i++) {
auto gauntletPage = gauntletPagesArray[i];
gauntletPage->setID(fmt::format("gauntlet-page-{}", i + 1));

if (auto gauntletMenu = getChildOfType<CCMenu>(gauntletPage, 0)) {
gauntletMenu->setID("gauntlet-menu");

auto gauntletButtons = CCArrayExt<CCMenuItemSpriteExtra*>(gauntletMenu->getChildren());
for (int i = 0; i < gauntletButtons.size(); i++) {
auto gauntletButton = gauntletButtons[i];

gauntletButton->setID(fmt::format("gauntlet-button-{}", i + 1));

if (auto gauntletNodeParent = getChildOfType<CCNode>(gauntletButton, 0)) {
gauntletNodeParent->setID("gauntlet-node-parent");

getChildOfType<GauntletNode>(gauntletNodeParent, 0)->setID("gauntlet-node");
}
}
}
}
}

getChildOfType<CCSpriteBatchNode>(gauntletsList, 0)->setID("page-buttons");
}
}
};
141 changes: 141 additions & 0 deletions src/LevelPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include <Geode/Geode.hpp>
#include <Geode/binding/LevelPage.hpp>
#include <Geode/modify/LevelPage.hpp>
#include <Geode/utils/NodeIDs.hpp>

using namespace geode::prelude;
using namespace geode::node_ids;

$register_ids(LevelPage) {
setIDs(
this,
0,
"level-menu",
"normal-progress-bar",
"practice-progress-bar",
"normal-progress-label",
"practice-progress-label",
"normal-mode-label",
"practice-mode-label"
);

if (auto levelMenu = this->getChildByID("level-menu")) {
if (auto levelButton = getChildOfType<CCMenuItemSpriteExtra>(levelMenu, 0)) {
levelButton->setID("level-button");

// why in gods name does this sprite house everything
if (auto whiteSprite = getChildOfType<CCSprite>(levelButton, 0)) {
whiteSprite->setID("white-sprite");

if (auto scale9Sprite = getChildOfType<CCScale9Sprite>(whiteSprite, 0)) {
scale9Sprite->setID("scale-9-sprite");

setIDs(
scale9Sprite,
0,
"background",
"level-name-label",
"difficulty-sprite",
"stars-icon",
"stars-label",
"secret-coin-icon-1",
"secret-coin-icon-2",
"secret-coin-icon-3"
);
}

if (auto controllerStartSprite = getChildOfType<CCSprite>(whiteSprite, 0)) {
controllerStartSprite->setID("controller-start-sprite");
}
}
}
}
}

struct LevelPageIDs : Modify<LevelPageIDs, LevelPage> {
static void onModify(auto& self) {
if (!self.setHookPriority("LevelPage::create", GEODE_ID_PRIORITY)) {
log::warn("Failed to set LevelPage::create hook priority, node IDs may not work properly");
}
}

// LevelPage::init is half-inlined on windows
static LevelPage* create(GJGameLevel* level) {
auto layer = LevelPage::create(level);
if (!layer) return nullptr;

NodeIDs::get()->provide(layer);

return layer;
}

void updateDynamicPage(GJGameLevel* level) {
LevelPage::updateDynamicPage(level);

// can't believe im bugfixing this game
if (auto emptyMenu = getChildOfType<CCMenu>(this, 1); emptyMenu && emptyMenu->getChildrenCount() == 0) {
emptyMenu->removeFromParent();
}

if (GameStatsManager::sharedState()->getStat("8") < level->m_requiredCoins) {
setIDs(
this->getChildByID("level-menu")
->getChildByID("level-button")
->getChildByID("white-sprite")
->getChildByID("scale-9-sprite"),
8,
"lock-sprite",
"secret-coin-icon",
"secret-coin-label"
);
} else {
setIDs(
this->getChildByID("level-menu")
->getChildByID("level-button")
->getChildByID("white-sprite")
->getChildByID("scale-9-sprite"),
8,
"orbs-icon",
"orbs-label"
);
}

// this is how updateDynamicPage itself does it
if (level->m_levelID <= 0) {
if (level->m_levelID == -2) {
if (auto buttonMenu = getChildOfType<CCMenu>(this, 1)) {
buttonMenu->setID("button-menu");

if (auto towerButton = getChildOfType<CCMenuItemSpriteExtra>(buttonMenu, 0)) {
towerButton->setID("tower-button");

if (auto towerSprite = getChildOfType<CCSprite>(towerButton, 0)) {
towerSprite->setID("tower-sprite");

setIDs(
towerSprite,
0,
"the-tower-sprite",
"square-particle-system",
"glow-particle-system",
"skull-particle-system"
);
}
}
}
} else {
getChildOfType<CCLabelBMFont>(this, 4)->setID("coming-soon-label");

if (auto buttonMenu = getChildOfType<CCMenu>(this, 1)) {
buttonMenu->setID("button-menu");

if (auto secretDoorButton = getChildOfType<CCMenuItemSpriteExtra>(buttonMenu, 0)) {
secretDoorButton->setID("secret-door-button");

getChildOfType<CCSprite>(secretDoorButton, 0)->setID("secret-door-sprite");
}
}
}
}
}
};
Loading

0 comments on commit d49e19b

Please sign in to comment.