diff options
-rw-r--r-- | BitmapChar.cs | 108 | ||||
-rw-r--r-- | BitmapFontEd.GfxEditor.resources | bin | 8040 -> 8374 bytes | |||
-rw-r--r-- | BitmapFontEd.MainForm.resources | bin | 6234 -> 12270 bytes | |||
-rw-r--r-- | BitmapFontEd.prjx | 2 | ||||
-rw-r--r-- | GfxEditor.cs | 252 | ||||
-rw-r--r-- | MainForm.cs | 401 | ||||
-rw-r--r-- | Util.cs | 78 |
7 files changed, 684 insertions, 157 deletions
diff --git a/BitmapChar.cs b/BitmapChar.cs index 910a4b2..f902d7c 100644 --- a/BitmapChar.cs +++ b/BitmapChar.cs @@ -20,6 +20,7 @@ using System;
using System.Drawing;
using System.IO;
+using System.Collections;
namespace BitmapFontEd
{
@@ -33,9 +34,11 @@ namespace BitmapFontEd m_width=width;
m_height=height;
m_data=new Color[m_width,m_height];
+ Clear(Color.Black);
+ m_changed=false;
}
- public BitmapChar() : this(8,8)
+ public BitmapChar() : this(16,16)
{
}
@@ -48,6 +51,8 @@ namespace BitmapFontEd for(int x=0;x<m_width;x++)
for(int y=0;y<m_height;y++)
m_data[x,y]=old.m_data[x,y];
+
+ m_changed=old.m_changed;
}
public uint Width
@@ -60,9 +65,24 @@ namespace BitmapFontEd get {return m_height;}
}
+ public bool Changed
+ {
+ get {return m_changed;}
+ }
+
public void Resize(uint width, uint height)
{
+ if (width==m_width && height==m_height)
+ {
+ return;
+ }
+
Color[,] data=new Color[width,height];
+
+ for(int y=0;y<height;y++)
+ for(int x=0;x<width;x++)
+ data[x,y]=Color.Black;
+
uint mx=Math.Min(width,m_width);
uint my=Math.Min(height,m_height);
@@ -73,11 +93,16 @@ namespace BitmapFontEd m_width=width;
m_height=height;
m_data=data;
+ m_changed=true;
}
public Color this [uint x, uint y]
{
- set {m_data[x,y]=value;}
+ set
+ {
+ m_data[x,y]=value;
+ m_changed=true;
+ }
get {return m_data[x,y];}
}
@@ -86,6 +111,8 @@ namespace BitmapFontEd for(int y=0;y<m_height;y++)
for(int x=0;x<m_width;x++)
m_data[x,y]=c;
+
+ m_changed=true;
}
public void MirrorHorizontal()
@@ -97,6 +124,7 @@ namespace BitmapFontEd d[x,y]=m_data[m_width-x-1,y];
m_data=d;
+ m_changed=true;
}
public void MirrorVertical()
@@ -108,6 +136,7 @@ namespace BitmapFontEd d[x,y]=m_data[x,m_height-y-1];
m_data=d;
+ m_changed=true;
}
public void Scroll(int dx, int dy)
@@ -119,6 +148,7 @@ namespace BitmapFontEd d[Mod(x+dx,m_width),Mod(y+dy,m_height)]=m_data[x,y];
m_data=d;
+ m_changed=true;
}
public void RotateRight()
@@ -139,6 +169,7 @@ namespace BitmapFontEd }
m_data=d;
+ m_changed=true;
}
public void RotateLeft()
@@ -159,6 +190,7 @@ namespace BitmapFontEd }
m_data=d;
+ m_changed=true;
}
public void Output(Stream stream)
@@ -190,6 +222,8 @@ namespace BitmapFontEd }
}
+ s.m_changed=false;
+
return s;
}
@@ -199,6 +233,7 @@ namespace BitmapFontEd private uint m_width;
private uint m_height;
private Color[,] m_data;
+ private bool m_changed;
private int Mod(int v, uint max)
{
@@ -254,4 +289,73 @@ namespace BitmapFontEd }
}
}
+
+ /// <summary>
+ /// Describes a list of bitmap characters
+ /// </summary>
+ public class BitmapCharList : IEnumerable
+ {
+ private const int CHARS=96;
+
+ public BitmapCharList()
+ {
+ m_list=new BitmapChar[CHARS];
+
+ for(int f=0;f<CHARS;f++)
+ {
+ m_list[f]=new BitmapChar();
+ }
+
+ m_changed=false;
+ }
+
+ public BitmapChar this [int i]
+ {
+ get {return m_list[i];}
+ set
+ {
+ m_list[i]=value;
+ m_changed=true;
+ }
+ }
+
+ public bool Changed
+ {
+ get {return m_changed;}
+ set {m_changed=value;}
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return m_list.GetEnumerator();
+ }
+
+ public void Output(Stream stream)
+ {
+ foreach (BitmapChar c in m_list)
+ {
+ c.Output(stream);
+ }
+ }
+
+ public static BitmapCharList Input(Stream stream)
+ {
+ BitmapCharList l=new BitmapCharList();
+
+ for(int f=0;f<CHARS;f++)
+ {
+ l.m_list[f]=BitmapChar.Input(stream);
+ }
+
+ l.Changed=false;
+
+ return l;
+ }
+
+ // ------------------------------------------------
+ // PRIVATE
+ //
+ private BitmapChar[] m_list;
+ private bool m_changed;
+ }
}
diff --git a/BitmapFontEd.GfxEditor.resources b/BitmapFontEd.GfxEditor.resources Binary files differindex 77fb9e2..094b568 100644 --- a/BitmapFontEd.GfxEditor.resources +++ b/BitmapFontEd.GfxEditor.resources diff --git a/BitmapFontEd.MainForm.resources b/BitmapFontEd.MainForm.resources Binary files differindex 263887f..b43b7e2 100644 --- a/BitmapFontEd.MainForm.resources +++ b/BitmapFontEd.MainForm.resources diff --git a/BitmapFontEd.prjx b/BitmapFontEd.prjx index 92b8bb5..8a9e287 100644 --- a/BitmapFontEd.prjx +++ b/BitmapFontEd.prjx @@ -4,10 +4,10 @@ <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\BitmapFontEd.MainForm.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
<File name="..\GfxEditor.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
- <File name=".\GfxEd8.GfxEditor.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
<File name=".\BitmapChar.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
<File name=".\BitmapFontEd.GfxEditor.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
<File name="..\CopyMenu.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="..\Util.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
</Contents>
<References />
<DeploymentInformation target="" script="" strategy="File" />
diff --git a/GfxEditor.cs b/GfxEditor.cs index d67b19e..d72b2fb 100644 --- a/GfxEditor.cs +++ b/GfxEditor.cs @@ -33,20 +33,21 @@ namespace BitmapFontEd [ToolboxItem(true)]
public class GfxEditor : System.Windows.Forms.UserControl
{
- private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button m_undoButton;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label m_fgPreview;
- private System.Windows.Forms.NumericUpDown m_sizeX;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label m_bgPreview;
private System.Windows.Forms.PictureBox m_edit;
- private System.Windows.Forms.NumericUpDown m_sizeY;
private System.Windows.Forms.ComboBox m_modeList;
+ private System.Windows.Forms.Label m_fgPreview;
private System.Windows.Forms.PictureBox m_preview;
+ private System.Windows.Forms.NumericUpDown m_sizeY;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label m_bgPreview;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.NumericUpDown m_sizeX;
+ private System.Windows.Forms.Label m_pos;
+ private System.Windows.Forms.Button m_undoButton;
private const uint SIZE=256;
private Color TRANS=Color.Empty;
@@ -146,93 +147,76 @@ namespace BitmapFontEd /// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
- this.m_preview = new System.Windows.Forms.PictureBox();
- this.m_modeList = new System.Windows.Forms.ComboBox();
- this.m_sizeY = new System.Windows.Forms.NumericUpDown();
- this.m_edit = new System.Windows.Forms.PictureBox();
+ this.m_undoButton = new System.Windows.Forms.Button();
+ this.m_pos = new System.Windows.Forms.Label();
+ this.m_sizeX = new System.Windows.Forms.NumericUpDown();
+ this.label3 = new System.Windows.Forms.Label();
this.m_bgPreview = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
- this.m_sizeX = new System.Windows.Forms.NumericUpDown();
+ this.m_sizeY = new System.Windows.Forms.NumericUpDown();
+ this.m_preview = new System.Windows.Forms.PictureBox();
this.m_fgPreview = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.m_undoButton = new System.Windows.Forms.Button();
+ this.m_modeList = new System.Windows.Forms.ComboBox();
+ this.m_edit = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit();
+ this.label4 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit();
this.SuspendLayout();
//
- // m_preview
+ // m_undoButton
//
- this.m_preview.BackColor = System.Drawing.SystemColors.Control;
- this.m_preview.Location = new System.Drawing.Point(288, 208);
- 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_undoButton.Location = new System.Drawing.Point(8, 272);
+ this.m_undoButton.Name = "m_undoButton";
+ this.m_undoButton.Size = new System.Drawing.Size(72, 24);
+ this.m_undoButton.TabIndex = 16;
+ this.m_undoButton.Text = "Undo";
+ this.m_undoButton.Click += new System.EventHandler(this.OnUndo);
//
- // m_modeList
+ // m_pos
//
- this.m_modeList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.m_modeList.Items.AddRange(new object[] {
- "Plot",
- "Line",
- "Rectangle",
- "Filled Rect",
- "Circle",
- "Filled Circle",
- "Ellipse",
- "Filled Ellipse",
- "Flood Fill",
- "Copy/Paste"});
- this.m_modeList.Location = new System.Drawing.Point(280, 64);
- this.m_modeList.MaxDropDownItems = 16;
- this.m_modeList.Name = "m_modeList";
- this.m_modeList.Size = new System.Drawing.Size(104, 21);
- this.m_modeList.TabIndex = 15;
- this.m_modeList.SelectedIndexChanged += new System.EventHandler(this.OnModeSelect);
+ this.m_pos.Location = new System.Drawing.Point(160, 272);
+ this.m_pos.Name = "m_pos";
+ this.m_pos.Size = new System.Drawing.Size(104, 24);
+ this.m_pos.TabIndex = 23;
+ this.m_pos.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
- // m_sizeY
+ // m_sizeX
//
- this.m_sizeY.CausesValidation = false;
- this.m_sizeY.Location = new System.Drawing.Point(336, 24);
- this.m_sizeY.Maximum = new System.Decimal(new int[] {
+ this.m_sizeX.CausesValidation = false;
+ this.m_sizeX.Location = new System.Drawing.Point(280, 24);
+ this.m_sizeX.Maximum = new System.Decimal(new int[] {
32,
0,
0,
0});
- this.m_sizeY.Minimum = new System.Decimal(new int[] {
+ this.m_sizeX.Minimum = new System.Decimal(new int[] {
1,
0,
0,
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.TabIndex = 20;
- this.m_sizeY.Value = new System.Decimal(new int[] {
+ this.m_sizeX.Name = "m_sizeX";
+ this.m_sizeX.ReadOnly = true;
+ 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,
0,
0,
0});
- this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSize);
- this.m_sizeY.Leave += new System.EventHandler(this.OnSize);
+ this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSize);
+ this.m_sizeX.Leave += new System.EventHandler(this.OnSize);
//
- // m_edit
+ // label3
//
- 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.label3.Location = new System.Drawing.Point(280, 8);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(48, 16);
+ this.label3.TabIndex = 8;
+ this.label3.Text = "Width";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_bgPreview
//
@@ -244,6 +228,15 @@ namespace BitmapFontEd this.m_bgPreview.TabIndex = 18;
this.m_bgPreview.Click += new System.EventHandler(this.OnBackground);
//
+ // label5
+ //
+ this.label5.Location = new System.Drawing.Point(336, 96);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(40, 16);
+ this.label5.TabIndex = 12;
+ this.label5.Text = "Right";
+ this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
// label6
//
this.label6.Location = new System.Drawing.Point(336, 8);
@@ -253,31 +246,40 @@ namespace BitmapFontEd this.label6.Text = "Height";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
- // m_sizeX
+ // m_sizeY
//
- this.m_sizeX.CausesValidation = false;
- this.m_sizeX.Location = new System.Drawing.Point(280, 24);
- this.m_sizeX.Maximum = new System.Decimal(new int[] {
+ this.m_sizeY.CausesValidation = false;
+ this.m_sizeY.Location = new System.Drawing.Point(336, 24);
+ this.m_sizeY.Maximum = new System.Decimal(new int[] {
32,
0,
0,
0});
- this.m_sizeX.Minimum = new System.Decimal(new int[] {
+ this.m_sizeY.Minimum = new System.Decimal(new int[] {
1,
0,
0,
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.TabIndex = 19;
- this.m_sizeX.Value = new System.Decimal(new int[] {
+ this.m_sizeY.Name = "m_sizeY";
+ this.m_sizeY.ReadOnly = true;
+ 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,
0,
0,
0});
- this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSize);
- this.m_sizeX.Leave += new System.EventHandler(this.OnSize);
+ this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSize);
+ this.m_sizeY.Leave += new System.EventHandler(this.OnSize);
+ //
+ // m_preview
+ //
+ this.m_preview.BackColor = System.Drawing.SystemColors.Control;
+ this.m_preview.Location = new System.Drawing.Point(288, 208);
+ 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_fgPreview
//
@@ -289,32 +291,40 @@ namespace BitmapFontEd this.m_fgPreview.TabIndex = 17;
this.m_fgPreview.Click += new System.EventHandler(this.OnForeground);
//
- // label4
- //
- this.label4.Location = new System.Drawing.Point(280, 96);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(32, 16);
- this.label4.TabIndex = 10;
- this.label4.Text = "Left";
- this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label5
+ // m_modeList
//
- this.label5.Location = new System.Drawing.Point(336, 96);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(40, 16);
- this.label5.TabIndex = 12;
- this.label5.Text = "Right";
- this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.m_modeList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.m_modeList.Items.AddRange(new object[] {
+ "Plot",
+ "Line",
+ "Rectangle",
+ "Filled Rect",
+ "Circle",
+ "Filled Circle",
+ "Ellipse",
+ "Filled Ellipse",
+ "Flood Fill",
+ "Copy/Paste"});
+ this.m_modeList.Location = new System.Drawing.Point(280, 64);
+ this.m_modeList.MaxDropDownItems = 16;
+ this.m_modeList.Name = "m_modeList";
+ this.m_modeList.Size = new System.Drawing.Size(104, 21);
+ this.m_modeList.TabIndex = 15;
+ this.m_modeList.SelectedIndexChanged += new System.EventHandler(this.OnModeSelect);
//
- // m_undoButton
+ // m_edit
//
- this.m_undoButton.Location = new System.Drawing.Point(8, 272);
- this.m_undoButton.Name = "m_undoButton";
- this.m_undoButton.Size = new System.Drawing.Size(72, 24);
- this.m_undoButton.TabIndex = 16;
- this.m_undoButton.Text = "Undo";
- this.m_undoButton.Click += new System.EventHandler(this.OnUndo);
+ 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);
//
// label1
//
@@ -334,17 +344,18 @@ namespace BitmapFontEd this.label2.Text = "Preview";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
- // label3
+ // label4
//
- this.label3.Location = new System.Drawing.Point(280, 8);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(48, 16);
- this.label3.TabIndex = 8;
- this.label3.Text = "Width";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.label4.Location = new System.Drawing.Point(280, 96);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(32, 16);
+ this.label4.TabIndex = 10;
+ this.label4.Text = "Left";
+ this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// GfxEditor
//
+ this.Controls.Add(this.m_pos);
this.Controls.Add(this.label6);
this.Controls.Add(this.label2);
this.Controls.Add(this.m_sizeY);
@@ -361,8 +372,8 @@ namespace BitmapFontEd this.Controls.Add(this.m_edit);
this.Name = "GfxEditor";
this.Size = new System.Drawing.Size(392, 304);
- ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).EndInit();
this.ResumeLayout(false);
}
#endregion
@@ -377,9 +388,14 @@ namespace BitmapFontEd set {m_gridCol=value;}
}
- public Size CharSize
+ public uint CharWidth
{
- get {return new Size((int)m_width,(int)m_height);}
+ get {return m_width;}
+ }
+
+ public uint CharHeight
+ {
+ get {return m_height;}
}
public BitmapChar BitmapChar
@@ -390,8 +406,8 @@ namespace BitmapFontEd m_char=value;
m_ignoreSize=true;
m_sizeX.Value=Convert.ToDecimal(m_char.Width);
- m_sizeY.Value=Convert.ToDecimal(m_char.Height);
m_ignoreSize=false;
+ m_sizeY.Value=Convert.ToDecimal(m_char.Height);
InitialiseOverlay();
DrawChar();
}
@@ -840,6 +856,8 @@ namespace BitmapFontEd void OnLeaveEditor(object sender, System.EventArgs e)
{
//m_inEditor=false;
+
+ m_pos.Text="";
if (m_drawing && m_mode==Mode.ePlot)
{
@@ -881,6 +899,8 @@ namespace BitmapFontEd x=(uint)e.X/m_grid;
y=(uint)e.Y/m_grid;
+ m_pos.Text=x+","+y;
+
if (x>=m_char.Width || y>=m_char.Height)
{
return;
@@ -1052,6 +1072,7 @@ namespace BitmapFontEd ColorDialog d=new ColorDialog();
d.Color=m_fgPreview.BackColor;
+ d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
@@ -1064,6 +1085,7 @@ namespace BitmapFontEd ColorDialog d=new ColorDialog();
d.Color=m_bgPreview.BackColor;
+ d.FullOpen=true;
if (d.ShowDialog()==DialogResult.OK)
{
diff --git a/MainForm.cs b/MainForm.cs index 731bf2a..e63371a 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -20,6 +20,7 @@ using System;
using System.Drawing;
using System.Windows.Forms;
+using System.Text;
namespace BitmapFontEd
{
@@ -28,17 +29,33 @@ namespace BitmapFontEd /// </summary>
public class MainForm : System.Windows.Forms.Form
{
- private System.Windows.Forms.MenuItem menuItem6;
- private System.Windows.Forms.MenuItem m_quit;
- private System.Windows.Forms.MenuItem m_saveAs;
- private System.Windows.Forms.MenuItem m_save;
+ private System.Windows.Forms.CheckBox m_applyAll;
+ private System.Windows.Forms.GroupBox m_selectGroup;
+ private System.Windows.Forms.GroupBox m_adjustGroup;
private System.Windows.Forms.MainMenu m_menu;
+ private System.Windows.Forms.ComboBox m_asciiSelect;
private System.Windows.Forms.MenuItem m_fileMenu;
- private System.Windows.Forms.GroupBox m_editGroup;
private System.Windows.Forms.MenuItem m_open;
+ private System.Windows.Forms.MenuItem menuItem6;
+ private System.Windows.Forms.MenuItem m_saveAs;
+ private System.Windows.Forms.TrackBar m_charSelect;
+ private System.Windows.Forms.MenuItem m_quit;
private System.Windows.Forms.MenuItem m_new;
+ private System.Windows.Forms.GroupBox m_editGroup;
+ private System.Windows.Forms.Button m_revert;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button m_resize;
+ private System.Windows.Forms.MenuItem m_about;
+ private System.Windows.Forms.MenuItem m_save;
+ private System.Windows.Forms.NumericUpDown m_codeSelect;
+ private System.Windows.Forms.GroupBox m_globaladjustGroup;
+ private System.Windows.Forms.MenuItem m_helpMenu;
- private GfxEditor m_edit;
+ private GfxEditor m_edit;
+ private BitmapCharList m_chars;
+ private int m_selected;
+ private bool m_inSelect;
public MainForm()
{
@@ -53,7 +70,28 @@ namespace BitmapFontEd m_edit.Location=new Point(4,16);
m_editGroup.Controls.Add(m_edit);
- m_edit.BitmapChar=new BitmapChar();
+ m_chars=new BitmapCharList();
+
+ for(byte c=32;c<128;c++)
+ {
+ switch(c)
+ {
+ case 32:
+ m_asciiSelect.Items.Add("Space");
+ break;
+ case 127:
+ m_asciiSelect.Items.Add("DEL");
+ break;
+ default:
+ m_asciiSelect.Items.Add
+ (Encoding.ASCII.GetString(new byte[] {c}));
+ break;
+ }
+ }
+
+ m_selected=0;
+
+ SelectChar(0);
}
[STAThread]
@@ -69,28 +107,124 @@ namespace BitmapFontEd /// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
+ this.m_helpMenu = new System.Windows.Forms.MenuItem();
+ this.m_globaladjustGroup = new System.Windows.Forms.GroupBox();
+ this.m_codeSelect = new System.Windows.Forms.NumericUpDown();
+ this.m_save = new System.Windows.Forms.MenuItem();
+ this.m_about = new System.Windows.Forms.MenuItem();
+ this.m_resize = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.m_revert = new System.Windows.Forms.Button();
+ this.m_editGroup = new System.Windows.Forms.GroupBox();
this.m_new = new System.Windows.Forms.MenuItem();
+ this.m_quit = new System.Windows.Forms.MenuItem();
+ this.m_charSelect = new System.Windows.Forms.TrackBar();
+ this.m_saveAs = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
this.m_open = new System.Windows.Forms.MenuItem();
- this.m_editGroup = new System.Windows.Forms.GroupBox();
this.m_fileMenu = new System.Windows.Forms.MenuItem();
+ this.m_asciiSelect = new System.Windows.Forms.ComboBox();
this.m_menu = new System.Windows.Forms.MainMenu();
- this.m_save = new System.Windows.Forms.MenuItem();
- this.m_saveAs = new System.Windows.Forms.MenuItem();
- this.m_quit = new System.Windows.Forms.MenuItem();
- this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this.m_adjustGroup = new System.Windows.Forms.GroupBox();
+ this.m_selectGroup = new System.Windows.Forms.GroupBox();
+ this.m_applyAll = new System.Windows.Forms.CheckBox();
+ this.m_globaladjustGroup.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).BeginInit();
+ this.m_adjustGroup.SuspendLayout();
+ this.m_selectGroup.SuspendLayout();
this.SuspendLayout();
//
- // m_new
+ // m_helpMenu
//
- this.m_new.Index = 0;
- this.m_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
- this.m_new.Text = "&New";
+ this.m_helpMenu.Index = 1;
+ this.m_helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.m_about});
+ this.m_helpMenu.Text = "&Help";
//
- // m_open
+ // m_globaladjustGroup
//
- this.m_open.Index = 1;
- this.m_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
- this.m_open.Text = "&Open";
+ this.m_globaladjustGroup.Controls.Add(this.m_resize);
+ this.m_globaladjustGroup.Location = new System.Drawing.Point(424, 8);
+ this.m_globaladjustGroup.Name = "m_globaladjustGroup";
+ this.m_globaladjustGroup.Size = new System.Drawing.Size(216, 48);
+ this.m_globaladjustGroup.TabIndex = 2;
+ this.m_globaladjustGroup.TabStop = false;
+ this.m_globaladjustGroup.Text = "Global Adjustments";
+ //
+ // m_codeSelect
+ //
+ this.m_codeSelect.Location = new System.Drawing.Point(88, 64);
+ this.m_codeSelect.Maximum = new System.Decimal(new int[] {
+ 127,
+ 0,
+ 0,
+ 0});
+ this.m_codeSelect.Minimum = new System.Decimal(new int[] {
+ 32,
+ 0,
+ 0,
+ 0});
+ this.m_codeSelect.Name = "m_codeSelect";
+ this.m_codeSelect.ReadOnly = true;
+ this.m_codeSelect.Size = new System.Drawing.Size(64, 21);
+ this.m_codeSelect.TabIndex = 9;
+ this.m_codeSelect.Value = new System.Decimal(new int[] {
+ 32,
+ 0,
+ 0,
+ 0});
+ this.m_codeSelect.ValueChanged += new System.EventHandler(this.OnSelectByCode);
+ //
+ // m_save
+ //
+ this.m_save.Index = 2;
+ this.m_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
+ this.m_save.Text = "&Save";
+ this.m_save.Click += new System.EventHandler(this.OnSave);
+ //
+ // m_about
+ //
+ this.m_about.Index = 0;
+ this.m_about.Text = "&About";
+ this.m_about.Click += new System.EventHandler(this.OnAbout);
+ //
+ // m_resize
+ //
+ this.m_resize.Location = new System.Drawing.Point(8, 16);
+ this.m_resize.Name = "m_resize";
+ this.m_resize.Size = new System.Drawing.Size(88, 24);
+ this.m_resize.TabIndex = 0;
+ this.m_resize.Text = "Resize All";
+ this.m_resize.Click += new System.EventHandler(this.OnResize);
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(16, 64);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(72, 24);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "ASCII Code:";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(160, 64);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(72, 24);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Character:";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // m_revert
+ //
+ this.m_revert.Location = new System.Drawing.Point(304, 64);
+ this.m_revert.Name = "m_revert";
+ this.m_revert.Size = new System.Drawing.Size(88, 24);
+ this.m_revert.TabIndex = 6;
+ this.m_revert.Text = "Revert";
+ this.m_revert.Click += new System.EventHandler(this.OnRevert);
//
// m_editGroup
//
@@ -101,6 +235,48 @@ namespace BitmapFontEd this.m_editGroup.TabStop = false;
this.m_editGroup.Text = "Editor";
//
+ // m_new
+ //
+ this.m_new.Index = 0;
+ this.m_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
+ this.m_new.Text = "&New";
+ this.m_new.Click += new System.EventHandler(this.OnNew);
+ //
+ // m_quit
+ //
+ this.m_quit.Index = 5;
+ this.m_quit.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;
+ this.m_quit.Text = "&Quit";
+ this.m_quit.Click += new System.EventHandler(this.OnQuit);
+ //
+ // m_charSelect
+ //
+ this.m_charSelect.Location = new System.Drawing.Point(8, 16);
+ this.m_charSelect.Maximum = 95;
+ this.m_charSelect.Name = "m_charSelect";
+ this.m_charSelect.Size = new System.Drawing.Size(392, 42);
+ this.m_charSelect.TabIndex = 5;
+ this.m_charSelect.Scroll += new System.EventHandler(this.OnSelectChar);
+ //
+ // m_saveAs
+ //
+ this.m_saveAs.Index = 3;
+ this.m_saveAs.Shortcut = System.Windows.Forms.Shortcut.F12;
+ this.m_saveAs.Text = "S&ave as...";
+ this.m_saveAs.Click += new System.EventHandler(this.OnSaveAs);
+ //
+ // menuItem6
+ //
+ this.menuItem6.Index = 4;
+ this.menuItem6.Text = "-";
+ //
+ // m_open
+ //
+ this.m_open.Index = 1;
+ this.m_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
+ this.m_open.Text = "&Open";
+ this.m_open.Click += new System.EventHandler(this.OnOpen);
+ //
// m_fileMenu
//
this.m_fileMenu.Index = 0;
@@ -113,38 +289,62 @@ namespace BitmapFontEd this.m_quit});
this.m_fileMenu.Text = "&File";
//
+ // m_asciiSelect
+ //
+ this.m_asciiSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.m_asciiSelect.Location = new System.Drawing.Point(224, 64);
+ this.m_asciiSelect.MaxDropDownItems = 20;
+ this.m_asciiSelect.Name = "m_asciiSelect";
+ this.m_asciiSelect.Size = new System.Drawing.Size(64, 21);
+ this.m_asciiSelect.TabIndex = 8;
+ this.m_asciiSelect.SelectedIndexChanged += new System.EventHandler(this.OnSelectByChar);
+ //
// m_menu
//
this.m_menu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.m_fileMenu});
+ this.m_fileMenu,
+ this.m_helpMenu});
//
- // m_save
- //
- this.m_save.Index = 2;
- this.m_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
- this.m_save.Text = "&Save";
+ // m_adjustGroup
//
- // m_saveAs
+ this.m_adjustGroup.Controls.Add(this.m_applyAll);
+ this.m_adjustGroup.Location = new System.Drawing.Point(424, 64);
+ this.m_adjustGroup.Name = "m_adjustGroup";
+ this.m_adjustGroup.Size = new System.Drawing.Size(216, 384);
+ this.m_adjustGroup.TabIndex = 3;
+ this.m_adjustGroup.TabStop = false;
+ this.m_adjustGroup.Text = "Character Adjustments";
//
- this.m_saveAs.Index = 3;
- this.m_saveAs.Shortcut = System.Windows.Forms.Shortcut.F12;
- this.m_saveAs.Text = "S&ave as...";
+ // m_selectGroup
//
- // m_quit
+ this.m_selectGroup.Controls.Add(this.m_codeSelect);
+ this.m_selectGroup.Controls.Add(this.m_asciiSelect);
+ this.m_selectGroup.Controls.Add(this.m_revert);
+ this.m_selectGroup.Controls.Add(this.m_charSelect);
+ this.m_selectGroup.Controls.Add(this.label2);
+ this.m_selectGroup.Controls.Add(this.label1);
+ this.m_selectGroup.Location = new System.Drawing.Point(8, 344);
+ this.m_selectGroup.Name = "m_selectGroup";
+ this.m_selectGroup.Size = new System.Drawing.Size(408, 104);
+ this.m_selectGroup.TabIndex = 1;
+ this.m_selectGroup.TabStop = false;
+ this.m_selectGroup.Text = "Character";
//
- this.m_quit.Index = 5;
- this.m_quit.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;
- this.m_quit.Text = "&Quit";
+ // m_applyAll
//
- // menuItem6
- //
- this.menuItem6.Index = 4;
- this.menuItem6.Text = "-";
+ this.m_applyAll.Location = new System.Drawing.Point(8, 16);
+ this.m_applyAll.Name = "m_applyAll";
+ this.m_applyAll.Size = new System.Drawing.Size(88, 16);
+ this.m_applyAll.TabIndex = 1;
+ this.m_applyAll.Text = "Apply To All";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
- this.ClientSize = new System.Drawing.Size(642, 479);
+ this.ClientSize = new System.Drawing.Size(650, 479);
+ this.Controls.Add(this.m_adjustGroup);
+ this.Controls.Add(this.m_globaladjustGroup);
+ this.Controls.Add(this.m_selectGroup);
this.Controls.Add(this.m_editGroup);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
@@ -152,8 +352,131 @@ namespace BitmapFontEd this.MinimumSize = new System.Drawing.Size(648, 504);
this.Name = "MainForm";
this.Text = "Bitmap Font Editor";
+ this.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing);
+ this.m_globaladjustGroup.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).EndInit();
+ this.m_adjustGroup.ResumeLayout(false);
+ this.m_selectGroup.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
+
+ private bool EditChanged
+ {
+ get {return m_edit.BitmapChar!=null && m_edit.BitmapChar.Changed;}
+ }
+
+ private bool ChangesAllowed
+ {
+ get {return (!m_chars.Changed && !EditChanged) || Util.YesNo("Abandon changes?");}
+ }
+
+ void OnAbout(object sender, System.EventArgs e)
+ {
+ Util.About();
+ }
+
+ void OnNew(object sender, System.EventArgs e)
+ {
+ if (ChangesAllowed)
+ {
+ m_chars=new BitmapCharList();
+ m_edit.BitmapChar=new BitmapChar();
+ OnSelectChar(null,null);
+ }
+ }
+
+ void OnOpen(object sender, System.EventArgs e)
+ {
+
+ }
+
+ void OnSave(object sender, System.EventArgs e)
+ {
+
+ }
+
+ void OnSaveAs(object sender, System.EventArgs e)
+ {
+
+ }
+
+ void OnQuit(object sender, System.EventArgs e)
+ {
+ Close();
+ }
+
+ void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if (!ChangesAllowed)
+ {
+ e.Cancel=true;
+ }
+ }
+
+ private void SelectChar(int sel)
+ {
+ m_inSelect=true;
+
+ if (EditChanged)
+ {
+ m_chars[m_selected]=m_edit.BitmapChar;
+ }
+
+ m_selected=sel;
+
+ m_charSelect.Value=sel;
+ m_codeSelect.Value=sel+32;
+ m_asciiSelect.SelectedIndex=sel;
+
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+
+ m_inSelect=false;
+ }
+
+ void OnSelectByCode(object sender, System.EventArgs e)
+ {
+ if (!m_inSelect)
+ {
+ SelectChar(Convert.ToInt32(m_codeSelect.Value-32));
+ }
+ }
+
+ void OnSelectByChar(object sender, System.EventArgs e)
+ {
+ if (!m_inSelect)
+ {
+ SelectChar(m_asciiSelect.SelectedIndex);
+ }
+ }
+
+ void OnSelectChar(object sender, System.EventArgs e)
+ {
+ if (!m_inSelect)
+ {
+ SelectChar(m_charSelect.Value);
+ }
+ }
+
+ void OnRevert(object sender, System.EventArgs e)
+ {
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+ }
+
+ void OnResize(object sender, System.EventArgs e)
+ {
+ uint w=m_edit.CharWidth;
+ uint h=m_edit.CharHeight;
+
+ if (Util.YesNo("Sure you want to resize all characters to " + w + " by " + h))
+ {
+ foreach (BitmapChar c in m_chars)
+ {
+ c.Resize(w,h);
+ }
+ }
+ }
+
}
}
@@ -0,0 +1,78 @@ +// BitmapFontEd
+// Copyright (C) 2005 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 System.Text;
+
+namespace BitmapFontEd
+{
+ /// <summary>
+ /// Usual utils and some state machine
+ /// </summary>
+ public class Util
+ {
+ public static bool YesNo(string s)
+ {
+ return MessageBox.Show(s,"Question",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question)==DialogResult.Yes;
+ }
+
+ public static void Message(string s)
+ {
+ MessageBox.Show(s,"Message",MessageBoxButtons.OK,MessageBoxIcon.Information);
+ }
+
+ public static void Error(string s)
+ {
+ MessageBox.Show(s,"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error);
+ }
+
+ public static void Error(string file, string s)
+ {
+ MessageBox.Show(file+"\n\n"+s,"File Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
+ }
+
+ public static void About()
+ {
+ MessageBox.Show(m_about,"About Bitmap Font Editor",
+ MessageBoxButtons.OK,MessageBoxIcon.Information);
+ }
+
+ private Util()
+ {
+ }
+
+ private static string m_about=
+ "Bitmap Font Editor\n"+
+ "Copyright Ian Cowburn 2005\n\n"+
+ "This program is free software; you can redistribute it and/or\n"+
+ "modify it under the terms of the GNU General Public License\n"+
+ "as published by the Free Software Foundation; either version 2\n"+
+ "of the License, or (at your option) any later version.\n\n"+
+ "This program is distributed in the hope that it will be useful,\n"+
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"+
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"+
+ "GNU General Public License for more details.\n\n"+
+ "You should have received a copy of the GNU General Public License\n"+
+ "along with this program; if not, write to the Free Software\n"+
+ "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.";
+ }
+}
|