GithubHelp home page GithubHelp logo

garage-stats-menu's Introduction

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 <capeling.garage-stats-menu/include/StatsDisplayAPI.h>

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!)

garage-stats-menu's People

Contributors

capeling avatar

Stargazers

Flainn avatar Rod avatar

Watchers

 avatar

garage-stats-menu's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.