Skip to content

Commit

Permalink
Adding feature to replace chunks in FG/BG layouts, improving message …
Browse files Browse the repository at this point in the history
…displayed after importing.
  • Loading branch information
MainMemory committed Jun 5, 2016
1 parent 2f63ff6 commit 96c18b4
Show file tree
Hide file tree
Showing 9 changed files with 573 additions and 111 deletions.
10 changes: 5 additions & 5 deletions SonLVL/FindChunksDialog.Designer.cs

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

2 changes: 1 addition & 1 deletion SonLVL/FindChunksDialog.cs
Expand Up @@ -23,7 +23,7 @@ private void FindChunksDialog_VisibleChanged(object sender, EventArgs e)
{
if (Visible)
{
tileList1.Images = new List<Bitmap>(LevelData.CompChunkBmps);
tileList1.Images = LevelData.CompChunkBmps;
tileList1.ImageWidth = LevelData.Level.ChunkWidth;
tileList1.ImageHeight = LevelData.Level.ChunkHeight;
chunkSelect.Maximum = LevelData.Chunks.Count;
Expand Down
220 changes: 122 additions & 98 deletions SonLVL/MainForm.Designer.cs

Large diffs are not rendered by default.

74 changes: 70 additions & 4 deletions SonLVL/MainForm.cs
Expand Up @@ -104,9 +104,11 @@ void Application_ThreadException(object sender, System.Threading.ThreadException
internal List<string> LogFile = new List<string>();
Dictionary<string, ToolStripMenuItem> levelMenuItems;
Dictionary<char, BitmapBits> HUDLetters, HUDNumbers;
internal FindObjectsDialog findObjectsDialog;
internal FindChunksDialog findFGChunksDialog;
internal FindChunksDialog findBGChunksDialog;
FindObjectsDialog findObjectsDialog;
FindChunksDialog findFGChunksDialog;
FindChunksDialog findBGChunksDialog;
ReplaceChunksDialog replaceFGChunksDialog;
ReplaceChunksDialog replaceBGChunksDialog;
List<LayoutSection> savedLayoutSections;
List<Bitmap> savedLayoutSectionImages;
int waterPalette;
Expand Down Expand Up @@ -299,6 +301,8 @@ private void MainForm_Load(object sender, EventArgs e)
findObjectsDialog = new FindObjectsDialog();
findFGChunksDialog = new FindChunksDialog();
findBGChunksDialog = new FindChunksDialog();
replaceFGChunksDialog = new ReplaceChunksDialog();
replaceBGChunksDialog = new ReplaceChunksDialog();
if (Program.Arguments.Length > 0)
LoadINI(Program.Arguments[0]);
}
Expand Down Expand Up @@ -743,6 +747,7 @@ private void backgroundLevelLoader_RunWorkerCompleted(object sender, RunWorkerCo
BlockCount.Text = LevelData.Blocks.Count.ToString("X") + " / " + LevelData.GetBlockMax().ToString("X");
TileCount.Text = LevelData.Tiles.Count.ToString("X") + " / 800";
deleteUnusedTilesToolStripButton.Enabled = deleteUnusedBlocksToolStripButton.Enabled = deleteUnusedChunksToolStripButton.Enabled =
replaceBackgroundToolStripButton.Enabled = replaceForegroundToolStripButton.Enabled =
clearBackgroundToolStripButton.Enabled = clearForegroundToolStripButton.Enabled = usageCountsToolStripMenuItem.Enabled = true;
#if !DEBUG
loadingAnimation1.Hide();
Expand Down Expand Up @@ -5103,7 +5108,30 @@ private bool ImportImage(Bitmap bmp, Bitmap colbmp1, Bitmap colbmp2, Bitmap prib
else if (newBlocks.Count > 0)
chunkBlockEditor.SelectedObjects = chunkBlockEditor.SelectedObjects;
sw.Stop();
MessageBox.Show(sw.Elapsed.ToString());
System.Text.StringBuilder msg = new System.Text.StringBuilder();
msg.AppendFormat("New tiles: {0:X}\n", newTiles.Count);
msg.AppendFormat("New blocks: {0:X}\n", newBlocks.Count);
msg.AppendFormat("New chunks: {0:X}\n", newChunks.Count);
msg.Append("\nCompleted in ");
if (sw.Elapsed.Hours > 0)
{
msg.AppendFormat("{0}:{1:00}:{2:00}", sw.Elapsed.Hours, sw.Elapsed.Minutes, sw.Elapsed.Seconds);
if (sw.Elapsed.Milliseconds > 0)
msg.AppendFormat(".{000}", sw.Elapsed.Milliseconds);
}
else if (sw.Elapsed.Minutes > 0)
{
msg.AppendFormat("{0}:{1:00}", sw.Elapsed.Minutes, sw.Elapsed.Seconds);
if (sw.Elapsed.Milliseconds > 0)
msg.AppendFormat(".{000}", sw.Elapsed.Milliseconds);
}
else
{
msg.AppendFormat("{0}", sw.Elapsed.Seconds);
if (sw.Elapsed.Milliseconds > 0)
msg.AppendFormat(".{000}", sw.Elapsed.Milliseconds);
}
MessageBox.Show(this, msg.ToString(), "Import Results");
importProgressControl1.Hide();
Enabled = true;
UseWaitCursor = false;
Expand Down Expand Up @@ -8782,6 +8810,44 @@ private void usageCountsToolStripMenuItem_Click(object sender, EventArgs e)
using (StatisticsDialog dlg = new StatisticsDialog())
dlg.ShowDialog(this);
}

private void replaceForegroundToolStripButton_Click(object sender, EventArgs e)
{
if (replaceFGChunksDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
byte fc = (byte)replaceFGChunksDialog.findChunk.Value;
byte rc = (byte)replaceFGChunksDialog.replaceChunk.Value;
int cnt = 0;
for (int y = 0; y < LevelData.FGHeight; y++)
for (int x = 0; x < LevelData.FGWidth; x++)
if (LevelData.Layout.FGLayout[x,y] == fc)
{
LevelData.Layout.FGLayout[x, y] = rc;
cnt++;
}
MessageBox.Show(this, "Replaced " + cnt + " chunks.", "SonLVL");
DrawLevel();
}
}

private void replaceBackgroundToolStripButton_Click(object sender, EventArgs e)
{
if (replaceBGChunksDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
byte fc = (byte)replaceBGChunksDialog.findChunk.Value;
byte rc = (byte)replaceBGChunksDialog.replaceChunk.Value;
int cnt = 0;
for (int y = 0; y < LevelData.BGHeight; y++)
for (int x = 0; x < LevelData.BGWidth; x++)
if (LevelData.Layout.BGLayout[x, y] == fc)
{
LevelData.Layout.BGLayout[x, y] = rc;
cnt++;
}
MessageBox.Show(this, "Replaced " + cnt + " chunks.", "SonLVL");
DrawLevel();
}
}
}

public enum EditingMode { Draw, Select }
Expand Down
6 changes: 3 additions & 3 deletions SonLVL/MainForm.resx
Expand Up @@ -265,6 +265,9 @@
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="panel11.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand Down Expand Up @@ -447,9 +450,6 @@
eULeQCkQrSaKL/3DgLJa3+ovZwP+hT/C2BP8Irgr7nRUzgAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="panel11.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tileContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>499, 17</value>
</metadata>
Expand Down
202 changes: 202 additions & 0 deletions SonLVL/ReplaceChunksDialog.Designer.cs

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

0 comments on commit 96c18b4

Please sign in to comment.