This repository was archived by the owner on Jan 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStatistics.cs
304 lines (277 loc) · 13.9 KB
/
Statistics.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
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;
using System.Threading;
using System.Collections;
using System.Diagnostics.Eventing.Reader;
namespace EEditor
{
public partial class Statistics : Form
{
private Dictionary<int, int> bcount = new Dictionary<int, int>();
private Dictionary<int, Dictionary<uint, int>> bcound = new Dictionary<int, Dictionary<uint, int>>();
private Semaphore wait = new Semaphore(0, 1);
public Statistics()
{
InitializeComponent();
}
private void Statistics_Load(object sender, EventArgs e)
{
panel1.AutoScroll = true;
panel1.BackColor = MainForm.themecolors.accent;
this.BackColor = MainForm.themecolors.background;
this.ForeColor = MainForm.themecolors.foreground;
foreach (Control cntrls in this.Controls)
{
if (cntrls.GetType() == typeof(RadioButton))
{
((RadioButton)cntrls).ForeColor = MainForm.themecolors.foreground;
((RadioButton)cntrls).BackColor = MainForm.themecolors.accent;
}
}
sortby(1);
}
private void sortby(int id)
{
panel1.Controls.Clear();
bcount.Clear();
bcound.Clear();
for (int x = 0; x < MainForm.editArea.CurFrame.Width; x++)
{
for (int y = 0; y < MainForm.editArea.CurFrame.Height; y++)
{
if (id >= 0 && id <= 3)
{
if (bcount.ContainsKey(MainForm.editArea.CurFrame.Foreground[y, x]))
{
bcount[MainForm.editArea.CurFrame.Foreground[y, x]] += 1;
}
if (!bcount.ContainsKey(MainForm.editArea.CurFrame.Foreground[y, x]))
{
bcount.Add(MainForm.editArea.CurFrame.Foreground[y, x], 1);
}
}
if (id == 0 || id == 4)
{
if (bcount.ContainsKey(MainForm.editArea.CurFrame.Background[y, x]) && MainForm.editArea.CurFrame.Background[y, x] != 0)
{
bcount[MainForm.editArea.CurFrame.Background[y, x]] += 1;
}
if (!bcount.ContainsKey(MainForm.editArea.CurFrame.Background[y, x]) && MainForm.editArea.CurFrame.Background[y, x] != 0)
{
bcount.Add(MainForm.editArea.CurFrame.Background[y, x], 1);
}
if (MainForm.editArea.CurFrame.BlockData7[y, x].ToString() != null && MainForm.editArea.CurFrame.Background[y, x] >= 631 && MainForm.editArea.CurFrame.Background[y, x] <= 633)
{
if (bcound.ContainsKey(MainForm.editArea.CurFrame.Background[y, x]))
{
if (bcound[MainForm.editArea.CurFrame.Background[y, x]].ContainsKey(MainForm.editArea.CurFrame.BlockData7[y, x]))
{
bcound[MainForm.editArea.CurFrame.Background[y, x]][MainForm.editArea.CurFrame.BlockData7[y, x]] += 1;
}
else
{
bcound[MainForm.editArea.CurFrame.Background[y, x]].Add(MainForm.editArea.CurFrame.BlockData7[y, x], 1);
}
}
else if (!bcound.ContainsKey(MainForm.editArea.CurFrame.Background[y, x]))
{
bcound.Add(MainForm.editArea.CurFrame.Background[y, x], new Dictionary<uint, int>() { { MainForm.editArea.CurFrame.BlockData7[y, x], 1 } });
}
}
}
}
}
int position = 0, wposition = 4;
foreach (var val in bcount)
{
PictureBox table = new PictureBox();
ToolTip tp = new ToolTip();
tp.SetToolTip(table, val.Key.ToString());
table.Location = new Point(wposition, position + 4);
table.Name = $"Table_ID{val.Key}";
table.Size = new Size(60, 30);
Bitmap bmp = new Bitmap(table.Width, table.Height);
Bitmap block = new Bitmap(16, 16);
if (val.Key < 500 || val.Key >= 1000)
{
if (MainForm.ForegroundBlocks.ContainsKey(val.Key) && (id == 0 || id == 1))
{
block = MainForm.ForegroundBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);
}
if (MainForm.ActionBlocks.ContainsKey(val.Key) && (id == 0 || id == 2))
{
block = MainForm.ActionBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);
}
if (MainForm.DecorationBlocks.ContainsKey(val.Key) && (id == 0 || id == 3))
{
block = MainForm.DecorationBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);
}
}
else
{
if (MainForm.BackgroundBlocks.ContainsKey(val.Key) && val.Key != 0 && (id == 0 || id == 4))
{
block = MainForm.BackgroundBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);
}
else
{
}
}
}
if (bcound.Count > 0 && (id == 0 || id == 4))
{
if (bcound.ContainsKey(631) || bcound.ContainsKey(632) || bcound.ContainsKey(633))
{
foreach (var val in bcound)
{
foreach (var kvp in bcound[val.Key])
{
uint innerKey = kvp.Key;
int value = kvp.Value;
PictureBox table = new PictureBox();
ToolTip tp = new ToolTip();
tp.SetToolTip(table, $"{val.Key}");
table.Location = new Point(wposition, position + 4);
table.Name = $"Table_ID_{val.Key}_{innerKey}";
table.Size = new Size(60, 30);
Bitmap bmp = new Bitmap(table.Width, table.Height);
Bitmap block = new Bitmap(16, 16);
block = MainForm.ColoredBGBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.FillRectangle(new SolidBrush(bdata.UIntToColor(innerKey)), new Rectangle(8, 8, 16, 16));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);
}
}
}
}
//Dictionary<uint, int> dic = bcount[633];
/*PictureBox table = new PictureBox();
ToolTip tp = new ToolTip();
tp.SetToolTip(table, val.Key.ToString());
table.Location = new Point(wposition, position + 4);
table.Name = $"Table_ID{val.Key}";
table.Size = new Size(60, 30);
Bitmap bmp = new Bitmap(table.Width, table.Height);
Bitmap block = new Bitmap(16, 16);
Console.WriteLine(val.Key);
block = MainForm.ColoredBlocks[val.Key];
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(5, 5, 100, 50));
gr.DrawRectangle(new Pen(Color.White), new Rectangle(5, 5, 54, 24));
gr.DrawImage(block, new Point(8, 8));
//gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.Black), new Point(25, 9));
gr.DrawString($"{val.Value}", new Font("Arial", 8, FontStyle.Regular), new SolidBrush(Color.White), new Point(24, 8));
}
table.Image = bmp;
wposition += 60;
if (wposition == 244) //244
{
wposition = 4;
position += 30;
}
panel1.Controls.Add(table);*/
}
private void fgradioButton_CheckedChanged(object sender, EventArgs e)
{
sortby(1);
}
private void actradioButton_CheckedChanged(object sender, EventArgs e)
{
sortby(2);
}
private void decorradioButton_CheckedChanged(object sender, EventArgs e)
{
sortby(3);
}
private void bgradioButton_CheckedChanged(object sender, EventArgs e)
{
sortby(4);
}
}
}