/// <summary> /// Creates a BaseDXDrawableItem UI item from WzSubProperty /// </summary> /// <param name="subProperty"></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> /// <returns></returns> private BaseDXDrawableItem CreateBaseDXDrawableItemWithWzProperty(WzSubProperty subProperty, bool flip, Point relativePositionXY, GraphicsDevice graphicsDevice) { List <IDXObject> drawableImages = new List <IDXObject>(); int i = 0; WzImageProperty imgProperty; while ((imgProperty = subProperty[i.ToString()]) != null) { if (imgProperty is WzCanvasProperty property) { System.Drawing.Bitmap btImage = property.GetLinkedWzCanvasBitmap(); // maximise System.Drawing.PointF origin = property.GetCanvasOriginPosition(); int?delay = property[WzCanvasProperty.AnimationDelayPropertyName]?.GetInt(); if (_CanvasSnapshotHeight == -1) { _CanvasSnapshotHeight = btImage.Height; // set the snapshot width and height _CanvasSnapshotWidth = btImage.Width; } IDXObject dxObj_miniMapPixel = new DXObject(origin, btImage.ToTexture2D(graphicsDevice), delay != null ? (int)delay : 0); drawableImages.Add(dxObj_miniMapPixel); } i++; } if (drawableImages.Count == 0) // oh noz u sux { throw new Exception("Error creating BaseDXDrawableItem from WzSubProperty."); } if (drawableImages.Count > 0) { BaseDXDrawableItem item_pixelDot = new BaseDXDrawableItem(drawableImages, flip) { Position = relativePositionXY }; return(item_pixelDot); } return(new BaseDXDrawableItem(drawableImages[0], flip) { Position = relativePositionXY }); }
/// <summary> /// Load spine related assets and contents /// </summary> protected override void LoadContent() { // Font spriteBatch = new SpriteBatch(GraphicsDevice); // Animation frames List <IDXObject> animationFrames = new List <IDXObject>(); // WzNodes to DXObject foreach (WzNode selNode in selectedAnimationNodes) { WzObject obj = (WzObject)selNode.Tag; bool isUOLProperty = obj is WzUOLProperty; if (obj is WzCanvasProperty || isUOLProperty) { WzCanvasProperty canvasProperty; // Get image property System.Drawing.Bitmap image; if (!isUOLProperty) { canvasProperty = ((WzCanvasProperty)obj); image = canvasProperty.GetLinkedWzCanvasBitmap(); } else { WzObject linkVal = ((WzUOLProperty)obj).LinkValue; if (linkVal is WzCanvasProperty property) { canvasProperty = property; image = canvasProperty.GetLinkedWzCanvasBitmap(); } else { break; } } // Get delay property int?delay = canvasProperty[WzCanvasProperty.AnimationDelayPropertyName]?.GetInt(); if (delay == null) { delay = 0; } // Add to the list of images to render System.Drawing.PointF origin = canvasProperty.GetCanvasOriginPosition(); DXObject dxObject = new DXObject((int)-origin.X, (int)-origin.Y, image.ToTexture2D(graphicsDeviceMgr.GraphicsDevice), (int)delay) { Tag = obj.FullPath }; animationFrames.Add(dxObject); } } dxDrawableItem = new BaseDXDrawableItem(animationFrames, false); // Debug items System.Drawing.Bitmap bitmap_debug = new System.Drawing.Bitmap(1, 1); bitmap_debug.SetPixel(0, 0, System.Drawing.Color.White); texture_debugBoundaryRect = bitmap_debug.ToTexture2D(graphicsDeviceMgr.GraphicsDevice); }