private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { clearRoom(); //add layout objects ! string f = (string)listBox1.Items[listBox1.SelectedIndex]; BinaryReader br = new BinaryReader(new FileStream("Layout\\" + f, FileMode.Open, FileAccess.Read)); string type = br.ReadString(); List <SaveObject> data = new List <SaveObject>(); while (br.BaseStream.Position != br.BaseStream.Length) { data.Add(new SaveObject(br, typeof(Room_Object))); } foreach (SaveObject o in data) { if (o.type == typeof(Room_Object)) { Room_Object ro = scene.room.addObject(o.tid, (byte)(o.x), (byte)(o.y), o.size, o.layer); if (ro != null) { ro.setRoom(scene.room); ro.options = o.options; scene.room.tilesObjects.Add(ro); } } } scene.room.reloadGfx(); scene.DrawRoom(); scene.Refresh(); }
public void addSpecialErasedDraw() { borderlessobject.Clear(); for (int i = 0; i < room.tilesObjects.Count - 1; i++) { Room_Object o = room.tilesObjects[i]; o.specialDraw = false; if (o is object_69 || o is object_8A || o is object_3F || o is object_40 || o is object_41 || o is object_42 || o is object_43 || o is object_44 || o is object_46 || o is object_2A || o is object_29 || o is object_22) { borderlessobject.Add(o); } foreach (Room_Object bo in borderlessobject) { if (o is object_69 || o is object_8A || o is object_3F || o is object_40 || o is object_41 || o is object_42 || o is object_43 || o is object_44 || o is object_46 || o is object_2A || o is object_29 || o is object_22) { if (o != bo) { if (new Rectangle(o.nx * 8, o.ny * 8, 8, 8).IntersectsWith(new Rectangle(bo.nx * 8, bo.ny * 8, bo.width, bo.height))) { o.specialDraw = true; } } } } } }
private void ObjectViewer_MouseClick(object sender, MouseEventArgs e) { int w = (this.Size.Width / 64); int h = (((items.Count / w) + 1) * 64); int xpos = 0; int ypos = 0; int index = 0; this.Size = new Size(this.Size.Width, h); foreach (Room_Object o in items) { if (index < items.Count) { Rectangle itemRect = new Rectangle(xpos * 64, ypos * 64, 64, 64); if (itemRect.Contains(new Point(e.X, e.Y))) { selectedIndex = index; selectedObject = o; } xpos++; if (xpos >= w) { xpos = 0; ypos++; } index++; } } OnValueChanged(new EventArgs()); Refresh(); }
public SaveObject(Room_Object o) //Room_Object { this.x = o.x; this.y = o.y; this.tid = o.id; this.layer = o.layer; this.size = o.size; this.options = o.options; type = typeof(Room_Object); }
private void ObjectViewer_MouseClick(object sender, MouseEventArgs e) { int w = (this.Size.Width / 64); int h = (((items.Count / w) + 1) * 64); int xpos = 0; int ypos = 0; int index = 0; this.Size = new Size(this.Size.Width, h); foreach (Room_Object o in items) { if (index < items.Count) { Rectangle itemRect = new Rectangle(xpos * 64, ypos * 64, 64, 64); Rectangle itemstarRect = new Rectangle((xpos * 64) + 44, (ypos * 64) + 44, 16, 16); if (itemRect.Contains(new Point(e.X, e.Y))) { selectedIndex = index; selectedObject = o; if (itemstarRect.Contains((new Point(e.X, e.Y)))) { //Make Favourite or not if (Settings.Default.favoriteObjects[o.id] == "true") { Settings.Default.favoriteObjects[o.id] = "false"; } else { Settings.Default.favoriteObjects[o.id] = "true"; } } OnValueChanged(new EventArgs()); Refresh(); return; } xpos++; if (xpos >= w) { xpos = 0; ypos++; } index++; } } }
public void drawObject(Graphics g, Room_Object o) { if ((o.options & ObjectOption.Door) != ObjectOption.Door) { if (o.specialDraw) { if (o is object_69 || o is object_8A) //vertical objects { g.DrawImage(o.bitmap, o.nx * 8, ((o.drawYFix * 8) + o.ny * 8) + 8, new Rectangle(0, 8, o.bitmap.Width, o.bitmap.Height), GraphicsUnit.Pixel); } else if (o is object_3F || o is object_40 || o is object_41 || o is object_42 || o is object_43 || o is object_44 || o is object_46 || o is object_2A || o is object_29 || o is object_22) //horizontal objects { g.DrawImage(o.bitmap, (o.nx * 8) + 8, ((o.drawYFix * 8) + o.ny * 8), new Rectangle(8, 0, o.bitmap.Width, o.bitmap.Height), GraphicsUnit.Pixel); } } else { g.DrawImage(o.bitmap, o.nx * 8, (o.drawYFix * 8) + o.ny * 8); } } }
public void readTiles(BinaryReader br) { short count = br.ReadInt16(); for (int j = 0; j < count; j++) { //<Tiles Objects Data> //short ID ,byte X, byte Y, byte Layer short id = br.ReadInt16(); byte x = br.ReadByte(); byte y = br.ReadByte(); byte size = br.ReadByte(); byte layer = br.ReadByte(); ObjectOption options = (ObjectOption)br.ReadByte(); if ((options & ObjectOption.Door) == ObjectOption.Door) { Room_Object o = new object_door(id, x, y, size, layer); if (o != null) { o.options = (ObjectOption)options; o.setRoom(activeScene.room); activeScene.room.tilesObjects.Add(o); } } else { Room_Object o = activeScene.room.addObject(id, x, y, size, layer); if (o != null) { o.options = (ObjectOption)options; o.setRoom(activeScene.room); activeScene.room.tilesObjects.Add(o); } } } }
public void drawSelection(Graphics graphics) { foreach (Object o in room.selectedObject) { if (o is Sprite) { graphics.DrawRectangle(Pens.Green, (o as Sprite).boundingbox); } else if (o is PotItem) { graphics.DrawRectangle(Pens.Green, new Rectangle((o as PotItem).nx * 8, (o as PotItem).ny * 8, 16, 16)); } else if (o is Room_Object) { Room_Object obj = (o as Room_Object); int yfix = 0; if (obj.diagonalFix) { yfix = -(6 + obj.size); } graphics.DrawRectangle(Pens.Green, new Rectangle((obj.nx + obj.offsetX) * 8, (obj.ny + obj.offsetY + yfix) * 8, obj.width, obj.height)); } } if (mouse_down) { int rx = dragx; int ry = dragy; if (move_x < 0) { Math.Abs(rx = dragx + move_x); } if (move_y < 0) { Math.Abs(ry = dragy + move_y); } if (room.selectedObject.Count == 0) { if (selectedMode == ObjectMode.Spritemode) { graphics.DrawRectangle(new Pen(Brushes.White), new Rectangle(rx * 16, ry * 16, Math.Abs(move_x) * 16, Math.Abs(move_y) * 16)); } else { graphics.DrawRectangle(new Pen(Brushes.White), new Rectangle(rx * 8, ry * 8, Math.Abs(move_x) * 8, Math.Abs(move_y) * 8)); } } foreach (Object o in room.selectedObject) { if (o is Sprite) { graphics.DrawRectangle(Pens.LimeGreen, (o as Sprite).boundingbox); } else if (o is PotItem) { graphics.DrawRectangle(Pens.LimeGreen, new Rectangle((o as PotItem).nx * 8, (o as PotItem).ny * 8, 16, 16)); } else if (o is Room_Object) { Room_Object obj = (o as Room_Object); int yfix = 0; if (obj.diagonalFix) { yfix = -(6 + obj.size); } graphics.DrawRectangle(Pens.LimeGreen, new Rectangle((obj.nx + obj.offsetX) * 8, (obj.ny + obj.offsetY + yfix) * 8, obj.width, obj.height)); } } } }
public void drawSelection(Graphics graphics) { foreach (Object o in room.selectedObject) { if (o is Sprite) { graphics.DrawRectangle(Pens.Green, (o as Sprite).boundingbox); } else if (o is PotItem) { graphics.DrawRectangle(Pens.Green, new Rectangle((o as PotItem).nx * 8, (o as PotItem).ny * 8, 16, 16)); } else if (o is Room_Object) { Room_Object obj = (o as Room_Object); int yfix = 0; if (obj.diagonalFix) { yfix = -(6 + obj.size); } graphics.DrawRectangle(Pens.Green, new Rectangle((obj.nx + obj.offsetX) * 8, (obj.ny + obj.offsetY + yfix) * 8, obj.width, obj.height)); } } if (showBG2Outline) { if (room.bg2 != Background2.Off) { foreach (Room_Object obj in room.tilesObjects) { //Draw doors here since they'll all be put on bg3 anyways if (obj.showRectangle) { int yfix = 0; if (obj.diagonalFix) { yfix = -(6 + obj.size); } graphics.DrawRectangle(Pens.DarkCyan, new Rectangle((obj.nx + obj.offsetX) * 8, (obj.ny + obj.offsetY + yfix) * 8, obj.width, obj.height)); } } } } if (mouse_down) { int rx = dragx; int ry = dragy; if (move_x < 0) { Math.Abs(rx = dragx + move_x); } if (move_y < 0) { Math.Abs(ry = dragy + move_y); } if (room.selectedObject.Count == 0) { if (selectedMode == ObjectMode.Spritemode) { graphics.DrawRectangle(new Pen(Brushes.White), new Rectangle(rx * 16, ry * 16, Math.Abs(move_x) * 16, Math.Abs(move_y) * 16)); } else { graphics.DrawRectangle(new Pen(Brushes.White), new Rectangle(rx * 8, ry * 8, Math.Abs(move_x) * 8, Math.Abs(move_y) * 8)); } } foreach (Object o in room.selectedObject) { if (o is Sprite) { graphics.DrawRectangle(Pens.LimeGreen, (o as Sprite).boundingbox); } else if (o is PotItem) { graphics.DrawRectangle(Pens.LimeGreen, new Rectangle((o as PotItem).nx * 8, (o as PotItem).ny * 8, 16, 16)); } else if (o is Room_Object) { Room_Object obj = (o as Room_Object); int yfix = 0; if (obj.diagonalFix) { yfix = -(6 + obj.size); } graphics.DrawRectangle(Pens.LimeGreen, new Rectangle((obj.nx + obj.offsetX) * 8, (obj.ny + obj.offsetY + yfix) * 8, obj.width, obj.height)); } } } }
public void drawDoors(Graphics g, Room_Object o) { if ((o.options & ObjectOption.Door) == ObjectOption.Door) { if (o is object_door) { if ((o.id & 0xFF00) == 0x1200) { g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; GraphicsPath gpath = new GraphicsPath(); gpath.AddString("Exit", new FontFamily("Consolas"), 1, 12, new Point(o.x * 8, ((o.y) * 8) + 8), StringFormat.GenericDefault); Pen pen = new Pen(Color.FromArgb(30, 30, 30), 2); g.DrawPath(pen, gpath); SolidBrush brush = new SolidBrush(Color.FromArgb(255, 255, 255)); g.FillPath(brush, gpath); return; } if ((o.id & 0xFF00) == 0x1600) { g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; GraphicsPath gpath = new GraphicsPath(); gpath.AddString("toBG2", new FontFamily("Consolas"), 1, 12, new Point(o.x * 8, ((o.y) * 8) + 8), StringFormat.GenericDefault); Pen pen = new Pen(Color.FromArgb(30, 30, 30), 2); g.DrawPath(pen, gpath); SolidBrush brush = new SolidBrush(Color.FromArgb(255, 255, 255)); g.FillPath(brush, gpath); return; } if ((o as object_door).door_dir == 0) { if ((o as object_door).door_pos >= 12) { int drawPos = 9; if ((o as object_door).door_pos <= 16) { drawPos = 9; } else { drawPos = 14; } o.bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); g.DrawImage(o.bitmap, o.nx * 8, (o.y - drawPos) * 8); o.bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); } } else if ((o as object_door).door_dir == 2) { if ((o as object_door).door_pos >= 12) { int drawPos = 7; if ((o as object_door).door_pos <= 16) { drawPos = 7; } else { drawPos = 13; } o.bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); g.DrawImage(o.bitmap, (o.nx - drawPos) * 8, (o.y) * 8); o.bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); } } g.DrawImage(o.bitmap, o.nx * 8, o.ny * 8); } } }