Navigation Menu

Skip to content

Commit

Permalink
SADXLVL2: Quick fix for Twinkle Circuit's geometry lingering when loa…
Browse files Browse the repository at this point in the history
…ded before Sky Chase.
  • Loading branch information
michael-fadely committed May 8, 2015
1 parent 0d349e6 commit f0eb4e0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
9 changes: 7 additions & 2 deletions SADXLVL2/MainForm.cs
Expand Up @@ -384,7 +384,6 @@ private void LevelToolStripMenuItem_Clicked(object sender, EventArgs e)

private void LoadStage(string id)
{
isStageLoaded = false;
UseWaitCursor = true;
Enabled = false;

Expand Down Expand Up @@ -459,9 +458,15 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)

toolStrip1.Enabled = false;

// HACK: Fixes Twinkle Circuit's geometry lingering if loaded before Sky Chase.
// I'm sure the real problem is somewhere below, but this is sort of an all around cleanup.
if (isStageLoaded)
LevelData.Clear();

isStageLoaded = false;

using (ProgressDialog progress = new ProgressDialog("Loading stage: " + levelName, steps))
{

IniLevelData level = ini.Levels[levelID];

string syspath = Path.Combine(Environment.CurrentDirectory, ini.SystemPath);
Expand Down
42 changes: 29 additions & 13 deletions SAEditorCommon/DataTypes/LevelData.cs
Expand Up @@ -56,8 +56,11 @@ public static void InvalidateRenderState()
/// </summary>
public static void ClearLevelGeometry()
{
LevelItems.Clear();
geo.COL.Clear();
if (LevelItems != null)
LevelItems.Clear();
if (geo != null && geo.COL != null)
geo.COL.Clear();

InvalidateRenderState();
}

Expand All @@ -66,20 +69,23 @@ public static void ClearLevelGeometry()
/// </summary>
public static void ClearLevelGeoAnims()
{
geo.Anim.Clear();
InvalidateRenderState();
if (geo != null && geo.Anim != null)
{
geo.Anim.Clear();
InvalidateRenderState();
}
}

/// <summary>
/// Clears SET Items for all characters.
/// </summary>
public static void ClearSETItems()
{
if (LevelData.SETItems == null)
if (SETItems == null)
return;

for (uint i = 0; i < SETChars.Length; i++)
LevelData.SETItems[i] = new List<SETItem>();
SETItems[i] = new List<SETItem>();

InvalidateRenderState();
}
Expand All @@ -90,10 +96,10 @@ public static void ClearSETItems()
/// <param name="character">The ID of the character whose layout you want to clear.</param>
public static void ClearSETItems(int character)
{
if (LevelData.SETItems == null)
if (SETItems == null)
return;

LevelData.SETItems[character] = new List<SETItem>();
SETItems[character] = new List<SETItem>();
InvalidateRenderState();
}

Expand All @@ -102,11 +108,11 @@ public static void ClearSETItems(int character)
/// </summary>
public static void ClearCAMItems()
{
if (LevelData.CAMItems == null)
if (CAMItems == null)
return;

for (uint i = 0; i < SETChars.Length; i++)
LevelData.CAMItems[i] = new List<CAMItem>();
CAMItems[i] = new List<CAMItem>();

InvalidateRenderState();
}
Expand All @@ -117,13 +123,23 @@ public static void ClearCAMItems()
/// <param name="character">The ID of the character whose layout you want to clear.</param>
public static void ClearCAMItems(int character)
{
if (LevelData.CAMItems == null)
if (CAMItems == null)
return;

LevelData.CAMItems[character] = new List<CAMItem>();
CAMItems[character] = new List<CAMItem>();
InvalidateRenderState();
}

/// <summary>
/// Clears the entire stage.
/// </summary>
public static void Clear()
{
ClearCAMItems();
ClearSETItems();
ClearLevelGeoAnims();
ClearLevelGeometry();
}

public static string GetStats()
{
int landtableItems = LevelData.geo.COL.Count;
Expand Down

0 comments on commit f0eb4e0

Please sign in to comment.