From 2cbb1698e5a4eec4fac57e8479636466185beeb5 Mon Sep 17 00:00:00 2001 From: Minemaker0430 <85040155+Minemaker0430@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:20:12 -0600 Subject: [PATCH] beta 24 --- changelog.md | 10 ++++++++++ mod.json | 4 ++-- src/CreatorLayer.cpp | 18 +++++++++++++---- src/DPLayer.hpp | 1 - src/LevelListLayer.cpp | 12 ++++++++--- src/Settings.hpp | 21 ++++++++++---------- src/StatsPopup.cpp | 45 ++++++++++++++++++++++-------------------- src/main.cpp | 35 +++++++++++++++++++++++++++----- 8 files changed, 100 insertions(+), 46 deletions(-) diff --git a/changelog.md b/changelog.md index 39ff77d..5b8423d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,13 @@ +# v1.0.0-beta.24 + +* Fixed a weirdly specific crash +* Converted Stats Menu tabs to ButtonSprites instead of whatever I did +* Pages API Compatibility +* Fixed some sprite alignment issues +* Fixed Settings Page crash +* Attempted to fix save file bugs +* ABSOLUTE PERFECTION now shows the correct percentage + # v1.0.0-beta.23 * Fixed Crash diff --git a/mod.json b/mod.json index b133f4a..cfb275c 100644 --- a/mod.json +++ b/mod.json @@ -1,10 +1,10 @@ { - "geode": "3.0.0-beta.1", + "geode": "3.0.0-beta.4", "gd": { "win": "2.206", "android": "2.206" }, - "version": "v1.0.0-beta.23", + "version": "v1.0.0-beta.24", "id": "minemaker0430.gddp_integration", "name": "GDDP Integration", "developer": "Minemaker0430", diff --git a/src/CreatorLayer.cpp b/src/CreatorLayer.cpp index a6ad335..23478f3 100644 --- a/src/CreatorLayer.cpp +++ b/src/CreatorLayer.cpp @@ -62,13 +62,21 @@ class $modify(CreatorLayer) { } auto dpBtn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(DPLayer::callback)); - dpBtn->setPosition({ 451, 153 }); + dpBtn->setContentSize({ 83.6f, 83.6f }); + dpBtn->setPosition({ 450.f, 155.f }); dpBtn->setID("demon-progression-button"); + typeinfo_cast(dpBtn->getChildren()->objectAtIndex(0))->setPositionX(44.f); menu->addChild(dpBtn); if (menu->getChildByID("map-packs-button")) { - dpBtn->setPosition({ menu->getChildByID("map-packs-button")->getPositionX() + 2.2f, menu->getChildByID("map-packs-button")->getPositionY() - 2 }); - menu->getChildByID("map-packs-button")->setVisible(false); + dpBtn->setPosition({ menu->getChildByID("map-packs-button")->getPositionX(), menu->getChildByID("map-packs-button")->getPositionY() }); + + if (Loader::get()->isModLoaded("alphalaneous.pages_api")) { + menu->getChildByID("map-packs-button")->removeMeAndCleanup(); + } + else { + menu->getChildByID("map-packs-button")->setVisible(false); + } } } else { @@ -86,8 +94,10 @@ class $modify(CreatorLayer) { } auto dpBtn = CCMenuItemSpriteExtra::create(spr, this, menu_selector(DPLayer::callback)); - dpBtn->setPosition({ 451, 153 }); + dpBtn->setContentSize({ 83.6f, 83.6f }); + dpBtn->setPosition({ 450.f, 155.f }); dpBtn->setID("demon-progression-button"); + typeinfo_cast(dpBtn->getChildren()->objectAtIndex(0))->setPositionX(44.f); menu->addChild(dpBtn); if (Loader::get()->isModLoaded("capeling.goodbye_unnecessary_buttons")) { diff --git a/src/DPLayer.hpp b/src/DPLayer.hpp index d301a1c..258330d 100644 --- a/src/DPLayer.hpp +++ b/src/DPLayer.hpp @@ -34,7 +34,6 @@ class DPLayer : public CCLayer { void reloadCallback(CCObject*); //when reload is pressed void reloadData(bool); //reload all data void reloadList(int type); - void infoCallback(CCObject*); void soonCallback(CCObject*); //Coming Soon void achievementsCallback(CCObject*); }; diff --git a/src/LevelListLayer.cpp b/src/LevelListLayer.cpp index a2ae0a3..d3319c2 100644 --- a/src/LevelListLayer.cpp +++ b/src/LevelListLayer.cpp @@ -130,6 +130,9 @@ class $modify(LevelListLayer) { if (inGDDP && !Mod::get()->getSavedValue("is-practice", false)) { auto progText = getChildOfType(this, 2); + + if (!progText) { return; } + std::string progressStr = progText->getString(); auto packProgress = 0; @@ -168,16 +171,16 @@ class $modify(LevelListLayer) { auto listID = data[type][id]["listID"].as_int(); //get list save - auto listSave = Mod::get()->getSavedValue(std::to_string(listID)); + auto listSave = Mod::get()->getSavedValue(std::to_string(listID), ListSaveFormat { .progress = 0, .completed = false, .hasRank = false }); - auto hasRank = false; + auto hasRank = listSave.hasRank; auto progress = packProgress; if ((packProgress >= reqLevels) && (type == "main")) { hasRank = true; } - auto completed = false; + auto completed = listSave.completed; if ((packProgress == totalLevels) && type != "monthly") { completed = true; @@ -188,6 +191,9 @@ class $modify(LevelListLayer) { else if ((type == "monthly") && (packProgress > 5)) { completed = true; } + else { + completed = false; + } if (type == "monthly" && packProgress >= 5) { auto completedMonthlies = Mod::get()->getSavedValue("monthly-completions"); diff --git a/src/Settings.hpp b/src/Settings.hpp index a6faa5c..814c23b 100644 --- a/src/Settings.hpp +++ b/src/Settings.hpp @@ -25,19 +25,20 @@ class SectionSettingNode : public SettingNode { if (!SettingNode::init(value)) return false; this->setContentSize({ width, 40.f }); - std::string name = Mod::get()->getSettingDefinition(value->getKey())->get()->json->get("name"); + if (Mod::get()->getSettingDefinition(value->getKey())->get()->json->try_get("name")) { + std::string name = Mod::get()->getSettingDefinition(value->getKey())->get()->json->get("name"); + + auto theMenu = CCMenu::create(); + auto theLabel = CCLabelBMFont::create(name.c_str(), "bigFont.fnt"); - auto theMenu = CCMenu::create(); - auto theLabel = CCLabelBMFont::create(name.c_str(), "bigFont.fnt"); - - theLabel->setScale(.5); - theLabel->setPositionX(0); - theMenu->addChild(theLabel); - theMenu->setPosition(width / 2, 20.f); - - this->addChild(theMenu); + theLabel->setScale(.5); + theLabel->setPositionX(0); + theMenu->addChild(theLabel); + theMenu->setPosition(width / 2, 20.f); + this->addChild(theMenu); + } return true; } diff --git a/src/StatsPopup.cpp b/src/StatsPopup.cpp index bc8ee20..84c3f2d 100644 --- a/src/StatsPopup.cpp +++ b/src/StatsPopup.cpp @@ -24,44 +24,47 @@ bool StatsPopup::setup() { //create tabs auto tabs = CCMenu::create(); + + auto mainBtnSprOff = ButtonSprite::create("Summary", "bigFont.fnt", "GJ_button_01.png", 0.65f); + mainBtnSprOff->m_BGSprite->setContentSize({ 115.f, 25.f }); - auto tabOff = CCScale9Sprite::create("GJ_button_01.png"); - tabOff->setContentSize({115.f, 25.f}); + auto mainBtnSprOn = ButtonSprite::create("Summary", "bigFont.fnt", "GJ_button_02.png", 0.65f); + mainBtnSprOn->m_BGSprite->setContentSize({ 115.f, 25.f }); - auto tabOn = CCScale9Sprite::create("GJ_button_02.png"); - tabOn->setContentSize({ 115.f, 25.f }); - - auto mainBtn = CCMenuItemToggler::create(tabOff, tabOn, this, menu_selector(StatsPopup::onTab)); + auto mainBtn = CCMenuItemToggler::create(mainBtnSprOff, mainBtnSprOn, this, menu_selector(StatsPopup::onTab)); + mainBtn->setContentSize({ 115.f, 25.f }); mainBtn->setPosition({ 90.f, 0.f }); mainBtn->setID("main"); mainBtn->setTag(static_cast(StatsTab::Main)); mainBtn->toggle(true); - auto mainText = CCLabelBMFont::create("Summary", "bigFont.fnt"); - mainText->setPosition({ 57.5f, 14.f }); - mainText->setScale(0.65f); - mainBtn->addChild(mainText); tabs->addChild(mainBtn); - auto ranksBtn = CCMenuItemToggler::create(tabOff, tabOn, this, menu_selector(StatsPopup::onTab)); + auto ranksBtnSprOff = ButtonSprite::create("Ranks", "bigFont.fnt", "GJ_button_01.png", 0.65f); + ranksBtnSprOff->m_BGSprite->setContentSize({ 115.f, 25.f }); + + auto ranksBtnSprOn = ButtonSprite::create("Ranks", "bigFont.fnt", "GJ_button_02.png", 0.65f); + ranksBtnSprOn->m_BGSprite->setContentSize({ 115.f, 25.f }); + + auto ranksBtn = CCMenuItemToggler::create(ranksBtnSprOff, ranksBtnSprOn, this, menu_selector(StatsPopup::onTab)); + ranksBtn->setContentSize({ 115.f, 25.f }); ranksBtn->setPosition({ 210.f, 0.f }); ranksBtn->setID("ranks"); ranksBtn->setTag(static_cast(StatsTab::Ranks)); ranksBtn->toggle(false); - auto ranksText = CCLabelBMFont::create("Ranks", "bigFont.fnt"); - ranksText->setPosition({ 57.5f, 14.f }); - ranksText->setScale(0.65f); - ranksBtn->addChild(ranksText); tabs->addChild(ranksBtn); - auto titlesBtn = CCMenuItemToggler::create(tabOff, tabOn, this, menu_selector(StatsPopup::onTab)); + auto titlesBtnSprOff = ButtonSprite::create("Titles", "bigFont.fnt", "GJ_button_01.png", 0.65f); + titlesBtnSprOff->m_BGSprite->setContentSize({ 115.f, 25.f }); + + auto titlesBtnSprOn = ButtonSprite::create("Titles", "bigFont.fnt", "GJ_button_02.png", 0.65f); + titlesBtnSprOn->m_BGSprite->setContentSize({ 115.f, 25.f }); + + auto titlesBtn = CCMenuItemToggler::create(titlesBtnSprOff, titlesBtnSprOn, this, menu_selector(StatsPopup::onTab)); + titlesBtn->setContentSize({ 115.f, 25.f }); titlesBtn->setPosition({ 330.f, 0.f }); titlesBtn->setID("titles"); titlesBtn->setTag(static_cast(StatsTab::Titles)); titlesBtn->toggle(false); - auto titlesText = CCLabelBMFont::create("Titles", "bigFont.fnt"); - titlesText->setPosition({ 57.5f, 14.f }); - titlesText->setScale(0.65f); - titlesBtn->addChild(titlesText); tabs->addChild(titlesBtn); tabs->setPosition({0.f, 200.f}); @@ -931,7 +934,7 @@ void StatsPopup::loadTab(int id) { packProgressBack->setScaleX(0.6f); packProgressBack->setScaleY(0.65f); - auto progressLabel = CCLabelBMFont::create(fmt::format("{}%", clamp(floor(progressPercent * 100), 0, 100)).c_str(), "bigFont.fnt"); + auto progressLabel = CCLabelBMFont::create(fmt::format("{}%", clamp(floor(totalPercent * 100), 0, 100)).c_str(), "bigFont.fnt"); progressLabel->setPosition({ 170.f, 12.f }); progressLabel->setScale(0.65f); progressLabel->setZOrder(2); diff --git a/src/main.cpp b/src/main.cpp index 8e3a3a5..78bc289 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,10 +72,6 @@ DPLayer* DPLayer::create() { return nullptr; } -void DPLayer::infoCallback(CCObject*) { //unused - FLAlertLayer::create(nullptr, "GDDP Info", "OK", nullptr, "Beat the required number of levels in each pack to get a special rank and move on to the next pack.\n\nMod Developer: Minemaker0430\nGDDP Creator: Trusta\nSpecial Thanks: FireMario211 (Firee), HJFod, The GDP Discord Server, & The Geode Discord Server")->show(); -} - void DPLayer::soonCallback(CCObject*) { FLAlertLayer::create("Coming Soon!", "This feature hasn't been implemented yet but will be in the future!", "OK")->show(); } @@ -431,6 +427,7 @@ bool DPLayer::init() { listTop->setZOrder(10); listBottom->setZOrder(10); + //if (!Loader::get()->isModLoaded("alphalaneous.transparent_lists")) {} this->addChild(listMiddle); this->addChild(listLeft); this->addChild(listRight); @@ -462,6 +459,8 @@ bool DPLayer::init() { auto achievementButton = CCMenuItemSpriteExtra::create(achievementBtnSprite, this, menu_selector(DPLayer::achievementsCallback)); achievementButton->setPosition({ size.width - 30, 30 }); leaderboardButton->setPosition({ size.width - 30, 80 }); + achievementButton->setID("stats-btn"); + leaderboardButton->setID("leaderboards-btn"); auto extrasMenu = CCMenu::create(); extrasMenu->setPosition({ 0, 0 }); //extrasMenu->addChild(leaderboardButton); @@ -469,6 +468,31 @@ bool DPLayer::init() { extrasMenu->setID("extras-menu"); this->addChild(extrasMenu); + //utility tabs + auto skillsetsSpr = CircleButtonSprite::createWithSpriteFrameName("DP_Beginner.png"_spr); + auto rouletteSpr = CircleButtonSprite::createWithSpriteFrameName("DP_Beginner.png"_spr); + auto recommendedSpr = CircleButtonSprite::createWithSpriteFrameName("DP_Beginner.png"_spr); + + auto skillsetsBtn = CCMenuItemSpriteExtra::create(skillsetsSpr, this, menu_selector(DPLayer::soonCallback)); + auto rouletteBtn = CCMenuItemSpriteExtra::create(rouletteSpr, this, menu_selector(DPLayer::soonCallback)); + auto recommendedBtn = CCMenuItemSpriteExtra::create(recommendedSpr, this, menu_selector(DPLayer::soonCallback)); + + skillsetsBtn->setPositionY(50.f); + rouletteBtn->setPositionY(0.f); + recommendedBtn->setPositionY(-50.f); + + skillsetsBtn->setID("skillsets-btn"); + rouletteBtn->setID("roulette-btn"); + recommendedBtn->setID("recommended-btn"); + + auto utilityMenu = CCMenu::create(); + utilityMenu->setPosition({ 63.f, 167.f }); + utilityMenu->addChild(skillsetsBtn); + utilityMenu->addChild(rouletteBtn); + utilityMenu->addChild(recommendedBtn); + utilityMenu->setID("utility-menu"); + //this->addChild(utilityMenu); + //list tabs auto listTabs = CCMenu::create(); listTabs->setID("list-tabs"); @@ -597,7 +621,7 @@ void DPLayer::reloadList(int type) { if (type == static_cast(DPListType::Legacy)) { mainPack = m_data[dataIdx][i]["mainPack"].as_int(); } //get list save - auto listSave = Mod::get()->getSavedValue(std::to_string(listID)); + auto listSave = Mod::get()->getSavedValue(std::to_string(listID), ListSaveFormat{ .progress = 0, .completed = false, .hasRank = false }); auto fullTitle = name; if (type == static_cast(DPListType::Main) || type == static_cast(DPListType::Legacy)) { @@ -827,6 +851,7 @@ void DPLayer::reloadList(int type) { if (i == 0 && type == static_cast(DPListType::Monthly)) { auto goldBG = CCLayerColor::create({255, 200, 0, 255}); + //if (Loader::get()->isModLoaded("alphalaneous.transparent_lists")) { goldBG->setOpacity(50); } goldBG->setID("gold-bg"); cell->addChild(goldBG);