-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSelector.cs
432 lines (401 loc) · 17.6 KB
/
Selector.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
using System;
using System.Collections.Generic;
using System.Linq;
using Beatmap.Base;
using Selector.UserInterface;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
namespace Selector
{
[Plugin("Selector")]
public class Selector
{
private ArcGridContainer _arcGridContainer;
private ChainGridContainer _chainsGridContainer;
private EventGridContainer _eventGridContainer;
private NoteGridContainer _noteGridContainer;
private ObstacleGridContainer _obstacleGridContainer;
private BPMChangeGridContainer _bpmGridContainer;
private UI _ui;
[Init]
private void Init()
{
SceneManager.sceneLoaded += SceneLoaded;
_ui = new UI(this);
}
private void SceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if (arg0.buildIndex == 3)
{
_noteGridContainer = Object.FindObjectOfType<NoteGridContainer>();
_eventGridContainer = Object.FindObjectOfType<EventGridContainer>();
_obstacleGridContainer = Object.FindObjectOfType<ObstacleGridContainer>();
_arcGridContainer = Object.FindObjectOfType<ArcGridContainer>();
_chainsGridContainer = Object.FindObjectOfType<ChainGridContainer>();
_bpmGridContainer = Object.FindObjectOfType<BPMChangeGridContainer>();
var mapEditorUI = Object.FindObjectOfType<MapEditorUI>();
_ui.AddMenu(mapEditorUI);
}
}
public void Select()
{
var notes = new List<BaseNote>();
var bombs = new List<BaseNote>();
var arcs = new List<BaseArc>();
var chains = new List<BaseChain>();
var events = new List<BaseEvent>();
var obstacles = new List<BaseObstacle>();
GrabAll(ref notes, ref bombs, ref arcs, ref chains, ref events, ref obstacles);
FilterTime(ref notes, ref bombs, ref arcs, ref chains, ref events, ref obstacles);
FilterColor(ref notes, ref arcs, ref chains);
FilterDirection(ref notes, ref arcs, ref chains);
FilterX(ref notes, ref bombs, ref arcs, ref chains, ref obstacles);
FilterY(ref notes, ref bombs, ref arcs, ref chains, ref obstacles);
FilterType(ref events);
FilterValue(ref events);
FilterFloatValue(ref events);
notes.ForEach(n => { SelectionController.Select(n, true, false, false); });
bombs.ForEach(n => { SelectionController.Select(n, true, false, false); });
arcs.ForEach(o => { SelectionController.Select(o, true, false, false); });
chains.ForEach(o => { SelectionController.Select(o, true, false, false); });
events.ForEach(e => { SelectionController.Select(e, true, false, false); });
obstacles.ForEach(o => { SelectionController.Select(o, true, false, false); });
SelectionController.SelectionChangedEvent?.Invoke();
}
public void Deselect()
{
var notes = new List<BaseNote>();
var bombs = new List<BaseNote>();
var arcs = new List<BaseArc>();
var chains = new List<BaseChain>();
var events = new List<BaseEvent>();
var obstacles = new List<BaseObstacle>();
GrabAll(ref notes, ref bombs, ref arcs, ref chains, ref events, ref obstacles);
FilterTime(ref notes, ref bombs, ref arcs, ref chains, ref events, ref obstacles);
FilterColor(ref notes, ref arcs, ref chains);
FilterDirection(ref notes, ref arcs, ref chains);
FilterX(ref notes, ref bombs, ref arcs, ref chains, ref obstacles);
FilterY(ref notes, ref bombs, ref arcs, ref chains, ref obstacles);
FilterType(ref events);
FilterValue(ref events);
FilterFloatValue(ref events);
notes.ForEach(n => { SelectionController.Deselect(n, false); });
bombs.ForEach(n => { SelectionController.Deselect(n, false); });
arcs.ForEach(o => { SelectionController.Deselect(o, false); });
chains.ForEach(o => { SelectionController.Deselect(o, false); });
events.ForEach(e => { SelectionController.Deselect(e, false); });
obstacles.ForEach(o => { SelectionController.Deselect(o, false); });
SelectionController.SelectionChangedEvent?.Invoke();
}
public void SelectAll()
{
var notes = new List<BaseNote>();
var bombs = new List<BaseNote>();
var arcs = new List<BaseArc>();
var chains = new List<BaseChain>();
var events = new List<BaseEvent>();
var obstacles = new List<BaseObstacle>();
GrabAll(ref notes, ref bombs, ref arcs, ref chains, ref events, ref obstacles);
notes.ForEach(n => { SelectionController.Select(n, true, false, false); });
bombs.ForEach(n => { SelectionController.Select(n, true, false, false); });
arcs.ForEach(o => { SelectionController.Select(o, true, false, false); });
chains.ForEach(o => { SelectionController.Select(o, true, false, false); });
events.ForEach(e => { SelectionController.Select(e, true, false, false); });
obstacles.ForEach(o => { SelectionController.Select(o, true, false, false); });
SelectionController.SelectionChangedEvent?.Invoke();
}
public void DeselectAll()
{
SelectionController.DeselectAll();
}
private void GrabAll(ref List<BaseNote> notes, ref List<BaseNote> bombs, ref List<BaseArc> arcs,
ref List<BaseChain> chains, ref List<BaseEvent> events, ref List<BaseObstacle> obstacles)
{
notes = Options.SelectNote
? _noteGridContainer.MapObjects.Where(n => n.Type != 3).ToList()
: new List<BaseNote>();
bombs = Options.SelectBomb
? _noteGridContainer.MapObjects.Where(n => n.Type == 3).Cast<BaseNote>()
.ToList()
: new List<BaseNote>();
arcs = Options.SelectArc ? _arcGridContainer.MapObjects.ToList() : new List<BaseArc>();
chains = Options.SelectChain
? _chainsGridContainer.MapObjects.ToList()
: new List<BaseChain>();
events = Options.SelectEvent
? _eventGridContainer.MapObjects.ToList()
: new List<BaseEvent>();
obstacles = Options.SelectObstacle
? _obstacleGridContainer.MapObjects.ToList()
: new List<BaseObstacle>();
}
private float _adjustTimeStart = 0;
private float _adjustTimeEnd = 0;
private bool ObjectFilterTime(BaseObject obj)
{
return obj.JsonTime >= _adjustTimeStart && obj.JsonTime <= _adjustTimeEnd;
}
private void FilterTime(ref List<BaseNote> notes, ref List<BaseNote> bombs, ref List<BaseArc> arcs,
ref List<BaseChain> chains, ref List<BaseEvent> events, ref List<BaseObstacle> obstacles)
{
if (!Options.TimeSelect) return;
_adjustTimeStart = Options.TimeStart - Options.TimeTolerance;
_adjustTimeEnd = Options.TimeEnd + Options.TimeTolerance;
notes = new List<BaseNote>(notes.Where(ObjectFilterTime));
bombs = new List<BaseNote>(bombs.Where(ObjectFilterTime));
arcs = new List<BaseArc>(arcs.Where(ObjectFilterTime));
chains = new List<BaseChain>(chains.Where(ObjectFilterTime));
events = new List<BaseEvent>(events.Where(ObjectFilterTime));
obstacles = new List<BaseObstacle>(obstacles.Where(ObjectFilterTime));
}
private void FilterColor(ref List<BaseNote> notes, ref List<BaseArc> arcs,
ref List<BaseChain> chains)
{
if (!Options.GridColorSelect) return;
var color = -1;
switch (Options.GridColor)
{
case "Red":
color = 0;
break;
case "Blue":
color = 1;
break;
}
notes = new List<BaseNote>(notes.Where(obj => obj.Color == color));
arcs = new List<BaseArc>(arcs.Where(obj => obj.Color == color));
chains = new List<BaseChain>(chains.Where(obj => obj.Color == color));
}
private void FilterDirection(ref List<BaseNote> notes, ref List<BaseArc> arcs,
ref List<BaseChain> chains)
{
if (!Options.GridDirectionSelect) return;
var direction = -1;
switch (Options.GridDirection)
{
case "Up":
direction = 0;
break;
case "Down":
direction = 1;
break;
case "Left":
direction = 2;
break;
case "Right":
direction = 3;
break;
case "Up-Left":
direction = 4;
break;
case "Up-Right":
direction = 5;
break;
case "Down-Left":
direction = 6;
break;
case "Down-Right":
direction = 7;
break;
case "Any":
direction = 8;
break;
case "Unknown":
direction = 9;
break;
case "ME":
direction = 10;
break;
}
switch (direction)
{
case 9:
notes = new List<BaseNote>(notes.Where(obj => obj.CutDirection < 0 || obj.CutDirection > 8));
arcs = new List<BaseArc>(arcs.Where(obj => obj.CutDirection < 0 || obj.CutDirection > 8));
chains = new List<BaseChain>(chains.Where(obj => obj.CutDirection < 0 || obj.CutDirection > 8));
break;
case 10:
notes = new List<BaseNote>(notes.Where(obj => obj.CutDirection >= 1000 && obj.CutDirection <= 1360));
arcs = new List<BaseArc>(arcs.Where(obj => (obj.CutDirection >= 1000 && obj.CutDirection <= 1360) || (obj.CutDirection >= 2000 && obj.CutDirection <= 2360)));
chains = new List<BaseChain>(chains.Where(obj =>
(obj.CutDirection >= 1000 && obj.CutDirection <= 1360) || (obj.CutDirection >= 2000 && obj.CutDirection <= 2360)));
break;
default:
notes = new List<BaseNote>(notes.Where(obj => obj.CutDirection == direction));
arcs = new List<BaseArc>(arcs.Where(obj => obj.CutDirection == direction));
chains = new List<BaseChain>(chains.Where(obj => obj.CutDirection == direction));
break;
}
}
private bool GridFilterX(BaseGrid obj)
{
return obj.PosX == Options.GridX;
}
private void FilterX(ref List<BaseNote> notes, ref List<BaseNote> bombs, ref List<BaseArc> arcs,
ref List<BaseChain> chains, ref List<BaseObstacle> obstacles)
{
if (!Options.GridXSelect) return;
notes = new List<BaseNote>(notes.Where(GridFilterX));
bombs = new List<BaseNote>(bombs.Where(GridFilterX));
arcs = new List<BaseArc>(arcs.Where(GridFilterX));
chains = new List<BaseChain>(chains.Where(GridFilterX));
obstacles = new List<BaseObstacle>(obstacles.Where(GridFilterX));
}
private bool GridFilterY(BaseGrid obj)
{
return obj.PosY == Options.GridY;
}
private void FilterY(ref List<BaseNote> notes, ref List<BaseNote> bombs, ref List<BaseArc> arcs,
ref List<BaseChain> chains, ref List<BaseObstacle> obstacles)
{
if (!Options.GridYSelect) return;
notes = new List<BaseNote>(notes.Where(GridFilterY));
bombs = new List<BaseNote>(bombs.Where(GridFilterY));
arcs = new List<BaseArc>(arcs.Where(GridFilterY));
chains = new List<BaseChain>(chains.Where(GridFilterY));
obstacles = new List<BaseObstacle>(obstacles.Where(GridFilterY));
}
private void FilterType(ref List<BaseEvent> events)
{
if (!Options.EventTypeSelect) return;
var type = -1;
switch (Options.EventType)
{
case "0 - Back top":
type = 0;
break;
case "1 - Ring":
type = 1;
break;
case "2 - L Laser":
type = 2;
break;
case "3 - R Laser":
type = 3;
break;
case "4 - Center":
type = 4;
break;
case "5 - Boost":
type = 5;
break;
case "6 - XL Light":
type = 6;
break;
case "7 - XR Light":
type = 7;
break;
case "8 - Ring Rot":
type = 8;
break;
case "9 - Ring Zoom":
type = 9;
break;
case "10 - XL Laser":
type = 10;
break;
case "11 - XR Laser":
type = 11;
break;
case "12 - L Rot":
type = 12;
break;
case "13 - R Rot":
type = 13;
break;
case "14 - Early Rot":
type = 14;
break;
case "15 - Late Rot":
type = 15;
break;
case "16 - Utility 0":
type = 16;
break;
case "17 - Utility 1":
type = 17;
break;
case "18 - Utility 2":
type = 18;
break;
case "19 - Utility 3":
type = 19;
break;
case "40 - Special 0":
type = 40;
break;
case "41 - Special 1":
type = 41;
break;
case "42 - Special 2":
type = 42;
break;
case "43 - Special 3":
type = 43;
break;
case "100 - BPM":
type = 100;
break;
case "Custom":
type = Options.EventTypeCustom;
break;
}
events = new List<BaseEvent>(events.Where(obj => obj.Type == type));
}
private void FilterValue(ref List<BaseEvent> events)
{
if (Options.EventValueColorSelect)
{
switch (Options.EventValueColor)
{
case "Blue":
events = new List<BaseEvent>(events.Where(obj => obj.IsBlue));
break;
case "Red":
events = new List<BaseEvent>(events.Where(obj => obj.IsRed));
break;
case "White":
events = new List<BaseEvent>(events.Where(obj => obj.IsWhite));
break;
case "Unknown":
events = new List<BaseEvent>(events.Where(obj => obj.Value < 0 || obj.Value > 12));
break;
case "Custom":
events = new List<BaseEvent>(events.Where(obj => obj.Value == Options.EventValueCustom));
break;
}
}
if (Options.EventValueTypeSelect)
{
switch (Options.EventValueType)
{
case "Off":
events = new List<BaseEvent>(events.Where(obj => obj.IsOff));
break;
case "On":
events = new List<BaseEvent>(events.Where(obj => obj.IsOn));
break;
case "Flash":
events = new List<BaseEvent>(events.Where(obj => obj.IsFlash));
break;
case "Fade":
events = new List<BaseEvent>(events.Where(obj => obj.IsFade));
break;
case "Transition":
events = new List<BaseEvent>(events.Where(obj => obj.IsTransition));
break;
}
}
}
private void FilterFloatValue(ref List<BaseEvent> events)
{
if (!Options.EventFloatValueSelect) return;
events = new List<BaseEvent>(events.Where(obj =>
Math.Abs(obj.FloatValue - Options.EventFloatValue) <= Options.EventFloatValueTolerance));
}
[Exit]
private void Exit()
{
}
}
}