Example #1
0
        /// <summary>
        /// Shows dialog to create a new map
        /// </summary>
        private void ShowNewDialog(object sender, EventArgs e)
        {
            NewMapDialog newMapDialog = new NewMapDialog(rows, cols, tilewidth, tileheight);

            //Show the new map dialog and check if OK clicked
            if (newMapDialog.ShowDialog(this) == DialogResult.OK)
            {
                //If current map not saved then provide option to user to save or cancel
                if (ChangesMade)
                //if (currentDocumentPath != null)	//ie. current document has been previously saved
                {
                    var dlgResult = MessageBox.Show("Save changes before creating a new map?", "New map...", MessageBoxButtons.YesNoCancel);
                    if (dlgResult == DialogResult.Cancel)
                    {
                        //Break out and cancel
                        return;
                    }
                    else if (dlgResult == DialogResult.Yes)
                    {
                        //Save first
                        Save();
                    }
                }

                //Save map parameters for next time
                rows       = NewMapDialog.Rows;
                cols       = NewMapDialog.Cols;
                tilewidth  = NewMapDialog.TileWidth;
                tileheight = NewMapDialog.TileHeight;

                //Continue with creating a new map once
                NewPKRMap(cols, rows, tilewidth, tileheight);
            }
        }
Example #2
0
        private void 新規作成ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewMapDialog nmd = new NewMapDialog();

            if (nmd.ShowDialog() == DialogResult.OK)
            {
                MapTabPage mtp = new MapTabPage(nmd.MapName);
                mtp.Data.Width  = nmd.MapWidth;
                mtp.Data.Height = nmd.MapHeight;
                this.tabControl1.Controls.Add(mtp);
                nmd.Dispose();
            }
        }
Example #3
0
        private void btn_New_Click(object sender, RoutedEventArgs e)
        {
            NewMapDialog dialog = new NewMapDialog();

            if (dialog.ShowDialog() == true)
            {
                InitMap(dialog.MapWidth, dialog.MapHeight);
                btn_New.IsEnabled = true;
                btn_Reset.IsEnabled = true;
                btn_Save.IsEnabled = true;
                btn_Randomize.IsEnabled = true;
                btn_Red.IsEnabled = true;
                btn_Black.IsEnabled = true;
            }
        }
Example #4
0
        // Handle making a new map
        private void NewMap_Click(object sender, EventArgs e)
        {
            //int mapsize;

            NewMapDialog NewMapForm = new NewMapDialog();

            if (NewMapForm.ShowDialog() == DialogResult.OK)
            {
                mapsize   = int.Parse(NewMapForm.MapSize);
                MapName   = NewMapForm.MapName;
                this.Text = MapName;

                // Make sure the value was between 17-100
                if (mapsize < 17 || mapsize > 60)
                {
                    MessageBox.Show("The map size you entered was incorrect", "ERROR!");
                    return;
                }

                MapArray = new Tile[mapsize, mapsize];

                // Set the image locations for the tiles
                int xpos = 1;
                int ypos = 1;
                for (int i = 0; i < mapsize; i++)
                {
                    for (int j = 0; j < mapsize; j++)
                    {
                        MapArray[i, j] = new Tile(TileSet[BackgroundTileIndex].TileImage, TileSet[BackgroundTileIndex].Name, xpos, ypos);
                        xpos          += 33;
                    }
                    xpos  = 1;
                    ypos += 33;
                }

                // now we need to create the map
                int MapImageWidth  = (mapsize * 32) + ((mapsize - 1) * 1);
                int MapImageHeight = MapImageWidth;

                Size mapPixelSize = new Size(MapImageWidth, MapImageHeight);
                pan_MapWindow.AutoScrollMinSize = mapPixelSize;

                // Create a new bitmap to draw the map onto
                MapImage = new Bitmap(MapImageWidth, MapImageHeight, PixelFormat.Format32bppRgb);

                // Get a graphic context from the image so we can draw to it
                Graphics g_TS = Graphics.FromImage(MapImage);

                // Clear out the image to be all white
                Rectangle  background = new Rectangle(0, 0, MapImageWidth, MapImageHeight);
                SolidBrush myBrush    = new SolidBrush(Color.White);
                g_TS.FillRectangle(myBrush, background);

                // Now loop through and print vertical and horizontal lines
                xpos = 0;
                ypos = 0;
                Pen myPen = new Pen(Color.Black, 1);

                // vertical lines
                for (int i = 0; i < mapsize; i++)
                {
                    g_TS.DrawLine(myPen, xpos, ypos, xpos, MapImageHeight);
                    xpos += 33;
                }
                xpos = 0;
                // Horizontal lines
                for (int i = 0; i < mapsize; i++)
                {
                    g_TS.DrawLine(myPen, xpos, ypos, MapImageWidth, ypos);
                    ypos += 33;
                }

                // Draw the base map, which is currently defaulted to grass tiles
                for (int i = 0; i < mapsize; i++)
                {
                    for (int j = 0; j < mapsize; j++)
                    {
                        AddTileToMap(i, j);
                    }
                }

                g_TS.Dispose();
                MapCreated = true;
                pan_MapWindow.Invalidate();
            }
        }