diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-06-12 01:16:15 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-06-12 01:16:15 +0000 |
commit | b8b5e5a5cc836a381b4861bc9fc18eb0b72cf0c9 (patch) | |
tree | 14dfb63a86842c18f089a89b19f6a368bcf822b4 | |
parent | 9a66f9371393fc793f8427749e167400dff99bb5 (diff) |
Added controls for setting characters to top left and setting widths and heights accordingly.
-rw-r--r-- | BitmapChar.cs | 52 | ||||
-rw-r--r-- | BitmapFontEd.MainForm.resources | bin | 18455 -> 19283 bytes | |||
-rw-r--r-- | MainForm.cs | 166 | ||||
-rw-r--r-- | Util.cs | 7 |
4 files changed, 221 insertions, 4 deletions
diff --git a/BitmapChar.cs b/BitmapChar.cs index 649c135..cd1fc00 100644 --- a/BitmapChar.cs +++ b/BitmapChar.cs @@ -71,6 +71,58 @@ namespace BitmapFontEd get {return m_changed;}
}
+ public int FirstUsedRow
+ {
+ get
+ {
+ for(int y=0;y<m_height;y++)
+ for(int x=0;x<m_width;x++)
+ if (m_data[x,y].A!=0)
+ return y;
+
+ return -1;
+ }
+ }
+
+ public int FirstUsedColumn
+ {
+ get
+ {
+ for(int x=0;x<m_width;x++)
+ for(int y=0;y<m_height;y++)
+ if (m_data[x,y].A!=0)
+ return x;
+
+ return -1;
+ }
+ }
+
+ public int LastUsedRow
+ {
+ get
+ {
+ for(int y=m_height-1;y>=0;y--)
+ for(int x=0;x<m_width;x++)
+ if (m_data[x,y].A!=0)
+ return y;
+
+ return -1;
+ }
+ }
+
+ public int LastUsedColumn
+ {
+ get
+ {
+ for(int x=m_width-1;x>=0;x--)
+ for(int y=0;y<m_height;y++)
+ if (m_data[x,y].A!=0)
+ return x;
+
+ return -1;
+ }
+ }
+
public void Resize(int width, int height)
{
CheckSize(width,height);
diff --git a/BitmapFontEd.MainForm.resources b/BitmapFontEd.MainForm.resources Binary files differindex 45acce1..c5fc8fe 100644 --- a/BitmapFontEd.MainForm.resources +++ b/BitmapFontEd.MainForm.resources diff --git a/MainForm.cs b/MainForm.cs index 00d7514..a0f3238 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -43,7 +43,9 @@ namespace BitmapFontEd private System.Windows.Forms.MenuItem m_break1;
private System.Windows.Forms.MenuItem m_fileMenu;
private System.Windows.Forms.Button m_mirrorVertical;
+ private System.Windows.Forms.Button m_autoheight;
private System.Windows.Forms.Button m_rotRight;
+ private System.Windows.Forms.Button m_topleft;
private System.Windows.Forms.Button m_revert;
private System.Windows.Forms.Button m_dropShadow;
private System.Windows.Forms.MenuItem m_about;
@@ -69,6 +71,7 @@ namespace BitmapFontEd private System.Windows.Forms.MenuItem m_open;
private System.Windows.Forms.Button m_mirrorHorizontal;
private System.Windows.Forms.GroupBox m_selectGroup;
+ private System.Windows.Forms.Button m_autowidth;
private System.Windows.Forms.Button m_clear;
private GfxEditor m_edit;
@@ -136,6 +139,7 @@ namespace BitmapFontEd /// </summary>
private void InitializeComponent() {
this.m_clear = new System.Windows.Forms.Button();
+ this.m_autowidth = new System.Windows.Forms.Button();
this.m_selectGroup = new System.Windows.Forms.GroupBox();
this.m_mirrorHorizontal = new System.Windows.Forms.Button();
this.m_open = new System.Windows.Forms.MenuItem();
@@ -161,7 +165,9 @@ namespace BitmapFontEd this.m_about = new System.Windows.Forms.MenuItem();
this.m_dropShadow = new System.Windows.Forms.Button();
this.m_revert = new System.Windows.Forms.Button();
+ this.m_topleft = new System.Windows.Forms.Button();
this.m_rotRight = new System.Windows.Forms.Button();
+ this.m_autoheight = new System.Windows.Forms.Button();
this.m_mirrorVertical = new System.Windows.Forms.Button();
this.m_fileMenu = new System.Windows.Forms.MenuItem();
this.m_break1 = new System.Windows.Forms.MenuItem();
@@ -189,6 +195,15 @@ namespace BitmapFontEd this.m_clear.Text = "Clear";
this.m_clear.Click += new System.EventHandler(this.OnClear);
//
+ // m_autowidth
+ //
+ this.m_autowidth.Location = new System.Drawing.Point(112, 40);
+ this.m_autowidth.Name = "m_autowidth";
+ this.m_autowidth.Size = new System.Drawing.Size(96, 24);
+ this.m_autowidth.TabIndex = 19;
+ this.m_autowidth.Text = "Auto Width";
+ this.m_autowidth.Click += new System.EventHandler(this.OnAutoWidth);
+ //
// m_selectGroup
//
this.m_selectGroup.Controls.Add(this.m_codeSelect);
@@ -298,7 +313,7 @@ namespace BitmapFontEd //
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.Size = new System.Drawing.Size(96, 24);
this.m_resize.TabIndex = 1;
this.m_resize.Text = "Resize All";
this.m_resize.Click += new System.EventHandler(this.OnResize);
@@ -404,6 +419,15 @@ namespace BitmapFontEd this.m_revert.Text = "Revert";
this.m_revert.Click += new System.EventHandler(this.OnRevert);
//
+ // m_topleft
+ //
+ this.m_topleft.Location = new System.Drawing.Point(112, 16);
+ this.m_topleft.Name = "m_topleft";
+ this.m_topleft.Size = new System.Drawing.Size(96, 24);
+ this.m_topleft.TabIndex = 2;
+ this.m_topleft.Text = "Align Top Left";
+ this.m_topleft.Click += new System.EventHandler(this.OnAlignTopLeft);
+ //
// m_rotRight
//
this.m_rotRight.Location = new System.Drawing.Point(112, 216);
@@ -413,6 +437,15 @@ namespace BitmapFontEd this.m_rotRight.Text = "Right";
this.m_rotRight.Click += new System.EventHandler(this.OnRotateRight);
//
+ // m_autoheight
+ //
+ this.m_autoheight.Location = new System.Drawing.Point(8, 48);
+ this.m_autoheight.Name = "m_autoheight";
+ this.m_autoheight.Size = new System.Drawing.Size(96, 24);
+ this.m_autoheight.TabIndex = 3;
+ this.m_autoheight.Text = "Auto Height";
+ this.m_autoheight.Click += new System.EventHandler(this.OnAutoHeight);
+ //
// m_mirrorVertical
//
this.m_mirrorVertical.Location = new System.Drawing.Point(112, 88);
@@ -459,6 +492,7 @@ namespace BitmapFontEd //
// m_adjustGroup
//
+ this.m_adjustGroup.Controls.Add(this.m_autowidth);
this.m_adjustGroup.Controls.Add(this.m_grabFont);
this.m_adjustGroup.Controls.Add(this.m_edge);
this.m_adjustGroup.Controls.Add(this.m_dropShadow);
@@ -476,19 +510,21 @@ namespace BitmapFontEd this.m_adjustGroup.Controls.Add(this.label3);
this.m_adjustGroup.Controls.Add(this.m_clear);
this.m_adjustGroup.Controls.Add(this.m_applyAll);
- this.m_adjustGroup.Location = new System.Drawing.Point(424, 64);
+ this.m_adjustGroup.Location = new System.Drawing.Point(424, 96);
this.m_adjustGroup.Name = "m_adjustGroup";
- this.m_adjustGroup.Size = new System.Drawing.Size(216, 384);
+ this.m_adjustGroup.Size = new System.Drawing.Size(216, 352);
this.m_adjustGroup.TabIndex = 3;
this.m_adjustGroup.TabStop = false;
this.m_adjustGroup.Text = "Adjustments and Effects";
//
// m_globaladjustGroup
//
+ this.m_globaladjustGroup.Controls.Add(this.m_autoheight);
+ this.m_globaladjustGroup.Controls.Add(this.m_topleft);
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.Size = new System.Drawing.Size(216, 80);
this.m_globaladjustGroup.TabIndex = 2;
this.m_globaladjustGroup.TabStop = false;
this.m_globaladjustGroup.Text = "Global Adjustments";
@@ -658,6 +694,7 @@ namespace BitmapFontEd {
m_chars.Output(str);
m_path=fsel.FileName;
+ m_save.Enabled=true;
str.Close();
}
catch (Exception ex)
@@ -1020,5 +1057,126 @@ namespace BitmapFontEd }
}
}
+
+ void OnAlignTopLeft(object sender, System.EventArgs e)
+ {
+ int row=Int32.MaxValue;
+ int col=Int32.MaxValue;
+ int gap=0;
+
+ if (Util.YesNo("Leave one column gap to left and top?"))
+ {
+ gap=1;
+ }
+
+ foreach (BitmapChar c in m_chars)
+ {
+ if (c.FirstUsedColumn!=-1)
+ {
+ row=Math.Min(c.FirstUsedRow-gap,row);
+ }
+
+ if (c.FirstUsedRow!=-1)
+ {
+ col=Math.Min(c.FirstUsedColumn-gap,col);
+ }
+ }
+
+ if (col==0 && row==0)
+ {
+ Util.Message("There is a character already aligned to the top left");
+ return;
+ }
+
+ if (Util.YesNo("Characters will be scrolled up by " + row + " row(s)\n" +
+ "and left by " + col + " column(s)\n\nContinue?"))
+ {
+ FetchEdit();
+
+ foreach (BitmapChar c in m_chars)
+ {
+ c.Scroll(-col,-row);
+ }
+
+ m_chars.Changed=true;
+
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+ }
+ }
+
+ void OnAutoWidth(object sender, System.EventArgs e)
+ {
+ int gap=1;
+
+ if (Util.YesNo("Leave one column gap on right?"))
+ {
+ gap=2;
+ }
+
+ FetchEdit();
+
+ if (m_applyAll.Checked)
+ {
+ foreach (BitmapChar c in m_chars)
+ {
+ int col=Math.Max(1,Math.Min(GfxEditor.MAX_SIZE,c.LastUsedColumn+gap));
+ c.Resize(col,c.Height);
+ }
+ }
+ else
+ {
+ int col=Math.Max(1,Math.Min(GfxEditor.MAX_SIZE,m_chars[m_selected].LastUsedColumn+gap));
+ m_chars[m_selected].Resize(col,m_chars[m_selected].Height);
+ }
+
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+ }
+
+ void OnAutoHeight(object sender, System.EventArgs e)
+ {
+ bool each=false;
+
+ switch(Util.YesNoCancel("Set all characters to the same height?"))
+ {
+ case DialogResult.Yes:
+ each=false;
+ break;
+ case DialogResult.No:
+ each=true;
+ break;
+ default:
+ return;
+ }
+
+ FetchEdit();
+
+ if (each)
+ {
+ foreach (BitmapChar c in m_chars)
+ {
+ int row=Math.Max(1,Math.Min(GfxEditor.MAX_SIZE,c.LastUsedRow+1));
+
+ c.Resize(c.Width,row);
+ }
+ }
+ else
+ {
+ int row=1;
+
+ foreach (BitmapChar c in m_chars)
+ {
+ row=Math.Max(row,Math.Min(GfxEditor.MAX_SIZE,c.LastUsedRow+1));
+ }
+
+ foreach (BitmapChar c in m_chars)
+ {
+ c.Resize(c.Width,row);
+ }
+ }
+
+ m_chars.Changed=true;
+
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+ }
}
}
@@ -38,6 +38,13 @@ namespace BitmapFontEd MessageBoxIcon.Question)==DialogResult.Yes;
}
+ public static DialogResult YesNoCancel(string s)
+ {
+ return MessageBox.Show(s,"Bitmap Font Editor",
+ MessageBoxButtons.YesNoCancel,
+ MessageBoxIcon.Question);
+ }
+
public static void Message(string s)
{
MessageBox.Show(s,"Bitmap Font Editor",MessageBoxButtons.OK,MessageBoxIcon.Information);
|