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

Commit

Permalink
Added --Transparency
Browse files Browse the repository at this point in the history
Added --ScalingFactor
Added code to adjust inventory panel to correspond to the scaling factor slot width and height.
Added code to adjust form to inventory panel + statistics panel width.
  • Loading branch information
Squirrelies committed Feb 8, 2019
1 parent 3e47684 commit f470ae3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
33 changes: 27 additions & 6 deletions RE2REmakeSRT/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;

Expand All @@ -21,23 +22,39 @@ public partial class MainUI : Form
private System.Timers.Timer memoryPollingTimer;
private long lastPtrUpdate;
private long lastFullUIDraw;

private SmoothingMode smoothingMode = SmoothingMode.HighSpeed;
private PixelOffsetMode pixelOffsetMode = PixelOffsetMode.HighSpeed;
private CompositingQuality compositingQuality = CompositingQuality.HighSpeed;

private CompositingMode compositingMode = CompositingMode.SourceOver;
private CompositingQuality compositingQuality = CompositingQuality.HighSpeed;
private SmoothingMode smoothingMode = SmoothingMode.None;
private PixelOffsetMode pixelOffsetMode = PixelOffsetMode.Half;
private InterpolationMode interpolationMode = InterpolationMode.NearestNeighbor;
private TextRenderingHint textRenderingHint = TextRenderingHint.AntiAliasGridFit;
private StringFormat stringFormat = new StringFormat(StringFormat.GenericDefault) { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Far };

