From 9855436fa64305753da5c6b988db834927720c9a Mon Sep 17 00:00:00 2001
From: biwa <6475593+biwa@users.noreply.github.com>
Date: Fri, 5 Jun 2020 19:49:38 +0200
Subject: [PATCH] 3D floor mode: fixed a problem where splitting a 3D floor
didn't work correctly when some selected sectors didn't belong to that 3D
floor
---
.../Windows/ThreeDFloorEditorWindow.cs | 29 ++++++++++---------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/Source/Plugins/3DFloorMode/Windows/ThreeDFloorEditorWindow.cs b/Source/Plugins/3DFloorMode/Windows/ThreeDFloorEditorWindow.cs
index 3b0967ea..abef9aab 100644
--- a/Source/Plugins/3DFloorMode/Windows/ThreeDFloorEditorWindow.cs
+++ b/Source/Plugins/3DFloorMode/Windows/ThreeDFloorEditorWindow.cs
@@ -111,12 +111,17 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
threeDFloorPanel.ScrollControlIntoView(dup);
}
+ ///
+ /// Splits the 3D floor, creating a new 3D floor for every checked sector
+ ///
+ /// The control for the 3D floor that's to be split
public void SplitThreeDFloor(ThreeDFloorHelperControl ctrl)
{
- var items = new List();
- var controls = new List();
+ List items = new List();
+ List controls = new List() { ctrl };
int numsplits = 0;
+ // Create a list of all checked sectors
for (int i = 0; i < ctrl.checkedListBoxSectors.Items.Count; i++)
{
if(ctrl.checkedListBoxSectors.GetItemCheckState(i) == CheckState.Checked)
@@ -134,39 +139,37 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
have to add exactly one additional control
*/
- controls.Add(ctrl);
-
if (items.Count == 1)
- {
numsplits = 1;
- }
else
- {
numsplits = items.Count - 1;
- }
+ // Get new controls for the additional 3D floors
for (int i = 0; i < numsplits; i++)
{
var newctrl = GetThreeDFloorControl();
newctrl.Update(ctrl);
- newctrl.Show();
-
controls.Add(newctrl);
}
+ // Update the ckeckboxes of the controls to reflect the split 3D floors
for (int i = controls.Count - 1; i >= 0 ; i--)
{
+ // Uncheck all sectors...
for (int j = 0; j < items.Count; j++)
- {
- controls[i].checkedListBoxSectors.SetItemChecked(j, false);
- }
+ controls[i].checkedListBoxSectors.SetItemChecked(items[j], false);
+ // ... and only check a single one
if (useitem >= 0)
controls[i].checkedListBoxSectors.SetItemChecked(items[useitem], true);
useitem--;
}
+
+ // Show the new controls
+ foreach (Control c in controls)
+ c.Show();
}
public void DetachThreeDFloor(ThreeDFloorHelperControl ctrl)