返回提交历史
Modified
SeaOfRadiationEditor/MainForm.cs
+88
-35
Modified
SeaOfRadiationEditor/MainForm.resx
+3
-0
Modified
SeaOfRadiationEditor/SystemProfile.cs
+3
-3
XFEstudio/SeaOfRadiationEditor
优化代码显示
41590d9
代码差异
3 个文件
+94
-38
@@ -6,20 +6,22 @@ namespace SeaOfRadiationEditor;
6
6
7
7
public partial class MainForm : Form
8
8
{
9
public static MainForm? Current { get; set; }
10
public DynamicMemoryItem resetItem;
11
public DynamicMemoryItem timeCounterItem;
12
public DynamicMemoryItem staminaItem;
13
public DynamicMemoryItem geneItem;
9
public static MainForm? Current { get; private set; }
10
private readonly DynamicMemoryItem _resetItem;
11
private readonly DynamicMemoryItem _healthItem;
12
private readonly DynamicMemoryItem _timeCounterItem;
13
private readonly DynamicMemoryItem _staminaItem;
14
private readonly DynamicMemoryItem _geneItem;
14
15
public MainForm()
15
16
{
16
17
InitializeComponent();
17
18
Current = this;
18
19
Program.Manager.ValueChanged += Manager_ValueChanged;
19
resetItem = Program.Manager["Reset"];
20
timeCounterItem = Program.Manager["TimeCounter"];
21
staminaItem = Program.Manager["Stamina"];
22
geneItem = Program.Manager["Gene"];
20
_resetItem = Program.Manager["Reset"];
21
_healthItem = Program.Manager["Health"];
22
_timeCounterItem = Program.Manager["TimeCounter"];
23
_staminaItem = Program.Manager["Stamina"];
24
_geneItem = Program.Manager["Gene"];
23
25
}
24
26
25
27
private void Manager_ValueChanged(MemoryItem sender, MemoryValue e)
@@ -34,6 +36,13 @@ public partial class MainForm : Form
34
36
Trace.WriteLine($"Resetд��ʧ��");
35
37
}
36
38
break;
39
case "Health":
40
if (e.CurrentValueGetSuccessful && checkBox5.Checked)
41
{
42
if (!sender.Write(int.Parse(textBox5.Text)))
43
Trace.WriteLine("Healthд��ʧ��");
44
}
45
break;
37
46
case "TimeCounter":
38
47
if (e.CurrentValueGetSuccessful && checkBox2.Checked)
39
48
{
@@ -55,15 +64,14 @@ public partial class MainForm : Form
55
64
Trace.WriteLine("Geneд��ʧ��");
56
65
}
57
66
break;
58
default:
59
break;
60
67
}
61
68
}
62
69
63
70
private async void CheckBox1_CheckedChanged(object sender, EventArgs e)
64
71
{
65
if (sender is CheckBox checkBox)
72
try
66
73
{
74
if (sender is not CheckBox checkBox) return;
67
75
if (checkBox.Checked)
68
76
{
69
77
if (CheckGameStart())
@@ -89,12 +97,17 @@ public partial class MainForm : Form
89
97
textBox1.Enabled = true;
90
98
}
91
99
}
100
catch (Exception ex)
101
{
102
Debug.WriteLine(ex.Message);
103
}
92
104
}
93
105
94
106
private async void CheckBox2_CheckedChanged(object sender, EventArgs e)
95
107
{
96
if (sender is CheckBox checkBox)
108
try
97
109
{
110
if (sender is not CheckBox checkBox) return;
98
111
if (checkBox.Checked)
99
112
{
100
113
if (CheckGameStart())
@@ -104,7 +117,7 @@ public partial class MainForm : Form
104
117
textBox2.Enabled = false;
105
118
await Task.Delay(5);
106
119
Program.Manager["TimeCounter"].Write(float.Parse(textBox2.Text));
107
timeCounterItem.Write(float.Parse(textBox2.Text));
120
_timeCounterItem.Write(float.Parse(textBox2.Text));
108
121
}
109
122
catch (Exception ex)
110
123
{
@@ -121,12 +134,17 @@ public partial class MainForm : Form
121
134
textBox2.Enabled = true;
122
135
}
123
136
}
137
catch (Exception ex)
138
{
139
Debug.WriteLine(ex.Message);
140
}
124
141
}
125
142
126
143
private async void CheckBox3_CheckedChanged(object sender, EventArgs e)
127
144
{
128
if (sender is CheckBox checkBox)
145
try
129
146
{
147
if (sender is not CheckBox checkBox) return;
130
148
if (checkBox.Checked)
131
149
{
132
150
if (CheckGameStart())
@@ -136,7 +154,7 @@ public partial class MainForm : Form
136
154
textBox3.Enabled = false;
137
155
await Task.Delay(5);
138
156
Program.Manager["Stamina"].Write(float.Parse(textBox3.Text));
139
staminaItem.Write(float.Parse(textBox3.Text));
157
_staminaItem.Write(float.Parse(textBox3.Text));
140
158
}
141
159
catch (Exception ex)
142
160
{
@@ -153,40 +171,42 @@ public partial class MainForm : Form
153
171
textBox3.Enabled = true;
154
172
}
155
173
}
174
catch (Exception ex)
175
{
176
Debug.WriteLine(ex.Message);
177
}
156
178
}
157
179
158
180
private async void CheckBox4_CheckedChanged(object sender, EventArgs e)
159
181
{
160
182
try
161
183
{
162
if (sender is CheckBox checkBox)
184
if (sender is not CheckBox checkBox) return;
185
if (checkBox.Checked)
163
186
{
164
if (checkBox.Checked)
187
if (CheckGameStart())
165
188
{
166
if (CheckGameStart())
189
try
167
190
{
168
try
169
{
170
textBox4.Enabled = false;
171
await Task.Delay(5);
172
Program.Manager["Gene"].Write(int.Parse(textBox4.Text));
173
geneItem.Write(int.Parse(textBox4.Text));
174
}
175
catch (Exception ex)
176
{
177
Trace.WriteLine(ex.ToString());
178
}
191
textBox4.Enabled = false;
192
await Task.Delay(5);
193
Program.Manager["Gene"].Write(int.Parse(textBox4.Text));
194
_geneItem.Write(int.Parse(textBox4.Text));
179
195
}
180
else
196
catch (Exception ex)
181
197
{
182
checkBox4.Checked = false;
198
Trace.WriteLine(ex.ToString());
183
199
}
184
200
}
185
201
else
186
202
{
187
textBox4.Enabled = true;
203
checkBox4.Checked = false;
188
204
}
189
205
}
206
else
207
{
208
textBox4.Enabled = true;
209
}
190
210
}
191
211
catch (Exception ex)
192
212
{
@@ -194,9 +214,41 @@ public partial class MainForm : Form
194
214
}
195
215
}
196
216
197
private void CheckBox5_CheckedChanged(object sender, EventArgs e)
217
private async void CheckBox5_CheckedChanged(object sender, EventArgs e)
198
218
{
199
219
try
220
{
221
if (sender is not CheckBox checkBox) return;
222
if (checkBox.Checked)
223
{
224
if (CheckGameStart())
225
{
226
try
227
{
228
textBox5.Enabled = false;
229
await Task.Delay(5);
230
Program.Manager["Health"].Write(int.Parse(textBox5.Text));
231
_healthItem.Write(int.Parse(textBox5.Text));
232
}
233
catch (Exception ex)
234
{
235
Trace.WriteLine(ex.ToString());
236
}
237
}
238
else
239
{
240
checkBox5.Checked = false;
241
}
242
}
243
else
244
{
245
textBox5.Enabled = true;
246
}
247
}
248
catch (Exception ex)
249
{
250
Debug.WriteLine(ex.Message);
251
}
200
252
}
201
253
202
254
private static bool CheckGameStart()
@@ -212,5 +264,6 @@ public partial class MainForm : Form
212
264
Current?.Invoke(() => Current.checkBox2.Checked = false);
213
265
Current?.Invoke(() => Current.checkBox3.Checked = false);
214
266
Current?.Invoke(() => Current.checkBox4.Checked = false);
267
Current?.Invoke(() => Current.checkBox5.Checked = false);
215
268
}
216
269
}
@@ -142,4 +142,7 @@
142
142
AAAAAAAAAAAAAA==
143
143
</value>
144
144
</data>
145
<data name="MainForm_CheckGameStart_请启动游戏" xml:space="preserve">
146
<value>请启动游戏</value>
147
</data>
145
148
</root>
@@ -2,14 +2,14 @@
2
2
3
3
public static class SystemProfile
4
4
{
5
private static bool isGameRunning;
5
private static bool _isGameRunning;
6
6
7
7
public static bool IsGameRunning
8
8
{
9
get { return isGameRunning; }
9
get { return _isGameRunning; }
10
10
set
11
11
{
12
isGameRunning = value;
12
_isGameRunning = value;
13
13
if (value)
14
14
{
15
15
try