From 464ff1dd58d0a2796c6b0f18d9021a9076fa166d Mon Sep 17 00:00:00 2001 From: hiimjustin000 <52604018+hiimjustin000@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:57:10 -0500 Subject: [PATCH] Yes siree, thought about --- CMakeLists.txt | 2 +- changelog.md | 4 ++++ mod.json | 4 ++-- src/DemonsInBetween.cpp | 2 +- src/hooks/LevelInfoLayer.cpp | 41 ++++++++++++++++++++++++------------ 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e24177..9d1086d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") set(CMAKE_CXX_VISIBILITY_PRESET hidden) -project(DemonsInBetween VERSION 1.4.5) +project(DemonsInBetween VERSION 1.4.6) add_library(${PROJECT_NAME} SHARED src/classes/DIBInfoPopup.cpp diff --git a/changelog.md b/changelog.md index 5254e37..4977971 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Demons In Between Changelog +## v1.4.6 (2025-01-07) +- Added back demon refresh button in the level info page +- Fixed enjoyment rating not showing up in the demon info popup + ## v1.4.5 (2024-11-24) - Fixed some crashes related to exiting menus too quickly - Fixed difficulties disappearing on failed requests diff --git a/mod.json b/mod.json index fd70f7a..312bdf2 100644 --- a/mod.json +++ b/mod.json @@ -1,11 +1,11 @@ { - "geode": "4.0.1", + "geode": "4.1.2", "gd": { "android": "2.2074", "win": "2.2074", "mac": "2.2074" }, - "version": "v1.4.5", + "version": "v1.4.6", "id": "hiimjustin000.demons_in_between", "name": "Demons In Between", "developer": "hiimjustin000", diff --git a/src/DemonsInBetween.cpp b/src/DemonsInBetween.cpp index 2ba809f..d80bd77 100644 --- a/src/DemonsInBetween.cpp +++ b/src/DemonsInBetween.cpp @@ -64,7 +64,7 @@ void DemonsInBetween::loadDemonForLevel( auto rating = round(json["Rating"].asDouble().unwrapOr(0.0) * 100) / 100; auto difficulty = DemonsInBetween::DIFFICULTY_INDICES[(int)round(rating)]; - auto enjoyment = !json.contains("Enjoyment") || json["Enjoyment"].isNull() ? round(json["Enjoyment"].asDouble().unwrapOr(-999.0) * 100) / 100 : -999.0; + auto enjoyment = !json.contains("Enjoyment") || json["Enjoyment"].isNull() ? -999.0 : round(json["Enjoyment"].asDouble().unwrapOr(-999.0) * 100) / 100; auto& gddl = main ? GDDL_MAIN : GDDL; gddl.push_back({ levelID, rating, enjoyment, difficulty }); diff --git a/src/hooks/LevelInfoLayer.cpp b/src/hooks/LevelInfoLayer.cpp index 5964363..bc0ca7f 100644 --- a/src/hooks/LevelInfoLayer.cpp +++ b/src/hooks/LevelInfoLayer.cpp @@ -6,6 +6,8 @@ using namespace geode::prelude; class $modify(DIBLevelInfoLayer, LevelInfoLayer) { struct Fields { EventListener m_listener; + bool m_createDemon; + CCMenuItemSpriteExtra* m_demonInfoButton; }; static void onModify(auto& self) { @@ -17,18 +19,19 @@ class $modify(DIBLevelInfoLayer, LevelInfoLayer) { if (level->m_stars.value() < 10) return true; - auto createDemon = true; + auto f = m_fields.self(); + f->m_createDemon = true; - if (getChildByID("grd-difficulty") || !Mod::get()->getSettingValue("enable-difficulties")) createDemon = false; + if (getChildByID("grd-difficulty") || !Mod::get()->getSettingValue("enable-difficulties")) f->m_createDemon = false; auto gddpDifficulty = getChildByID("gddp-difficulty"); - if (gddpDifficulty && !Mod::get()->getSettingValue("gddp-integration-override")) createDemon = false; + if (gddpDifficulty && !Mod::get()->getSettingValue("gddp-integration-override")) f->m_createDemon = false; else if (gddpDifficulty) gddpDifficulty->setVisible(false); auto levelID = level->m_levelID.value(); auto demon = DemonsInBetween::demonForLevel(levelID, false); if (demon.id != 0 && demon.difficulty != 0) { - createUI(demon, createDemon); + createUI(demon); return true; } @@ -38,8 +41,8 @@ class $modify(DIBLevelInfoLayer, LevelInfoLayer) { ), 3); m_difficultySprite->setOpacity(0); - DemonsInBetween::loadDemonForLevel(std::move(m_fields->m_listener), levelID, false, [this, createDemon](LadderDemon& demon) { - createUI(demon, createDemon); + DemonsInBetween::loadDemonForLevel(std::move(m_fields->m_listener), levelID, false, [this](LadderDemon& demon) { + createUI(demon); release(); }, [this] { retain(); }); @@ -83,7 +86,7 @@ class $modify(DIBLevelInfoLayer, LevelInfoLayer) { case 6: originalDifficulty = "Extreme Demon"; break; } - FLAlertLayer::create("Demon Info", fmt::format( + createQuickPopup("Demon Info", fmt::format( "{}\n" "Tier: {}\n" "Enjoyment: {}\n" @@ -94,21 +97,31 @@ class $modify(DIBLevelInfoLayer, LevelInfoLayer) { demon.enjoyment >= 0.0 ? fmt::format("{}", demon.enjoyment) : "N/A", difficulty, originalDifficulty - ), "OK")->show(); + ), "OK", "Refresh", [this](auto, bool btn2) { + if (!btn2) return; + auto levelID = m_level->m_levelID.value(); + DemonsInBetween::LEVELS_LOADED.erase(levelID); + DemonsInBetween::loadDemonForLevel(std::move(m_fields->m_listener), levelID, false, [this](LadderDemon& demon) { + createUI(demon); + release(); + }, [this] { retain(); }); + }); } - void createUI(LadderDemon const& demon, bool createDemon) { - auto demonInfoButton = CCMenuItemSpriteExtra::create( + void createUI(LadderDemon const& demon) { + auto f = m_fields.self(); + if (f->m_demonInfoButton) f->m_demonInfoButton->removeFromParent(); + + f->m_demonInfoButton = CCMenuItemSpriteExtra::create( CircleButtonSprite::createWithSpriteFrameName(fmt::format("DIB_{:02d}_001.png"_spr, demon.difficulty).c_str()), this, menu_selector(DIBLevelInfoLayer::onDemonInfo) ); - demonInfoButton->setID("demon-info-button"_spr); - + f->m_demonInfoButton->setID("demon-info-button"_spr); auto leftSideMenu = getChildByID("left-side-menu"); - leftSideMenu->addChild(demonInfoButton); + leftSideMenu->addChild(f->m_demonInfoButton); leftSideMenu->updateLayout(); - if (!createDemon) return; + if (!f->m_createDemon) return; if (auto betweenDifficultySprite = static_cast(getChildByID("between-difficulty-sprite"_spr))) { betweenDifficultySprite->setDisplayFrame(