Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

Commit

Permalink
Added options UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Squirrelies committed Feb 10, 2019
1 parent 7932619 commit 5d779c2
Show file tree
Hide file tree
Showing 11 changed files with 524 additions and 22 deletions.
3 changes: 3 additions & 0 deletions RE2REmakeSRT/AttachUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 9 additions & 4 deletions RE2REmakeSRT/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
77 changes: 77 additions & 0 deletions RE2REmakeSRT/Options.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
191 changes: 191 additions & 0 deletions RE2REmakeSRT/OptionsUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions RE2REmakeSRT/OptionsUI.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Loading

0 comments on commit 5d779c2

Please sign in to comment.