Exemplo n.º 1
0
        /// <summary>
        /// Event handler for the "New Map" menu item.  Launches
        /// a dialog to colleced the needed map information. If 
        /// the dialog is successful, the resulting map is loaded
        /// into the editor.
        /// </summary>
        void NewMapMenuClicked(object sender, EventArgs e)
        {
            if (mapDirty)
            {
                if (DialogResult.Yes != MessageBox.Show("The map has not been saved.  Continue creating a new map?", "Warning", MessageBoxButtons.YesNo))
                    return;
            }

            MapDialog mapDialog = new MapDialog();

            if (mapDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Store the resulting tilemap
                tilemap = mapDialog.Tilemap;
                mapViewerControl.Tilemap = tilemap;

                // Set the scrollbar maximums to match our map size
                hScrollBar2.Maximum = tilemap.Width;
                vScrollBar1.Maximum = tilemap.Height;

                // Clear our old lists
                tileImageList.Images.Clear();
                tileListView.Items.Clear();
                tilePalette.Clear();

                // Mark the map as dirty until it is saved
                mapDirty = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Event handler for the "New Map" menu item.  Launches
        /// a dialog to colleced the needed map information. If 
        /// the dialog is successful, the resulting map is loaded
        /// into the editor.
        /// </summary>
        void NewMapClicked(object sender, EventArgs e)
        {
            if (mapDirty)
            {
                if(DialogResult.Yes != MessageBox.Show("The map has not been saved.  Continue creating a new map?", "Warning", MessageBoxButtons.YesNo))
                return;
            }

            MapDialog mapDialog = new MapDialog();

            if (mapDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Store the resulting tilemap
                tilemap = mapDialog.Tilemap;

                // Set the scrollbar maximums to match our map size
                hScrollBarMap.Maximum = tilemap.Width;
                vScrollBarMap.Maximum = tilemap.Height;

                // Clear our old lists
                tileImageList.Images.Clear();
                tileListView.Items.Clear();
                tilePalette.Clear();
                listBoxLayers.Items.Clear();

                // Add our layers to the layer list gui
                foreach(TilemapLayer layer in tilemap.Layers)
                {
                    listBoxLayers.Items.Add(layer.Name);
                }

                // Mark the map as dirty until it is saved
                mapDirty = true;
            }
        }