public void Remove(string l2) { // Remove it from the serialized form if (newObjectsData.ContainsKey(l2)) { newObjectsData.Remove(l2); SerializeObjects(); } // Remove all instances of it foreach (Board board in multiBoard.Boards) { for (int i = 0; i < board.BoardItems.TileObjs.Count; i++) { LayeredItem li = board.BoardItems.TileObjs[i]; if (li is ObjectInstance) { ObjectInfo oi = (ObjectInfo)li.BaseInfo; if (oi.oS == oS && oi.l0 == l0 && oi.l1 == l1 && oi.l2 == l2) { li.RemoveItem(null); i--; } } } } // Search it in newObjects foreach (ObjectInfo oi in newObjects) { if (oi.l2 == l2) { newObjects.Remove(oi); oi.ParentObject.Remove(); return; } } // Search it in wz objects foreach (WzImageProperty prop in l1prop.WzProperties) { if (prop.Name == l2) { prop.Remove(); // We removed a property that existed in the file already, so we must set it as updated SetOsUpdated(); return; } } throw new Exception("Could not find " + l2 + " in userObjs"); }
/// <summary> /// Adds a map tile to the layer /// </summary> /// <param name="tileParent">Parent of the new tile</param> /// <param name="name">Name of the new tile</param> /// <param name="boardTile">Board tile that contains the new properties</param> // /// <returns>The new object</returns> public static void AddMapTile(WzSubProperty tileParent, String name, LayeredItem boardTile) { WzSubProperty newObj = new WzSubProperty(name); //newObj.Parent = tileParent; tileParent.AddProperty(newObj); if (((WzSubProperty)tileParent.Parent)["info"]["tS"] == null) ((WzSubProperty)((WzSubProperty)tileParent.Parent)["info"]).AddProperty(new WzStringProperty("tS", ((TileInfo)boardTile.BaseInfo).tS)); else ((WzStringProperty)((WzSubProperty)tileParent.Parent)["info"]["tS"]).Value = ((TileInfo)boardTile.BaseInfo).tS; newObj.AddProperty(new WzStringProperty("u", ((TileInfo)boardTile.BaseInfo).u)); newObj.AddProperty(new WzCompressedIntProperty("no", Int32.Parse(((TileInfo)boardTile.BaseInfo).no))); newObj.AddProperty(new WzCompressedIntProperty("x", boardTile.X)); newObj.AddProperty(new WzCompressedIntProperty("y", boardTile.Y)); newObj.AddProperty(new WzCompressedIntProperty("z", boardTile.Z)); newObj.AddProperty(new WzCompressedIntProperty("zM", boardTile.Z)); tileParent.ParentImage.Changed = true; //return newObj; }
/// <summary> /// Adds a map object to the layer /// </summary> /// <param name="objParent">Parent of the new object</param> /// <param name="name">Name of the new object</param> /// <param name="boardObj">Board object that contains the new properties</param> public static void AddMapObj(WzSubProperty objParent, String name, LayeredItem boardObj) { WzSubProperty newObj = new WzSubProperty(name); //newObj.Parent = objParent; objParent.AddProperty(newObj); newObj.AddProperty(new WzStringProperty("oS", ((ObjectInfo)boardObj.BaseInfo).oS)); newObj.AddProperty(new WzStringProperty("l0", ((ObjectInfo)boardObj.BaseInfo).l0)); newObj.AddProperty(new WzStringProperty("l1", ((ObjectInfo)boardObj.BaseInfo).l1)); newObj.AddProperty(new WzStringProperty("l2", ((ObjectInfo)boardObj.BaseInfo).l2)); newObj.AddProperty(new WzCompressedIntProperty("x", boardObj.X)); newObj.AddProperty(new WzCompressedIntProperty("y", boardObj.Y)); newObj.AddProperty(new WzCompressedIntProperty("z", boardObj.Z)); newObj.AddProperty(new WzCompressedIntProperty("zM", boardObj.Z)); objParent.ParentImage.Changed = true; //return newObj; }
/// <summary> /// Overwrites a (mapid).img tile property /// </summary> /// <param name="tile">The tile that is being edited</param> /// <param name="boardTile">The Board tile that has the edited properties</param> public static void overWriteTile(WzSubProperty tile, LayeredItem boardTile) { //Yes, I know I could have easily made overWriteObj check for if it's a tile or obj instance //but this class needs more methods in it -DeathRight if (tile != null) { //OOOOOOH, I JUST GOT THAT, 'tS' stands for Tile Source, and 'oS' stands for Object Source //better put that in the Tile/ObjectInfo property summarys! -DeathRight ((WzStringProperty)((WzSubProperty)tile.Parent.Parent)["info"]["tS"]).Value = ((TileInfo)boardTile.BaseInfo).tS; ((WzStringProperty)tile["u"]).Value = ((TileInfo)boardTile.BaseInfo).u; ((WzCompressedIntProperty)tile["no"]).Value = Int32.Parse(((TileInfo)boardTile.BaseInfo).no); ((WzCompressedIntProperty)tile["x"]).Value = boardTile.X; ((WzCompressedIntProperty)tile["y"]).Value = boardTile.Y; //Wtf? There's a Z but it's not a property in tiles? Well, not needed I guess -DeathRight tile.ParentImage.Changed = true; } }
/// <summary> /// Overwrites a (mapid).img object property /// </summary> /// <param name="obj">The object that is being edited</param> /// <param name="boardObj">The Board object that has the edited properties</param> public static void overWriteObj(WzSubProperty obj, LayeredItem boardObj) { if (obj != null) { ((WzStringProperty)obj["oS"]).Value = ((ObjectInfo)boardObj.BaseInfo).oS; ((WzStringProperty)obj["l0"]).Value = ((ObjectInfo)boardObj.BaseInfo).l0; ((WzStringProperty)obj["l1"]).Value = ((ObjectInfo)boardObj.BaseInfo).l1; ((WzStringProperty)obj["l2"]).Value = ((ObjectInfo)boardObj.BaseInfo).l2; ((WzCompressedIntProperty)obj["x"]).Value = boardObj.X; ((WzCompressedIntProperty)obj["y"]).Value = boardObj.Y; ((WzCompressedIntProperty)obj["z"]).Value = boardObj.Z; obj.ParentImage.Changed = true; } }