diff --git a/Terraformer.vcxproj b/Terraformer.vcxproj index 0805b03..87124c5 100644 --- a/Terraformer.vcxproj +++ b/Terraformer.vcxproj @@ -171,6 +171,7 @@ + diff --git a/Terraformer.vcxproj.filters b/Terraformer.vcxproj.filters index b9cfa74..10ff717 100644 --- a/Terraformer.vcxproj.filters +++ b/Terraformer.vcxproj.filters @@ -95,6 +95,9 @@ Header Files + + Header Files + diff --git a/dist/CS_W1.a2ls b/dist/CS_W1.a2ls index 4bbf2dc..751eef1 100644 Binary files a/dist/CS_W1.a2ls and b/dist/CS_W1.a2ls differ diff --git a/dist/imgui.ini b/dist/imgui.ini index 0579976..4b58c50 100644 --- a/dist/imgui.ini +++ b/dist/imgui.ini @@ -26,6 +26,53 @@ Size=1920,1050 Collapsed=0 DockId=0x8B93E3BD,0 +[Window][Terraformer | Editing map: a] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: aa] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: aaa] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: aaad] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: C] +Pos=0,30 +Size=1920,1050 +Collapsed=0 +DockId=0x8B93E3BD,0 + +[Window][Terraformer | Editing map: CS] +Pos=272,251 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: New WorldC] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: CC] +Pos=60,60 +Size=1120,342 +Collapsed=0 + +[Window][Terraformer | Editing map: D] +Pos=0,30 +Size=1920,1050 +Collapsed=0 +DockId=0x8B93E3BD,0 + [Docking][Data] -DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=505,569 Size=1920,1050 CentralNode=1 Selected=0xCF79E78A +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=49,113 Size=1920,1050 CentralNode=1 Selected=0x30BE4982 diff --git a/include/map.h b/include/map.h index ee1d2e4..b24f59f 100644 --- a/include/map.h +++ b/include/map.h @@ -113,6 +113,9 @@ class Map { void AddNode(); void AddPath(); + void RemoveNode(u32 index); + void RemovePath(u32 index); + void Save(const std::string& filePath); MapData::Header header; diff --git a/include/terraformer.h b/include/terraformer.h index 3e02c9b..71701c9 100644 --- a/include/terraformer.h +++ b/include/terraformer.h @@ -10,11 +10,14 @@ class Terraformer { Map* map = nullptr; std::string message = ""; + int selectedNode = -1; + int selectedPath = -1; void Update(); void UINodes(); void UIPaths(); + void UIProperties(); void LoadFile(const std::string& filePath); void NewFile(); diff --git a/src/Map.cpp b/src/Map.cpp index 2dd6b2c..060bdda 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -131,6 +131,15 @@ void Map::AddPath() { this->paths.push_back(path); } +void Map::RemoveNode(u32 index) { + this->nodes.erase(this->nodes.begin() + index); +} + +void Map::RemovePath(u32 index) { + delete[] this->paths[index].unlockCriteriaData; + this->paths.erase(this->paths.begin() + index); +} + void Map::Save(const std::string& filePath) { std::ofstream file(filePath, std::ios::binary); diff --git a/src/terraformer.cpp b/src/terraformer.cpp index 83e4f83..da84432 100644 --- a/src/terraformer.cpp +++ b/src/terraformer.cpp @@ -28,6 +28,8 @@ void Terraformer::Update() { } if (ImGui::Begin((std::string{"Terraformer | Editing map: "} + std::string{this->map->worldInfo.name}).c_str())) { + this->UIProperties(); + ImGui::NewLine(); this->UINodes(); ImGui::SameLine(); this->UIPaths(); @@ -35,13 +37,36 @@ void Terraformer::Update() { } void Terraformer::UINodes() { + ImGui::PushID("nodes"); + if (ImGui::Button("+", ImVec2(40, 0))) { + this->map->AddNode(); + } + ImGui::SameLine(); + if (ImGui::Button("-", ImVec2(40, 0))) { + if (this->selectedNode != -1) { + this->map->RemoveNode(this->selectedNode); + this->selectedNode = -1; + } + } + ImGui::PopID(); + ImGui::BeginChild("Nodes", ImVec2(500, 0), true); for (u32 i = 0; i < this->map->nodes.size(); i++) { + + MapData::Node& node = this->map->nodes[i]; + const bool selected = (i == this->selectedNode); + ImGui::PushID(i); + if (ImGui::Selectable((std::string{"Node "} + std::to_string(i)).c_str(), selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick)) { + if (selectedNode == i) { + this->selectedNode = -1; + } else { + this->selectedNode = i; + } + } - ImGui::Text("Node %d", i); ImGui::InputText("Bone Name", node.boneName, sizeof(node.boneName)); ImGui::Combo("Type", (int*)&node.type, "Normal\0Passthrough\0Level\0"); @@ -63,18 +88,30 @@ void Terraformer::UINodes() { ImGui::PopID(); - if (i != this->map->nodes.size() - 1) { - ImGui::Separator(); - } + //if (i != this->map->nodes.size() - 1) { + // ImGui::Separator(); + //} } - if (ImGui::Button("Add Node")) { - this->map->AddNode(); - } ImGui::EndChild(); } void Terraformer::UIPaths() { + ImGui::PushID("paths"); + if (ImGui::Button("+", ImVec2(40, 0))) { + this->map->AddPath(); + } + ImGui::SameLine(); + if (ImGui::Button("-", ImVec2(40, 0))) { + if (this->selectedPath != -1) { + this->map->RemovePath(this->selectedPath); + this->selectedPath = -1; + } + } + ImGui::PopID(); + + ImGui::SameLine(); + ImGui::BeginChild("Paths", ImVec2(500, 0), true); static const char* const animationString = @@ -105,8 +142,19 @@ void Terraformer::UIPaths() { for (u32 i = 0; i < this->map->paths.size(); i++) { MapData::Path& path = this->map->paths[i]; + const bool selected = (i == this->selectedPath); + ImGui::PushID(i); - ImGui::Text("Path %d", i); + if (ImGui::Selectable((std::string{ "Path " } + std::to_string(i)).c_str(), selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick)) { + if (selectedPath == i) { + this->selectedPath = -1; + } + else { + this->selectedPath = i; + } + } + + ImGui::Combo("Starting Node", (int*)&path.startingNodeIndex, nodeNames.c_str()); ImGui::Combo("Ending Node", (int*)&path.endingNodeIndex, nodeNames.c_str()); ImGui::InputFloat("Speed", &path.speed); @@ -118,12 +166,17 @@ void Terraformer::UIPaths() { } } - if (ImGui::Button("Add Path")) { - this->map->AddPath(); - } ImGui::EndChild(); } +void Terraformer::UIProperties() { + ImGui::BeginChild("Properties", ImVec2(1010, 200), true); + ImGui::InputText("World Name", this->map->worldInfo.name, sizeof(this->map->worldInfo.name)); + ImGui::InputScalar("World ID", ImGuiDataType_U32, &this->map->worldInfo.worldID); + //ImGui::InputScalar("Map ID", ImGuiDataType_S32, &this->map->); + ImGui::EndChild(); +} + void Terraformer::LoadFile(const std::string& filePath) { std::cout << "Loading file: " << filePath << std::endl;