From e5ab6963a2e4cc2538bc8c438874142208217727 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:45:31 +0200 Subject: [PATCH] trigger indicator updates --- mod.json | 18 ++++++ src/utils/Editor.cpp | 31 ++++++++++ src/utils/Editor.hpp | 4 ++ src/utils/ObjectIDs.hpp | 128 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 src/utils/ObjectIDs.hpp diff --git a/mod.json b/mod.json index 9b7e0cf..c5b548a 100644 --- a/mod.json +++ b/mod.json @@ -204,6 +204,24 @@ "name": "Supporter Settings", "description": "These settings are for features only available to Supporters. Support BetterEdit to get access!" }, + "trigger-indicator-colors": { + "type": "string", + "one-of": ["None", "Selected Only", "All"], + "default": "Selected Only", + "name": "Dynamic Trigger Indicator Colors", + "description": "Control whether Trigger Indicators should be colored based on the trigger, or if they should just be white" + }, + "trigger-indicators-color-objects": { + "type": "bool", + "default": false, + "name": "Trigger Indicator Color Selection", + "description": "Control whether Trigger Indicators should also color the target objects, or only point to them via the line" + }, + "wip-section": { + "type": "title", + "name": "WIP Features", + "description": "These settings are for features that are currently Work-In-Progress. This means that these features may be unstable and unusable, and are only included for testing purposes. Developer Mode is required to enable them." + }, "better-select": { "type": "bool", "default": false, diff --git a/src/utils/Editor.cpp b/src/utils/Editor.cpp index 9852c08..64f945e 100644 --- a/src/utils/Editor.cpp +++ b/src/utils/Editor.cpp @@ -2,7 +2,9 @@ #include #include #include +#include #include +#include #include #include @@ -235,3 +237,32 @@ ListenerResult UIShowFilter::handle(std::function fn, UIShowEvent* ev) } return ListenerResult::Propagate; } + +class $modify(TintLayer, LevelEditorLayer) { + struct Fields { + std::unordered_map, ccColor3B> tinted {}; + }; + + $override + void updateVisibility(float dt) { + LevelEditorLayer::updateVisibility(dt); + for (auto [obj, color] : m_fields->tinted) { + obj->setObjectColor(color); + // if (m_detailSprite) { + // m_detailSprite->setColor(color); + // m_detailSprite->setChildColor(color); + // } + } + } +}; + +void be::tintObject(GameObject* obj, std::optional const& color) { + auto lel = static_cast(LevelEditorLayer::get()); + if (color) { + lel->m_fields->tinted.insert({ obj, *color }); + obj->setObjectColor(*color); + } + else { + lel->m_fields->tinted.erase(obj); + } +} diff --git a/src/utils/Editor.hpp b/src/utils/Editor.hpp index 86f2d16..1c3f8a7 100644 --- a/src/utils/Editor.hpp +++ b/src/utils/Editor.hpp @@ -26,6 +26,10 @@ namespace be { * Check if the given editor is view-only */ bool isViewOnlyEditor(LevelEditorLayer* lel); + /** + * Color an object like selecting (without changing its actual color) + */ + void tintObject(GameObject* obj, std::optional const& color); } //// More EditCommand options diff --git a/src/utils/ObjectIDs.hpp b/src/utils/ObjectIDs.hpp new file mode 100644 index 0000000..96c98de --- /dev/null +++ b/src/utils/ObjectIDs.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include + +using namespace geode::prelude; + +class ObjectID { +private: + int m_id; + +public: + ObjectID(int id) : m_id(id) {} + + ccColor3B getTriggerColor() const { + switch (m_id) { + case MOVE_TRIGGER: case AREA_MOVE_TRIGGER: case EDIT_AREA_MOVE_TRIGGER: + return ccc3(255, 0, 255); + + case ROTATE_TRIGGER: case AREA_ROTATE_TRIGGER: case EDIT_AREA_ROTATE_TRIGGER: + return ccc3(127, 127, 255); + + case SCALE_TRIGGER: case AREA_SCALE_TRIGGER: case EDIT_AREA_SCALE_TRIGGER: + return ccc3(63, 191, 255); + + case PULSE_TRIGGER: case AREA_TINT_TRIGGER: case EDIT_AREA_TINT_TRIGGER: + return ccc3(255, 255, 0); + + case ALPHA_TRIGGER: case AREA_FADE_TRIGGER: case EDIT_AREA_FADE_TRIGGER: + return ccc3(0, 255, 255); + + case TOGGLE_TRIGGER: return ccc3(255, 63, 63); + case SPAWN_TRIGGER: return ccc3(35, 204, 127); + case FOLLOW_TRIGGER: return ccc3(255, 127, 127); + + case ADVANCED_FOLLOW_TRIGGER: case EDIT_ADVANCED_FOLLOW_TRIGGER: case RE_TARGET_ADVANCED_FOLLOW_TRIGGER: + return ccc3(204, 255, 199); + + case ANIMATE_TRIGGER: return ccc3(255, 183, 0); + case FOLLOW_PLAYER_Y_TRIGGER: return ccc3(255, 255, 127); + case CHANGE_BG_TRIGGER: return ccc3(127, 255, 255); + case CHANGE_GROUND_TRIGGER: return ccc3(255, 255, 127); + case CHANGE_MIDGROUND_TRIGGER: return ccc3(255, 127, 255); + case TOUCH_TRIGGER: return ccc3(0, 137, 178); + case COUNT_TRIGGER: return ccc3(255, 183, 252); + case INSTANT_COUNT_TRIGGER: return ccc3(255, 135, 255); + case PICKUP_TRIGGER: return ccc3(255, 109, 0); + case RANDOM_TRIGGER: return ccc3(63, 127, 255); + case STOP_TRIGGER: return ccc3(163, 0, 86); + + case ADVANCED_RANDOM_TRIGGER: case SEQUENCE_TRIGGER: + return ccc3(165, 94, 255); + + case SPAWN_PARTICLE_TRIGGER: return ccc3(150, 150, 150); + case RESET_TRIGGER: return ccc3(255, 100, 0); + case CAMERA_ZOOM_TRIGGER: return ccc3(127, 127, 255); + case CAMERA_STATIC_TRIGGER: return ccc3(255, 127, 127); + case CAMERA_ROTATE_TRIGGER: return ccc3(255, 245, 0); + case CAMERA_EDGE_TRIGGER: return ccc3(0, 199, 255); + case CAMERA_MODE_TRIGGER: return ccc3(191, 255, 0); + case COLLISION_TRIGGER: return ccc3(83, 66, 250); + case TIME_WARP_TRIGGER: return ccc3(153, 127, 153); + case BG_SPEED_TRIGGER: return ccc3(127, 255, 255); + case ON_DEATH_TRIGGER: return ccc3(204, 101, 101); + case PLAYER_CONTROL_TRIGGER: return ccc3(101, 255, 255); + + case MIDGROUND_SETUP_TRIGGER: case MIDGROUND_SPEED_TRIGGER: + return ccc3(255, 127, 255); + + case CAMERA_OFFSET_TRIGGER: case CAMERA_GP_OFFSET_TRIGGER: + return ccc3(127, 255, 127); + + default: + return ccWHITE; + } + } + + static constexpr int MOVE_TRIGGER = 901; + static constexpr int STOP_TRIGGER = 1616; + static constexpr int PULSE_TRIGGER = 1006; + static constexpr int ALPHA_TRIGGER = 1007; + static constexpr int TOGGLE_TRIGGER = 1049; + static constexpr int SPAWN_TRIGGER = 1268; + static constexpr int ROTATE_TRIGGER = 1346; + static constexpr int SCALE_TRIGGER = 2067; + static constexpr int FOLLOW_TRIGGER = 1347; + static constexpr int ANIMATE_TRIGGER = 1585; + static constexpr int FOLLOW_PLAYER_Y_TRIGGER = 1814; + static constexpr int ADVANCED_FOLLOW_TRIGGER = 3016; + static constexpr int EDIT_ADVANCED_FOLLOW_TRIGGER = 3660; + static constexpr int RE_TARGET_ADVANCED_FOLLOW_TRIGGER = 3661; + static constexpr int AREA_MOVE_TRIGGER = 3006; + static constexpr int AREA_ROTATE_TRIGGER = 3007; + static constexpr int AREA_SCALE_TRIGGER = 3008; + static constexpr int AREA_FADE_TRIGGER = 3009; + static constexpr int AREA_TINT_TRIGGER = 3010; + static constexpr int EDIT_AREA_MOVE_TRIGGER = 3011; + static constexpr int EDIT_AREA_ROTATE_TRIGGER = 3012; + static constexpr int EDIT_AREA_SCALE_TRIGGER = 3013; + static constexpr int EDIT_AREA_FADE_TRIGGER = 3014; + static constexpr int EDIT_AREA_TINT_TRIGGER = 3015; + static constexpr int CHANGE_BG_TRIGGER = 3029; + static constexpr int CHANGE_GROUND_TRIGGER = 3030; + static constexpr int CHANGE_MIDGROUND_TRIGGER = 3031; + static constexpr int TOUCH_TRIGGER = 1595; + static constexpr int COUNT_TRIGGER = 1611; + static constexpr int INSTANT_COUNT_TRIGGER = 1811; + static constexpr int PICKUP_TRIGGER = 1817; + static constexpr int RANDOM_TRIGGER = 1912; + static constexpr int ADVANCED_RANDOM_TRIGGER = 2068; + static constexpr int SEQUENCE_TRIGGER = 3607; + static constexpr int SPAWN_PARTICLE_TRIGGER = 3608; + static constexpr int RESET_TRIGGER = 3618; + static constexpr int CAMERA_ZOOM_TRIGGER = 1913; + static constexpr int CAMERA_STATIC_TRIGGER = 1914; + static constexpr int CAMERA_OFFSET_TRIGGER = 1916; + static constexpr int CAMERA_GP_OFFSET_TRIGGER = 2901; + static constexpr int CAMERA_ROTATE_TRIGGER = 2015; + static constexpr int CAMERA_EDGE_TRIGGER = 2062; + static constexpr int CAMERA_MODE_TRIGGER = 2925; + static constexpr int COLLISION_TRIGGER = 1815; + static constexpr int TIME_WARP_TRIGGER = 1935; + static constexpr int MIDGROUND_SETUP_TRIGGER = 2999; + static constexpr int BG_SPEED_TRIGGER = 3606; + static constexpr int MIDGROUND_SPEED_TRIGGER = 3612; + static constexpr int INSTANT_COLLISION_TRIGGER = 3609; + static constexpr int ON_DEATH_TRIGGER = 1812; + static constexpr int PLAYER_CONTROL_TRIGGER = 1932; +};