public static void update() { try { string data = DownloadWebPage("http://nsmbhd.net/spritexml.php"); if (data.Trim() == "") { throw new Exception("Got empty data"); } if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); StreamWriter sw = new StreamWriter(fs); sw.Write(data); sw.Close(); fs.Close(); MessageBox.Show(LanguageManager.Get("SpriteData", "Updated")); } catch (Exception e) { MessageBox.Show(String.Format(LanguageManager.Get("SpriteData", "ErrorUpdate"), e.Message), LanguageManager.Get("SpriteData", "ErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void load() { SelectTool(ToolType.Brush); hoverStatus.Text = ""; imageStatus.Text = string.Format(LanguageManager.Get("GraphicsEditor", "imageStatus"), 8, img.getWidth(), img.getHeight()); }
void objectHovered(NSMBObject obj) { if (obj == hover) { return; } hover = obj; if (obj == null) { toolTip1.Hide(this); } else { int x = Width - 16; int y = obj.Y * 16 - 8 + obj.Height * 8 - vScrollBar1.Value; toolTip1.ToolTipTitle = LanguageManager.Get("ObjectPickerControl", "Object") + obj.ObjNum; string text = ""; if (gfx.Tilesets[tileset].UseNotes && obj.ObjNum < gfx.Tilesets[tileset].ObjNotes.Length) { text = gfx.Tilesets[tileset].ObjNotes[obj.ObjNum]; } toolTip1.Show(text + " ", this, x, y); } }
private void exportTilesetBtn_Click(object sender, EventArgs e) { getFiles(); if (GFXFile == null) { return; } if (PalFile == null) { return; } if (LayoutFile == null) { return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = LanguageManager.Get("Filters", "background"); if (sfd.ShowDialog() != DialogResult.OK) { return; } System.IO.BinaryWriter bw = new System.IO.BinaryWriter( new System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)); bw.Write(fileHeader); writeFileContents(GFXFile, bw); writeFileContents(PalFile, bw); writeFileContents(LayoutFile, bw); bw.Close(); }
private void importThisWithPalBtn_Click(object sender, EventArgs e) { if (!(imageListBox.SelectedItem is PalettedImage)) { MessageBox.Show(this, LanguageManager.Get("ImageManager", "noImageSelected")); return; } if (!(paletteListBox.SelectedItem is Palette)) { MessageBox.Show(this, LanguageManager.Get("ImageManager", "noPaletteSelected")); return; } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = LanguageManager.Get("Filters", "png"); if (ofd.ShowDialog(this) == DialogResult.Cancel) { return; } Bitmap b = new Bitmap(ofd.FileName); (imageListBox.SelectedItem as PalettedImage).replaceImgAndPal(b, paletteListBox.SelectedItem as Palette); b.Dispose(); updateImage(); }
private void editLevelButton_Click(object sender, EventArgs e) { // Make a caption string EditorCaption = ""; if (levelTreeView.SelectedNode.Parent.Parent == null) { EditorCaption += levelTreeView.SelectedNode.Text; } else { EditorCaption += levelTreeView.SelectedNode.Parent.Text + ", " + levelTreeView.SelectedNode.Text; } // Open it try { LevelEditor NewEditor = new LevelEditor((string)levelTreeView.SelectedNode.Tag, EditorCaption); NewEditor.Show(); } catch (AlreadyEditingException) { MessageBox.Show(LanguageManager.Get("Errors", "Level")); } }
private void deleteDescriptions_Click(object sender, EventArgs e) { if (!descExists) { return; } if (MessageBox.Show(LanguageManager.Get("TilesetEditor", "sureDelDescriptions"), LanguageManager.Get("TilesetEditor", "titleDelDescriptions"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } ROM.UserInfo.descriptions.Remove(TilesetID); createDescriptions.Visible = true; deleteDescriptions.Visible = false; tilesetObjectEditor1.descBox.Visible = false; tilesetObjectEditor1.descLbl.Visible = false; if (TilesetID != 65535) // The Jyotyu tileset { t.UseNotes = false; } else //Restore the original notes { t.ObjNotes = NSMBGraphics.GetDescriptions(LanguageManager.GetList("ObjNotes")); } descExists = false; objectPickerControl1.Invalidate(true); }
private void hexEditLevelButton_Click(object sender, EventArgs e) { if (levelTreeView.SelectedNode == null) { return; } // Make a caption string EditorCaption = LanguageManager.Get("General", "EditingSomething") + " "; if (levelTreeView.SelectedNode.Parent.Parent == null) { EditorCaption += levelTreeView.SelectedNode.Text; } else { EditorCaption += levelTreeView.SelectedNode.Parent.Text + ", " + levelTreeView.SelectedNode.Text; } // Open it try { LevelHexEditor NewEditor = new LevelHexEditor((string)levelTreeView.SelectedNode.Tag); NewEditor.Text = EditorCaption; NewEditor.Show(); } catch (AlreadyEditingException) { MessageBox.Show(LanguageManager.Get("Errors", "Level")); } }
private void SetZoomLevel(int zoom) { if (img == null || pal == null) { return; } ZoomLevel = zoom; drawingBox.Size = new Size(img.getWidth() * zoom, img.getHeight() * zoom); ViewWidth = drawingBox.Width; ViewHeight = drawingBox.Height; RenderZoomCache(); zoomIn.Enabled = true; zoomActualSize.Enabled = true; zoomOut.Enabled = true; if (zoom == 1) { zoomActualSize.Enabled = false; zoomOut.Enabled = false; } if (zoom == 8) { zoomIn.Enabled = false; } zoomLabel.Text = string.Format(LanguageManager.Get("GraphicsEditor", "zoomLabel"), ZoomLevel * 100); drawingBox.Invalidate(); }
private void deleteBackups_Click(object sender, EventArgs e) { if (MessageBox.Show((LanguageManager.Get("LevelChooser", "delbackup")), (LanguageManager.Get("LevelChooser", "delbacktitle")), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { System.IO.Directory.Delete(Path.Combine(Application.StartupPath, "Backup"), true); } }
private void importClipboard_Click(object sender, EventArgs e) { if (MessageBox.Show((LanguageManager.Get("LevelChooser", "replaceclipboard")), (LanguageManager.Get("LevelChooser", "replaceclipboardtitle")), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } try { string leveltxt = Clipboard.GetText(); if (!(leveltxt.StartsWith("NSMBeLevel|") && leveltxt.EndsWith("|"))) { throw new Exception(); } leveltxt = leveltxt.Substring(11, leveltxt.Length - 12); byte[] levelfile = ROM.LZ77_Decompress(Convert.FromBase64String(leveltxt)); ByteArrayInputStream strm = new ByteArrayInputStream(levelfile); BinaryReader br = new BinaryReader(strm); string LevelFilename = (string)levelTreeView.SelectedNode.Tag; NSMBe4.DSFileSystem.File LevelFile = ROM.FS.getFileByName(LevelFilename + ".bin"); NSMBe4.DSFileSystem.File BGFile = ROM.FS.getFileByName(LevelFilename + "_bgdat.bin"); new ExportedLevel(br).Import(LevelFile, BGFile); br.Close(); } catch (Exception ex) { MessageBox.Show((LanguageManager.Get("LevelChooser", "clipinvalidlevel"))); } }
private void populateListBox(ListBox listBox, int maxID, string listName) { List <String> strings = LanguageManager.GetList(listName); listBox.BeginUpdate(); listBox.Items.Clear(); for (int i = 0; i < maxID; i++) { listBox.Items.Add(string.Format(LanguageManager.Get("BehaviorEditor", "unknown"), i)); } foreach (string item in strings) { int where = item.IndexOf('='); int idx; if (item.StartsWith("0x")) { idx = int.Parse(item.Substring(2, where - 2), System.Globalization.NumberStyles.AllowHexSpecifier); } else { idx = int.Parse(item.Substring(0, where)); } string text = item.Substring(where + 1); listBox.Items[idx] = text; } listBox.EndUpdate(); }
public bool export() { checkStuff(); SaveFileDialog ofd = new SaveFileDialog(); ofd.Filter = LanguageManager.Get("Filters", "png"); if (ofd.ShowDialog(win) == DialogResult.Cancel) { return(false); } calcSizes(); Bitmap b = new Bitmap(tx, ty); Graphics bgfx = Graphics.FromImage(b); int x = 0; foreach (PixelPalettedImage img in imgs) { int y = 0; foreach (Palette pal in pals) { Bitmap bb = img.render(pal); bgfx.DrawImage(bb, x, y, bb.Width, bb.Height); bb.Dispose(); y += tys; } x += img.getWidth(); } b.Save(ofd.FileName); b.Dispose(); return(true); }
private void updateParamTypeAndData() { List <ParamTypes> paramTypes = effectiveParamTypes(currentFlags, currentSubType); useParamType(paramTypes[0]); refreshParamData(); if (paramTypes.Count == 1) { string typeName = LanguageManager.Get("BehaviorEditor", "type_" + getInternalLangNameForParamType(paramTypes[0])); paramsLabel.Text = string.Format( LanguageManager.Get("BehaviorEditor", "params_normal"), typeName); } else { string[] typeNames = new string[paramTypes.Count]; for (int i = 0; i < paramTypes.Count; i++) { typeNames[i] = LanguageManager.Get("BehaviorEditor", "type_" + getInternalLangNameForParamType(paramTypes[i])); } paramsLabel.Text = string.Format( LanguageManager.Get("BehaviorEditor", "params_conflict"), string.Join(", ", typeNames)); } }
public ExportedLevel(System.IO.BinaryReader br) { string Header = br.ReadString(); if (Header != fileHeader) { throw new Exception(LanguageManager.Get("NSMBLevel", "InvalidFile")); } ushort FileVersion = br.ReadUInt16(); if (FileVersion > version) { throw new Exception(LanguageManager.Get("NSMBLevel", "OldVersion")); } LevelFileID = br.ReadUInt16(); BGDatFileID = br.ReadUInt16(); int LevelFileLength = br.ReadInt32(); LevelFile = br.ReadBytes(LevelFileLength); int BGFileLength = br.ReadInt32(); BGDatFile = br.ReadBytes(BGFileLength); }
public SpriteEventsViewer(LevelEditorControl ed) { InitializeComponent(); this.ed = ed; spriteTable.DataSource = spriteList; LanguageManager.ApplyToContainer(this, "SpriteEvents"); this.EventID.HeaderText = LanguageManager.Get("SpriteEvents", "EventID"); this.SpriteNum.HeaderText = LanguageManager.Get("SpriteEvents", "SpriteNumber"); this.SpriteName.HeaderText = LanguageManager.Get("SpriteEvents", "SpriteName"); }
private void editTileset_Click(object sender, EventArgs e) { try { new TilesetEditor(Level.Blocks[0][0xC], "").Show(); } catch (AlreadyEditingException) { MessageBox.Show(LanguageManager.Get("Errors", "Tileset")); } }
private void openClipboard_Click(object sender, EventArgs e) { try { new LevelEditor(new NSMBLevel(new ClipboardLevelSource())).Show(); } catch (Exception ex) { MessageBox.Show(LanguageManager.Get("LevelChooser", "clipinvalidlevel")); } }
private void openTilesetButton_Click(object sender, EventArgs e) { try { new TilesetEditor((ushort)tilesetComboBox.SelectedIndex, (string)tilesetComboBox.SelectedItem).Show(); } catch (AlreadyEditingException) { MessageBox.Show(LanguageManager.Get("Errors", "Tileset")); } Close(); }
private void editNoharaSubButton_Click(object sender, EventArgs e) { try { new TilesetEditor(65534, "Nohara SubUnit").Show(); } catch (AlreadyEditingException) { MessageBox.Show(LanguageManager.Get("Errors", "Tileset")); } Close(); }
private void openRomButton_Click(object sender, EventArgs e) { string path = ""; string[] backups = null; if (Properties.Settings.Default.BackupFiles != "" && MessageBox.Show(LanguageManager.Get("StartForm", "OpenBackups"), LanguageManager.Get("StartForm", "OpenBackupsTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes) { backups = Properties.Settings.Default.BackupFiles.Split(';'); path = backups[0]; } else { OpenFileDialog openROMDialog = new OpenFileDialog(); openROMDialog.Filter = LanguageManager.Get("Filters", "rom"); if (Properties.Settings.Default.ROMFolder != "") { openROMDialog.InitialDirectory = Properties.Settings.Default.ROMFolder; } if (openROMDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = openROMDialog.FileName; } } if (path == "") { return; } try { NitroROMFilesystem fs = new NitroROMFilesystem(path); Properties.Settings.Default.ROMFolder = System.IO.Path.GetDirectoryName(path); Properties.Settings.Default.Save(); if (backups != null) { for (int l = 1; l < backups.Length; l++) { ROM.fileBackups.Add(backups[l]); } } run(fs); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void changeLanguageButton_Click(object sender, EventArgs e) { if (languageListBox.SelectedItem != null) { Properties.Settings.Default.LanguageFile = languageListBox.SelectedItem.ToString(); Properties.Settings.Default.Save(); MessageBox.Show( LanguageManager.Get("LevelChooser", "LangChanged"), LanguageManager.Get("LevelChooser", "LangChangedTitle"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void exportTilesetBtn_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = LanguageManager.Get("Filters", "tileset"); if (sfd.ShowDialog() != DialogResult.OK) { return; } NSMBTileset t = loadTileset(getSelectedID()); t.exportTileset(sfd.FileName); }
public override string ToString() { string type; if (topLayer) { type = LanguageManager.Get("BackgroundList", "top"); } else { type = LanguageManager.Get("BackgroundList", "bottom"); } return(type + " " + name); }
public bool import() { checkStuff(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = LanguageManager.Get("Filters", "png"); if (ofd.ShowDialog() == DialogResult.Cancel) { return(false); } calcSizes(); Bitmap b = new Bitmap(ofd.FileName); if (b.Width != tx || b.Height != ty) { throw new Exception("Wrong input image size"); } List <Bitmap> bl = new List <Bitmap>(); for (int i = 0; i < pals.Count; i++) { Bitmap bbb = new Bitmap(b.Width, tys); Graphics bbbgfx = Graphics.FromImage(bbb); bbbgfx.DrawImage(b, 0, -i * tys, b.Width, b.Height); bl.Add(bbb); } b.Dispose(); ImageIndexer ii = new ImageIndexer(bl, pals[0].pal.Length, true, 0); int x = 0; foreach (PixelPalettedImage i in imgs) { i.setPixelData(ii.imageData, x, 0); x += i.getWidth(); } for (int i = 0; i < pals.Count; i++) { pals[i].pal = ii.palettes[i]; } return(false); }
private void mpPatch_Click(object sender, EventArgs e) { NarcReplace("Dat_Field.narc", "J01_1.bin"); NarcReplace("Dat_Basement.narc", "J02_1.bin"); NarcReplace("Dat_Ice.narc", "J03_1.bin"); NarcReplace("Dat_Pipe.narc", "J04_1.bin"); NarcReplace("Dat_Fort.narc", "J05_1.bin"); NarcReplace("Dat_Field.narc", "J01_1_bgdat.bin"); NarcReplace("Dat_Basement.narc", "J02_1_bgdat.bin"); NarcReplace("Dat_Ice.narc", "J03_1_bgdat.bin"); NarcReplace("Dat_Pipe.narc", "J04_1_bgdat.bin"); NarcReplace("Dat_Fort.narc", "J05_1_bgdat.bin"); MessageBox.Show(LanguageManager.Get("General", "Completed")); }
private void importTilesetBtn_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = LanguageManager.Get("Filters", "tileset"); ofd.CheckFileExists = true; if (ofd.ShowDialog() != DialogResult.OK) { return; } NSMBTileset t = loadTileset(getSelectedID()); t.importTileset(ofd.FileName); }
public static void Load() { datas = new Dictionary <int, SpriteData>(); if (!File.Exists(path)) { if (MessageBox.Show(LanguageManager.Get("SpriteData", "Prompt"), LanguageManager.Get("SpriteData", "PromptTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { update(); } else { return; } } try { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); XmlReader xmlr = XmlReader.Create(fs); xmlr.ReadToFollowing("category"); do { int id = int.Parse(xmlr.GetAttribute("id")); categoryIds.Add(id); categories.Add(xmlr.ReadElementContentAsString()); spritesInCategory.Add(id, new List <int>()); } while (xmlr.ReadToNextSibling("category")); while (xmlr.ReadToFollowing("sprite")) { SpriteData d = readFromStream(xmlr); if (d != null) { datas.Add(d.spriteID, d); } } xmlr.Close(); fs.Close(); } catch (Exception e) { MessageBox.Show(LanguageManager.Get("SpriteData", "ErrorParse"), LanguageManager.Get("SpriteData", "ErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); datas.Clear(); } }
private void RenameBtn_Click(object sender, EventArgs e) { string newName; BackgroundEntry bg = tilesetListBox.SelectedItem as BackgroundEntry; string listName = bg.topLayer ? "Foregrounds" : "Backgrounds"; if (textForm.ShowDialog(LanguageManager.Get("BackgroundList", "renamePrompt"), bg.name, out newName) == DialogResult.OK) { if (newName == string.Empty) { ROM.UserInfo.removeListItem(listName, bg.id, true); tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, LanguageManager.GetList(listName)[bg.id]); return; } ROM.UserInfo.setListItem(listName, bg.id, newName, true); tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, newName); } }
public bool ForceClose() { if (Dirty) { DialogResult dr; dr = MessageBox.Show(LanguageManager.Get("LevelHexEditor", "UnsavedLevel"), LanguageManager.Get("General", "Question"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { Save(); } else if (dr == DialogResult.Cancel) { return(true); } } return(false); }