public MainUI()
{
InitializeComponent();

// Set titlebar.
this.Text += string.Format(" v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

if (Program.programSpecialOptions.HasFlag(ProgramFlags.NoTitleBar))
this.FormBorderStyle = FormBorderStyle.None;

// Set titlebar.
this.Text += string.Format(" v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
if (Program.programSpecialOptions.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.
this.inventoryPanel.Width = Program.INV_SLOT_WIDTH * 4;
this.inventoryPanel.Height = Program.INV_SLOT_HEIGHT * 5;

// Adjust main form width as well.
this.Width = this.statisticsPanel.Width + this.inventoryPanel.Width + 24;

//// We may also want adjust the statistics panel height and the form height.
//// Commenting out for right now in case they want 50% scaling but still need the statistics height to view enemy hp?
//this.statisticsPanel.Height = this.inventoryPanel.Height - 66;
//this.Height = this.inventoryPanel.Height + 41;

lastPtrUpdate = DateTime.UtcNow.Ticks;
lastFullUIDraw = DateTime.UtcNow.Ticks;
Expand Down Expand Up @@ -112,6 +129,7 @@ private void playerHealthStatus_Paint(object sender, PaintEventArgs e)
e.Graphics.CompositingMode = compositingMode;
e.Graphics.InterpolationMode = interpolationMode;
e.Graphics.PixelOffsetMode = pixelOffsetMode;
e.Graphics.TextRenderingHint = textRenderingHint;

// Draw health.
if (Program.gameMem.PlayerCurrentHealth > 1200 || Program.gameMem.PlayerCurrentHealth < 0) // Dead?
Expand Down Expand Up @@ -143,6 +161,7 @@ private void playerInfoPanel_Paint(object sender, PaintEventArgs e)
e.Graphics.CompositingMode = compositingMode;
e.Graphics.InterpolationMode = interpolationMode;
e.Graphics.PixelOffsetMode = pixelOffsetMode;
e.Graphics.TextRenderingHint = textRenderingHint;
}

private void inventoryPanel_Paint(object sender, PaintEventArgs e)
Expand All @@ -152,6 +171,7 @@ private void inventoryPanel_Paint(object sender, PaintEventArgs e)
e.Graphics.CompositingMode = compositingMode;
e.Graphics.InterpolationMode = interpolationMode;
e.Graphics.PixelOffsetMode = pixelOffsetMode;
e.Graphics.TextRenderingHint = textRenderingHint;

foreach (InventoryEntry inv in Program.gameMem.PlayerInventory)
{
Expand Down Expand Up @@ -194,6 +214,7 @@ private void statisticsPanel_Paint(object sender, PaintEventArgs e)
e.Graphics.CompositingMode = compositingMode;
e.Graphics.InterpolationMode = interpolationMode;
e.Graphics.PixelOffsetMode = pixelOffsetMode;
e.Graphics.TextRenderingHint = textRenderingHint;

// IGT Display.
e.Graphics.DrawText(0, 0, string.Format("{0}", Program.gameMem.IGTString), Brushes.White, new Font("Consolas", 16, FontStyle.Bold));
Expand Down
36 changes: 25 additions & 11 deletions RE2REmakeSRT/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public static class Program
public static GameMemory gameMem;
public static Bitmap inventoryImage; // The inventory item sheet.
public static Bitmap inventoryError; // An error image.
public const double INV_SLOT_SCALING = 0.75; // Scaling factor for the inventory images.
public const int INV_SLOT_WIDTH = (int)(112 * INV_SLOT_SCALING); // Individual inventory slot width.
public const int INV_SLOT_HEIGHT = (int)(112 * INV_SLOT_SCALING); // Individual inventory slot height.
public static double INV_SLOT_SCALING; // Scaling factor for the inventory images.
public static int INV_SLOT_WIDTH;
public static int INV_SLOT_HEIGHT;

/// <summary>
/// The main entry point for the application.
Expand All @@ -29,38 +29,52 @@ public static void Main(string[] args)
programSpecialOptions = ProgramFlags.None;
foreach (string arg in args)
{
if (string.Equals(arg, "--Help", StringComparison.InvariantCultureIgnoreCase))
if (arg.Equals("--Help", StringComparison.InvariantCultureIgnoreCase))
{
StringBuilder message = new StringBuilder("Command-line arguments:\r\n\r\n");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--Skip-Checksum", "Skip the checksum file validation step.");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--No-Titlebar", "Hide the titlebar and window frame.");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--Always-On-Top", "Always appear on top of other windows.");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--Transparent", "Make the background transparent.");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--ScalingFactor=n", "Set the inventory slot scaling factor on a scale of 0.0 to 1.0. Default: 0.75 (75%)");
message.AppendFormat("{0}\r\n\t{1}\r\n\r\n", "--Debug", "Debug mode.");

MessageBox.Show(null, message.ToString().Trim(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
Environment.Exit(0);
}

if (string.Equals(arg, "--Skip-Checksum", StringComparison.InvariantCultureIgnoreCase))
if (arg.Equals("--Skip-Checksum", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions |= ProgramFlags.SkipChecksumCheck;

if (string.Equals(arg, "--No-Titlebar", StringComparison.InvariantCultureIgnoreCase))
if (arg.Equals("--No-Titlebar", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions |= ProgramFlags.NoTitleBar;

if (string.Equals(arg, "--Always-On-Top", StringComparison.InvariantCultureIgnoreCase))
if (arg.Equals("--Always-On-Top", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions |= ProgramFlags.AlwaysOnTop;

// Assigning here because debug will always be the sum of all of the options being on.
if (string.Equals(arg, "--Debug", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions = ProgramFlags.Debug;
if (arg.Equals("--Transparent", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions |= 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, just set us to the default value.

if (arg.Equals("--Debug", StringComparison.InvariantCultureIgnoreCase))
programSpecialOptions |= 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.

// Standard WinForms stuff.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

// Transform the inventory image in resources down from 32bpp w/ Alpha to 16bpp w/o Alpha. This greatly improve performance especially when coupled with CompositingMode.SourceCopy because no complex alpha blending needs to occur.
inventoryImage = Properties.Resources.ui0100_iam_texout.Clone(new Rectangle(0, 0, Properties.Resources.ui0100_iam_texout.Width, Properties.Resources.ui0100_iam_texout.Height), PixelFormat.Format16bppRgb555);
//inventoryImage = Properties.Resources.ui0100_iam_texout.Clone(new Rectangle(0, 0, Properties.Resources.ui0100_iam_texout.Width, Properties.Resources.ui0100_iam_texout.Height), PixelFormat.Format16bppRgb555);
// Testing perf. with PARGB.
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)
Expand Down
1 change: 1 addition & 0 deletions RE2REmakeSRT/ProgramFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum ProgramFlags : byte
SkipChecksumCheck = 0x01,
NoTitleBar = 0x02,
AlwaysOnTop = 0x04,
Transparent = 0x08,
Debug = SkipChecksumCheck
}
}
4 changes: 2 additions & 2 deletions RE2REmakeSRT/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.3")]
[assembly: AssemblyFileVersion("1.1.4.3")]
[assembly: AssemblyVersion("1.1.5.0")]
[assembly: AssemblyFileVersion("1.1.5.0")]

0 comments on commit f470ae3

Please sign in to comment.