Skip to content

Commit

Permalink
document everything in editor api
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Oct 9, 2023
1 parent c4ecd2d commit afce702
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
59 changes: 58 additions & 1 deletion api/include/MoreTabs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ using namespace geode::prelude;
struct MoreTabsUI;

namespace editor_api {
/**
* Class for adding more tabs to the editor, including the edit and delete menus
* @class MoreTabs
*/
class EDITOR_API_EXPORT MoreTabs : public CCNode {
protected:
int m_selectedEditTab;
Expand All @@ -23,21 +27,74 @@ namespace editor_api {

CCMenuItemToggler* createTab(const char* icon, CCObject* target, SEL_MenuHandler selector);

/**
* Create
*/
static MoreTabs* create(EditorUI* ui);

friend struct ::MoreTabsUI;

public:
/**
* Add a new create tab
* @param icon The sprite frame name of the icon of the tab
* @param content The content of the tab
* @returns The tag of the created tab
*/
int addCreateTab(const char* icon, EditButtonBar* content);

/**
* Add a new create tab
* @param icon The sprite frame name of the icon of the tab
* @param buttons The list of buttons to add to the EditButtonBar
* @returns The tag of the created tab
*/
int addCreateTab(const char* icon, CCArray* buttons);

/**
* Add a new create tab
* @param icon The sprite frame name of the icon of the tab
* @param objIDs The list of objects to add to the tab
* @returns The tag of the created tab
*/
int addCreateTab(const char* icon, std::vector<int> const& objIDs);

/**
* Add a new edit tab
* @param icon The sprite frame name of the icon of the tab
* @param content The contents of the tab
* @returns The tag of the created tab
*/
int addEditTab(const char* icon, CCNode* content);

/**
* Get a create tab based on its tag
* @param tag The tag of the tab
* @returns The EditButtonBar with the tag, or nullptr
*/
EditButtonBar* getCreateTab(int tag) const;

/**
* Go to a specific edit tab based on its tag
*/
void switchEditTab(int tag);

/**
* Cycle tab selection to the right
*/
void nextTab();

/**
* Cycle tab selection to the left
*/
void prevTab();

static MoreTabs* create(EditorUI* ui);
/**
* Get the MoreTabs controller for a specific Editor UI
* @param ui The editor
* @param create Whether to create the controller if it hasn't been created yet
* @returns The MoreTabs controller, or nullptr if one doesn't exist
*/
static MoreTabs* get(EditorUI* ui, bool create = true);
};
}
53 changes: 53 additions & 0 deletions api/include/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,67 @@
using namespace geode::prelude;

namespace editor_api {
/**
* Convert a ZLayer into a readable string (like T1 or B3)
* @param z The ZLayer value to convert (as an instance of the ZLayer enum)
* @returns The Z layer as a string
*/
EDITOR_API_EXPORT std::string zLayerToString(ZLayer z);

/**
* Helper function to iterate objects for GD
* @param target The first object to add to the iteration; may be nullptr
* @param targets The array of objects to iterate; may be nullptr
* @returns CCArrayExt iterator for the passed objects
* @note If neither are nullptr, target is first in the iteration list
*/
EDITOR_API_EXPORT CCArrayExt<GameObject> iterTargets(GameObject* target, CCArray* targets);

/**
* Helper function to iterate selected objects
* @param ui Editor UI
* @returns CCArrayExt iterator for selected objects
*/
EDITOR_API_EXPORT CCArrayExt<GameObject> iterSelected(EditorUI* ui);

/**
* Check whether a point is within a polygon
* @warning Currently unimplemented!!
*/
EDITOR_API_EXPORT bool polygonIntersect(std::vector<CCPoint> const& a, CCPoint const& b);

/**
* Smartly expand selection to a whole structure based on an object in it
* @param ui The editor
* @param from The object to expand the selection from
* @returns List of objects to select for the structure
* @note Actually doesn't select the structure, only returns the objects in the structure
*/
EDITOR_API_EXPORT CCArray* selectStructure(EditorUI* ui, GameObject* from);

/**
* Smartly expand selection to a whole structure based on objects in it
* @param ui The editor
* @param from The objects to expand the selection from
* @returns List of objects to select for the structure
* @note Actually doesn't select the structure, only returns the objects in the structure
*/
EDITOR_API_EXPORT CCArray* selectStructure(EditorUI* ui, CCArray* from);

/**
* Color an object a different color
* @param obj The object to tint
* @param color The color to tint the object to, or nullopt to reset to default
* @warning Currently unimplemented!!
*/
EDITOR_API_EXPORT void tintObject(GameObject* obj, std::optional<ccColor3B> const& color);

/**
* Helper to create a square button that fits in the editor's UI
* @param top The top sprite's frame name
* @param bg The background sprite
* @returns The created sprite
*/
EDITOR_API_EXPORT ButtonSprite* createEditorButtonSprite(const char* top, const char* bg = "GJ_button_01.png");

/**
Expand Down

0 comments on commit afce702

Please sign in to comment.