Stats Display API

capeling, OmgRod

Stats Display API

Allows mods to easily add custom stats into the icon kit

Developer usage

Setting up Stats Display API for mod usage

Make sure to declare Stats Display API as a dependency in your 'mod.json'

"dependencies": [
	{
		"id": "capeling.garage-stats-menu",
		"version": ">=v1.0.1",
		"importance": "required"
	}
]

Then include the API in your source file

#include

Usage

StatsDisplayAPI::getNewItem Has 4 things you need to pass through it

  • The ID of the item (always use _spr!)
  • The CCNode used for the icon
  • How much of the item you have
  • The scale of the icon

This will return a CCNode which you should add to stats menu!

Example

To add a displayed stat you simply need to create a item through the API and then add it to the menu

This code adds your current fire shards to the display

class $modify(GJGarageLayer) {
	bool init() {
		if (!GJGarageLayer::init())
			return false;

		auto statMenu = this->getChildByID("capeling.garage-stats-menu/stats-menu");

		auto myStatItem = StatsDisplayAPI::getNewItem("fire-shards"_spr, CCSprite::createWithSpriteFrameName("fireShardSmall_001.png"), GameStatsManager::sharedState()->getStat("16"), 0.8f);

		if (statMenu) {
			statMenu->addChild(myStatItem);
			statMenu->updateLayout();
		}

		return true;
	}
};

If in any case the stats menu does not exist, you should check to make sure that it is not nullptr before adding your item

auto statMenu = this->getChildByID("capeling.garage-stats-menu/stats-menu");
if (statMenu) {
	statMenu->addChild(myStatItem);
	statMenu->updateLayout();
}

(Always remember to update the layout!)

v1.3.1-beta.1

  • Add API tag

v1.3.0

v1.2.1

  • Bugfix: Move stats up if there are no page buttons (by NyteLyte)

v1.2.0

  • Update to Geode v4.6.1
  • Add API tag

v1.1.0

  • Added Capeling back as a developer
  • Auto-scale and resize stats menu

v1.0.4

  • Changed mod ID

v1.0.3

  • Ported to iOS
  • Bugfix for issue in which the stats menu goes under the corner if too many stats are added

v1.0.2

  • 2.207 support

v1.0.1

  • Fix for other platforms (Hopefully)

v1.0.0

  • Initial release

Original Site made by HJfod. Geode 2 parody-ish by MeFinity.

Geode-SDK is the property of the Geode Team.


This website (Geode 2, Codename Malachite) is not affiliated with the Geode Team in any way shape or form.