diff --git a/IXS Widescreen Utility.sln b/IXS Widescreen Utility.sln new file mode 100644 index 0000000..88fe760 --- /dev/null +++ b/IXS Widescreen Utility.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IXS Widescreen Utility", "IXS Widescreen Utility\IXS Widescreen Utility.csproj", "{97F23403-9E77-4A03-9C10-4EF2E19A9AB5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {97F23403-9E77-4A03-9C10-4EF2E19A9AB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97F23403-9E77-4A03-9C10-4EF2E19A9AB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97F23403-9E77-4A03-9C10-4EF2E19A9AB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97F23403-9E77-4A03-9C10-4EF2E19A9AB5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/IXS Widescreen Utility.v12.suo b/IXS Widescreen Utility.v12.suo new file mode 100644 index 0000000..61305e3 Binary files /dev/null and b/IXS Widescreen Utility.v12.suo differ diff --git a/IXS Widescreen Utility/App.config b/IXS Widescreen Utility/App.config new file mode 100644 index 0000000..fad249e --- /dev/null +++ b/IXS Widescreen Utility/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/IXS Widescreen Utility/Form1.Designer.cs b/IXS Widescreen Utility/Form1.Designer.cs new file mode 100644 index 0000000..37213a3 --- /dev/null +++ b/IXS Widescreen Utility/Form1.Designer.cs @@ -0,0 +1,317 @@ +namespace IXS_Widescreen_Utility +{ + partial class Form1 + { + /// + /// 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.tbFileLocation = new System.Windows.Forms.TextBox(); + this.btnBrowse = new System.Windows.Forms.Button(); + this.tbWidth = new System.Windows.Forms.TextBox(); + this.tbHeight = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.rbDoNothing = new System.Windows.Forms.RadioButton(); + this.tbAspectHeight = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.tbAspectWidth = new System.Windows.Forms.TextBox(); + this.rbCustom = new System.Windows.Forms.RadioButton(); + this.rbAuto = new System.Windows.Forms.RadioButton(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.btnApply = new System.Windows.Forms.Button(); + this.btnAutoFill = new System.Windows.Forms.Button(); + this.gbResolutions = new System.Windows.Forms.GroupBox(); + this.rbRes4 = new System.Windows.Forms.RadioButton(); + this.rbRes3 = new System.Windows.Forms.RadioButton(); + this.rbRes2 = new System.Windows.Forms.RadioButton(); + this.rbRes1 = new System.Windows.Forms.RadioButton(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.gbResolutions.SuspendLayout(); + this.SuspendLayout(); + // + // tbFileLocation + // + this.tbFileLocation.Location = new System.Drawing.Point(12, 12); + this.tbFileLocation.Name = "tbFileLocation"; + this.tbFileLocation.Size = new System.Drawing.Size(484, 20); + this.tbFileLocation.TabIndex = 0; + // + // btnBrowse + // + this.btnBrowse.Location = new System.Drawing.Point(404, 38); + this.btnBrowse.Name = "btnBrowse"; + this.btnBrowse.Size = new System.Drawing.Size(92, 23); + this.btnBrowse.TabIndex = 1; + this.btnBrowse.Text = "Browse..."; + this.btnBrowse.UseVisualStyleBackColor = true; + this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); + // + // tbWidth + // + this.tbWidth.Location = new System.Drawing.Point(49, 13); + this.tbWidth.Name = "tbWidth"; + this.tbWidth.Size = new System.Drawing.Size(45, 20); + this.tbWidth.TabIndex = 0; + // + // tbHeight + // + this.tbHeight.Location = new System.Drawing.Point(49, 41); + this.tbHeight.Name = "tbHeight"; + this.tbHeight.Size = new System.Drawing.Size(45, 20); + this.tbHeight.TabIndex = 1; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.rbDoNothing); + this.groupBox1.Controls.Add(this.tbAspectHeight); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.tbAspectWidth); + this.groupBox1.Controls.Add(this.rbCustom); + this.groupBox1.Controls.Add(this.rbAuto); + this.groupBox1.Location = new System.Drawing.Point(129, 39); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(133, 90); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Aspect Ratio"; + // + // rbDoNothing + // + this.rbDoNothing.AutoSize = true; + this.rbDoNothing.Checked = true; + this.rbDoNothing.Location = new System.Drawing.Point(7, 15); + this.rbDoNothing.Name = "rbDoNothing"; + this.rbDoNothing.Size = new System.Drawing.Size(79, 17); + this.rbDoNothing.TabIndex = 0; + this.rbDoNothing.TabStop = true; + this.rbDoNothing.Text = "Do Nothing"; + this.rbDoNothing.UseVisualStyleBackColor = true; + // + // tbAspectHeight + // + this.tbAspectHeight.Location = new System.Drawing.Point(86, 60); + this.tbAspectHeight.Name = "tbAspectHeight"; + this.tbAspectHeight.Size = new System.Drawing.Size(35, 20); + this.tbAspectHeight.TabIndex = 4; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(70, 63); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(10, 13); + this.label3.TabIndex = 3; + this.label3.Text = ":"; + // + // tbAspectWidth + // + this.tbAspectWidth.Location = new System.Drawing.Point(29, 60); + this.tbAspectWidth.Name = "tbAspectWidth"; + this.tbAspectWidth.Size = new System.Drawing.Size(35, 20); + this.tbAspectWidth.TabIndex = 3; + // + // rbCustom + // + this.rbCustom.AutoSize = true; + this.rbCustom.Location = new System.Drawing.Point(7, 61); + this.rbCustom.Name = "rbCustom"; + this.rbCustom.Size = new System.Drawing.Size(28, 17); + this.rbCustom.TabIndex = 2; + this.rbCustom.Text = " "; + this.rbCustom.UseVisualStyleBackColor = true; + // + // rbAuto + // + this.rbAuto.AutoSize = true; + this.rbAuto.Location = new System.Drawing.Point(7, 38); + this.rbAuto.Name = "rbAuto"; + this.rbAuto.Size = new System.Drawing.Size(47, 17); + this.rbAuto.TabIndex = 1; + this.rbAuto.Text = "Auto"; + this.rbAuto.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Width:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(5, 44); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(41, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Height:"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label1); + this.groupBox2.Controls.Add(this.label2); + this.groupBox2.Controls.Add(this.tbWidth); + this.groupBox2.Controls.Add(this.tbHeight); + this.groupBox2.Location = new System.Drawing.Point(12, 39); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(111, 90); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Custom Resolution"; + // + // btnApply + // + this.btnApply.Location = new System.Drawing.Point(404, 128); + this.btnApply.Name = "btnApply"; + this.btnApply.Size = new System.Drawing.Size(92, 23); + this.btnApply.TabIndex = 3; + this.btnApply.Text = "Apply"; + this.btnApply.UseVisualStyleBackColor = true; + this.btnApply.Click += new System.EventHandler(this.btnApply_Click); + // + // btnAutoFill + // + this.btnAutoFill.Location = new System.Drawing.Point(404, 67); + this.btnAutoFill.Name = "btnAutoFill"; + this.btnAutoFill.Size = new System.Drawing.Size(92, 23); + this.btnAutoFill.TabIndex = 2; + this.btnAutoFill.Text = "Auto Fill"; + this.btnAutoFill.UseVisualStyleBackColor = true; + this.btnAutoFill.Click += new System.EventHandler(this.button1_Click); + // + // gbResolutions + // + this.gbResolutions.Controls.Add(this.rbRes4); + this.gbResolutions.Controls.Add(this.rbRes3); + this.gbResolutions.Controls.Add(this.rbRes2); + this.gbResolutions.Controls.Add(this.rbRes1); + this.gbResolutions.Location = new System.Drawing.Point(268, 40); + this.gbResolutions.Name = "gbResolutions"; + this.gbResolutions.Size = new System.Drawing.Size(130, 111); + this.gbResolutions.TabIndex = 8; + this.gbResolutions.TabStop = false; + this.gbResolutions.Text = "Resolution To Replace"; + // + // rbRes4 + // + this.rbRes4.AutoSize = true; + this.rbRes4.Location = new System.Drawing.Point(6, 88); + this.rbRes4.Name = "rbRes4"; + this.rbRes4.Size = new System.Drawing.Size(78, 17); + this.rbRes4.TabIndex = 3; + this.rbRes4.Text = "1280x1024"; + this.rbRes4.UseVisualStyleBackColor = true; + // + // rbRes3 + // + this.rbRes3.AutoSize = true; + this.rbRes3.Location = new System.Drawing.Point(6, 65); + this.rbRes3.Name = "rbRes3"; + this.rbRes3.Size = new System.Drawing.Size(72, 17); + this.rbRes3.TabIndex = 2; + this.rbRes3.Text = "1024x768"; + this.rbRes3.UseVisualStyleBackColor = true; + // + // rbRes2 + // + this.rbRes2.AutoSize = true; + this.rbRes2.Location = new System.Drawing.Point(6, 42); + this.rbRes2.Name = "rbRes2"; + this.rbRes2.Size = new System.Drawing.Size(66, 17); + this.rbRes2.TabIndex = 1; + this.rbRes2.Text = "800x600"; + this.rbRes2.UseVisualStyleBackColor = true; + // + // rbRes1 + // + this.rbRes1.AutoSize = true; + this.rbRes1.Checked = true; + this.rbRes1.Location = new System.Drawing.Point(6, 19); + this.rbRes1.Name = "rbRes1"; + this.rbRes1.Size = new System.Drawing.Size(66, 17); + this.rbRes1.TabIndex = 0; + this.rbRes1.TabStop = true; + this.rbRes1.Text = "640x480"; + this.rbRes1.UseVisualStyleBackColor = true; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(507, 163); + this.Controls.Add(this.gbResolutions); + this.Controls.Add(this.btnAutoFill); + this.Controls.Add(this.btnApply); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnBrowse); + this.Controls.Add(this.tbFileLocation); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "Form1"; + this.Text = "IXS Widescreen Tool v0.8"; + this.Load += new System.EventHandler(this.Form1_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.gbResolutions.ResumeLayout(false); + this.gbResolutions.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox tbFileLocation; + private System.Windows.Forms.Button btnBrowse; + private System.Windows.Forms.TextBox tbWidth; + private System.Windows.Forms.TextBox tbHeight; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox tbAspectHeight; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox tbAspectWidth; + private System.Windows.Forms.RadioButton rbCustom; + private System.Windows.Forms.RadioButton rbAuto; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button btnApply; + private System.Windows.Forms.Button btnAutoFill; + private System.Windows.Forms.RadioButton rbDoNothing; + private System.Windows.Forms.GroupBox gbResolutions; + private System.Windows.Forms.RadioButton rbRes4; + private System.Windows.Forms.RadioButton rbRes3; + private System.Windows.Forms.RadioButton rbRes2; + private System.Windows.Forms.RadioButton rbRes1; + } +} + diff --git a/IXS Widescreen Utility/Form1.cs b/IXS Widescreen Utility/Form1.cs new file mode 100644 index 0000000..c6e6945 --- /dev/null +++ b/IXS Widescreen Utility/Form1.cs @@ -0,0 +1,434 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace IXS_Widescreen_Utility +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + //Globals + long[] widthOffset = { 0x1A79D4, 0x1A79E0, 0x1A79EC, 0x1A79F8 }; //0x16EE5; + long[] heightOffset = { 0x1A79D8, 0x1A79E4, 0x1A79F0, 0x1A79FC }; //0x16EF3; + long[] stringOffset = { 0x1A7F51, 0x1A7F45, 0x1A7F35, 0x1A7F29, }; + int[] stringLength = { 9, 9, 10, 10 }; + long fovOffset = 0x9F17; + long aspectOffset = 0x9F09; + + private void programStart() + { + //Automatically search for game.exe in common locations + string[] gamePaths = { "Game.exe", + "C:/Program Files (x86)/LEGO Interactive/Island Xtreme Stunts/Game.exe", + "C:/Program Files/LEGO Interactive/Island Xtreme Stunts/Game.exe" }; + + foreach (string path in gamePaths) + { + if (File.Exists(path)) + { + tbFileLocation.Text = Path.GetFullPath(path); + tbFileLocation.Select(0, 0); //Prevents weird automatic highlighting + break; + } + } + } + + + //Auto Fill Button + private void button1_Click(object sender, EventArgs e) + { + //Set aspect ratio to auto + rbAuto.Checked = true; + + //Set custom resolution to screen resolution + Rectangle screen = Screen.PrimaryScreen.Bounds; + + tbWidth.Text = "" + screen.Width; + tbHeight.Text = "" + screen.Height; + } + + + private void btnBrowse_Click(object sender, EventArgs e) + { + //Setup dialog box + OpenFileDialog dialog = new OpenFileDialog(); + + dialog.Filter = "Executable Files (*.exe)|*.exe"; + dialog.FileName = "Game.exe"; + dialog.CheckFileExists = true; + dialog.InitialDirectory = Path.GetDirectoryName(tbFileLocation.Text); + + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + tbFileLocation.Text = Path.GetFullPath(dialog.FileName); + } + } + + + private int getToReplace() + { + if (rbRes1.Checked == true) + { + return 0; + } + else if (rbRes2.Checked == true) + { + return 1; + } + else if (rbRes3.Checked == true) + { + return 2; + } + else if (rbRes4.Checked == true) + { + return 3; + } + + return 0; + } + + + private void btnRemove_Click(object sender, EventArgs e) + { + string finalMessage = ""; + + string exePath = tbFileLocation.Text; + + if (File.Exists(exePath)) + { + byte[] virtualFile = File.ReadAllBytes(exePath); + + //Reset aspect + byte[] aspect = BitConverter.GetBytes(4f / 3f); + + for (int i = 0; i < 4; i++) + { + virtualFile[aspectOffset + i] = aspect[i]; + } + + //Reset fov + byte[] fov = BitConverter.GetBytes(0x200); + + for (int i = 0; i < 2; i++) + { + virtualFile[fovOffset + i] = fov[i]; + } + + //Reset resolutions + int[] widths = { 640, 800, 1024, 1280 }; + int[] heights = { 480, 600, 768, 1024 }; + + for (int i = 0; i < 4; i++) + { + byte[] wBytes = BitConverter.GetBytes(widths[i]); + byte[] hBytes = BitConverter.GetBytes(heights[i]); + + for (int a = 0; a < 4; a++) + { + virtualFile[widthOffset[i] + a] = wBytes[a]; + virtualFile[heightOffset[i] + a] = hBytes[a]; + } + } + + try + { + File.WriteAllBytes(exePath, virtualFile); + finalMessage += "Hacks removed."; + } + catch (UnauthorizedAccessException ex) + { + finalMessage += "Could not remove hacks. Run this program as an administrator"; + } + } + + finalMessage += "\n\nOperation completed."; + MessageBox.Show(finalMessage); + } + + + private void btnApply_Click(object sender, EventArgs e) + { + string exePath = tbFileLocation.Text; + bool doApply = true; + + //If the file name is not Game.exe, warn the user of their own stupidity + string fileName = Path.GetFileName(exePath); + + if (!fileName.Equals("Game.exe")) + { + DialogResult result = MessageBox.Show("Are you certain that you want to patch " + fileName + "?\nYou could ruin the file if it's anything other than Island Xtreme Stunts.", "Unusual File Name", MessageBoxButtons.YesNo); + + if (result == System.Windows.Forms.DialogResult.Yes) { + DialogResult result2 = MessageBox.Show("Are you REALLY sure? This is your final warning.", "Last Warning", MessageBoxButtons.YesNo); + + if (result2 == System.Windows.Forms.DialogResult.No) + { + doApply = false; + } + } + } + + + if (doApply == true) + { + string finalMessage = "Operation Finished.\n"; + + //Check if file exists at all + if (File.Exists(exePath)) + { + byte[] virtualFile = File.ReadAllBytes(exePath); + bool writeVirtualFile = false; + + //Check for bad exe version + byte[] badVersionBytes = { 0x9C, 0xF4, 0x9B, 0xC2 }; + long badVersionOffset = 0x80; + + if (virtualFile[badVersionOffset] == badVersionBytes[0] && + virtualFile[badVersionOffset + 1] == badVersionBytes[1] && + virtualFile[badVersionOffset + 2] == badVersionBytes[2] && + virtualFile[badVersionOffset + 3] == badVersionBytes[3]) + { + finalMessage += "\nUnsupported version detected. Use the patch mentioned in the Readme."; + } + else + { + + //Backup file + { + string backupPath = exePath + ".bak"; + + if (!File.Exists(backupPath)) + { + try + { + File.WriteAllBytes(backupPath, virtualFile); + finalMessage += "\nMade a backup file."; + } + catch (UnauthorizedAccessException ex) + { + finalMessage += "\nBackup file was not made. Run this program as an administrator."; + } + } + } + + //Check if dimentions are valid + bool validResolution = true; + + int width = StringToInt(tbWidth.Text); + int height = StringToInt(tbHeight.Text); + + int toReplace = getToReplace(); + + if (width != 0 && height != 0) + { + byte[] widthBytes = BitConverter.GetBytes(width); + byte[] heightBytes = BitConverter.GetBytes(height); + + for (int i = 0; i < 4; i++) + { + virtualFile[widthOffset[toReplace] + i] = widthBytes[i]; + virtualFile[heightOffset[toReplace] + i] = heightBytes[i]; + } + + //Write new resolution strings + byte[] stringBytes = Encoding.ASCII.GetBytes(createResolutionString(toReplace)); + + for (int i = 0; i < stringLength[toReplace]; i++) + { + virtualFile[stringOffset[toReplace] + i] = stringBytes[i]; + } + + writeVirtualFile = true; + finalMessage += "\nWrote resolution " + width + "x" + height + "."; + } + else + { + validResolution = false; + finalMessage += "\nInvalid resolution input. Ignored."; + } + + //Handle aspect ratio and fov + if (rbDoNothing.Checked == false) + { + float aspect = 4f / 3f; + bool writeFOV = true; + + //Automatic aspect ratio + if (rbAuto.Checked == true) + { + //If valid resolution was entered, use those values + if (validResolution == true) + { + aspect = (float)width / (float)height; + } + //Find resolution in file + else + { + long wo = widthOffset[toReplace]; + long ho = heightOffset[toReplace]; + + byte[] widthBytes = { virtualFile[wo], virtualFile[wo + 1], virtualFile[wo + 2], virtualFile[wo + 3] }; + byte[] heightBytes = { virtualFile[ho], virtualFile[ho + 1], virtualFile[ho + 2], virtualFile[ho + 3] }; + + int foundWidth = BitConverter.ToInt32(widthBytes, 0); + int foundHeight = BitConverter.ToInt32(heightBytes, 0); + + aspect = (float)foundWidth / (float)foundHeight; + } + } + + //Custom fov + else + { + int aspW = StringToInt(tbAspectWidth.Text); + int aspH = StringToInt(tbAspectHeight.Text); + + if (aspW != 0 && aspH != 0) + { + aspect = (float)aspW / (float)aspH; + } + else + { + writeFOV = false; + finalMessage += "\nInvalid aspect ratio input. Ignored."; + } + } + + //Convert data to bytes + byte[] aspectBytes = BitConverter.GetBytes(aspect); + + //Write values + if (writeFOV == true) + { + int fov = (int)(384f * aspect); + + //Verified aspect ratios. Should be replaced with a perfect calculation algorithm + if (aspect == 4 / 3) + { + fov = 512; + } + else if (aspect == 16 / 10) + { + fov = 602; + } + else if (aspect == 16 / 9 || aspect == 1366 / 768) + { + fov = 658; + } + + byte[] fovBytes = BitConverter.GetBytes(fov); + + for (int i = 0; i < 2; i++) + { + virtualFile[fovOffset + i] = fovBytes[i]; + } + + for (int i = 0; i < 4; i++) + { + virtualFile[aspectOffset + i] = aspectBytes[i]; + } + + writeVirtualFile = true; + + finalMessage += "\nWrote aspect ratio " + aspect + "."; + } + } + else + { + finalMessage += "\nIgnored aspect ratio."; + } + + if (writeVirtualFile == true) + { + try + { + File.WriteAllBytes(tbFileLocation.Text, virtualFile); + finalMessage += "\nPatched file successfully."; + } + catch (UnauthorizedAccessException ex) + { + finalMessage += "\n\nError: File was not patched. Run this program as an administrator."; + } + } + else + { + finalMessage += "\n\nNothing needed to be done, so nothing was done."; + } + } + } + else + { + finalMessage += "File not found. Nothing was done."; + } + + MessageBox.Show(finalMessage); + } + } + + + private string createResolutionString(int index) + { + string result = ""; + + result = tbWidth.Text.Trim() + "X" + tbHeight.Text.Trim(); + + //Fill in sides with spaces + int side = 1; + while (result.Length < stringLength[index]) + { + if (side == 1) + { + side = 0; + result = " " + result; + } + else if (side == 0) + { + side = 1; + result = result + " "; + } + } + + return result; + } + + + private void Form1_Load(object sender, EventArgs e) + { + programStart(); + } + + + //Returns 0 if the string is not a number or less than zero + private int StringToInt(String s) + { + if (s == "") + { + s = " "; + } + + if (s.All(char.IsDigit) == true) + { + int result = Int32.Parse(s); + + if (result > 0) + { + return result; + } + } + + return 0; + } + + } +} diff --git a/IXS Widescreen Utility/Form1.resx b/IXS Widescreen Utility/Form1.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/IXS Widescreen Utility/Form1.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/IXS Widescreen Utility/IXS Widescreen Utility.csproj b/IXS Widescreen Utility/IXS Widescreen Utility.csproj new file mode 100644 index 0000000..d031c00 --- /dev/null +++ b/IXS Widescreen Utility/IXS Widescreen Utility.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {97F23403-9E77-4A03-9C10-4EF2E19A9AB5} + WinExe + Properties + IXS_Widescreen_Utility + IXS Widescreen Utility + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/IXS Widescreen Utility/Program.cs b/IXS Widescreen Utility/Program.cs new file mode 100644 index 0000000..d9ab52c --- /dev/null +++ b/IXS Widescreen Utility/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace IXS_Widescreen_Utility +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +}