Beispiel #1
0
 void SaveTileMaps()
 {
     if (!Directory.Exists(m_filePath + "\\Worlds\\" + m_worldName + "\\TileMaps"))
     {
         Directory.CreateDirectory(m_filePath + "\\Worlds\\" + m_worldName + "\\TileMaps");
     }
     foreach (string file in Directory.GetFiles(m_filePath + "\\Worlds\\" + m_worldName + "\\TileMaps"))
     {
         FileInfo fileInfo = new FileInfo(file);
         if (fileInfo.Name.Contains("tilemap"))
         {
             File.Delete(file);
         }
     }
     for (int i = 0; i < tileMaps.GetTileMapCount(); i++)
     {
         Stream    oStream = new FileStream(m_filePath + "\\Worlds\\" + m_worldName + "\\TileMaps\\tilemap" + i.ToString() + ".png", FileMode.Create);
         Texture2D tileMap = tileMaps.GetTileMap(i);
         tileMap.SaveAsPng(oStream, tileMap.Width, tileMap.Height);
         oStream.Close();
     }
 }
        public TileToolBar(Texture2D background, Texture2D floorTex, Texture2D roofTex, Texture2D tileBoxTex, Texture2D arrowLeft, Texture2D arrowRight, Texture2D openTex, Texture2D deleteTex, Texture2D openFileBGTex, Texture2D closeButtonTex, Texture2D folderTex, Texture2D fileTex, Texture2D backButtonTex, Texture2D hScrollBarBGTex, Texture2D hScrollBarButtonTex, Texture2D vScrollBarBGTex, Texture2D vScrollBarButtonTex, SpriteFont numberFont, SpriteFont fileFont, GraphicsDeviceManager graphics, int nLayers, TileMaps tileMaps, Network network)
        {
            if (tileMaps.GetTileMapCount() > 0)
            {
                m_Ready = true;
            }

            m_tileMaps = tileMaps;
            m_network  = network;

            m_backGroundTexture = background;
            m_tileBoxTexture    = tileBoxTex;

            m_toolBarSize     = new Size(graphics.PreferredBackBufferWidth, 320);
            m_toolBarLocation = new Point(0, graphics.PreferredBackBufferHeight - m_toolBarSize.Height);

            m_layerDrawDistance = 17;
            m_layerBoxLocation  = new Point(8, 48);
            m_layerButtonWidth  = 48;
            InitializeFloorLayerButtons(floorTex, nLayers);
            InitializeRoofLayerButtons(roofTex, nLayers);

            m_tileBoxSize       = new Size(640, 256);
            m_activeTileMapSize = m_tileBoxSize;
            m_nActiveTileMap    = 0;
            m_tileBoxLocation   = new Point(m_layerBoxLocation.X + 8 + m_layerButtonWidth, 48);
            m_tileZoom          = 2;
            m_tileBoxBorderSize = 5;

            m_tileMapSelecterLoc  = new Point(0, 14);
            m_tileMapSelecterSize = new Size(96, 32);
            InitializeTileMapSelecter(arrowLeft, arrowRight, numberFont);

            m_openTileMapButtonLoc    = new Point(m_tileBoxLocation.X + m_tileBoxSize.Width + 17, m_tileBoxLocation.Y);
            m_openTileMapButtonSize   = new Size(32, 32);
            m_deleteTileMapButtonLoc  = new Point(m_openTileMapButtonLoc.X, m_openTileMapButtonLoc.Y + m_openTileMapButtonSize.Height + 5);
            m_deleteTileMapButtonSize = new Size(32, 32);
            InitializeTileMapButtons(openTex, deleteTex);
            m_prevMouseState = Mouse.GetState();

            Size          openFileWindowSize = new Size(768, 512);
            List <string> fileTypes          = new List <string>();

            fileTypes.Add(".png");
            Point openFileWindowLocation = new Point(graphics.PreferredBackBufferWidth / 2 - openFileWindowSize.Width / 2, graphics.PreferredBackBufferHeight / 2 - openFileWindowSize.Height / 2);

            m_openFileWindow = new OpenFileWindow(openFileWindowLocation, openFileWindowSize,
                                                  openFileBGTex, closeButtonTex, backButtonTex, folderTex, fileTex, hScrollBarBGTex,
                                                  hScrollBarButtonTex, fileFont, System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures), fileTypes);
            m_openFileWindow.WindowOkEvent += new OkHandler(OpenFileWindowOk);

            m_hScrollBarTileBoxSize = new Size(m_tileBoxSize.Width + m_tileBoxBorderSize * 2, 16);
            m_hScrollBarTileBoxLoc  = new Point(m_tileBoxLocation.X - m_tileBoxBorderSize, m_tileBoxLocation.Y + m_tileBoxSize.Height);
            m_vScrollBarTileBoxSize = new Size(16, m_tileBoxSize.Height + m_tileBoxBorderSize * 2);
            m_vScrollBarTileBoxLoc  = new Point(m_tileBoxLocation.X + m_tileBoxSize.Width, m_tileBoxLocation.Y - m_tileBoxBorderSize);
            InitializeScrollBars(hScrollBarBGTex, hScrollBarButtonTex, vScrollBarBGTex, vScrollBarButtonTex);

            Texture2D tileMap = tileMaps.GetTileMap(m_nActiveTileMap);

            CalculateCropBounds(tileMap);
            ConfigurateScrollBars(tileMaps.TilePixSize());
        }
 void InitializeTileMapSelecter(Texture2D leftTex, Texture2D rightTex, SpriteFont font)
 {
     m_tileMapSelecter = new NumberSelecter(new Point(m_tileMapSelecterLoc.X + m_toolBarLocation.X, m_tileMapSelecterLoc.Y + m_toolBarLocation.Y), m_tileMapSelecterSize, m_nActiveTileMap, Color.White, leftTex, rightTex, font, 0, m_tileMaps.GetTileMapCount() - 1);
 }