From 600287f275063dde1ea6f55fd9aa5247d27256cf Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 21 May 2005 02:38:48 +0000 Subject: Changed use of uints to ints (casting was getting silly). Fixed some funnies with edits -- font import now seem to work, somehow. --- BitmapChar.cs | 77 ++++++++++++++--------- BitmapFontEd.MainForm.resources | Bin 18455 -> 18455 bytes GfxEditor.cs | 136 ++++++++++++++++++---------------------- MainForm.cs | 85 +++++++++++++------------ Util.cs | 47 +++++++------- 5 files changed, 175 insertions(+), 170 deletions(-) diff --git a/BitmapChar.cs b/BitmapChar.cs index 4719b33..3033fee 100644 --- a/BitmapChar.cs +++ b/BitmapChar.cs @@ -29,12 +29,13 @@ namespace BitmapFontEd /// public class BitmapChar { - public BitmapChar(uint width, uint height) + public BitmapChar(int width, int height) { + CheckSize(width,height); m_width=width; m_height=height; m_data=new Color[m_width,m_height]; - Clear(Color.Empty); + Clear(Color.Transparent); m_changed=false; } @@ -55,12 +56,12 @@ namespace BitmapFontEd m_changed=old.m_changed; } - public uint Width + public int Width { get {return m_width;} } - public uint Height + public int Height { get {return m_height;} } @@ -70,8 +71,10 @@ namespace BitmapFontEd get {return m_changed;} } - public void Resize(uint width, uint height) + public void Resize(int width, int height) { + CheckSize(width,height); + if (width==m_width && height==m_height) { return; @@ -81,10 +84,10 @@ namespace BitmapFontEd for(int y=0;yc2) { - uint t=c2; + int t=c2; c2=c1; c1=t; } @@ -889,15 +884,10 @@ namespace BitmapFontEd m_overlay[x,y]=col; } - private void DrawLine(uint ux1, uint uy1, - uint ux2, uint uy2, + private void DrawLine(int x1, int y1, + int x2, int y2, Color col) { - int x1=(int)ux1;; - int y1=(int)uy1; - int x2=(int)ux2; - int y2=(int)uy2; - int dx=x2-x1; int dy=y2-y1; @@ -972,8 +962,8 @@ namespace BitmapFontEd } } - private void DrawRect(uint x1, uint y1, - uint x2, uint y2, + private void DrawRect(int x1, int y1, + int x2, int y2, Color col, bool fill) { RankCoord(ref x1, ref x2); @@ -981,19 +971,19 @@ namespace BitmapFontEd if (fill) { - for(uint x=x1;x<=x2;x++) - for(uint y=y1;y<=y2;y++) + for(int x=x1;x<=x2;x++) + for(int y=y1;y<=y2;y++) m_overlay[x,y]=col; } else { - for(uint x=x1;x<=x2;x++) + for(int x=x1;x<=x2;x++) { m_overlay[x,y1]=col; m_overlay[x,y2]=col; } - for(uint y=y1;y<=y2;y++) + for(int y=y1;y<=y2;y++) { m_overlay[x1,y]=col; m_overlay[x2,y]=col; @@ -1001,14 +991,12 @@ namespace BitmapFontEd } } - private void DrawEllipse(uint originx, uint originy, - uint radpointx, uint radpointy, + private void DrawEllipse(int ox, int oy, + int radpointx, int radpointy, Color col, bool circle, bool fill) { - int ox=(int)originx; - int oy=(int)originy; - double rx=Math.Abs(ox-(int)radpointx)+1; - double ry=Math.Abs(oy-(int)radpointy)+1; + double rx=Math.Abs(ox-radpointx)+1; + double ry=Math.Abs(oy-radpointy)+1; if (circle) { @@ -1034,7 +1022,7 @@ namespace BitmapFontEd } } - private void FloodFill(uint x, uint y, Color col, Color bg) + private void FloodFill(int x, int y, Color col, Color bg) { if (m_overlay[x,y]==col || m_overlay[x,y]!=bg) { @@ -1070,7 +1058,7 @@ namespace BitmapFontEd void OnSizeWidth(object sender, System.EventArgs e) { - m_width=Convert.ToUInt32(m_sizeX.Value); + m_width=Convert.ToInt32(m_sizeX.Value); if (m_char!=null) { @@ -1090,7 +1078,7 @@ namespace BitmapFontEd void OnSizeHeight(object sender, System.EventArgs e) { - m_height=Convert.ToUInt32(m_sizeY.Value); + m_height=Convert.ToInt32(m_sizeY.Value); if (m_char!=null) { @@ -1153,11 +1141,11 @@ namespace BitmapFontEd return; } - uint x; - uint y; + int x; + int y; - x=(uint)e.X/m_grid; - y=(uint)e.Y/m_grid; + x=e.X/m_grid; + y=e.Y/m_grid; m_pos.Text=x+","+y; diff --git a/MainForm.cs b/MainForm.cs index 6a48840..fa13599 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -36,7 +36,7 @@ namespace BitmapFontEd private System.Windows.Forms.Label label1; private System.Windows.Forms.MenuItem m_helpMenu; private System.Windows.Forms.NumericUpDown m_codeSelect; - private System.Windows.Forms.Label label5; + private System.Windows.Forms.GroupBox m_globaladjustGroup; private System.Windows.Forms.GroupBox m_adjustGroup; private System.Windows.Forms.Button m_scrollDown; private System.Windows.Forms.Button m_scrollUp; @@ -46,8 +46,6 @@ namespace BitmapFontEd private System.Windows.Forms.Button m_rotRight; private System.Windows.Forms.Button m_revert; private System.Windows.Forms.Button m_dropShadow; - private System.Windows.Forms.GroupBox m_globaladjustGroup; - private System.Windows.Forms.Button m_glow; private System.Windows.Forms.MenuItem m_about; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button m_scrollRight; @@ -60,8 +58,10 @@ namespace BitmapFontEd private System.Windows.Forms.MainMenu m_menu; private System.Windows.Forms.Button m_resize; 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.MenuItem m_save; + private System.Windows.Forms.Label label5; private System.Windows.Forms.MenuItem m_saveAs; private System.Windows.Forms.Button m_scrollLeft; private System.Windows.Forms.GroupBox m_editGroup; @@ -143,8 +143,10 @@ namespace BitmapFontEd this.m_editGroup = new System.Windows.Forms.GroupBox(); this.m_scrollLeft = 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_edge = new System.Windows.Forms.Button(); this.m_asciiSelect = new System.Windows.Forms.ComboBox(); this.m_resize = new System.Windows.Forms.Button(); this.m_menu = new System.Windows.Forms.MainMenu(); @@ -157,8 +159,6 @@ namespace BitmapFontEd this.m_scrollRight = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.m_about = new System.Windows.Forms.MenuItem(); - this.m_glow = new System.Windows.Forms.Button(); - this.m_globaladjustGroup = new System.Windows.Forms.GroupBox(); this.m_dropShadow = new System.Windows.Forms.Button(); this.m_revert = new System.Windows.Forms.Button(); this.m_rotRight = new System.Windows.Forms.Button(); @@ -168,15 +168,15 @@ namespace BitmapFontEd this.m_scrollUp = new System.Windows.Forms.Button(); this.m_scrollDown = new System.Windows.Forms.Button(); this.m_adjustGroup = new System.Windows.Forms.GroupBox(); - this.label5 = new System.Windows.Forms.Label(); + this.m_globaladjustGroup = new System.Windows.Forms.GroupBox(); this.m_codeSelect = new System.Windows.Forms.NumericUpDown(); this.m_helpMenu = new System.Windows.Forms.MenuItem(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.m_selectGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).BeginInit(); - this.m_globaladjustGroup.SuspendLayout(); this.m_adjustGroup.SuspendLayout(); + this.m_globaladjustGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).BeginInit(); this.SuspendLayout(); // @@ -252,6 +252,15 @@ namespace BitmapFontEd this.m_saveAs.Text = "S&ave as..."; this.m_saveAs.Click += new System.EventHandler(this.OnSaveAs); // + // label5 + // + this.label5.Location = new System.Drawing.Point(8, 200); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(72, 16); + this.label5.TabIndex = 11; + this.label5.Text = "Rotate"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // m_save // this.m_save.Index = 2; @@ -266,6 +275,15 @@ namespace BitmapFontEd this.m_quit.Text = "&Quit"; this.m_quit.Click += new System.EventHandler(this.OnQuit); // + // m_edge + // + this.m_edge.Location = new System.Drawing.Point(112, 272); + this.m_edge.Name = "m_edge"; + this.m_edge.Size = new System.Drawing.Size(96, 24); + this.m_edge.TabIndex = 17; + this.m_edge.Text = "Edge"; + this.m_edge.Click += new System.EventHandler(this.OnEdge); + // // m_asciiSelect // this.m_asciiSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -368,25 +386,6 @@ namespace BitmapFontEd this.m_about.Text = "&About"; this.m_about.Click += new System.EventHandler(this.OnAbout); // - // m_glow - // - this.m_glow.Location = new System.Drawing.Point(112, 272); - this.m_glow.Name = "m_glow"; - this.m_glow.Size = new System.Drawing.Size(96, 24); - this.m_glow.TabIndex = 17; - this.m_glow.Text = "Glow"; - this.m_glow.Click += new System.EventHandler(this.OnGlow); - // - // m_globaladjustGroup - // - 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_dropShadow // this.m_dropShadow.Location = new System.Drawing.Point(8, 272); @@ -461,7 +460,7 @@ namespace BitmapFontEd // m_adjustGroup // this.m_adjustGroup.Controls.Add(this.m_grabFont); - this.m_adjustGroup.Controls.Add(this.m_glow); + this.m_adjustGroup.Controls.Add(this.m_edge); this.m_adjustGroup.Controls.Add(this.m_dropShadow); this.m_adjustGroup.Controls.Add(this.label6); this.m_adjustGroup.Controls.Add(this.m_rotRight); @@ -484,14 +483,15 @@ namespace BitmapFontEd this.m_adjustGroup.TabStop = false; this.m_adjustGroup.Text = "Adjustments and Effects"; // - // label5 + // m_globaladjustGroup // - this.label5.Location = new System.Drawing.Point(8, 200); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(72, 16); - this.label5.TabIndex = 11; - this.label5.Text = "Rotate"; - this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + 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 // @@ -559,8 +559,8 @@ namespace BitmapFontEd this.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing); this.m_selectGroup.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).EndInit(); - this.m_globaladjustGroup.ResumeLayout(false); this.m_adjustGroup.ResumeLayout(false); + this.m_globaladjustGroup.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).EndInit(); this.ResumeLayout(false); } @@ -737,8 +737,8 @@ namespace BitmapFontEd void OnResize(object sender, System.EventArgs e) { - uint w=m_edit.CharWidth; - uint h=m_edit.CharHeight; + int w=m_edit.CharWidth; + int h=m_edit.CharHeight; if (Util.YesNo("Sure you want to resize all characters to " + w + " by " + h)) { @@ -911,7 +911,7 @@ namespace BitmapFontEd } } - void OnGlow(object sender, System.EventArgs e) + void OnEdge(object sender, System.EventArgs e) { AlphaColourDialog d=new AlphaColourDialog("Select Glow Colour"); @@ -927,12 +927,12 @@ namespace BitmapFontEd { foreach (BitmapChar c in m_chars) { - c.Glow(m_glowCol); + c.Edge(m_glowCol); } } else { - m_chars[m_selected].Glow(m_glowCol); + m_chars[m_selected].Edge(m_glowCol); } m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); @@ -965,11 +965,11 @@ namespace BitmapFontEd my=Math.Min(my+1,GfxEditor.MAX_SIZE); System.Diagnostics.Debug.WriteLine("(post)mx="+mx+" my="+my); - c.Resize((uint)mx,(uint)my); + c.Resize(mx,my); for(x=0;x>8; - } - } - public static void WriteInt(Stream str, int l) { for(uint f=0;f<4;f++) @@ -111,6 +90,30 @@ namespace BitmapFontEd str.Read(b,0,len); return Encoding.ASCII.GetString(b); } + + public static void DumpAlpha(string title, Color[,] col) + { + Debug.WriteLine("**** "+title+" ****"); + + for(int y=0;y