Skip to content

Commit

Permalink
I love refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Feb 6, 2025
1 parent 464ff1d commit 4e9d26c
Show file tree
Hide file tree
Showing 28 changed files with 268 additions and 223 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ jobs:
- uses: actions/checkout@v4

- name: Build the mod
uses: geode-sdk/build-geode-mod@main
uses: hiimjasmine00/build-geode-mod@main
with:
sdk: nightly
build-config: ${{ matrix.config.build-config || 'Release' }}
export-pdb: true
export-symbols: true
combine: true
target: ${{ matrix.config.target }}

Expand All @@ -47,22 +49,10 @@ jobs:
needs: ['build']

steps:
- uses: geode-sdk/build-geode-mod/combine@main
- uses: hiimjasmine00/build-geode-mod/combine@main
id: build

- uses: actions/upload-artifact@v4
with:
name: Build Output
path: ${{ steps.build.outputs.build-output }}

release:
name: Release the mod
runs-on: ubuntu-latest
needs: ['package']

steps:
- uses: actions/checkout@v4

- uses: hiimjustin000/release-geode-mod@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Geode Mod

on:
workflow_dispatch:

jobs:
release:
name: Release mod
runs-on: ubuntu-latest
environment:
name: release
url: ${{ steps.mod-release.outputs.url }}

steps:
- uses: actions/checkout@v4

- uses: hiimjasmine00/release-geode-mod@main
id: mod-release
with:
token: ${{ secrets.GITHUB_TOKEN }}

publish:
name: Publish mod
runs-on: ubuntu-latest
needs: ['release']
environment:
name: publish
url: ${{ steps.mod-publish.outputs.url }}

steps:
- uses: actions/checkout@v4

- uses: hiimjasmine00/release-geode-mod/publish@main
id: mod-publish
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(GEODE_DISABLE_PRECOMPILED_HEADERS ON)

project(DemonsInBetween VERSION 1.4.6)
project(DemonsInBetween VERSION 1.4.7)

