This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
/
PartyEditor2.Script.txt
executable file
·12800 lines (11471 loc) · 481 KB
/
PartyEditor2.Script.txt
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
/**
* Party Editor
*/
#RequireContext CEditorPlugin
#Const Version "2016-03-21"
#Const ScriptName "PartyEditor2.Script.txt"
#Const C_EditorVersion "11.1.1"
#Include "TextLib" as TL
#Include "MathLib" as ML
#Include "MapUnits" as MU
#Include "Libs/Openplanet/UIPadButtons.Script.txt" as Buttons
#Include "Libs/Openplanet/Buttons.Script.txt" as Buttons2
#Include "Libs/Openplanet/SystemText.Script.txt" as SystemText
#Include "Libs/Openplanet/TMConsole/MapEditor/Utils.Script.txt" as Utils
#Include "Libs/Openplanet/TMConsole/MapEditor/Sound.Script.txt" as Sound
#Include "Libs/Openplanet/TMConsole/MapEditor/Music.Script.txt" as Music
#Include "Libs/Openplanet/TMConsole/MapEditor/Random.Script.txt" as Random
#Include "Libs/Openplanet/TMConsole/MapEditor/Macroblock.Script.txt" as Macroblock
#Include "Libs/Openplanet/TMConsole/MapEditor/MapContent.Script.txt" as MapContent
#Include "Libs/Openplanet/TMConsole/MapEditor/Placement.Script.txt" as Placement
#Include "Libs/Openplanet/TMConsole/MapEditor/ThemePack.Script.txt" as ThemePack
#Include "Libs/Openplanet/TMConsole/MapEditor/Layers.Script.txt" as Layers
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Stylesheet.Script.txt" as Styles
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Header.Script.txt" as UI_Header
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/StyleSelection.Script.txt" as UI_StyleSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/BlockHelp.Script.txt" as UI_BlockHelp
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/TerrainPreview.Script.txt" as UI_TerrainPreview
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/MacroblockSelection.Script.txt" as UI_MacroblockSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/SkinSelection.Script.txt" as UI_SkinSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/SpawnSelection.Script.txt" as UI_SpawnSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/DecoSelection.Script.txt" as UI_DecoSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/PopUp.Script.txt" as UI_PopUp
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/SimpleChoice.Script.txt" as UI_SimpleChoice
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Menu.Script.txt" as UI_Menu
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/SimpleMenu.Script.txt" as UI_SimpleMenu
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/RandomMenu.Script.txt" as UI_RandomMenu
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/ShadowMenu.Script.txt" as UI_ShadowMenu
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/MapStyleSelection.Script.txt" as UI_MapStyleSelection
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/MenuOutro.Script.txt" as UI_MenuOutro
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Tuto.Script.txt" as UI_Tuto
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Progression.Script.txt" as UI_Progression
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/Multilaps.Script.txt" as UI_Multilaps
#Include "Libs/Openplanet/TMConsole/MapEditor/UI/MouseControl.Script.txt" as UI_MouseControl
#Include "Libs/Openplanet/TMConsole/MapEditor/CutPaste.Script.txt" as CutPaste
#Include "Libs/Openplanet/TMConsole/MapEditor/Collection.Script.txt" as Collection
#Include "Libs/Openplanet/TMConsole/MapEditor/RandomStyles.Script.txt" as RandomStyles
#Include "Libs/Openplanet/TMConsole/MapEditor/Transitions.Script.txt" as Transitions
#Include "Libs/Openplanet/TMConsole/MapEditor/AutoFinish.Script.txt" as AutoFinish
#Include "Libs/Openplanet/TMConsole/MapEditor/BlockVariant.Script.txt" as BlockVariant
#Include "Libs/Openplanet/TMConsole/MapEditor/History2.Script.txt" as History2
#Include "Libs/Openplanet/TMConsole/MapEditor/Terrain.Script.txt" as Terrain
#Include "Libs/Openplanet/TMConsole/MapEditor/Selection.Script.txt" as Selection
#Include "Libs/Openplanet/TMConsole/MapEditor/WeightedListStack.Script.txt" as List
#Include "Libs/Openplanet/TMConsole/MapEditor/Camera.Script.txt" as Camera
#Include "Libs/Openplanet/TMConsole/MapEditor/MapTypeSynchro.Script.txt" as MapTypeSynchro
#Include "Libs/Openplanet/TMConsole/MapEditor/MapInfo.Script.txt" as MapInfo
#Include "Libs/Openplanet/TMConsole/MapEditor/EditorAchievements.Script.txt" as Achievements
#Include "Libs/Openplanet/TMConsole/UplayActionsSynchro.Script.txt" as UplayActionsSynchro
// ---------------------------------- //
// Settings
// ---------------------------------- //
#Setting S_EditorLevel 0/*/1*/
#Setting S_TrialVersion False/*/True*/
#Setting S_CreateCopy False
#Setting S_ShadowQuality 0/*/2*/
#Setting S_RandomMap_Generate False/*/True*/
#Setting S_RandomMap_Validate False/*/True*/
#Setting S_RandomMap_Config ""/*/"""
<commands>
<!--<seed>2</seed> tunnel -->
<seed>23</seed>
<!--<properties>
<length>1200.</length>
<checkpointsspacing>250.</checkpointsspacing>
</properties>-->
<!--<trackmultipliers>
<multiplier isturning="0">0.5</multiplier>
</trackmultiplier>-->
</commands>"""*/
#Setting S_RandomMap_Seed 0
#Setting S_RandomMap_Length ""
#Setting S_RandomMap_Speed ""
#Setting S_RandomMap_Style ""
// ---------------------------------- //
// Constants
// ---------------------------------- //
#Const C_TerrainPreviewThreshold 1500 ///< Duration before placing a terrain
#Const C_DefaultDecoAmount 0. ///< Default amount of deco of each type
#Const C_DefaultPodiumAmount 0. ///< Default amount of podium
#Const C_MaxRecentMacroblocks 10 ///< Maximum number of recent macroblock
#Const C_AutoFinish_MaxSteps 50 ///< Maxium number of blocks to place when trying to auto-finish the track
#Const C_AutoFinish_MaxIterations 250 ///< Maximum number of iterations during auto finish
#Const C_AutoFinish_PaddingTop 3 ///< Minimum number of blocks between the clip and the top of the map
#Const C_RandomMap_MaxIterations 250 ///< Maximum number of iterations during random map
#Const C_RandomMap_MaxTries 3 ///< Maximum number of tries to generate a random map
#Const C_CameraCoord_Terraforming <1297.7, 89.559, 112.73> ///< Random terraforming camera coordinates
#Const C_CameraRot_Terraforming <317., 13.2> ///< Random terraforming camera rotation
#Const C_CameraZoom_Terraforming ["Canyon" => 1800., "Valley" => 1200., "Stadium" => 1000., "Lagoon" => 1200.] ///< Terraforming camera zoom
#Const C_CameraZoom_Reroll 1000. ///< Reroll camera zoom
#Const C_CameraCoord_Place <127.12, 175.3, -84.15> ///< Random macroblock camera coordinates
#Const C_CameraRot_Place <312., 46.8> ///< Random macroblock camera rotation
#Const C_RandomDecorationDelay 500 ///< Delay between two random decoration macroblock
#Const C_RandomTerrainId "PartyEditor_RandomTerrain" ///< Random terrain id
#Const C_InitialAutoRepeatDelay 250 ///< Initial delay (in ms) before activating the autorepeat
#Const C_MaxAutoRepeatDelay 200 ///< Maximum delay (in ms) between two press of a button to let the autorepeat active
#Const C_AutoRepeatTime 100 ///< Time (in ms) between two activations of an autorepeat
#Const C_CursorVisibility 0. ///< Cursor visibility
#Const C_HideBlockHelpers False ///< Hide block helpers
#Const C_Expert_AutoDir False ///< Automatically direct the macroblock in a valid direction
#Const C_ShowPlacementGrid False ///< Show the placement grid helper
#Const C_RandomLandscape False ///< Use random terraforming in the normal editor
#Const C_RandomMusic True ///< Play music during the random generation
#Const C_FastTerraforming True ///< Yield frequency during random terraforming
#Const C_FastLagoon False ///< Speed up random generation on Lagoon
#Const C_Music True ///< Enable the music
#Const C_CopperLimit_Soft 8000 ///< Warn player that he's reaching the copper limit
#Const C_CopperLimit_Hard 8500 ///< Copper price limit
#Const C_CopperLimit_Deco 7000 ///< Copper limit that start to lessen decoration
#Const C_DecoLimiter 0.5 ///< Limit the decoration amount (1.=>full, 0.5=>medium, 0.=>empty)
#Const C_WarnControllerOnPc True ///< Warn player to connect a controller on PC
#Const C_CheckpointGap 300. ///< Best distance between checkpoints
#Const C_FastShadow CEditorPlugin::ShadowsQuality::Fast ///< Fast shadow computation
#Const C_RemoveAutoSwitchMode False ///< Automatically switch to the mode of the removed block
#Const C_CutPasteBeginner True ///< Allow cut paste in the beginner editor
// Theme packs
#Const C_ThemePack_Beginner "file://Media/Config/TMConsole/MapEditor/BeginnerPack.xml"
#Const C_ThemePack_Advanced "file://Media/Config/TMConsole/MapEditor/ThemePacks.xml"
#Const C_ThemePack_Expert "file://Media/Config/TMConsole/MapEditor/ExpertPacks.xml"
// Editor levels
#Const C_Editor_Beginner 0
#Const C_Editor_Advanced 1
#Const C_Editor_Expert 2
#Const C_Editor_Classic 3
// Shadow quality
#Const C_Shadow_AlwaysAsk 0
#Const C_Shadow_Fast 1
#Const C_Shadow_Nice 2
// Ticks
#Const C_Tick_FilterMacroblock 100
#Const C_Tick_GetFinishCoordBFS 100
#Const C_Tick_GetFinishCoordGBFS 100
#Const C_Tick_RandomDecorate 25
#Const C_Tick_BlockHelper 2500
// Sequences
#Const C_Sequence_MainMenu 0 ///< The player is in the main menu
#Const C_Sequence_PopUp 1 ///< The player is in a pop up
#Const C_Sequence_SelectTerrain 2 ///< The player must select a terrain
#Const C_Sequence_RandomTerrain 3 ///< Random terrain settings
#Const C_Sequence_AutoTerrain 4 ///< Terraforming the map automatically
#Const C_Sequence_PlaceStart 5 ///< The player must place a start block
#Const C_Sequence_ConnectMode 6 ///< The player build the track after the start block in connect mode
#Const C_Sequence_FreeMode 7 ///< Free mode
#Const C_Sequence_TestMode 8 ///< The player select a checkpoint to spawn
#Const C_Sequence_AutoFinish 9 ///< Auto-finishing the track
#Const C_Sequence_EditTerrain 10 ///< Terrain edition : add mode
#Const C_Sequence_AutoDecoration 11 ///< Decorating the map automatically
#Const C_Sequence_EditDecoration 12 ///< Decoration edition : add mode
#Const C_Sequence_RandomMap 13 ///< Full random map generation
#Const C_Sequence_RerollMap 14 ///< Reroll random map
#Const C_Sequence_MapStyle 15 ///< Map style selection
#Const C_Sequence_Simple_Terraforming 16 ///< Simple mode terraforming
#Const C_Sequence_Simple_AutoTerrain 17 ///< Simple mode auto terraform terrain
#Const C_Sequence_Simple_PlaceStart 18 ///< Simple mode place start
#Const C_Sequence_Simple_BuildTrack 19 ///< Simple mode build track
#Const C_Sequence_Simple_MoveCursor 20 ///< Simple mode move cursor
#Const C_Sequence_Simple_Test 21 ///< Simple mode test
#Const C_Sequence_Simple_Deco 22 ///< Simple mode decoration
#Const C_Sequence_Simple_Outro 23 ///< Simple mode outro
#Const C_Sequence_Classic_Build 24 ///< Classic editor build mode
#Const C_Sequence_None -1 ///< No sequence selected
// Simple choice events
#Const C_SimpleChoice_SelectLandscape 0 ///< Select landscape
#Const C_SimpleChoice_StartTrack 1 ///< Start track after selecting a landscape
#Const C_SimpleChoice_DecoGenerate 2 ///< Generate random decoration
#Const C_SimpleChoise_DecoValid 3 ///< Confirm decoration and start validation
#Const C_SimpleChoice_DecoCancel 4 ///< Cancel decoration step and go back to track editing
#Const C_SimpleChoice_DecoDefault 5 ///< Set the amount of each decoration category to their default value
#Const C_SimpleChoice_RandomGenerate 6 ///< Generate a new random map
#Const C_SimpleChoice_RandomSave 7 ///< Save the random map
#Const C_SimpleChoice_RandomPlay 8 ///< Play on the random map
// Category
#Const C_Categories [
//L16N [MapEditor] Edit mode where the player modify the landscape
_("Landscape"),
//L16N [MapEditor] Edit mode where the player modify the track
_("Track")
]
#Const C_Categories_Landscape 0
#Const C_Categories_Construct 1
// Modes
#Const C_Modes [
//L16N [MapEditor] Edit mode where the track is generated randomly
_("Random"),
//L16N [MapEditor] Edit mode where the player select a preconstructed landscape by navigating between pictures of the landscapes
_("Postcards"),
//L16N [MapEditor] Edit mode where the player modify the landscape
_("Landscape"),
//L16N [MapEditor] Edit mode where the player modify the track
_("Track"),
//L16N [MapEditor] Edit mode where the player modify the decoration
_("Decoration")]
#Const C_Modes_LandscapeRandom 0
#Const C_Modes_LandscapePostcards 1
#Const C_Modes_ConstructTerrain 2
#Const C_Modes_ConstructTrack 3
#Const C_Modes_ConstructDeco 4
#Const C_Translations [
//L16N [MapEditor] List of blocks used recently
_("Recents"),
//L16N [MapEditor] List of favorite blocks
_("Favorites")
]
// Auto repeat
#Const C_AutoRepeatDisabled [CEditorPluginEvent::EInput::Unknown, CEditorPluginEvent::EInput::Menu, CEditorPluginEvent::EInput::SwitchToRace, CEditorPluginEvent::EInput::CursorTurn, CEditorPluginEvent::EInput::CursorPick, CEditorPluginEvent::EInput::CursorPlace, CEditorPluginEvent::EInput::RemoveAll, CEditorPluginEvent::EInput::CursorDelete, CEditorPluginEvent::EInput::CameraZoomNext]
#Const C_AutoRepeatEnabled [CEditorPluginEvent::EInput::Undo, CEditorPluginEvent::EInput::Redo, CEditorPluginEvent::EInput::CursorUp, CEditorPluginEvent::EInput::CursorRight, CEditorPluginEvent::EInput::CursorDown, CEditorPluginEvent::EInput::CursorLeft, CEditorPluginEvent::EInput::CursorRaise, CEditorPluginEvent::EInput::CursorLower, CEditorPluginEvent::EInput::CameraUp, CEditorPluginEvent::EInput::CameraRight, CEditorPluginEvent::EInput::CameraDown, CEditorPluginEvent::EInput::CameraLeft, CEditorPluginEvent::EInput::IconUp, CEditorPluginEvent::EInput::IconRight, CEditorPluginEvent::EInput::IconDown, CEditorPluginEvent::EInput::IconLeft]
#Const C_AutoRepeatCursor [CEditorPluginEvent::EInput::IconUp, CEditorPluginEvent::EInput::IconRight, CEditorPluginEvent::EInput::IconDown, CEditorPluginEvent::EInput::IconLeft, CEditorPluginEvent::EInput::CursorUp, CEditorPluginEvent::EInput::CursorRight, CEditorPluginEvent::EInput::CursorDown, CEditorPluginEvent::EInput::CursorLeft]
#Const C_AutoRepeatCamera [CEditorPluginEvent::EInput::CameraUp, CEditorPluginEvent::EInput::CameraRight, CEditorPluginEvent::EInput::CameraDown, CEditorPluginEvent::EInput::CameraLeft]
#Const C_StopGeneration [CEditorPluginEvent::EInput::Menu]
#Const C_Debug False ///< Global debug
#Const C_EnableLog False ///< Global log switch
#Const C_LogToFile False ///< Log to file
#Const C_LogThemePack False ///< Log theme pack debug
#Const C_LogRandom False ///< Log random map generation progress
#Const C_DemoSony False ///< Sony VR demo
// ---------------------------------- //
// Globales
// ---------------------------------- //
declare Integer G_CurrentSequence; ///< The current sequence
declare Integer G_PrevSequence; ///< The previous sequence
declare Boolean G_TestMode; ///< Player is in test mode
declare Integer G_FreeModeVariant; ///< Force a variant in free mode
declare Integer G_PreviewTerrainTime; ///< Time at which the terrain will be previewed
declare Text G_PreviewTerrainId; ///< Name of the terrain to preview
declare Boolean G_GeneratingTerrain; ///< Editor is randomly generating terrain
declare Boolean G_GeneratingDecoration; ///< Editor is randomly generating terrain
declare Boolean G_RandomMapGeneration; ///< Generate a random map
declare Boolean G_AutoFinishing; ///< Editor is trying to auto finish the map
declare Int3 G_CursorCoord; ///< Real cursor coord
declare CEditorPlugin::CardinalDirections G_CursorDir; ///< Real cursor dir
declare CMacroblockModel G_CursorMacroblockModel; ///< Real cursor macroblock model
declare Integer G_CursorConnectedTo; ///< Connection used for the current cursor
declare CMacroblockModel[][Text] G_AvailableMacroblocks; ///< Available macroblocks
declare Text[CMacroblockModel] G_DiscardedMacroblocks; ///< Macroblocks discarded by the filtering
declare Integer[] G_AvailableConnectors;///< Available connectors
declare Ident G_AvailableCheckpoint; ///< Is there a checkpoint available
declare Text[] G_RecentMacroblocks; ///< Recently used macroblocks
declare Integer[CEditorPluginEvent::EInput] G_AutoRepeatInput; ///< Input to auto repeat
declare Integer[CEditorPluginEvent::EInput] G_LastDeviceInput; ///< Last device use to do the input
declare CEditorPluginEvent::EInput[] G_InputBuffer; ///< Buffer the inputs
declare Integer[] G_DeviceBuffer; ///< Device used to generate the inputs
declare Text[][Text][] G_UIInputBuffer; ///< Buffer of UI inputs
declare Boolean G_CancelGeneration; ///< Stop the current auto-finish or random generation process
declare Boolean G_LeaveEditor; ///< Leave the editor
declare Boolean G_RestartGeneration; ///< Restart the random generation process
declare Boolean G_StartingNewMap; ///< True if we're starting a new map after placing the terrain
declare Boolean G_MainMenu; ///< True when in main menu
declare Boolean G_MapStyleSelection; ///< True when in map style selection menu
declare Integer G_Category; ///< Current category
declare Integer G_Mode; ///< Current mode
declare Boolean G_IsSkinning; ///< True when the player edit the skin of an object
declare Boolean G_IsEditing; ///< True when the player edit a macroblock
declare Int3 G_ForcedCursorCoord; ///< Force the cursor coordinates
declare Int3[Integer] G_SavedCursorCoord; ///< Saved cursor coordinates for differents sequences
declare Integer G_LastRandomPlace; ///< Last time a random macroblock was placed
declare Boolean G_AllowLongPress; ///< Allow long press
declare Int3 G_FilteringCoord; ///< Coordinates of the last macroblocks filter
declare Integer G_InactivityStartTime; ///< Time of the last player activity
declare Boolean G_AskForDeco; ///< Ask the player if he wants to decorate his map
declare Boolean G_AskForValidation; ///< Ask the player if he wants to validate his map
declare Integer G_MacroblocksCount; ///< Number of macroblocks available
declare Integer G_Setting_EditorLevel; ///< Editor mode
declare Boolean G_WaitingRerollAnswer; ///< Waiting an answer to know if we reroll or not
declare Boolean G_RerollRandomMap; ///< Reroll random map or not
declare Boolean G_TestedRandomMap; ///< The random map was tested
declare CEditorPlugin::PlaceMode G_PlaceMode; ///< Forced place mode
declare CEditorPlugin::EditMode G_EditMode; ///< Forced edit mode
declare Boolean G_HMD_IsActive; ///< HMD status
declare Boolean G_NeedRebuild; ///< Map must be rebuild to access history
declare Boolean G_MoveCursor; ///< Move cursor in simple mode
declare Boolean G_CanAskCheckpoint; ///< Can ask the player to place a checkpoint
declare Boolean G_TerrainCanPress; ///< Can press button to add terrain
declare CMacroblockModel[] G_RandomMacroblocks; ///< Macroblocks for the random generator
declare Boolean G_RebuildMap; ///< Trackbuilder is rebuilding a map
declare Integer[Ident] G_CacheBlocksSkins; ///< Save the index of the last skin used on a block
declare Integer G_Platform; ///< Current platform used for the buttons
declare Boolean G_StartClassicEditor; ///< Start the classic map editor on PC
// ---------------------------------- //
// Functions
// ---------------------------------- //
Void LogRandomMap(Text _Text) {
if (C_LogRandom) Utils::Log(_Text);
}
// ---------------------------------- //
/** Check if an input is down
*
* @param _Input The input to check
*
* @return True if the input is down, False otherwise
*/
Boolean InputIsDown(CEditorPluginEvent::EInput _Input) {
switch (_Input) {
case CEditorPluginEvent::EInput::Menu : return EditorInputIsDown_Menu;
case CEditorPluginEvent::EInput::SwitchToRace : return EditorInputIsDown_SwitchToRace;
case CEditorPluginEvent::EInput::Undo : return EditorInputIsDown_Undo;
case CEditorPluginEvent::EInput::Redo : return EditorInputIsDown_Redo;
case CEditorPluginEvent::EInput::CursorUp : return EditorInputIsDown_CursorUp;
case CEditorPluginEvent::EInput::CursorRight : return EditorInputIsDown_CursorRight;
case CEditorPluginEvent::EInput::CursorDown : return EditorInputIsDown_CursorDown;
case CEditorPluginEvent::EInput::CursorLeft : return EditorInputIsDown_CursorLeft;
case CEditorPluginEvent::EInput::CursorRaise : return EditorInputIsDown_CursorRaise;
case CEditorPluginEvent::EInput::CursorLower : return EditorInputIsDown_CursorLower;
case CEditorPluginEvent::EInput::CursorTurn : return EditorInputIsDown_CursorTurn;
case CEditorPluginEvent::EInput::CursorPick : return EditorInputIsDown_CursorPick;
case CEditorPluginEvent::EInput::CursorPlace : return EditorInputIsDown_CursorPlace;
case CEditorPluginEvent::EInput::CursorDelete : return EditorInputIsDown_CursorDelete;
case CEditorPluginEvent::EInput::RemoveAll : return EditorInputIsDown_RemoveAll;
case CEditorPluginEvent::EInput::CameraUp : return EditorInputIsDown_CameraUp;
case CEditorPluginEvent::EInput::CameraRight : return EditorInputIsDown_CameraRight;
case CEditorPluginEvent::EInput::CameraDown : return EditorInputIsDown_CameraDown;
case CEditorPluginEvent::EInput::CameraLeft : return EditorInputIsDown_CameraLeft;
case CEditorPluginEvent::EInput::CameraZoomNext : return EditorInputIsDown_CameraZoomNext;
case CEditorPluginEvent::EInput::IconUp : return EditorInputIsDown_IconUp;
case CEditorPluginEvent::EInput::IconRight : return EditorInputIsDown_IconRight;
case CEditorPluginEvent::EInput::IconDown : return EditorInputIsDown_IconDown;
case CEditorPluginEvent::EInput::IconLeft : return EditorInputIsDown_IconLeft;
}
return False;
}
// ---------------------------------- //
/// Clear the input buffers
Void ClearInputBuffer() {
G_InputBuffer.clear();
G_DeviceBuffer.clear();
G_UIInputBuffer.clear();
}
// ---------------------------------- //
/** Update the input buffer
*
* @param _Input The input to add
* @param _IsPad Input generated by a pad
* @param _IsKeyboard Input generated by a keyboard
* @param _IsMouse Input generated by a mouse
*/
Void UpdateInputBuffer(CEditorPluginEvent::EInput _Input, Boolean _IsPad, Boolean _IsKeyboard, Boolean _IsMouse) {
// Ignore mouse input
if (_IsMouse) return;
if (G_InputBuffer.exists(_Input)) return;
if (UI_MacroblockSelection::IsSelecting() || C_AutoRepeatDisabled.exists(_Input)) {
G_InputBuffer.add(_Input);
G_DeviceBuffer.add(Buttons2::GetInputDevice(_IsPad, _IsKeyboard, _IsMouse));
} else {
if (!G_AutoRepeatInput.existskey(_Input)) G_AutoRepeatInput[_Input] = 0;
if (Now > G_AutoRepeatInput[_Input]) {
declare TimeSinceLastTrigger = Now - G_AutoRepeatInput[_Input];
if (C_AutoRepeatCursor.exists(_Input)) {
foreach (Input in C_AutoRepeatCursor) {
if (!G_AutoRepeatInput.existskey(Input)) continue;
if (Now - G_AutoRepeatInput[Input] < TimeSinceLastTrigger) {
TimeSinceLastTrigger = Now - G_AutoRepeatInput[Input];
}
}
} else if (C_AutoRepeatCamera.exists(_Input)) {
foreach (Input in C_AutoRepeatCamera) {
if (!G_AutoRepeatInput.existskey(Input)) continue;
if (Now - G_AutoRepeatInput[Input] < TimeSinceLastTrigger) {
TimeSinceLastTrigger = Now - G_AutoRepeatInput[Input];
}
}
}
declare NextTriggerTime = Now + C_InitialAutoRepeatDelay;
if (TimeSinceLastTrigger <= C_MaxAutoRepeatDelay) {
NextTriggerTime = Now + C_AutoRepeatTime;
}
G_AutoRepeatInput[_Input] = NextTriggerTime;
G_InputBuffer.add(_Input);
G_DeviceBuffer.add(Buttons2::GetInputDevice(_IsPad, _IsKeyboard, _IsMouse));
}
}
}
// ---------------------------------- //
/** Update the input buffer
*
* @param _Input The input to add
*/
Void UpdateInputBuffer(CEditorPluginEvent::EInput _Input) {
declare IsPad = False;
declare IsKeyboard = False;
declare IsMouse = False;
if (G_LastDeviceInput.existskey(_Input)) {
declare Device = G_LastDeviceInput[_Input];
IsPad = (Device == Buttons2::Device_Pad());
IsKeyboard = (Device == Buttons2::Device_Keyboard());
IsMouse = (Device == Buttons2::Device_Mouse());
}
UpdateInputBuffer(_Input, IsPad, IsKeyboard, IsMouse);
}
// ---------------------------------- //
/** Update the UI input buffer
*
* @param _Type The event type
* @param _Data The data
*/
Void UpdateUIInputBuffer(Text _Type, Text[] _Data) {
G_UIInputBuffer.add([_Type => _Data]);
}
// ---------------------------------- //
/** Get the name of the map
*
* @return The name of the map
*/
Text GetMapName() {
declare metadata Text PartyEditor_MapName for Map;
return PartyEditor_MapName;
}
// ---------------------------------- //
/** Check if we are in a given editor mode
*
* @param _Level The level to check
*
* @return True if we are in the given editor mode, False otherwise
*/
Boolean IsEditor(Integer _Level) {
if (S_RandomMap_Generate && _Level == C_Editor_Expert) return True; ///< Random editor is expert editor
return (G_Setting_EditorLevel == _Level && !S_RandomMap_Generate);
}
// ---------------------------------- //
/** Check if we the user is allowed to cut and paste
*
* @return True if the user can cut and paste, False otherwise
*/
Boolean CutPasteIsAllowed() {
return (
!G_RandomMapGeneration && (
IsEditor(C_Editor_Advanced) || (IsEditor(C_Editor_Beginner) && C_CutPasteBeginner)
)
);
}
// ---------------------------------- //
/// Check that a pad is connected
Void CheckPadConnection() {
if (!IsEditorReadyForRequest || UI_PopUp::IsInLoading() || HoldLoadingScreen) return;
if (
(
SystemPlatform == CManiaApp::ESystemPlatform::PS4 ||
SystemPlatform == CManiaApp::ESystemPlatform::XBoxOne ||
C_WarnControllerOnPc
) &&
UserMgr != Null &&
UserMgr.MainUserPad == Null
) {
//L16N [MapEditor] Text of the pop-up displayed when all controllers are disconnected. The %1 will be replaced by the name of the controller, eg: Dualshock 4 (r) wireless controller or XB1 wireless controller.
//declare PleaseConnectPadText = TL::Compose(_("Please reconnect the %1"), Buttons::GetPadName());
UI_PopUp::PadDisconnected(True);
declare SimpleMenuVisible = UI_SimpleMenu::IsVisible();
declare MenuVisible = UI_Menu::IsVisible();
if (SimpleMenuVisible) UI_SimpleMenu::Hide();
if (MenuVisible) UI_Menu::Hide();
Sound::Play("EditorPopUp");
// Wait the reconnection of the controller + a press on the Cross or A button
while ((UserMgr != Null && UserMgr.MainUserPad == Null)) {
yield;
}
if (SimpleMenuVisible) UI_SimpleMenu::Show();
if (MenuVisible) UI_Menu::Show();
UI_PopUp::PadDisconnected(False);
// Clear input buffer
ClearInputBuffer();
G_TerrainCanPress = False;
}
}
// ---------------------------------- //
/// Display random generator menu
Void RandomMenu() {
declare Wait = True;
declare Answer = UI_RandomMenu::Selection_Null();
if (G_CurrentSequence == C_Sequence_RandomMap) {
UI_RandomMenu::SetOptions([UI_RandomMenu::Selection_Restart(), UI_RandomMenu::Selection_Quit(), UI_RandomMenu::Selection_Back()]);
} else {
if (S_RandomMap_Validate) {
UI_RandomMenu::SetOptions([UI_RandomMenu::Selection_Quit(), UI_RandomMenu::Selection_Back()]);
} else {
UI_RandomMenu::SetOptions([UI_RandomMenu::Selection_Quit(), UI_RandomMenu::Selection_Back()]);
}
}
UI_RandomMenu::Show();
Sound::Play("EditorPopUp");
while (Wait) {
yield; ///< Yield before events to remove first menu button press
foreach (Event in PendingEvents) {
if (Event.Type == CEditorPluginEvent::Type::EditorInput) {
switch (Event.Input) {
case CEditorPluginEvent::EInput::Menu : {
Sound::Play("EditorMenuCancel");
Wait = False;
}
case CEditorPluginEvent::EInput::CursorPlace : {
Answer = UI_RandomMenu::Valid();
Wait = False;
}
case CEditorPluginEvent::EInput::RemoveAll : {
if (Event.IsFromKeyboard) {
Sound::Play("EditorMenuCancel");
Wait = False;
}
}
case CEditorPluginEvent::EInput::CursorDelete : {
if (Event.IsFromPad) {
Sound::Play("EditorMenuCancel");
Wait = False;
}
}
case CEditorPluginEvent::EInput::CursorUp : UI_RandomMenu::Prev();
case CEditorPluginEvent::EInput::CursorDown : UI_RandomMenu::Next();
case CEditorPluginEvent::EInput::IconUp : UI_RandomMenu::Prev();
case CEditorPluginEvent::EInput::IconDown : UI_RandomMenu::Next();
}
} else if (Event.Type == CEditorPluginEvent::Type::LayerCustomEvent) {
switch (Event.CustomEventType) {
case UI_RandomMenu::Event_Hover(): UI_RandomMenu::Select(TL::ToInteger(Event.CustomEventData[0]), True);
case UI_RandomMenu::Event_Click(): {
UI_RandomMenu::Select(TL::ToInteger(Event.CustomEventData[0]));
Answer = UI_RandomMenu::Valid();
Wait = False;
}
}
}
}
// Check after the events, to avoid validating in the menu when closing the pad pop-up
CheckPadConnection();
}
switch (Answer) {
case UI_RandomMenu::Selection_Restart(): {
G_CancelGeneration = True;
G_RestartGeneration = True;
}
case UI_RandomMenu::Selection_Quit(): {
G_CancelGeneration = True;
G_LeaveEditor = True;
}
}
UI_RandomMenu::Hide();
// Clear input buffer
ClearInputBuffer();
G_TerrainCanPress = False;
}
// ---------------------------------- //
/// Check if we can display a tutorial to the player
Void CheckTuto() {
if (G_RebuildMap) return; //< No tutorial during map rebuild
if (G_CurrentSequence == C_Sequence_Simple_BuildTrack) {
declare StartDistance = MapContent::GetDistanceTo(MapContent::Block_Start());
declare LastCheckpointDistance = MapContent::GetDistanceTo(MapContent::Block_Checkpoint());
declare LastStopEngineDistance = MapContent::GetDistanceTo(MapContent::Block_StopEngine());
// Checkpoint tuto
if (IsEditor(C_Editor_Beginner)) {
if (StartDistance > 1500. && StartDistance < 2000.) {
UI_Tuto::Enable(UI_Tuto::Tuto_Finish());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Finish());
}
if (G_AvailableCheckpoint != NullId && LastCheckpointDistance > C_CheckpointGap) {
UI_Tuto::Enable(UI_Tuto::Tuto_Checkpoint());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Checkpoint());
}
}
// Switch tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_Switch())) {
if (UI_Tuto::Count(UI_Tuto::Tuto_Switch()) >= 1) {
UI_Tuto::Validate(UI_Tuto::Tuto_Switch());
} else if (G_AvailableConnectors.count > 1) {
UI_Tuto::Enable(UI_Tuto::Tuto_Switch());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Switch());
}
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Switch());
}
// Test tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_Test()) && MapContent::HasCheckpoint()) {
UI_Tuto::Enable(UI_Tuto::Tuto_Test());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Test());
}
// Stop engine tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_StopEngine()) && LastStopEngineDistance < LastCheckpointDistance) {
UI_Tuto::Enable(UI_Tuto::Tuto_StopEngine());
} else if (UI_Tuto::IsEnabled(UI_Tuto::Tuto_StopEngine()) && LastStopEngineDistance >= LastCheckpointDistance) {
UI_Tuto::Validate(UI_Tuto::Tuto_StopEngine());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_StopEngine());
}
} else if (G_CurrentSequence == C_Sequence_Simple_MoveCursor) {
// Connection modes tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_ConnectMode())) {
UI_Tuto::Enable(UI_Tuto::Tuto_ConnectMode());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_ConnectMode());
}
} else if (
G_CurrentSequence == C_Sequence_FreeMode ||
G_CurrentSequence == C_Sequence_PlaceStart ||
G_CurrentSequence == C_Sequence_EditDecoration
) {
// Move tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_MoveBlock()) && !G_IsEditing && !G_IsSkinning) {
UI_Tuto::Enable(UI_Tuto::Tuto_MoveBlock());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_MoveBlock());
}
// Move tuto PC
if (G_Platform == Buttons2::System_PC() && !UI_Tuto::IsValidated(UI_Tuto::Tuto_MoveBlock_Mouse())) {
UI_Tuto::Enable(UI_Tuto::Tuto_MoveBlock_Mouse());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_MoveBlock_Mouse());
}
// Place tuto PC
if (G_Platform == Buttons2::System_PC() && !UI_Tuto::IsValidated(UI_Tuto::Tuto_PlaceBlock_Mouse())) {
UI_Tuto::Enable(UI_Tuto::Tuto_PlaceBlock_Mouse());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_PlaceBlock_Mouse());
}
if (G_CurrentSequence == C_Sequence_PlaceStart) {
// Multilaps tuto
if (CursorMacroblockModel != Null && CursorMacroblockModel.HasMultilap && !UI_Tuto::IsValidated(UI_Tuto::Tuto_Multilaps())) {
UI_Tuto::Enable(UI_Tuto::Tuto_Multilaps());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Multilaps());
}
}
if (G_CurrentSequence == C_Sequence_FreeMode || G_CurrentSequence == C_Sequence_EditDecoration) {
// Macroblock selection tuto
if (!G_IsEditing && !G_IsSkinning && !UI_Tuto::IsValidated(UI_Tuto::Tuto_Rosaces())) {
UI_Tuto::Enable(UI_Tuto::Tuto_Rosaces());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Rosaces());
}
// Switch build mode tuto
if (!G_IsEditing && !G_IsSkinning && !UI_Tuto::IsValidated(UI_Tuto::Tuto_ChangeMode())) {
UI_Tuto::Enable(UI_Tuto::Tuto_ChangeMode());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_ChangeMode());
}
// Editing tuto
declare PartyEditor_TutoEditCopy for This = False;
if ((G_IsEditing || G_IsSkinning) && PartyEditor_TutoEditCopy && !UI_Tuto::IsValidated(UI_Tuto::Tuto_Edit())) {
UI_Tuto::Enable(UI_Tuto::Tuto_Edit());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Edit());
}
// Skin tuto
if (G_IsSkinning && !UI_Tuto::IsValidated(UI_Tuto::Tuto_Skin())) {
UI_Tuto::Enable(UI_Tuto::Tuto_Skin());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_Skin());
}
}
} else if (G_CurrentSequence == C_Sequence_EditTerrain) {
// Edit terrain tuto
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_EditTerrain())) {
UI_Tuto::Enable(UI_Tuto::Tuto_EditTerrain());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_EditTerrain());
}
}
if (
G_CurrentSequence == C_Sequence_Simple_PlaceStart ||
G_CurrentSequence == C_Sequence_Simple_BuildTrack ||
G_CurrentSequence == C_Sequence_Simple_MoveCursor ||
G_CurrentSequence == C_Sequence_PlaceStart ||
G_CurrentSequence == C_Sequence_FreeMode ||
G_CurrentSequence == C_Sequence_EditTerrain ||
G_CurrentSequence == C_Sequence_EditDecoration
) {
// Camera move tuto
if (G_Platform == Buttons2::System_PC() && !UI_Tuto::IsValidated(UI_Tuto::Tuto_CameraMove_Mouse())) {
UI_Tuto::Enable(UI_Tuto::Tuto_CameraMove_Mouse());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_CameraMove_Mouse());
}
if (G_Platform != Buttons2::System_PC() && !UI_Tuto::IsValidated(UI_Tuto::Tuto_CameraMove_Pad())) {
UI_Tuto::Enable(UI_Tuto::Tuto_CameraMove_Pad());
} else {
UI_Tuto::Disable(UI_Tuto::Tuto_CameraMove_Pad());
}
/*
if (!UI_Tuto::IsValidated(UI_Tuto::Tuto_CameraZoom())) {
UI_Tuto::Enable(UI_Tuto::Tuto_CameraZoom());
}
*/
}
}
// ---------------------------------- //
/// Update the save status when the map is modified
Void MapModified() {
if (GetMapName() == "") Utils::SetSaveStatus(Utils::SaveStatus_NotSaved());
else Utils::SetSaveStatus(Utils::SaveStatus_Modified());
}
// ---------------------------------- //
/// Yield
Void Yield() {
yield;
if (UserMgr != Null && UserMgr.MainUser != Null) UplayActionsSynchro::CheckUplayActions();
declare AskStopGeneration = False;
foreach (Event in PendingEvents) {
if (Event.Type == CEditorPluginEvent::Type::EditorInput) {
// Launch classic map editor
if (Event.Input == CEditorPluginEvent::EInput::ClassicMapEditor) {
if (!IsEditor(C_Editor_Classic)) G_StartClassicEditor = True;
} else {
// Save device used to generate input
if (Event.IsFromPad) {
G_LastDeviceInput[Event.Input] = Buttons2::Device_Pad();
} else if (Event.IsFromKeyboard) {
G_LastDeviceInput[Event.Input] = Buttons2::Device_Keyboard();
} else if (Event.IsFromMouse) {
G_LastDeviceInput[Event.Input] = Buttons2::Device_Mouse();
}
if (UI_MacroblockSelection::IsSelecting() || C_AutoRepeatDisabled.exists(Event.Input)) {
UpdateInputBuffer(Event.Input, Event.IsFromPad, Event.IsFromKeyboard, Event.IsFromMouse);
}
if (
(G_CurrentSequence == C_Sequence_RandomMap || G_CurrentSequence == C_Sequence_AutoFinish) &&
C_StopGeneration.exists(Event.Input)
) {
AskStopGeneration = True;
}
}
} else if (Event.Type == CEditorPluginEvent::Type::MapModified) {
MapModified();
} else if (Event.Type == CEditorPluginEvent::Type::LayerCustomEvent) {
declare Text[] Data;
foreach (Value in Event.CustomEventData) Data.add(Value);
UpdateUIInputBuffer(Event.CustomEventType, Data);
}
}
foreach (Input in C_AutoRepeatEnabled) {
if (!UI_MacroblockSelection::IsSelecting() && InputIsDown(Input)) {
UpdateInputBuffer(Input);
} else {
G_AutoRepeatInput[Input] = 0;
}
}
// Classic editor stop here
if (IsEditor(C_Editor_Classic)) return;
// ------------------------------------------------------------------------------------------------------------------------ //
// Play camera animations
Camera::Loop();
// Force cursor coordinates
if (CursorCoord != G_ForcedCursorCoord) {
CursorCoord = G_ForcedCursorCoord;
}
// Update platform
declare Platform = UI_Tuto::GetPlatform();
if (G_Platform != Platform) {
G_Platform = Platform;
CheckTuto();
}
// Block help
if (UI_BlockHelp::CanBeVisible()) {
// Force helper display when there are less than 5 blocks on the map
if (
IsEditor(C_Editor_Beginner) ||
G_TestMode ||
G_WaitingRerollAnswer ||
(!IsEditor(C_Editor_Expert) && MapContent::Count() < 5)
) {
if (!UI_BlockHelp::IsVisible()) UI_BlockHelp::Show();
} else {
declare Activities =
PendingEvents.count > 0 ||
G_InputBuffer.count > 0 ||
G_UIInputBuffer.count > 0 ||
IsEditor(C_Editor_Expert) && (
UI_MacroblockSelection::IsSelecting() ||
(UI_Tuto::IsVisible() && UI_Tuto::IsEnabled())
);
if (UI_BlockHelp::IsVisible()) {
if (Activities) {
UI_BlockHelp::Hide();
G_InactivityStartTime = Now;
}
} else {
if (Activities) {
G_InactivityStartTime = Now;
} else if (G_InactivityStartTime + C_Tick_BlockHelper <= Now) {
UI_BlockHelp::Show();
Sound::Play("EditorBlockHelp");
}
}
}
}
// Force place and edit modes
if (PlaceMode != G_PlaceMode) PlaceMode = G_PlaceMode;
if (EditMode != G_EditMode) EditMode = G_EditMode;
// Check if a pad is connected
CheckPadConnection();
// Stop random generation ?
if (AskStopGeneration) {
// Cancel random map
if (G_CurrentSequence == C_Sequence_RandomMap) {
RandomMenu();
}
// Cancel auto-finish
else {
UI_PopUp::Confirm(
//L16N [MapEditor] Title of the pop-up asking the player if he really wants to cancel the ongoing auto-finish process. The auto-finish is a function of the track editor that automatically place a finish block in an uncomplete track.
_("Stop auto-finish"),
//L16N [MapEditor] Text of the pop-up asking the player if he really wants to cancel the ongoing auto-finish process. The auto-finish is a function of the track editor that automatically place a finish block in an uncomplete track.
_("Do you want to stop the auto-finish?"),
//L16N [MapEditor] Confirm button in a pop-up
_("Yes"),
//L16N [MapEditor] Cancel button in a pop-up
_("No")
);
Sound::Play("EditorPopUp");
while (UI_PopUp::Wait()) yield;
// Clear input buffer
ClearInputBuffer();
G_TerrainCanPress = False;
G_CancelGeneration = UI_PopUp::Answer();
}
}
}
// ---------------------------------- //
/// Sleep
Void Sleep(Integer _Duration) {
declare EndTime = Now + _Duration;
while (Now < EndTime) {
Yield();
}
}
// ---------------------------------- //
/// Wait for the editor to be ready
Void WaitReady() {
while (!IsEditorReadyForRequest) Yield();
}
// ---------------------------------- //
/** Create a multilines Text from an array of messages
*
* @param _Messages The messages to compose
*
* @return The multilines Text
*/
Text ComposeMultilines(Text[] _Messages) {
if (_Messages.count <= 0) return "";
declare ComposeMessage = "";
for (I, 1, _Messages.count) {
if (ComposeMessage != "") ComposeMessage ^= "\n";
ComposeMessage ^= "%"^I;
}
declare Message = "";
switch (_Messages.count) {
case 1 : Message = TL::Compose(ComposeMessage, _Messages[0]);
case 2 : Message = TL::Compose(ComposeMessage, _Messages[0], _Messages[1]);
case 3 : Message = TL::Compose(ComposeMessage, _Messages[0], _Messages[1], _Messages[2]);
case 4 : Message = TL::Compose(ComposeMessage, _Messages[0], _Messages[1], _Messages[2], _Messages[3]);
default : Message = TL::Compose(ComposeMessage, _Messages[0], _Messages[1], _Messages[2], _Messages[3], _Messages[4]);
}
return Message;
}
// ---------------------------------- //
/** Get the custom skin name of a block model
*
* @param _BlockModel The BlockModel to check
* @param _SkinIndex The index of the skin
*
* @return The custom skin name
*/
Text GetSkinName(CBlockModel _BlockModel, Integer _SkinIndex) {
return "|"^_SkinIndex^"|"^GetBlockModelSkinName(_BlockModel, _SkinIndex);
}
// ---------------------------------- //
/** Set the name of the map
*
* @param _MapName The name of the map
*/
Void SetMapName(Text _MapName) {
declare metadata Text PartyEditor_MapName for Map;
PartyEditor_MapName = _MapName;
}
// ---------------------------------- //
/** Check if we are in a constrained editor mode
*
* @return True if we are in constrained editor mode, False otherwise
*/
Boolean IsSimpleEditor() {
return (!S_RandomMap_Generate && (G_Setting_EditorLevel == C_Editor_Beginner || G_Setting_EditorLevel == C_Editor_Advanced));
}
// ---------------------------------- //
/** Check if we can display a notification in the cursor helper
*
* @return True if we can display a notification, False otherwise
*/
Boolean CanNotify() {
return (
!G_RebuildMap && (
G_CurrentSequence == C_Sequence_Simple_PlaceStart ||
G_CurrentSequence == C_Sequence_Simple_BuildTrack ||
G_CurrentSequence == C_Sequence_Simple_MoveCursor ||
G_CurrentSequence == C_Sequence_PlaceStart ||
G_CurrentSequence == C_Sequence_FreeMode ||
G_CurrentSequence == C_Sequence_EditTerrain ||
G_CurrentSequence == C_Sequence_EditDecoration
)
);
}
// ---------------------------------- //
/** Check if we have to check coppers limit