public uint AddCanvas(WzCanvasProperty node) { uint ret = (uint)Canvases.Count; Canvases.Add(node); return(ret); }
/// <summary> /// Load background from WzImageProperty /// </summary> /// <param name="parentObject"></param> /// <param name="spineParentObject"></param> /// <param name="bS"></param> /// <param name="type"></param> /// <param name="no"></param> /// <returns></returns> private static BackgroundInfo Load(WzImageProperty parentObject, string bS, BackgroundInfoType type, string no) { WzCanvasProperty frame0; if (type == BackgroundInfoType.Animation) { frame0 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]); } else if (type == BackgroundInfoType.Spine) { // TODO: make a preview of the spine image ffs WzCanvasProperty spineCanvas = (WzCanvasProperty)parentObject["0"]; if (spineCanvas != null) { Bitmap bitmap = spineCanvas.GetLinkedWzCanvasBitmap(); PointF origin__ = spineCanvas.GetCanvasOriginPosition(); return(new BackgroundInfo(parentObject, bitmap, WzInfoTools.PointFToSystemPoint(origin__), bS, type, no, parentObject)); } else { PointF origin_ = new PointF(); return(new BackgroundInfo(parentObject, Properties.Resources.placeholder, WzInfoTools.PointFToSystemPoint(origin_), bS, type, no, parentObject)); } } else { frame0 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject); } PointF origin = frame0.GetCanvasOriginPosition(); return(new BackgroundInfo(frame0, frame0.GetLinkedWzCanvasBitmap(), WzInfoTools.PointFToSystemPoint(origin), bS, type, no, parentObject)); }
public static PortalInfo Load(WzCanvasProperty parentObject) { PortalInfo portal = new PortalInfo(parentObject.Name, parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), parentObject); Program.InfoManager.Portals.Add(portal.type, portal); return(portal); }
public ObjectInfo Add(Bitmap bmp, string name) { if (!IsNameValid(name)) { throw new NameAlreadyUsedException(); } Point origin = new Point(bmp.Width / 2, bmp.Height / 2); WzSubProperty prop = new WzSubProperty(); WzCanvasProperty canvasProp = new WzCanvasProperty(); canvasProp.PngProperty = new WzPngProperty(); canvasProp.PngProperty.SetImage(bmp); canvasProp["origin"] = new WzVectorProperty("", new WzIntProperty("X", origin.X), new WzIntProperty("Y", origin.Y)); canvasProp["z"] = new WzIntProperty("", 0); prop["0"] = canvasProp; ObjectInfo oi = new ObjectInfo(bmp, origin, oS, Program.APP_NAME, l1, name, prop); newObjects.Add(oi); newObjectsData.Add(name, SaveImageToBytes(bmp)); SerializeObjects(); l1prop[name] = prop; return(oi); }
public static PortalInfo Load(WzCanvasProperty parentObject) { PortalInfo portal = new PortalInfo((PortalType)ptByShortName[parentObject.Name], parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), parentObject); Program.InfoManager.Portals[(int)ptByShortName[parentObject.Name]] = portal; return(portal); }
public void ExtractPortals() { WzSubProperty portalParent = (WzSubProperty)this["map"]["MapHelper.img"]["portal"]; WzSubProperty editorParent = (WzSubProperty)portalParent["editor"]; for (int i = 0; i < editorParent.WzProperties.Count; i++) { WzCanvasProperty portal = (WzCanvasProperty)editorParent.WzProperties[i]; Program.InfoManager.PortalTypeById.Add(portal.Name); PortalInfo.Load(portal); } WzSubProperty gameParent = (WzSubProperty)portalParent["game"]["pv"]; foreach (WzImageProperty portal in gameParent.WzProperties) { if (portal.WzProperties[0] is WzSubProperty) { Dictionary <string, Bitmap> images = new Dictionary <string, Bitmap>(); Bitmap defaultImage = null; foreach (WzSubProperty image in portal.WzProperties) { //WzSubProperty portalContinue = (WzSubProperty)image["portalContinue"]; //if (portalContinue == null) continue; Bitmap portalImage = image["0"].GetBitmap(); if (image.Name == "default") { defaultImage = portalImage; } else { images.Add(image.Name, portalImage); } } Program.InfoManager.GamePortals.Add(portal.Name, new PortalGameImageInfo(defaultImage, images)); } else if (portal.WzProperties[0] is WzCanvasProperty) { Dictionary <string, Bitmap> images = new Dictionary <string, Bitmap>(); Bitmap defaultImage = null; try { foreach (WzCanvasProperty image in portal.WzProperties) { //WzSubProperty portalContinue = (WzSubProperty)image["portalContinue"]; //if (portalContinue == null) continue; Bitmap portalImage = image.GetLinkedWzCanvasBitmap(); defaultImage = portalImage; images.Add(image.Name, portalImage); } Program.InfoManager.GamePortals.Add(portal.Name, new PortalGameImageInfo(defaultImage, images)); } catch (InvalidCastException) { continue; } //nexon likes to toss ints in here zType etc } } for (int i = 0; i < Program.InfoManager.PortalTypeById.Count; i++) { Program.InfoManager.PortalIdByType[Program.InfoManager.PortalTypeById[i]] = i; } }
public TileSetBrowser(ListBox target) { InitializeComponent(); targetListBox = target; styleManager.ManagerStyle = UserSettings.applicationStyle; List <string> sortedTileSets = new List <string>(); foreach (DictionaryEntry tS in Program.InfoManager.TileSets) { sortedTileSets.Add((string)tS.Key); } sortedTileSets.Sort(); foreach (string tS in sortedTileSets) { WzImage tSImage = Program.InfoManager.TileSets[tS]; if (!tSImage.Parsed) { tSImage.ParseImage(); } IWzImageProperty enh0 = tSImage["enH0"]; if (enh0 == null) { continue; } WzCanvasProperty image = (WzCanvasProperty)enh0["0"]; if (image == null) { continue; } //image.PngProperty.GetPNG(true); KoolkLVItem item = koolkLVContainer.createItem(image.PngProperty.GetPNG(true), tS, true); item.MouseDown += new MouseEventHandler(item_Click); item.MouseDoubleClick += new MouseEventHandler(item_DoubleClick); } }
public TileSetBrowser(ListBox target) { InitializeComponent(); targetListBox = target; List <string> sortedTileSets = new List <string>(); foreach (KeyValuePair <string, WzImage> tS in Program.InfoManager.TileSets) { sortedTileSets.Add(tS.Key); } sortedTileSets.Sort(); foreach (string tS in sortedTileSets) { WzImage tSImage = Program.InfoManager.TileSets[tS]; if (!tSImage.Parsed) { tSImage.ParseImage(); } WzImageProperty enh0 = tSImage["enH0"]; if (enh0 == null) { continue; } WzCanvasProperty image = (WzCanvasProperty)enh0["0"]; if (image == null) { continue; } ImageViewer item = koolkLVContainer.Add(image.GetLinkedWzCanvasBitmap(), tS, true); item.MouseDown += new MouseEventHandler(item_Click); item.MouseDoubleClick += new MouseEventHandler(item_DoubleClick); } }
private static ObjectInfo Load(WzSubProperty parentObject, string oS, string l0, string l1, string l2) { WzCanvasProperty frame1 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]); ObjectInfo result = new ObjectInfo( frame1.GetLinkedWzCanvasBitmap(), WzInfoTools.PointFToSystemPoint(frame1.GetCanvasOriginPosition()), oS, l0, l1, l2, parentObject); WzImageProperty chairs = parentObject["seat"]; WzImageProperty ropes = frame1["rope"]; WzImageProperty ladders = frame1["ladder"]; WzImageProperty footholds = frame1["foothold"]; result.footholdOffsets = ParsePropToOffsetMap(footholds); result.ropeOffsets = ParsePropToOffsetMap(ropes); result.ladderOffsets = ParsePropToOffsetMap(ladders); if (chairs != null) { result.chairOffsets = ParsePropToOffsetList(chairs); } return(result); }
/// <summary> /// Loads spine texture from the specified WZ path /// </summary> /// <param name="page"></param> /// <param name="path"></param> public void Load(AtlasPage page, string path) { WzObject frameNode = this.ParentNode[path]; if (frameNode == null) { return; } WzCanvasProperty canvasProperty = null; WzImageProperty imageChild = (WzImageProperty)ParentNode[path]; if (imageChild is WzUOLProperty uolProperty) { WzObject uolLink = uolProperty.LinkValue; if (uolLink is WzCanvasProperty uolPropertyLink) { canvasProperty = uolPropertyLink; } else { // other unimplemented prop? } } else if (imageChild is WzCanvasProperty property) { canvasProperty = property; } if (canvasProperty != null) { Bitmap bitmap = canvasProperty.GetLinkedWzCanvasBitmap(); if (bitmap != null && graphicsDevice != null) { Texture2D tex = new Texture2D(graphicsDevice, bitmap.Width, bitmap.Height, true, SurfaceFormat.Color); BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat); int bufferSize = data.Height * data.Stride; //create data buffer byte[] bytes = new byte[bufferSize]; // copy bitmap data into buffer Marshal.Copy(data.Scan0, bytes, 0, bytes.Length); // copy our buffer to the texture tex.SetData(bytes); // unlock the bitmap data bitmap.UnlockBits(data); page.rendererObject = tex; page.width = bitmap.Width; page.height = bitmap.Height; } } }
private static BackgroundInfo Load(WzImageProperty parentObject, string bS, bool ani, string no) { WzCanvasProperty frame0 = ani ? (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]) : (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject); PointF origin = frame0.GetCanvasOriginPosition(); return(new BackgroundInfo(frame0.GetLinkedWzCanvasBitmap(), WzInfoTools.PointFToSystemPoint(origin), bS, ani, no, parentObject)); }
private void WriteBitmap(WzCanvasProperty node, BinaryWriter bw) { Bitmap b = node.PngProperty.GetBitmap(); byte[] compressed = GetCompressedBitmap(b); bw.Write((uint)compressed.Length); bw.Write(compressed); }
public static ObjectInfo Load(WzSubProperty parentObject, string oS, string l0, string l1, string l2) { WzCanvasProperty frame1 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]); ObjectInfo result = new ObjectInfo(frame1.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)frame1["origin"]), oS, l0, l1, l2, parentObject); WzSubProperty chairs = (WzSubProperty)parentObject["seat"]; IWzImageProperty footholds = (IWzImageProperty)frame1["foothold"]; if (footholds != null) { if (footholds is WzConvexProperty) { result.fullFootholdInfo = false; result.footholdOffsets = new List <XNA.Point>(); foreach (WzVectorProperty fhAnchor in footholds.WzProperties) { result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(fhAnchor)); } } else { result.fullFootholdInfo = true; result.footholdFullOffsets = new List <List <XNA.Point> >(); List <XNA.Point> fhAnchorList = new List <XNA.Point>(); foreach (WzConvexProperty fh in footholds.WzProperties) { foreach (WzVectorProperty fhAnchor in fh.WzProperties) { fhAnchorList.Add(WzInfoTools.VectorToXNAPoint(fhAnchor)); } result.footholdFullOffsets.Add(fhAnchorList); fhAnchorList = new List <XNA.Point>(); } } } //IWzImageProperty ropes = (IWzImageProperty)frame1["ladder"]; if (chairs != null) { result.chairOffsets = new List <XNA.Point>(); foreach (WzVectorProperty chair in chairs.WzProperties) { result.chairOffsets.Add(WzInfoTools.VectorToXNAPoint(chair)); } } /*if (footholds != null) * foreach (WzVectorProperty foothold in footholds.WzProperties) * result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(foothold));*/ /*if (ropes != null && ropes.WzProperties.Count > 0) * if (ropes.WzProperties[0] is WzVectorProperty) * foreach (WzVectorProperty rope in ropes.WzProperties) * result.ropeOffsets.Add(WzInfoTools.VectorToXNAPoint(rope)); * else if (ropes.WzProperties[0] is WzConvexProperty) * foreach (WzConvexProperty convex in ropes.WzProperties) * foreach (WzVectorProperty rope in convex.WzProperties) * result.ropeOffsets.Add(WzInfoTools.VectorToXNAPoint(rope)); * else throw new Exception("wrong rope anchor type at ObjectInfo Load");*/ return(result); }
private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e) { if ((string)mapNamesBox.SelectedItem == "MapLogin" || (string)mapNamesBox.SelectedItem == "MapLogin1" || (string)mapNamesBox.SelectedItem == "CashShopPreview" || mapNamesBox.SelectedItem == null) { linkLabel.Visible = false; mapNotExist.Visible = false; minimapBox.Image = (Image) new Bitmap(1, 1); load = mapNamesBox.SelectedItem != null; } else { string mapid = ((string)mapNamesBox.SelectedItem).Substring(0, 9); string mapcat = "Map" + mapid.Substring(0, 1); WzImage mapImage = (WzImage)Program.WzManager["map"]["Map"][mapcat][mapid + ".img"]; if (mapImage == null) { linkLabel.Visible = false; mapNotExist.Visible = true; minimapBox.Image = (Image) new Bitmap(1, 1); load = false; } else { using (WzImageResource rsrc = new WzImageResource(mapImage)) { if (mapImage["info"]["link"] != null) { linkLabel.Visible = true; mapNotExist.Visible = false; minimapBox.Image = (Image) new Bitmap(1, 1); load = false; } else { linkLabel.Visible = false; mapNotExist.Visible = false; load = true; WzCanvasProperty minimap = (WzCanvasProperty)mapImage.GetFromPath("miniMap/canvas"); if (minimap != null) { minimapBox.Image = (Image)minimap.PngProperty.GetPNG(false); } else { minimapBox.Image = (Image) new Bitmap(1, 1); } load = true; } } GC.Collect(); } } SelectionChanged.Invoke(); }
private void LoadTileSetList() { if (tileSetList.SelectedItem == null) { return; } tileImagesContainer.Controls.Clear(); WzImage tileSetImage = Program.InfoManager.TileSets[(string)tileSetList.SelectedItem]; if (tileSetImage == null) { return; } foreach (WzSubProperty tCat in tileSetImage.WzProperties) { if (tCat.Name == "info") { continue; } if (ApplicationSettings.randomTiles) { WzCanvasProperty canvasProp = (WzCanvasProperty)tCat["0"]; if (canvasProp == null) { continue; } KoolkLVItem item = tileImagesContainer.createItem(canvasProp.PngProperty.GetPNG(false), tCat.Name, true); TileInfo[] randomInfos = new TileInfo[tCat.WzProperties.Count]; for (int i = 0; i < randomInfos.Length; i++) { WzCanvasProperty tile = (WzCanvasProperty)tCat.WzProperties[i]; if (tile.HCTag == null) { tile.HCTag = TileInfo.Load(tile, (string)tileSetList.SelectedItem, tCat.Name, tile.Name); } randomInfos[i] = (TileInfo)tile.HCTag; } item.Tag = randomInfos; item.MouseDown += new MouseEventHandler(tileItem_Click); item.MouseUp += new MouseEventHandler(item_MouseUp); } else { foreach (WzCanvasProperty tile in tCat.WzProperties) { if (tile.HCTag == null) { tile.HCTag = TileInfo.Load(tile, (string)tileSetList.SelectedItem, tCat.Name, tile.Name); } KoolkLVItem item = tileImagesContainer.createItem(tile.PngProperty.GetPNG(false), tCat.Name + "/" + tile.Name, true); item.Tag = tile.HCTag; item.MouseDown += new MouseEventHandler(tileItem_Click); item.MouseUp += new MouseEventHandler(item_MouseUp); } } } }
public static PortalInfo Load(WzCanvasProperty parentObject) { PortalInfo portal = new PortalInfo( parentObject.Name, parentObject.GetLinkedWzCanvasBitmap(), WzInfoTools.PointFToSystemPoint(parentObject.GetCanvasOriginPosition()), parentObject); Program.InfoManager.Portals.Add(portal.type, portal); return(portal); }
private Bitmap RenderMinimap(Size bmpSize, WzFile wzFile, WzImage img, string mapIdName, WzSubProperty miniMapSubProperty) { Bitmap minimapRender = new Bitmap(400, 200); using (Graphics drawBuf = Graphics.FromImage(minimapRender)) { // Draw map mark WzStringProperty mapMark = ((WzStringProperty)img["info"]["mapMark"]); if (mapMark != null) { string mapMarkPath = wzFile.WzDirectory.Name + "/MapHelper.img/mark/" + mapMark.GetString(); WzCanvasProperty mapMarkCanvas = (WzCanvasProperty)wzFile.GetObjectFromPath(mapMarkPath); if (mapMarkCanvas != null && mapMark.ToString() != "None") // Doesnt have to render mapmark if its not available. Actual client does not crash { drawBuf.DrawImage(mapMarkCanvas.GetLinkedWzCanvasBitmap(), 10, 10); } } // Get map name string mapName = string.Empty; string streetName = string.Empty; string mapNameStringPath = "String.wz/Map.img"; WzImage mapNameImages = (WzImage)WzFile.GetObjectFromMultipleWzFilePath(mapNameStringPath, Program.WzMan.WzFileListReadOnly); foreach (WzSubProperty subAreaImgProp in mapNameImages.WzProperties) { foreach (WzSubProperty mapImg in subAreaImgProp.WzProperties) { if (mapImg.Name == mapIdName) { mapName = mapImg["mapName"].ReadString(string.Empty); streetName = mapImg["streetName"].ReadString(string.Empty); break; } } } // Draw map name and ID //drawBuf.FillRectangle(new SolidBrush(Color.CornflowerBlue), 0, 0, bmpSize.Width, bmpSize.Height); drawBuf.DrawString(string.Format("[{0}] {1}", mapIdName, streetName), FONT_DISPLAY_MAPID, new SolidBrush(Color.Black), new PointF(60, 10)); drawBuf.DrawString(mapName, FONT_DISPLAY_MAPID, new SolidBrush(Color.Black), new PointF(60, 30)); // Draw mini map if (miniMapSubProperty != null) { drawBuf.DrawImage(((WzCanvasProperty)miniMapSubProperty["canvas"]).GetLinkedWzCanvasBitmap(), 10, 80); } else { drawBuf.DrawString("Minimap not availible", FONT_DISPLAY_MINIMAP_NOT_AVAILABLE, new SolidBrush(Color.Black), new PointF(10, 45)); } } minimapRender.Save("Renders\\" + mapIdName + "\\" + mapIdName + "_miniMapRender.bmp"); return(minimapRender); }
public static int PropertySorter(WzCanvasProperty a, WzCanvasProperty b) { int aIndex = 0; int bIndex = 0; if (!int.TryParse(a.Name, out aIndex) || !int.TryParse(b.Name, out bIndex)) { return(0); } return(aIndex.CompareTo(bIndex)); }
private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e) { if ((string)mapNamesBox.SelectedItem == "MapLogin" || (string)mapNamesBox.SelectedItem == "MapLogin1" || (string)mapNamesBox.SelectedItem == "CashShopPreview" || mapNamesBox.SelectedItem == null) { linkLabel.Visible = false; mapNotExist.Visible = false; minimapBox.Image = (Image) new Bitmap(1, 1); loadButton.Enabled = true; return; } string mapid = ((string)mapNamesBox.SelectedItem).Substring(0, 9); string mapcat = "Map" + mapid.Substring(0, 1); WzImage mapImage = (WzImage)Program.WzManager["map"].GetObjectFromPath("Map.wz/Map/" + mapcat + "/" + mapid + ".img"); if (mapImage == null) { linkLabel.Visible = false; mapNotExist.Visible = true; minimapBox.Image = (Image) new Bitmap(1, 1); loadButton.Enabled = false; return; } if (!mapImage.Parsed) { mapImage.ParseImage(); } if (mapImage["info"]["link"] != null) { linkLabel.Visible = true; mapNotExist.Visible = false; minimapBox.Image = (Image) new Bitmap(1, 1); loadButton.Enabled = false; } else { linkLabel.Visible = false; mapNotExist.Visible = false; loadButton.Enabled = true; WzCanvasProperty minimap = (WzCanvasProperty)mapImage.GetFromPath("miniMap/canvas"); if (minimap != null) { minimapBox.Image = (Image)minimap.PngProperty.GetPNG(false); } else { minimapBox.Image = (Image) new Bitmap(1, 1); } } mapImage.UnparseImage(); GC.Collect(); }
public void LoadTileSetList() { lock (hcsm.MultiBoard) { if (tileSetList.SelectedItem == null) { return; } tileImagesContainer.Controls.Clear(); string selectedSetName = (string)tileSetList.SelectedItem; if (!Program.InfoManager.TileSets.ContainsKey(selectedSetName)) { return; } WzImage tileSetImage = Program.InfoManager.TileSets[selectedSetName]; int? mag = InfoTool.GetOptionalInt(tileSetImage["info"]["mag"]); foreach (WzSubProperty tCat in tileSetImage.WzProperties) { if (tCat.Name == "info") { continue; } if (ApplicationSettings.randomTiles) { WzCanvasProperty canvasProp = (WzCanvasProperty)tCat["0"]; if (canvasProp == null) { continue; } ImageViewer item = tileImagesContainer.Add(canvasProp.GetLinkedWzCanvasBitmap(), tCat.Name, true); TileInfo[] randomInfos = new TileInfo[tCat.WzProperties.Count]; for (int i = 0; i < randomInfos.Length; i++) { randomInfos[i] = TileInfo.Get((string)tileSetList.SelectedItem, tCat.Name, tCat.WzProperties[i].Name, mag); } item.Tag = randomInfos; item.MouseDown += new MouseEventHandler(tileItem_Click); item.MouseUp += new MouseEventHandler(ImageViewer.item_MouseUp); } else { foreach (WzCanvasProperty tile in tCat.WzProperties) { ImageViewer item = tileImagesContainer.Add(tile.GetLinkedWzCanvasBitmap(), tCat.Name + "/" + tile.Name, true); item.Tag = TileInfo.Get((string)tileSetList.SelectedItem, tCat.Name, tile.Name, mag); item.MouseDown += new MouseEventHandler(tileItem_Click); item.MouseUp += new MouseEventHandler(ImageViewer.item_MouseUp); } } } } }
/// <summary> /// Load background from WzImageProperty /// </summary> /// <param name="graphicsDevice">The graphics device that the backgroundInfo is to be rendered on (loading spine)</param> /// <param name="parentObject"></param> /// <param name="spineParentObject"></param> /// <param name="bS"></param> /// <param name="type"></param> /// <param name="no"></param> /// <returns></returns> private static BackgroundInfo Load(GraphicsDevice graphicsDevice, WzImageProperty parentObject, string bS, BackgroundInfoType type, string no) { WzCanvasProperty frame0; if (type == BackgroundInfoType.Animation) { frame0 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject["0"]); } else if (type == BackgroundInfoType.Spine) { // TODO: make a preview of the spine image ffs WzCanvasProperty spineCanvas = (WzCanvasProperty)parentObject["0"]; if (spineCanvas != null) { // Load spine WzSpineAnimationItem wzSpineAnimationItem = null; if (graphicsDevice != null) // graphicsdevice needed to work.. assuming that it is loaded by now before BackgroundPanel { WzImageProperty spineAtlasProp = ((WzSubProperty)parentObject).WzProperties.FirstOrDefault( wzprop => wzprop is WzStringProperty property && property.IsSpineAtlasResources); if (spineAtlasProp != null) { WzStringProperty stringObj = (WzStringProperty)spineAtlasProp; wzSpineAnimationItem = new WzSpineAnimationItem(stringObj); wzSpineAnimationItem.LoadResources(graphicsDevice); } } // Preview Image Bitmap bitmap = spineCanvas.GetLinkedWzCanvasBitmap(); // Origin PointF origin__ = spineCanvas.GetCanvasOriginPosition(); return(new BackgroundInfo(parentObject, bitmap, WzInfoTools.PointFToSystemPoint(origin__), bS, type, no, parentObject, wzSpineAnimationItem)); } else { PointF origin_ = new PointF(); return(new BackgroundInfo(parentObject, Properties.Resources.placeholder, WzInfoTools.PointFToSystemPoint(origin_), bS, type, no, parentObject, null)); } } else { frame0 = (WzCanvasProperty)WzInfoTools.GetRealProperty(parentObject); } PointF origin = frame0.GetCanvasOriginPosition(); return(new BackgroundInfo(frame0, frame0.GetLinkedWzCanvasBitmap(), WzInfoTools.PointFToSystemPoint(origin), bS, type, no, parentObject, null)); }
private void CreateWzProp(IPropertyContainer parent, WzPropertyType propType, string propName, object value) { WzImageProperty addedProp; switch (propType) { case WzPropertyType.Float: addedProp = new WzFloatProperty(propName); break; case WzPropertyType.Canvas: addedProp = new WzCanvasProperty(propName); ((WzCanvasProperty)addedProp).PngProperty = new WzPngProperty(); break; case WzPropertyType.Int: addedProp = new WzIntProperty(propName); break; case WzPropertyType.Double: addedProp = new WzDoubleProperty(propName); break; /*case WzPropertyType.Sound: * addedProp = new WzSoundProperty(propName); * break;*/ case WzPropertyType.String: addedProp = new WzStringProperty(propName); break; case WzPropertyType.Short: addedProp = new WzShortProperty(propName); break; case WzPropertyType.Vector: addedProp = new WzVectorProperty(propName); ((WzVectorProperty)addedProp).X = new WzIntProperty("X"); ((WzVectorProperty)addedProp).Y = new WzIntProperty("Y"); break; case WzPropertyType.Lua: // probably dont allow the user to create custom Lua for now.. { addedProp = new WzLuaProperty(propName, new byte[] { }); break; } default: throw new NotSupportedException("Not supported type"); } addedProp.SetValue(value); parent.AddProperty(addedProp); }
private void DumpCanvasProp(string wzPath, WzCanvasProperty canvasProp, AWzObject uol, bool uolDirCopy) { string fileName = CleanFileName(uol != null && !uolDirCopy ? uol.Name : canvasProp.Name); string newFilePath = Path.Combine(ExtractPath, wzPath, fileName + ".png"); if (LinkType != LinkType.Copy && !(string.IsNullOrEmpty(canvasProp.Outlink) && string.IsNullOrEmpty(canvasProp.Inlink) && uol == null)) { string targetFile; if (!string.IsNullOrEmpty(canvasProp.Inlink)) { targetFile = Path.Combine(CurrentImageDir, canvasProp.Inlink + ".png"); } else if (!string.IsNullOrEmpty(canvasProp.Outlink)) { targetFile = Path.Combine(WzFolderName, canvasProp.Outlink.Substring(canvasProp.Outlink.IndexOf("/", StringComparison.OrdinalIgnoreCase) + 1) + ".png"); } else { targetFile = Path.Combine(WzFolderName, canvasProp.FullPath.Substring(canvasProp.FullPath.IndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1) + ".png"); } SanitizeTargetPath(ref targetFile); FileInfo file = new FileInfo(targetFile); bool createLink = true; if (!File.Exists(targetFile)) { createLink = WritePng(wzPath, fileName, targetFile, canvasProp, file); } if (createLink) { FileInfo linkPath = new FileInfo(newFilePath); linkPath.Directory.Create(); bool res = LinkType == LinkType.Symbolic ? CreateSymbolicLink(newFilePath, targetFile, 0) : CreateHardLink(newFilePath, targetFile, IntPtr.Zero); if (!res) { uint error = GetLastError(); if (error == 1142) // max links reached for file, fallback to copy mode { WritePng(wzPath, fileName, newFilePath, canvasProp); } else if (error != 183) // link already exists { Form.UpdateTextBoxInfo(Form.InfoTextBox, "Error creating link: " + error + " - " + newFilePath + " -> " + targetFile, true); } } } } else { WritePng(wzPath, fileName, newFilePath, canvasProp); } }
private void AddHairRow(WzImage image) { string imgName = Path.GetFileNameWithoutExtension(image.Name); int id = int.Parse(imgName); WzCanvasProperty icon = (WzCanvasProperty)image.GetFromPath("default/hairOverHead"); if (icon == null) { icon = (WzCanvasProperty)image.GetFromPath("default/hair"); } string name = StringUtility.GetEqp(id); EquipHairsView.GridView.Rows.Add(id, icon?.GetBitmap(), name, ""); }
public static WzCanvasProperty GetReactorImage(WzImage parentImage) { WzSubProperty action0 = (WzSubProperty)parentImage["0"]; if (action0 != null) { WzCanvasProperty frame1 = (WzCanvasProperty)GetRealProperty(action0["0"]); if (frame1 != null) { return(frame1); } } return(null); }
public static WzCanvasProperty GetNpcImage(WzImage parentImage) { WzSubProperty standParent = (WzSubProperty)parentImage["stand"]; if (standParent != null) { WzCanvasProperty frame1 = (WzCanvasProperty)GetRealProperty(standParent["0"]); if (frame1 != null) { return(frame1); } } return(null); }
public static TileInfo Load(WzCanvasProperty parentObject, string tS, string u, string no) { TileInfo result = new TileInfo(parentObject.PngProperty.GetPNG(false), WzInfoTools.VectorToSystemPoint((WzVectorProperty)parentObject["origin"]), tS, u, no, parentObject); WzConvexProperty footholds = (WzConvexProperty)parentObject["foothold"]; if (footholds != null) { foreach (WzVectorProperty foothold in footholds.WzProperties) { result.footholdOffsets.Add(WzInfoTools.VectorToXNAPoint(foothold)); } } return(result); }
private void ExtractPNGFromImage(WzImage image) { WzCanvasProperty reactorImage = WzInfoTools.GetReactorImage(image); if (reactorImage != null) { Image = reactorImage.PngProperty.GetPNG(false); Origin = WzInfoTools.VectorToSystemPoint((WzVectorProperty)reactorImage["origin"]); } else { Image = new Bitmap(1, 1); Origin = new System.Drawing.Point(); } }
private void ExtractPNGFromImage(WzImage image) { WzCanvasProperty reactorImage = WzInfoTools.GetReactorImage(image); if (reactorImage != null) { Image = reactorImage.GetLinkedWzCanvasBitmap(); Origin = WzInfoTools.PointFToSystemPoint(reactorImage.GetCanvasOriginPosition()); } else { Image = new Bitmap(1, 1); Origin = new System.Drawing.Point(); } }
private bool WritePng(string wzPath, string fileName, string filePath, WzCanvasProperty canvasProp, FileInfo overrideFile = null) { Form.UpdateToolstripStatus("Dumping " + fileName + ".png to " + wzPath); while (!string.IsNullOrEmpty(canvasProp.Inlink) || !string.IsNullOrEmpty(canvasProp.Outlink)) { if (!string.IsNullOrEmpty(canvasProp.Inlink)) { if (canvasProp.InlinkValue == null) { return(false); } canvasProp = canvasProp.InlinkValue; } else if (!string.IsNullOrEmpty(canvasProp.Outlink)) { if (canvasProp.OutlinkValue == null) { return(false); } canvasProp = canvasProp.OutlinkValue; } } if (canvasProp != null) { CreateDirectory(ref wzPath); if (overrideFile != null) { overrideFile.Directory.Create(); } if (filePath == null) { filePath = Path.Combine(ExtractPath, wzPath, fileName + ".png"); } using (var myFileOut = new FileStream(filePath, FileMode.Create)) { if (canvasProp.PngProperty.GetPNG() == null) { Form.UpdateTextBoxInfo(Form.InfoTextBox, "Error Dumping " + fileName + ".png to " + wzPath, true); } else { canvasProp.PngProperty.GetPNG().Save(myFileOut, ImageFormat.Png); } } return(true); } return(false); }