summaryrefslogtreecommitdiff
path: root/PaletteForm.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-01-21 01:09:09 +0000
committerIan C <ianc@noddybox.co.uk>2005-01-21 01:09:09 +0000
commitca8de716adf7a191a749963fe5a974e3d8d4ca75 (patch)
treeb3752370928c06d54c2c71f92ae3299229af9066 /PaletteForm.cs
parent0aa5b86abb019771d71e764f27bb2ef1d61c2d2a (diff)
Initial checkinHEADmaster
Diffstat (limited to 'PaletteForm.cs')
-rw-r--r--PaletteForm.cs205
1 files changed, 205 insertions, 0 deletions
diff --git a/PaletteForm.cs b/PaletteForm.cs
new file mode 100644
index 0000000..b24824b
--- /dev/null
+++ b/PaletteForm.cs
@@ -0,0 +1,205 @@
+// GfxEd8
+// Copyright (C) 2004 Ian Cowburn
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// $Id$
+//
+using System;
+using System.Windows.Forms;
+using GfxEdInterface;
+
+namespace GfxEd8
+{
+ /// <summary>
+ /// Description of PaletteForm.
+ /// </summary>
+ public class PaletteForm : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.NumericUpDown m_index;
+ private System.Windows.Forms.Label m_warning;
+ private System.Windows.Forms.Button m_cancel;
+ private System.Windows.Forms.Label m_col;
+ private System.Windows.Forms.ComboBox m_pal;
+ private System.Windows.Forms.Button m_ok;
+
+ private IPlugin m_plugin;
+ private Sprite m_sprite;
+
+ public PaletteForm(IPlugin plugin, Sprite s)
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ m_plugin=plugin;
+ m_sprite=s;
+
+ CancelButton=m_cancel;
+
+ foreach (Colour c in m_plugin.Palette)
+ {
+ m_pal.Items.Add(c);
+ }
+
+ m_index.Minimum=0;
+ m_index.Maximum=m_plugin.MaxColours-1;
+ m_index.Value=1;
+ }
+
+ public Sprite Sprite
+ {
+ get {return m_sprite;}
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.m_ok = new System.Windows.Forms.Button();
+ this.m_pal = new System.Windows.Forms.ComboBox();
+ this.m_col = new System.Windows.Forms.Label();
+ this.m_cancel = new System.Windows.Forms.Button();
+ this.m_warning = new System.Windows.Forms.Label();
+ this.m_index = new System.Windows.Forms.NumericUpDown();
+ ((System.ComponentModel.ISupportInitialize)(this.m_index)).BeginInit();
+ this.SuspendLayout();
+ //
+ // m_ok
+ //
+ this.m_ok.Location = new System.Drawing.Point(160, 64);
+ this.m_ok.Name = "m_ok";
+ this.m_ok.Size = new System.Drawing.Size(88, 24);
+ this.m_ok.TabIndex = 0;
+ this.m_ok.Text = "OK";
+ this.m_ok.Click += new System.EventHandler(this.OnOK);
+ //
+ // m_pal
+ //
+ this.m_pal.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.m_pal.Location = new System.Drawing.Point(80, 24);
+ this.m_pal.Name = "m_pal";
+ this.m_pal.Size = new System.Drawing.Size(192, 21);
+ this.m_pal.TabIndex = 3;
+ this.m_pal.SelectedIndexChanged += new System.EventHandler(this.OnSelectColour);
+ //
+ // m_col
+ //
+ this.m_col.Location = new System.Drawing.Point(280, 16);
+ this.m_col.Name = "m_col";
+ this.m_col.Size = new System.Drawing.Size(64, 40);
+ this.m_col.TabIndex = 4;
+ //
+ // m_cancel
+ //
+ this.m_cancel.Location = new System.Drawing.Point(256, 64);
+ this.m_cancel.Name = "m_cancel";
+ this.m_cancel.Size = new System.Drawing.Size(88, 24);
+ this.m_cancel.TabIndex = 1;
+ this.m_cancel.Text = "Cancel";
+ this.m_cancel.Click += new System.EventHandler(this.OnCancel);
+ //
+ // m_warning
+ //
+ this.m_warning.Location = new System.Drawing.Point(8, 48);
+ this.m_warning.Name = "m_warning";
+ this.m_warning.Size = new System.Drawing.Size(144, 40);
+ this.m_warning.TabIndex = 5;
+ this.m_warning.Text = "label1";
+ //
+ // m_index
+ //
+ this.m_index.Location = new System.Drawing.Point(8, 24);
+ this.m_index.Name = "m_index";
+ this.m_index.Size = new System.Drawing.Size(56, 20);
+ this.m_index.TabIndex = 2;
+ this.m_index.ValueChanged += new System.EventHandler(this.OnSelectIndex);
+ //
+ // PaletteForm
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(354, 95);
+ this.ControlBox = false;
+ this.Controls.Add(this.m_warning);
+ this.Controls.Add(this.m_col);
+ this.Controls.Add(this.m_pal);
+ this.Controls.Add(this.m_index);
+ this.Controls.Add(this.m_cancel);
+ this.Controls.Add(this.m_ok);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "PaletteForm";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Edit Sprite Palette";
+ ((System.ComponentModel.ISupportInitialize)(this.m_index)).EndInit();
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ void OnSelectIndex(object sender, System.EventArgs e)
+ {
+ uint i=(uint)m_index.Value;
+
+ m_pal.SelectedIndex=(int)m_sprite.Pal(i);
+
+ m_pal.Enabled=m_plugin.SprPalEditable[i];
+
+ if (m_pal.Enabled && m_plugin.SprPalCommon[i])
+ {
+ m_warning.Text="WARNING:\nThis colour is common amongst all sprites";
+ }
+ else
+ {
+ m_warning.Text="";
+ }
+ }
+
+ void OnSelectColour(object sender, System.EventArgs e)
+ {
+ uint i=(uint)m_pal.SelectedIndex;
+
+ if (m_index.Value!=0 && i==0)
+ {
+ Util.Message("The background colour cannot be used\n"+
+ "for anything but the background");
+ m_pal.SelectedIndex=1;
+ }
+
+ Colour c=(Colour)m_pal.Items[m_pal.SelectedIndex];
+
+ m_sprite.Pal((uint)m_index.Value,(uint)m_pal.SelectedIndex);
+ m_col.BackColor=c.DrawCol;
+ }
+
+ void OnOK(object sender, System.EventArgs e)
+ {
+ DialogResult=DialogResult.OK;
+ Close();
+ }
+
+ void OnCancel(object sender, System.EventArgs e)
+ {
+ DialogResult=DialogResult.Cancel;
+ Close();
+ }
+
+ }
+}