private NSMBTileset loadTileset(ushort TilesetID) { NSMBGraphics g = new NSMBGraphics(); int TilesetNumber; if (TilesetID == 65535) { // load Jyotyu g.LoadTilesets(0); TilesetNumber = 0; } else if (TilesetID == 65534) { // load Nohara_sub g.LoadTilesets(2); TilesetNumber = 2; } else { // load a normal tileset g.LoadTilesets(TilesetID); TilesetNumber = 1; } return(g.Tilesets[TilesetNumber]); }
public void load(NSMBGraphics g, int TilesetNumber) { this.tnum = TilesetNumber; this.tls = g.Tilesets[tnum]; tilePicker1.init(new Bitmap[] { tls.map16.buffer }, 16); previewObject = new NSMBObject(0, tnum, 0, 0, 6, 6, g); }
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); }
public void Initialise(NSMBGraphics GFXd, int tileset) { if (inited) { return; } inited = true; gfx = GFXd; this.tileset = tileset; LoadObjects(); }
public void Initialise(NSMBGraphics GFXd) { if (inited) { return; } inited = true; GFX = GFXd; Ready = true; LoadObjects(); }
public NSMBObject(NSMBObject o) // clone constructor: returns an identical object { this.ObjNum = o.ObjNum; this.Tileset = o.Tileset; this.GFX = o.GFX; this.X = o.X; this.Y = o.Y; this.Width = o.Width; this.Height = o.Height; CachedObj = new int[Width, Height]; UpdateObjCache(); }
public NSMBObject(int ObjNum, int Tileset, int X, int Y, int Width, int Height, NSMBGraphics GFX) { this.ObjNum = ObjNum; this.Tileset = Tileset; this.GFX = GFX; this.X = X; this.Y = Y; this.Width = Width; this.Height = Height; CachedObj = new int[Width, Height]; UpdateObjCache(); }
public void Initialise(NSMBGraphics GFX, NSMBLevel Level, LevelEditor editor) { this.GFX = GFX; this.Level = Level; this.editor = editor; Ready = true; hScrollBar.Visible = true; vScrollBar.Visible = true; ViewablePixels = new Rectangle(); ViewableBlocks = new Rectangle(); UpdateScrollbars(); remakeTileCache(); DrawingArea.Invalidate(); }
public static NSMBObject FromString(String[] strs, ref int idx, NSMBGraphics gfx) { NSMBObject o = new NSMBObject( int.Parse(strs[6 + idx]), int.Parse(strs[5 + idx]), int.Parse(strs[1 + idx]), int.Parse(strs[2 + idx]), int.Parse(strs[3 + idx]), int.Parse(strs[4 + idx]), gfx); idx += 7; return(o); }
public NSMBLevel(LevelSource source) { this.source = source; this.name = source.getLevelName(); byte[] eLevelFile = source.getData(); byte[] eBGFile = source.getBGDatData(); int FilePos; // Level loading time yay. // Since I don't know the format for every block, I will just load them raw. Blocks = new byte[][] { null, null, null, null, null, null, null, null, null, null, null, null, null, null }; FilePos = 0; for (int BlockIdx = 0; BlockIdx < 14; BlockIdx++) { int BlockOffset = eLevelFile[FilePos] | (eLevelFile[FilePos + 1] << 8) | (eLevelFile[FilePos + 2] << 16) | eLevelFile[FilePos + 3] << 24; FilePos += 4; int BlockSize = eLevelFile[FilePos] | (eLevelFile[FilePos + 1] << 8) | (eLevelFile[FilePos + 2] << 16) | eLevelFile[FilePos + 3] << 24; FilePos += 4; Blocks[BlockIdx] = new byte[BlockSize]; Array.Copy(eLevelFile, BlockOffset, Blocks[BlockIdx], 0, BlockSize); } byte TilesetID = Blocks[0][0x0C]; byte BGNSCID = Blocks[2][2]; GFX = new NSMBGraphics(); GFX.LoadTilesets(TilesetID, BGNSCID); // Now objects. int ObjectCount = eBGFile.Length / 10; Objects = new List <NSMBObject>(ObjectCount); FilePos = 0; for (int ObjectIdx = 0; ObjectIdx < ObjectCount; ObjectIdx++) { int ObjID = eBGFile[FilePos] | (eBGFile[FilePos + 1] << 8); //int ObjX = eBGFile[FilePos + 2] | (eBGFile[FilePos + 3] << 8); //int ObjY = eBGFile[FilePos + 4] | (eBGFile[FilePos + 5] << 8); int ObjX = BitConverter.ToInt16(eBGFile, FilePos + 2); int ObjY = BitConverter.ToInt16(eBGFile, FilePos + 4); int ObjWidth = eBGFile[FilePos + 6] | (eBGFile[FilePos + 7] << 8); int ObjHeight = eBGFile[FilePos + 8] | (eBGFile[FilePos + 9] << 8); Objects.Add(new NSMBObject(ObjID & 4095, (ObjID & 61440) >> 12, ObjX, ObjY, ObjWidth, ObjHeight, GFX)); FilePos += 10; } /* * Sprite struct: * Offs Len Dat * 0x0 2 Sprite id * 0x2 2 X * 0x4 2 Y * 0x6 6 Dat * 0xD end */ // Sprites byte[] SpriteBlock = Blocks[6]; int SpriteCount = (SpriteBlock.Length - 2) / 12; Sprites = new List <NSMBSprite>(SpriteCount); FilePos = 0; for (int SpriteIdx = 0; SpriteIdx < SpriteCount; SpriteIdx++) { NSMBSprite Sprite = new NSMBSprite(this); Sprite.Type = SpriteBlock[FilePos] | (SpriteBlock[FilePos + 1] << 8); Sprite.X = SpriteBlock[FilePos + 2] | (SpriteBlock[FilePos + 3] << 8); Sprite.Y = SpriteBlock[FilePos + 4] | (SpriteBlock[FilePos + 5] << 8); Sprite.Data = new byte[6]; FilePos += 6; Sprite.Data[0] = SpriteBlock[FilePos + 1]; Sprite.Data[1] = SpriteBlock[FilePos + 0]; Sprite.Data[2] = SpriteBlock[FilePos + 5]; Sprite.Data[3] = SpriteBlock[FilePos + 4]; Sprite.Data[4] = SpriteBlock[FilePos + 3]; Sprite.Data[5] = SpriteBlock[FilePos + 2]; // Array.Copy(SpriteBlock, FilePos + 6, Sprite.Data, 0, 6); Sprites.Add(Sprite); FilePos += 6; } // Entrances. byte[] EntranceBlock = Blocks[5]; int EntranceCount = EntranceBlock.Length / 20; Entrances = new List <NSMBEntrance>(EntranceCount); FilePos = 0; for (int EntIdx = 0; EntIdx < EntranceCount; EntIdx++) { NSMBEntrance Entrance = new NSMBEntrance(); Entrance.X = EntranceBlock[FilePos] | (EntranceBlock[FilePos + 1] << 8); Entrance.Y = EntranceBlock[FilePos + 2] | (EntranceBlock[FilePos + 3] << 8); Entrance.CameraX = EntranceBlock[FilePos + 4] | (EntranceBlock[FilePos + 5] << 8); Entrance.CameraY = EntranceBlock[FilePos + 6] | (EntranceBlock[FilePos + 7] << 8); Entrance.Number = EntranceBlock[FilePos + 8]; Entrance.DestArea = EntranceBlock[FilePos + 9]; Entrance.ConnectedPipeID = EntranceBlock[FilePos + 10]; Entrance.DestEntrance = EntranceBlock[FilePos + 12]; Entrance.Type = EntranceBlock[FilePos + 14]; Entrance.Settings = EntranceBlock[FilePos + 15]; Entrance.Unknown1 = EntranceBlock[FilePos + 16]; Entrance.EntryView = EntranceBlock[FilePos + 18]; Entrance.Unknown2 = EntranceBlock[FilePos + 19]; //Array.Copy(EntranceBlock, FilePos, Entrance.Data, 0, 20); Entrances.Add(Entrance); FilePos += 20; } // Views ByteArrayInputStream ViewBlock = new ByteArrayInputStream(Blocks[7]); ByteArrayInputStream CamBlock = new ByteArrayInputStream(Blocks[1]); Views = new List <NSMBView>(); while (ViewBlock.lengthAvailable(16)) { Views.Add(NSMBView.read(ViewBlock, CamBlock)); } // Zones ByteArrayInputStream ZoneBlock = new ByteArrayInputStream(Blocks[8]); Zones = new List <NSMBView>(); while (ZoneBlock.lengthAvailable(12)) { Zones.Add(NSMBView.readZone(ZoneBlock)); } // Paths ByteArrayInputStream PathBlock = new ByteArrayInputStream(Blocks[10]); ByteArrayInputStream PathNodeBlock = new ByteArrayInputStream(Blocks[12]); Paths = new List <NSMBPath>(); while (!PathBlock.end()) { Paths.Add(NSMBPath.read(PathBlock, PathNodeBlock, false)); } PathBlock = new ByteArrayInputStream(Blocks[9]); PathNodeBlock = new ByteArrayInputStream(Blocks[11]); ProgressPaths = new List <NSMBPath>(); while (!PathBlock.end()) { ProgressPaths.Add(NSMBPath.read(PathBlock, PathNodeBlock, true)); } //Extra Data (decompiled, so messy code) byte[] block3 = this.Blocks[13]; int capacity4 = (block3.Length - 16) / 16; int num4 = 16; this.ExtraData = new List <NSMBExtraData>(capacity4); for (int index2 = 0; index2 < capacity4; ++index2) { NSMBExtraData nsmbExtraData = new NSMBExtraData(); for (int index3 = 0; index3 < 16; ++index3) { nsmbExtraData.data[index3] = block3[num4 + index3]; } this.ExtraData.Add(nsmbExtraData); num4 += 16; } CalculateSpriteModifiers(); repaintAllTilemap(); }
public PickerTest(NSMBGraphics g) { InitializeComponent(); objectPickerControlNew1.Initialise(g, 1); this.Icon = Properties.Resources.nsmbe; }
public TilesetEditor(ushort TilesetID, string tilesetName) { InitializeComponent(); if (Properties.Settings.Default.mdi) { this.MdiParent = MdiParentForm.instance; } LanguageManager.ApplyToContainer(this, "TilesetEditor"); savePNG.Filter = LanguageManager.Get("Filters", "png"); openPNG.Filter = LanguageManager.Get("Filters", "png"); saveTileset.Filter = LanguageManager.Get("Filters", "tileset"); openTileset.Filter = LanguageManager.Get("Filters", "tileset"); Text = string.Format(LanguageManager.Get("TilesetEditor", "_TITLE"), tilesetName); g = new NSMBGraphics(); this.TilesetID = TilesetID; if (TilesetID == 65535) { // load Jyotyu g.LoadTilesets(0); TilesetNumber = 0; } else if (TilesetID == 65534) { // load Nohara_sub g.LoadTilesets(2); TilesetNumber = 2; } else { // load a normal tileset g.LoadTilesets(TilesetID); TilesetNumber = 1; } t = g.Tilesets[TilesetNumber]; t.beginEdit(); objectPickerControl1.Initialise(g); objectPickerControl1.CurrentTileset = TilesetNumber; tilesetObjectEditor1.load(g, TilesetNumber); tilemapEditor1.load(t.map16); imageManager1.addImage(t.graphics); for (int i = 0; i < t.palettes.Length; i++) { imageManager1.addPalette(t.palettes[i]); } tileBehaviorPicker.init(new Bitmap[] { t.Map16Buffer }, 16); //FIXME // graphicsEditor1.SaveGraphics += new GraphicsEditor.SaveGraphicsHandler(graphicsEditor1_SaveGraphics); descExists = ROM.UserInfo.descriptions.ContainsKey(TilesetID); //Fild in there are descriptions for the tileset deleteDescriptions.Visible = descExists; //Make the appropriate button visible createDescriptions.Visible = !descExists; tilesetObjectEditor1.descBox.Visible = descExists; //Hide or show the description text box tilesetObjectEditor1.descLbl.Visible = descExists; if (descExists) { descriptions = ROM.UserInfo.descriptions[TilesetID]; //Get the descriptions tilesetObjectEditor1.descBox.Text = descriptions[0]; //Fill the description box with that of the first object } this.Icon = Properties.Resources.nsmbe; }