public WzMp3Streamer(WzBinaryProperty sound, bool repeat) { this.repeat = repeat; this.sound = sound; byteStream = new MemoryStream(sound.GetBytes(false)); this.bIsMP3File = !sound.Name.EndsWith("wav"); // mp3 file does not end with any extension wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback()); try { if (bIsMP3File) { mpegStream = new Mp3FileReader(byteStream); wavePlayer.Init(mpegStream); } else { waveFileStream = new WaveFileReader(byteStream); wavePlayer.Init(waveFileStream); } } catch (System.Exception e) { playbackSuccessfully = false; //InvalidDataException // Message = "Not a WAVE file - no RIFF header" } Volume = 0.5f; // default volume wavePlayer.PlaybackStopped += new EventHandler <StoppedEventArgs>(wavePlayer_PlaybackStopped); }
public uint AddMP3(WzBinaryProperty node) { uint ret = (uint)MP3s.Count; MP3s.Add(node); return(ret); }
/// <summary> /// Load skeleton data by json or binary automatically /// </summary> /// <param name="atlasNode"></param> /// <param name="atlas"></param> /// <param name="data"></param> /// <returns></returns> private static bool TryLoadSkeletonJsonOrBinary(WzImageProperty atlasNode, Atlas atlas, out SkeletonData data) { data = null; if (atlasNode == null || atlasNode.Parent == null || atlas == null) { return(false); } WzObject parent = atlasNode.Parent; List <WzImageProperty> childProperties; if (parent is WzImageProperty) { childProperties = ((WzImageProperty)parent).WzProperties; } else { childProperties = ((WzImage)parent).WzProperties; } if (childProperties != null) { WzStringProperty stringJsonProp = (WzStringProperty)childProperties.Where(child => child.Name.EndsWith(".json")).FirstOrDefault(); if (stringJsonProp != null) // read json based { StringReader skeletonReader = new StringReader(stringJsonProp.GetString()); SkeletonJson json = new SkeletonJson(atlas); data = json.ReadSkeletonData(skeletonReader); return(true); } else { // try read binary based foreach (WzImageProperty property in childProperties) { if (property is WzBinaryProperty) { WzBinaryProperty soundProp = (WzBinaryProperty)property; // should be called binaryproperty actually using (MemoryStream ms = new MemoryStream(soundProp.GetBytes(false))) { SkeletonBinary skeletonBinary = new SkeletonBinary(atlas); data = skeletonBinary.ReadSkeletonData(ms); return(true); } } } } } return(false); }
public void ExtractSoundFile(string soundWzFile) { WzDirectory directory = this[soundWzFile]; if (directory == null) { return; } foreach (WzImage soundImage in directory.WzImages) { if (!soundImage.Name.ToLower().Contains("bgm")) { continue; } if (!soundImage.Parsed) { soundImage.ParseImage(); } try { foreach (WzImageProperty bgmImage in soundImage.WzProperties) { WzBinaryProperty binProperty = null; if (bgmImage is WzBinaryProperty bgm) { binProperty = bgm; } else if (bgmImage is WzUOLProperty uolBGM) // is UOL property { WzObject linkVal = ((WzUOLProperty)bgmImage).LinkValue; if (linkVal is WzBinaryProperty linkCanvas) { binProperty = linkCanvas; } } if (binProperty != null) { Program.InfoManager.BGMs[WzInfoTools.RemoveExtension(soundImage.Name) + @"/" + binProperty.Name] = binProperty; } } } catch (Exception e) { string error = string.Format("[ExtractSoundFile] Error parsing {0}, {1} file.\r\nError: {2}", soundWzFile, soundImage.Name, e.ToString()); MapleLib.Helpers.ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); continue; } } }
/// <summary> /// Constructor. Create by the WzSubProperty object /// </summary> /// <param name="uiButtonProperty"></param> /// <param name="BtMouseClickProperty"></param> /// <param name="BtMouseOverProperty"></param> /// <param name="flip"></param> /// <param name="relativePositionXY">The relative position of the button to be overlaid on top of the main BaseDXDrawableItem</param> /// <param name="graphicsDevice"></param> public UIObject(WzSubProperty uiButtonProperty, WzBinaryProperty BtMouseClickProperty, WzBinaryProperty BtMouseOverProperty, bool flip, Point relativePositionXY, GraphicsDevice graphicsDevice) { WzSubProperty normalStateProperty = (WzSubProperty)uiButtonProperty["normal"]; WzSubProperty disabledStateProperty = (WzSubProperty)uiButtonProperty["disabled"]; WzSubProperty pressedStateProperty = (WzSubProperty)uiButtonProperty["pressed"]; WzSubProperty mouseOverStateProperty = (WzSubProperty)uiButtonProperty["mouseOver"]; this.normalState = CreateBaseDXDrawableItemWithWzProperty(normalStateProperty, flip, relativePositionXY, graphicsDevice); this.disabledState = CreateBaseDXDrawableItemWithWzProperty(disabledStateProperty, flip, relativePositionXY, graphicsDevice); this.pressedState = CreateBaseDXDrawableItemWithWzProperty(pressedStateProperty, flip, relativePositionXY, graphicsDevice); this.mouseOverState = CreateBaseDXDrawableItemWithWzProperty(mouseOverStateProperty, flip, relativePositionXY, graphicsDevice); this.seBtMouseClick = CreateSoundEffectWithWzProperty(BtMouseClickProperty); this.seBtMouseOver = CreateSoundEffectWithWzProperty(BtMouseOverProperty); }
/// <summary> /// Create SoundEffect from WzBinaryProperty /// TODO: combined cache /// </summary> /// <param name="BtMouseProperty"></param> /// <returns></returns> private SoundEffect CreateSoundEffectWithWzProperty(WzBinaryProperty BtMouseProperty) { /*using (MemoryStream ms = new MemoryStream(BtMouseProperty.GetBytes(true))) // dont dispose until its no longer needed * { * WaveFormat wavFmt = BtMouseProperty.WavFormat; * if (wavFmt.Encoding == WaveFormatEncoding.MpegLayer3) * { * Mp3FileReader mpegStream = new Mp3FileReader(ms); * SoundEffect effect = SoundEffect.FromStream(mpegStream); * } * else if (wavFmt.Encoding == WaveFormatEncoding.Pcm) * { * WaveFileReader waveFileStream = new WaveFileReader(ms); * SoundEffect effect = SoundEffect.FromStream(waveFileStream); * } * }*/ /* using (MemoryStream ms = new MemoryStream(BtMouseProperty.GetBytes(true))) // dont dispose until its no longer needed * { * using (Mp3FileReader reader = new Mp3FileReader(ms)) * { * using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader)) * { * // WaveFileWriter.CreateWaveFile(outputFile, pcmStream); * SoundEffect effect = SoundEffect.FromStream(pcmStream); * } * } * } * * using (MemoryStream ms = new MemoryStream(BtMouseProperty.GetBytes(true))) // dont dispose until its no longer needed * { * using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(ms))) * { * // convert 16 bit to 8 bit pcm stream * var newFormat = new WaveFormat(8000, 16, 1); * using (var conversionStream = new WaveFormatConversionStream(newFormat, pcm)) // https://stackoverflow.com/questions/49776648/wav-file-conversion-pcm-48khz-16-bit-rate-to-u-law-8khz-8-bit-rate-using-naudio ty * { * SoundEffect effect = SoundEffect.FromStream(conversionStream); * return effect; // TODO: dispose this later * } * } * }*/ return(null); }
internal WzImageProperty ParsePropertyFromXMLElement(XmlElement element) { switch (element.Name) { case "imgdir": WzSubProperty sub = new WzSubProperty(element.GetAttribute("name")); foreach (XmlElement subelement in element) { sub.AddProperty(ParsePropertyFromXMLElement(subelement)); } return(sub); case "canvas": WzCanvasProperty canvas = new WzCanvasProperty(element.GetAttribute("name")); if (!element.HasAttribute("basedata")) { throw new NoBase64DataException("no base64 data in canvas element with name " + canvas.Name); } canvas.PngProperty = new WzPngProperty(); MemoryStream pngstream = new MemoryStream(Convert.FromBase64String(element.GetAttribute("basedata"))); canvas.PngProperty.SetPNG((Bitmap)Image.FromStream(pngstream, true, true)); foreach (XmlElement subelement in element) { canvas.AddProperty(ParsePropertyFromXMLElement(subelement)); } return(canvas); case "int": WzIntProperty compressedInt = new WzIntProperty(element.GetAttribute("name"), int.Parse(element.GetAttribute("value"), formattingInfo)); return(compressedInt); case "double": WzDoubleProperty doubleProp = new WzDoubleProperty(element.GetAttribute("name"), double.Parse(element.GetAttribute("value"), formattingInfo)); return(doubleProp); case "null": WzNullProperty nullProp = new WzNullProperty(element.GetAttribute("name")); return(nullProp); case "sound": if (!element.HasAttribute("basedata") || !element.HasAttribute("basehead") || !element.HasAttribute("length")) { throw new NoBase64DataException("no base64 data in sound element with name " + element.GetAttribute("name")); } WzBinaryProperty sound = new WzBinaryProperty(element.GetAttribute("name"), int.Parse(element.GetAttribute("length")), Convert.FromBase64String(element.GetAttribute("basehead")), Convert.FromBase64String(element.GetAttribute("basedata"))); return(sound); case "string": WzStringProperty stringProp = new WzStringProperty(element.GetAttribute("name"), element.GetAttribute("value")); return(stringProp); case "short": WzShortProperty shortProp = new WzShortProperty(element.GetAttribute("name"), short.Parse(element.GetAttribute("value"), formattingInfo)); return(shortProp); case "long": WzLongProperty longProp = new WzLongProperty(element.GetAttribute("name"), long.Parse(element.GetAttribute("value"), formattingInfo)); return(longProp); case "uol": WzUOLProperty uol = new WzUOLProperty(element.GetAttribute("name"), element.GetAttribute("value")); return(uol); case "vector": WzVectorProperty vector = new WzVectorProperty(element.GetAttribute("name"), new WzIntProperty("x", Convert.ToInt32(element.GetAttribute("x"))), new WzIntProperty("y", Convert.ToInt32(element.GetAttribute("y")))); return(vector); case "float": WzFloatProperty floatProp = new WzFloatProperty(element.GetAttribute("name"), float.Parse(element.GetAttribute("value"), formattingInfo)); return(floatProp); case "extended": WzConvexProperty convex = new WzConvexProperty(element.GetAttribute("name")); foreach (XmlElement subelement in element) { convex.AddProperty(ParsePropertyFromXMLElement(subelement)); } return(convex); } throw new InvalidDataException("unknown XML prop " + element.Name); }
/// <summary> /// /// </summary> /// <param name="tw"></param> /// <param name="depth"></param> /// <param name="prop"></param> /// <param name="exportFilePath"></param> protected void WritePropertyToXML(TextWriter tw, string depth, WzImageProperty prop, string exportFilePath) { if (prop is WzCanvasProperty) { WzCanvasProperty property3 = (WzCanvasProperty)prop; if (ExportBase64Data) { MemoryStream stream = new MemoryStream(); property3.PngProperty.GetPNG(false).Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] pngbytes = stream.ToArray(); stream.Close(); tw.Write(string.Concat(new object[] { depth, "<canvas name=\"", XmlUtil.SanitizeText(property3.Name), "\" width=\"", property3.PngProperty.Width, "\" height=\"", property3.PngProperty.Height, "\" basedata=\"", Convert.ToBase64String(pngbytes), "\">" }) + lineBreak); } else { tw.Write(string.Concat(new object[] { depth, "<canvas name=\"", XmlUtil.SanitizeText(property3.Name), "\" width=\"", property3.PngProperty.Width, "\" height=\"", property3.PngProperty.Height, "\">" }) + lineBreak); } string newDepth = depth + indent; foreach (WzImageProperty property in property3.WzProperties) { WritePropertyToXML(tw, newDepth, property, exportFilePath); } tw.Write(depth + "</canvas>" + lineBreak); } else if (prop is WzIntProperty) { WzIntProperty property4 = (WzIntProperty)prop; tw.Write(string.Concat(new object[] { depth, "<int name=\"", XmlUtil.SanitizeText(property4.Name), "\" value=\"", property4.Value, "\"/>" }) + lineBreak); } else if (prop is WzDoubleProperty) { WzDoubleProperty property5 = (WzDoubleProperty)prop; tw.Write(string.Concat(new object[] { depth, "<double name=\"", XmlUtil.SanitizeText(property5.Name), "\" value=\"", property5.Value, "\"/>" }) + lineBreak); } else if (prop is WzNullProperty) { WzNullProperty property6 = (WzNullProperty)prop; tw.Write(depth + "<null name=\"" + XmlUtil.SanitizeText(property6.Name) + "\"/>" + lineBreak); } else if (prop is WzBinaryProperty) { WzBinaryProperty property7 = (WzBinaryProperty)prop; if (ExportBase64Data) { tw.Write(string.Concat(new object[] { depth, "<sound name=\"", XmlUtil.SanitizeText(property7.Name), "\" length=\"", property7.Length.ToString(), "\" basehead=\"", Convert.ToBase64String(property7.Header), "\" basedata=\"", Convert.ToBase64String(property7.GetBytes(false)), "\"/>" }) + lineBreak); } else { tw.Write(depth + "<sound name=\"" + XmlUtil.SanitizeText(property7.Name) + "\"/>" + lineBreak); } } else if (prop is WzStringProperty) { WzStringProperty property8 = (WzStringProperty)prop; string str = XmlUtil.SanitizeText(property8.Value); tw.Write(depth + "<string name=\"" + XmlUtil.SanitizeText(property8.Name) + "\" value=\"" + str + "\"/>" + lineBreak); } else if (prop is WzSubProperty) { WzSubProperty property9 = (WzSubProperty)prop; tw.Write(depth + "<imgdir name=\"" + XmlUtil.SanitizeText(property9.Name) + "\">" + lineBreak); string newDepth = depth + indent; foreach (WzImageProperty property in property9.WzProperties) { WritePropertyToXML(tw, newDepth, property, exportFilePath); } tw.Write(depth + "</imgdir>" + lineBreak); } else if (prop is WzShortProperty) { WzShortProperty property10 = (WzShortProperty)prop; tw.Write(string.Concat(new object[] { depth, "<short name=\"", XmlUtil.SanitizeText(property10.Name), "\" value=\"", property10.Value, "\"/>" }) + lineBreak); } else if (prop is WzLongProperty) { WzLongProperty long_prop = (WzLongProperty)prop; tw.Write(string.Concat(new object[] { depth, "<long name=\"", XmlUtil.SanitizeText(long_prop.Name), "\" value=\"", long_prop.Value, "\"/>" }) + lineBreak); } else if (prop is WzUOLProperty) { WzUOLProperty property11 = (WzUOLProperty)prop; tw.Write(depth + "<uol name=\"" + property11.Name + "\" value=\"" + XmlUtil.SanitizeText(property11.Value) + "\"/>" + lineBreak); } else if (prop is WzVectorProperty) { WzVectorProperty property12 = (WzVectorProperty)prop; tw.Write(string.Concat(new object[] { depth, "<vector name=\"", XmlUtil.SanitizeText(property12.Name), "\" x=\"", property12.X.Value, "\" y=\"", property12.Y.Value, "\"/>" }) + lineBreak); } else if (prop is WzFloatProperty) { WzFloatProperty property13 = (WzFloatProperty)prop; string str2 = Convert.ToString(property13.Value, formattingInfo); if (!str2.Contains(".")) { str2 = str2 + ".0"; } tw.Write(depth + "<float name=\"" + XmlUtil.SanitizeText(property13.Name) + "\" value=\"" + str2 + "\"/>" + lineBreak); } else if (prop is WzConvexProperty) { tw.Write(depth + "<extended name=\"" + XmlUtil.SanitizeText(prop.Name) + "\">" + lineBreak); WzConvexProperty property14 = (WzConvexProperty)prop; string newDepth = depth + indent; foreach (WzImageProperty property in property14.WzProperties) { WritePropertyToXML(tw, newDepth, property, exportFilePath); } tw.Write(depth + "</extended>" + lineBreak); } else if (prop is WzLuaProperty) // probably added on v188 gms? { WzLuaProperty property15 = (WzLuaProperty)prop; string parentName = property15.Parent.Name; tw.Write(depth); tw.Write(lineBreak); // Export standalone file here using (TextWriter twLua = new StreamWriter(File.Create(exportFilePath.Replace(parentName + ".xml", parentName)))) { twLua.Write(property15.ToString()); } } }
private void WriteNode(WzObject node, DumpState ds, BinaryWriter bw, uint nextChildID) { ds.AddNode(node); bw.Write(ds.AddString(node.Name)); bw.Write(nextChildID); bw.Write((ushort)GetChildCount(node)); ushort type; if (node is WzDirectory || node is WzImage || node is WzSubProperty || node is WzConvexProperty || node is WzNullProperty) { type = 0; // no data; children only (8) } else if (node is WzIntProperty || node is WzShortProperty || node is WzLongProperty) { type = 1; // int32 (4) } else if (node is WzDoubleProperty || node is WzFloatProperty) { type = 2; // Double (0) } else if (node is WzStringProperty || node is WzLuaProperty) { type = 3; // String (4) } else if (node is WzVectorProperty) { type = 4; // (0) } else if (node is WzCanvasProperty) { type = 5; // (4) } else if (node is WzBinaryProperty) { type = 6; // (4) } else { throw new InvalidOperationException("Unhandled WZ node type [1]"); } bw.Write(type); if (node is WzIntProperty) { bw.Write((long)((WzIntProperty)node).Value); } else if (node is WzShortProperty) { bw.Write((long)((WzShortProperty)node).Value); } else if (node is WzLongProperty) { bw.Write(((WzLongProperty)node).Value); } else if (node is WzFloatProperty) { bw.Write((double)((WzFloatProperty)node).Value); } else if (node is WzDoubleProperty) { bw.Write(((WzDoubleProperty)node).Value); } else if (node is WzStringProperty) { bw.Write(ds.AddString(((WzStringProperty)node).Value)); } else if (node is WzVectorProperty) { Point pNode = ((WzVectorProperty)node).Pos; bw.Write(pNode.X); bw.Write(pNode.Y); } else if (node is WzCanvasProperty) { WzCanvasProperty wzcp = (WzCanvasProperty)node; bw.Write(ds.AddCanvas(wzcp)); bool flag16 = true; // export canvas if (flag16) { bw.Write((ushort)wzcp.PngProperty.GetBitmap().Width); bw.Write((ushort)wzcp.PngProperty.GetBitmap().Height); } else { bw.Write(0); } } else if (node is WzBinaryProperty) { WzBinaryProperty wzmp = (WzBinaryProperty)node; bw.Write(ds.AddMP3(wzmp)); bool flag18 = true; if (flag18) { bw.Write((uint)wzmp.GetBytes().Length); } else { bw.Write(0); } } switch (type) { case 0: bw.Write(0L); break; case 3: bw.Write(0); break; } }
private void WriteMP3(WzBinaryProperty node, BinaryWriter bw) { byte[] i = node.GetBytes(); bw.Write(i); }
/// <summary> /// Draws the frame and the UI of the minimap. /// TODO: This whole thing needs to be dramatically simplified via further abstraction to keep it noob-proof :( /// </summary> /// <param name="minimapFrameProperty">UI.wz/UIWindow2.img/MiniMap</param> /// <param name="mapBoard"></param> /// <param name="device"></param> /// <param name="MapName">The map name. i.e The Hill North</param> /// <param name="StreetName">The street name. i.e Hidden street</param> /// <returns></returns> public static MinimapItem CreateMinimapFromProperty(WzSubProperty minimapFrameProperty, Board mapBoard, GraphicsDevice device, string MapName, string StreetName, WzDirectory SoundWZFile) { if (mapBoard.MiniMap == null) { return(null); } WzSubProperty maxMapProperty = (WzSubProperty)minimapFrameProperty["MaxMap"]; WzSubProperty miniMapProperty = (WzSubProperty)minimapFrameProperty["MinMap"]; WzSubProperty maxMapMirrorProperty = (WzSubProperty)minimapFrameProperty["MaxMapMirror"]; // for Zero maps WzSubProperty miniMapMirrorProperty = (WzSubProperty)minimapFrameProperty["MinMapMirror"]; // for Zero maps WzSubProperty BtNpc = (WzSubProperty)minimapFrameProperty["BtNpc"]; // npc button WzSubProperty BtMin = (WzSubProperty)minimapFrameProperty["BtMin"]; // mininise button WzSubProperty BtMax = (WzSubProperty)minimapFrameProperty["BtMax"]; // maximise button WzSubProperty BtBig = (WzSubProperty)minimapFrameProperty["BtBig"]; // big button WzSubProperty BtMap = (WzSubProperty)minimapFrameProperty["BtMap"]; // world button WzSubProperty useFrame; if (mapBoard.MapInfo.zeroSideOnly || MapConstants.IsZerosTemple(mapBoard.MapInfo.id)) // zero's temple { useFrame = maxMapMirrorProperty; } else { useFrame = maxMapProperty; } // Wz frames System.Drawing.Bitmap c = ((WzCanvasProperty)useFrame?["c"])?.GetLinkedWzCanvasBitmap(); System.Drawing.Bitmap e = ((WzCanvasProperty)useFrame?["e"])?.GetLinkedWzCanvasBitmap(); System.Drawing.Bitmap n = ((WzCanvasProperty)useFrame?["n"])?.GetLinkedWzCanvasBitmap(); System.Drawing.Bitmap s = ((WzCanvasProperty)useFrame?["s"])?.GetLinkedWzCanvasBitmap(); System.Drawing.Bitmap w = ((WzCanvasProperty)useFrame?["w"])?.GetLinkedWzCanvasBitmap(); System.Drawing.Bitmap ne = ((WzCanvasProperty)useFrame?["ne"])?.GetLinkedWzCanvasBitmap(); // top right System.Drawing.Bitmap nw = ((WzCanvasProperty)useFrame?["nw"])?.GetLinkedWzCanvasBitmap(); // top left System.Drawing.Bitmap se = ((WzCanvasProperty)useFrame?["se"])?.GetLinkedWzCanvasBitmap(); // bottom right System.Drawing.Bitmap sw = ((WzCanvasProperty)useFrame?["sw"])?.GetLinkedWzCanvasBitmap(); // bottom left // Constants const float TOOLTIP_FONTSIZE = 10f; const int MAPMARK_IMAGE_ALIGN_LEFT = 7; // the number of pixels from the left to draw the map mark image const int MAP_IMAGE_PADDING = 2; // the number of pixels from the left to draw the minimap image System.Drawing.Color color_bgFill = System.Drawing.Color.Transparent; System.Drawing.Color color_foreGround = System.Drawing.Color.White; string renderText = string.Format("{0}{1}{2}", StreetName, Environment.NewLine, MapName); // Map background image System.Drawing.Bitmap miniMapImage = mapBoard.MiniMap; // the original minimap image without UI frame overlay int effective_width = miniMapImage.Width + e.Width + w.Width; int effective_height = miniMapImage.Height + n.Height + s.Height; using (System.Drawing.Font font = new System.Drawing.Font(GLOBAL_FONT, TOOLTIP_FONTSIZE)) { // Get the width of the 'streetName' or 'mapName' System.Drawing.Graphics graphics_dummy = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1)); // dummy image just to get the Graphics object for measuring string System.Drawing.SizeF tooltipSize = graphics_dummy.MeasureString(renderText, font); effective_width = Math.Max((int)tooltipSize.Width + nw.Width, effective_width); // set new width int miniMapAlignXFromLeft = MAP_IMAGE_PADDING; if (effective_width > miniMapImage.Width) // if minimap is smaller in size than the (text + frame), minimap will be aligned to the center instead { miniMapAlignXFromLeft = (effective_width - miniMapImage.Width) / 2 /* - miniMapAlignXFromLeft*/; } System.Drawing.Bitmap miniMapUIImage = new System.Drawing.Bitmap(effective_width, effective_height); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(miniMapUIImage)) { // Frames and background UIFrameHelper.DrawUIFrame(graphics, color_bgFill, ne, nw, se, sw, e, w, n, s, null, effective_width, effective_height); // Map name + street name graphics.DrawString( renderText, font, new System.Drawing.SolidBrush(color_foreGround), 50, 20); // Map mark if (Program.InfoManager.MapMarks.ContainsKey(mapBoard.MapInfo.mapMark)) { System.Drawing.Bitmap mapMark = Program.InfoManager.MapMarks[mapBoard.MapInfo.mapMark]; graphics.DrawImage(mapMark.ToImage(), MAPMARK_IMAGE_ALIGN_LEFT, 17); } // Map image graphics.DrawImage(miniMapImage, miniMapAlignXFromLeft, // map is on the center n.Height); graphics.Flush(); } // Dots pixel System.Drawing.Bitmap bmp_DotPixel = new System.Drawing.Bitmap(2, 4); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bmp_DotPixel)) { graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.Yellow), new System.Drawing.RectangleF(0, 0, bmp_DotPixel.Width, bmp_DotPixel.Height)); graphics.Flush(); } IDXObject dxObj_miniMapPixel = new DXObject(0, n.Height, bmp_DotPixel.ToTexture2D(device), 0); BaseDXDrawableItem item_pixelDot = new BaseDXDrawableItem(dxObj_miniMapPixel, false) { Position = new Point( miniMapAlignXFromLeft, // map is on the center 0) }; // Map Texture2D texturer_miniMap = miniMapUIImage.ToTexture2D(device); IDXObject dxObj = new DXObject(0, 0, texturer_miniMap, 0); MinimapItem minimapItem = new MinimapItem(dxObj, item_pixelDot); ////////////// Minimap buttons//////////////////// // This must be in order. // >>> If aligning from the left to the right. Items at the left must be at the top of the code // >>> If aligning from the right to the left. Items at the right must be at the top of the code with its (x position - parent width). // TODO: probably a wrapper class in the future, such as HorizontalAlignment and VerticalAlignment, or Grid/ StackPanel WzBinaryProperty BtMouseClickSoundProperty = (WzBinaryProperty)SoundWZFile["UI.img"]?["BtMouseClick"]; WzBinaryProperty BtMouseOverSoundProperty = (WzBinaryProperty)SoundWZFile["UI.img"]?["BtMouseOver"]; UIObject objUIBtMap = new UIObject(BtMap, BtMouseClickSoundProperty, BtMouseOverSoundProperty, false, new Point(MAP_IMAGE_PADDING, MAP_IMAGE_PADDING), device); objUIBtMap.X = effective_width - objUIBtMap.CanvasSnapshotWidth - 8; // render at the (width of minimap - obj width) UIObject objUIBtBig = new UIObject(BtBig, BtMouseClickSoundProperty, BtMouseOverSoundProperty, false, new Point(MAP_IMAGE_PADDING, MAP_IMAGE_PADDING), device); objUIBtBig.X = objUIBtMap.X - objUIBtBig.CanvasSnapshotWidth; // render at the (width of minimap - obj width) UIObject objUIBtMax = new UIObject(BtMax, BtMouseClickSoundProperty, BtMouseOverSoundProperty, false, new Point(MAP_IMAGE_PADDING, MAP_IMAGE_PADDING), device); objUIBtMax.X = objUIBtBig.X - objUIBtMax.CanvasSnapshotWidth; // render at the (width of minimap - obj width) UIObject objUIBtMin = new UIObject(BtMin, BtMouseClickSoundProperty, BtMouseOverSoundProperty, false, new Point(MAP_IMAGE_PADDING, MAP_IMAGE_PADDING), device); objUIBtMin.X = objUIBtMax.X - objUIBtMin.CanvasSnapshotWidth; // render at the (width of minimap - obj width) // BaseClickableUIObject objUINpc = new BaseClickableUIObject(BtNpc, false, new Point(objUIBtMap.CanvasSnapshotWidth + objUIBtBig.CanvasSnapshotWidth + objUIBtMax.CanvasSnapshotWidth + objUIBtMin.CanvasSnapshotWidth, MAP_IMAGE_PADDING), device); minimapItem.AddUIButtons(objUIBtMin); minimapItem.AddUIButtons(objUIBtMax); minimapItem.AddUIButtons(objUIBtBig); minimapItem.AddUIButtons(objUIBtMap); ////////////////////////////////////////////////// return(minimapItem); } }
internal static WzExtended ExtractMore(WzBinaryReader reader, uint offset, int eob, string name, string iname, WzObject parent, WzImage imgParent) { if (iname == "") { iname = reader.ReadString(); } switch (iname) { case "Property": WzSubProperty subProp = new WzSubProperty(name) { Parent = parent }; reader.BaseStream.Position += 2; // Reserved? subProp.AddProperties(WzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent)); return(subProp); case "Canvas": WzCanvasProperty canvasProp = new WzCanvasProperty(name) { Parent = parent }; reader.BaseStream.Position++; if (reader.ReadByte() == 1) { reader.BaseStream.Position += 2; canvasProp.AddProperties(WzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent)); } canvasProp.PngProperty = new WzPngProperty(reader, imgParent.ParseEverything) { Parent = canvasProp }; return(canvasProp); case "Shape2D#Vector2D": WzVectorProperty vecProp = new WzVectorProperty(name) { Parent = parent }; vecProp.X = new WzIntProperty("X", reader.ReadCompressedInt()) { Parent = vecProp }; vecProp.Y = new WzIntProperty("Y", reader.ReadCompressedInt()) { Parent = vecProp }; return(vecProp); case "Shape2D#Convex2D": WzConvexProperty convexProp = new WzConvexProperty(name) { Parent = parent }; int convexEntryCount = reader.ReadCompressedInt(); convexProp.WzProperties.Capacity = convexEntryCount; for (int i = 0; i < convexEntryCount; i++) { convexProp.AddProperty(ParseExtendedProp(reader, offset, 0, name, convexProp, imgParent)); } return(convexProp); case "Sound_DX8": WzBinaryProperty soundProp = new WzBinaryProperty(name, reader, imgParent.ParseEverything) { Parent = parent }; return(soundProp); case "UOL": reader.BaseStream.Position++; switch (reader.ReadByte()) { case 0: return(new WzUOLProperty(name, reader.ReadString()) { Parent = parent }); case 1: return(new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32())) { Parent = parent }); } throw new Exception("Unsupported UOL type"); default: throw new Exception("Unknown iname: " + iname); } }