From a287ddaee7f62d25898d5d9e3504c6ef877b5d6e Mon Sep 17 00:00:00 2001 From: Anton Mukhin Date: Fri, 23 May 2025 16:40:44 +0300 Subject: [PATCH] Bugs fixed: - Improper bytes count for 16 or 32 bit numbers export - Exception on Code Shift when nothing is selected in Symbols List --- McBitFont/CodeShift.Designer.cs | 10 +++++----- McBitFont/Export.cs | 17 +++++++++-------- McBitFont/Form1.cs | 7 ++++++- TODO.txt | 4 ++++ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/McBitFont/CodeShift.Designer.cs b/McBitFont/CodeShift.Designer.cs index 9051363..1ded990 100644 --- a/McBitFont/CodeShift.Designer.cs +++ b/McBitFont/CodeShift.Designer.cs @@ -76,17 +76,17 @@ // lblValue // lblValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - lblValue.AutoSize = true; - lblValue.Location = new System.Drawing.Point(206, 8); + lblValue.Location = new System.Drawing.Point(156, 8); lblValue.Name = "lblValue"; - lblValue.Size = new System.Drawing.Size(50, 15); + lblValue.Size = new System.Drawing.Size(110, 15); lblValue.TabIndex = 3; lblValue.Text = "Shift by:"; + lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // nudValue // nudValue.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - nudValue.Location = new System.Drawing.Point(206, 27); + nudValue.Location = new System.Drawing.Point(185, 27); nudValue.Maximum = new decimal(new int[] { 254, 0, 0, 0 }); nudValue.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); nudValue.Name = "nudValue"; @@ -130,7 +130,7 @@ // lblRange // lblRange.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - lblRange.Location = new System.Drawing.Point(204, 53); + lblRange.Location = new System.Drawing.Point(183, 53); lblRange.Name = "lblRange"; lblRange.Size = new System.Drawing.Size(62, 31); lblRange.TabIndex = 9; diff --git a/McBitFont/Export.cs b/McBitFont/Export.cs index f4c593e..11f5fcb 100644 --- a/McBitFont/Export.cs +++ b/McBitFont/Export.cs @@ -33,7 +33,7 @@ namespace McBitFont { } } comments.Add("header", - "// File generated by McBitFont " + MainForm.version + "\n" + + "// File generated by McBitFont v" + MainForm.version + "\n" + "// made by Anton Mukhin (mcfly@mcflyer.ru)\n" + "//\n" + "//\n" @@ -51,7 +51,8 @@ namespace McBitFont { comments.Add("font_header_map", "// Font header map:\n" + - "// width; // Font width in pixels\n" + + "// packed; // Flag for packed font" + + "// width; // Font width in pixels (0 - variable width)\n" + "// height; // Font height in pixels\n" + "// space; // Font space in pixels\n" + "// first; // First character code\n" + @@ -212,7 +213,7 @@ namespace McBitFont { " " + mainForm.frames.First().code.ToString() + ", // First character code\n" + " " + mainForm.frames.Last().code.ToString() + ", // Last character code\n" ; - bTotal += 6; // Count bytes total + bTotal += 6*bits / 8; // Count bytes total } // Brackets for 2D array definition @@ -245,7 +246,7 @@ namespace McBitFont { // Should we post a prefix to the number? pref = (!cbZeroes.Checked && ((f.width < 10 && nbase == 16) || (f.width < 2 && nbase == 2))) ? "" : prefix; output += (lines != 1 ? " " : "") + pref + Convert.ToString(f.width, nbase).PadLeft(pad, '0') + (lines != 0 ? (lines == 1 ? ", " : "") : ",\n"); - bTotal++; // Count bytes total + bTotal += bits / 8; // Count bytes total // Count posted numbers numcount++; if (lines != 2) numcount = 0; @@ -336,7 +337,7 @@ namespace McBitFont { // should we post a prefix to the number? pref = (!cbZeroes.Checked && ((b < 10 && nbase == 16) || (b < 2 && nbase == 2))) ? "" : prefix; output += pref + Convert.ToString(b, nbase).PadLeft(pad, '0'); - bTotal++; // Count bytes total + bTotal += bits / 8; // Count bytes total // count posted numbers numcount++; @@ -353,12 +354,12 @@ namespace McBitFont { } } if (packed && (f.width * f.height / 8) % bits > 0) { - // post leftovers in last byte + // post leftovers in last number // should we post a prefix to the number? pref = (!cbZeroes.Checked && ((b < 10 && nbase == 16) || (b < 2 && nbase == 2))) ? "" : prefix; output += (numcount > 0? ", " : "") + pref + Convert.ToString(b, nbase).PadLeft(pad, '0'); - bTotal++; // Count bytes total + bTotal += bits / 8; // Count bytes total // count posted numbers numcount++; @@ -384,7 +385,7 @@ namespace McBitFont { // Add header and bytes total counter if (com) { - output = "// Bytes total: " + bTotal.ToString() + "\n" + output; + output = "// Bytes total: " + bTotal.ToString() + "\n" + output; output = comments["header"] + output; } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index efceba7..e083773 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -776,6 +776,9 @@ namespace McBitFont { prjFileName = filename; prjName = Path.GetFileNameWithoutExtension(filename); this.Text = "McBitFont " + version + " - " + prjName; + + miniList.Items[0].Selected = true; + CheckForAdd(); fbuffer = false; @@ -1019,7 +1022,9 @@ namespace McBitFont { Cursor.Current = Cursors.WaitCursor; FrameMiniature ff; - var sel = miniList.SelectedItems[0].Index; + int sel; + if (miniList.SelectedItems.Count > 0) sel = miniList.SelectedItems[0].Index; + else sel = 0; var val = Convert.ToInt32(csform.nudValue.Value); if (csform.rbSpecify.Checked) val -= csform.sc; if (csform.rbShiftLeft.Checked) val *= -1; diff --git a/TODO.txt b/TODO.txt index 7596bc0..6fda64c 100644 --- a/TODO.txt +++ b/TODO.txt @@ -5,6 +5,8 @@ V Better quality pictures in symbol list V Spinning cursor when application is busy V Change Menu icons V Re-arranged menu items +- Option to display codes in Hex numbers +- Make symbol list wider to display 8 characters instead of 7 Functionality: V Context menu in symbol navigator @@ -20,3 +22,5 @@ V "Packed" fonts export V "Bytes total comment in export Bugs: +V Improper bytes count for 16 or 32 bit numbers export +V Exception on Code Shift when nothing is selected in Symbols List