diff options
| author | ilotterytea <iltsu@alright.party> | 2025-02-01 22:11:28 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-02-01 22:11:28 +0500 |
| commit | 860773932a67fa0a30c5943336bef6e0be0414a1 (patch) | |
| tree | bc3bc08027d4ace29587d414bbead409596f5afa /src/editor.cpp | |
| parent | c89db32c69c2ca3db059193591ec910d45fbbcc3 (diff) | |
feat: select a tile
Diffstat (limited to 'src/editor.cpp')
| -rw-r--r-- | src/editor.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/editor.cpp b/src/editor.cpp index b78ec2a..65e9cf4 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -2,6 +2,7 @@ #include <SFML/Graphics/RenderWindow.hpp> #include <SFML/System/Vector2.hpp> +#include <memory> #include <optional> #include <string> @@ -51,6 +52,33 @@ namespace silly::editor { ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar); + // --- TILE SELECTION --- + ImGui::BeginChild("TileSelectionRegion", ImVec2(0, 400), + ImGuiChildFlags_Border, + ImGuiWindowFlags_HorizontalScrollbar); + + float padding = 10.0f; + float imageSize = TILE_WIDTH * 2.5f; + int columns = ImGui::GetContentRegionAvail().x / (imageSize + padding); + int count = 0; + + for (auto it = this->tileset.get_tiles().begin(); + it != this->tileset.get_tiles().end(); ++it) { + if (ImGui::ImageButton(std::to_string(it->get()->id).c_str(), + it->get()->texture, + sf::Vector2f(imageSize, imageSize))) { + this->selectedTile = std::make_optional(*it); + } + + count++; + + if (count % columns != 0) { + ImGui::SameLine(); + } + } + + ImGui::EndChild(); + // --- "CREATING A NEW TILE" WINDOW --- if (ImGui::Button("Add tile") && !this->newTileState.has_value()) { this->newTileState = |
