From e30edb155ad9449df5078eb21ca4b33920be4785 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 30 Sep 2018 19:44:21 +0000 Subject: Added Tile and Data mode --- MapEd/Form1.Designer.cs | 93 ++++++++++++++++++++----------- MapEd/Form1.cs | 14 ++++- MapEd/MapControl.cs | 142 +++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 190 insertions(+), 59 deletions(-) diff --git a/MapEd/Form1.Designer.cs b/MapEd/Form1.Designer.cs index 81f3df5..5990a04 100644 --- a/MapEd/Form1.Designer.cs +++ b/MapEd/Form1.Designer.cs @@ -43,6 +43,7 @@ this.label2 = new System.Windows.Forms.Label(); this.tileMode = new System.Windows.Forms.RadioButton(); this.dataMode = new System.Windows.Forms.RadioButton(); + this.tileAndDataMode = new System.Windows.Forms.RadioButton(); this.panel = new MapEd.LayoutPanel(); this.map = new MapEd.MapControl(); this.mainMenu.SuspendLayout(); @@ -54,11 +55,13 @@ // // mainMenu // + this.mainMenu.ImageScalingSize = new System.Drawing.Size(32, 32); this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem}); this.mainMenu.Location = new System.Drawing.Point(0, 0); this.mainMenu.Name = "mainMenu"; - this.mainMenu.Size = new System.Drawing.Size(992, 24); + this.mainMenu.Padding = new System.Windows.Forms.Padding(12, 4, 0, 4); + this.mainMenu.Size = new System.Drawing.Size(1984, 44); this.mainMenu.TabIndex = 0; this.mainMenu.Text = "Main Menu"; // @@ -71,14 +74,14 @@ this.saveMenuItem, this.quitMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Size = new System.Drawing.Size(64, 36); this.fileToolStripMenuItem.Text = "File"; // // newMenuItem // this.newMenuItem.Name = "newMenuItem"; this.newMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newMenuItem.Size = new System.Drawing.Size(155, 22); + this.newMenuItem.Size = new System.Drawing.Size(274, 38); this.newMenuItem.Text = "New..."; this.newMenuItem.Click += new System.EventHandler(this.OnNew); // @@ -86,7 +89,7 @@ // this.loadMenuItem.Name = "loadMenuItem"; this.loadMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.loadMenuItem.Size = new System.Drawing.Size(155, 22); + this.loadMenuItem.Size = new System.Drawing.Size(274, 38); this.loadMenuItem.Text = "Open..."; this.loadMenuItem.Click += new System.EventHandler(this.OnLoad); // @@ -95,7 +98,7 @@ this.saveAsMenuItem.Enabled = false; this.saveAsMenuItem.Name = "saveAsMenuItem"; this.saveAsMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12; - this.saveAsMenuItem.Size = new System.Drawing.Size(155, 22); + this.saveAsMenuItem.Size = new System.Drawing.Size(274, 38); this.saveAsMenuItem.Text = "Save As..."; this.saveAsMenuItem.Click += new System.EventHandler(this.OnSaveAs); // @@ -104,14 +107,14 @@ this.saveMenuItem.Enabled = false; this.saveMenuItem.Name = "saveMenuItem"; this.saveMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveMenuItem.Size = new System.Drawing.Size(155, 22); + this.saveMenuItem.Size = new System.Drawing.Size(274, 38); this.saveMenuItem.Text = "Save"; this.saveMenuItem.Click += new System.EventHandler(this.OnSave); // // quitMenuItem // this.quitMenuItem.Name = "quitMenuItem"; - this.quitMenuItem.Size = new System.Drawing.Size(155, 22); + this.quitMenuItem.Size = new System.Drawing.Size(274, 38); this.quitMenuItem.Text = "Quit"; this.quitMenuItem.Click += new System.EventHandler(this.OnQuit); // @@ -128,23 +131,25 @@ "Filled Rectangle", "Circle", "Filled Circle"}); - this.drawingMode.Location = new System.Drawing.Point(13, 28); + this.drawingMode.Location = new System.Drawing.Point(26, 54); + this.drawingMode.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.drawingMode.Name = "drawingMode"; - this.drawingMode.Size = new System.Drawing.Size(121, 21); + this.drawingMode.Size = new System.Drawing.Size(238, 33); this.drawingMode.TabIndex = 1; this.drawingMode.SelectedIndexChanged += new System.EventHandler(this.OnDrawingMode); // // tileNumber // this.tileNumber.Enabled = false; - this.tileNumber.Location = new System.Drawing.Point(173, 29); + this.tileNumber.Location = new System.Drawing.Point(346, 56); + this.tileNumber.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.tileNumber.Maximum = new decimal(new int[] { 1000, 0, 0, 0}); this.tileNumber.Name = "tileNumber"; - this.tileNumber.Size = new System.Drawing.Size(58, 20); + this.tileNumber.Size = new System.Drawing.Size(116, 31); this.tileNumber.TabIndex = 2; this.tileNumber.ValueChanged += new System.EventHandler(this.OnTileNumber); // @@ -152,9 +157,10 @@ // this.tilePreview.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.tilePreview.Enabled = false; - this.tilePreview.Location = new System.Drawing.Point(237, 28); + this.tilePreview.Location = new System.Drawing.Point(474, 54); + this.tilePreview.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.tilePreview.Name = "tilePreview"; - this.tilePreview.Size = new System.Drawing.Size(32, 32); + this.tilePreview.Size = new System.Drawing.Size(64, 62); this.tilePreview.TabIndex = 3; this.tilePreview.TabStop = false; this.tilePreview.Click += new System.EventHandler(this.OnSelectTile); @@ -162,7 +168,8 @@ // dataNumber // this.dataNumber.Enabled = false; - this.dataNumber.Location = new System.Drawing.Point(314, 29); + this.dataNumber.Location = new System.Drawing.Point(628, 56); + this.dataNumber.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.dataNumber.Maximum = new decimal(new int[] { 1000000, 0, @@ -174,25 +181,27 @@ 0, -2147483648}); this.dataNumber.Name = "dataNumber"; - this.dataNumber.Size = new System.Drawing.Size(98, 20); + this.dataNumber.Size = new System.Drawing.Size(196, 31); this.dataNumber.TabIndex = 5; this.dataNumber.ValueChanged += new System.EventHandler(this.OnDataNumber); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(140, 31); + this.label1.Location = new System.Drawing.Point(280, 60); + this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.Size = new System.Drawing.Size(53, 25); this.label1.TabIndex = 6; this.label1.Text = "Tile:"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(275, 31); + this.label2.Location = new System.Drawing.Point(550, 60); + this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(33, 13); + this.label2.Size = new System.Drawing.Size(63, 25); this.label2.TabIndex = 7; this.label2.Text = "Data:"; // @@ -201,9 +210,10 @@ this.tileMode.AutoSize = true; this.tileMode.Checked = true; this.tileMode.Enabled = false; - this.tileMode.Location = new System.Drawing.Point(419, 31); + this.tileMode.Location = new System.Drawing.Point(838, 60); + this.tileMode.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.tileMode.Name = "tileMode"; - this.tileMode.Size = new System.Drawing.Size(72, 17); + this.tileMode.Size = new System.Drawing.Size(138, 29); this.tileMode.TabIndex = 8; this.tileMode.TabStop = true; this.tileMode.Text = "Tile Mode"; @@ -214,15 +224,29 @@ // this.dataMode.AutoSize = true; this.dataMode.Enabled = false; - this.dataMode.Location = new System.Drawing.Point(498, 31); + this.dataMode.Location = new System.Drawing.Point(996, 60); + this.dataMode.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); this.dataMode.Name = "dataMode"; - this.dataMode.Size = new System.Drawing.Size(78, 17); + this.dataMode.Size = new System.Drawing.Size(148, 29); this.dataMode.TabIndex = 9; this.dataMode.TabStop = true; this.dataMode.Text = "Data Mode"; this.dataMode.UseVisualStyleBackColor = true; this.dataMode.Click += new System.EventHandler(this.OnDataOrTileMode); // + // tileAndDataMode + // + this.tileAndDataMode.AutoSize = true; + this.tileAndDataMode.Enabled = false; + this.tileAndDataMode.Location = new System.Drawing.Point(1154, 60); + this.tileAndDataMode.Name = "tileAndDataMode"; + this.tileAndDataMode.Size = new System.Drawing.Size(233, 29); + this.tileAndDataMode.TabIndex = 11; + this.tileAndDataMode.TabStop = true; + this.tileAndDataMode.Text = "Tile And Data Mode"; + this.tileAndDataMode.UseVisualStyleBackColor = true; + this.tileAndDataMode.Click += new System.EventHandler(this.OnDataOrTileMode); + // // panel // this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -230,26 +254,29 @@ | System.Windows.Forms.AnchorStyles.Right))); this.panel.AutoScroll = true; this.panel.Controls.Add(this.map); - this.panel.Location = new System.Drawing.Point(12, 66); + this.panel.Location = new System.Drawing.Point(24, 127); + this.panel.Margin = new System.Windows.Forms.Padding(6); this.panel.Name = "panel"; - this.panel.Size = new System.Drawing.Size(968, 336); + this.panel.Size = new System.Drawing.Size(1936, 646); this.panel.TabIndex = 10; // // map // - this.map.Font = new System.Drawing.Font("Arial Narrow", 5.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.map.Location = new System.Drawing.Point(2, 2); + this.map.Font = new System.Drawing.Font("Microsoft Sans Serif", 5.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.map.Location = new System.Drawing.Point(4, 4); this.map.MapDrawMode = MapEd.MapControl.DrawMode.Plot; - this.map.Margin = new System.Windows.Forms.Padding(2); + this.map.MapPlotMode = MapEd.MapControl.PlotMode.Tile; + this.map.Margin = new System.Windows.Forms.Padding(4); this.map.Name = "map"; - this.map.Size = new System.Drawing.Size(480, 163); + this.map.Size = new System.Drawing.Size(960, 313); this.map.TabIndex = 4; // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(992, 414); + this.ClientSize = new System.Drawing.Size(1984, 796); + this.Controls.Add(this.tileAndDataMode); this.Controls.Add(this.panel); this.Controls.Add(this.dataMode); this.Controls.Add(this.tileMode); @@ -261,7 +288,8 @@ this.Controls.Add(this.drawingMode); this.Controls.Add(this.mainMenu); this.MainMenuStrip = this.mainMenu; - this.MinimumSize = new System.Drawing.Size(320, 200); + this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); + this.MinimumSize = new System.Drawing.Size(614, 319); this.Name = "Form1"; this.Text = "MapEd"; this.mainMenu.ResumeLayout(false); @@ -294,6 +322,7 @@ private System.Windows.Forms.RadioButton dataMode; private MapControl map; private LayoutPanel panel; + private System.Windows.Forms.RadioButton tileAndDataMode; } } diff --git a/MapEd/Form1.cs b/MapEd/Form1.cs index c990bcc..0bbf941 100644 --- a/MapEd/Form1.cs +++ b/MapEd/Form1.cs @@ -40,6 +40,7 @@ namespace MapEd tileMode.Enabled = true; dataMode.Enabled = true; tilePreview.Enabled = true; + tileAndDataMode.Enabled = true; } private void OnNew(object sender, EventArgs e) @@ -201,7 +202,18 @@ namespace MapEd private void OnDataOrTileMode(object sender, EventArgs e) { - map.SetDataMode(sender == dataMode); + if (sender == tileMode) + { + map.MapPlotMode = MapControl.PlotMode.Tile; + } + else if (sender == dataMode) + { + map.MapPlotMode = MapControl.PlotMode.Data; + } + else + { + map.MapPlotMode = MapControl.PlotMode.TileAndData; + } } private void OnSelectTile(object sender, EventArgs e) diff --git a/MapEd/MapControl.cs b/MapEd/MapControl.cs index 2acb8cb..50620ba 100644 --- a/MapEd/MapControl.cs +++ b/MapEd/MapControl.cs @@ -23,6 +23,13 @@ namespace MapEd FillCircle }; + public enum PlotMode + { + Tile = 1, + Data = 2, + TileAndData = 3 + }; + private const int SCALE = 2; private bool mapSet; @@ -32,7 +39,7 @@ namespace MapEd private int[,] map; private int[,] data; private TileStrip tiles; - private bool dataMode; + private PlotMode plotMode; private int tileNumber; private int dataNumber; @@ -84,7 +91,7 @@ namespace MapEd if (firstX == -1 && firstY == -1 && timerDraw) { - if (dataMode) + if (DataMode) { DrawData(timerX, timerY, data[timerY,timerX]); } @@ -112,6 +119,22 @@ namespace MapEd } } + public PlotMode MapPlotMode + { + get + { + return plotMode; + } + + set + { + plotMode = value; + firstX = -1; + firstY = -1; + RedrawMap(); + } + } + public void SetMap(int width, int height, TileStrip tiles, int tileSize) { this.width = width; @@ -184,12 +207,6 @@ namespace MapEd dataNumber = data; } - public void SetDataMode(bool on) - { - dataMode = on; - RedrawMap(); - } - public void SetMap(int[,] map) { for(int y = 0; y < height; y++) @@ -216,6 +233,22 @@ namespace MapEd RedrawMap(); } + private bool DataMode + { + get + { + return (plotMode & PlotMode.Data) == PlotMode.Data; + } + } + + private bool TileMode + { + get + { + return (plotMode & PlotMode.Tile) == PlotMode.Tile; + } + } + private void OnMouseMove(object sender, MouseEventArgs e) { if (!mapSet) @@ -228,13 +261,18 @@ namespace MapEd if (x < width && y < height && (x != lastX || y != lastY)) { - if (dataMode) + if (DataMode) { - if (e.Button == MouseButtons.Left && drawMode == DrawMode.Plot) + if (DataMode && e.Button == MouseButtons.Left && drawMode == DrawMode.Plot) { data[y,x] = dataNumber; } + if (TileMode && e.Button == MouseButtons.Left && drawMode == DrawMode.Plot) + { + map[y,x] = tileNumber; + } + if (lastX != -1 && lastY != -1) { DrawData(lastX, lastY, data[lastY,lastX]); @@ -262,7 +300,7 @@ namespace MapEd lastX = x; lastY = y; - if (dataMode) + if (DataMode) { toolTip.Show(data[y,x].ToString(), this, 500); } @@ -278,7 +316,7 @@ namespace MapEd if (lastX != -1 && lastY != -1) { - if (dataMode) + if (DataMode) { DrawData(lastX, lastY, data[lastY,lastX]); } @@ -308,14 +346,15 @@ namespace MapEd switch(drawMode) { case DrawMode.Plot: - if (dataMode) + if (DataMode) { if (data[y,x] != dataNumber) { data[y,x] = dataNumber; } } - else + + if (TileMode) { if (map[y,x] != tileNumber) { @@ -470,9 +509,15 @@ namespace MapEd { if (y == y1 || y == y2 || x == x1 | x == x2 | fill) { - if (dataMode) + if (DataMode) { data[y,x] = dataNumber; + + if (TileMode) + { + map[y,x] = tileNumber; + } + DrawData(x, y, dataNumber); } else @@ -514,9 +559,15 @@ namespace MapEd { if (XInRange(px1) && YInRange(py)) { - if (dataMode) + if (DataMode) { data[py, px1] = dataNumber; + + if (TileMode) + { + map[py,px1] = tileNumber; + } + DrawData(px1, py, dataNumber); } else @@ -531,9 +582,15 @@ namespace MapEd { if (XInRange(px1) && YInRange(py)) { - if (dataMode) + if (DataMode) { data[py, px1] = dataNumber; + + if (TileMode) + { + map[py,px1] = tileNumber; + } + DrawData(px1, py, dataNumber); } else @@ -545,9 +602,15 @@ namespace MapEd if (XInRange(px2) && YInRange(py)) { - if (dataMode) + if (DataMode) { data[py, px2] = dataNumber; + + if (TileMode) + { + map[py,px2] = tileNumber; + } + DrawData(px2, py, dataNumber); } else @@ -565,7 +628,7 @@ namespace MapEd { int back; - if (dataMode) + if (DataMode && !TileMode) { back = data[y,x]; @@ -594,7 +657,7 @@ namespace MapEd return; } - if (dataMode) + if (DataMode && !TileMode) { if (data[y,x] != back) { @@ -612,7 +675,16 @@ namespace MapEd } map[y,x] = tileNumber; - DrawCell(x, y, tileNumber); + + if (DataMode) + { + data[y,x] = dataNumber; + DrawData(x, y, dataNumber); + } + else + { + DrawCell(x, y, tileNumber); + } } FloodFill(x + 1, y, back); @@ -655,9 +727,15 @@ namespace MapEd int x = x1; int y = y1; - if (dataMode) + if (DataMode) { data[y,x] = dataNumber; + + if (TileMode) + { + map[y,x] = tileNumber; + } + DrawData(x, y, dataNumber); } else @@ -682,9 +760,15 @@ namespace MapEd x+=ix; } - if (dataMode) + if (DataMode) { data[y,x] = dataNumber; + + if (TileMode) + { + map[y,x] = tileNumber; + } + DrawData(x, y, dataNumber); } else @@ -710,9 +794,15 @@ namespace MapEd x+=ix; } - if (dataMode) + if (DataMode) { data[y,x] = dataNumber; + + if (TileMode) + { + map[y,x] = tileNumber; + } + DrawData(x, y, dataNumber); } else @@ -728,7 +818,7 @@ namespace MapEd { using(Graphics g = CreateGraphics()) { - if (dataMode) + if (DataMode) { for(int y = 0; y < height; y++) { @@ -760,7 +850,7 @@ namespace MapEd private void RedrawMap(int x1, int y1, int x2, int y2, Graphics g) { - if (dataMode) + if (DataMode) { for(int y = y1; y <= y2; y++) { -- cgit v1.2.3