Skip to content

Commit

Permalink
Isolated Chunk Viewing (#56)
Browse files Browse the repository at this point in the history
* Isolated Chunk Viewing Option

Resolves #38
  • Loading branch information
Knuxfan24 authored Jul 18, 2024
1 parent f0d827a commit 462d5f6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
63 changes: 63 additions & 0 deletions HeroesPowerPlant/LevelEditor/LevelEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ namespace HeroesPowerPlant.LevelEditor
{
public partial class LevelEditor : Form, IUnsavedChanges
{
// Internal value to determine if chunk isolation is active.
private bool isolationActive = false;

protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.WindowsShutDown)
Expand Down Expand Up @@ -857,6 +860,12 @@ private void numericCurrentChunk_ValueChanged(object sender, EventArgs e)
}

ProgramIsChangingStuff = false;

// Change the isolation button text.
buttonIsolateChunk.Text = "Isolate Chunk";

// Disable the isolation flag.
isolationActive = false;
}

private void buttonAddChunkClick(object sender, EventArgs e)
Expand Down Expand Up @@ -998,6 +1007,60 @@ public void MATFlag_Reassignment(string target, string replacement)
}
}

private void buttonIsolateChunk_Click(object sender, EventArgs e)
{
// Recheck all the level models in the list view.
foreach (ListViewItem item in listViewLevelModels.Items)
item.Checked = true;

// Check if the isolation isn't active.
if (!isolationActive)
{
// Set up a list of level model indices to be hidden.
List<int> indicesToHide = new();

// Loop through each entry in the BSP list.
for (int bspIndex = 0; bspIndex < bspRenderer.BSPList.Count; bspIndex++)
{
// Check if this BSP's chunk index doesn't match the selected visiblity block's chunk value.
if (bspRenderer.BSPList[bspIndex].ChunkNumber != NumChunkNum.Value)
{
// Hide this chunk.
bspRenderer.BSPList[bspIndex].isVisible = false;

// Mark the index of this BSP to be hidden.
indicesToHide.Add(bspIndex);
}

// If not, then make this chunk visible.
else
bspRenderer.BSPList[bspIndex].isVisible = true;
}

// Loop through and uncheck each level model in our list of indices.
foreach (int index in indicesToHide)
listViewLevelModels.Items[index].Checked = false;

// Change the button text.
buttonIsolateChunk.Text = "Disable Isolation";

// Set the isolation flag.
isolationActive = true;
}
else
{
// Loop through and make every chunk visible.
for (int bspIndex = 0; bspIndex < bspRenderer.BSPList.Count; bspIndex++)
bspRenderer.BSPList[bspIndex].isVisible = true;

// Change the button text.
buttonIsolateChunk.Text = "Isolate Chunk";

// Disable the isolation flag.
isolationActive = false;
}
}

private bool _unsavedChangesLevel = false;
private bool _unsavedChangesVisibility = false;

Expand Down
15 changes: 15 additions & 0 deletions HeroesPowerPlant/LevelEditor/LevelEditor.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 462d5f6

Please sign in to comment.