diff --git a/RE2REmakeSRT/AttachUI.cs b/RE2REmakeSRT/AttachUI.cs index 20696a9..0bcfa7f 100644 --- a/RE2REmakeSRT/AttachUI.cs +++ b/RE2REmakeSRT/AttachUI.cs @@ -11,6 +11,9 @@ public partial class AttachUI : Form public AttachUI() { InitializeComponent(); + + this.ContextMenu = Program.contextMenu; + processPollingTimer = new System.Timers.Timer() { AutoReset = false, Interval = 250 }; processPollingTimer.Elapsed += ProcessPollingTimer_Elapsed; processPollingTimer.Start(); diff --git a/RE2REmakeSRT/MainUI.cs b/RE2REmakeSRT/MainUI.cs index 2d879c0..d400a33 100644 --- a/RE2REmakeSRT/MainUI.cs +++ b/RE2REmakeSRT/MainUI.cs @@ -50,10 +50,10 @@ public MainUI() // Set titlebar. this.Text += string.Format(" v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); - if (Program.programSpecialOptions.HasFlag(ProgramFlags.NoTitleBar)) + if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.NoTitleBar)) this.FormBorderStyle = FormBorderStyle.None; - if (Program.programSpecialOptions.HasFlag(ProgramFlags.Transparent)) + if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.Transparent)) this.TransparencyKey = Color.Black; // Set the width and height of the inventory display so it matches the maximum items and the scaling size of those items. @@ -71,6 +71,11 @@ public MainUI() lastPtrUpdate = DateTime.UtcNow.Ticks; lastFullUIDraw = DateTime.UtcNow.Ticks; + this.ContextMenu = Program.contextMenu; + this.playerHealthStatus.ContextMenu = Program.contextMenu; + this.statisticsPanel.ContextMenu = Program.contextMenu; + this.inventoryPanel.ContextMenu = Program.contextMenu; + memoryPollingTimer = new System.Timers.Timer() { AutoReset = false, Interval = SLIM_UI_DRAW_MS }; memoryPollingTimer.Elapsed += MemoryPollingTimer_Elapsed; memoryPollingTimer.Start(); @@ -83,7 +88,7 @@ private void MemoryPollingTimer_Elapsed(object sender, System.Timers.ElapsedEven // Suspend UI layout logic to perform redrawing. MainUI uiForm = (MainUI)Program.mainContext.MainForm; - if (Program.programSpecialOptions.HasFlag(ProgramFlags.AlwaysOnTop)) + if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.AlwaysOnTop)) { if (uiForm.InvokeRequired) uiForm.Invoke(new Action(() => uiForm.TopMost = true)); @@ -238,7 +243,7 @@ private void statisticsPanel_Paint(object sender, PaintEventArgs e) // IGT Display. e.Graphics.DrawString(string.Format("{0}", Program.gameMem.IGTString), new Font("Consolas", 16, FontStyle.Bold), Brushes.White, 0, 0, stdStringFormat); - if (Program.programSpecialOptions.HasFlag(ProgramFlags.Debug)) + if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.Debug)) { e.Graphics.DrawString("Raw IGT", new Font("Consolas", 9, FontStyle.Bold), Brushes.Gray, 2, 25, stdStringFormat); e.Graphics.DrawString(Program.gameMem.IGTRaw.ToString(), new Font("Consolas", 12, FontStyle.Bold), Brushes.Gray, 0, 37, stdStringFormat); diff --git a/RE2REmakeSRT/Options.cs b/RE2REmakeSRT/Options.cs new file mode 100644 index 0000000..d89243c --- /dev/null +++ b/RE2REmakeSRT/Options.cs @@ -0,0 +1,77 @@ +using Microsoft.Win32; + +namespace RE2REmakeSRT +{ + public struct Options + { + public ProgramFlags Flags; + public double ScalingFactor; + + public void GetOptions() + { + // Initialize registry key. + RegistryKey optionsKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\RE2REmakeSRT", false); + + // Load registry values. + if (RegistryHelper.GetBoolValue(optionsKey, "Debug", false)) + Flags |= ProgramFlags.Debug; + else + Flags &= ~ProgramFlags.Debug; + + if (RegistryHelper.GetBoolValue(optionsKey, "SkipChecksumCheck", false)) + Flags |= ProgramFlags.SkipChecksumCheck; + else + Flags &= ~ProgramFlags.SkipChecksumCheck; + + if (RegistryHelper.GetBoolValue(optionsKey, "NoTitleBar", false)) + Flags |= ProgramFlags.NoTitleBar; + else + Flags &= ~ProgramFlags.NoTitleBar; + + if (RegistryHelper.GetBoolValue(optionsKey, "AlwaysOnTop", false)) + Flags |= ProgramFlags.AlwaysOnTop; + else + Flags &= ~ProgramFlags.AlwaysOnTop; + + if (RegistryHelper.GetBoolValue(optionsKey, "Transparent", false)) + Flags |= ProgramFlags.Transparent; + else + Flags &= ~ProgramFlags.Transparent; + + double.TryParse(RegistryHelper.GetValue(optionsKey, "ScalingFactor", "0.75"), out ScalingFactor); + } + + public void SetOptions() + { + // Initialize registry key. + RegistryKey optionsKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\RE2REmakeSRT", true); + + if ((Flags & ProgramFlags.Debug) == ProgramFlags.Debug) + optionsKey.SetValue("Debug", 1, RegistryValueKind.DWord); + else + optionsKey.SetValue("Debug", 0, RegistryValueKind.DWord); + + if ((Flags & ProgramFlags.SkipChecksumCheck) == ProgramFlags.SkipChecksumCheck) + optionsKey.SetValue("SkipChecksumCheck", 1, RegistryValueKind.DWord); + else + optionsKey.SetValue("SkipChecksumCheck", 0, RegistryValueKind.DWord); + + if ((Flags & ProgramFlags.NoTitleBar) == ProgramFlags.NoTitleBar) + optionsKey.SetValue("NoTitleBar", 1, RegistryValueKind.DWord); + else + optionsKey.SetValue("NoTitleBar", 0, RegistryValueKind.DWord); + + if ((Flags & ProgramFlags.AlwaysOnTop) == ProgramFlags.AlwaysOnTop) + optionsKey.SetValue("AlwaysOnTop", 1, RegistryValueKind.DWord); + else + optionsKey.SetValue("AlwaysOnTop", 0, RegistryValueKind.DWord); + + if ((Flags & ProgramFlags.Transparent) == ProgramFlags.Transparent) + optionsKey.SetValue("Transparent", 1, RegistryValueKind.DWord); + else + optionsKey.SetValue("Transparent", 0, RegistryValueKind.DWord); + + optionsKey.SetValue("ScalingFactor", ScalingFactor.ToString(), RegistryValueKind.String); + } + } +} diff --git a/RE2REmakeSRT/OptionsUI.Designer.cs b/RE2REmakeSRT/OptionsUI.Designer.cs new file mode 100644 index 0000000..0d9b423 --- /dev/null +++ b/RE2REmakeSRT/OptionsUI.Designer.cs @@ -0,0 +1,191 @@ +namespace RE2REmakeSRT +{ + partial class OptionsUI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.debugCheckBox = new System.Windows.Forms.CheckBox(); + this.skipChecksumCheckBox = new System.Windows.Forms.CheckBox(); + this.noTitlebarCheckBox = new System.Windows.Forms.CheckBox(); + this.alwaysOnTopCheckBox = new System.Windows.Forms.CheckBox(); + this.transparentBackgroundCheckBox = new System.Windows.Forms.CheckBox(); + this.optionsGroupBox = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.scalingFactorNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.cancelButton = new System.Windows.Forms.Button(); + this.saveButton = new System.Windows.Forms.Button(); + this.optionsGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scalingFactorNumericUpDown)).BeginInit(); + this.SuspendLayout(); + // + // debugCheckBox + // + this.debugCheckBox.AutoSize = true; + this.debugCheckBox.Location = new System.Drawing.Point(6, 122); + this.debugCheckBox.Name = "debugCheckBox"; + this.debugCheckBox.Size = new System.Drawing.Size(88, 17); + this.debugCheckBox.TabIndex = 0; + this.debugCheckBox.Text = "Debug Mode"; + this.debugCheckBox.UseVisualStyleBackColor = true; + // + // skipChecksumCheckBox + // + this.skipChecksumCheckBox.AutoSize = true; + this.skipChecksumCheckBox.Location = new System.Drawing.Point(6, 99); + this.skipChecksumCheckBox.Name = "skipChecksumCheckBox"; + this.skipChecksumCheckBox.Size = new System.Drawing.Size(148, 17); + this.skipChecksumCheckBox.TabIndex = 1; + this.skipChecksumCheckBox.Text = "Skip Checksum Checking"; + this.skipChecksumCheckBox.UseVisualStyleBackColor = true; + // + // noTitlebarCheckBox + // + this.noTitlebarCheckBox.AutoSize = true; + this.noTitlebarCheckBox.Location = new System.Drawing.Point(6, 53); + this.noTitlebarCheckBox.Name = "noTitlebarCheckBox"; + this.noTitlebarCheckBox.Size = new System.Drawing.Size(78, 17); + this.noTitlebarCheckBox.TabIndex = 2; + this.noTitlebarCheckBox.Text = "No Titlebar"; + this.noTitlebarCheckBox.UseVisualStyleBackColor = true; + // + // alwaysOnTopCheckBox + // + this.alwaysOnTopCheckBox.AutoSize = true; + this.alwaysOnTopCheckBox.Location = new System.Drawing.Point(6, 30); + this.alwaysOnTopCheckBox.Name = "alwaysOnTopCheckBox"; + this.alwaysOnTopCheckBox.Size = new System.Drawing.Size(96, 17); + this.alwaysOnTopCheckBox.TabIndex = 3; + this.alwaysOnTopCheckBox.Text = "Always on Top"; + this.alwaysOnTopCheckBox.UseVisualStyleBackColor = true; + // + // transparentBackgroundCheckBox + // + this.transparentBackgroundCheckBox.AutoSize = true; + this.transparentBackgroundCheckBox.Location = new System.Drawing.Point(6, 76); + this.transparentBackgroundCheckBox.Name = "transparentBackgroundCheckBox"; + this.transparentBackgroundCheckBox.Size = new System.Drawing.Size(144, 17); + this.transparentBackgroundCheckBox.TabIndex = 4; + this.transparentBackgroundCheckBox.Text = "Transparent Background"; + this.transparentBackgroundCheckBox.UseVisualStyleBackColor = true; + // + // optionsGroupBox + // + this.optionsGroupBox.Controls.Add(this.label1); + this.optionsGroupBox.Controls.Add(this.scalingFactorNumericUpDown); + this.optionsGroupBox.Controls.Add(this.skipChecksumCheckBox); + this.optionsGroupBox.Controls.Add(this.debugCheckBox); + this.optionsGroupBox.Controls.Add(this.transparentBackgroundCheckBox); + this.optionsGroupBox.Controls.Add(this.noTitlebarCheckBox); + this.optionsGroupBox.Controls.Add(this.alwaysOnTopCheckBox); + this.optionsGroupBox.Location = new System.Drawing.Point(2, 2); + this.optionsGroupBox.Name = "optionsGroupBox"; + this.optionsGroupBox.Size = new System.Drawing.Size(169, 174); + this.optionsGroupBox.TabIndex = 5; + this.optionsGroupBox.TabStop = false; + this.optionsGroupBox.Text = "Options"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(65, 147); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(75, 13); + this.label1.TabIndex = 6; + this.label1.Text = "Scaling Factor"; + // + // scalingFactorNumericUpDown + // + this.scalingFactorNumericUpDown.DecimalPlaces = 2; + this.scalingFactorNumericUpDown.Increment = new decimal(new int[] { + 5, + 0, + 0, + 131072}); + this.scalingFactorNumericUpDown.Location = new System.Drawing.Point(6, 145); + this.scalingFactorNumericUpDown.Name = "scalingFactorNumericUpDown"; + this.scalingFactorNumericUpDown.Size = new System.Drawing.Size(53, 20); + this.scalingFactorNumericUpDown.TabIndex = 5; + this.scalingFactorNumericUpDown.Value = new decimal(new int[] { + 75, + 0, + 0, + 131072}); + // + // cancelButton + // + this.cancelButton.Location = new System.Drawing.Point(2, 182); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 6; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // saveButton + // + this.saveButton.Location = new System.Drawing.Point(96, 182); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(75, 23); + this.saveButton.TabIndex = 7; + this.saveButton.Text = "Save"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.saveButton_Click); + // + // OptionsUI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(173, 207); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.optionsGroupBox); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "OptionsUI"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "RE2 (2019) SRT"; + this.optionsGroupBox.ResumeLayout(false); + this.optionsGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scalingFactorNumericUpDown)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.CheckBox debugCheckBox; + private System.Windows.Forms.CheckBox skipChecksumCheckBox; + private System.Windows.Forms.CheckBox noTitlebarCheckBox; + private System.Windows.Forms.CheckBox alwaysOnTopCheckBox; + private System.Windows.Forms.CheckBox transparentBackgroundCheckBox; + private System.Windows.Forms.GroupBox optionsGroupBox; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown scalingFactorNumericUpDown; + } +} \ No newline at end of file diff --git a/RE2REmakeSRT/OptionsUI.cs b/RE2REmakeSRT/OptionsUI.cs new file mode 100644 index 0000000..a74ee5d --- /dev/null +++ b/RE2REmakeSRT/OptionsUI.cs @@ -0,0 +1,66 @@ +using System; +using System.Windows.Forms; + +namespace RE2REmakeSRT +{ + public partial class OptionsUI : Form + { + public OptionsUI() + { + InitializeComponent(); + + // Set titlebar. + this.Text += string.Format(" v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); + + debugCheckBox.Checked = (Program.programSpecialOptions.Flags & ProgramFlags.Debug) == ProgramFlags.Debug; + skipChecksumCheckBox.Checked = (Program.programSpecialOptions.Flags & ProgramFlags.SkipChecksumCheck) == ProgramFlags.SkipChecksumCheck; + noTitlebarCheckBox.Checked = (Program.programSpecialOptions.Flags & ProgramFlags.NoTitleBar) == ProgramFlags.NoTitleBar; + alwaysOnTopCheckBox.Checked = (Program.programSpecialOptions.Flags & ProgramFlags.AlwaysOnTop) == ProgramFlags.AlwaysOnTop; + transparentBackgroundCheckBox.Checked = (Program.programSpecialOptions.Flags & ProgramFlags.Transparent) == ProgramFlags.Transparent; + scalingFactorNumericUpDown.Value = (decimal)Program.programSpecialOptions.ScalingFactor; + } + + private void cancelButton_Click(object sender, EventArgs e) + { + // Close form. + this.Close(); + } + + private void saveButton_Click(object sender, EventArgs e) + { + // Set flag changes prior to saving. + if (debugCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.Debug) != ProgramFlags.Debug) + Program.programSpecialOptions.Flags |= ProgramFlags.Debug; + else if (!debugCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.Debug) == ProgramFlags.Debug) + Program.programSpecialOptions.Flags &= ~ProgramFlags.Debug; + + if (skipChecksumCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.SkipChecksumCheck) != ProgramFlags.SkipChecksumCheck) + Program.programSpecialOptions.Flags |= ProgramFlags.SkipChecksumCheck; + else if (!skipChecksumCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.SkipChecksumCheck) == ProgramFlags.SkipChecksumCheck) + Program.programSpecialOptions.Flags &= ~ProgramFlags.SkipChecksumCheck; + + if (noTitlebarCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.NoTitleBar) != ProgramFlags.NoTitleBar) + Program.programSpecialOptions.Flags |= ProgramFlags.NoTitleBar; + else if (!noTitlebarCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.NoTitleBar) == ProgramFlags.NoTitleBar) + Program.programSpecialOptions.Flags &= ~ProgramFlags.NoTitleBar; + + if (alwaysOnTopCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.AlwaysOnTop) != ProgramFlags.AlwaysOnTop) + Program.programSpecialOptions.Flags |= ProgramFlags.AlwaysOnTop; + else if (!alwaysOnTopCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.AlwaysOnTop) == ProgramFlags.AlwaysOnTop) + Program.programSpecialOptions.Flags &= ~ProgramFlags.AlwaysOnTop; + + if (transparentBackgroundCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.Transparent) != ProgramFlags.Transparent) + Program.programSpecialOptions.Flags |= ProgramFlags.Transparent; + else if (!transparentBackgroundCheckBox.Checked && (Program.programSpecialOptions.Flags & ProgramFlags.Transparent) == ProgramFlags.Transparent) + Program.programSpecialOptions.Flags &= ~ProgramFlags.Transparent; + + Program.programSpecialOptions.ScalingFactor = (double)scalingFactorNumericUpDown.Value; + + // Write registry values. + Program.programSpecialOptions.SetOptions(); + + // Close form. + this.Close(); + } + } +} diff --git a/RE2REmakeSRT/OptionsUI.resx b/RE2REmakeSRT/OptionsUI.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/RE2REmakeSRT/OptionsUI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RE2REmakeSRT/Program.cs b/RE2REmakeSRT/Program.cs index c5414a4..e773b66 100644 --- a/RE2REmakeSRT/Program.cs +++ b/RE2REmakeSRT/Program.cs @@ -11,12 +11,12 @@ namespace RE2REmakeSRT public static class Program { public static ApplicationContext mainContext; - public static ProgramFlags programSpecialOptions; + public static ContextMenu contextMenu; + public static Options programSpecialOptions; public static Process gameProc; public static GameMemory gameMem; public static Bitmap inventoryImage; // The inventory item sheet. public static Bitmap inventoryError; // An error image. - public static double INV_SLOT_SCALING = 0.75d; // Scaling factor for the inventory images. public static int INV_SLOT_WIDTH; public static int INV_SLOT_HEIGHT; @@ -27,7 +27,9 @@ public static class Program public static void Main(string[] args) { // Handle command-line parameters. - programSpecialOptions = ProgramFlags.None; + programSpecialOptions = new Options(); + programSpecialOptions.GetOptions(); + foreach (string arg in args) { if (arg.Equals("--Help", StringComparison.InvariantCultureIgnoreCase)) @@ -45,28 +47,28 @@ public static void Main(string[] args) } if (arg.Equals("--Skip-Checksum", StringComparison.InvariantCultureIgnoreCase)) - programSpecialOptions |= ProgramFlags.SkipChecksumCheck; + programSpecialOptions.Flags |= ProgramFlags.SkipChecksumCheck; if (arg.Equals("--No-Titlebar", StringComparison.InvariantCultureIgnoreCase)) - programSpecialOptions |= ProgramFlags.NoTitleBar; + programSpecialOptions.Flags |= ProgramFlags.NoTitleBar; if (arg.Equals("--Always-On-Top", StringComparison.InvariantCultureIgnoreCase)) - programSpecialOptions |= ProgramFlags.AlwaysOnTop; + programSpecialOptions.Flags |= ProgramFlags.AlwaysOnTop; if (arg.Equals("--Transparent", StringComparison.InvariantCultureIgnoreCase)) - programSpecialOptions |= ProgramFlags.Transparent; + programSpecialOptions.Flags |= ProgramFlags.Transparent; if (arg.StartsWith("--ScalingFactor=", StringComparison.InvariantCultureIgnoreCase)) - if (!double.TryParse(arg.Split(new char[1] { '=' }, 2, StringSplitOptions.None)[1], out INV_SLOT_SCALING)) - INV_SLOT_SCALING = 0.75d; // Default scaling factor for the inventory images. If we fail to process the user input, ensure this gets set to the default value just in case. + if (!double.TryParse(arg.Split(new char[1] { '=' }, 2, StringSplitOptions.None)[1], out programSpecialOptions.ScalingFactor)) + programSpecialOptions.ScalingFactor = 0.75d; // Default scaling factor for the inventory images. If we fail to process the user input, ensure this gets set to the default value just in case. if (arg.Equals("--Debug", StringComparison.InvariantCultureIgnoreCase)) - programSpecialOptions |= ProgramFlags.Debug; + programSpecialOptions.Flags |= ProgramFlags.Debug; } // Set item slot sizes after scaling is determined. - INV_SLOT_WIDTH = (int)Math.Round(112d * INV_SLOT_SCALING, MidpointRounding.AwayFromZero); // Individual inventory slot width. - INV_SLOT_HEIGHT = (int)Math.Round(112d * INV_SLOT_SCALING, MidpointRounding.AwayFromZero); // Individual inventory slot height. + INV_SLOT_WIDTH = (int)Math.Round(112d * programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero); // Individual inventory slot width. + INV_SLOT_HEIGHT = (int)Math.Round(112d * programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero); // Individual inventory slot height. // Standard WinForms stuff. Application.EnableVisualStyles(); @@ -76,10 +78,10 @@ public static void Main(string[] args) inventoryImage = Properties.Resources.ui0100_iam_texout.Clone(new Rectangle(0, 0, Properties.Resources.ui0100_iam_texout.Width, Properties.Resources.ui0100_iam_texout.Height), PixelFormat.Format32bppPArgb); // Rescales the image down if the scaling factor is not 1. - if (INV_SLOT_SCALING != 1d) + if (programSpecialOptions.ScalingFactor != 1d) { - int sheetWidth = (int)Math.Round(inventoryImage.Width * INV_SLOT_SCALING, MidpointRounding.AwayFromZero); - int sheetHeight = (int)Math.Round(inventoryImage.Height * INV_SLOT_SCALING, MidpointRounding.AwayFromZero); + int sheetWidth = (int)Math.Round(inventoryImage.Width * programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero); + int sheetHeight = (int)Math.Round(inventoryImage.Height * programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero); inventoryImage = new Bitmap(inventoryImage, sheetWidth, sheetHeight); } @@ -92,6 +94,18 @@ public static void Main(string[] args) grp.DrawLine(new Pen(Color.FromArgb(150, 255, 0, 0), 3), inventoryError.Width, 0, 0, inventoryError.Height); } + contextMenu = new ContextMenu(); + contextMenu.MenuItems.Add("Options", (object sender, EventArgs e) => + { + using (OptionsUI optionsForm = new OptionsUI()) + optionsForm.ShowDialog(); + }); + contextMenu.MenuItems.Add("-", (object sender, EventArgs e) => { }); + contextMenu.MenuItems.Add("Exit", (object sender, EventArgs e) => + { + Environment.Exit(0); + }); + // This form finds the process for re2.exe (assigned to gameProc) or waits until it is found. using (mainContext = new ApplicationContext(new AttachUI())) Application.Run(mainContext); diff --git a/RE2REmakeSRT/Properties/AssemblyInfo.cs b/RE2REmakeSRT/Properties/AssemblyInfo.cs index 3ecb5a5..74d5693 100644 --- a/RE2REmakeSRT/Properties/AssemblyInfo.cs +++ b/RE2REmakeSRT/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.5.2")] -[assembly: AssemblyFileVersion("1.1.5.2")] +[assembly: AssemblyVersion("1.1.6.0")] +[assembly: AssemblyFileVersion("1.1.6.0")] diff --git a/RE2REmakeSRT/RE2REmakeSRT.csproj b/RE2REmakeSRT/RE2REmakeSRT.csproj index db667a4..e2d76d5 100644 --- a/RE2REmakeSRT/RE2REmakeSRT.csproj +++ b/RE2REmakeSRT/RE2REmakeSRT.csproj @@ -72,16 +72,27 @@ + + + Form + + + OptionsUI.cs + + MainUI.cs + + OptionsUI.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/RE2REmakeSRT/REmake2VersionDetector.cs b/RE2REmakeSRT/REmake2VersionDetector.cs index 09ebd59..1c775d6 100644 --- a/RE2REmakeSRT/REmake2VersionDetector.cs +++ b/RE2REmakeSRT/REmake2VersionDetector.cs @@ -20,7 +20,7 @@ private static byte[] GetSHA256Checksum(string filePath) public static REmake2VersionEnumeration GetVersion(Process remake2Proc) { // If we're skipping the checksum version check, return the latest version we kow about. - if (Program.programSpecialOptions.HasFlag(ProgramFlags.SkipChecksumCheck)) + if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.SkipChecksumCheck)) return REmake2VersionEnumeration.Stock_1p01; byte[] processHash = GetSHA256Checksum(remake2Proc.MainModule.FileName); diff --git a/RE2REmakeSRT/RegistryHelper.cs b/RE2REmakeSRT/RegistryHelper.cs new file mode 100644 index 0000000..a345f9b --- /dev/null +++ b/RE2REmakeSRT/RegistryHelper.cs @@ -0,0 +1,15 @@ +using Microsoft.Win32; + +namespace RE2REmakeSRT +{ + public static class RegistryHelper + { + public static T GetValue(RegistryKey baseKey, string valueKey, T defaultValue) => (T)baseKey.GetValue(valueKey, defaultValue); + + public static bool GetBoolValue(RegistryKey baseKey, string valueKey, bool defaultValue) + { + int dwordValue = GetValue(baseKey, valueKey, (defaultValue) ? 1 : 0); + return (dwordValue == 0) ? false : true; + } + } +}