Jouca / BadgesAPI

An API for Geometry Dash badges, used for user profiles
GNU General Public License v3.0
3 stars 0 forks source link

Badges API

An API mod to integrate badges in a special menu & optimizing UI for ProfilePage & CommentCell

Mod Example

This mod use NodeIDs as a dependency to make tags working well, you may use it if you want to use this API.

Using as a dependency

Add the mod to your mod.json:

{
    "dependencies": [
        {
            "id": "jouca.badgesapi",
            "version": ">=v1.1.0",
            "importance": "required"
        }
    ]
}

All the hooks on this API are in very low priority states, you should make sure that your mod doesn't go too much bellow the priorities that Badges API uses for correctly detecting your badges.

How to use this mod?

Here's an example of how to put your badge inside:

#include <Geode/Geode.hpp>
#include <Geode/modify/ProfilePage.hpp>
#include <Geode/modify/CommentCell.hpp>

using namespace geode::prelude;

class $modify(ProfilePage) {
    void loadPageFromUserInfo(GJUserScore* a2) {
        ProfilePage::loadPageFromUserInfo(a2);
        auto layer = m_mainLayer;

        CCMenu* username_menu = typeinfo_cast<CCMenu*>(layer->getChildByIDRecursive("username-menu"));

        // your code for create your badge

        yourBadge->setID("mycustombadge-badge")
        username_menu->addChild(yourBadge);
    }
};

class $modify(CommentCell) {
    void loadFromComment(GJComment* p0) {
        CommentCell::loadFromComment(p0);
        auto layer = m_mainLayer;

        CCMenu* username_menu = typeinfo_cast<CCMenu*>(layer->getChildByIDRecursive("username-menu"));

        // your code for create your badge

        yourBadge->setID("mycustombadge-badge")
        username_menu->addChild(yourBadge);
    }
};

If you add your badge after the Layer has loaded (example with HTTP requests), it will still be added!

Credits

License

This project is created by Jouca under the GNU General Public License v3.0, read more by clicking on the highlighted name.