EditorTab API

Alphalaneous

EditorTab API

An API mod for adding editor tabs easily.

To use, hook EditorUI::init and use alpha::editor_tabs::addTab() after calling original to add a tab. You must pass in an ID, the edit mode, a create node callback, and a create icon callback. There are two optional callbacks, one fot whent the tab is entered and exited, and one for when the tab is reloaded (row and column count changes).

When adding a tab, it must be in a specific mode, the three vanilla ones are BUILD, EDIT, and DELETE, but you can assign your own too, though you are responsible for handling any buttons to switch to said mode.

You can use any node as the return in the create node callback. This API also provides an easy way to create an EditButtonBar (alpha::editor_tabs::createEditButtonBar) which will be initialized with the correct size and positioning.

Tab IDs should be unique

class $modify(MyEditorUI, EditorUI) {

    bool init(LevelEditorLayer* editorLayer) {
        if (!EditorUI::init(editorLayer)) return false;

        alpha::editor_tabs::addTab("rawr-tab"_spr, alpha::editor_tabs::BUILD, 
        [] { // Create the tab
            std::vector> nodes;
            auto label = CCLabelBMFont::create("Rawr", "bigFont.fnt");
            nodes.push_back(label);

            return alpha::editor_tabs::createEditButtonBar(nodes);
        }, 
        [] { // create the tab icon
            return CCSprite::createWithSpriteFrameName("spike_01_001.png");
        }, 
        [] (bool state, auto tab) { // do something when the tab is entered and exited
            log::info("rawr-tab state: {}", state);
        }, 
        [] (int rows, int cols, auto tab) { // do something when the tab is reloaded
            log::info("rawr tab rows: {}, cols: {}", rows, cols);
        });

        return true;
    }
};

This API also provides ways to get information on what tab or mode you are on, as well as getting stuff from a tab ID itself.

// current mode (BUILD, EDIT, DELETE, or a custom string)
geode::Result getCurrentMode()

// current tab as the ID
geode::Result getCurrentTab()

// get a tab's index by ID
geode::Result getTabIndex(geode::ZStringView tabID)

// get a tab's mode by ID
geode::Result getTabMode(geode::ZStringView tabID)

// get a tab's node by ID
geode::Result> nodeForTab(geode::ZStringView tabID)

// get a tab's toggler by ID
geode::Result> togglerForTab(geode::ZStringView tabID)

You can also remove a tab if needed with just the tab ID.

void removeTab(geode::ZStringView tabID)

2.0.0-alpha.1

  • Rewrite the whole thing
  • Make the api more sane
  • Custom Modes
  • Rewrote a lot of EditButtonBar
    • Performance gains by removing invisible pages! (~40% FPS increase compared to vanilla on my PC)
  • Bug fixes
  • Pagination

1.1.0-beta.1

  • 2.2081 Support

1.0.19

  • If you have a bug report, please be normal, don't spam ping me, make a post or a bug report on the GitHub repo for the mod. Easy right? Apparently not.
  • Fixed a bug with tab visibility.

1.0.18

  • Fix a bug where other mods updating the buttons would reset main tab visibility

1.0.17

  • It comes with great sadness to admit that I have failed both my fans and myself after all this time. I was once a good person, I swear! But alas, the whole world dogpiled on me and "cancelled" me for my actions. I have done something so horrid that I cannot even ask for forgiveness anymore. I mispelled the word "judgement" in my last release. I understand if you no longer wish to support me and my mods after this, but we do have to rise up against this "cancel culture". I am not a bad person, it's everyone else that is wrong. I have corrected the mistake. I love my fans so much. By the way, you should donate to my Ko-Fi to help get me out of this rut from gambling all that charity money. I need to make $150,000 fast to make up for it. Please make sure to like and subscribe! Alpha Out!

1.0.16

  • In this release, I have fixed what would be considered a severe and complete lapse within my own judgement. I had failed to properly account for recent changes within the Geode index that allow for me to add a certain tag, the API tag. Due to my failure, I am forced by my own means to release this update to add the much needed API tag. I apologize for making such a severe mistake and I will ensure that I do better in the future. Thank you for listening and following along with my journey through this. I have started therapy and will strive to better myself.

1.0.15

  • iOS Jitless Support
  • New icon

1.0.14

  • iOS support

1.0.13

  • Fix a crash

1.0.12

  • Fix a bug with invisible tabs

1.0.11

  • Add tags

1.0.10

  • Resolve issue with page preserving
  • Performance improvements

1.0.9

  • Set EditButtonBars to -1 index

1.0.8

  • Android32 fix

1.0.7

  • Fix hook prio

1.0.6

  • 2.2074 support

1.0.5

  • Fix scaling

1.0.4

  • Fix EditButtonBar alignment bug

1.0.3

  • Fix Custom Objects Tab

1.0.2

  • Fix EditButtonBars

1.0.1

  • Fix BoomScrollLayer positioning

1.0.0

  • Adding tab icons is better if they are the same icon!
  • Out of beta and now officially feature complete

1.0.0-beta.3

  • Keybinds for switching between tabs works now:
  • Custom Nodes are no longer invisible when using keybinds
  • Edit and Delete mods now support keybinds for switching tabs

1.0.0-beta.2

  • Fix a bug relating to Pages API

1.0.0-beta.1

  • Fix tab positioning again
  • Fix non EditButtonBars crashing on pause
  • Fix missing menu when there is no node IDs, causing overlapping buttons on the build tab
  • Fix non EditButtonBars not scaling when BetterEdit scaling is used
  • Non EditButtonBars should now properly change visibility always

1.0.0-alpha.21

  • Fix tab positioning again

1.0.0-alpha.20

  • Fix tab positioning again

1.0.0-alpha.19

  • Fix tab positioning again

1.0.0-alpha.18

  • Fix Positioning of arrows until BetterEdit fixes it

1.0.0-alpha.17

  • Fix pausing showing first edit tab (hopefully, can't reproduce myself but has been reported)

1.0.0-alpha.16

  • Fix tab height again (darn hook prio)

1.0.0-alpha.15

  • Fix navigation buttons being invisible

1.0.0-alpha.14

  • Fix navigation button positions

1.0.0-alpha.13

  • Fix tab menu Y position

1.0.0-alpha.12

  • Unstupid something

1.0.0-alpha.11

  • Introduce non-registry based tab adding

1.0.0-alpha.10

  • Fix positioning if Node IDs is disabled (why)
  • Fix toggleMode hook prio

1.0.0-alpha.9

  • Preemptively fix positioning issues for potential BetterEdit changes

1.0.0-alpha.8

  • Fix another BetterEdit scaling bug
  • Fix misalignment when BetterEdit isn't installed
  • Fix vanilla bug where build tabs aren't centered :3

1.0.0-alpha.7

  • You'd have never guessed that a memory leak slipped through, but it did, and has been fixed!

1.0.0-alpha.6

  • Fixed a bug where BetterEdit recenters all EditButtonBars, solution: do the same thing when I need to

1.0.0-alpha.5

  • Fixed a bug where params are different on nightly geode, so the tab BG was wrong

1.0.0-alpha.4

  • Fix a crash where BetterEdit expects an EditButtonBar to have children

1.0.0-alpha.3

  • Add ability to add tabs to Edit and Delete categories, no more EditButtonBar requirement, just add and modify a node instead if you want :P

1.0.0-alpha.2

  • Unstupid a piece of code

1.0.0-alpha.1

  • 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.