-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstage_select_actor3.lua
2387 lines (2097 loc) · 87.9 KB
/
stage_select_actor3.lua
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
FILE: stage_select_actor3.lua
Reference Code: stage_select_actor3.lc
Author: blujay
Notes: The following code has been decompiled with the assistance of a modified
binary of the DSLuaDecompiler to produce *some* output, while not very meaningful it helps
outline the structure of some functions so that the disassembled lua could be used
as a reference instead of the guiding light
The following code was all written by hand, and was compiled via https://github.com/ultimate-research/smash-lua
and disassembled using https://github.com/jam1garner/smash-luadec
The output disassembly of this file is guaranteed to match exactly that of stage_select_actor3.lc
when unmodified.
]]
--
--[[
this file was created from 6000 lines of disassembly that the DSLuaDecompiler couldn't decompile
i am very tired
]]
--
local did_set_alt = false
-- R0
local ui_common = UiScriptPlayer.require("common/ui_common")
-- R1
local stage_select_bgm = UiScriptPlayer.require2("common/stage_select_bgm3")
-- R2
local layout_root_index = 1
-- R3
local blink_counter = 30
-- this is the default scaling of the stage tiles
-- when they are not currently selected
-- R4
local unselected_button_scale = 1.0
-- this is the scaling of the stage tiles
-- when they are currently selected
-- R5
local selected_button_scale = 1.3
-- this is the number of frames for how long an (un)select animation
-- should take
-- R6
local select_button_frames = 4
-- this appears to be related to the scroll bar on custom stages
-- R7
local scroll_amount_max = 150.0
-- medal states
local MEDAL_STATE_UNINITIALIZED = 0 -- R8
local MEDAL_STATE_ACTIVE = 1 -- R9
local MEDAL_STATE_WAITING = 2 -- R10
local MEDAL_STATE_PLACED = 3 -- R11
local MEDAL_STATE_TERM = 4 -- R12
-- Button IDs for the main buttons (unused)
local BUTTON_ID_BACK = 0 -- R13
local BUTTON_ID_NORMAL = 1 -- R14
local BUTTON_ID_MAKE = 2 -- R15
local MAIN_BUTTON_COUNT = 3 -- R16
-- Buttons IDs for the up/down buttons on the custom stage tab
local BUTTON_ID_SUB_STAGE_UP = 0 -- R17
local BUTTON_ID_SUB_STAGE_DOWN = 1 -- R18
-- Button ids for the stage select previews
local BUTTON_ID_FORM_TYPE = 0 -- R19
local BUTTON_ID_MUSC_SELECT = 1 -- R20
local PREVIEW_BUTTON_COUNT = 2 -- R21
--
local SCENE_STATE_REGULAR = 0 -- R22
local SCENE_STATE_SHOULD_EXIT = 1 -- R23
local SCENE_STATE_EXITING = 2 -- R24
local SCENE_STATE_EXITED = 3 -- R25
exit_code_ = nil
-- The layout root, gotten from the LayoutRootList with the index specified
-- by `layout_root_index`
local layout_root = nil -- R26
-- The root view of the layout root stored in `layout_root`
local root_view = nil -- R27
-- VirtualInput
local virtual_input = nil -- R28
-- LayoutButtonSelector
-- This button selector contains the back button, and the
-- taps for both the main stages and the custom stages
local root_button_selector = nil -- R29
-- LayoutButtonSelector
-- Owns `back_button`, below, which is the virtual back button
local back_button_selector = nil -- R30
-- LayoutButtonSelector
-- Owns the up/down buttons for navigating the custom stage tab
local navigation_button_selector = nil -- R31
-- array of LayoutButtonSelector for stage previews
-- handles selecting things like the music, form, etc.
local preview_button_selectors = {} -- R32
-- Data class that holds the selected/decided buttons selectors
local SelectedButton = { -- R33
new = function()
return {
selected_button_id_ = UI_INVALID_INDEX,
decided_button_id_ = UI_INVALID_INDEX
}
end
}
-- Instance of above class
local root_selected_button = nil -- R34
-- a virtual, invisible back button
-- this button is triggered by a unique layout for only if you are pressing the B
-- button, at which point it will update the root selector's back button
local back_button = nil -- R35
-- selected button of the two buttons in `navigation_button_selector`
local sub_stage_nav_button = nil -- R36
-- selected buttons on each of the previews
local preview_selected_buttons = {} -- R37
local current_selected_preview = -1 -- R38
local highlighed_preview = -1 -- R39
local prev_highlighed_preview = -1 -- R40
local current_selected_panel = -1 -- R41
--[[
Data Type: StagePreview
Description: Holds information about a stage preview on the left side (vanilla) of the SSS layout
Members:
* `enable_`: true if this preview is enabled (there can be multiple previews)
* `panel_id_`: the pane ID of this preview
* `form_type_`: the form (normal, battlefield, or omega) of the preview
* `is_sub_stage_`: if this is a sub stage
* `music_parts_`: the music note icon/name on the preview
* `on_button_form_type_`: if the form info (icon + name) is extended out more than the icon
* `on_button_music_`: if the music info is extended out more than the icon
* `form_type_blink_counter_`: the number of frames that the form info is extended (swich from battlefield -> normal and you'll see what this is)
]]
--
local StagePreview = { -- R42
new = function()
return {
enable_ = false,
panel_id_ = UI_INVALID_INDEX,
selected_alt_ = 0,
form_type_ = 0,
is_sub_stage_ = false,
form_type_parts_ = nil,
music_parts_ = nil,
on_button_form_type_ = false,
on_button_music_ = false,
form_type_blink_counter_ = 0
}
end
}
-- Array of stage previews with length 3 (value of USE_STAGE_MAX)
local stage_previews = {} -- R43
local is_invalid_stage_2 = false -- R44
local prev_invalid_stage_2 = false -- R45
--[[
Data Type: StagePanel
Description: Holds UI/animation information about each stage panel. A stage panel
is one of the icons for selecting a stage
Members:
* `frame_`: the current frame of animation
* `target_scale_`: the end scale of the animation
* `scale_value_`: the amount to scale by (?)
]]
--
local StagePanel = { -- R46
new = function()
return {
frame_ = 0,
target_scale_ = 0.0,
scale_value_ = 0.0
}
end
}
-- Array of stage panels with length STAGE_PANEL_LIST_NUM
local stage_panels = {} -- R47
-- Information regarding the state of picking a custom stage
local stage_sub_selector_info = { -- R48
scroll_value_ = 0.0,
scroll_end_ = false,
is_play_se_ = true,
select_sub_id_ = UI_INVALID_INDEX,
waiting_in_ = false,
}
stage_sub_scroll_button_operatable_ = false
--[[
Data Type: Medal
Description: Holds information about the medals that are used to pick stages. There
are the same number of these as there are stage previews
Members:
* `state_`: the state of the medal
* `put_index_`: the index of the panel which the medal is put on
* `take_animation_`: animation to pickup the medal
* `is_sub_stage_`: if it is on a custom stage
]]
--
local Medal = { -- R49
new = function()
return {
state_ = MEDAL_STATE_WAITING,
put_index_ = UI_INVALID_INDEX,
take_animation_ = nil,
is_sub_stage_ = false
}
end
}
-- An array of Medal classes, with a length of 3 (same length as USE_STAGE_MAX)
local medals = {} -- R50
local tab_index = 0 -- R51
local allow_sub_stage = true -- R52
-- The layout view for the selection tab
local tab_layout = nil -- R53
-- The pane for the text describing which form is currently selected
local tab_form_button_pane = nil -- R54
-- Array of buttons in the root selector
local main_buttons = {} -- R55
local is_canceling = false -- R56
local ignore_cancel_input = false -- R57
local is_hand_interpolated_moving = false -- R58
local should_play_cursor_sound = true -- R59
local is_page_changing = false -- R60
local long_cancel_se = nil -- R61
-- The animation to transition to the next scene, gotten from `root_view`
local next_scene_animation = nil -- R62
local scene_state = SCENE_STATE_REGULAR -- R63
-- Performs interpolation of a value using a sin wave for a more natural curve than just linear
-- CLOSURE_4, R64
local sin_interpolate = function(progress, total)
local angle = 0.0
if progress ~= 0 then
angle = 1.5708 * (progress / total)
end
return math.sin(angle)
end
-- Gets the name of the stage preview part in the layout file
-- CLOSURE_5, R65
local get_stage_preview_name = function(preview_index)
return string.format("set_preview_st_0%d", preview_index)
end
-- Gets the name of the stage icon part in the layout file
-- CLOSURE_6, R66
local get_stage_panel_name = function(stage_index)
return string.format("set_parts_n_stage_%03d", stage_index)
end
-- Gets the name of the medal part in the layout file
-- CLOSURE_7, R67
local get_medal_name = function(medal_index)
return string.format("set_medal_0%d", medal_index)
end
-- Gets the index of the next enabled stage preview
-- CLOSURE_8, R68
local get_next_enabled_preview = function()
for i = 1, USE_STAGE_NUM, 1 do
if stage_previews[i].enable_ == true then
return i - 1
end
end
return UI_INVALID_INDEX
end
-- Gets the index of the last enabled stage preview
-- CLOSURE_9, R69
local get_last_enabled_preview = function()
for i = USE_STAGE_NUM, 1, -1 do
if stage_previews[i].enable_ == true then
return i - 1
end
end
return UI_INVALID_INDEX
end
-- Gets the index of the next disabled stage preview
-- CLOSURE_10, R70
local get_next_disabled_preview = function()
for i = 1, USE_STAGE_NUM, 1 do
if stage_previews[i].enable_ == false then
return i - 1
end
end
return UI_INVALID_INDEX
end
-- Gets the index of the last disabled stage preview
-- CLOSURE_11, R71
local get_last_disabled_preview = function()
for i = USE_STAGE_NUM, 1, -1 do
if stage_previews[i].enable_ == false then
return i - 1
end
end
return UI_INVALID_INDEX
end
-- Checks if all stage previews are enabled or not
-- CLOSURE_12, R72
local check_all_previews_enabled = function()
if get_next_disabled_preview() == UI_INVALID_INDEX then
return true
end
return false
end
-- Checks if all stage previews are disabled or not
-- CLOSURE_13, R73
local check_all_previews_disabled = function()
if get_next_enabled_preview() == UI_INVALID_INDEX then
return true
end
return false
end
-- Gets the next stage from (usually triggered by pressing X)
-- CLOSURE_14, R74
local get_next_stage_form = function(current_form)
current_form = current_form + 1
if STAGE_FORM_TYPE_NUM <= current_form then
current_form = 0
end
return current_form
end
-- Updates the text on the tab at the top of the SSS
-- CLOSURE_15, R75
local set_tab_form_text = function(stage_form)
local form_names = {
"normal",
"battlefield",
"end"
}
tab_layout:play_animation(string.format("stage_%s", form_names[stage_form + 1]), 1.0)
tab_form_button_pane:set_text_message(string.format("mel_stage_select_%s", form_names[stage_form + 1]))
end
-- Plays the looping long-cancel sound effect (when you are holding B to exit)
-- CLOSURE_16, R76
local play_long_cancel_se = function()
if long_cancel_se == nil then
long_cancel_se = UiSoundManager.play_se_loop("se_system_cancel_longpress")
end
end
-- Stops playing the looping long-cancel sound effect if it is playing
-- CLOSURE_17, R77
local stop_long_cancel_se = function()
if long_cancel_se ~= nil then
long_cancel_se:keyoff(0)
long_cancel_se = nil
end
end
-- Shows or hides the scene
-- CLOSURE_18, R78
local set_scene_enable = function(enable)
virtual_input:set_enable(enable)
root_button_selector:set_enable(enable)
root_button_selector:set_focus(enable)
local show_back_button = enable
if IS_SIMPLE_CANCEL == false then
show_back_button = false
end
back_button_selector:set_enable(show_back_button)
back_button_selector:set_focus(show_back_button)
local stage_preview_button = nil
for i = 1, USE_STAGE_NUM, 1 do
stage_preview_button = preview_button_selectors[i]
stage_preview_button:set_enable(enable)
stage_preview_button:set_focus(enable)
end
end
-- Shows or hides the scene/hand
-- CLOSURE_19, R79
local show_scene_and_hand = function(show_scene, enable_hand)
set_scene_enable(show_scene)
local enable_hand = enable_hand
if enable_hand == false and UiScriptPlayer.invoke("get_hand_on_stage_preview_id") ~= UI_INVALID_INDEX then
enable_hand = true
end
if enable_hand == true then
UiScriptPlayer.invoke("set_hand_enable", show_scene)
end
end
-- Gets the specified main button
-- CLOSURE_20, R80
local get_main_button = function(button_id)
return main_buttons[button_id + 1]
end
-- Sets the active state of the specified button
-- CLOSURE_21, R81
local set_main_button_active = function(button_id, active)
root_button_selector:set_selectable(button_id, active)
root_button_selector:set_decidable(button_id, active)
end
-- Enables the specified stage preview
-- CLOSURE_22, R82
local enable_stage_preview = function(preview_index, panel_id, is_sub_stage)
local preview = stage_previews[preview_index + 1]
preview.enable_ = true
preview.panel_id_ = panel_id
preview.is_sub_stage_ = is_sub_stage
end
-- Disables the specified stage preview
-- CLOSURE_23, R83
local disable_stage_preview = function(preview_index)
local preview = stage_previews[preview_index + 1]
preview.enable_ = false
preview.panel_id_ = UI_INVALID_INDEX
preview.is_sub_stage_ = false
end
-- Sets the stage form of the specified preview
-- CLOSURE_24, R84
local set_stage_preview_form = function(preview_index, stage_form)
if preview_index ~= UI_INVALID_INDEX then
if UiScriptPlayer.invoke("is_fixed_form_type_stage_preview", preview_index) == true then
local training_form = UiScriptPlayer.invoke("get_stage_fixed_form_type", preview_index)
UiScriptPlayer.invoke("set_stage_form_type_stage_preview", preview_index, training_form)
if preview_index == current_selected_preview then
set_tab_form_text(training_form)
end
return
end
stage_previews[preview_index + 1].form_type_ = stage_form
UiScriptPlayer.invoke("set_stage_form_type_stage_preview", preview_index, stage_form)
if preview_index == current_selected_preview then
set_tab_form_text(stage_form)
end
end
end
-- Enables/disables the stage form/music buttons for the specified preview
-- CLOSURE_25, R85
local set_stage_preview_buttons_enable = function(preview_index, enable)
-- the BUTTON_FORM_TYPE_0 is the index of the first
-- stage preview's form button, and to get to the next one
-- you add 2, which is why this adds preview_index << 1 (shifting to the left by
-- one is the same as multiplying by 2)
local button_id = BUTTON_FORM_TYPE_0 + (preview_index << 1)
local preview = preview_button_selectors[preview_index + 1]
preview:set_selectable(button_id, enable)
preview:set_decidable(button_id, enable)
-- the music button is at button_id + 1
preview:set_selectable(button_id + 1, enable)
preview:set_decidable(button_id + 1, enable)
end
-- Sets the stage preview based on the selected stage panel
-- CLOSURE_26, R86
local set_stage_preview_from_stage_panel = function(preview_index, panel_index)
if allow_sub_stage == true and panel_index ~= UI_INVALID_INDEX then
set_stage_preview_buttons_enable(preview_index, true)
end
UiScriptPlayer.invoke("set_stage_preview_from_panel", preview_index, panel_index)
set_stage_preview_form(preview_index, stage_previews[preview_index + 1].form_type_)
end
-- Sets the stage preview based on the selected custom stage panel
-- CLOSURE_27, R87
local set_stage_preview_from_sub_stage_panel = function(preview_index, panel_index)
if allow_sub_stage == true and panel_index ~= UI_INVALID_INDEX then
set_stage_preview_buttons_enable(preview_index, false)
end
UiScriptPlayer.invoke("set_stage_preview_from_sub_panel", preview_index, panel_index)
end
-- Plays the stage form switch animation
-- CLOSURE_28, R88
local switch_stage_form = function(preview_index, stage_form)
local anims = {
"anim_type_normal",
"anim_type_battlefield",
"anim_type_end"
}
root_view:play_animation_parts(get_stage_preview_name(preview_index), anims[stage_form + 1])
UiSoundManager.play_se_label("se_system_switch")
end
-- Plays the stage decide animation if we aren't in my music
-- CLOSURE_29, R89
local play_decide_stage_animation = function(preview_index)
if IS_MY_MUSIC == false then
root_view:play_animation_parts(get_stage_preview_name(preview_index), "decide")
end
end
-- Plays the stage undecide animation
-- CLOSURE_30, R90
local play_un_decide_animation = function(preview_index)
root_view:play_animation_parts(get_stage_preview_name(preview_index), "un_decide")
end
-- Plays the selection animation on the stage preview
-- CLOSURE_31, R91
local play_select_animation = function(preview_index)
local name = get_stage_preview_name(preview_index)
root_view:play_animation_parts(name, "select")
root_view:play_animation_parts(name, "on_crs_preview_anime")
end
-- Plays the off_crs animation on the stage preview
-- CLOSURE_32, R92
local play_off_preview_animation = function(preview_index)
root_view:play_animation_parts(get_stage_preview_name(preview_index), "off_crs_preview_anime")
end
-- Plays the unselect animation on the stage preview
-- CLOSURE_33, R93
local play_un_select_animation = function(preview_index)
root_view:play_animation_parts(get_stage_preview_name(preview_index), "un_select")
end
-- Moves to the next stage preview in a multi-select stage preview
-- CLOSURE_34, R94
local advance_stage_preview = function(next_preview, current_preview)
play_un_select_animation(current_preview)
play_off_preview_animation(current_preview)
UiScriptPlayer.invoke("set_enable_shortcut_button_stage_preview", current_preview, false)
play_select_animation(next_preview)
UiScriptPlayer.invoke("set_enable_shortcut_button_stage_preview", next_preview, true)
end
-- Plays the cursor sound
-- CLOSURE_35, R95
local play_cursor_sound = function()
if should_play_cursor_sound == true and is_page_changing == false then
UiSoundManager.play_se(UI_SE_ID_CURSOR)
end
should_play_cursor_sound = true
end
-- Sets up the target scaling for the specified panel
-- CLOSURE_36, R96
local setup_scale_anim = function(panel_id, target_scale)
local x_scale, y_scale = nil
x_scale, y_scale = root_view:get_scale_parts(get_stage_panel_name(panel_id))
local panel = stage_panels[panel_id + 1]
panel.target_scale_ = target_scale
panel.scale_value_ = panel.target_scale_ - x_scale
end
-- Selects the specified panel if it is allowed
-- CLOSURE_37, R97
local select_panel = function(panel_id)
if panel_id ~= UI_INVALID_INDEX then
if UiScriptPlayer.invoke("is_lock_stage_panel", panel_id) == true then
return
end
local panel = root_view:get_button(get_stage_panel_name(panel_id))
panel:select(false, true)
stage_panels[panel_id + 1].frame_ = select_button_frames
setup_scale_anim(panel_id, selected_button_scale)
end
end
-- Unselects the specified panel
-- CLOSURE_38, R98
local unselect_panel = function(panel_id)
if panel_id ~= UI_INVALID_INDEX then
local panel = root_view:get_button(get_stage_panel_name(panel_id))
panel:unselect()
stage_panels[panel_id + 1].frame_ = select_button_frames
setup_scale_anim(panel_id, unselected_button_scale)
end
end
-- Changes the currently selected panel
-- CLOSURE_39, R99
local change_panel = function(new_panel_id)
if current_selected_panel == new_panel_id then
return false
end
unselect_panel(current_selected_panel)
select_panel(new_panel_id)
current_selected_panel = new_panel_id
if current_selected_panel ~= UI_INVALID_INDEX then
play_cursor_sound()
end
return true
end
-- Updates the scaling of the specified panel
-- CLOSURE_40, R100
local update_panel_scaling = function(panel_id)
local name = get_stage_panel_name(panel_id)
local panel = stage_panels[panel_id + 1]
if panel.frame_ <= 0 then
return
end
panel.frame_ = ui_common.sub_time_counter(panel.frame_)
local scale = 1.0
if panel.frame_ <= 0 then
scale = panel.target_scale_
else
local interpolation = sin_interpolate(panel.frame_, select_button_frames)
scale = panel.target_scale_ - panel.scale_value_ * interpolation
end
root_view:set_scale_parts(name, scale, scale)
end
-- Advances the stage preview and then sets up the from
-- CLOSURE_41, R101
local switch_stage_preview = function(preview_id)
if preview_id < 0 then
preview_id = 0
elseif USE_STAGE_NUM <= preview_id then
preview_id = USE_STAGE_NUM - 1
end
if current_selected_preview == preview_id then
return
end
play_un_select_animation(current_selected_preview)
play_off_preview_animation(current_selected_preview)
play_select_animation(preview_id)
UiScriptPlayer.invoke("set_enable_shortcut_button_stage_preview", current_selected_preview, false)
UiScriptPlayer.invoke("set_enable_shortcut_button_stage_preview", preview_id, true)
current_selected_preview = preview_id
local preview = stage_previews[current_selected_preview + 1]
if preview.is_sub_stage_ == false then
if preview.panel_id_ ~= UI_INVALID_INDEX then
should_play_cursor_sound = false
change_panel(preview.panel_id_)
should_play_cursor_sound = true
end
set_stage_preview_form(current_selected_preview, preview.form_type_)
else
set_tab_form_text(preview.form_type_)
end
end
-- Sets the information for the specified medal
-- CLOSURE_42, R102
local set_medal_info = function(medal_id, medal_state, is_sub)
local medal = medals[medal_id + 1]
medal.state_ = medal_state
medal.is_sub_stage_ = is_sub
end
-- Gets the current medal index from the hand
-- CLOSURE_43, R103
local get_current_medal_index = function()
if tab_index == TAB_SWITCH_SUB then
return UiScriptPlayer.invoke("get_hand_on_medal_index_sub_list")
end
return UiScriptPlayer.invoke("get_hand_on_medal_index")
end
-- Checks whether any medal is currently grabbed
-- CLOSURE_44, R104
local any_medal_grabbed = function()
for i = 0, USE_STAGE_NUM - 1, 1 do
if UiScriptPlayer.invoke("is_medal_grabbed", i) == true then
return true
end
end
return false
end
-- Grabs the specified medal
-- CLOSURE_45, R105
local grab_medal = function(medal_id, update_hand)
UiScriptPlayer.invoke("set_medal_grabbed", medal_id, update_hand, false)
if update_hand == true then
set_medal_info(medal_id, MEDAL_STATE_ACTIVE, false)
UiScriptPlayer.invoke("set_hand_grabbed", true)
medals[medal_id + 1].take_animation_:stop_at_end()
end
end
-- Updates the visibility of all medals
-- CLOSURE_46, R106
local update_medal_visibility = function()
if USE_STAGE_NUM < 2 then
return
end
for i = 0, USE_STAGE_NUM - 1, 1 do
if UiScriptPlayer.invoke("is_medal_grabbed", i) == true then
if i ~= current_selected_preview then
UiScriptPlayer.invoke("set_medal_visible", i, false)
set_medal_info(i, MEDAL_STATE_WAITING, false)
end
end
end
end
-- CLOSURE_47, R107
local update_medal = function()
local index = get_current_medal_index()
if index ~= UI_INVALID_INDEX and stage_previews[index + 1].enable_ == true then
if index == current_selected_preview then
if check_all_previews_enabled() == true then
play_select_animation(index)
end
else
switch_stage_preview(index)
end
grab_medal(current_selected_preview, true)
UiScriptPlayer.invoke("cancel_medal_sub_list", current_selected_preview)
disable_stage_preview(current_selected_preview)
play_un_decide_animation(current_selected_preview)
UiScriptPlayer.invoke("move_medal_interpolated_from_hand", current_selected_preview)
return
end
end
-- CLOSURE_48, R108
local un_decide_medal = function()
local medal = medals[current_selected_preview + 1]
if medal.state_ ~= MEDAL_STATE_ACTIVE then
grab_medal(current_selected_preview, true)
UiScriptPlayer.invoke("cancel_medal_sub_list", current_selected_preview)
disable_stage_preview(current_selected_preview)
play_un_decide_animation(current_selected_preview)
UiScriptPlayer.invoke("move_hand_interpolated_from_medal", current_selected_preview)
update_medal_visibility()
end
end
-- Plays either the select or unselect animation
-- CLOSURE_49, R109
local play_tab_animation = function(current_tab, is_select)
local button_name = nil
if current_tab == TAB_SWITCH_SUB then
button_name = "set_parts_btn_make"
else
button_name = "set_parts_btn_normal"
end
if is_select == true then
root_view:play_animation_parts(button_name, "tab_select")
else
root_view:play_animation_parts(button_name, "tab_un_select")
end
end
-- Changes the current page
-- CLOSURE_50, R110
local change_page = function(should_play_page_change)
local tab_anim = "tab_stage_normal"
local part_name = "set_parts_btn_normal"
local normal_select = true
local make_select = false
if tab_index == TAB_SWITCH_SUB then
tab_anim = "tab_stage_make"
part_name = "set_parts_btn_make"
normal_select = false
make_select = true
end
is_page_changing = true
UiScriptPlayer.invoke("set_se_unique_counter", "se_system_cursor", 2)
UiScriptPlayer.invoke("set_hand_medal_range", tab_index)
play_tab_animation(TAB_SWITCH_NORMAL, normal_select)
play_tab_animation(TAB_SWITCH_SUB, make_select)
root_view:play_animation(tab_anim, 1.0)
root_view:bring_to_front_parts(part_name)
-- sets the button as active, does not set it as the active tab
set_main_button_active(BUTTON_TAB_SUB, normal_select)
for i = 0, USE_STAGE_NUM - 1, 1 do
local medal = medals[i + 1]
if medal.state_ == MEDAL_STATE_PLACED then
if medal.is_sub_stage_ == false then
UiScriptPlayer.invoke("set_medal_visible", i, normal_select)
else
UiScriptPlayer.invoke("set_medal_visible", i, make_select)
end
end
end
if DO_NOT_SCROLL_STAGE_SUB_LIST == false then
navigation_button_selector:set_enable(make_select)
navigation_button_selector:set_focus(make_select)
end
if stage_sub_list_selector_ ~= nil then
stage_sub_list_selector_:set_enable(make_select)
stage_sub_list_selector_:set_focus(make_select)
end
if make_select == true then
change_panel(UI_INVALID_INDEX)
if UiScriptPlayer.invoke("get_hand_on_stage_sub_id") == UI_INVALID_INDEX then
stage_sub_selector_info.select_sub_id_ = UI_INVALID_INDEX
stage_sub_list_selector_:select_item(stage_sub_selector_info.select_sub_id_, true)
set_stage_preview_from_sub_stage_panel(current_selected_preview, stage_sub_selector_info.select_sub_id_)
end
end
if check_all_previews_enabled() == false then
local medal_anim = "stage_make"
if normal_select == true then
current_selected_panel = UI_INVALID_INDEX
local form = stage_previews[current_selected_preview + 1].form_type_
if form == STAGE_FORM_TYPE_BATTLE then
medal_anim = "stage_battlefield"
elseif form == STAGE_FORM_TYPE_END then
medal_anim = "stage_end"
else
medal_anim = "stage_normal"
end
else
stage_sub_selector_info.select_sub_id_ = UI_INVALID_INDEX
end
local parts = root_view:get_parts(get_medal_name(current_selected_preview))
parts:play_animation(medal_anim, 1.0)
end
if should_play_page_change == true then
UiSoundManager.play_se_label("se_system_page_change")
end
end
-- Sets up the SSS layout
-- CLOSURE_51, R111
local setup = function()
layout_root = LayoutRootList[layout_root_index]
root_view = layout_root:get_root_view()
virtual_input = layout_root:get_virtual_input()
next_scene_animation = root_view:get_animation("anim_next_scene")
for i = 1, USE_STAGE_MAX, 1 do
stage_previews[i] = StagePreview.new()
medals[i] = Medal.new()
end
for i = 1, STAGE_PANEL_LIST_NUM, 1 do
stage_panels[i] = StagePanel.new()
end
for i = 0, USE_STAGE_NUM - 1, 1 do
local stage_parts = root_view:get_parts(get_stage_preview_name(i))
stage_previews[i + 1].form_type_parts_ = stage_parts:get_parts("set_parts_btn_stage")
stage_previews[i + 1].music_parts_ = stage_parts:get_parts("set_parts_btn_music")
local medal_parts = root_view:get_parts(get_medal_name(i))
medals[i + 1].take_animation_ = medal_parts:get_animation("take")
end
local config = LayoutButtonSelectorConfig.new()
config.selection_type = LAYOUTBUTTONSELECTOR_SELECTION_TYPE_POINTER
config.use_only_pointer_input = true
config.is_unique_se = true
config.cursor_se_label_code = "se_system_cursor"
root_button_selector = LayoutButtonSelector.new()
root_button_selector:setup(root_view, "selector_0", config)
root_selected_button = SelectedButton.new()
back_button_selector = LayoutButtonSelector.new()
back_button_selector:setup(root_view, "selector_2", config)
back_button_selector:setup_button(BUTTON_BACK, "btn_back")
back_button = SelectedButton.new()
navigation_button_selector = LayoutButtonSelector.new()
navigation_button_selector:setup(root_view, "selector_1", config)
navigation_button_selector:setup_button(BUTTON_ID_SUB_STAGE_UP, "set_parts_btn_csr_t")
navigation_button_selector:setup_button(BUTTON_ID_SUB_STAGE_DOWN, "set_parts_btn_csr_b")
sub_stage_nav_button = SelectedButton.new()
local parts, selector = nil
local current_button = BUTTON_FORM_TYPE_0
for i = 0, USE_STAGE_NUM - 1, 1 do
selector = LayoutButtonSelector.new()
parts = root_view:get_parts(get_stage_preview_name(i))
selector:setup(parts, "selector_0", config)
selector:setup_button(current_button, "set_parts_btn_stage")
current_button = current_button + 1
selector:setup_button(current_button, "set_parts_btn_music")
current_button = current_button + 1
preview_button_selectors[i + 1] = selector
preview_selected_buttons[i + 1] = SelectedButton.new()
end
local main_button_names = {
"set_parts_btn_back",
"set_parts_btn_normal",
"set_parts_btn_make",
}
local name = nil
for i = 1, BUTTON_KIND_MAIN_NUM, 1 do
name = main_button_names[i]
root_button_selector:setup_button(i - 1, name)
main_buttons[i] = root_view:get_button(name)
main_buttons[i]:set_decide_on_trigger(true, false)
end
local back_button = root_view:get_parts(main_button_names[BUTTON_BACK + 1])
local text_00 = back_button:get_pane("set_txt_back_00")
local text_01 = back_button:get_pane("set_txt_back_01")
text_00:set_text_message(string.format("mel_over_return_0%d", RETURN_TEXT_ID))
text_01:set_text_message(string.format("mel_return_0%d", RETURN_TEXT_ID))
if IS_INVISIBLE_CANCEL == true then
back_button:set_visible(false)
end
end
-- Initializes the medal position, presumably at the beginning of the SSS load
-- CLOSURE_52, R112
local init_medal = function(medal_id)
UiScriptPlayer.invoke("set_hand_position_from_panel", 0)
UiScriptPlayer.invoke("set_medal_collect_range_from_panel", medal_id, 0)
UiScriptPlayer.invoke("set_medal_position_from_panel", medal_id, 0)
UiScriptPlayer.invoke("set_medal_visible", medal_id, true)
end
-- Sets up the stage select screen from the environment
-- CLOSURE_53, R113
local setup_from_environment = function()
local last_enabled_preview = 0
local current_id, unused_variable = nil -- unused variable to match register usage, not sure why
highlighed_preview = UI_INVALID_INDEX
prev_highlighed_preview = UI_INVALID_INDEX
current_selected_panel = UI_INVALID_INDEX
tab_index = TAB_SWITCH_NORMAL
is_hand_interpolated_moving = false
should_play_cursor_sound = false
tab_layout = root_view:get_parts("set_parts_btn_normal")
tab_form_button_pane = tab_layout:get_pane("set_txt_normal")
set_tab_form_text(STAGE_FORM_TYPE_NORMAL)
for i = 1, USE_STAGE_NUM, 1 do
if IS_SELECT_FROM_FIRST == true and 1 < i then
break