add_library(${PROJECT_NAME} SHARED
src/classes/DIBInfoPopup.cpp
src/classes/DIBSearchPopup.cpp
src/classes/TableNode.cpp
src/hooks/LevelBrowserLayer.cpp
src/hooks/LevelCell.cpp
src/hooks/LevelInfoLayer.cpp
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 hiimjustin000
Copyright (c) 2024-2025 hiimjasmine00

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ A mod that adds demon difficulties in between existing ones.
# Credits
- [SufficientEbb](https://gdbrowser.com/u/20865884) - Idea for the mod
- [HexCodes](https://gdbrowser.com/u/16858187) - Additional ideas for the mod
- [Krintop](https://gdbrowser.com/u/7242014) - Designer of the mod logo and textures
- [hiimjustin000](https://gdbrowser.com/u/7466002) - Creator of the mod
- [Krintop](https://gdbrowser.com/u/7242014) - Designer of the mod textures
- [hiimjasmine00](https://gdbrowser.com/u/7466002) - Creator of the mod

# Gallery
![Quick Search](./resources/quicksearch.png)
![Quick Search](./resources/quicksearch.png)\
![Demon Info 1](./resources/demon-info-1.png)\
![Demon Info 2](./resources/demon-info-2.png)\
![Demon Info 3](./resources/demon-info-3.png)\
![Demon Info 4](./resources/demon-info-4.png)

# Difficulties
- Free Demon (Tier 1)
Expand Down
10 changes: 7 additions & 3 deletions about.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ A mod that adds demon difficulties in between existing ones.
# Credits
- [SufficientEbb](user:20865884) - Idea for the mod
- [HexCodes](user:16858187) - Additional ideas for the mod
- [Krintop](user:7242014) - Designer of the mod logo and textures
- [hiimjustin000](user:7466002) - Creator of the mod
- [Krintop](user:7242014) - Designer of the mod textures
- [hiimjasmine00](user:7466002) - Creator of the mod

# Gallery
![Quick Search](hiimjustin000.demons_in_between/quicksearch.png&scale:0.8333)
![Quick Search](hiimjustin000.demons_in_between/quicksearch.png?width=320)\
![Demon Info 1](hiimjustin000.demons_in_between/demon-info-1.png?width=320)\
![Demon Info 2](hiimjustin000.demons_in_between/demon-info-2.png?width=320)\
![Demon Info 3](hiimjustin000.demons_in_between/demon-info-3.png?width=320)\
![Demon Info 4](hiimjustin000.demons_in_between/demon-info-4.png?width=320)

# Difficulties
- Free Demon (Tier 1)
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.7 (2025-02-06)
- Redesigned the mod logo
- Updated the gallery to include the demon breakdown

## 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
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 9 additions & 13 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
{
"geode": "4.1.2",
"geode": "4.2.0",
"gd": {
"android": "2.2074",
"win": "2.2074",
"mac": "2.2074"
},
"version": "v1.4.6",
"version": "v1.4.7",
"id": "hiimjustin000.demons_in_between",
"name": "Demons In Between",
"developer": "hiimjustin000",
"developer": "hiimjasmine00",
"description": "A mod that adds demon difficulties in between existing ones.",
"dependencies": [
{
"id": "geode.node-ids",
"version": ">=v1.12.0",
"importance": "required"
}
],
"dependencies": {
"geode.node-ids": ">=v1.12.0"
},
"resources": {
"spritesheets": {
"DIB_IconSheet": [
Expand Down Expand Up @@ -65,15 +61,15 @@
"default": true
},
"gddp-integration-override": {
"name": "GDDP Integration Override",
"description": "Whether or not to override the GDDP Integration difficulties.",
"name": "GDDP Override",
"description": "Whether or not to override the GDDP difficulties.",
"type": "bool",
"default": false
}
},
"links": {
"community": "https://discord.gg/QVKmbvBXA7",
"source": "https://github.com/hiimjustin000/DemonsInBetween",
"source": "https://github.com/hiimjasmine00/DemonsInBetween",
"homepage": "https://www.hiimjustin000.com"
},
"tags": [
Expand Down
Binary file added resources/demon-info-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/demon-info-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/demon-info-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/demon-info-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 23 additions & 25 deletions src/DemonsInBetween.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#include "DemonsInBetween.hpp"
#include <Geode/binding/GameLevelManager.hpp>
#include <Geode/binding/GJDifficultySprite.hpp>
#include <Geode/binding/GJGameLevel.hpp>
#include <Geode/binding/GJSearchObject.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/utils/ranges.hpp>

using namespace geode::prelude;

LadderDemon& DemonsInBetween::demonForLevel(int levelID, bool main) {
static LadderDemon empty = { 0, 0.0, 0.0, 0 };
auto& gddl = main ? GDDL_MAIN : GDDL;
auto demon = std::find_if(gddl.begin(), gddl.end(), [levelID, main](auto const& d) {
auto demon = ranges::indexOf(gddl, [levelID, main](const LadderDemon& d) {
return d.id == levelID;
});
return demon == gddl.end() ? empty : *demon;
return !demon.has_value() ? empty : gddl[demon.value()];
}

CCSpriteFrame* DemonsInBetween::spriteFrameForDifficulty(int difficulty, GJDifficultyName name, GJFeatureState state) {
Expand Down Expand Up @@ -48,12 +54,12 @@ GJFeatureState DemonsInBetween::stateForLevel(GJGameLevel* level) {

void DemonsInBetween::loadDemonForLevel(
EventListener<web::WebTask>&& listenerRef, int levelID, bool main,
std::function<void(LadderDemon&)> const& callback, std::function<void()> const& preCallback
const std::function<void(LadderDemon&)>& callback
) {
if (LEVELS_LOADED.contains(levelID)) return;

auto&& listener = std::move(listenerRef);
listener.bind([callback, levelID, main, preCallback](web::WebTask::Event* e) {
listener.bind([callback, levelID, main](web::WebTask::Event* e) {
if (auto res = e->getValue()) {
LEVELS_LOADED.insert(levelID);

Expand All @@ -68,8 +74,7 @@ void DemonsInBetween::loadDemonForLevel(

auto& gddl = main ? GDDL_MAIN : GDDL;
gddl.push_back({ levelID, rating, enjoyment, difficulty });
preCallback();
queueInMainThread([callback, levelID, main] { callback(demonForLevel(levelID, main)); });
callback(demonForLevel(levelID, main));
}
});

Expand All @@ -78,7 +83,7 @@ void DemonsInBetween::loadDemonForLevel(

void DemonsInBetween::searchObjectForPage(
EventListener<web::WebTask>&& listenerRef, int page, bool refresh,
std::function<void(GJSearchObject*)> const& callback, std::function<void()> const& preCallback
const std::function<void(GJSearchObject*)>& callback
) {
auto glm = GameLevelManager::get();
auto searchCache = static_cast<CCDictionary*>(glm->getUserObject("search-cache"_spr));
Expand All @@ -91,15 +96,13 @@ void DemonsInBetween::searchObjectForPage(
if (!refresh && searchCache->objectForKey(searchKey)) {
SEARCH_SIZE = SEARCH_SIZES[DIFFICULTY];
MAX_PAGE = (SEARCH_SIZE - 1) / 10;
preCallback();
callback(static_cast<GJSearchObject*>(searchCache->objectForKey(searchKey)));
return;
return callback(static_cast<GJSearchObject*>(searchCache->objectForKey(searchKey)));
}

auto tierBound = TIER_BOUNDS[DIFFICULTY];

auto&& listener = std::move(listenerRef);
listener.bind([callback, page, preCallback](web::WebTask::Event* e) {
listener.bind([callback, page](web::WebTask::Event* e) {
if (auto res = e->getValue()) {
if (!res->ok()) return;

Expand All @@ -108,20 +111,15 @@ void DemonsInBetween::searchObjectForPage(
SEARCH_SIZES[DIFFICULTY] = SEARCH_SIZE;
MAX_PAGE = (SEARCH_SIZE - 1) / 10;

std::vector<std::string> levels;
if (json.contains("levels") && json["levels"].isArray()) {
for (auto const& level : json["levels"].asArray().unwrap()) {
if (level.contains("ID") && level["ID"].isNumber()) levels.push_back(std::to_string(level["ID"].asInt().unwrap()));
}
}

preCallback();
queueInMainThread([callback, levels, page] {
auto searchObject = GJSearchObject::create(SearchType::MapPackOnClick, string::join(levels, ","));
if (auto searchCache = static_cast<CCDictionary*>(GameLevelManager::get()->getUserObject("search-cache"_spr)))
searchCache->setObject(searchObject, fmt::format("{}_{}", DIFFICULTY, page));
callback(searchObject);
});
auto searchObject = GJSearchObject::create(SearchType::MapPackOnClick, json.contains("levels") && json["levels"].isArray() ? string::join(
ranges::map<std::vector<std::string>>(ranges::filter(json["levels"].asArray().unwrap(), [](const matjson::Value& level) {
return level.contains("ID") && level["ID"].isNumber();
}), [](const matjson::Value& level) {
return std::to_string(level["ID"].asInt().unwrap());
}), ",") : "");
if (auto searchCache = static_cast<CCDictionary*>(GameLevelManager::get()->getUserObject("search-cache"_spr)))
searchCache->setObject(searchObject, fmt::format("{}_{}", DIFFICULTY, page));
callback(searchObject);
}
});

Expand Down
7 changes: 5 additions & 2 deletions src/DemonsInBetween.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <cocos2d.h>
#include <Geode/Enums.hpp>
#include <Geode/GeneratedPredeclare.hpp>
#include <Geode/utils/web.hpp>

struct LadderDemon {
Expand Down Expand Up @@ -46,10 +49,10 @@ class DemonsInBetween {
static GJFeatureState stateForLevel(GJGameLevel*);
static void loadDemonForLevel(
geode::EventListener<geode::utils::web::WebTask>&&, int, bool,
std::function<void(LadderDemon&)> const&, std::function<void()> const&
const std::function<void(LadderDemon&)>&
);
static void searchObjectForPage(
geode::EventListener<geode::utils::web::WebTask>&&, int, bool,
std::function<void(GJSearchObject*)> const&, std::function<void()> const&
const std::function<void(GJSearchObject*)>&
);
};
29 changes: 15 additions & 14 deletions src/classes/DIBInfoPopup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "../DemonsInBetween.hpp"
#include "DIBInfoPopup.hpp"
#include "../DemonsInBetween.hpp"
#include <Geode/binding/ButtonSprite.hpp>
#include <Geode/binding/GameLevelManager.hpp>
#include <Geode/binding/GameStatsManager.hpp>
#include <Geode/binding/GameToolbox.hpp>
#include <Geode/binding/GJGameLevel.hpp>
#include <Geode/binding/LoadingCircle.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/utils/ranges.hpp>

using namespace geode::prelude;

Expand Down Expand Up @@ -67,11 +75,7 @@ bool DIBInfoPopup::setup() {
CACHED_DEMONS.push_back(demon);
}

retain();
queueInMainThread([this] {
setupDemonInfo();
release();
});
setupDemonInfo();
}
});

Expand All @@ -98,10 +102,10 @@ void DIBInfoPopup::setupDemonInfo() {
else classicCompleted++;

auto levelID = level->m_levelID.value();
auto demon = std::find_if(CACHED_DEMONS.begin(), CACHED_DEMONS.end(), [levelID](auto const& d) {
auto demon = ranges::find(CACHED_DEMONS, [levelID](const CachedLadderDemon& d) {
return d.id == levelID;
});
if (demon == CACHED_DEMONS.end() || demon->id == 0 || demon->difficulty == 0) {
if (!demon.has_value() || demon->id == 0 || demon->difficulty == 0) {
auto& completionCount = isPlatformer ? m_completionCountPlatformer : m_completionCountClassic;
auto difficulty = DemonsInBetween::difficultyForDemonDifficulty(level->m_demonDifficulty);
if (difficulty > 0) completionCount[difficulty - 1]++;
Expand Down Expand Up @@ -146,8 +150,8 @@ void DIBInfoPopup::setupDemonInfo() {

for (auto [dailyID, dailyLevel] : CCDictionaryExt<std::string, GJGameLevel*>(glm->m_dailyLevels)) {
if (dailyLevel->m_stars.value() < 10 || dailyLevel->m_normalPercent.value() < 100 || !gsm->hasCompletedLevel(dailyLevel)) continue;
if (dailyLevel->m_dailyID >= 200000) eventCompleted++;
else if (dailyLevel->m_dailyID >= 100000) weeklyCompleted++;
if (dailyLevel->m_dailyID > 200000) eventCompleted++;
else if (dailyLevel->m_dailyID > 100000) weeklyCompleted++;
}

for (auto [levelID, gauntletLevel] : CCDictionaryExt<std::string, GJGameLevel*>(glm->m_gauntletLevels)) {
Expand Down Expand Up @@ -237,10 +241,7 @@ void DIBInfoPopup::onClose(CCObject*) {
}

void DIBInfoPopup::keyDown(enumKeyCodes key) {
if (!m_loaded) {
Popup<>::keyDown(key);
return;
}
if (!m_loaded) return Popup<>::keyDown(key);

switch (key) {
case KEY_Left: case CONTROLLER_Left:
Expand Down
1 change: 1 addition & 0 deletions src/classes/DIBInfoPopup.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Geode/ui/Popup.hpp>
#include <Geode/utils/web.hpp>

struct CachedLadderDemon {
Expand Down
Loading

0 comments on commit 4e9d26c

Please sign in to comment.