Skip to content

Commit

Permalink
Yes siree, thought about
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Jan 7, 2025
1 parent 18dff33 commit 464ff1d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/DemonsInBetween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
41 changes: 27 additions & 14 deletions src/hooks/LevelInfoLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ using namespace geode::prelude;
class $modify(DIBLevelInfoLayer, LevelInfoLayer) {
struct Fields {
EventListener<web::WebTask> m_listener;
bool m_createDemon;
CCMenuItemSpriteExtra* m_demonInfoButton;
};

static void onModify(auto& self) {
Expand All @@ -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<bool>("enable-difficulties")) createDemon = false;
if (getChildByID("grd-difficulty") || !Mod::get()->getSettingValue<bool>("enable-difficulties")) f->m_createDemon = false;

auto gddpDifficulty = getChildByID("gddp-difficulty");
if (gddpDifficulty && !Mod::get()->getSettingValue<bool>("gddp-integration-override")) createDemon = false;
if (gddpDifficulty && !Mod::get()->getSettingValue<bool>("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;
}

Expand All @@ -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(); });

Expand Down Expand Up @@ -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(
"<cy>{}</c>\n"
"<cg>Tier</c>: {}\n"
"<cl>Enjoyment</c>: {}\n"
Expand All @@ -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<CCSprite*>(getChildByID("between-difficulty-sprite"_spr))) {
betweenDifficultySprite->setDisplayFrame(
Expand Down

0 comments on commit 464ff1d

Please sign in to comment.