From d32cde1fd48e09c15a319ce89039d9089796dd65 Mon Sep 17 00:00:00 2001 From: robooooo Date: Wed, 26 Feb 2025 09:41:00 +0000 Subject: [PATCH] chargeboots for uya too --- ...r.cs => ChargebootColorPicker.Designer.cs} | 30 ++++--------- ...2Cosmetics.cs => ChargebootColorPicker.cs} | 43 +++++++++++-------- ...metics.resx => ChargebootColorPicker.resx} | 0 RaCTrainer/RAC2/RAC2Form.cs | 13 ++++-- RaCTrainer/RAC3/RAC3Form.Designer.cs | 33 +++++++++----- RaCTrainer/RAC3/RAC3Form.cs | 13 ++++++ RaCTrainer/offsets/RAC3/rac3.cs | 5 +++ RaCTrainer/racman.csproj | 10 ++--- mods/NPEA00387/rainbow-charge/main.lua | 33 ++++++++++++++ mods/NPEA00387/rainbow-charge/patch.txt | 7 +++ 10 files changed, 130 insertions(+), 57 deletions(-) rename RaCTrainer/{RAC2/RAC2Cosmetics.Designer.cs => ChargebootColorPicker.Designer.cs} (92%) rename RaCTrainer/{RAC2/RAC2Cosmetics.cs => ChargebootColorPicker.cs} (80%) rename RaCTrainer/{RAC2/RAC2Cosmetics.resx => ChargebootColorPicker.resx} (100%) create mode 100644 mods/NPEA00387/rainbow-charge/main.lua create mode 100644 mods/NPEA00387/rainbow-charge/patch.txt diff --git a/RaCTrainer/RAC2/RAC2Cosmetics.Designer.cs b/RaCTrainer/ChargebootColorPicker.Designer.cs similarity index 92% rename from RaCTrainer/RAC2/RAC2Cosmetics.Designer.cs rename to RaCTrainer/ChargebootColorPicker.Designer.cs index 605abbf..eb3d09b 100644 --- a/RaCTrainer/RAC2/RAC2Cosmetics.Designer.cs +++ b/RaCTrainer/ChargebootColorPicker.Designer.cs @@ -1,6 +1,6 @@ -namespace racman.RAC2 +namespace racman { - partial class RAC2Cosmetics + partial class ChargebootColorPicker { /// /// Required designer variable. @@ -28,7 +28,6 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); this.colorDialog1 = new System.Windows.Forms.ColorDialog(); this.buttonColor1 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); @@ -52,15 +51,6 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); this.SuspendLayout(); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(70, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Chargeboots "; - // // buttonColor1 // this.buttonColor1.Location = new System.Drawing.Point(12, 51); @@ -75,11 +65,11 @@ private void InitializeComponent() // this.label2.AutoSize = true; this.label2.ForeColor = System.Drawing.Color.Red; - this.label2.Location = new System.Drawing.Point(88, 9); + this.label2.Location = new System.Drawing.Point(12, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(257, 13); + this.label2.Size = new System.Drawing.Size(276, 13); this.label2.TabIndex = 2; - this.label2.Text = "* custom colors only permitted on blmod leaderboards"; + this.label2.Text = "* currently permitted on RAC2 BLMOD leaderboards only"; // // pictureBox1 // @@ -153,6 +143,7 @@ private void InitializeComponent() this.pictureBox3.Size = new System.Drawing.Size(41, 41); this.pictureBox3.TabIndex = 11; this.pictureBox3.TabStop = false; + this.pictureBox3.Click += new System.EventHandler(this.pictureBox3_Click); // // buttonColor3 // @@ -213,11 +204,11 @@ private void InitializeComponent() this.label6.TabIndex = 94; this.label6.Text = "Save Slot"; // - // RAC2Cosmetics + // ChargebootColorPicker // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(364, 245); + this.ClientSize = new System.Drawing.Size(358, 245); this.Controls.Add(this.label6); this.Controls.Add(this.comboBoxSlots); this.Controls.Add(this.buttonLoad); @@ -233,8 +224,7 @@ private void InitializeComponent() this.Controls.Add(this.pictureBox1); this.Controls.Add(this.label2); this.Controls.Add(this.buttonColor1); - this.Controls.Add(this.label1); - this.Name = "RAC2Cosmetics"; + this.Name = "ChargebootColorPicker"; this.Text = "Cosmetics"; this.Load += new System.EventHandler(this.RAC2Cosmetics_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); @@ -246,8 +236,6 @@ private void InitializeComponent() } #endregion - - private System.Windows.Forms.Label label1; private System.Windows.Forms.ColorDialog colorDialog1; private System.Windows.Forms.Button buttonColor1; private System.Windows.Forms.Label label2; diff --git a/RaCTrainer/RAC2/RAC2Cosmetics.cs b/RaCTrainer/ChargebootColorPicker.cs similarity index 80% rename from RaCTrainer/RAC2/RAC2Cosmetics.cs rename to RaCTrainer/ChargebootColorPicker.cs index ed4d73a..e107e83 100644 --- a/RaCTrainer/RAC2/RAC2Cosmetics.cs +++ b/RaCTrainer/ChargebootColorPicker.cs @@ -7,16 +7,25 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using System.Windows.Media; -namespace racman.RAC2 +namespace racman { - public partial class RAC2Cosmetics : Form + public partial class ChargebootColorPicker : Form { - RAC2Form rac2form; - public RAC2Cosmetics(RAC2Form parent) + IPS3API api; + uint primaryFront; + uint primaryBack; + uint tintFront; + uint tintBack; + + public ChargebootColorPicker(IPS3API ps3api, uint pf, uint pb, uint tf, uint tb) { - rac2form = parent; + api = ps3api; + primaryFront = pf; + primaryBack = pb; + tintFront = tf; + tintBack = tb; + InitializeComponent(); } @@ -40,12 +49,11 @@ private void buttonReset_Click(object sender, EventArgs e) { DefaultColors(); - var api = rac2form.game.api; var pid = api.getCurrentPID(); - api.WriteMemory(pid, rac2.addr.chargebootsPrimaryFrontColor, 4, "40FF8020"); - api.WriteMemory(pid, rac2.addr.chargebootsPrimaryBackColor, 4, "00CF6000"); - api.WriteMemory(pid, rac2.addr.chargebootsTintFrontColor, 4, "20FFFF00"); - api.WriteMemory(pid, rac2.addr.chargebootsTintBackColor, 4, "00008000"); + api.WriteMemory(pid, primaryFront, 4, "40FF8020"); + api.WriteMemory(pid, primaryBack, 4, "00CF6000"); + api.WriteMemory(pid, tintFront, 4, "20FFFF00"); + api.WriteMemory(pid, tintBack, 4, "00008000"); } private void buttonColor_Click(object sender, EventArgs e) @@ -92,29 +100,28 @@ private void pictureBox3_Click(object sender, EventArgs e) private void ApplyChanges() { - var api = rac2form.game.api; var pid = api.getCurrentPID(); // FRONT: primary front, tint front - api.WriteMemory(pid, rac2.addr.chargebootsPrimaryFrontColor, new byte[] + api.WriteMemory(pid, primaryFront, new byte[] { 0x40, colorDialog1.Color.B, colorDialog1.Color.G, colorDialog1.Color.R }); - api.WriteMemory(pid, rac2.addr.chargebootsTintFrontColor, new byte[] + api.WriteMemory(pid, tintFront, new byte[] { 0x40, colorDialog1.Color.B, colorDialog1.Color.G, colorDialog1.Color.R }); // MID: tint back - api.WriteMemory(pid, rac2.addr.chargebootsTintBackColor, new byte[] + api.WriteMemory(pid, tintBack, new byte[] { 0x40, colorDialog2.Color.B, colorDialog2.Color.G, colorDialog2.Color.R }); // BACK: primary back - api.WriteMemory(pid, rac2.addr.chargebootsPrimaryBackColor, new byte[] + api.WriteMemory(pid, primaryBack, new byte[] { - 0x30, colorDialog3.Color.B, colorDialog3.Color.G, colorDialog3.Color.R + 0x25, colorDialog3.Color.B, colorDialog3.Color.G, colorDialog3.Color.R }); } @@ -138,6 +145,8 @@ private void buttonLoad_Click(object sender, EventArgs e) pictureBox1.BackColor = colorDialog1.Color; pictureBox2.BackColor = colorDialog2.Color; pictureBox3.BackColor = colorDialog3.Color; + + ApplyChanges(); } } } diff --git a/RaCTrainer/RAC2/RAC2Cosmetics.resx b/RaCTrainer/ChargebootColorPicker.resx similarity index 100% rename from RaCTrainer/RAC2/RAC2Cosmetics.resx rename to RaCTrainer/ChargebootColorPicker.resx diff --git a/RaCTrainer/RAC2/RAC2Form.cs b/RaCTrainer/RAC2/RAC2Form.cs index 268ab9d..f936ce9 100644 --- a/RaCTrainer/RAC2/RAC2Form.cs +++ b/RaCTrainer/RAC2/RAC2Form.cs @@ -1,5 +1,4 @@ -using racman.RAC2; -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -17,7 +16,7 @@ namespace racman public partial class RAC2Form : Form { static ModLoaderForm modLoaderForm; - static RAC2Cosmetics cosmeticsForm; + static ChargebootColorPicker cosmeticsForm; AutosplitterHelper autosplitter; public rac2 game; @@ -590,7 +589,13 @@ private void button3_Click(object sender, EventArgs e) private void buttonCosmetics_Click(object sender, EventArgs e) { - cosmeticsForm = new RAC2Cosmetics(this); + cosmeticsForm = new ChargebootColorPicker( + game.api, + rac2.addr.chargebootsPrimaryFrontColor, + rac2.addr.chargebootsPrimaryBackColor, + rac2.addr.chargebootsTintFrontColor, + rac2.addr.chargebootsTintBackColor + ); cosmeticsForm.Show(); } } diff --git a/RaCTrainer/RAC3/RAC3Form.Designer.cs b/RaCTrainer/RAC3/RAC3Form.Designer.cs index a872cc8..79a4a1b 100644 --- a/RaCTrainer/RAC3/RAC3Form.Designer.cs +++ b/RaCTrainer/RAC3/RAC3Form.Designer.cs @@ -56,6 +56,7 @@ private void InitializeComponent() this.switchGameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.configureButtonCombosToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.flagViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.patchLoaderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.memoryUtilitiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autosplitterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -92,7 +93,7 @@ private void InitializeComponent() this.buttonSetup = new System.Windows.Forms.Button(); this.label14 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); - this.flagViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonCosmetics = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -349,6 +350,13 @@ private void InitializeComponent() this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(209, 6); // + // flagViewerToolStripMenuItem + // + this.flagViewerToolStripMenuItem.Name = "flagViewerToolStripMenuItem"; + this.flagViewerToolStripMenuItem.Size = new System.Drawing.Size(212, 22); + this.flagViewerToolStripMenuItem.Text = "Level flag viewer"; + this.flagViewerToolStripMenuItem.Click += new System.EventHandler(this.flagViewerToolStripMenuItem_Click); + // // patchLoaderToolStripMenuItem // this.patchLoaderToolStripMenuItem.Name = "patchLoaderToolStripMenuItem"; @@ -374,7 +382,7 @@ private void InitializeComponent() // editRouteToolStripMenuItem // this.editRouteToolStripMenuItem.Name = "editRouteToolStripMenuItem"; - this.editRouteToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.editRouteToolStripMenuItem.Size = new System.Drawing.Size(134, 22); this.editRouteToolStripMenuItem.Text = "Edit route..."; this.editRouteToolStripMenuItem.Click += new System.EventHandler(this.editRouteToolStripMenuItem_Click); // @@ -619,7 +627,7 @@ private void InitializeComponent() // coordsLabel // this.coordsLabel.AutoSize = true; - this.coordsLabel.Location = new System.Drawing.Point(13, 424); + this.coordsLabel.Location = new System.Drawing.Point(13, 450); this.coordsLabel.Name = "coordsLabel"; this.coordsLabel.Size = new System.Drawing.Size(123, 13); this.coordsLabel.TabIndex = 101; @@ -675,7 +683,7 @@ private void InitializeComponent() "Ozzy Kamikaze"}); this.shipColourComboBox.Location = new System.Drawing.Point(237, 390); this.shipColourComboBox.Name = "shipColourComboBox"; - this.shipColourComboBox.Size = new System.Drawing.Size(121, 21); + this.shipColourComboBox.Size = new System.Drawing.Size(132, 21); this.shipColourComboBox.TabIndex = 103; this.shipColourComboBox.SelectedIndexChanged += new System.EventHandler(this.shipColourComboBox_SelectedIndexChanged); // @@ -744,12 +752,15 @@ private void InitializeComponent() this.label15.TabIndex = 110; this.label15.Text = "leave. there\'s nothing for you here. unless..."; // - // flagViewerToolStripMenuItem + // buttonCosmetics // - this.flagViewerToolStripMenuItem.Name = "flagViewerToolStripMenuItem"; - this.flagViewerToolStripMenuItem.Size = new System.Drawing.Size(212, 22); - this.flagViewerToolStripMenuItem.Text = "Level flag viewer"; - this.flagViewerToolStripMenuItem.Click += new System.EventHandler(this.flagViewerToolStripMenuItem_Click); + this.buttonCosmetics.Location = new System.Drawing.Point(236, 417); + this.buttonCosmetics.Name = "buttonCosmetics"; + this.buttonCosmetics.Size = new System.Drawing.Size(133, 23); + this.buttonCosmetics.TabIndex = 111; + this.buttonCosmetics.Text = "Cosmetics"; + this.buttonCosmetics.UseVisualStyleBackColor = true; + this.buttonCosmetics.Click += new System.EventHandler(this.buttonCosmetics_Click); // // RAC3Form // @@ -757,7 +768,8 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(385, 424); + this.ClientSize = new System.Drawing.Size(385, 472); + this.Controls.Add(this.buttonCosmetics); this.Controls.Add(this.label15); this.Controls.Add(this.label14); this.Controls.Add(this.buttonSetup); @@ -887,6 +899,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem autosplitterToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editRouteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem flagViewerToolStripMenuItem; + private System.Windows.Forms.Button buttonCosmetics; } } diff --git a/RaCTrainer/RAC3/RAC3Form.cs b/RaCTrainer/RAC3/RAC3Form.cs index cb5ee12..c92b961 100644 --- a/RaCTrainer/RAC3/RAC3Form.cs +++ b/RaCTrainer/RAC3/RAC3Form.cs @@ -56,6 +56,7 @@ private enum Planets int ohkoMemSubID = -1; public rac3 game; + public ChargebootColorPicker cosmeticsForm; private AutosplitterHelper autosplitterHelper; private AutosplitterConfigForm autosplitterConfigForm; @@ -494,5 +495,17 @@ private void flagViewerToolStripMenuItem_Click(object sender, EventArgs e) viewer.Text = $"{planets_comboBox.SelectedItem} level flags"; viewer.Show(); } + + private void buttonCosmetics_Click(object sender, EventArgs e) + { + cosmeticsForm = new ChargebootColorPicker( + game.api, + rac3.addr.chargebootsPrimaryFrontColor, + rac3.addr.chargebootsPrimaryBackColor, + rac3.addr.chargebootsTintFrontColor, + rac3.addr.chargebootsTintBackColor + ); + cosmeticsForm.Show(); + } } } \ No newline at end of file diff --git a/RaCTrainer/offsets/RAC3/rac3.cs b/RaCTrainer/offsets/RAC3/rac3.cs index ec19284..5f80199 100644 --- a/RaCTrainer/offsets/RAC3/rac3.cs +++ b/RaCTrainer/offsets/RAC3/rac3.cs @@ -80,6 +80,11 @@ public class RaC3Addresses : IAddresses public uint miscLevelFlags => throw new System.NotImplementedException(); public uint infobotFlags => throw new System.NotImplementedException(); public uint moviesFlags => throw new System.NotImplementedException(); + + public uint chargebootsTintFrontColor => 0xc33ac0; + public uint chargebootsTintBackColor => 0xc33ac4; + public uint chargebootsPrimaryFrontColor => 0xc33ab0; + public uint chargebootsPrimaryBackColor => 0xc33ab4; } public class rac3 : IGame, IAutosplitterAvailable { diff --git a/RaCTrainer/racman.csproj b/RaCTrainer/racman.csproj index 80226b0..1e82243 100644 --- a/RaCTrainer/racman.csproj +++ b/RaCTrainer/racman.csproj @@ -141,11 +141,11 @@ - + Form - - RAC2Cosmetics.cs + + ChargebootColorPicker.cs Form @@ -289,8 +289,8 @@ MemoryForm.cs - - RAC2Cosmetics.cs + + ChargebootColorPicker.cs RAC2JPForm.cs diff --git a/mods/NPEA00387/rainbow-charge/main.lua b/mods/NPEA00387/rainbow-charge/main.lua new file mode 100644 index 0000000..181c2ee --- /dev/null +++ b/mods/NPEA00387/rainbow-charge/main.lua @@ -0,0 +1,33 @@ +function OnLoad() + hue = 0 + addr1 = 0xc33ac0 + addr2 = 0xc33ab0 +end + +local function abgr_from_hue(alpha, hue) + local r = math.floor((math.sin(hue * math.pi * 2) * 0.5 + 0.5) * 255) + local g = math.floor((math.sin((hue * math.pi * 2) + (math.pi * 2 / 3)) * 0.5 + 0.5) * 255) + local b = math.floor((math.sin((hue * math.pi * 2) + (math.pi * 4 / 3)) * 0.5 + 0.5) * 255) + + -- Convert to ABGR (0xAABBGGRR format) + local a = alpha + local abgr = (a << 24) | (b << 16) | (g << 8) | r + return abgr +end + +function OnTick() + local color = abgr_from_hue(0x40, hue) + local color2 = abgr_from_hue(0x20, hue + 0.2) -- Offset hue for second color + + Ratchetron:WriteMemory(GAME_PID, addr1, color) + Ratchetron:WriteMemory(GAME_PID, addr1 + 4, color2) + Ratchetron:WriteMemory(GAME_PID, addr2, color) + Ratchetron:WriteMemory(GAME_PID, addr2 + 4, color2) + + hue = (hue + 0.01) % 1 -- Cycle hue + +end + +function OnUnload() + +end \ No newline at end of file diff --git a/mods/NPEA00387/rainbow-charge/patch.txt b/mods/NPEA00387/rainbow-charge/patch.txt new file mode 100644 index 0000000..cba2e31 --- /dev/null +++ b/mods/NPEA00387/rainbow-charge/patch.txt @@ -0,0 +1,7 @@ +#- name: Rainbow chargeboots +#- author: bordplate & isak!! +#- href: https://github.com/MichaelRelaxen/racman +#- version: 1.0 +#- description: Makes your chargeboots rainbow <3 + +automation: main.lua \ No newline at end of file