From afce702eb19a629363f134b56abe256d3b5be3e3 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 9 Oct 2023 21:46:02 +0300 Subject: [PATCH] document everything in editor api --- api/include/MoreTabs.hpp | 59 +++++++++++++++++++++++++++++++++++++++- api/include/Utils.hpp | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/api/include/MoreTabs.hpp b/api/include/MoreTabs.hpp index f3a0cdb0..a14aff1a 100644 --- a/api/include/MoreTabs.hpp +++ b/api/include/MoreTabs.hpp @@ -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; @@ -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 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); }; } diff --git a/api/include/Utils.hpp b/api/include/Utils.hpp index 1436bccb..13a6c514 100644 --- a/api/include/Utils.hpp +++ b/api/include/Utils.hpp @@ -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 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 iterSelected(EditorUI* ui); + + /** + * Check whether a point is within a polygon + * @warning Currently unimplemented!! + */ EDITOR_API_EXPORT bool polygonIntersect(std::vector 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 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"); /**