Skip to content

Commit

Permalink
beta 24
Browse files Browse the repository at this point in the history
  • Loading branch information
Minemaker0430 committed Jun 20, 2024
1 parent 7f44275 commit 2cbb169
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 46 deletions.
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 14 additions & 4 deletions src/CreatorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CCSprite*>(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 {
Expand All @@ -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<CCSprite*>(dpBtn->getChildren()->objectAtIndex(0))->setPositionX(44.f);
menu->addChild(dpBtn);

if (Loader::get()->isModLoaded("capeling.goodbye_unnecessary_buttons")) {
Expand Down
1 change: 0 additions & 1 deletion src/DPLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
};
Expand Down
12 changes: 9 additions & 3 deletions src/LevelListLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class $modify(LevelListLayer) {

if (inGDDP && !Mod::get()->getSavedValue<bool>("is-practice", false)) {
auto progText = getChildOfType<CCLabelBMFont>(this, 2);

if (!progText) { return; }

std::string progressStr = progText->getString();

auto packProgress = 0;
Expand Down Expand Up @@ -168,16 +171,16 @@ class $modify(LevelListLayer) {
auto listID = data[type][id]["listID"].as_int();

//get list save
auto listSave = Mod::get()->getSavedValue<ListSaveFormat>(std::to_string(listID));
auto listSave = Mod::get()->getSavedValue<ListSaveFormat>(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;
Expand All @@ -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<matjson::Array>("monthly-completions");
Expand Down
21 changes: 11 additions & 10 deletions src/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CustomSetting>()->json->get<std::string>("name");
if (Mod::get()->getSettingDefinition(value->getKey())->get<CustomSetting>()->json->try_get<std::string>("name")) {
std::string name = Mod::get()->getSettingDefinition(value->getKey())->get<CustomSetting>()->json->get<std::string>("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;
}
Expand Down
45 changes: 24 additions & 21 deletions src/StatsPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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<int>(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<int>(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});
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 30 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -462,13 +459,40 @@ 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);
extrasMenu->addChild(achievementButton);
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");
Expand Down Expand Up @@ -597,7 +621,7 @@ void DPLayer::reloadList(int type) {
if (type == static_cast<int>(DPListType::Legacy)) { mainPack = m_data[dataIdx][i]["mainPack"].as_int(); }

//get list save
auto listSave = Mod::get()->getSavedValue<ListSaveFormat>(std::to_string(listID));
auto listSave = Mod::get()->getSavedValue<ListSaveFormat>(std::to_string(listID), ListSaveFormat{ .progress = 0, .completed = false, .hasRank = false });

auto fullTitle = name;
if (type == static_cast<int>(DPListType::Main) || type == static_cast<int>(DPListType::Legacy)) {
Expand Down Expand Up @@ -827,6 +851,7 @@ void DPLayer::reloadList(int type) {

if (i == 0 && type == static_cast<int>(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);

Expand Down

0 comments on commit 2cbb169

Please sign in to comment.