1
0
mirror of https://github.com/MainMemory/BlupiEdit.git synced 2025-03-16 18:45:07 +01:00

Adding more menu events, adding basic controls for Tiles and Objects tabs.

This commit is contained in:
MainMemory 2014-06-21 16:52:51 -05:00
parent ca193405f1
commit dfedb83324
3 changed files with 191 additions and 19 deletions

View File

@ -12,8 +12,11 @@ namespace BlupiEdit
{ {
public partial class LevelSelectForm : Form public partial class LevelSelectForm : Form
{ {
public LevelSelectForm() LevelSelectFormMode mode;
public LevelSelectForm(LevelSelectFormMode mode)
{ {
this.mode = mode;
InitializeComponent(); InitializeComponent();
} }
@ -22,6 +25,8 @@ namespace BlupiEdit
private void LevelSelectForm_Load(object sender, EventArgs e) private void LevelSelectForm_Load(object sender, EventArgs e)
{ {
if (mode == LevelSelectFormMode.Save)
openButton.Text = "&Save";
levelSetList.BeginUpdate(); levelSetList.BeginUpdate();
for (int i = 1; i < 9; i++) for (int i = 1; i < 9; i++)
if (File.Exists(string.Format("data\\info{0:000}.blp", i))) if (File.Exists(string.Format("data\\info{0:000}.blp", i)))
@ -100,7 +105,9 @@ namespace BlupiEdit
private void numericUpDown1_ValueChanged(object sender, EventArgs e) private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{ {
if ((levelList.SelectedIndex = levels.IndexOf((int)numericUpDown1.Value)) == -1) levelList.SelectedIndex = levels.IndexOf((int)numericUpDown1.Value);
if (mode == LevelSelectFormMode.Save) return;
if (levelList.SelectedIndex == -1)
openButton.Text = "&New"; openButton.Text = "&New";
else else
openButton.Text = "&Open"; openButton.Text = "&Open";
@ -110,4 +117,10 @@ namespace BlupiEdit
public int LevelNum { get { return (int)numericUpDown1.Value; } } public int LevelNum { get { return (int)numericUpDown1.Value; } }
} }
public enum LevelSelectFormMode
{
Open,
Save
}
} }

View File

@ -38,10 +38,22 @@
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
this.tilePanel = new System.Windows.Forms.UserControl();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.objectPanel = new System.Windows.Forms.UserControl();
this.vScrollBar2 = new System.Windows.Forms.VScrollBar();
this.hScrollBar2 = new System.Windows.Forms.HScrollBar();
this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// menuStrip1 // menuStrip1
@ -88,6 +100,7 @@
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(154, 22); this.saveToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.saveToolStripMenuItem.Text = "&Save"; this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
// //
// saveAsToolStripMenuItem // saveAsToolStripMenuItem
// //
@ -95,6 +108,7 @@
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(154, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.saveAsToolStripMenuItem.Text = "Save &As..."; this.saveAsToolStripMenuItem.Text = "Save &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
@ -106,6 +120,7 @@
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(154, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
// //
// tabControl1 // tabControl1
// //
@ -121,6 +136,7 @@
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.tableLayoutPanel1);
this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1"; this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
@ -129,8 +145,54 @@
this.tabPage1.Text = "Tiles"; this.tabPage1.Text = "Tiles";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.vScrollBar1, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.hScrollBar1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.tilePanel, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(570, 506);
this.tableLayoutPanel1.TabIndex = 0;
//
// vScrollBar1
//
this.vScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.vScrollBar1.Enabled = false;
this.vScrollBar1.Location = new System.Drawing.Point(553, 0);
this.vScrollBar1.Name = "vScrollBar1";
this.vScrollBar1.Size = new System.Drawing.Size(17, 489);
this.vScrollBar1.TabIndex = 0;
//
// hScrollBar1
//
this.hScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.hScrollBar1.Enabled = false;
this.hScrollBar1.Location = new System.Drawing.Point(0, 489);
this.hScrollBar1.Name = "hScrollBar1";
this.hScrollBar1.Size = new System.Drawing.Size(553, 17);
this.hScrollBar1.TabIndex = 1;
//
// tilePanel
//
this.tilePanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.tilePanel.Location = new System.Drawing.Point(3, 3);
this.tilePanel.Name = "tilePanel";
this.tilePanel.Size = new System.Drawing.Size(547, 483);
this.tilePanel.TabIndex = 2;
//
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.tableLayoutPanel2);
this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
@ -139,6 +201,51 @@
this.tabPage2.Text = "Objects"; this.tabPage2.Text = "Objects";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 2;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.Controls.Add(this.objectPanel, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.vScrollBar2, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.hScrollBar2, 0, 1);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.Size = new System.Drawing.Size(570, 506);
this.tableLayoutPanel2.TabIndex = 1;
//
// objectPanel
//
this.objectPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.objectPanel.Location = new System.Drawing.Point(3, 3);
this.objectPanel.Name = "objectPanel";
this.objectPanel.Size = new System.Drawing.Size(547, 483);
this.objectPanel.TabIndex = 3;
//
// vScrollBar2
//
this.vScrollBar2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.vScrollBar2.Enabled = false;
this.vScrollBar2.Location = new System.Drawing.Point(553, 0);
this.vScrollBar2.Name = "vScrollBar2";
this.vScrollBar2.Size = new System.Drawing.Size(17, 489);
this.vScrollBar2.TabIndex = 0;
//
// hScrollBar2
//
this.hScrollBar2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.hScrollBar2.Enabled = false;
this.hScrollBar2.Location = new System.Drawing.Point(0, 489);
this.hScrollBar2.Name = "hScrollBar2";
this.hScrollBar2.Size = new System.Drawing.Size(553, 17);
this.hScrollBar2.TabIndex = 1;
//
// tabPage3 // tabPage3
// //
this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Location = new System.Drawing.Point(4, 22);
@ -160,10 +267,14 @@
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "BlupiEdit"; this.Text = "BlupiEdit";
this.Load += new System.EventHandler(this.MainForm_Load); this.Load += new System.EventHandler(this.MainForm_Load);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -183,6 +294,14 @@
private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.VScrollBar vScrollBar1;
private System.Windows.Forms.HScrollBar hScrollBar1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.VScrollBar vScrollBar2;
private System.Windows.Forms.HScrollBar hScrollBar2;
private System.Windows.Forms.UserControl tilePanel;
private System.Windows.Forms.UserControl objectPanel;
} }
} }

