forked from MichaelRelaxen/racman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChargebootColorPicker.cs
152 lines (130 loc) · 5 KB
/
ChargebootColorPicker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace racman
{
public partial class ChargebootColorPicker : Form
{
IPS3API api;
uint primaryFront;
uint primaryBack;
uint tintFront;
uint tintBack;
public ChargebootColorPicker(IPS3API ps3api, uint pf, uint pb, uint tf, uint tb)
{
api = ps3api;
primaryFront = pf;
primaryBack = pb;
tintFront = tf;
tintBack = tb;
InitializeComponent();
}
private void RAC2Cosmetics_Load(object sender, EventArgs e)
{
DefaultColors();
comboBoxSlots.SelectedIndex = 0;
}
private void DefaultColors()
{
colorDialog1.Color = Color.FromArgb(0xFF, 0x20, 0x80, 0xFF);
colorDialog2.Color = Color.FromArgb(0xFF, 0x00, 0x80, 0xFF);
colorDialog3.Color = Color.FromArgb(0xFF, 0x00, 0x60, 0xCF);
pictureBox1.BackColor = colorDialog1.Color;
pictureBox2.BackColor = colorDialog2.Color;
pictureBox3.BackColor = colorDialog3.Color;
}
private void buttonReset_Click(object sender, EventArgs e)
{
DefaultColors();
var pid = api.getCurrentPID();
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)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.BackColor = colorDialog1.Color;
};
ApplyChanges();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
buttonColor_Click(sender, e);
}
private void buttonColor2_Click(object sender, EventArgs e)
{
if (colorDialog2.ShowDialog() == DialogResult.OK)
{
pictureBox2.BackColor = colorDialog2.Color;
}
ApplyChanges();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
buttonColor2_Click(sender, e);
}
private void buttonColor3_Click(object sender, EventArgs e)
{
if (colorDialog3.ShowDialog() == DialogResult.OK)
{
pictureBox3.BackColor = colorDialog3.Color;
}
ApplyChanges();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
buttonColor3_Click(sender, e);
}
private void ApplyChanges()
{
var pid = api.getCurrentPID();
// FRONT: primary front, tint front
api.WriteMemory(pid, primaryFront, new byte[]
{
0x40, colorDialog1.Color.B, colorDialog1.Color.G, colorDialog1.Color.R
});
api.WriteMemory(pid, tintFront, new byte[]
{
0x40, colorDialog1.Color.B, colorDialog1.Color.G, colorDialog1.Color.R
});
// MID: tint back
api.WriteMemory(pid, tintBack, new byte[]
{
0x40, colorDialog2.Color.B, colorDialog2.Color.G, colorDialog2.Color.R
});
// BACK: primary back
api.WriteMemory(pid, primaryBack, new byte[]
{
0x25, colorDialog3.Color.B, colorDialog3.Color.G, colorDialog3.Color.R
});
}
private void buttonSave_Click(object sender, EventArgs e)
{
func.ChangeFileLines("config.txt", colorDialog1.Color.ToArgb().ToString(), "SavedColor1No" + comboBoxSlots.SelectedIndex);
func.ChangeFileLines("config.txt", colorDialog2.Color.ToArgb().ToString(), "SavedColor2No" + comboBoxSlots.SelectedIndex);
func.ChangeFileLines("config.txt", colorDialog3.Color.ToArgb().ToString(), "SavedColor3No" + comboBoxSlots.SelectedIndex);
}
private void buttonLoad_Click(object sender, EventArgs e)
{
var c1 = func.GetConfigData("config.txt", "SavedColor1No" + comboBoxSlots.SelectedIndex);
var c2 = func.GetConfigData("config.txt", "SavedColor2No" + comboBoxSlots.SelectedIndex);
var c3 = func.GetConfigData("config.txt", "SavedColor3No" + comboBoxSlots.SelectedIndex);
colorDialog1.Color = Color.FromArgb(Convert.ToInt32(c1));
colorDialog2.Color = Color.FromArgb(Convert.ToInt32(c2));
colorDialog3.Color = Color.FromArgb(Convert.ToInt32(c3));
pictureBox1.BackColor = colorDialog1.Color;
pictureBox2.BackColor = colorDialog2.Color;
pictureBox3.BackColor = colorDialog3.Color;
ApplyChanges();
}
}
}