diff --git a/ReClass.NET/Controls/HotSpotTextBox.cs b/ReClass.NET/Controls/HotSpotTextBox.cs
index 218cdeb7..32cdb337 100644
--- a/ReClass.NET/Controls/HotSpotTextBox.cs
+++ b/ReClass.NET/Controls/HotSpotTextBox.cs
@@ -20,10 +20,10 @@ public class HotSpotTextBox : TextBox
get => font;
set
{
- if (font != value)
- {
- font = value;
+ font = value;
+ if (font?.Font != null)
+ {
base.Font = font.Font;
}
}
diff --git a/ReClass.NET/Controls/MemoryViewControl.cs b/ReClass.NET/Controls/MemoryViewControl.cs
index 64b8dfa4..7f150dca 100644
--- a/ReClass.NET/Controls/MemoryViewControl.cs
+++ b/ReClass.NET/Controls/MemoryViewControl.cs
@@ -88,6 +88,17 @@ public MemoryViewControl()
memoryPreviewPopUp = new MemoryPreviewPopUp(font);
}
+ public void RefreshFont()
+ {
+ if (Program.DesignMode)
+ {
+ return;
+ }
+
+ hotSpotEditBox.Font = font;
+ Invalidate();
+ }
+
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
diff --git a/ReClass.NET/Forms/MainForm.cs b/ReClass.NET/Forms/MainForm.cs
index e771a10d..eb1a75e6 100644
--- a/ReClass.NET/Forms/MainForm.cs
+++ b/ReClass.NET/Forms/MainForm.cs
@@ -97,6 +97,11 @@ public MainForm()
pluginManager = new PluginManager(new DefaultPluginHost(this, Program.RemoteProcess, Program.Logger));
}
+ public void RefreshMemoryViewFont()
+ {
+ memoryViewControl.RefreshFont();
+ }
+
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
diff --git a/ReClass.NET/Forms/SettingsForm.Designer.cs b/ReClass.NET/Forms/SettingsForm.Designer.cs
index 82e4efd9..0c61c8c4 100644
--- a/ReClass.NET/Forms/SettingsForm.Designer.cs
+++ b/ReClass.NET/Forms/SettingsForm.Designer.cs
@@ -45,6 +45,10 @@ private void InitializeComponent()
this.showIntegerCheckBox = new System.Windows.Forms.CheckBox();
this.showFloatCheckBox = new System.Windows.Forms.CheckBox();
this.displayGroupBox = new System.Windows.Forms.GroupBox();
+ this.monoSpaceFontSizeNumericUpDown = new System.Windows.Forms.NumericUpDown();
+ this.monoSpaceFontSizeLabel = new System.Windows.Forms.Label();
+ this.monoSpaceFontComboBox = new System.Windows.Forms.ComboBox();
+ this.monoSpaceFontLabel = new System.Windows.Forms.Label();
this.randomizeWindowTitleCheckBox = new System.Windows.Forms.CheckBox();
this.runAsAdminCheckBox = new System.Windows.Forms.CheckBox();
this.highlightChangedValuesCheckBox = new System.Windows.Forms.CheckBox();
@@ -136,6 +140,7 @@ private void InitializeComponent()
this.fileAssociationGroupBox.SuspendLayout();
this.commentsGroupBox.SuspendLayout();
this.displayGroupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.monoSpaceFontSizeNumericUpDown)).BeginInit();
this.colorsSettingTabPage.SuspendLayout();
this.nodeColorGroupBox.SuspendLayout();
this.typeDefinitionsSettingsTabPage.SuspendLayout();
@@ -150,7 +155,7 @@ private void InitializeComponent()
this.settingsTabControl.Location = new System.Drawing.Point(12, 60);
this.settingsTabControl.Name = "settingsTabControl";
this.settingsTabControl.SelectedIndex = 0;
- this.settingsTabControl.Size = new System.Drawing.Size(562, 355);
+ this.settingsTabControl.Size = new System.Drawing.Size(562, 395);
this.settingsTabControl.TabIndex = 1;
//
// generalSettingsTabPage
@@ -162,7 +167,7 @@ private void InitializeComponent()
this.generalSettingsTabPage.Location = new System.Drawing.Point(4, 22);
this.generalSettingsTabPage.Name = "generalSettingsTabPage";
this.generalSettingsTabPage.Padding = new System.Windows.Forms.Padding(3);
- this.generalSettingsTabPage.Size = new System.Drawing.Size(554, 329);
+ this.generalSettingsTabPage.Size = new System.Drawing.Size(554, 369);
this.generalSettingsTabPage.TabIndex = 0;
this.generalSettingsTabPage.Text = "General";
this.generalSettingsTabPage.UseVisualStyleBackColor = true;
@@ -172,7 +177,7 @@ private void InitializeComponent()
this.fileAssociationGroupBox.Controls.Add(this.removeAssociationButton);
this.fileAssociationGroupBox.Controls.Add(this.createAssociationButton);
this.fileAssociationGroupBox.Controls.Add(this.associationInfoLabel);
- this.fileAssociationGroupBox.Location = new System.Drawing.Point(6, 231);
+ this.fileAssociationGroupBox.Location = new System.Drawing.Point(6, 275);
this.fileAssociationGroupBox.Name = "fileAssociationGroupBox";
this.fileAssociationGroupBox.Size = new System.Drawing.Size(542, 85);
this.fileAssociationGroupBox.TabIndex = 4;
@@ -298,6 +303,10 @@ private void InitializeComponent()
//
// displayGroupBox
//
+ this.displayGroupBox.Controls.Add(this.monoSpaceFontSizeNumericUpDown);
+ this.displayGroupBox.Controls.Add(this.monoSpaceFontSizeLabel);
+ this.displayGroupBox.Controls.Add(this.monoSpaceFontComboBox);
+ this.displayGroupBox.Controls.Add(this.monoSpaceFontLabel);
this.displayGroupBox.Controls.Add(this.randomizeWindowTitleCheckBox);
this.displayGroupBox.Controls.Add(this.runAsAdminCheckBox);
this.displayGroupBox.Controls.Add(this.highlightChangedValuesCheckBox);
@@ -306,11 +315,60 @@ private void InitializeComponent()
this.displayGroupBox.Controls.Add(this.showNodeAddressCheckBox);
this.displayGroupBox.Location = new System.Drawing.Point(283, 39);
this.displayGroupBox.Name = "displayGroupBox";
- this.displayGroupBox.Size = new System.Drawing.Size(265, 160);
+ this.displayGroupBox.Size = new System.Drawing.Size(265, 230);
this.displayGroupBox.TabIndex = 2;
this.displayGroupBox.TabStop = false;
this.displayGroupBox.Text = "Display";
//
+ // monoSpaceFontSizeNumericUpDown
+ //
+ this.monoSpaceFontSizeNumericUpDown.Location = new System.Drawing.Point(70, 183);
+ this.monoSpaceFontSizeNumericUpDown.Minimum = new decimal(new int[] {
+ 6,
+ 0,
+ 0,
+ 0});
+ this.monoSpaceFontSizeNumericUpDown.Maximum = new decimal(new int[] {
+ 48,
+ 0,
+ 0,
+ 0});
+ this.monoSpaceFontSizeNumericUpDown.Name = "monoSpaceFontSizeNumericUpDown";
+ this.monoSpaceFontSizeNumericUpDown.Size = new System.Drawing.Size(185, 20);
+ this.monoSpaceFontSizeNumericUpDown.TabIndex = 9;
+ this.monoSpaceFontSizeNumericUpDown.Value = new decimal(new int[] {
+ 13,
+ 0,
+ 0,
+ 0});
+ //
+ // monoSpaceFontSizeLabel
+ //
+ this.monoSpaceFontSizeLabel.AutoSize = true;
+ this.monoSpaceFontSizeLabel.Location = new System.Drawing.Point(6, 185);
+ this.monoSpaceFontSizeLabel.Name = "monoSpaceFontSizeLabel";
+ this.monoSpaceFontSizeLabel.Size = new System.Drawing.Size(30, 13);
+ this.monoSpaceFontSizeLabel.TabIndex = 8;
+ this.monoSpaceFontSizeLabel.Text = "Size:";
+ //
+ // monoSpaceFontComboBox
+ //
+ this.monoSpaceFontComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.monoSpaceFontComboBox.FormattingEnabled = true;
+ this.monoSpaceFontComboBox.Location = new System.Drawing.Point(70, 156);
+ this.monoSpaceFontComboBox.Name = "monoSpaceFontComboBox";
+ this.monoSpaceFontComboBox.Size = new System.Drawing.Size(185, 21);
+ this.monoSpaceFontComboBox.TabIndex = 7;
+ //
+ // monoSpaceFontLabel
+ //
+ this.monoSpaceFontLabel.AutoSize = true;
+ this.monoSpaceFontLabel.Location = new System.Drawing.Point(6, 159);
+ this.monoSpaceFontLabel.Name = "monoSpaceFontLabel";
+ this.monoSpaceFontLabel.Size = new System.Drawing.Size(31, 13);
+ this.monoSpaceFontLabel.TabIndex = 6;
+ this.monoSpaceFontLabel.Text = "Font:";
+ //
// randomizeWindowTitleCheckBox
//
this.randomizeWindowTitleCheckBox.AutoSize = true;
@@ -1116,7 +1174,7 @@ private void InitializeComponent()
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(586, 427);
+ this.ClientSize = new System.Drawing.Size(586, 467);
this.Controls.Add(this.bannerBox);
this.Controls.Add(this.settingsTabControl);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@@ -1134,6 +1192,7 @@ private void InitializeComponent()
this.commentsGroupBox.PerformLayout();
this.displayGroupBox.ResumeLayout(false);
this.displayGroupBox.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.monoSpaceFontSizeNumericUpDown)).EndInit();
this.colorsSettingTabPage.ResumeLayout(false);
this.colorsSettingTabPage.PerformLayout();
this.nodeColorGroupBox.ResumeLayout(false);
@@ -1152,6 +1211,10 @@ private void InitializeComponent()
private System.Windows.Forms.TabPage typeDefinitionsSettingsTabPage;
private System.Windows.Forms.CheckBox stayOnTopCheckBox;
private System.Windows.Forms.GroupBox displayGroupBox;
+ private System.Windows.Forms.NumericUpDown monoSpaceFontSizeNumericUpDown;
+ private System.Windows.Forms.Label monoSpaceFontSizeLabel;
+ private System.Windows.Forms.ComboBox monoSpaceFontComboBox;
+ private System.Windows.Forms.Label monoSpaceFontLabel;
private System.Windows.Forms.CheckBox showNodeAddressCheckBox;
private System.Windows.Forms.CheckBox showTextCheckBox;
private System.Windows.Forms.CheckBox showNodeOffsetCheckBox;
diff --git a/ReClass.NET/Forms/SettingsForm.cs b/ReClass.NET/Forms/SettingsForm.cs
index fcc4121e..77fb9e33 100644
--- a/ReClass.NET/Forms/SettingsForm.cs
+++ b/ReClass.NET/Forms/SettingsForm.cs
@@ -1,5 +1,7 @@
using System;
using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
using ReClassNET.Controls;
using ReClassNET.Extensions;
@@ -106,6 +108,48 @@ private void SetGeneralBindings()
SetBinding(showPluginInfoCheckBox, nameof(CheckBox.Checked), settings, nameof(Settings.ShowCommentPluginInfo));
SetBinding(runAsAdminCheckBox, nameof(CheckBox.Checked), settings, nameof(Settings.RunAsAdmin));
SetBinding(randomizeWindowTitleCheckBox, nameof(CheckBox.Checked), settings, nameof(Settings.RandomizeWindowTitle));
+
+ var fontNames = FontFamily.Families
+ .Where(f => f.IsStyleAvailable(FontStyle.Regular))
+ .Select(f => f.Name)
+ .OrderBy(n => n)
+ .ToArray();
+ monoSpaceFontComboBox.Items.AddRange(fontNames);
+ if (!string.IsNullOrEmpty(settings.MonoSpaceFontName) && monoSpaceFontComboBox.Items.Contains(settings.MonoSpaceFontName))
+ {
+ monoSpaceFontComboBox.SelectedItem = settings.MonoSpaceFontName;
+ }
+ else if (monoSpaceFontComboBox.Items.Contains("Courier New"))
+ {
+ monoSpaceFontComboBox.SelectedItem = "Courier New";
+ }
+ else if (monoSpaceFontComboBox.Items.Count > 0)
+ {
+ monoSpaceFontComboBox.SelectedIndex = 0;
+ }
+ if (monoSpaceFontComboBox.SelectedItem is string selectedFont)
+ {
+ settings.MonoSpaceFontName = selectedFont;
+ }
+ monoSpaceFontComboBox.SelectedIndexChanged += (_, __) =>
+ {
+ if (monoSpaceFontComboBox.SelectedItem is string fontName)
+ {
+ settings.MonoSpaceFontName = fontName;
+ Program.UpdateMonoSpaceFont();
+ }
+ };
+
+ monoSpaceFontSizeNumericUpDown.Value = Math.Min(
+ monoSpaceFontSizeNumericUpDown.Maximum,
+ Math.Max(monoSpaceFontSizeNumericUpDown.Minimum, settings.MonoSpaceFontSize)
+ );
+ settings.MonoSpaceFontSize = (int)monoSpaceFontSizeNumericUpDown.Value;
+ monoSpaceFontSizeNumericUpDown.ValueChanged += (_, __) =>
+ {
+ settings.MonoSpaceFontSize = (int)monoSpaceFontSizeNumericUpDown.Value;
+ Program.UpdateMonoSpaceFont();
+ };
}
private void SetColorBindings()
diff --git a/ReClass.NET/Nodes/BaseNumericNode.cs b/ReClass.NET/Nodes/BaseNumericNode.cs
index 61782ca6..c549828d 100644
--- a/ReClass.NET/Nodes/BaseNumericNode.cs
+++ b/ReClass.NET/Nodes/BaseNumericNode.cs
@@ -37,10 +37,10 @@ protected Size DrawNumeric(DrawContext context, int x, int y, Image icon, string
x = AddIcon(context, x, y, icon, HotSpot.NoneId, HotSpotType.None);
x = AddAddressOffset(context, x, y);
- x = AddText(context, x, y, context.Settings.TypeColor, HotSpot.NoneId, type) + context.Font.Width;
+ x = AddText(context, x, y, context.Settings.TypeColor, HotSpot.NoneId, type.PadRight(6)) + context.Font.Width;
if (!IsWrapped)
{
- x = AddText(context, x, y, context.Settings.NameColor, HotSpot.NameId, Name) + context.Font.Width;
+ x = AddText(context, x, y, context.Settings.NameColor, HotSpot.NameId, Name.PadRight(12)) + context.Font.Width;
}
x = AddText(context, x, y, context.Settings.NameColor, HotSpot.NoneId, "=") + context.Font.Width;
x = AddText(context, x, y, context.Settings.ValueColor, 0, value) + context.Font.Width;
diff --git a/ReClass.NET/Program.cs b/ReClass.NET/Program.cs
index f28cb0bd..5d6bc4c8 100644
--- a/ReClass.NET/Program.cs
+++ b/ReClass.NET/Program.cs
@@ -51,13 +51,6 @@ static void Main(string[] args)
// ignored
}
- MonoSpaceFont = new FontEx
- {
- Font = new Font("Courier New", DpiUtil.ScaleIntX(13), GraphicsUnit.Pixel),
- Width = DpiUtil.ScaleIntX(8),
- Height = DpiUtil.ScaleIntY(16)
- };
-
NativeMethods.EnableDebugPrivileges();
Application.EnableVisualStyles();
@@ -68,6 +61,8 @@ static void Main(string[] args)
Settings = SettingsSerializer.Load();
Logger = new GuiLogger();
+ UpdateMonoSpaceFont();
+
if (!NativeMethods.IsUnix() && Settings.RunAsAdmin && !WinUtil.IsAdministrator)
{
WinUtil.RunElevated(Process.GetCurrentProcess().MainModule?.FileName, args.Length > 0 ? string.Join(" ", args) : null);
@@ -99,6 +94,48 @@ static void Main(string[] args)
SettingsSerializer.Save(Settings);
}
+ /// Creates or updates the monospace font used by the memory view from .
+ public static void UpdateMonoSpaceFont()
+ {
+ var fontName = string.IsNullOrWhiteSpace(Settings?.MonoSpaceFontName) ? "Courier New" : Settings.MonoSpaceFontName;
+ var fontSize = Settings?.MonoSpaceFontSize > 0 ? Settings.MonoSpaceFontSize : 13;
+
+ Font font;
+ try
+ {
+ font = new Font(fontName, DpiUtil.ScaleIntX(fontSize), GraphicsUnit.Pixel);
+ }
+ catch
+ {
+ font = new Font(FontFamily.GenericMonospace, DpiUtil.ScaleIntX(fontSize), GraphicsUnit.Pixel);
+ }
+
+ int width;
+ int height;
+ using (var bitmap = new Bitmap(1, 1))
+ using (var g = Graphics.FromImage(bitmap))
+ {
+ var charSize = g.MeasureString("X", font, int.MaxValue, StringFormat.GenericTypographic);
+ width = Math.Max(1, (int)Math.Ceiling(charSize.Width));
+ height = Math.Max(1, (int)Math.Ceiling(font.GetHeight(g)));
+ }
+
+ var previous = MonoSpaceFont?.Font;
+
+ if (MonoSpaceFont == null)
+ {
+ MonoSpaceFont = new FontEx();
+ }
+
+ MonoSpaceFont.Font = font;
+ MonoSpaceFont.Width = width;
+ MonoSpaceFont.Height = height;
+
+ previous?.Dispose();
+
+ MainForm?.RefreshMemoryViewFont();
+ }
+
/// Shows the exception in a special form.
/// The exception.
public static void ShowException(Exception ex)
diff --git a/ReClass.NET/Settings.cs b/ReClass.NET/Settings.cs
index b5d9268b..bd5c796d 100644
--- a/ReClass.NET/Settings.cs
+++ b/ReClass.NET/Settings.cs
@@ -26,6 +26,10 @@ public class Settings
public bool HighlightChangedValues { get; set; } = true;
+ public string MonoSpaceFontName { get; set; } = "Courier New";
+
+ public int MonoSpaceFontSize { get; set; } = 13;
+
public Encoding RawDataEncoding { get; set; } = Encoding.GetEncoding(1252); /* Windows-1252 */
// Comment Drawing Settings
diff --git a/ReClass.NET/Util/SettingsSerializer.cs b/ReClass.NET/Util/SettingsSerializer.cs
index 2a5a4e82..451aec11 100644
--- a/ReClass.NET/Util/SettingsSerializer.cs
+++ b/ReClass.NET/Util/SettingsSerializer.cs
@@ -44,6 +44,8 @@ public static Settings Load()
XElementSerializer.TryRead(display, nameof(settings.ShowNodeOffset), e => settings.ShowNodeOffset = XElementSerializer.ToBool(e));
XElementSerializer.TryRead(display, nameof(settings.ShowNodeText), e => settings.ShowNodeText = XElementSerializer.ToBool(e));
XElementSerializer.TryRead(display, nameof(settings.HighlightChangedValues), e => settings.HighlightChangedValues = XElementSerializer.ToBool(e));
+ XElementSerializer.TryRead(display, nameof(settings.MonoSpaceFontName), e => settings.MonoSpaceFontName = XElementSerializer.ToString(e));
+ XElementSerializer.TryRead(display, nameof(settings.MonoSpaceFontSize), e => settings.MonoSpaceFontSize = XElementSerializer.ToInt(e));
XElementSerializer.TryRead(display, nameof(settings.ShowCommentFloat), e => settings.ShowCommentFloat = XElementSerializer.ToBool(e));
XElementSerializer.TryRead(display, nameof(settings.ShowCommentInteger), e => settings.ShowCommentInteger = XElementSerializer.ToBool(e));
XElementSerializer.TryRead(display, nameof(settings.ShowCommentPointer), e => settings.ShowCommentPointer = XElementSerializer.ToBool(e));
@@ -115,6 +117,8 @@ public static void Save(Settings settings)
XElementSerializer.ToXml(nameof(settings.ShowNodeOffset), settings.ShowNodeOffset),
XElementSerializer.ToXml(nameof(settings.ShowNodeText), settings.ShowNodeText),
XElementSerializer.ToXml(nameof(settings.HighlightChangedValues), settings.HighlightChangedValues),
+ XElementSerializer.ToXml(nameof(settings.MonoSpaceFontName), settings.MonoSpaceFontName),
+ XElementSerializer.ToXml(nameof(settings.MonoSpaceFontSize), settings.MonoSpaceFontSize),
XElementSerializer.ToXml(nameof(settings.ShowCommentFloat), settings.ShowCommentFloat),
XElementSerializer.ToXml(nameof(settings.ShowCommentInteger), settings.ShowCommentInteger),
XElementSerializer.ToXml(nameof(settings.ShowCommentPointer), settings.ShowCommentPointer),