/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="normalState"></param>
 /// <param name="disabledState"></param>
 /// <param name="pressedState"></param>
 /// <param name="mouseOverState"></param>
 public UIObject(BaseDXDrawableItem normalState, BaseDXDrawableItem disabledState, BaseDXDrawableItem pressedState, BaseDXDrawableItem mouseOverState)
 {
     this.normalState    = normalState;
     this.disabledState  = disabledState;
     this.pressedState   = pressedState;
     this.mouseOverState = mouseOverState;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="frames"></param>
        /// <param name="item_pixelDot"></param>
        public MinimapItem(IDXObject frames, BaseDXDrawableItem item_pixelDot)
            : base(frames, false)
        {
            this.item_pixelDot = item_pixelDot;

            this.Position = new Point(10, 10); // starting position
        }
Exemple #3
0
        private BaseDXDrawableItem cursorItemPressedState; // default state of the cursor = this instance


        public MouseCursorItem(List <IDXObject> frames, BaseDXDrawableItem cursorItemPressedState)
            : base(frames, false)
        {
            previousMouseState = Mouse.GetState();

            this.mouseCursorItemStates  = (int)MouseCursorItemStates.Normal;
            this.cursorItemPressedState = cursorItemPressedState;
        }
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
            graphicsDeviceMgr.EndDraw();
            graphicsDeviceMgr.Dispose();
            graphicsDeviceMgr = null;

            dxDrawableItem = null;
        }
Exemple #5
0
        /// <summary>
        /// Map item
        /// </summary>
        /// <param name="texturePool"></param>
        /// <param name="source"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="mapCenterX"></param>
        /// <param name="mapCenterY"></param>
        /// <param name="device"></param>
        /// <param name="usedProps"></param>
        /// <param name="flip"></param>
        /// <returns></returns>
        public static MouseCursorItem CreateMouseCursorFromProperty(TexturePool texturePool, WzImageProperty source, int x, int y, GraphicsDevice device, ref List <WzObject> usedProps, bool flip)
        {
            WzSubProperty cursorCanvas        = (WzSubProperty)source?["0"];
            WzSubProperty cursorPressedCanvas = (WzSubProperty)source?["1"]; // click

            List <IDXObject> frames = LoadFrames(texturePool, cursorCanvas, x, y, device, ref usedProps);

            BaseDXDrawableItem clickedState = CreateMapItemFromProperty(texturePool, cursorPressedCanvas, 0, 0, new Point(0, 0), device, ref usedProps, false);

            return(new MouseCursorItem(frames, clickedState));
        }
Exemple #6
0
        public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
                                  int mapShiftX, int mapShiftY, int centerX, int centerY,
                                  ReflectionDrawableBoundary drawReflectionInfo,
                                  int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
                                  int TickCount)
        {
            // control minimap render UI position via
            //  Position.X, Position.Y

            // Draw the main drame
            base.Draw(sprite, skeletonMeshRenderer, gameTime,
                      0, 0, centerX, centerY,
                      drawReflectionInfo,
                      RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution,
                      TickCount);

            int minimapPosX = (mapShiftX + (RenderWidth / 2)) / 16;
            int minimapPosY = (mapShiftY + (RenderHeight / 2)) / 16;

            item_pixelDot.Draw(sprite, skeletonMeshRenderer, gameTime,
                               -Position.X, -Position.Y, minimapPosX, minimapPosY,
                               drawReflectionInfo,
                               RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution,
                               TickCount);

            //IDXObject lastFrameDrawn = base.LastFrameDrawn;
            //int minimapMainFrameWidth = lastFrameDrawn.Width;
            //int minimapMainFrameHeight = lastFrameDrawn.Height;

            // draw minimap buttons
            foreach (MapObjects.UIObject.UIObject uiBtn in uiButtons)
            {
                BaseDXDrawableItem buttonToDraw = uiBtn.GetBaseDXDrawableItemByState();

                // Position drawn is relative to the MinimapItem
                int drawRelativeX = -(this.Position.X) - uiBtn.X; // Left to right
                int drawRelativeY = -(this.Position.Y) - uiBtn.Y; // Top to bottom

                buttonToDraw.Draw(sprite, skeletonMeshRenderer,
                                  gameTime,
                                  drawRelativeX,
                                  drawRelativeY,
                                  centerX, centerY,
                                  null,
                                  RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount);
            }
        }
        /// <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>
        /// 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
            });
        }
Exemple #9
0
        /// <summary>
        ///
        /// </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)
        {
            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 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;

            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

                System.Drawing.Bitmap miniMapUIImage = new System.Drawing.Bitmap(effective_width, effective_height);

                int mapDrawPositionX = (effective_width / 2) - nw.Width;  // map is on the center. The position relative to the UI

                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);

                    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(), 7, 17);
                    }

                    // Map image
                    graphics.DrawImage(miniMapImage,
                                       mapDrawPositionX, // 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(
                        mapDrawPositionX, // map is on the center
                        0)
                };

                // Map
                Texture2D texturer_miniMap = miniMapUIImage.ToTexture2D(device);

                IDXObject   dxObj = new DXObject(0, 0, texturer_miniMap, 0);
                MinimapItem item  = new MinimapItem(dxObj, item_pixelDot);

                return(item);
            }
        }
Exemple #10
0
        /// <summary>
        /// Map item
        /// </summary>
        /// <param name="texturePool"></param>
        /// <param name="source"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="mapCenterX"></param>
        /// <param name="mapCenterY"></param>
        /// <param name="device"></param>
        /// <param name="usedProps"></param>
        /// <param name="flip"></param>
        /// <returns></returns>
        public static BaseDXDrawableItem CreateMapItemFromProperty(TexturePool texturePool, WzImageProperty source, int x, int y, Point mapCenter, GraphicsDevice device, ref List <WzObject> usedProps, bool flip)
        {
            BaseDXDrawableItem mapItem = new BaseDXDrawableItem(LoadFrames(texturePool, source, x, y, device, ref usedProps), flip);

            return(mapItem);
        }
        /// <summary>
        ///
        /// </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)
        {
            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 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 string TOOLTIP_FONT     = "Arial";
            const float  TOOLTIP_FONTSIZE = 10f;

            System.Drawing.Color color_bgFill     = System.Drawing.Color.Transparent;
            System.Drawing.Color color_foreGround = System.Drawing.Color.White;

            // 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);

            // 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(TOOLTIP_FONT, TOOLTIP_FONTSIZE))
            {
                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);

                    graphics.DrawString(
                        string.Format("{0}{1}{2}", StreetName, Environment.NewLine, MapName),
                        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(), 7, 17);
                    }

                    // Map image
                    graphics.DrawImage(miniMapImage, 10, n.Height);

                    graphics.Flush();
                }
                Texture2D texturer_miniMap = miniMapUIImage.ToTexture2D(device);

                IDXObject   dxObj = new DXObject(0, 0, texturer_miniMap, 0);
                MinimapItem item  = new MinimapItem(dxObj, item_pixelDot);

                return(item);
            }
        }
        /// <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);
        }
Exemple #13
0
        /// <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);
            }
        }