static puzzle data!

This commit is contained in:
Asuro
2025-03-13 00:41:32 +01:00
parent f3f994fd8b
commit 155339917d
18 changed files with 264 additions and 143 deletions

View File

@@ -3,6 +3,7 @@
#include "../Instance.h"
#include "../Log.h"
#include "../Mesh.h"
#include "../Tools.h"
#include "Rendering.h"
#include "SDL3/SDL_events.h"
@@ -515,6 +516,8 @@ namespace Game
for (int32_t i = 0; i < BX_COUNTOF(level.Puzzles); ++i)
{
auto& puzzleData = level.Puzzles[i].Data;
if (puzzleData.PuzzleName[0] == 0) continue;
bool isSelected = debug.SelectedDebugLevel == i;
ImGui::PushID("selectable");
if (ImGui::Selectable(puzzleData.PuzzleName, isSelected))
@@ -525,6 +528,7 @@ namespace Game
if (isSelected)
{
ImGui::PushID("edit field");
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
ImGui::InputText("", puzzleData.PuzzleName, sizeof(Generated::PuzzleData::PuzzleName));
ImGui::PopID();
@@ -536,6 +540,53 @@ namespace Game
}
}
ImGui::End();
if (ImGui::Begin("Cards"))
{
Generated::StaticPuzzleData& staticData = Generated::GetStaticPuzzleData();
if (ImGui::Button("Save"))
{
Generated::SaveStaticPuzzleData();
}
ImGui::SameLine();
if (ImGui::Button("Reload"))
{
Generated::LoadStaticPuzzleData();
}
for (int32_t i = 0; i < BX_COUNTOF(staticData.Cards); ++i)
{
ImGui::Separator();
Generated::StaticPuzzleCard& card = staticData.Cards[i];
ImGui::PushID(i);
ImGui::Text("%i", i);
Tools::ModelDropdown(card.ModelHandle);
for (int32_t y = 0; y < Puzzle::Config::CardSize; ++y)
{
ImGui::PushID(y);
for (int32_t x = 0; x < Puzzle::Config::CardSize; ++x)
{
if (x > 0) ImGui::SameLine();
ImGui::PushID(x);
auto& node = card.Nodes[y * Puzzle::Config::CardSize + x];
if (ImGui::Button(Generated::PuzzleElementType::ShortName[node.PlacedTypes[0]], {26, 24}))
{
int32_t newVal = int32_t(node.PlacedTypes[0]) + 1;
if (newVal >= Generated::PuzzleElementType::EntryCount)
{
newVal = 0;
}
node.PlacedTypes[0] = Generated::PuzzleElementType::Enum(newVal);
}
ImGui::PopID();
}
ImGui::PopID();
}
ImGui::PopID();
}
}
ImGui::End();
}
GetInstance().GameLevel.Update();