From e6510bdf5f66371c916cd26a9932fa59541e83d8 Mon Sep 17 00:00:00 2001 From: Catto_ <57293929+CattoDev@users.noreply.github.com> Date: Fri, 13 Oct 2023 22:29:00 +0200 Subject: [PATCH] LayerManager progress 4 (ig) Literally just waiting for mac binding to be accepted --- .../LayerManager/EditorLayerInput.cpp | 77 ++++++++++++++++++- src/features/LayerManager/LayerManager.cpp | 67 ---------------- 2 files changed, 76 insertions(+), 68 deletions(-) diff --git a/src/features/LayerManager/EditorLayerInput.cpp b/src/features/LayerManager/EditorLayerInput.cpp index 245defb7..b08e7d90 100644 --- a/src/features/LayerManager/EditorLayerInput.cpp +++ b/src/features/LayerManager/EditorLayerInput.cpp @@ -1,6 +1,9 @@ #include "EditorLayerInput.hpp" #include "LayerManager.hpp" +#include +#include + void updateEditorLayerButtons(EditorUI* editorUI) { if(!editorUI) return; @@ -87,4 +90,76 @@ void EUITextDelegate::textChanged(CCTextInputNode* input) { updateEditorLayerButtons(editor->m_editorUI); } -} \ No newline at end of file +} + +/* + HOOKS +*/ +void filterObjects(CCArray* objs) { + size_t i = 0; + size_t maxCount = objs->count(); + + while(i < maxCount) { + auto obj = as(objs->objectAtIndex(i)); + + auto layer = LayerManager::get()->getLayer(obj->m_editorLayer); + if(layer && layer->m_locked) { + objs->removeObjectAtIndex(i, false); + + if(obj->m_isSelected) { + obj->deselectObject(); + } + + maxCount--; + } + else { + i++; + } + } +} + +class $modify(LMEditorLayer, LevelEditorLayer) { + GameObject* objectAtPosition(CCPoint position) { + auto obj = LevelEditorLayer::objectAtPosition(position); + + if(obj != nullptr) { + if(auto layer = LayerManager::get()->getLayer(obj->m_editorLayer)) { + if(layer->m_locked) { + obj = nullptr; + } + } + } + + return obj; + } + + CCArray* objectsAtPosition(CCPoint position) { + auto objs = LevelEditorLayer::objectsAtPosition(position); + + filterObjects(objs); + + return objs; + } + + CCArray* objectsInRect(CCRect rect, bool ignoreLayer) { + auto objs = LevelEditorLayer::objectsInRect(rect, ignoreLayer); + + filterObjects(objs); + + return objs; + } +}; + +class $modify(EditorUI) { + void processSelectObjects(CCArray* objs) { + filterObjects(objs); + + return EditorUI::processSelectObjects(objs); + } + + void selectObjects(CCArray* objs, bool ignoreFilters) { + EditorUI::selectObjects(objs, ignoreFilters); + + filterObjects(m_selectedObjects); + } +}; \ No newline at end of file diff --git a/src/features/LayerManager/LayerManager.cpp b/src/features/LayerManager/LayerManager.cpp index 2c9eca7f..994801eb 100644 --- a/src/features/LayerManager/LayerManager.cpp +++ b/src/features/LayerManager/LayerManager.cpp @@ -2,8 +2,6 @@ #include #include -#include -#include LayerManager* g_manager = nullptr; @@ -151,71 +149,6 @@ class $modify(LMGameObject, GameObject) { } }; -void filterObjects(CCArray* objs) { - size_t i = 0; - size_t maxCount = objs->count(); - - while(i < maxCount) { - auto obj = as(objs->objectAtIndex(i)); - - auto layer = LayerManager::get()->getLayer(obj->m_editorLayer); - if(layer && layer->m_locked) { - objs->removeObjectAtIndex(i, false); - obj->deselectObject(); - maxCount--; - } - else { - i++; - } - } -} - -class $modify(LMEditorLayer, LevelEditorLayer) { - GameObject* objectAtPosition(CCPoint position) { - auto obj = LevelEditorLayer::objectAtPosition(position); - - if(obj != nullptr) { - if(auto layer = LayerManager::get()->getLayer(obj->m_editorLayer)) { - if(layer->m_locked) { - obj = nullptr; - } - } - } - - return obj; - } - - CCArray* objectsAtPosition(CCPoint position) { - auto objs = LevelEditorLayer::objectsAtPosition(position); - - filterObjects(objs); - - return objs; - } - - CCArray* objectsInRect(CCRect rect, bool ignoreLayer) { - auto objs = LevelEditorLayer::objectsInRect(rect, ignoreLayer); - - filterObjects(objs); - - return objs; - } -}; - -class $modify(EditorUI) { - void processSelectObjects(CCArray* objs) { - filterObjects(objs); - - return EditorUI::processSelectObjects(objs); - } - - void selectObjects(CCArray* objs, bool ignoreFilters) { - EditorUI::selectObjects(objs, ignoreFilters); - - filterObjects(m_selectedObjects); - } -}; - // needa put this here cuz of LMGJGameLevel LayerManager::Level * LayerManager::getLevel() { auto lvl = as(LevelEditorLayer::get()->m_level);