/// <summary>
        /// Context menu for adding mini map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MapAddMinimap(object sender, EventArgs e)
        {
            System.Windows.Controls.MenuItem item = (System.Windows.Controls.MenuItem)sender;
            if (item == null)
            {
                return;
            }

            System.Windows.Controls.TabItem tabItem = (System.Windows.Controls.TabItem)item.Tag;
            TabItemContainer container     = (TabItemContainer)tabItem.Tag;
            Board            selectedBoard = container.Board;

            lock (selectedBoard.ParentControl)
            {
                if (selectedBoard.MapInfo.Image != null)
                {
                    Microsoft.Xna.Framework.Rectangle VR;
                    Microsoft.Xna.Framework.Point     mapCenter, mapSize, minimapCenter, minimapSize;
                    bool hasVR, hasMinimap;
                    MapLoader.GetMapDimensions(selectedBoard.MapInfo.Image, out VR, out mapCenter, out mapSize, out minimapCenter, out minimapSize, out hasVR, out hasMinimap);
                    selectedBoard.MinimapRectangle = new MinimapRectangle(selectedBoard, new Microsoft.Xna.Framework.Rectangle(-minimapCenter.X, -minimapCenter.Y, minimapSize.X, minimapSize.Y));
                }
                else
                {
                    selectedBoard.MinimapRectangle = new MinimapRectangle(selectedBoard, new Microsoft.Xna.Framework.Rectangle(-selectedBoard.CenterPoint.X + 100, -selectedBoard.CenterPoint.Y + 100, selectedBoard.MapSize.X - 200, selectedBoard.MapSize.Y - 200));
                }
                selectedBoard.RegenerateMinimap();
            }
        }
Example #2
0
        public void DeserializeBoard(string data)
        {
            dynamic serData = JsonConvert.DeserializeObject(data);

            serData = Deserialize2(serData);
            if (serData.userobjs != null)
            {
                board.ParentControl.UserObjects.DeserializeObjects(serData.userobjs);
            }
            board.MapSize     = DeserializePoint(serData.size);
            board.CenterPoint = DeserializePoint(serData.center);
            MapleEmptyRectangle.SerializationForm vrSer = JsonConvert.DeserializeObject <MapleEmptyRectangle.SerializationForm>(serData.vr);
            MapleEmptyRectangle.SerializationForm mmSer = JsonConvert.DeserializeObject <MapleEmptyRectangle.SerializationForm>(serData.minimap);
            board.VRRectangle      = vrSer == null ? null : new VRRectangle(board, vrSer);
            board.MinimapRectangle = mmSer == null ? null : new MinimapRectangle(board, mmSer);
            board.MapInfo          = JsonConvert.DeserializeObject <MapInfo>(serData.info);
            foreach (ISerializable item in DeserializeList(serData.items))
            {
                item.AddToBoard(null);
            }
            board.RegenerateMinimap();
            board.TabPage.Text = board.MapInfo.strMapName;
            foreach (Layer l in board.Layers)
            {
                l.RecheckTileSet();
                l.RecheckZM();
            }
            MapLoader.GenerateDefaultZms(board);
        }
Example #3
0
        private void mapAddMinimap(object sender, EventArgs e)
        {
            Board selectedBoard = (Board)((ToolStripMenuItem)sender).Tag;

            lock (selectedBoard.ParentControl)
            {
                if (selectedBoard.MapInfo.Image != null)
                {
                    Microsoft.Xna.Framework.Rectangle VR;
                    Microsoft.Xna.Framework.Point     mapCenter, mapSize, minimapCenter, minimapSize;
                    bool hasVR, hasMinimap;
                    MapLoader.GetMapDimensions(selectedBoard.MapInfo.Image, out VR, out mapCenter, out mapSize, out minimapCenter, out minimapSize, out hasVR, out hasMinimap);
                    selectedBoard.MinimapRectangle = new MinimapRectangle(selectedBoard, new Microsoft.Xna.Framework.Rectangle(-minimapCenter.X, -minimapCenter.Y, minimapSize.X, minimapSize.Y));
                }
                else
                {
                    selectedBoard.MinimapRectangle = new MinimapRectangle(selectedBoard, new Microsoft.Xna.Framework.Rectangle(-selectedBoard.CenterPoint.X + 100, -selectedBoard.CenterPoint.Y + 100, selectedBoard.MapSize.X - 200, selectedBoard.MapSize.Y - 200));
                }
                selectedBoard.RegenerateMinimap();
            }
        }
Example #4
0
 public static MapSimulator CreateMapSimulator(Board mapBoard)
 {
     if (mapBoard.MiniMap == null) mapBoard.RegenerateMinimap();
     MapSimulator result = new MapSimulator(mapBoard);
     List<WzObject> usedProps = new List<WzObject>();
     WzDirectory MapFile = Program.WzManager["map"];
     WzDirectory tileDir = (WzDirectory)MapFile["Tile"];
     GraphicsDevice device = result.DxDevice;
     foreach (LayeredItem tileObj in mapBoard.BoardItems.TileObjs)
         result.mapObjects[tileObj.LayerNumber].Add(CreateMapItemFromProperty((WzImageProperty)tileObj.BaseInfo.ParentObject, tileObj.X, tileObj.Y, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, tileObj is IFlippable ? ((IFlippable)tileObj).Flip : false));
     foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds)
         result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip));
     foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds)
         result.backgrounds.Add(CreateBackgroundFromProperty((WzImageProperty)background.BaseInfo.ParentObject, background.BaseX, background.BaseY, background.rx, background.ry, background.cx, background.cy, background.a, background.type, background.front, mapBoard.CenterPoint.X, mapBoard.CenterPoint.Y, result.DxDevice, ref usedProps, background.Flip));
     foreach (WzObject obj in usedProps) obj.MSTag = null;
     usedProps.Clear();
     GC.Collect();
     GC.WaitForPendingFinalizers();
     return result;
 }