Skip to content

Commit 0ca8a51

Browse files
committed
few fixes to map clearing
1 parent 781862d commit 0ca8a51

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

include/DOM/RoomDataDOMNode.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class LRoomDataDOMNode : public LBGRenderDOMNode
6060
void SetMin(glm::vec3 min) { bbmin = min; }
6161
void SetMax(glm::vec3 max) { bbmax = max; }
6262

63+
uint32_t* GetCameraBehavior() { return &mCameraBehavior; }
6364
float* GetDarkColor() { return &mDarkColor.r; }
6465

6566
int32_t GetRoomIndex() const { return mRoomIndex; }

src/DOM/MapDOMNode.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,6 @@ bool LMapDOMNode::SaveMirrorData()
529529

530530
std::vector<std::shared_ptr<LMirrorDOMNode>> MirrorNodes = GetChildrenOfType<LMirrorDOMNode>(EDOMNodeType::Mirror);
531531

532-
if (MirrorNodes.size() == 0)
533-
{
534-
if (std::filesystem::exists(mirrorsPath))
535-
{
536-
std::filesystem::remove(mirrorsPath);
537-
}
538-
539-
return true;
540-
}
541-
542532
bStream::CMemoryStream memStream = bStream::CMemoryStream(8 + (MirrorNodes.size() * 0x38), bStream::Big, bStream::Out);
543533
memStream.writeUInt32(MirrorNodes.size());
544534
memStream.writeUInt32(0);

src/DOM/RoomDOMNode.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ void LRoomDOMNode::RenderDetailsUI(float dt)
638638
ImGui::InputInt("Sound Room Size", &mSoundRoomSize);
639639
LUIUtility::RenderTooltip("???");
640640

641+
ImGui::InputInt("Camera Behavior", (int32_t*)dataNode->GetCameraBehavior());
642+
LUIUtility::RenderTooltip("Behavior type the camera will use in this room.");
643+
641644
// Bounding Box
642645
ImGui::Text("Bounding Box");
643646
glm::vec3 min = dataNode->GetMin();
@@ -668,10 +671,7 @@ void LRoomDOMNode::RenderDetailsUI(float dt)
668671
ImGui::NewLine();
669672

670673
auto chestData = GetChildrenOfType<LTreasureTableDOMNode>(EDOMNodeType::TreasureTable);
671-
if (chestData.size() == 0)
672-
return;
673-
674-
if (ImGui::TreeNode("Treasure Chest Settings"))
674+
if (chestData.size() != 0 && ImGui::TreeNode("Treasure Chest Settings"))
675675
{
676676
chestData[0]->RenderDetailsUI(dt);
677677
ImGui::TreePop();
@@ -681,8 +681,15 @@ void LRoomDOMNode::RenderDetailsUI(float dt)
681681
{
682682
int index = dataNode->GetRoomIndex();
683683
int id = dataNode->GetRoomID();
684-
ImGui::InputInt("Room Index", &index);
685-
ImGui::InputInt("Room ID", &id);
684+
685+
if(ImGui::InputInt("Room Index", &index)){
686+
dataNode->SetRoomIndex(index);
687+
}
688+
689+
if(ImGui::InputInt("Room ID", &id)){
690+
dataNode->SetRoomID(id);
691+
}
692+
686693
ImGui::TreePop();
687694
}
688695
}

src/scene/EditorScene.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ void LEditorScene::Init(){
110110
}
111111

112112
void LEditorScene::Clear(){
113+
mRoomDoors.clear();
114+
mCurrentRooms.clear();
113115
mPathRenderer.mPaths.clear();
114116
mPointManager.mBillboards.clear();
115117
}

src/ui/BooldozerEditor.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void LBooldozerEditor::Render(float dt, LEditorScene* renderer_scene)
202202

203203
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
204204
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
205-
ImGui::SetNextWindowSize({ImGui::GetMainViewport()->Size.x * 0.25, ImGui::GetMainViewport()->Size.y * 0.75}, ImGuiCond_Appearing);
205+
ImGui::SetNextWindowSize({ImGui::GetMainViewport()->Size.x * 0.25f, ImGui::GetMainViewport()->Size.y * 0.75f}, ImGuiCond_Appearing);
206206
if (ImGui::BeginPopupModal("Map Select", NULL, ImGuiWindowFlags_AlwaysAutoResize))
207207
{
208208
for(int x = 0; x <= 13; x++){
@@ -247,6 +247,8 @@ void LBooldozerEditor::Render(float dt, LEditorScene* renderer_scene)
247247
ImGui::Separator();
248248
if (ImGui::Button("Yes")) {
249249
renderer_scene->Clear();
250+
GetSelectionManager()->ClearSelection();
251+
250252
auto rooms = mLoadedMap->GetChildrenOfType<LRoomDOMNode>(EDOMNodeType::Room);
251253

252254
std::shared_ptr<LRoomDOMNode> newRoom = std::make_shared<LRoomDOMNode>("Room 0");
@@ -257,14 +259,22 @@ void LBooldozerEditor::Render(float dt, LEditorScene* renderer_scene)
257259

258260
std::string resPathInRoot = std::format("{}/{}{}", OPTIONS.mRootPath, "files", newRoomData->GetResourcePath());
259261

260-
for(auto room : rooms){
261-
mLoadedMap->RemoveChild(room);
262+
for(auto ent : mLoadedMap->GetChildrenOfType<LEntityDOMNode>(EDOMNodeType::Entity)){
263+
mLoadedMap->RemoveChild(ent);
264+
}
265+
266+
for(auto mirror : mLoadedMap->GetChildrenOfType<LMirrorDOMNode>(EDOMNodeType::Mirror)){
267+
mLoadedMap->RemoveChild(mirror);
262268
}
263269

264270
for(auto door : mLoadedMap->GetChildrenOfType<LDoorDOMNode>(EDOMNodeType::Door)){
265271
mLoadedMap->RemoveChild(door);
266272
}
267273

274+
for(auto room : rooms){
275+
mLoadedMap->RemoveChild(room);
276+
}
277+
268278
// Clear all room resources
269279
std::filesystem::remove_all(std::filesystem::path(resPathInRoot).parent_path());
270280

@@ -285,8 +295,8 @@ void LBooldozerEditor::Render(float dt, LEditorScene* renderer_scene)
285295
newRoomData->SetRoomID(0);
286296
newRoomData->SetRoomIndex(0);
287297

288-
newRoomData->SetMin({-550, 0, 0});
289-
newRoomData->SetMax({550, 500, 800});
298+
newRoomData->SetMin({-1000, 0, -1000});
299+
newRoomData->SetMax({1000, 1000, 1000});
290300
newRoom->AddChild(newRoomData);
291301
newRoom->SetRoomNumber(0);
292302
newRoomData->GetAdjacencyList().push_back(newRoom);

0 commit comments

Comments
 (0)