From dbbb195540cfea514489d9379089fee009fdaca2 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 13 Oct 2024 22:34:13 -0400 Subject: [PATCH] Indicate selected preset in the presets menu --- BinxelviewForm.cs | 16 ++++++++++++++-- readme.txt | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/BinxelviewForm.cs b/BinxelviewForm.cs index 70052a7..f4ed553 100644 --- a/BinxelviewForm.cs +++ b/BinxelviewForm.cs @@ -73,6 +73,7 @@ enum PaletteMode bool disable_pixel_redraw = false; // used to temporarily block redraws during repeated updates Font posfont_regular, posfont_bold; Random random = new Random(); + int preset_menu_fixed_items; int main_w, main_h; // used to restore size during split_view switch int fixed_w, fixed_h; @@ -1229,9 +1230,9 @@ bool openFile(string path) void reloadPresets() { // remove everything but Reload, Set Directory and separator - while (presetToolStripMenuItem.DropDownItems.Count > 3) + while (presetToolStripMenuItem.DropDownItems.Count > preset_menu_fixed_items) { - presetToolStripMenuItem.DropDownItems.RemoveAt(3); + presetToolStripMenuItem.DropDownItems.RemoveAt(preset_menu_fixed_items); } presets = new List(); @@ -1586,6 +1587,13 @@ void redrawPreset() twiddleZAdvancedMenuItem.Checked = preset.twiddle == 1; twiddleNAdvancedMenuItem.Checked = preset.twiddle == 2; + // check the preset menu item corresponding to the current preset + for (int i=preset_menu_fixed_items; i < presetToolStripMenuItem.DropDownItems.Count; ++i) + { + ToolStripMenuItem t = (ToolStripMenuItem)presetToolStripMenuItem.DropDownItems[i]; + t.Checked = (preset.name == t.Name); + } + disable_pixel_redraw = old_disable_pixel_redraw; // restore pixel redraw } @@ -1738,6 +1746,7 @@ private void exitFileMenuItem_Click(object sender, EventArgs e) private void reloadPresetMenuItem_Click(object sender, EventArgs e) { reloadPresets(); + redrawPreset(); } private void setDirectoryPresetMenuItem_Click(object sender, EventArgs e) @@ -1757,6 +1766,7 @@ private void setDirectoryPresetMenuItem_Click(object sender, EventArgs e) { preset_dir = Path.GetDirectoryName(d.FileName); reloadPresets(); + redrawPreset(); } } @@ -2175,6 +2185,7 @@ private void buttonSavePreset_Click(object sender, EventArgs e) { preset.name = Path.GetFileNameWithoutExtension(d.FileName); // update name for saved options reloadPresets(); + redrawPreset(); } } } @@ -2647,6 +2658,7 @@ private void BinxelviewForm_Load(object sender, EventArgs e) comboBoxPalette.SelectedIndex = (int)PaletteMode.PALETTE_RGB - 1; numericZoom.Minimum = 1; numericZoom.Maximum = ZOOM_MAX; + preset_menu_fixed_items = presetToolStripMenuItem.DropDownItems.Count; fixed_w = this.Width; // default width is fixed width fixed_h = this.Height - (pixelScroll.Height + 0); // fixed height should cut off pixel view entirely main_w = this.Width; diff --git a/readme.txt b/readme.txt index 97e679b..f5d5b49 100644 --- a/readme.txt +++ b/readme.txt @@ -279,6 +279,7 @@ Changes - Use byte/bit for default chunky table instead of just bit. - Genesis/MegaDrive 8px preset. - Fix bug when loading version 3 presets. +- Indicate selected preset in the presets menu. 1.6.1.0 (2024-10-13) - Option persistence, INI file save and load.