View File

@ -11,7 +11,7 @@ namespace BlupiEdit
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
int userid, levelnum;
public MainForm() public MainForm()
{ {
@ -24,9 +24,18 @@ namespace BlupiEdit
LoadGame(Program.Arguments[0]); LoadGame(Program.Arguments[0]);
} }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (LevelData.CurrentLevel != null)
switch (MessageBox.Show(this, "Do you want to save?", "BlupiEdit", MessageBoxButtons.YesNoCancel))
{
case DialogResult.Yes:
LevelData.SaveLevel();
break;
case DialogResult.Cancel:
e.Cancel = true;
break;
}
} }
private void openToolStripMenuItem_Click(object sender, EventArgs e) private void openToolStripMenuItem_Click(object sender, EventArgs e)
@ -44,22 +53,53 @@ namespace BlupiEdit
private void changeLevelToolStripMenuItem_Click(object sender, EventArgs e) private void changeLevelToolStripMenuItem_Click(object sender, EventArgs e)
{ {
using (LevelSelectForm ls = new LevelSelectForm()) using (LevelSelectForm ls = new LevelSelectForm(LevelSelectFormMode.Open))
if (ls.ShowDialog(this) == DialogResult.OK) if (ls.ShowDialog(this) == DialogResult.OK)
{ {
LevelData.LoadLevel(ls.UserID, ls.LevelNum); userid = ls.UserID;
levelnum = ls.LevelNum;
LevelData.LoadLevel(userid, levelnum);
// TODO: more stuff // TODO: more stuff
StringBuilder sb = new StringBuilder("BlupiEdit - Speedy Blupi"); UpdateFormText();
if (LevelData.IsBlupi2) sb.Append(" 2"); saveAsToolStripMenuItem.Enabled = saveToolStripMenuItem.Enabled = true;
sb.Append(" - ");
if (ls.UserID == 0)
sb.AppendFormat("World {0:000}", ls.LevelNum);
else
sb.AppendFormat("User {0} Design {1:000}", ls.UserID, ls.LevelNum);
if (!string.IsNullOrEmpty(LevelData.CurrentLevel.LevelName))
sb.AppendFormat(" - {0}", LevelData.CurrentLevel.LevelName);
Text = sb.ToString();
} }
} }
private void UpdateFormText()
{
StringBuilder sb = new StringBuilder("BlupiEdit - Speedy Blupi");
if (LevelData.IsBlupi2) sb.Append(" 2");
sb.Append(" - ");
if (userid == 0)
sb.AppendFormat("World {0:000}", levelnum);
else
sb.AppendFormat("User {0} Design {1:000}", userid, levelnum);
if (!string.IsNullOrEmpty(LevelData.CurrentLevel.LevelName))
sb.AppendFormat(" - {0}", LevelData.CurrentLevel.LevelName);
Text = sb.ToString();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
LevelData.SaveLevel();
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
using (LevelSelectForm ls = new LevelSelectForm(LevelSelectFormMode.Save))
if (ls.ShowDialog(this) == DialogResult.OK)
{
userid = ls.UserID;
levelnum = ls.LevelNum;
LevelData.CurrentLevelPath = LevelData.GetLevelName(userid, levelnum);
LevelData.SaveLevel();
UpdateFormText();
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
} }
} }