From 8cab4c79401e11dab09a92e72327c80927377835 Mon Sep 17 00:00:00 2001 From: FireMario211 <17692105+FireMario211@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:37:41 -0500 Subject: [PATCH] all changes for now --- mod.json | 10 +++--- src/MoreLeaderboards/CustomScoreCell.cpp | 12 +++---- src/MoreLeaderboards/MoreLeaderboards.cpp | 25 +++++++------- src/MoreLeaderboards/SelectRegion.cpp | 4 +-- src/Notifications/DailyChest.cpp | 8 +++-- src/Notifications/EventsPush.cpp | 2 +- src/Secret/BadApple.cpp | 16 ++++----- src/Settings/CustomSettings.hpp | 33 +++++++++--------- src/Styles/NewGJCommentList.cpp | 4 +-- src/Styles/NewProfilePage.cpp | 2 +- src/Utils/DemonList.cpp | 41 ++++++++++++++--------- src/Utils/FriendsProfilePage.cpp | 4 ++- src/main.cpp | 20 ++++------- 13 files changed, 91 insertions(+), 90 deletions(-) diff --git a/mod.json b/mod.json index 4c7887a..de20e84 100644 --- a/mod.json +++ b/mod.json @@ -1,11 +1,11 @@ { - "geode": "3.9.0", + "geode": "4.0.0-alpha.1", "version": "v1.3.12", "gd": { - "win": "2.206", - "mac": "2.206", - "android": "2.206", - "ios": "2.206" + "win": "2.2074", + "mac": "2.2074", + "android": "2.2074", + "ios": "2.2074" }, "platforms": ["android", "win", "mac"], "id": "gdutilsdevs.gdutils", diff --git a/src/MoreLeaderboards/CustomScoreCell.cpp b/src/MoreLeaderboards/CustomScoreCell.cpp index f0388c1..1ffb62c 100644 --- a/src/MoreLeaderboards/CustomScoreCell.cpp +++ b/src/MoreLeaderboards/CustomScoreCell.cpp @@ -33,19 +33,19 @@ class $modify(CustomScoreCell, GJScoreCell) { // Move child to menu with layout auto starsLabel = as(layer->getChildByIDRecursive("stars-label")); starsLabel->setLayoutOptions( - AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1) + AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1) ); auto starsIcon = as(layer->getChildByIDRecursive("stars-icon")); starsIcon->setLayoutOptions( - AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1) + AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1) ); auto moonsLabel = as(layer->getChildByIDRecursive("moons-label")); moonsLabel->setLayoutOptions( - AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1) + AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1) ); auto moonsIcon = as(layer->getChildByIDRecursive("moons-icon")); moonsIcon->setLayoutOptions( - AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0)->setMaxScale(0.5f)->setScalePriority(1) + AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0, 0.5F)->setScalePriority(1) ); // Username control @@ -62,7 +62,7 @@ class $modify(CustomScoreCell, GJScoreCell) { (SEL_MenuHandler)&CustomScoreCell::onViewProfile ); playerNameBtn->setLayoutOptions( - AxisLayoutOptions::create()->setAutoScale(true)->setMinScale(0.5f)->setMaxScale(0.8f)->setScalePriority(1) + AxisLayoutOptions::create()->setAutoScale(true)->setScaleLimits(0.5F, 0.8F)->setScalePriority(1) ); std::vector dataString = MoreLeaderboards::getWords(data_flag, "#"); @@ -431,4 +431,4 @@ class $modify(CustomScoreCell, GJScoreCell) { layer->updateLayout(); } } -}; \ No newline at end of file +}; diff --git a/src/MoreLeaderboards/MoreLeaderboards.cpp b/src/MoreLeaderboards/MoreLeaderboards.cpp index 0ed30e7..1a7ce55 100644 --- a/src/MoreLeaderboards/MoreLeaderboards.cpp +++ b/src/MoreLeaderboards/MoreLeaderboards.cpp @@ -44,10 +44,12 @@ std::vector MoreLeaderboards::getWords(std::string s, std::string d class SearchUserLBLayer : public BrownAlertDelegate { protected: MoreLeaderboards* m_layer; - InputNode* input_username = InputNode::create(200.0F, "Username", "bigFont.fnt", "", 20); + TextInput* input_username = TextInput::create(200.0F, "Username", "bigFont.fnt"); virtual void setup() { auto winSize = cocos2d::CCDirector::sharedDirector()->getWinSize(); + input_username->setMaxCharCount(20); + input_username->setPlaceholder(""); input_username->setPositionY(10); this->m_buttonMenu->addChild(input_username); auto validate_spr = ButtonSprite::create("Search", 60, true, "bigFont.fnt", "GJ_button_01.png", 30, .5F); @@ -435,7 +437,7 @@ void MoreLeaderboards::startLoadingMods() { [expect = std::move(expect), then = std::move(then)](web::WebResponse* response) { const std::lock_guard lock(lock_var); if (response->ok()) { - then(response->string().value()); + then(response->string().unwrapOrDefault()); } else { expect("An error occured while sending a request on our server. Please try again later."); } @@ -464,7 +466,7 @@ void MoreLeaderboards::startLoadingMore() { this->retain(); - const geode::utils::MiniFunction expect = [this](std::string const& error) { + const std::function expect = [this](std::string const& error) { loading = false; auto scene = CCDirector::sharedDirector()->getRunningScene(); auto layer = scene->getChildren()->objectAtIndex(0); @@ -486,7 +488,7 @@ void MoreLeaderboards::startLoadingMore() { this->release(); }; - const geode::utils::MiniFunction then = [this](std::string const& data) { + const std::function then = [this](std::string const& data) { if (data != "-1") { data_region = data; SelectRegion::displayedData = MoreLeaderboards::getWords(data, "|"); @@ -552,7 +554,7 @@ void MoreLeaderboards::startLoadingMore() { break; } - const geode::utils::MiniFunction expect = [this](std::string const& error) { + const std::function expect = [this](std::string const& error) { loading = false; auto scene = CCDirector::sharedDirector()->getRunningScene(); @@ -575,7 +577,7 @@ void MoreLeaderboards::startLoadingMore() { this->release(); }; - const geode::utils::MiniFunction then = [this](std::string const& data) { + const std::function then = [this](std::string const& data) { loading = false; const std::lock_guard lock(lock_var); @@ -629,7 +631,7 @@ void MoreLeaderboards::startLoadingMore() { request.param("type", type).param("page", page).param("country", country_id).param("username", username).param("mod", (modFilter ? "1" : "0")).param("modFilter", modFilterType).get("https://clarifygdps.com/gdutils/moreleaderboards.php").map( [expect = std::move(expect), then = std::move(then)](web::WebResponse* response) { if (response->ok()) { - then(response->string().value()); + then(response->string().unwrap()); } else { expect("An error occured while sending a request on our server. Please try again later."); } @@ -645,7 +647,7 @@ void MoreLeaderboards::startLoadingMore() { m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) { if (web::WebResponse* res = e->getValue()) { if (res->ok()) { - then(res->string().value()); + then(res->string().unwrap()); } else { expect("An error occured while sending a request on our server. Please try again later."); } @@ -751,8 +753,7 @@ void MoreLeaderboards::loadPageStats() { page_label->setLayoutOptions( AxisLayoutOptions::create() ->setAutoScale(true) - ->setMinScale(0) - ->setMaxScale(0.7f) + ->setScaleLimits(0, 0.7F) ->setScalePriority(1) ); menu_label->addChild(page_label); @@ -1255,9 +1256,6 @@ void MoreLeaderboards::onTab(CCObject* pSender) { if (pSender) { MoreLeaderboards::g_tab = static_cast(pSender->getTag()); } - - - resetInfos(); page = 0; @@ -1293,6 +1291,7 @@ class $modify(LeaderboardsLayer) { bool init(LeaderboardState state) { if (!LeaderboardsLayer::init(state)) return false; + log::info("weee"); auto menu = CCMenu::create(); auto plusSpr = CCSprite::createWithSpriteFrameName("GJ_plusBtn_001.png"); diff --git a/src/MoreLeaderboards/SelectRegion.cpp b/src/MoreLeaderboards/SelectRegion.cpp index 8a51064..80318f3 100644 --- a/src/MoreLeaderboards/SelectRegion.cpp +++ b/src/MoreLeaderboards/SelectRegion.cpp @@ -28,7 +28,7 @@ std::vector SelectRegion::getWords(std::string s, std::string delim void SelectRegion::scene(const std::function& callback) { auto popup = new SelectRegion(callback); - if (popup && popup->init(250.0f, 210.0f)) { + if (popup && popup->initAnchored(250.0f, 210.0f)) { popup->autorelease(); CCDirector::sharedDirector()->getRunningScene()->addChild(popup); } else { @@ -63,4 +63,4 @@ void SelectRegion::loadPage() { border->setPosition(m_mainLayer->getContentSize() / 2 - border->getContentSize() / 2); setTouchPriority(100); m_mainLayer->addChild(border); -} \ No newline at end of file +} diff --git a/src/Notifications/DailyChest.cpp b/src/Notifications/DailyChest.cpp index 2b44eed..7be2da3 100644 --- a/src/Notifications/DailyChest.cpp +++ b/src/Notifications/DailyChest.cpp @@ -5,9 +5,11 @@ static GJRewardItem* time1 = nullptr; static GJRewardItem* time2 = nullptr; void DailyChest::getRewards(unsigned int type) { - GameLevelManager* glm = GameLevelManager::sharedState(); - glm->m_GJRewardDelegate = this; - glm->getGJRewards(0); + auto glm = GameLevelManager::sharedState(); + if (glm) { + glm->m_GJRewardDelegate = this; + glm->getGJRewards(0); + } }; void DailyChest::rewardsStatusFinished(int p0) { diff --git a/src/Notifications/EventsPush.cpp b/src/Notifications/EventsPush.cpp index e3f6be8..a55e7a8 100644 --- a/src/Notifications/EventsPush.cpp +++ b/src/Notifications/EventsPush.cpp @@ -324,7 +324,7 @@ void EventsPush::onClickBtn(CCObject* ret) { 180.0F )->show(); } else { - auto data_result = response->string().value(); + auto data_result = response->string().unwrapOrDefault(); if (data_result != "-1") { auto scene = CCScene::create(); auto layer = LevelInfoLayer::create(EventsPush::convertLevelToJSON(data_result), false); diff --git a/src/Secret/BadApple.cpp b/src/Secret/BadApple.cpp index 770fc89..f06fd78 100644 --- a/src/Secret/BadApple.cpp +++ b/src/Secret/BadApple.cpp @@ -73,7 +73,7 @@ class $modify(SecretVault, SecretLayer2) { m_fields->m_menu->setContentSize({ 100, 200 }); m_fields->m_menu->setLayout( ColumnLayout::create() - ->setCrossAxisAlignment(cocos2d::AxisAlignment::Center) + ->setCrossAxisAlignment(AxisAlignment::Center) ); } @@ -97,8 +97,8 @@ class $modify(SecretVault, SecretLayer2) { auto menu = CCMenu::create(); menu->setLayout( RowLayout::create() - ->setAxis(cocos2d::Axis::Column) - ->setAxisAlignment(cocos2d::AxisAlignment::Center) + ->setAxis(Axis::Column) + ->setAxisAlignment(AxisAlignment::Center) ->setGap(3) ); @@ -119,8 +119,7 @@ class $modify(SecretVault, SecretLayer2) { badappleLabel->setLayoutOptions( AxisLayoutOptions::create() ->setAutoScale(true) - ->setMinScale(0) - ->setMaxScale(.4f) + ->setScaleLimits(0, 0.4F) ->setScalePriority(1) ); menu->addChild(badappleLabel); @@ -137,8 +136,8 @@ class $modify(SecretVault, SecretLayer2) { auto menu = CCMenu::create(); menu->setLayout( RowLayout::create() - ->setAxis(cocos2d::Axis::Column) - ->setAxisAlignment(cocos2d::AxisAlignment::Center) + ->setAxis(Axis::Column) + ->setAxisAlignment(AxisAlignment::Center) ->setGap(3) ); @@ -159,8 +158,7 @@ class $modify(SecretVault, SecretLayer2) { COTELabel->setLayoutOptions( AxisLayoutOptions::create() ->setAutoScale(true) - ->setMinScale(0) - ->setMaxScale(.2f) + ->setScaleLimits(0, 0.2F) ->setScalePriority(1) ); menu->addChild(COTELabel); diff --git a/src/Settings/CustomSettings.hpp b/src/Settings/CustomSettings.hpp index a1f79d6..16a05cf 100644 --- a/src/Settings/CustomSettings.hpp +++ b/src/Settings/CustomSettings.hpp @@ -1,5 +1,4 @@ #pragma once -#include #include "CreditsBetaMenu.h" #include "CreditsMenu.h" #include @@ -11,13 +10,13 @@ using namespace geode::prelude; class SettingTestValue : public SettingV3 { public: - static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { + static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { auto res = std::make_shared(); auto root = checkJson(json, "SettingTestValue"); res->init(key, modID, root); res->parseNameAndDescription(root); root.checkUnknownKeys(); - return root.ok(res); + return root.ok(std::static_pointer_cast(res)); } bool load(matjson::Value const& json) override { @@ -93,8 +92,7 @@ enum class SettingPosEnum : int { template <> struct matjson::Serialize { - static matjson::Value to_json(SettingPosEnum const& value) { - log::info("to_json {}", static_cast(value)); + static matjson::Value toJson(SettingPosEnum const& value) { switch (value) { case SettingPosEnum::TopLeft: return 1; @@ -107,32 +105,33 @@ struct matjson::Serialize { return 4; } } - static SettingPosEnum from_json(matjson::Value const& value) { - switch (value.as_int()) { - case 1: return SettingPosEnum::TopLeft; - case 2: return SettingPosEnum::TopRight; - case 3: return SettingPosEnum::BottomLeft; - case 4: return SettingPosEnum::BottomRight; - default: throw matjson::JsonException(fmt::format("invalid SettingPosEnum value '{}'", value)); + static Result fromJson(matjson::Value const& value) { + switch (value.asInt().unwrapOrDefault()) { + case 1: return Ok(SettingPosEnum::TopLeft); + case 2: return Ok(SettingPosEnum::TopRight); + case 3: return Ok(SettingPosEnum::BottomLeft); + case 4: return Ok(SettingPosEnum::BottomRight); + default: return Err("Invalid SettingPosEnum value '{}'", value.asInt().unwrapOrDefault()); } } static bool is_json(matjson::Value const& json) { - return json.is_number() || json.is_string(); + return json.isNumber() || json.isString(); } }; class SettingPosValue : public SettingBaseValueV3 { public: - static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { + static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { auto res = std::make_shared(); auto root = checkJson(json, "SettingPosValue"); res->parseBaseProperties(key, modID, root); root.checkUnknownKeys(); - return root.ok(res); + return root.ok(std::static_pointer_cast(res)); } SettingNodeV3* createNode(float width) override; }; + template <> struct geode::SettingTypeForValueType { using SettingType = SettingPosValue; @@ -263,13 +262,13 @@ class SettingPosNode : public SettingValueNodeV3 { class SettingCreditsValue : public SettingV3 { public: - static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { + static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { auto res = std::make_shared(); auto root = checkJson(json, "SettingCreditsValue"); res->init(key, modID, root); res->parseNameAndDescription(root); root.checkUnknownKeys(); - return root.ok(res); + return root.ok(std::static_pointer_cast(res)); } bool load(matjson::Value const& json) override { diff --git a/src/Styles/NewGJCommentList.cpp b/src/Styles/NewGJCommentList.cpp index cf8b592..2318bb9 100644 --- a/src/Styles/NewGJCommentList.cpp +++ b/src/Styles/NewGJCommentList.cpp @@ -278,7 +278,7 @@ class $modify(CommentCell) { m_fields->m_listener.bind([] (web::WebTask::Event* e) { if (web::WebResponse* res = e->getValue()) { if (res->ok()) { - result_global = res->string().value(); + result_global = res->string().unwrapOrDefault(); } } }); @@ -291,4 +291,4 @@ class $modify(CommentCell) { requestGDUtilsBadges(layer, comment->m_commentID); } } -}; \ No newline at end of file +}; diff --git a/src/Styles/NewProfilePage.cpp b/src/Styles/NewProfilePage.cpp index 0674bf0..6f3737d 100644 --- a/src/Styles/NewProfilePage.cpp +++ b/src/Styles/NewProfilePage.cpp @@ -430,7 +430,7 @@ class $modify(ProfilePage) { m_fields->m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) { if (web::WebResponse* res = e->getValue()) { if (res->ok()) { - then(res->string().value()); + then(res->string().unwrapOrDefault()); } else { expect("Request failed"); } diff --git a/src/Utils/DemonList.cpp b/src/Utils/DemonList.cpp index cdd0ce5..fe0e7a8 100644 --- a/src/Utils/DemonList.cpp +++ b/src/Utils/DemonList.cpp @@ -102,7 +102,7 @@ class $modify(LevelInfoLayer) { loading_circle->show(); const std::function)> then = [this, level, levelID, loading_circle, positionLabel, demonSpr, winSize](Result const& result_json) { - matjson::Value json = result_json.value(); + matjson::Value json = result_json.unwrapOrDefault(); std::string listId = Mod::get()->template getSettingValue("demonListSelection"); @@ -115,15 +115,21 @@ class $modify(LevelInfoLayer) { log::info("Level not found in Pointercrate."); this->release(); } else { - auto info = json.get(0); - auto position = info.get("position"); - positionLabel->setString(fmt::format("#{}", position).c_str()); - positionLabel->setScale(getScaleBasedPos(position)); - positionLabel->setVisible(true); - demonSpr->setVisible(true); - set(levelID, position); - log::info("Level found in Pointercrate! {} at #{}", level->m_levelName.c_str(), position); + auto info = json.get(0); + if (info.isOk()) { + auto positionRes = info.unwrap().get("position"); + if (positionRes.isOk()) { + int position = positionRes.unwrap().asInt().unwrapOrDefault(); + positionLabel->setString(fmt::format("#{}", position).c_str()); + positionLabel->setScale(getScaleBasedPos(position)); + positionLabel->setVisible(true); + demonSpr->setVisible(true); + set(levelID, position); + log::info("Level found in Pointercrate! {} at #{}", level->m_levelName.c_str(), position); + } + } this->release(); + } } else { if (loading_circle != nullptr) { @@ -133,13 +139,16 @@ class $modify(LevelInfoLayer) { if (json.contains("code")) { this->release(); } else { - auto position = json.get("position"); - positionLabel->setString(fmt::format("#{}", position).c_str()); - positionLabel->setScale(getScaleBasedPos(position)); - positionLabel->setVisible(true); - demonSpr->setVisible(true); - set(levelID, position); - log::info("Level found in AREDL! {} at #{}", level->m_levelName.c_str(), position); + auto positionRes = json.get("position"); + if (positionRes.isOk()) { + int position = positionRes.unwrap().asInt().unwrapOrDefault(); + positionLabel->setString(fmt::format("#{}", position).c_str()); + positionLabel->setScale(getScaleBasedPos(position)); + positionLabel->setVisible(true); + demonSpr->setVisible(true); + set(levelID, position); + log::info("Level found in AREDL! {} at #{}", level->m_levelName.c_str(), position); + } this->release(); } } diff --git a/src/Utils/FriendsProfilePage.cpp b/src/Utils/FriendsProfilePage.cpp index 041f06d..1b80688 100644 --- a/src/Utils/FriendsProfilePage.cpp +++ b/src/Utils/FriendsProfilePage.cpp @@ -20,6 +20,8 @@ const char* toLowerCase(const char* str) { class SearchUserLayer : public BrownAlertDelegate { protected: virtual void setup() { + input_username->setMaxCharCount(20); + input_username->setPlaceholder(""); auto winSize = cocos2d::CCDirector::sharedDirector()->getWinSize(); input_username->setPositionY(10); this->m_buttonMenu->addChild(input_username); @@ -46,7 +48,7 @@ class SearchUserLayer : public BrownAlertDelegate { float m_fWidth = s_defWidth; float m_fHeight = s_defHeight; public: - InputNode* input_username = InputNode::create(200.0F, "Username", "bigFont.fnt", "", 20); + TextInput* input_username = TextInput::create(200.0F, "Username", "bigFont.fnt"); static constexpr const float s_defWidth = 260.0f; static constexpr const float s_defHeight = 120.0f; static SearchUserLayer* create() { diff --git a/src/main.cpp b/src/main.cpp index 4b65b6a..20c0b5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,9 +159,11 @@ void processChestEvent(CCScene* self) { class $modify(CCScheduler) { // used to be GameManager void update(float dt) { CCScheduler::update(dt); - + auto director = CCDirector::sharedDirector(); + if (!director) return; bool waitUntilExit = false; auto scene = CCDirector::sharedDirector()->getRunningScene(); + if (!scene) return; if (scene->getChildrenCount() == 0) return; auto layer = scene->getChildren()->objectAtIndex(0); if (layer == nullptr) return; @@ -177,7 +179,7 @@ class $modify(CCScheduler) { // used to be GameManager bool everywhereElse = Mod::get()->template getSettingValue("everywhereElse"); if ((layerName != "LevelEditorLayer" && layerName != "PlayLayer") && !everywhereElse) return; if ((layerName != "LevelEditorLayer" && layerName != "PlayLayer") && everywhereElse) { - processChestEvent(scene); + //processChestEvent(scene); // disabled for now until this weird chest bug is fixed processEvent(scene); } } @@ -210,6 +212,7 @@ class $modify(CCScheduler) { // used to be GameManager class $modify(CCScheduler) { // GD Protocol part void update(float dt) { CCScheduler::update(dt); + return; // disabled for now until GLM::sharedState works auto scene = CCDirector::sharedDirector()->getRunningScene(); if (scene->getChildrenCount() == 0) return; auto layer = scene->getChildren()->objectAtIndex(0); @@ -260,7 +263,7 @@ class $modify(CCScheduler) { // GD Protocol part 180.0F )->show(); } else { - auto data = response->string().value(); + auto data = response->string().unwrapOrDefault(); if (data != "-1") { auto scene = CCScene::create(); @@ -492,16 +495,6 @@ class $modify(MyMenuLayerGDUTILS, MenuLayer) { //Discord::init(); for next update ;) // also for whatever reason, discord rpc doesnt work on vanilla gd, instead it shows absolutes MH icon for some reason even though I dont own MH. can someone explain that - - /*Mod::get()->registerCustomSettingType("notificationPlacement", 4); - Mod::get()->registerCustomSettingType("demonListSelection", 2); - // ok listen here, you dont provide a way to JUST get the file name, you provide the full path which isnt what i want, so dont complain geode devs. Okay? we good? ok - #ifdef GEODE_IS_WINDOWS - Mod::get()->registerCustomSettingType("spotifyApp", "Spotify.exe"); - #else - Mod::get()->registerCustomSettingType("spotifyApp", "Spotify.app"); - #endif - Mod::get()->registerCustomSettingType("credit-buttons", "none");*/ #ifdef GEODE_IS_WINDOWS #include @@ -607,4 +600,3 @@ endlocal #endif } -