Skip to content

Commit

Permalink
use garage stats menu mod for showing stat in garage
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowCat98 committed Sep 22, 2024
1 parent 6753f38 commit 99f1763
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"id": "geode.node-ids",
"importance": "required",
"version": ">=1.14.0"
},
{
"id": "capeling.garage-stats-menu",
"importance": "required",
"version": ">=1.0.1"
}
],
"settings": {
Expand Down
Binary file removed resources/empty_spr.png
Binary file not shown.
19 changes: 18 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <Geode/modify/GameStatsManager.hpp>
#include <Geode/modify/EndLevelLayer.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>
#include <Geode/modify/GJGarageLayer.hpp>
#include <capeling.garage-stats-menu/include/StatsDisplayAPI.h>

using namespace geode::prelude;
using namespace keybinds;
Expand All @@ -32,6 +34,21 @@ using namespace keybinds;
#endif
}

class $modify(GJGarageLayerHook, GJGarageLayer) {
bool init() {
if (!GJGarageLayer::init()) return false;
auto statMenu = this->getChildByID("capeling.garage-stats-menu/stats-menu");

auto totemItem = StatsDisplayAPI::getNewItem("totem-count"_spr, CCSprite::create("totem.png"_spr), Mod::get()->getSavedValue<int64_t>("totem-count"));

if (statMenu) {
statMenu->addChild(totemItem);
statMenu->updateLayout();
}
return true;
}
};

class $modify(GameStatsManagerHook, GameStatsManager) {
struct Fields {
int m_starsToShow;
Expand Down Expand Up @@ -76,7 +93,7 @@ struct Fields {

this->template addEventListener<InvokeBindFilter>([=](InvokeBindEvent* event) {
if (event->isDown()) {
if (hasSufficientTotems() || m_fields->m_canActivateTotem) {
if (hasSufficientTotems() && m_fields->m_canActivateTotem) {
Mod::get()->setSavedValue<int64_t>("totem-count", Mod::get()->getSavedValue<int64_t>("totem-count") - 1);
m_fields->m_shouldNoclip = true;
m_fields->m_shouldShowIndicator = true;
Expand Down

0 comments on commit 99f1763

Please sign in to comment.