From 1da99ca6c1d71c046d5368e4aef84c6f3d46bf142767ff6ca55dc33d2e70a51f Mon Sep 17 00:00:00 2001 From: Mexpert_PRO Date: Thu, 26 Mar 2026 18:55:30 +0100 Subject: [PATCH] small fixes --- .../src/BehaviourScripts/OrdererSpriteSet.cpp | 19 +++++++++++-- TSE_Editor/src/EditorSubsystem.cpp | 8 +++++- TSE_Editor/src/UI/ElementDrawer.cpp | 28 +++++++++++++++++++ TSE_Editor/src/UI/ElementDrawer.hpp | 2 ++ 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/TSE_Core/src/BehaviourScripts/OrdererSpriteSet.cpp b/TSE_Core/src/BehaviourScripts/OrdererSpriteSet.cpp index f588688..d2b6c17 100644 --- a/TSE_Core/src/BehaviourScripts/OrdererSpriteSet.cpp +++ b/TSE_Core/src/BehaviourScripts/OrdererSpriteSet.cpp @@ -1,6 +1,7 @@ #include "OrdererSpriteSet.hpp" #include #include +#include "Debug.hpp" TSE::OrdererSpriteSetChunk::OrdererSpriteSetChunk(int _chunksize, const Vector2 &_pos, SortingOrder _order) { @@ -144,6 +145,8 @@ void TSE::OrdererSpriteSet::SetSprite(Vector2 p, Vector2 Spriteindex, float heig { Vector2 chunkInnerPos = LocalToChunkPos(p); Vector2 chunkIndex = p - chunkInnerPos; + // Vector2 p2 = Vector2((int)p.x % chunkSize, (int)p.y % chunkSize); + // Vector2 chunkIndex = p - p2; if(!chunks.contains(chunkIndex)) { dirty = true; @@ -175,7 +178,9 @@ const std::vector *TSE::OrdererSpriteSet::GetChunkPositionsInOrder case TopLeft: std::sort(orderedChunks.begin(), orderedChunks.end(), [](const Vector2& a, const Vector2& b) { - return std::tie(a.y, a.x) > std::tie(b.y, b.x); + if (a.y != b.y) + return a.y > b.y; + return a.x < b.x; }); break; case TopRight: @@ -189,7 +194,9 @@ const std::vector *TSE::OrdererSpriteSet::GetChunkPositionsInOrder case BottomLeft: std::sort(orderedChunks.begin(), orderedChunks.end(), [](const Vector2& a, const Vector2& b) { - return std::tie(a.y, a.x) < std::tie(b.y, b.x); + if (a.y != b.y) + return a.y < b.y; + return a.x < b.x; }); break; case BottomRight: @@ -203,6 +210,14 @@ const std::vector *TSE::OrdererSpriteSet::GetChunkPositionsInOrder } dirty = false; + string poses = "["; + for(auto pos : orderedChunks) + { + poses += pos.ToString() + ","; + } + poses.erase(poses.end() - 1); + poses += "]"; + TSE_LOG("orderedPositions: " + poses); } return &orderedChunks; } diff --git a/TSE_Editor/src/EditorSubsystem.cpp b/TSE_Editor/src/EditorSubsystem.cpp index 6c2a887..e607861 100644 --- a/TSE_Editor/src/EditorSubsystem.cpp +++ b/TSE_Editor/src/EditorSubsystem.cpp @@ -3,6 +3,9 @@ #include "BehaviourScriptRegistry.hpp" #include "BehaviourScripts/AudioListener.hpp" #include "BehaviourScripts/AudioSource.hpp" +#include "BehaviourScripts/TileMap.hpp" +#include "BehaviourScripts/OrdererSpriteSet.hpp" +#include "BehaviourScripts/PhysicsObject.hpp" #include "BehaviourScripts/basicEditorCamera.hpp" TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("") @@ -26,6 +29,9 @@ TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("") BehaviourScriptRegistry::RegisterBehaviourScript("Camera", []() -> BehaviourScript* {return new Camera();}); BehaviourScriptRegistry::RegisterBehaviourScript("Audio Listener", []() -> BehaviourScript* {return new AudioListener();}); BehaviourScriptRegistry::RegisterBehaviourScript("Audio Source", []() -> BehaviourScript* {return new AudioSource();}); + BehaviourScriptRegistry::RegisterBehaviourScript("Tile Map", []() -> BehaviourScript* {return new TileMap();}); + BehaviourScriptRegistry::RegisterBehaviourScript("Orderer Sprite Set", []() -> BehaviourScript* {return new OrdererSpriteSet();}); + BehaviourScriptRegistry::RegisterBehaviourScript("Physics Object", []() -> BehaviourScript* { return new PhysicsObject(BodyType::Dynamic, ColliderShape::Box, 1.0f, 0.3f, Vector3(1, 1, 0)); }); #pragma region camerastuff @@ -43,4 +49,4 @@ TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("") editorLayer.SetNonVisual(true); #pragma endregion -} \ No newline at end of file +} diff --git a/TSE_Editor/src/UI/ElementDrawer.cpp b/TSE_Editor/src/UI/ElementDrawer.cpp index 2d3402d..e1d5ade 100644 --- a/TSE_Editor/src/UI/ElementDrawer.cpp +++ b/TSE_Editor/src/UI/ElementDrawer.cpp @@ -208,6 +208,10 @@ namespace TSE::EDITOR { Draw((TileMap*)element, debug); } + else if (name == "Orderer Sprite Set") + { + Draw((OrdererSpriteSet*)element, debug); + } else { element->CustomDraw(debug); @@ -915,6 +919,30 @@ namespace TSE::EDITOR ImGui::TextDisabled(("Chunk Count: " + std::to_string(element->GetChunkCount())).c_str()); } } + void ElementDrawer::Draw(OrdererSpriteSet *element, const bool &debug) + { + int orderIndex = static_cast(element->order); + const char* orderItems[] = { "TopRight", "TopLeft", "BottomRight", "BottomLeft" }; + if (ImGui::Combo("Order", &orderIndex, orderItems, IM_ARRAYSIZE(orderItems))) + { + element->order = static_cast(orderIndex); + for (auto& [_, chunk] : element->chunks) + { + chunk.SetOrdering(element->order); + } + element->DirtyAll(); + } + + ImGui::BeginDisabled(); + ImGui::DragInt("Chunk Size", &element->chunkSize, 1.0f); + ImGui::EndDisabled(); + + if (debug) + { + ImGui::Separator(); + ImGui::TextDisabled(("Chunk Count: " + std::to_string(element->GetChunkCount())).c_str()); + } + } void ElementDrawer::DrawAudioClipCompact(AudioClip *element, const bool &debug, const std::string &label) { float item_spacing = ImGui::GetStyle().ItemSpacing.x; diff --git a/TSE_Editor/src/UI/ElementDrawer.hpp b/TSE_Editor/src/UI/ElementDrawer.hpp index bdd5f89..21ddfcd 100644 --- a/TSE_Editor/src/UI/ElementDrawer.hpp +++ b/TSE_Editor/src/UI/ElementDrawer.hpp @@ -14,6 +14,7 @@ #include "BehaviourScripts/AudioListener.hpp" #include "BehaviourScripts/AudioSource.hpp" #include "BehaviourScripts/TileMap.hpp" +#include "BehaviourScripts/OrdererSpriteSet.hpp" namespace TSE::EDITOR { @@ -81,6 +82,7 @@ namespace TSE::EDITOR static void Draw(Camera* element, const bool& debug); static void Draw(ParticleSystem* element, const bool& debug); static void Draw(TileMap* element, const bool& debug); + static void Draw(OrdererSpriteSet* element, const bool& debug); static void DrawAudioClipCompact(AudioClip* element, const bool& debug, const std::string& label); static void DrawAudioClipNormal(AudioClip* element, const bool& debug, const std::string& label);