Added Collision Tag Matrix #296

Merged
srishamharan merged 5 commits from SP3-4-Editor into main 2022-12-27 13:59:49 +08:00
1 changed files with 13 additions and 13 deletions
Showing only changes of commit 82765648c4 - Show all commits

View File

@ -13,18 +13,18 @@ namespace SHADE
{ {
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers); ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow(); ImGui::TableNextRow();
for (int i = 0; i <= SHCollisionTag::NUM_LAYERS; ++i) for (int i = SHCollisionTag::NUM_LAYERS; i >= 0; --i)
{ {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if(i == 0) continue; if(i == SHCollisionTag::NUM_LAYERS) continue;
std::string const& tagName = SHCollisionTagMatrix::GetTagName(i- 1); std::string const& tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i - 1); auto tag = SHCollisionTagMatrix::GetTag(i);
if (!tag) if (!tag)
continue; continue;
//ImGui::Text(tagName.data()); //ImGui::Text(tagName.data());
SHEditorWidgets::InputText("##" + std::to_string(i), [i]{return SHCollisionTagMatrix::GetTagName(i- 1);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue); SHEditorWidgets::InputText("##" + std::to_string(i), [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
} }
for (int i = SHCollisionTag::NUM_LAYERS - 1; i >= 0; --i) for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i)
{ {
std::string tagName = SHCollisionTagMatrix::GetTagName(i); std::string tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i); auto tag = SHCollisionTagMatrix::GetTag(i);
@ -33,10 +33,11 @@ namespace SHADE
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text(tagName.data()); ImGui::Text(tagName.data());
for (int j = 0; j < SHCollisionTag::NUM_LAYERS - i; ++j) for (int j = (SHCollisionTag::NUM_LAYERS) - 1; j >= i; --j)
{ {
std::string tagName2 = SHCollisionTagMatrix::GetTagName(j); int idx = j;
auto tag2 = SHCollisionTagMatrix::GetTag(j); std::string tagName2 = SHCollisionTagMatrix::GetTagName(idx);
auto tag2 = SHCollisionTagMatrix::GetTag(idx);
if(!tag2) if(!tag2)
continue; continue;
@ -44,14 +45,13 @@ namespace SHADE
if(tagName.empty()) if(tagName.empty())
tagName = std::to_string(i); tagName = std::to_string(i);
if(tagName2.empty()) if(tagName2.empty())
tagName2 = std::to_string(j); tagName2 = std::to_string(idx);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
//if(i == j) //if(i == idx)
// continue; // continue;
std::string_view label = std::format("##{} vs {}", tagName, tagName2).data(); std::string_view label = std::format("##{} vs {}", tagName, tagName2).data();
SHEditorWidgets::CheckBox(label, [tag, &j]{return tag->GetLayerState(j);}, [tag, i, j](bool const& value){tag->SetLayerState(j, value); SHCollisionTagMatrix::GetTag(j)->SetLayerState(i, value);}, label.substr(2)); SHEditorWidgets::CheckBox(label, [tag, &idx]{return tag->GetLayerState(idx);}, [tag, i, idx](bool const& value){tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value);}, label.substr(2));
} }
} }
ImGui::EndTable(); ImGui::EndTable();