private void LevelEditor_FormClosed(object sender, FormClosedEventArgs e) { if (MinimapForm != null) { MinimapForm.Close(); } if (tools != null) { tools.Close(); } GFX.close(); Level.close(); }
private void processButton_Click(object sender, EventArgs e) { if (!findBlockRadioButton.Checked && !findSpriteRadioButton.Checked) { MessageBox.Show(LanguageManager.Get("DataFinder", "ChooseMode")); return; } StringBuilder output = new StringBuilder(); if (findBlockRadioButton.Checked) output.AppendLine(string.Format(LanguageManager.Get("DataFinder", "BlockInstances"), blockNumberUpDown.Value.ToString())); else output.AppendLine(string.Format(LanguageManager.Get("DataFinder", "SpriteInstances"), spriteUpDown.Value.ToString())); if (findBlockRadioButton.Checked) initDataComparer((int)(splitCountUpDown.Value)); else initDataComparer(6); for (int i = 0; i < Levels.Count; i++) { File levelFile = ROM.FS.getFileByName(LevelFiles[i] + ".bin"); File bgFile = ROM.FS.getFileByName(LevelFiles[i] + "_bgdat.bin"); NSMBLevel l = new NSMBLevel(levelFile, bgFile, null); string n = Levels[i]; n += ": "; if (findBlockRadioButton.Checked) { output.Append(n); int b = (int)(blockNumberUpDown.Value - 1); int s = (int)(splitCountUpDown.Value); if (s == 0) PrintByteArray(output, l.Blocks[b], 0, l.Blocks[b].Length, n); else { for (int j = 0; j < l.Blocks[b].Length; j += s) { if (j != 0) for (int k = 0; k < n.Length; k++) output.Append(" "); if(j+s < l.Blocks[b].Length) PrintByteArray(output, l.Blocks[b], j, j+s, n); else PrintByteArray(output, l.Blocks[b], j, l.Blocks[b].Length, n); } } } else { bool printSpace = false; foreach (NSMBSprite s in l.Sprites) { if (s.Type == spriteUpDown.Value) { if (printSpace) for (int k = 0; k < n.Length; k++) output.Append(" "); else output.Append(n); printSpace = true; PrintByteArray(output, s.Data, 0, 6, n); } } } l.close(); } if (data != null) { output.Append("\r\n"); output.Append("\r\n"); for (int i = 0; i < data.Length; i++) output.Append(String.Format("{0:00} ", i)); output.Append("\r\n"); for (int i = 0; i < data.Length; i++) { if (data[i].Keys.Count == 1) output.Append(String.Format("{0:X2}", data[i].Keys.GetEnumerator().Current)); else output.Append("__"); output.Append(" "); } output.Append("\r\n"); output.Append("\r\n"); for (int i = 0; i < data.Length; i++) { if (data[i].Keys.Count != 1) { output.Append("========================= " + i + ":\r\n"); int bestCount = -1; int bestVal = -1; foreach (byte b in data[i].Keys) { if (data[i][b].Count > bestCount) { bestCount = data[i][b].Count; bestVal = b; } } bool hideMostUsed = false; int mostUsed = bestVal; int mostUsedCount = bestCount; bestCount = -1; bestVal = -1; foreach (byte b in data[i].Keys) { if (data[i][b].Count > bestCount && b != mostUsed) { bestCount = data[i][b].Count; bestVal = b; } } if (mostUsedCount > bestCount * 2) hideMostUsed = true; foreach (byte b in data[i].Keys) { output.Append(String.Format("{0:X2}", b)); output.Append(": "); if (hideMostUsed && b == mostUsed) output.Append(" All Other Levels\r\n"); else { bool writeSpace = false; foreach (string s in data[i][b]) { if (writeSpace) output.Append(" "); writeSpace = true; output.Append(s + "\r\n"); } } } } } } outputTextBox.Text = output.ToString(); }
private void processButton_Click(object sender, EventArgs e) { if (!findBlockRadioButton.Checked && !findSpriteRadioButton.Checked) { MessageBox.Show(LanguageManager.Get("DataFinder", "ChooseMode")); return; } StringBuilder output = new StringBuilder(); if (findBlockRadioButton.Checked) { output.AppendLine(string.Format(LanguageManager.Get("DataFinder", "BlockInstances"), blockNumberUpDown.Value.ToString())); } else { output.AppendLine(string.Format(LanguageManager.Get("DataFinder", "SpriteInstances"), spriteUpDown.Value.ToString())); } if (findBlockRadioButton.Checked) { initDataComparer((int)(splitCountUpDown.Value)); } else { initDataComparer(6); } for (int i = 0; i < Levels.Count; i++) { File levelFile = ROM.FS.getFileByName(LevelFiles[i] + ".bin"); File bgFile = ROM.FS.getFileByName(LevelFiles[i] + "_bgdat.bin"); NSMBLevel l = new NSMBLevel(levelFile, bgFile, null); string n = Levels[i]; n += ": "; if (findBlockRadioButton.Checked) { output.Append(n); int b = (int)(blockNumberUpDown.Value - 1); int s = (int)(splitCountUpDown.Value); if (s == 0) { PrintByteArray(output, l.Blocks[b], 0, l.Blocks[b].Length, n); } else { for (int j = 0; j < l.Blocks[b].Length; j += s) { if (j != 0) { for (int k = 0; k < n.Length; k++) { output.Append(" "); } } if (j + s < l.Blocks[b].Length) { PrintByteArray(output, l.Blocks[b], j, j + s, n); } else { PrintByteArray(output, l.Blocks[b], j, l.Blocks[b].Length, n); } } } } else { bool printSpace = false; foreach (NSMBSprite s in l.Sprites) { if (s.Type == spriteUpDown.Value) { if (printSpace) { for (int k = 0; k < n.Length; k++) { output.Append(" "); } } else { output.Append(n); } printSpace = true; PrintByteArray(output, s.Data, 0, 6, n); } } } l.close(); } if (data != null) { output.Append("\r\n"); output.Append("\r\n"); for (int i = 0; i < data.Length; i++) { output.Append(String.Format("{0:00} ", i)); } output.Append("\r\n"); for (int i = 0; i < data.Length; i++) { if (data[i].Keys.Count == 1) { output.Append(String.Format("{0:X2}", data[i].Keys.GetEnumerator().Current)); } else { output.Append("__"); } output.Append(" "); } output.Append("\r\n"); output.Append("\r\n"); for (int i = 0; i < data.Length; i++) { if (data[i].Keys.Count != 1) { output.Append("========================= " + i + ":\r\n"); int bestCount = -1; int bestVal = -1; foreach (byte b in data[i].Keys) { if (data[i][b].Count > bestCount) { bestCount = data[i][b].Count; bestVal = b; } } bool hideMostUsed = false; int mostUsed = bestVal; int mostUsedCount = bestCount; bestCount = -1; bestVal = -1; foreach (byte b in data[i].Keys) { if (data[i][b].Count > bestCount && b != mostUsed) { bestCount = data[i][b].Count; bestVal = b; } } if (mostUsedCount > bestCount * 2) { hideMostUsed = true; } foreach (byte b in data[i].Keys) { output.Append(String.Format("{0:X2}", b)); output.Append(": "); if (hideMostUsed && b == mostUsed) { output.Append(" All Other Levels\r\n"); } else { bool writeSpace = false; foreach (string s in data[i][b]) { if (writeSpace) { output.Append(" "); } writeSpace = true; output.Append(s + "\r\n"); } } } } } } outputTextBox.Text = output.ToString(); }