diff --git a/SequenceEditor/Form1.Designer.cs b/SequenceEditor/Form1.Designer.cs index c2985f76f4..4bc482aae7 100644 --- a/SequenceEditor/Form1.Designer.cs +++ b/SequenceEditor/Form1.Designer.cs @@ -28,33 +28,102 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.surface1 = new SequenceEditor.Surface(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.surface1); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(708, 518); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(708, 543); + this.toolStripContainer1.TabIndex = 0; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); + // // surface1 // this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; this.surface1.Location = new System.Drawing.Point(0, 0); this.surface1.Name = "surface1"; - this.surface1.Size = new System.Drawing.Size(708, 543); + this.surface1.Size = new System.Drawing.Size(708, 518); this.surface1.TabIndex = 0; this.surface1.Text = "surface1"; // + // toolStrip1 + // + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButton1, + this.toolStripButton2}); + this.toolStrip1.Location = new System.Drawing.Point(3, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(191, 25); + this.toolStrip1.TabIndex = 0; + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(113, 22); + this.toolStripButton1.Text = "Add Another SHP..."; + this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); + // + // toolStripButton2 + // + this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); + this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton2.Name = "toolStripButton2"; + this.toolStripButton2.Size = new System.Drawing.Size(35, 22); + this.toolStripButton2.Text = "Save"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(708, 543); - this.Controls.Add(this.surface1); + this.Controls.Add(this.toolStripContainer1); this.Name = "Form1"; this.Text = "OpenRA Sequence Viewer"; + this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); this.ResumeLayout(false); } #endregion + private System.Windows.Forms.ToolStripContainer toolStripContainer1; private Surface surface1; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripButton toolStripButton1; + private System.Windows.Forms.ToolStripButton toolStripButton2; + } } diff --git a/SequenceEditor/Form1.cs b/SequenceEditor/Form1.cs index 6eb480d7f7..089ba7893b 100644 --- a/SequenceEditor/Form1.cs +++ b/SequenceEditor/Form1.cs @@ -17,5 +17,12 @@ namespace SequenceEditor InitializeComponent(); Text += " - " + Program.UnitName; } + + void toolStripButton1_Click(object sender, EventArgs e) + { + var shp = GetTextForm.GetString( "Add SHP..." ); + if (shp == null) return; + Program.Shps.Add(shp, Program.LoadAndResolve(shp)); + } } } diff --git a/SequenceEditor/Form1.resx b/SequenceEditor/Form1.resx index ff31a6db56..63ba374c02 100644 --- a/SequenceEditor/Form1.resx +++ b/SequenceEditor/Form1.resx @@ -117,4 +117,38 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oU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JaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + \ No newline at end of file diff --git a/SequenceEditor/GetTextForm.Designer.cs b/SequenceEditor/GetTextForm.Designer.cs new file mode 100644 index 0000000000..f10ff16949 --- /dev/null +++ b/SequenceEditor/GetTextForm.Designer.cs @@ -0,0 +1,94 @@ +namespace SequenceEditor +{ + partial class GetTextForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.Location = new System.Drawing.Point(13, 13); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(337, 20); + this.textBox1.TabIndex = 0; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button1.Location = new System.Drawing.Point(194, 50); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 1; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button2.Location = new System.Drawing.Point(275, 50); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Cancel"; + this.button2.UseVisualStyleBackColor = true; + // + // GetTextForm + // + this.AcceptButton = this.button1; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.button2; + this.ClientSize = new System.Drawing.Size(362, 85); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GetTextForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Placeholder"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} \ No newline at end of file diff --git a/SequenceEditor/GetTextForm.cs b/SequenceEditor/GetTextForm.cs new file mode 100644 index 0000000000..ba79aa3df8 --- /dev/null +++ b/SequenceEditor/GetTextForm.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace SequenceEditor +{ + public partial class GetTextForm : Form + { + public GetTextForm() + { + InitializeComponent(); + } + + public static string GetString(string title) + { + using (var f = new GetTextForm()) + { + f.Text = title; + if (DialogResult.OK != f.ShowDialog()) + return null; + return f.textBox1.Text; + } + } + } +} diff --git a/SequenceEditor/GetTextForm.resx b/SequenceEditor/GetTextForm.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/SequenceEditor/GetTextForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs index c6bc95a71e..f79f693a95 100644 --- a/SequenceEditor/Program.cs +++ b/SequenceEditor/Program.cs @@ -17,7 +17,7 @@ namespace SequenceEditor public static Palette Pal; public static Dictionary Sequences = new Dictionary(); - static Bitmap[] LoadAndResolve( string shp ) + public static Bitmap[] LoadAndResolve( string shp ) { var reader = new ShpReader(FileSystem.Open(shp + ".shp")); return reader.Select(ih => diff --git a/SequenceEditor/SequenceEditor.csproj b/SequenceEditor/SequenceEditor.csproj index 4617ddb3f2..3470d8969b 100644 --- a/SequenceEditor/SequenceEditor.csproj +++ b/SequenceEditor/SequenceEditor.csproj @@ -67,11 +67,20 @@ Form1.cs + + Form + + + GetTextForm.cs + Form1.cs + + GetTextForm.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/SequenceEditor/Surface.cs b/SequenceEditor/Surface.cs index c5e5de29a3..e90709231c 100644 --- a/SequenceEditor/Surface.cs +++ b/SequenceEditor/Surface.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; +using IjwFramework.Types; namespace SequenceEditor { @@ -20,6 +21,8 @@ namespace SequenceEditor = new Dictionary>(); Point mousePos; + Point clickPos; + bool isDragging; protected override void OnMouseMove(MouseEventArgs e) { @@ -28,6 +31,38 @@ namespace SequenceEditor Invalidate(); } + Pair? FindFrameAt(Point p) + { + if (items.Count > 0) + { + foreach (var shp in items) + { + var sel = shp.Value.FirstOrDefault(a => a.Value.Contains(mousePos)); + if (!sel.Value.IsEmpty) + return Pair.New(shp.Key, sel.Key); + } + } + + return null; + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + var frameAtPoint = FindFrameAt(e.Location); + if (frameAtPoint == null) return; + var seq = Program.Sequences + .Where(kv => kv.Value.shp == frameAtPoint.Value.First && + frameAtPoint.Value.Second.IsInRange( kv.Value.start, kv.Value.length )).ToArray(); + + foreach (var s in seq) + Program.Sequences.Remove(s.Key); + + Invalidate(); + } + } + protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); @@ -38,18 +73,13 @@ namespace SequenceEditor Point? toolPoint = null; string toolText = ""; - if (items.Count > 0) + var frameAtPoint = FindFrameAt(mousePos); + if (frameAtPoint != null) { - foreach (var shp in items) - { - var sel = shp.Value.FirstOrDefault(a => a.Value.Contains(mousePos)); - if (!sel.Value.IsEmpty) - { - e.Graphics.FillRectangle(Brushes.Silver, sel.Value); - toolPoint = new Point(sel.Value.Left, sel.Value.Bottom); - toolText = sel.Key.ToString(); - } - } + var rect = items[frameAtPoint.Value.First][frameAtPoint.Value.Second]; + e.Graphics.FillRectangle(Brushes.Silver, rect); + toolPoint = new Point(rect.Left, rect.Bottom); + toolText = frameAtPoint.Value.Second.ToString(); } items.Clear(); @@ -113,4 +143,12 @@ namespace SequenceEditor } } } + + static class Exts + { + public static bool IsInRange(this int x, int start, int len) + { + return x >= start && x < start + len; + } + } }