summaryrefslogtreecommitdiff
path: root/MainForm.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MainForm.cs')
-rw-r--r--MainForm.cs148
1 files changed, 106 insertions, 42 deletions
diff --git a/MainForm.cs b/MainForm.cs
index 7148c78..689c21d 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -53,28 +53,29 @@ namespace BitmapFontEd
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button m_scrollRight;
private System.Windows.Forms.CheckBox m_applyAll;
- private System.Windows.Forms.Button m_grabFont;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button m_rotLeft;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TrackBar m_charSelect;
private System.Windows.Forms.MainMenu m_menu;
private System.Windows.Forms.Button m_resize;
+ private System.Windows.Forms.Button m_clear;
private System.Windows.Forms.ComboBox m_asciiSelect;
private System.Windows.Forms.Button m_edge;
- private System.Windows.Forms.MenuItem m_quit;
+ private System.Windows.Forms.Button m_minunused;
private System.Windows.Forms.MenuItem m_save;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.MenuItem m_saveAs;
- private System.Windows.Forms.Button m_minunused;
private System.Windows.Forms.Button m_scrollLeft;
private System.Windows.Forms.GroupBox m_editGroup;
private System.Windows.Forms.MenuItem m_new;
private System.Windows.Forms.MenuItem m_open;
+ private System.Windows.Forms.Button m_flushleft;
private System.Windows.Forms.Button m_mirrorHorizontal;
private System.Windows.Forms.GroupBox m_selectGroup;
+ private System.Windows.Forms.MenuItem m_quit;
private System.Windows.Forms.Button m_autowidth;
- private System.Windows.Forms.Button m_clear;
+ private System.Windows.Forms.Button m_grabFont;
private GfxEditor m_edit;
private BitmapCharList m_chars;
@@ -86,6 +87,8 @@ namespace BitmapFontEd
private Color m_glowCol=Color.White;
+ private Font m_lastFont;
+
public MainForm()
{
//
@@ -140,28 +143,29 @@ namespace BitmapFontEd
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
- this.m_clear = new System.Windows.Forms.Button();
+ this.m_grabFont = new System.Windows.Forms.Button();
this.m_autowidth = new System.Windows.Forms.Button();
+ this.m_quit = new System.Windows.Forms.MenuItem();
this.m_selectGroup = new System.Windows.Forms.GroupBox();
this.m_mirrorHorizontal = new System.Windows.Forms.Button();
+ this.m_flushleft = new System.Windows.Forms.Button();
this.m_open = new System.Windows.Forms.MenuItem();
this.m_new = new System.Windows.Forms.MenuItem();
this.m_editGroup = new System.Windows.Forms.GroupBox();
this.m_scrollLeft = new System.Windows.Forms.Button();
- this.m_minunused = new System.Windows.Forms.Button();
this.m_saveAs = new System.Windows.Forms.MenuItem();
this.label5 = new System.Windows.Forms.Label();
this.m_save = new System.Windows.Forms.MenuItem();
- this.m_quit = new System.Windows.Forms.MenuItem();
+ this.m_minunused = new System.Windows.Forms.Button();
this.m_edge = new System.Windows.Forms.Button();
this.m_asciiSelect = new System.Windows.Forms.ComboBox();
+ this.m_clear = new System.Windows.Forms.Button();
this.m_resize = new System.Windows.Forms.Button();
this.m_menu = new System.Windows.Forms.MainMenu();
this.m_charSelect = new System.Windows.Forms.TrackBar();
this.label4 = new System.Windows.Forms.Label();
this.m_rotLeft = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
- this.m_grabFont = new System.Windows.Forms.Button();
this.m_applyAll = new System.Windows.Forms.CheckBox();
this.m_scrollRight = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
@@ -190,14 +194,14 @@ namespace BitmapFontEd
((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).BeginInit();
this.SuspendLayout();
//
- // m_clear
+ // m_grabFont
//
- this.m_clear.Location = new System.Drawing.Point(8, 40);
- this.m_clear.Name = "m_clear";
- this.m_clear.Size = new System.Drawing.Size(96, 24);
- this.m_clear.TabIndex = 3;
- this.m_clear.Text = "Clear";
- this.m_clear.Click += new System.EventHandler(this.OnClear);
+ this.m_grabFont.Location = new System.Drawing.Point(8, 296);
+ this.m_grabFont.Name = "m_grabFont";
+ this.m_grabFont.Size = new System.Drawing.Size(96, 24);
+ this.m_grabFont.TabIndex = 18;
+ this.m_grabFont.Text = "Grab Font";
+ this.m_grabFont.Click += new System.EventHandler(this.OnGrabFont);
//
// m_autowidth
//
@@ -208,6 +212,13 @@ namespace BitmapFontEd
this.m_autowidth.Text = "Auto Width";
this.m_autowidth.Click += new System.EventHandler(this.OnAutoWidth);
//
+ // 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_selectGroup
//
this.m_selectGroup.Controls.Add(this.m_codeSelect);
@@ -232,6 +243,15 @@ namespace BitmapFontEd
this.m_mirrorHorizontal.Text = "Horizontal";
this.m_mirrorHorizontal.Click += new System.EventHandler(this.OnHorizontalMirror);
//
+ // m_flushleft
+ //
+ this.m_flushleft.Location = new System.Drawing.Point(112, 80);
+ this.m_flushleft.Name = "m_flushleft";
+ this.m_flushleft.Size = new System.Drawing.Size(96, 24);
+ this.m_flushleft.TabIndex = 6;
+ this.m_flushleft.Text = "Flush Left";
+ this.m_flushleft.Click += new System.EventHandler(this.OnFlushLeft);
+ //
// m_open
//
this.m_open.Index = 1;
@@ -264,15 +284,6 @@ namespace BitmapFontEd
this.m_scrollLeft.Text = "Left";
this.m_scrollLeft.Click += new System.EventHandler(this.OnLeftScroll);
//
- // m_minunused
- //
- this.m_minunused.Location = new System.Drawing.Point(8, 80);
- this.m_minunused.Name = "m_minunused";
- this.m_minunused.Size = new System.Drawing.Size(96, 24);
- this.m_minunused.TabIndex = 5;
- this.m_minunused.Text = "Unused to 1x1";
- this.m_minunused.Click += new System.EventHandler(this.OnMinimizeUnused);
- //
// m_saveAs
//
this.m_saveAs.Index = 3;
@@ -296,12 +307,14 @@ namespace BitmapFontEd
this.m_save.Text = "&Save";
this.m_save.Click += new System.EventHandler(this.OnSave);
//
- // m_quit
+ // m_minunused
//
- 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);
+ this.m_minunused.Location = new System.Drawing.Point(8, 80);
+ this.m_minunused.Name = "m_minunused";
+ this.m_minunused.Size = new System.Drawing.Size(96, 24);
+ this.m_minunused.TabIndex = 5;
+ this.m_minunused.Text = "Unused to 1x1";
+ this.m_minunused.Click += new System.EventHandler(this.OnMinimizeUnused);
//
// m_edge
//
@@ -322,6 +335,15 @@ namespace BitmapFontEd
this.m_asciiSelect.TabIndex = 9;
this.m_asciiSelect.SelectedIndexChanged += new System.EventHandler(this.OnSelectByChar);
//
+ // m_clear
+ //
+ this.m_clear.Location = new System.Drawing.Point(8, 40);
+ this.m_clear.Name = "m_clear";
+ this.m_clear.Size = new System.Drawing.Size(96, 24);
+ this.m_clear.TabIndex = 3;
+ this.m_clear.Text = "Clear";
+ this.m_clear.Click += new System.EventHandler(this.OnClear);
+ //
// m_resize
//
this.m_resize.Location = new System.Drawing.Point(8, 16);
@@ -373,15 +395,6 @@ namespace BitmapFontEd
this.label6.Text = "Special Effects";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
- // m_grabFont
- //
- this.m_grabFont.Location = new System.Drawing.Point(8, 296);
- this.m_grabFont.Name = "m_grabFont";
- this.m_grabFont.Size = new System.Drawing.Size(96, 24);
- this.m_grabFont.TabIndex = 18;
- this.m_grabFont.Text = "Grab Font";
- this.m_grabFont.Click += new System.EventHandler(this.OnGrabFont);
- //
// m_applyAll
//
this.m_applyAll.Location = new System.Drawing.Point(8, 16);
@@ -541,6 +554,7 @@ namespace BitmapFontEd
//
// m_globaladjustGroup
//
+ this.m_globaladjustGroup.Controls.Add(this.m_flushleft);
this.m_globaladjustGroup.Controls.Add(this.m_minunused);
this.m_globaladjustGroup.Controls.Add(this.m_setsize);
this.m_globaladjustGroup.Controls.Add(this.m_autoheight);
@@ -568,7 +582,7 @@ namespace BitmapFontEd
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.Size = new System.Drawing.Size(64, 20);
this.m_codeSelect.TabIndex = 10;
this.m_codeSelect.Value = new System.Decimal(new int[] {
32,
@@ -604,8 +618,8 @@ namespace BitmapFontEd
//
// MainForm
//
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
- this.ClientSize = new System.Drawing.Size(650, 471);
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ 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);
@@ -1037,6 +1051,11 @@ namespace BitmapFontEd
{
FontDialog fdlg=new FontDialog();
+ if (m_lastFont!=null)
+ {
+ fdlg.Font=m_lastFont;
+ }
+
if (fdlg.ShowDialog()==DialogResult.OK)
{
AlphaColourDialog coldlg=new AlphaColourDialog("Font Colour");
@@ -1045,6 +1064,8 @@ namespace BitmapFontEd
if (coldlg.ShowDialog()==DialogResult.OK)
{
+ m_lastFont=fdlg.Font;
+
try
{
int max_height=Int32.MinValue;
@@ -1061,7 +1082,7 @@ namespace BitmapFontEd
{
string s=Encoding.ASCII.GetString(new byte[] {ascii});
g.Clear(Color.Transparent);
- g.DrawString(s,fdlg.Font,b,0,0);
+ g.DrawString(s,m_lastFont,b,0,0);
g.Flush(FlushIntention.Sync);
GrabChar(bmp,m_chars[ascii-32],ref max_height);
}
@@ -1128,6 +1149,49 @@ namespace BitmapFontEd
}
}
+ void OnFlushLeft(object sender, System.EventArgs e)
+ {
+ int failed=0;
+ int gap=0;
+
+ if (Util.YesNo("Leave one column gap to left?"))
+ {
+ gap=1;
+ }
+
+ FetchEdit();
+
+ foreach (BitmapChar c in m_chars)
+ {
+ if (c.FirstUsedColumn!=-1)
+ {
+ if (c.FirstUsedColumn<gap)
+ {
+ if (c.LastUsedColumn<c.Width-1)
+ {
+ c.Scroll(1,0);
+ }
+ else
+ {
+ failed++;
+ }
+ }
+ else
+ {
+ c.Scroll(gap-c.FirstUsedColumn,0);
+ }
+ }
+ }
+
+ m_chars.Changed=true;
+ m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]);
+
+ if (failed>0)
+ {
+ Util.Message("Failed to fix " + failed + " characters\nCharacters already take up all columns.");
+ }
+ }
+
void OnAutoWidth(object sender, System.EventArgs e)
{
int gap=1;