summaryrefslogtreecommitdiff
path: root/GfxEditor.cs
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-05-21 01:28:48 +0000
committerIan C <ianc@noddybox.co.uk>2005-05-21 01:28:48 +0000
commit33017193d2ca0b7b18e65526f93feb2fe3bfec46 (patch)
tree0926c37d149e9643e92b0e775c436e10d48b3f72 /GfxEditor.cs
parentcac0e5a6f3baeaa2e891677c79bba00ff3c44e1a (diff)
Changed so that editing allows alpha to be used. Font import still not working correctly.
Diffstat (limited to 'GfxEditor.cs')
-rw-r--r--GfxEditor.cs217
1 files changed, 144 insertions, 73 deletions
diff --git a/GfxEditor.cs b/GfxEditor.cs
index f5f002a..b78155a 100644
--- a/GfxEditor.cs
+++ b/GfxEditor.cs
@@ -35,7 +35,7 @@ namespace BitmapFontEd
{
private System.Windows.Forms.Label m_fgPreview;
private System.Windows.Forms.ComboBox m_modeList;
- private System.Windows.Forms.PictureBox m_edit;
+ private System.Windows.Forms.Label m_recent8;
private System.Windows.Forms.Label m_recent1;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label m_recent4;
@@ -44,12 +44,14 @@ namespace BitmapFontEd
private System.Windows.Forms.Label m_recent7;
private System.Windows.Forms.Label m_bgPreview;
private System.Windows.Forms.Label m_recent2;
- private System.Windows.Forms.NumericUpDown m_sizeY;
+ private System.Windows.Forms.Label m_recent3;
private System.Windows.Forms.PictureBox m_preview;
+ private System.Windows.Forms.NumericUpDown m_sizeY;
+ private System.Windows.Forms.Label m_gridCol;
+ private System.Windows.Forms.PictureBox m_edit;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label m_pos;
- private System.Windows.Forms.Label m_recent3;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Button m_undoButton;
@@ -61,7 +63,7 @@ namespace BitmapFontEd
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label m_recent8;
+ private System.Windows.Forms.Label m_backCol;
public const int MAX_SIZE=32;
@@ -99,7 +101,6 @@ namespace BitmapFontEd
private uint m_grid;
private uint m_mx;
private uint m_my;
- private Color m_gridCol;
private bool m_drawing;
private Mode m_mode;
@@ -128,10 +129,8 @@ namespace BitmapFontEd
m_char=null;
m_grid=8;
- m_grid=8;
m_mx=SIZE;
m_my=SIZE;
- m_gridCol=Color.LightGreen;
m_editRect=m_edit.ClientRectangle;
m_editBmp=new Bitmap(m_editRect.Width,m_editRect.Height);
@@ -144,6 +143,8 @@ namespace BitmapFontEd
m_drawing=false;
m_mode=Mode.ePlot;
+ m_bgPreview.BackColor=Color.FromArgb(0);
+
if (m_editRect.Width!=SIZE && m_editRect.Height!=SIZE)
{
throw new Exception("GfxEditor built with bad SIZE!");
@@ -165,7 +166,7 @@ namespace BitmapFontEd
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
- this.m_recent8 = new System.Windows.Forms.Label();
+ this.m_backCol = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
@@ -177,12 +178,14 @@ namespace BitmapFontEd
this.m_undoButton = new System.Windows.Forms.Button();
this.label15 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
- this.m_recent3 = new System.Windows.Forms.Label();
this.m_pos = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
- this.m_preview = new System.Windows.Forms.PictureBox();
+ this.m_edit = new System.Windows.Forms.PictureBox();
+ this.m_gridCol = new System.Windows.Forms.Label();
this.m_sizeY = new System.Windows.Forms.NumericUpDown();
+ this.m_preview = new System.Windows.Forms.PictureBox();
+ this.m_recent3 = new System.Windows.Forms.Label();
this.m_recent2 = new System.Windows.Forms.Label();
this.m_bgPreview = new System.Windows.Forms.Label();
this.m_recent7 = new System.Windows.Forms.Label();
@@ -191,22 +194,22 @@ namespace BitmapFontEd
this.m_recent4 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.m_recent1 = new System.Windows.Forms.Label();
- this.m_edit = new System.Windows.Forms.PictureBox();
+ this.m_recent8 = new System.Windows.Forms.Label();
this.m_modeList = new System.Windows.Forms.ComboBox();
this.m_fgPreview = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit();
this.SuspendLayout();
//
- // m_recent8
+ // m_backCol
//
- this.m_recent8.BackColor = System.Drawing.Color.Black;
- this.m_recent8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_recent8.Location = new System.Drawing.Point(352, 272);
- this.m_recent8.Name = "m_recent8";
- this.m_recent8.Size = new System.Drawing.Size(16, 16);
- this.m_recent8.TabIndex = 32;
- this.m_recent8.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
+ this.m_backCol.BackColor = System.Drawing.Color.Black;
+ this.m_backCol.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_backCol.Location = new System.Drawing.Point(168, 272);
+ this.m_backCol.Name = "m_backCol";
+ this.m_backCol.Size = new System.Drawing.Size(24, 24);
+ this.m_backCol.TabIndex = 34;
+ this.m_backCol.Click += new System.EventHandler(this.OnPaper);
//
// label4
//
@@ -260,7 +263,7 @@ namespace BitmapFontEd
0});
this.m_sizeX.Name = "m_sizeX";
this.m_sizeX.ReadOnly = true;
- this.m_sizeX.Size = new System.Drawing.Size(48, 21);
+ this.m_sizeX.Size = new System.Drawing.Size(48, 20);
this.m_sizeX.TabIndex = 19;
this.m_sizeX.Value = new System.Decimal(new int[] {
1,
@@ -320,21 +323,11 @@ namespace BitmapFontEd
this.label14.Size = new System.Drawing.Size(16, 16);
this.label14.TabIndex = 29;
//
- // m_recent3
- //
- this.m_recent3.BackColor = System.Drawing.Color.Black;
- this.m_recent3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.m_recent3.Location = new System.Drawing.Point(328, 248);
- this.m_recent3.Name = "m_recent3";
- this.m_recent3.Size = new System.Drawing.Size(16, 16);
- this.m_recent3.TabIndex = 27;
- this.m_recent3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
- //
// m_pos
//
- this.m_pos.Location = new System.Drawing.Point(160, 272);
+ this.m_pos.Location = new System.Drawing.Point(208, 272);
this.m_pos.Name = "m_pos";
- this.m_pos.Size = new System.Drawing.Size(104, 24);
+ this.m_pos.Size = new System.Drawing.Size(56, 24);
this.m_pos.TabIndex = 23;
this.m_pos.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
@@ -354,14 +347,29 @@ namespace BitmapFontEd
this.label12.Size = new System.Drawing.Size(16, 16);
this.label12.TabIndex = 31;
//
- // m_preview
+ // m_edit
//
- this.m_preview.BackColor = System.Drawing.SystemColors.Control;
- this.m_preview.Location = new System.Drawing.Point(288, 184);
- this.m_preview.Name = "m_preview";
- this.m_preview.Size = new System.Drawing.Size(34, 34);
- this.m_preview.TabIndex = 1;
- this.m_preview.TabStop = false;
+ this.m_edit.BackColor = System.Drawing.SystemColors.Control;
+ this.m_edit.Location = new System.Drawing.Point(8, 8);
+ this.m_edit.Name = "m_edit";
+ this.m_edit.Size = new System.Drawing.Size(256, 256);
+ this.m_edit.TabIndex = 0;
+ this.m_edit.TabStop = false;
+ this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor);
+ this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor);
+ this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ //
+ // m_gridCol
+ //
+ this.m_gridCol.BackColor = System.Drawing.Color.Lime;
+ this.m_gridCol.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_gridCol.Location = new System.Drawing.Point(136, 272);
+ this.m_gridCol.Name = "m_gridCol";
+ this.m_gridCol.Size = new System.Drawing.Size(24, 24);
+ this.m_gridCol.TabIndex = 33;
+ this.m_gridCol.Click += new System.EventHandler(this.OnGrid);
//
// m_sizeY
//
@@ -379,7 +387,7 @@ namespace BitmapFontEd
0});
this.m_sizeY.Name = "m_sizeY";
this.m_sizeY.ReadOnly = true;
- this.m_sizeY.Size = new System.Drawing.Size(48, 21);
+ this.m_sizeY.Size = new System.Drawing.Size(48, 20);
this.m_sizeY.TabIndex = 20;
this.m_sizeY.Value = new System.Decimal(new int[] {
1,
@@ -389,6 +397,25 @@ namespace BitmapFontEd
this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSizeHeight);
this.m_sizeY.Leave += new System.EventHandler(this.OnSizeHeight);
//
+ // m_preview
+ //
+ this.m_preview.BackColor = System.Drawing.SystemColors.Control;
+ this.m_preview.Location = new System.Drawing.Point(288, 184);
+ this.m_preview.Name = "m_preview";
+ this.m_preview.Size = new System.Drawing.Size(34, 34);
+ this.m_preview.TabIndex = 1;
+ this.m_preview.TabStop = false;
+ //
+ // m_recent3
+ //
+ this.m_recent3.BackColor = System.Drawing.Color.Black;
+ this.m_recent3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_recent3.Location = new System.Drawing.Point(328, 248);
+ this.m_recent3.Name = "m_recent3";
+ this.m_recent3.Size = new System.Drawing.Size(16, 16);
+ this.m_recent3.TabIndex = 27;
+ this.m_recent3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
+ //
// m_recent2
//
this.m_recent2.BackColor = System.Drawing.Color.Black;
@@ -401,7 +428,7 @@ namespace BitmapFontEd
//
// m_bgPreview
//
- this.m_bgPreview.BackColor = System.Drawing.Color.Black;
+ this.m_bgPreview.BackColor = System.Drawing.Color.Transparent;
this.m_bgPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_bgPreview.Location = new System.Drawing.Point(336, 112);
this.m_bgPreview.Name = "m_bgPreview";
@@ -467,19 +494,15 @@ namespace BitmapFontEd
this.m_recent1.TabIndex = 25;
this.m_recent1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
//
- // m_edit
+ // m_recent8
//
- this.m_edit.BackColor = System.Drawing.SystemColors.Control;
- this.m_edit.Location = new System.Drawing.Point(8, 8);
- this.m_edit.Name = "m_edit";
- this.m_edit.Size = new System.Drawing.Size(256, 256);
- this.m_edit.TabIndex = 0;
- this.m_edit.TabStop = false;
- this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor);
- this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
- this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
- this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor);
- this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
+ this.m_recent8.BackColor = System.Drawing.Color.Black;
+ this.m_recent8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.m_recent8.Location = new System.Drawing.Point(352, 272);
+ this.m_recent8.Name = "m_recent8";
+ this.m_recent8.Size = new System.Drawing.Size(16, 16);
+ this.m_recent8.TabIndex = 32;
+ this.m_recent8.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnRecent);
//
// m_modeList
//
@@ -514,6 +537,8 @@ namespace BitmapFontEd
//
// GfxEditor
//
+ this.Controls.Add(this.m_backCol);
+ this.Controls.Add(this.m_gridCol);
this.Controls.Add(this.m_recent8);
this.Controls.Add(this.m_recent7);
this.Controls.Add(this.m_recent6);
@@ -551,11 +576,6 @@ namespace BitmapFontEd
// -------------------------------------------------------
#region Public Interfaces
- public Color GridColour
- {
- set {m_gridCol=value;}
- }
-
public uint CharWidth
{
get {return m_width;}
@@ -634,14 +654,14 @@ namespace BitmapFontEd
private void DrawGrid()
{
Graphics g=Graphics.FromImage(m_prevBmp);
- Pen p=new Pen(m_gridCol);
+ Pen p=new Pen(m_gridCol.BackColor);
g.Clear(Color.Black);
Flush(ref g);
g=Graphics.FromImage(m_editBmp);
- g.Clear(Color.Black);
+ g.Clear(m_backCol.BackColor);
for(int x=0;x<m_width+1;x++)
{
@@ -659,6 +679,14 @@ namespace BitmapFontEd
m_preview.Invalidate();
}
+ private void RedrawChar()
+ {
+ DrawGrid();
+ DrawChar();
+ }
+
+ // This could really do with some optimisations
+ //
private void DrawChar()
{
if (m_char==null)
@@ -668,7 +696,7 @@ namespace BitmapFontEd
Graphics editg=Graphics.FromImage(m_editBmp);
Graphics prevg=Graphics.FromImage(m_prevBmp);
-
+
for(uint x=0;x<m_char.Width;x++)
for(uint y=0;y<m_char.Height;y++)
if (m_overlay[x,y]==TRANS)
@@ -678,19 +706,36 @@ namespace BitmapFontEd
Flush(ref editg);
Flush(ref prevg);
-
+
m_edit.Invalidate();
+ m_edit.Update();
m_preview.Invalidate();
+ m_preview.Update();
}
private void CharPlot(Graphics edit, Graphics prev,
- uint x, uint y, Color c)
+ uint x, uint y, Color c)
{
- SolidBrush p=new SolidBrush(c);
+ if (m_prevBmp.GetPixel((int)x,(int)y)==c)
+ {
+ return;
+ }
+
+ SolidBrush p=new SolidBrush(m_backCol.BackColor);
+
+ uint gx=x*m_grid+1;
+ uint gy=y*m_grid+1;
+ uint gw=m_grid-1;
- edit.FillRectangle(p,x*m_grid+1,y*m_grid+1,m_grid-1,m_grid-1);
+ edit.FillRectangle(p,gx,gy,gw,gw);
+ prev.FillRectangle(p,1+x,1+y,1,1);
+
+ p=new SolidBrush(c);
+
+ edit.FillRectangle(p,gx,gy,gw,gw);
prev.FillRectangle(p,1+x,1+y,1,1);
}
+
#endregion
// -------------------------------------------------------
@@ -758,14 +803,14 @@ namespace BitmapFontEd
for(uint x=x1;x<=x2;x++)
{
- m_overlay[x,y1]=m_gridCol;
- m_overlay[x,y2]=m_gridCol;
+ m_overlay[x,y1]=m_gridCol.BackColor;
+ m_overlay[x,y2]=m_gridCol.BackColor;
}
for(uint y=y1;y<=y2;y++)
{
- m_overlay[x1,y]=m_gridCol;
- m_overlay[x2,y]=m_gridCol;
+ m_overlay[x1,y]=m_gridCol.BackColor;
+ m_overlay[x2,y]=m_gridCol.BackColor;
}
}
@@ -1284,10 +1329,9 @@ namespace BitmapFontEd
void OnForeground(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select Colour for Left Mouse Button");
d.Color=m_fgPreview.BackColor;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -1298,10 +1342,9 @@ namespace BitmapFontEd
void OnBackground(object sender, System.EventArgs e)
{
- ColorDialog d=new ColorDialog();
+ AlphaColourDialog d=new AlphaColourDialog("Select Colour for Right Mouse Button");
d.Color=m_bgPreview.BackColor;
- d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -1324,6 +1367,34 @@ namespace BitmapFontEd
}
}
+ void OnGrid(object sender, System.EventArgs e)
+ {
+ AlphaColourDialog d=new AlphaColourDialog("Select Grid Colour");
+
+ d.AllowAlpha=false;
+ d.Color=m_gridCol.BackColor;
+
+ if (d.ShowDialog()==DialogResult.OK)
+ {
+ m_gridCol.BackColor=d.Color;
+ RedrawChar();
+ }
+ }
+
+ void OnPaper(object sender, System.EventArgs e)
+ {
+ AlphaColourDialog d=new AlphaColourDialog("Select Background Colour");
+
+ d.AllowAlpha=false;
+ d.Color=m_backCol.BackColor;
+
+ if (d.ShowDialog()==DialogResult.OK)
+ {
+ m_backCol.BackColor=d.Color;
+ RedrawChar();
+ }
+ }
+
#endregion
}
}