slight entity rework (todo: memory corruption >.<)
This commit is contained in:
@@ -182,329 +182,355 @@ namespace Tools
|
||||
return changed;
|
||||
}
|
||||
|
||||
void RenderDebugUI(Game::GameRendering& rendering)
|
||||
void RenderLogUI()
|
||||
{
|
||||
if (!rendering.SetupData.UseImgui) return;
|
||||
auto& time = Game::GetInstance().Time;
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
|
||||
if (ImGui::Begin("Log"))
|
||||
{
|
||||
ImGui::Checkbox("Shorten File Names", &debug.ShortenLogFileNames);
|
||||
ImGui::BeginTable("tbl",
|
||||
4,
|
||||
ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_SizingFixedFit |
|
||||
ImGuiTableFlags_RowBg);
|
||||
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("Log");
|
||||
ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("File", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
auto& logs = GetLogHistory();
|
||||
|
||||
int32_t lineCount = bx::min(100, LogInternal::LogHistorySize);
|
||||
for (int32_t i = 0; i < lineCount; ++i)
|
||||
{
|
||||
int32_t idx = logs.WriteIdx - i - 1;
|
||||
if (idx < 0) idx += LogInternal::LogHistorySize;
|
||||
const char* line = &logs.LogBuffer[idx * LogInternal::MaxLineSize];
|
||||
if (line[0] != 0)
|
||||
{
|
||||
int64_t timeOffset = logs.WriteTime[idx] - time.StartTime;
|
||||
double writeTime = (double)timeOffset / bx::getHPFrequency();
|
||||
uint32_t fileLine = logs.LineBuffer[idx];
|
||||
const char* filePath = &logs.FileBuffer[idx * LogInternal::MaxLineSize];
|
||||
const char* filePathRes =
|
||||
debug.ShortenLogFileNames ? bx::FilePath{filePath}.getFileName().getPtr() : filePath;
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.01f", writeTime);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", line);
|
||||
ImGui::SetItemTooltip("%f\n%s%s:%u", writeTime, line, filePath, fileLine);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%u", fileLine);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", filePathRes);
|
||||
|
||||
if (i > 0) ImGui::PopStyleColor(2);
|
||||
ImVec4 bgCol = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
if (logs.WriteType[idx] == ELogType::Warn)
|
||||
bgCol = {0.2f, 0.2f, 0.0f, 1.0f};
|
||||
else if (logs.WriteType[idx] == ELogType::Error)
|
||||
bgCol = {0.2f, 0.0f, 0.0f, 1.0f};
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, bgCol);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, bgCol);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
if (lineCount > 0) ImGui::PopStyleColor(2);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderRenderSettingsUI(Game::GameRendering& rendering)
|
||||
{
|
||||
auto& time = Game::GetInstance().Time;
|
||||
auto& shared = Game::GetShared();
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
auto& level = Game::GetInstance().GameLevel;
|
||||
auto& player = Game::GetInstance().Player;
|
||||
|
||||
if (rendering.UIVisible == Game::UIVisibilityState::Debug)
|
||||
if (ImGui::Begin("Rendering"))
|
||||
{
|
||||
ZoneScopedN("DebugUI");
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
if (rendering.LastShaderLoadTime >= 0.0f)
|
||||
{
|
||||
debug.DebugCardRotation++;
|
||||
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
|
||||
ImGui::TextColored({0.2f, 0.9f, 0.2f, 1.0f},
|
||||
"Shader loaded %.0f seconds ago",
|
||||
time.Now - rendering.LastShaderLoadTime);
|
||||
}
|
||||
if (ImGui::Begin("Log"))
|
||||
else
|
||||
{
|
||||
ImGui::Checkbox("Shorten File Names", &debug.ShortenLogFileNames);
|
||||
ImGui::BeginTable("tbl",
|
||||
4,
|
||||
ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable |
|
||||
ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg);
|
||||
ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("Log");
|
||||
ImGui::TableSetupColumn("Line", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableSetupColumn("File", ImGuiTableColumnFlags_NoResize);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
auto& logs = GetLogHistory();
|
||||
|
||||
int32_t lineCount = bx::min(100, LogInternal::LogHistorySize);
|
||||
for (int32_t i = 0; i < lineCount; ++i)
|
||||
{
|
||||
int32_t idx = logs.WriteIdx - i - 1;
|
||||
if (idx < 0) idx += LogInternal::LogHistorySize;
|
||||
const char* line = &logs.LogBuffer[idx * LogInternal::MaxLineSize];
|
||||
if (line[0] != 0)
|
||||
{
|
||||
int64_t timeOffset = logs.WriteTime[idx] - time.StartTime;
|
||||
double writeTime = (double)timeOffset / bx::getHPFrequency();
|
||||
uint32_t fileLine = logs.LineBuffer[idx];
|
||||
const char* filePath = &logs.FileBuffer[idx * LogInternal::MaxLineSize];
|
||||
const char* filePathRes =
|
||||
debug.ShortenLogFileNames ? bx::FilePath{filePath}.getFileName().getPtr() : filePath;
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%.01f", writeTime);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", line);
|
||||
ImGui::SetItemTooltip("%f\n%s%s:%u", writeTime, line, filePath, fileLine);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%u", fileLine);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", filePathRes);
|
||||
|
||||
if (i > 0) ImGui::PopStyleColor(2);
|
||||
ImVec4 bgCol = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
if (logs.WriteType[idx] == ELogType::Warn)
|
||||
bgCol = {0.2f, 0.2f, 0.0f, 1.0f};
|
||||
else if (logs.WriteType[idx] == ELogType::Error)
|
||||
bgCol = {0.2f, 0.0f, 0.0f, 1.0f};
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, bgCol);
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, bgCol);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
if (lineCount > 0) ImGui::PopStyleColor(2);
|
||||
ImGui::TextColored({0.9f, 0.2f, 0.2f, 1.0f}, "Shader load Failiure!");
|
||||
}
|
||||
ImGui::End();
|
||||
if (ImGui::Begin("Rendering"))
|
||||
if (ImGui::Button("Reload Meshes"))
|
||||
{
|
||||
if (rendering.LastShaderLoadTime >= 0.0f)
|
||||
{
|
||||
ImGui::TextColored({0.2f, 0.9f, 0.2f, 1.0f},
|
||||
"Shader loaded %.0f seconds ago",
|
||||
time.Now - rendering.LastShaderLoadTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TextColored({0.9f, 0.2f, 0.2f, 1.0f}, "Shader load Failiure!");
|
||||
}
|
||||
if (ImGui::Button("Reload Meshes"))
|
||||
{
|
||||
LoadModels(rendering.Models, rendering.ModelCount);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload Level"))
|
||||
{
|
||||
level = {};
|
||||
level.Setup(shared.Game);
|
||||
}
|
||||
LoadModels(rendering.Models, rendering.ModelCount);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload Level"))
|
||||
{
|
||||
level = {};
|
||||
level.Setup(shared.Game);
|
||||
}
|
||||
|
||||
ImGui::SliderFloat("Mouse Sensitivity", &player.MouseSensitivity, 0.1f, 5.0f);
|
||||
ImGui::SliderFloat("Player Speed", &player.MovementSpeed, 1.0f, 30.0f);
|
||||
ImGui::SliderFloat("Mouse Sensitivity", &player.MouseSensitivity, 0.1f, 5.0f);
|
||||
ImGui::SliderFloat("Player Speed", &player.MovementSpeed, 1.0f, 30.0f);
|
||||
|
||||
ImGui::Checkbox("Show ImGui Demo", &debug.ShowImguiDemo);
|
||||
ImGui::Checkbox("Show Stats", &debug.ShowStats);
|
||||
if (debug.ShowImguiDemo) ImGui::ShowDemoWindow(&debug.ShowImguiDemo);
|
||||
ImGui::Checkbox("Show ImGui Demo", &debug.ShowImguiDemo);
|
||||
ImGui::Checkbox("Show Stats", &debug.ShowStats);
|
||||
if (debug.ShowImguiDemo) ImGui::ShowDemoWindow(&debug.ShowImguiDemo);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Entity Groups");
|
||||
ImGui::Checkbox("Cubes", &level.Cubes.IsEnabled);
|
||||
ImGui::Checkbox("Tests", &level.Tests.IsEnabled);
|
||||
ImGui::Checkbox("PuzzleTiles", &level.PuzzleTiles.IsEnabled);
|
||||
ImGui::Checkbox("UIQuads", &level.UIQuads.IsEnabled);
|
||||
ImGui::Checkbox("Level", &level.LevelEntities.IsEnabled);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
bool uiconfigChanged = false;
|
||||
if (ImGui::TreeNodeEx("Game Tablet"))
|
||||
{
|
||||
uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletBackgroundRenderData);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Entity Groups");
|
||||
ImGui::Checkbox("Cubes", &level.Cubes.IsEnabled);
|
||||
ImGui::Checkbox("Tests", &level.Tests.IsEnabled);
|
||||
ImGui::Checkbox("PuzzleTiles", &level.PuzzleTiles.IsEnabled);
|
||||
ImGui::Checkbox("UIQuads", &level.UIQuads.IsEnabled);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Game Tablet");
|
||||
bool bTabletChanged = false;
|
||||
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletBackgroundRenderData);
|
||||
ImGui::Text("Status");
|
||||
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletStatusRenderData);
|
||||
bTabletChanged |= Tools::TextureDropdown(player.Config.TabletStatusSolvedTexture, "Solved Texture");
|
||||
bTabletChanged |=
|
||||
uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletStatusRenderData);
|
||||
uiconfigChanged |= Tools::TextureDropdown(player.Config.TabletStatusSolvedTexture, "Solved Texture");
|
||||
uiconfigChanged |=
|
||||
Tools::TextureDropdown(player.Config.TabletStatusNotSolvedTexture, "Not Solved Texture");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Reset");
|
||||
bTabletChanged |= Tools::EntityDataSettings(player.Config.TabletResetRenderData);
|
||||
if (bTabletChanged)
|
||||
{
|
||||
Serializer s;
|
||||
s.Init("game/data/static/uiconfig.dat", "UICO");
|
||||
s.WriteT(player.Config);
|
||||
s.Finish();
|
||||
level.PuzzleUI.Reset();
|
||||
}
|
||||
uiconfigChanged |= Tools::EntityDataSettings(player.Config.TabletResetRenderData);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNodeEx("Background Level"))
|
||||
{
|
||||
for (int32_t i = 0; i < BX_COUNTOF(player.Config.BackgroundLevelRenderData); ++i)
|
||||
{
|
||||
if (i > 0) ImGui::Separator();
|
||||
uiconfigChanged |= Tools::EntityDataSettings(player.Config.BackgroundLevelRenderData[i]);
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (uiconfigChanged)
|
||||
{
|
||||
Serializer s;
|
||||
s.Init("game/data/static/uiconfig.dat", "UICO");
|
||||
s.WriteT(player.Config);
|
||||
s.Finish();
|
||||
level.PuzzleUI.Reset();
|
||||
level.ReloadLevelEntities();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Dithergen"))
|
||||
{
|
||||
DitherGen(rendering.DitherTextures, rendering.DitherRecursion);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SliderInt("Recursion", &rendering.DitherRecursion, 1, 4);
|
||||
ImGui::Text("%ux%ux%u",
|
||||
rendering.DitherTextures.DitherTexWH,
|
||||
rendering.DitherTextures.DitherTexWH,
|
||||
rendering.DitherTextures.DitherTexDepth);
|
||||
if (!isValid(rendering.DitherTextures.PreviewTex))
|
||||
{
|
||||
ImGui::Text("Invalid Texture");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Image(rendering.DitherTextures.PreviewTex.idx,
|
||||
{(float)rendering.DitherTextures.DitherTexWH,
|
||||
(float)rendering.DitherTextures.DitherTexWH * rendering.DitherTextures.DitherTexDepth});
|
||||
}
|
||||
if (isValid(rendering.DitherTextures.RampTex))
|
||||
{
|
||||
ImGui::Image(rendering.DitherTextures.RampTex.idx,
|
||||
{BX_COUNTOF(rendering.DitherTextures.BrightnessRamp), 8});
|
||||
}
|
||||
Vec3 quadPos = level.UIQuads.Get({0}).EData.Transform.Position;
|
||||
ImGui::Text("%f %f %f", quadPos.x, quadPos.y, quadPos.z);
|
||||
|
||||
ImGui::Text("Shader log:");
|
||||
ImGui::TextWrapped("%s", Game::GetShared().Dev.ShaderLog);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderTexturesUI(Game::GameRendering& rendering)
|
||||
{
|
||||
if (ImGui::Begin("Textures"))
|
||||
{
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
rendering.LoadTextures();
|
||||
}
|
||||
for (int32_t i = 0; i < rendering.MaxTextures; ++i)
|
||||
{
|
||||
if (!isValid(rendering.Textures[i].RenderHandle)) continue;
|
||||
ImGui::Text("%i", i);
|
||||
float width = bx::min<float>(ImGui::GetContentRegionAvail().x, rendering.Textures[i].Info.width);
|
||||
float height = bx::min<float>(ImGui::GetContentRegionAvail().x, rendering.Textures[i].Info.height);
|
||||
ImGui::Image(rendering.Textures[i].RenderHandle.idx, {width, height});
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderPuzzlesUI()
|
||||
{
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
auto& level = Game::GetInstance().GameLevel;
|
||||
|
||||
if (ImGui::Begin("Puzzles"))
|
||||
{
|
||||
char nameBuf[64]{0};
|
||||
for (int32_t i = 0; i < BX_COUNTOF(level.Puzzles); ++i)
|
||||
{
|
||||
auto& puzzleData = level.Puzzles[i].Data;
|
||||
|
||||
bool isSelected = debug.SelectedDebugLevel == i;
|
||||
ImGui::PushID("selectable");
|
||||
bx::snprintf(nameBuf, sizeof(nameBuf), "%u: %s", i, puzzleData.PuzzleName);
|
||||
if (ImGui::Selectable(nameBuf, isSelected))
|
||||
{
|
||||
debug.SelectedDebugLevel = isSelected ? UINT16_MAX : i;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
if (debug.SelectedDebugLevel < BX_COUNTOF(level.Puzzles))
|
||||
{
|
||||
if (!Puzzle::RenderDebugUI(level.Puzzles[debug.SelectedDebugLevel].Data))
|
||||
{
|
||||
debug.SelectedDebugLevel = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderCardsUI(Game::GameRendering& rendering)
|
||||
{
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
|
||||
if (ImGui::Begin("Cards"))
|
||||
{
|
||||
Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
|
||||
|
||||
if (ImGui::Button("Save"))
|
||||
{
|
||||
Puzzle::SaveStaticPuzzleData();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
Puzzle::LoadStaticPuzzleData();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::ColorEdit3("Disabled Tint", &staticData.Visuals.DisabledCardTint.x);
|
||||
ImGui::ColorEdit3("Tile Base Color", &staticData.Visuals.TileBaseColor.x);
|
||||
ImGui::ColorEdit3("Tile Dot Color", &staticData.Visuals.TileDotColor.x);
|
||||
|
||||
for (int32_t i = 0; i < BX_COUNTOF(staticData.Cards); ++i)
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Dithergen"))
|
||||
Gen::StaticPuzzleCard& card = staticData.Cards[i];
|
||||
ImGui::PushID(i);
|
||||
char cardName[64]{0};
|
||||
bx::snprintf(cardName, sizeof(cardName), "%i", i);
|
||||
ImGui::Selectable(cardName);
|
||||
if (ImGui::BeginDragDropSource())
|
||||
{
|
||||
DitherGen(rendering.DitherTextures, rendering.DitherRecursion);
|
||||
Puzzle::DrawCard(card, debug.DebugCardRotation, ImGui::GetCursorScreenPos());
|
||||
ImGui::SetDragDropPayload("cardtype", &i, sizeof(i));
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SliderInt("Recursion", &rendering.DitherRecursion, 1, 4);
|
||||
ImGui::Text("%ux%ux%u",
|
||||
rendering.DitherTextures.DitherTexWH,
|
||||
rendering.DitherTextures.DitherTexWH,
|
||||
rendering.DitherTextures.DitherTexDepth);
|
||||
if (!isValid(rendering.DitherTextures.PreviewTex))
|
||||
{
|
||||
ImGui::Text("Invalid Texture");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Image(
|
||||
rendering.DitherTextures.PreviewTex.idx,
|
||||
{(float)rendering.DitherTextures.DitherTexWH,
|
||||
(float)rendering.DitherTextures.DitherTexWH * rendering.DitherTextures.DitherTexDepth});
|
||||
}
|
||||
if (isValid(rendering.DitherTextures.RampTex))
|
||||
{
|
||||
ImGui::Image(rendering.DitherTextures.RampTex.idx,
|
||||
{BX_COUNTOF(rendering.DitherTextures.BrightnessRamp), 8});
|
||||
}
|
||||
Vec3 quadPos = level.UIQuads.Get({0}).EData.Transform.Position;
|
||||
ImGui::Text("%f %f %f", quadPos.x, quadPos.y, quadPos.z);
|
||||
|
||||
ImGui::Text("Shader log:");
|
||||
ImGui::TextWrapped("%s", Game::GetShared().Dev.ShaderLog);
|
||||
}
|
||||
ImGui::End();
|
||||
if (ImGui::Begin("Textures"))
|
||||
{
|
||||
if (ImGui::Button("Reload"))
|
||||
Tools::ModelDropdown(card.BaseModelHandle);
|
||||
Tools::TextureDropdown(card.BoardTextureHandle);
|
||||
if (IsValid(card.BaseModelHandle))
|
||||
{
|
||||
rendering.LoadTextures();
|
||||
}
|
||||
for (int32_t i = 0; i < rendering.MaxTextures; ++i)
|
||||
{
|
||||
if (!isValid(rendering.Textures[i].RenderHandle)) continue;
|
||||
ImGui::Text("%i", i);
|
||||
float width = bx::min<float>(ImGui::GetContentRegionAvail().x, rendering.Textures[i].Info.width);
|
||||
float height = bx::min<float>(ImGui::GetContentRegionAvail().x, rendering.Textures[i].Info.height);
|
||||
ImGui::Image(rendering.Textures[i].RenderHandle.idx, {width, height});
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
if (ImGui::Begin("Puzzles"))
|
||||
{
|
||||
char nameBuf[64]{0};
|
||||
for (int32_t i = 0; i < BX_COUNTOF(level.Puzzles); ++i)
|
||||
{
|
||||
auto& puzzleData = level.Puzzles[i].Data;
|
||||
|
||||
bool isSelected = debug.SelectedDebugLevel == i;
|
||||
ImGui::PushID("selectable");
|
||||
bx::snprintf(nameBuf, sizeof(nameBuf), "%u: %s", i, puzzleData.PuzzleName);
|
||||
if (ImGui::Selectable(nameBuf, isSelected))
|
||||
auto& mdl = rendering.Models[card.BaseModelHandle.ModelIdx];
|
||||
if (mdl.SocketCount > 0 && ImGui::TreeNodeEx("Slots"))
|
||||
{
|
||||
debug.SelectedDebugLevel = isSelected ? UINT16_MAX : i;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
if (debug.SelectedDebugLevel < BX_COUNTOF(level.Puzzles))
|
||||
{
|
||||
if (!Puzzle::RenderDebugUI(level.Puzzles[debug.SelectedDebugLevel].Data))
|
||||
{
|
||||
debug.SelectedDebugLevel = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
if (ImGui::Begin("Cards"))
|
||||
{
|
||||
Gen::StaticPuzzleData& staticData = Puzzle::GetStaticPuzzleData();
|
||||
|
||||
if (ImGui::Button("Save"))
|
||||
{
|
||||
Puzzle::SaveStaticPuzzleData();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
Puzzle::LoadStaticPuzzleData();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::ColorEdit3("Disabled Tint", &staticData.Visuals.DisabledCardTint.x);
|
||||
ImGui::ColorEdit3("Tile Base Color", &staticData.Visuals.TileBaseColor.x);
|
||||
ImGui::ColorEdit3("Tile Dot Color", &staticData.Visuals.TileDotColor.x);
|
||||
|
||||
for (int32_t i = 0; i < BX_COUNTOF(staticData.Cards); ++i)
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
Gen::StaticPuzzleCard& card = staticData.Cards[i];
|
||||
ImGui::PushID(i);
|
||||
char cardName[64]{0};
|
||||
bx::snprintf(cardName, sizeof(cardName), "%i", i);
|
||||
ImGui::Selectable(cardName);
|
||||
if (ImGui::BeginDragDropSource())
|
||||
{
|
||||
Puzzle::DrawCard(card, debug.DebugCardRotation, ImGui::GetCursorScreenPos());
|
||||
ImGui::SetDragDropPayload("cardtype", &i, sizeof(i));
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
|
||||
Tools::ModelDropdown(card.BaseModelHandle);
|
||||
Tools::TextureDropdown(card.BoardTextureHandle);
|
||||
if (IsValid(card.BaseModelHandle))
|
||||
{
|
||||
auto& mdl = rendering.Models[card.BaseModelHandle.ModelIdx];
|
||||
if (mdl.SocketCount > 0 && ImGui::TreeNodeEx("Slots"))
|
||||
for (int32_t sIdx = 0; sIdx < mdl.SocketCount; ++sIdx)
|
||||
{
|
||||
for (int32_t sIdx = 0; sIdx < mdl.SocketCount; ++sIdx)
|
||||
Tools::ModelDropdown(card.Sockets[sIdx].Model, mdl.Sockets[sIdx].Name);
|
||||
int val = card.Sockets[sIdx].ConnectionDirection;
|
||||
ImGui::PushID(sIdx);
|
||||
if (ImGui::Combo("Connection Direction", &val, "North\0East\0South\0West\0"))
|
||||
{
|
||||
Tools::ModelDropdown(card.Sockets[sIdx].Model, mdl.Sockets[sIdx].Name);
|
||||
int val = card.Sockets[sIdx].ConnectionDirection;
|
||||
ImGui::PushID(sIdx);
|
||||
if (ImGui::Combo("Connection Direction", &val, "North\0East\0South\0West\0"))
|
||||
{
|
||||
card.Sockets[sIdx].ConnectionDirection = val;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Card");
|
||||
for (int8_t y = 0; y < Puzzle::Config::CardSize; ++y)
|
||||
{
|
||||
ImGui::PushID(y);
|
||||
for (int8_t x = 0; x < Puzzle::Config::CardSize; ++x)
|
||||
{
|
||||
if (x > 0) ImGui::SameLine();
|
||||
ImGui::PushID(x);
|
||||
auto& node = Puzzle::EditCardNodeAt(card, 0, x, y);
|
||||
if (ImGui::Button(Gen::PuzzleElementType::ShortName[node], {26, 24}))
|
||||
{
|
||||
int32_t newVal = int32_t(node) + 1;
|
||||
if (newVal >= Gen::PuzzleElementType::EntryCount)
|
||||
{
|
||||
newVal = 0;
|
||||
}
|
||||
node = Gen::PuzzleElementType::Enum(newVal);
|
||||
card.Sockets[sIdx].ConnectionDirection = val;
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Card");
|
||||
for (int8_t y = 0; y < Puzzle::Config::CardSize; ++y)
|
||||
{
|
||||
ImGui::PushID(y);
|
||||
for (int8_t x = 0; x < Puzzle::Config::CardSize; ++x)
|
||||
{
|
||||
if (x > 0) ImGui::SameLine();
|
||||
ImGui::PushID(x);
|
||||
auto& node = Puzzle::EditCardNodeAt(card, 0, x, y);
|
||||
if (ImGui::Button(Gen::PuzzleElementType::ShortName[node], {26, 24}))
|
||||
{
|
||||
int32_t newVal = int32_t(node) + 1;
|
||||
if (newVal >= Gen::PuzzleElementType::EntryCount)
|
||||
{
|
||||
newVal = 0;
|
||||
}
|
||||
node = Gen::PuzzleElementType::Enum(newVal);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::End();
|
||||
if (ImGui::Begin("Debug"))
|
||||
{
|
||||
ImGui::Checkbox("Arenas", &debug.ShowArenaUsage);
|
||||
ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo);
|
||||
ImGui::SliderFloat("Font Scale", &ImGui::GetIO().FontGlobalScale, 0.5f, 4.0f);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (debug.ShowArenaUsage)
|
||||
{
|
||||
if (ImGui::Begin("Arenas", &debug.ShowArenaUsage))
|
||||
{
|
||||
ProgressBar("Permanent", shared.Game.PermanentArena.Used, shared.Game.PermanentArena.MaxSize);
|
||||
ProgressBar("Entity", shared.Game.EntityArena.Used, shared.Game.EntityArena.MaxSize);
|
||||
ProgressBar("Transient", shared.Game.TransientArena.Used, shared.Game.TransientArena.MaxSize);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
void RenderEntitiesUI()
|
||||
{
|
||||
auto& level = Game::GetInstance().GameLevel;
|
||||
|
||||
if (ImGui::Begin("Entities"))
|
||||
if (ImGui::Begin("Entities"))
|
||||
{
|
||||
if (ImGui::TreeNodeEx("UIQuads"))
|
||||
{
|
||||
ImGui::Text("UIQuads");
|
||||
ImGui::Text("Count: %u", level.UIQuads.Count);
|
||||
for (uint16_t i = 0; i < level.UIQuads.Count; ++i)
|
||||
{
|
||||
ImGui::Separator();
|
||||
ImGui::PushID(i);
|
||||
ImGui::Text("%u", i);
|
||||
ImGui::SameLine();
|
||||
auto& quad = level.UIQuads.Get({i});
|
||||
ImGui::Checkbox("Debug Break on Render", &quad.EData.DebugBreakOnRender);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Visible", &quad.EData.Visible);
|
||||
TextureDropdown(quad.EData.TextureHandle);
|
||||
MaterialDropdown(quad.EData.MaterialHandle);
|
||||
@@ -512,9 +538,37 @@ namespace Tools
|
||||
ImGui::DragFloat3("UI Pos", &quad.UIPos.x);
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNodeEx("Level"))
|
||||
{
|
||||
ImGui::Text("Count: %u", level.LevelEntities.Count);
|
||||
for (uint16_t i = 0; i < level.LevelEntities.Count; ++i)
|
||||
{
|
||||
ImGui::Separator();
|
||||
ImGui::PushID(i);
|
||||
ImGui::Text("%u", i);
|
||||
ImGui::SameLine();
|
||||
auto& levelEnt = level.LevelEntities.Get({i});
|
||||
ImGui::Checkbox("Debug Break on Render", &levelEnt.EData.DebugBreakOnRender);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Visible", &levelEnt.EData.Visible);
|
||||
TextureDropdown(levelEnt.EData.TextureHandle);
|
||||
MaterialDropdown(levelEnt.EData.MaterialHandle);
|
||||
ImGui::DragFloat3("Pos", &levelEnt.EData.Transform.Position.x);
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderStatsUI()
|
||||
{
|
||||
auto& time = Game::GetInstance().Time;
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
|
||||
if (debug.ShowStats)
|
||||
{
|
||||
ImGui::SetNextWindowPos({0, 0});
|
||||
@@ -563,6 +617,48 @@ namespace Tools
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderDebugUI(Game::GameRendering& rendering)
|
||||
{
|
||||
if (!rendering.SetupData.UseImgui) return;
|
||||
ZoneScopedN("DebugUI");
|
||||
|
||||
auto& time = Game::GetInstance().Time;
|
||||
auto& shared = Game::GetShared();
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
auto& level = Game::GetInstance().GameLevel;
|
||||
auto& player = Game::GetInstance().Player;
|
||||
|
||||
if (rendering.UIVisible == Game::UIVisibilityState::Debug)
|
||||
{
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
debug.DebugCardRotation++;
|
||||
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
|
||||
}
|
||||
|
||||
if (ImGui::Begin("Debug"))
|
||||
{
|
||||
ImGui::Checkbox("ImGui Demo", &debug.ShowImguiDemo);
|
||||
ImGui::SliderFloat("Font Scale", &ImGui::GetIO().FontGlobalScale, 0.5f, 4.0f);
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Arenas");
|
||||
ProgressBar("Permanent", shared.Game.PermanentArena.Used, shared.Game.PermanentArena.MaxSize);
|
||||
ProgressBar("Entity", shared.Game.EntityArena.Used, shared.Game.EntityArena.MaxSize);
|
||||
ProgressBar("Transient", shared.Game.TransientArena.Used, shared.Game.TransientArena.MaxSize);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
RenderLogUI();
|
||||
RenderRenderSettingsUI(rendering);
|
||||
RenderTexturesUI(rendering);
|
||||
RenderPuzzlesUI();
|
||||
RenderCardsUI(rendering);
|
||||
RenderEntitiesUI();
|
||||
}
|
||||
RenderStatsUI();
|
||||
}
|
||||
void MeasureFrameEnd()
|
||||
{
|
||||
FrameTimes[FrameTimeIdx] = bx::getHPCounter();
|
||||
|
||||
Reference in New Issue
Block a user