· 4 years ago · Aug 11, 2021, 06:10 PM
1
2// @Component start utils
3// /*
4
5#Include "TextLib" as Utils_TL
6#Include "MathLib" as Utils_ML
7
8// */
9// @Component end utils
10
11// @Component start lib-tmnext-config
12// /*
13
14#Struct LibTMNextConfig_K_Config { Text APIBaseUrl; Text APIBordeauxClubUrl; Text APICompetitionUrl; Text APIMatchmakingUrl; Text WebsiteAdminClubUrl; Text ScriptEnvironment; Text BuildEnvironment; Boolean IsDebug; Text DefaultSubscription; Boolean IsCustomDisabled; Text DefaultMasterZone; Text OfflineCampaignJsonName; Text[] Features; }
15
16#Const LibTMNextConfig_C_DefaultConfig LibTMNextConfig_K_Config {
17 APIBaseUrl = "https://live-services.trackmania.nadeo.live",
18 APIBordeauxClubUrl = "https://club.trackmania.nadeo.club",
19 APICompetitionUrl = "https://competition.trackmania.nadeo.club",
20 APIMatchmakingUrl = "https://matchmaking.trackmania.nadeo.club",
21 WebsiteAdminClubUrl = "https://admin.trackmania.nadeo.club",
22 ScriptEnvironment = "production",
23 BuildEnvironment = "",
24 IsDebug = False,
25 DefaultSubscription = "",
26 IsCustomDisabled = False,
27 DefaultMasterZone = "World",
28 OfflineCampaignJsonName = "Campaign.production.json",
29 Features = []
30}
31
32#Const LibTMNextConfig_C_Feature_MatchmakingDebugQueue "MatchmakingDebugQueue"
33#Const LibTMNextConfig_C_Feature_Squadding "Squadding"
34#Const LibTMNextConfig_C_Feature_DebugShortcut "DebugShortcut"
35
36// */
37// @Component end lib-tmnext-config
38
39// @Component start component-menulibs-tools
40// /*
41
42#Include "TextLib" as ComponentMenuLibsTools_TL
43#Include "MathLib" as ComponentMenuLibsTools_ML
44#Include "ColorLib" as ComponentMenuLibsTools_CL
45
46#Struct ComponentMenuLibsTools_K_JoinLink { Text Full; Text Type; Text ServerLoginOrIp; Text Password; Text Port; Text Title; }
47
48#Const ComponentMenuLibsTools_C_HAlign_Left "left"
49#Const ComponentMenuLibsTools_C_HAlign_Center "center"
50#Const ComponentMenuLibsTools_C_HAlign_Right "right"
51
52#Const ComponentMenuLibsTools_C_VAlign_Top "top"
53#Const ComponentMenuLibsTools_C_VAlign_Center "center"
54#Const ComponentMenuLibsTools_C_VAlign_Bottom "bottom"
55
56#Const ComponentMenuLibsTools_C_FitLabelMaxSteps 15.
57#Const ComponentMenuLibsTools_C_TagForbiddenTags ["$h", "$l", "$<", "$>", "\n", "\r"]
58#Const ComponentMenuLibsTools_C_TagMaxLength 64
59#Const ComponentMenuLibsTools_C_LiveApiRankRoundingStart 10000
60
61// */
62// @Component end component-menulibs-tools
63
64// @Component start component-modelibs-uimodules
65// /*
66
67#Struct ComponentModeLibsUIModules_K_ModuleProperties { Vec2 Position; Real Scale; Boolean Visible; }
68
69#Struct ComponentModeLibsUIModules_K_Module {
70 CMlControl Control;
71 Boolean IsCustom;
72 ComponentModeLibsUIModules_K_ModuleProperties DefaultProperties;
73}
74
75// */
76// @Component end component-modelibs-uimodules
77
78// @Component start share-menu-navigation
79// /*
80
81#Include "TextLib" as ShareMenuNavigation_TL
82
83#Const ShareMenuNavigation_C_TextToMenuNavAction [
84 "::EMenuNavAction::Up" => CMlScriptEvent::EMenuNavAction::Up,
85 "::EMenuNavAction::Right" => CMlScriptEvent::EMenuNavAction::Right,
86 "::EMenuNavAction::Left" => CMlScriptEvent::EMenuNavAction::Left,
87 "::EMenuNavAction::Down" => CMlScriptEvent::EMenuNavAction::Down,
88 "::EMenuNavAction::Select" => CMlScriptEvent::EMenuNavAction::Select,
89 "::EMenuNavAction::Cancel" => CMlScriptEvent::EMenuNavAction::Cancel,
90 "::EMenuNavAction::PageUp" => CMlScriptEvent::EMenuNavAction::PageUp,
91 "::EMenuNavAction::PageDown" => CMlScriptEvent::EMenuNavAction::PageDown,
92 "::EMenuNavAction::AppMenu" => CMlScriptEvent::EMenuNavAction::AppMenu,
93 "::EMenuNavAction::Action1" => CMlScriptEvent::EMenuNavAction::Action1,
94 "::EMenuNavAction::Action2" => CMlScriptEvent::EMenuNavAction::Action2,
95 "::EMenuNavAction::ScrollUp" => CMlScriptEvent::EMenuNavAction::ScrollUp,
96 "::EMenuNavAction::ScrollDown" => CMlScriptEvent::EMenuNavAction::ScrollDown
97]
98
99#Struct ShareMenuNavigation_K_MenuNavigationEvent {
100 CMlScriptEvent::EMenuNavAction MenuNavAction;
101 Boolean IsActionAutoRepeat;
102 Integer UserIndex;
103}
104
105// */
106// @Component end share-menu-navigation
107
108// @Component start component-navigation
109// /*
110
111#Include "TextLib" as ComponentNavigation_TL
112
113#Const ComponentNavigation_C_EventType_NavigateInput 0
114#Const ComponentNavigation_C_EventType_NavigateMouse 1
115
116#Const ComponentNavigation_C_MouseSleepDelay 5000
117
118
119#Struct ComponentNavigation_K_NavigationSettings {
120 Text[Text] InputTargets;
121 Text Group;
122 Text Zone;
123 Boolean Focused;
124 Boolean Locked;
125}
126
127
128#Struct ComponentNavigation_K_NavigationProperties {
129 Boolean IsInitialized;
130 CMlControl[CMlScriptEvent::EMenuNavAction] Actions;
131 CMlControl[CMlScriptEvent::EMenuNavAction] SavedActions;
132 Text Group;
133 Boolean IsLocked;
134}
135
136#Struct ComponentNavigation_K_NavigationEvent {
137 Integer Type;
138 CMlControl From;
139 CMlControl To;
140 CMlFrame Container;
141 CMlScriptEvent::EMenuNavAction Input;
142 CMlScriptEvent::Type Mouse;
143 Integer UserIndex;
144}
145
146// */
147// @Component end component-navigation
148
149// @Component start component-commonlibs-audio-manager
150// /*
151
152
153// */
154// @Component end component-commonlibs-audio-manager
155
156// @Component start component-popupbackground
157// /*
158
159#Include "ColorLib" as ComponentPopUpBackground_CL
160#Include "TextLib" as ComponentPopUpBackground_TL
161
162#Const ComponentPopUpBackground_C_Event_LeavePopUp "Event_LeavePopUp"
163
164#Const ComponentPopUpBackground_C_PopUp_SizeX 299.
165#Const ComponentPopUpBackground_C_PopUp_SizeY 154.
166
167#Const ComponentPopUpBackground_C_DelayBetweenClicks 100
168
169#Struct ComponentPopUpBackground_K_Event {
170 Text Type;
171 Text PopUpName;
172 Boolean FromCloseButton;
173}
174
175#Struct ComponentPopUpBackground_K_Image {
176 Text Url;
177 Text AlphaMask;
178 Vec2 Size;
179 Vec2 Position;
180 Vec3 Colorize;
181 Real Opacity;
182}
183
184#Struct ComponentPopUpBackground_K_Properties {
185 Boolean ShowHeader;
186 Boolean UseHitbox;
187 ComponentPopUpBackground_K_Image Background;
188 ComponentPopUpBackground_K_Image Overlay;
189 ComponentPopUpBackground_K_Image Header;
190 ComponentPopUpBackground_K_Image HeaderOverlay;
191 ComponentPopUpBackground_K_Image HeaderBackground;
192 ComponentPopUpBackground_K_Image Footer;
193 ComponentPopUpBackground_K_Image CloseButton;
194}
195
196#Const ComponentPopUpBackground_C_Layout_Type_Null -1
197#Const ComponentPopUpBackground_C_Layout_Type_Default 0
198#Const ComponentPopUpBackground_C_Layout_Type_Campaign 1
199#Const ComponentPopUpBackground_C_Layout_Type_Browser 2
200#Const ComponentPopUpBackground_C_Layout_Type_ClubSubMenu 3
201
202#Const ComponentPopUpBackground_C_Layout_Types [
203 0 => ComponentPopUpBackground_K_Properties {
204 ShowHeader = False,
205 UseHitbox = False,
206 Background = ComponentPopUpBackground_K_Image {
207 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/PopUp_Room_Background.png",
208 AlphaMask = "",
209 Size = <299., 154.>,
210 Position = <0., 0.>,
211 Colorize = <-1., -1., -1.>,
212 Opacity = 1.
213 },
214 Overlay = ComponentPopUpBackground_K_Image {
215 Url = "",
216 AlphaMask = "",
217 Size = <299., 154.>,
218 Position = <.5, 0.>,
219 Colorize = <-1., -1., -1.>,
220 Opacity = 1.
221 },
222 HeaderBackground = ComponentPopUpBackground_K_Image {
223 Url = "",
224 AlphaMask = "",
225 Size = <299., 154.>,
226 Position = <0., 0.>,
227 Colorize = <-1., -1., -1.>,
228 Opacity = 1.
229 },
230 Header = ComponentPopUpBackground_K_Image {
231 Url = "",
232 AlphaMask = "",
233 Size = <-1., -1.>,
234 Position = <0., 0.>,
235 Colorize = <-1., -1., -1.>,
236 Opacity = 1.
237 },
238 HeaderOverlay = ComponentPopUpBackground_K_Image {
239 Url = "",
240 AlphaMask = "",
241 Size = <-1., -1.>,
242 Position = <0., 0.>,
243 Colorize = <-1., -1., -1.>,
244 Opacity = 1.
245 },
246 Footer = ComponentPopUpBackground_K_Image {
247 Url = "",
248 AlphaMask = "",
249 Size = <299., 154.>,
250 Position = <0., 0.>,
251 Colorize = <-1., -1., -1.>,
252 Opacity = .3
253 },
254 CloseButton = ComponentPopUpBackground_K_Image {
255 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/256x256/Icones_256_icon_cross_oblique.dds",
256 AlphaMask = "",
257 Size = <7., 7.>,
258 Position = <143.5, 72.>,
259 Colorize = <1., 1., 1.>,
260 Opacity = 1.
261 }
262 },
263 1 => ComponentPopUpBackground_K_Properties {
264 ShowHeader = True,
265 UseHitbox = True,
266 Background = ComponentPopUpBackground_K_Image {
267 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_body_full_01.dds",
268 AlphaMask = "",
269 Size = <308., 156.>,
270 Position = <0., 0.>,
271 Colorize = <0., 0.608, 0.372>,
272 Opacity = 1.
273 },
274 Overlay = ComponentPopUpBackground_K_Image {
275 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_body_gradient_01.dds",
276 AlphaMask = "",
277 Size = <308., 156.>,
278 Position = <0., 0.>,
279 Colorize = <0., 0.196, 0.157>,
280 Opacity = 1.
281 },
282 HeaderBackground = ComponentPopUpBackground_K_Image {
283 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_header_full_02.dds",
284 AlphaMask = "",
285 Size = <308., 156.>,
286 Position = <0., 0.>,
287 Colorize = <0., 0.608, 0.372>,
288 Opacity = 1.
289 },
290 Header = ComponentPopUpBackground_K_Image {
291 Url = "",
292 AlphaMask = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_header_mask.dds",
293 Size = <289.8, 50.35>,
294 Position = <9.1, 77.6>,
295 Colorize = <-1., -1., -1.>,
296 Opacity = 1.
297 },
298 HeaderOverlay = ComponentPopUpBackground_K_Image {
299 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_header_gradient_01.dds",
300 AlphaMask = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_header_mask.dds",
301 Size = <289.8, 50.35>,
302 Position = <9.1, 77.6>,
303 Colorize = <0., 0., 0.>,
304 Opacity = 1.
305 },
306 Footer = ComponentPopUpBackground_K_Image {
307 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_footer_30_01.dds",
308 AlphaMask = "",
309 Size = <308., 156.>,
310 Position = <0., -77.9>,
311 Colorize = <0.431, 0.98, 0.627>,
312 Opacity = .3
313 },
314 CloseButton = ComponentPopUpBackground_K_Image {
315 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/256x256/Icones_256_icon_cross_oblique.dds",
316 AlphaMask = "",
317 Size = <7., 7.>,
318 Position = <148., 72.>,
319 Colorize = <0., 0.608, 0.372>,
320 Opacity = 1.
321 }
322 },
323 2 => ComponentPopUpBackground_K_Properties {
324 ShowHeader = True,
325 UseHitbox = True,
326 Background = ComponentPopUpBackground_K_Image {
327 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Browser/Background/UI_Brower_popup_body_full_01.dds",
328 AlphaMask = "",
329 Size = <308., 156.>,
330 Position = <0., 0.>,
331 Colorize = <0., 0.608, 0.372>,
332 Opacity = 1.
333 },
334 Overlay = ComponentPopUpBackground_K_Image {
335 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Browser/Background/UI_Brower_popup_body_gradient_lineaire_01.dds",
336 AlphaMask = "",
337 Size = <308., 156.>,
338 Position = <0., 0.>,
339 Colorize = <0., 0.372, 0.274>,
340 Opacity = 1.
341 },
342 HeaderBackground = ComponentPopUpBackground_K_Image {
343 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Browser/Background/UI_Brower_popup_header_background.dds",
344 AlphaMask = "",
345 Size = <308., 156.>,
346 Position = <0., 0.>,
347 Colorize = <0.431, 0.98, 0.627>,
348 Opacity = 1.
349 },
350 Header = ComponentPopUpBackground_K_Image {
351 Url = "",
352 AlphaMask = "",
353 Size = <0., 0.>,
354 Position = <9.1, 77.6>,
355 Colorize = <-1., -1., -1.>,
356 Opacity = 1.
357 },
358 HeaderOverlay = ComponentPopUpBackground_K_Image {
359 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Browser/Background/UI_Brower_popup_header_gradient_255_01.dds",
360 AlphaMask = "",
361 Size = <288.5, 42.6>,
362 Position = <10., 77.6>,
363 Colorize = <0., 0.608, 0.372>,
364 Opacity = 1.
365 },
366 Footer = ComponentPopUpBackground_K_Image {
367 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/UI_popup_footer_30_01.dds",
368 AlphaMask = "",
369 Size = <308., 156.>,
370 Position = <0., -77.9>,
371 Colorize = <0.431, 0.98, 0.627>,
372 Opacity = .3
373 },
374 CloseButton = ComponentPopUpBackground_K_Image {
375 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/256x256/Icones_256_icon_cross_oblique.dds",
376 AlphaMask = "",
377 Size = <7., 7.>,
378 Position = <148., 72.>,
379 Colorize = <1., 1., 1.>,
380 Opacity = 1.
381 }
382 },
383 3 => ComponentPopUpBackground_K_Properties {
384 ShowHeader = False,
385 UseHitbox = True,
386 Background = ComponentPopUpBackground_K_Image {
387 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/PopUpClubSubMenu/menu_popup_club_sub_menu_body.dds",
388 AlphaMask = "",
389 Size = <308., 156.>,
390 Position = <0., 0.>,
391 Colorize = <-1., -1., -1.>,
392 Opacity = 1.
393 },
394 Overlay = ComponentPopUpBackground_K_Image {
395 Url = "",
396 AlphaMask = "",
397 Size = <308., 156.>,
398 Position = <0., 0.>,
399 Colorize = <-1., -1., -1.>,
400 Opacity = 1.
401 },
402 HeaderBackground = ComponentPopUpBackground_K_Image {
403 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PopUp/PopUpClubSubMenu/menu_popup_club_sub_menu_header.dds",
404 AlphaMask = "",
405 Size = <308., 156.>,
406 Position = <0., 0.>,
407 Colorize = <-1., -1., -1.>,
408 Opacity = 1.
409 },
410 Header = ComponentPopUpBackground_K_Image {
411 Url = "",
412 AlphaMask = "",
413 Size = <-1., -1.>,
414 Position = <0., 0.>,
415 Colorize = <-1., -1., -1.>,
416 Opacity = 1.
417 },
418 HeaderOverlay = ComponentPopUpBackground_K_Image {
419 Url = "",
420 AlphaMask = "",
421 Size = <-1., -1.>,
422 Position = <0., 0.>,
423 Colorize = <-1., -1., -1.>,
424 Opacity = 1.
425 },
426 Footer = ComponentPopUpBackground_K_Image {
427 Url = "",
428 AlphaMask = "",
429 Size = <308., 156.>,
430 Position = <0., 0.>,
431 Colorize = <-1., -1., -1.>,
432 Opacity = 0.
433 },
434 CloseButton = ComponentPopUpBackground_K_Image {
435 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/256x256/Icones_256_icon_cross_oblique.dds",
436 AlphaMask = "",
437 Size = <7., 7.>,
438 Position = <147.5, 72.5>,
439 Colorize = <1., 1., 1.>,
440 Opacity = 1.
441 }
442 },
443 4 => ComponentPopUpBackground_K_Properties {
444 ShowHeader = False,
445 UseHitbox = True,
446 Background = ComponentPopUpBackground_K_Image {
447 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/PageClub/ClubActivities/menu_clubs_activities_create_news_body.dds",
448 AlphaMask = "",
449 Size = <308., 156.>,
450 Position = <0., 0.>,
451 Colorize = <-1., -1., -1.>,
452 Opacity = 1.
453 },
454 Overlay = ComponentPopUpBackground_K_Image {
455 Url = "",
456 AlphaMask = "",
457 Size = <308., 156.>,
458 Position = <0., 0.>,
459 Colorize = <-1., -1., -1.>,
460 Opacity = 1.
461 },
462 HeaderBackground = ComponentPopUpBackground_K_Image {
463 Url = "",
464 AlphaMask = "",
465 Size = <308., 156.>,
466 Position = <0., 0.>,
467 Colorize = <-1., -1., -1.>,
468 Opacity = 1.
469 },
470 Header = ComponentPopUpBackground_K_Image {
471 Url = "",
472 AlphaMask = "",
473 Size = <-1., -1.>,
474 Position = <0., 0.>,
475 Colorize = <-1., -1., -1.>,
476 Opacity = 1.
477 },
478 HeaderOverlay = ComponentPopUpBackground_K_Image {
479 Url = "",
480 AlphaMask = "",
481 Size = <-1., -1.>,
482 Position = <0., 0.>,
483 Colorize = <-1., -1., -1.>,
484 Opacity = 1.
485 },
486 Footer = ComponentPopUpBackground_K_Image {
487 Url = "",
488 AlphaMask = "",
489 Size = <308., 156.>,
490 Position = <0., 0.>,
491 Colorize = <-1., -1., -1.>,
492 Opacity = 0.
493 },
494 CloseButton = ComponentPopUpBackground_K_Image {
495 Url = "file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/256x256/Icones_256_icon_cross_oblique.dds",
496 AlphaMask = "",
497 Size = <7., 7.>,
498 Position = <147.5, 72.5>,
499 Colorize = <1., 1., 1.>,
500 Opacity = 1.
501 }
502 }
503]
504
505// */
506// @Component end component-popupbackground
507
508// @Component start menu-libs-scroll
509// /*
510
511#Include "TextLib" as MenuLibsScroll_TL
512#Include "MathLib" as MenuLibsScroll_ML
513#Include "AnimLib" as MenuLibsScroll_AL
514#Include "ColorLib" as MenuLibsScroll_CL
515
516#Const MenuLibsScroll_C_EventType_Update 0
517#Const MenuLibsScroll_C_EventType_DisplayStart 1
518#Const MenuLibsScroll_C_EventType_DisplayEnd 2
519#Const MenuLibsScroll_C_EventType_Focus 3
520#Const MenuLibsScroll_C_EventType_Select 4
521#Const MenuLibsScroll_C_EventType_ReachLimit 5
522#Const MenuLibsScroll_C_EventType_Cancel 6
523#Const MenuLibsScroll_C_EventType_NavAction 7
524#Const MenuLibsScroll_C_EventType_ClampUpdate 8
525#Const MenuLibsScroll_C_EventType_PagerUpdate 9
526
527#Const MenuLibsScroll_C_Action_Click 0
528#Const MenuLibsScroll_C_Action_Unclick 1
529#Const MenuLibsScroll_C_Action_Over 2
530#Const MenuLibsScroll_C_Action_Out 3
531
532#Const MenuLibsScroll_C_ScrollBarVisibility_Never 0
533#Const MenuLibsScroll_C_ScrollBarVisibility_Always 1
534#Const MenuLibsScroll_C_ScrollBarVisibility_DuringScroll 2
535
536#Const MenuLibsScroll_C_ScrollBarVisibilityDuration 2500
537
538#Const MenuLibsScroll_C_SkewVAlign_Top 0
539#Const MenuLibsScroll_C_SkewVAlign_Center 1
540#Const MenuLibsScroll_C_SkewVAlign_Bottom 2
541
542#Const MenuLibsScroll_C_PagerThrottleDuration 1000
543
544#Struct MenuLibsScroll_K_Config { Integer DefaultElementsTotal; Integer ElementsPerLine; Integer ElementsPerPage; Vec2 ElementSize; Vec2 MarginSize; Vec2 WindowSize; Real HeaderHeight; Real FooterHeight; Boolean ScrollIndicator; Real ScrollIndicatorYOffset; Real ScrollIndicatorXOffset; Boolean AnimEnabled; Vec2 ScrollGrid; Integer ScrollBarVisibility; Real ScrollPadding; Real Skew; Integer SkewVAlign; Text ScrollIndicatorImage; Vec3 ScrollIndicatorColorize; Real ScrollIndicatorSize; Real ScrollBarXOffset; Integer PagerPageSize; Integer PagerTriggerSize; Integer PagerMarginSize; }
545
546#Struct MenuLibsScroll_K_ScrollAnimation {
547 Integer StartTime;
548 Real ScrollStart;
549 Real ScrollDelta;
550 Integer Duration;
551}
552
553#Struct MenuLibsScroll_K_ClampedControl {
554 CMlControl Control;
555 Integer Type;
556 Vec2 Limit;
557 Real Origin;
558 Boolean ClampedTop;
559 Boolean ClampedBottom;
560}
561
562#Struct MenuLibsScroll_K_Pager {
563 Integer ThrottleEndTime;
564 Integer CooldownEndTime;
565 Int2 Limits;
566}
567
568#Struct MenuLibsScroll_K_State {
569 MenuLibsScroll_K_Config Config;
570 MenuLibsScroll_K_ScrollAnimation Animation;
571 Integer ElementsTotal;
572 CMlFrame[] Elements;
573 CMlFrame Header;
574 CMlFrame Footer;
575 Boolean IsFocused;
576 Integer FocusedElementKey;
577 CMlFrame FocusedElement;
578 CMlControl ScrollIndicator;
579 Boolean CanPreScroll;
580 Boolean IsDisplayingStart;
581 Boolean IsDisplayingEnd;
582 CMlQuad EventGenerator;
583 Vec2 ScrollOffset;
584 CMlFrame ScrollBar;
585 Boolean IsInitialized;
586 Real ScrollBarWidth;
587 Integer ScrollBarHideTime;
588 MenuLibsScroll_K_ClampedControl[] ClampedControls;
589 CMlControl[] StickControls;
590 Boolean ScrollLocked;
591 Vec2 ScrollLockPosition;
592 MenuLibsScroll_K_Pager Pager;
593 Text[][] EventCustomData;
594}
595
596#Struct MenuLibsScroll_K_ScrollBarState {
597 CMlFrame Scroll;
598 Real AbsoluteTop;
599 Real AbsoluteBottom;
600 Real ClickShift;
601 Real Height;
602}
603
604#Struct MenuLibsScroll_K_ScrollPosition {
605 Integer Row;
606 Integer StartKey;
607 Integer EndKey;
608}
609
610#Struct MenuLibsScroll_K_Event {
611 Integer Type;
612 CMlFrame Scroll;
613 CMlFrame[Integer] ElementsVisible;
614 CMlFrame[Integer] ElementsHidden;
615 MenuLibsScroll_K_ScrollPosition ScrollPosition;
616 Integer Page;
617 Boolean DelayedElementsUpdate;
618 CMlFrame From;
619 Integer FromKey;
620 CMlFrame To;
621 Integer ToKey;
622 CMlScriptEvent::EMenuNavAction NavAction;
623 Boolean IsMouse;
624 MenuLibsScroll_K_ClampedControl ClampedControl;
625 Integer PagerOffset;
626 Integer PagerCount;
627 Text[][] CustomData;
628}
629
630#Struct MenuLibsScroll_K_ActivationZone {
631 CMlFrame Scroll;
632 Integer ElementRelativeKey;
633 CMlFrame Element;
634}
635
636// */
637// @Component end menu-libs-scroll
638
639// @Component start component-menulibs-menusounds
640// /*
641
642#Const ComponentMenuLibsMenuSounds_C_FocusInputs [
643 CMlScriptEvent::EMenuNavAction::Up,
644 CMlScriptEvent::EMenuNavAction::Down,
645 CMlScriptEvent::EMenuNavAction::Left,
646 CMlScriptEvent::EMenuNavAction::Right
647]
648
649#Const ComponentMenuLibsMenuSounds_C_Sound_Focus "MenuFocus"
650#Const ComponentMenuLibsMenuSounds_C_Sound_Select "MenuSelect"
651#Const ComponentMenuLibsMenuSounds_C_Sound_Cancel "BackButtonSelect"
652#Const ComponentMenuLibsMenuSounds_C_Sound_Silent "MenuSounds_UseSoundName_None"
653
654#Const ComponentMenuLibsMenuSounds_C_Playing_State 0
655#Const ComponentMenuLibsMenuSounds_C_InMenu_State 1
656#Const ComponentMenuLibsMenuSounds_C_PauseMenu_State 2
657
658// */
659// @Component end component-menulibs-menusounds
660
661// @Component start component-tmnext-button
662// /*
663
664#Include "TextLib" as ComponentTMNextButton_TL
665#Include "ColorLib" as ComponentTMNextButton_CL
666
667#Const ComponentTMNextButton_C_ColorType_None 0
668#Const ComponentTMNextButton_C_ColorType_Colorize 1
669#Const ComponentTMNextButton_C_ColorType_ModulateColor 2
670
671#Const ComponentTMNextButton_C_AnimTime_Blink 500
672
673#Struct ComponentTMNextButton_K_TextProperties {
674 Vec2 Size;
675 Real TextSize;
676 Text TextPrefix;
677 Text Value;
678 Text Font;
679 Real PosX;
680 Real PosY;
681 Vec3 Color;
682 Vec3 FocusColor;
683 Real ItalicSlope;
684 Text HAlign;
685 Text VAlign;
686 Integer MaxLine;
687 Boolean AutoNewLine;
688 Real Fit;
689 Real FitStep;
690 Real OpacityUnfocus;
691}
692
693#Struct ComponentTMNextButton_K_ImageProperties {
694 Integer ColorType;
695 Vec2 Size;
696 Text Image;
697 Text ImageFocus;
698 Real PosX;
699 Real PosY;
700 Vec3 Color;
701 Vec3 FocusColor;
702 Real Rotation;
703 Real Opacity;
704 Real OpacityUnfocus;
705 Real ImageFocusOpacity;
706 CMlQuad::EKeepRatioMode KeepRatio;
707 Text ContourImage;
708 Real ContourOpacityFocus;
709 Real ContourOpacityUnfocus;
710 Vec3 ContourColor;
711}
712
713#Struct ComponentTMNextButton_K_Properties {
714 Boolean IsButton;
715 Boolean IsLocked;
716 Boolean IsFocused;
717 Boolean IsBgEmpty;
718 Boolean IsBlink;
719 Real OpacityUnfocus;
720 Vec2 SizeHitbox;
721 Text AlphaMask;
722 ComponentTMNextButton_K_TextProperties Label;
723 ComponentTMNextButton_K_ImageProperties Icon;
724 ComponentTMNextButton_K_ImageProperties Background;
725 Text HAlign;
726 Text VAlign;
727}
728
729
730// */
731// @Component end component-tmnext-button
732
733#Include "TextLib" as TL
734
735#Const C_DivisionToImages_Official [
736 "1" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_gold_1.DDS",
737 "2" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_3.DDS",
738 "3" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_3.DDS",
739 "4" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_2.DDS",
740 "5" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_2.DDS"
741]
742
743#Const C_DivisionToTrophyType_Official [
744 "1" => 7,
745 "2" => 6,
746 "3" => 6,
747 "4" => 5,
748 "6" => 5
749]
750#Const C_DivisionToTrophyNumber_Official [
751 "1" => 1,
752 "2" => 6,
753 "3" => 3,
754 "4" => 7,
755 "6" => 4
756]
757
758#Const C_DivisionToImages_Rerun [
759 "1" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_3.DDS",
760 "2" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_3.DDS",
761 "3" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_2.DDS",
762 "4" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_2.DDS",
763 "5" => "file://Media/Manialinks/Nadeo/TMNext/Trophies/512/trophy_silver_2.DDS"
764]
765
766#Const C_DivisionToTrophyType_Rerun [
767 "1" => 6,
768 "2" => 6,
769 "3" => 5,
770 "4" => 5,
771 "6" => 5
772]
773
774#Const C_DivisionToTrophyNumber_Rerun [
775 "1" => 5,
776 "2" => 3,
777 "3" => 6,
778 "4" => 3,
779 "6" => 2
780]
781
782#Const C_Daily_Competition_Rerun "DailyCupMinor"
783
784
785
786// @Component start utils
787// /*
788
789CSmPlayer Utils_GetOwner() {
790 if (GUIPlayer != Null) return GUIPlayer;
791 return InputPlayer;
792}
793
794// Meant to be removed, still here for compatibility
795Text Utils_TimeToText(Integer _Time) {
796 return Utils_TL::TimeToText(_Time, True, True);
797}
798
799// Use to get only the suffix without the rank
800Text Utils_GetRankSuffix(Integer _Rank) {
801 if (_Rank <= 0) return "";
802 declare Rank = Utils_TL::ToText(_Rank);
803 declare Suffix = Utils_TL::FormatRank(_Rank, False);
804
805 if (Utils_TL::Find(Rank, Suffix, False, False)) {
806 Suffix = Utils_TL::Replace(Suffix, Rank, "");
807 return Suffix;
808 }
809
810 return "";
811}
812
813// Use to re scale UI modules in splitscreen
814Void Utils_AutoScaleSplitScreen(CMlFrame _Frame_Global, Real _VerticalScale, Real _HorizontalScale) {
815 declare CTitleControl::ESplitScreenLayout SplitScreenLayout for System;
816 if (SplitScreenLayout == CTitleControl::ESplitScreenLayout::Vertical) {
817 _Frame_Global.RelativeScale = _VerticalScale;
818 } else if (SplitScreenLayout == CTitleControl::ESplitScreenLayout::Horizontal) {
819 _Frame_Global.RelativeScale = _HorizontalScale;
820 } else if (SplitScreenLayout == CTitleControl::ESplitScreenLayout::Four) {
821 _Frame_Global.RelativeScale = 0.5;
822 }
823}
824
825// */
826// @Component end utils
827
828// @Component start lib-tmnext-config
829// /*
830
831LibTMNextConfig_K_Config LibTMNextConfig_Get() {
832 declare LibTMNextConfig_K_Config LibTMNextConfig_Config for System = LibTMNextConfig_C_DefaultConfig;
833 return LibTMNextConfig_Config;
834}
835
836Boolean LibTMNextConfig_HasFeature(Text _Feature) {
837 declare LibTMNextConfig_K_Config LibTMNextConfig_Config for System = LibTMNextConfig_C_DefaultConfig;
838 return LibTMNextConfig_Config.Features.exists(_Feature);
839}
840
841// */
842// @Component end lib-tmnext-config
843
844// @Component start component-menulibs-tools
845// /*
846
847Boolean ComponentMenuLibsTools_GetBooleanAttribute(CMlControl _Control, Text _AttributeName) {
848 if (_Control.DataAttributeExists(_AttributeName)) {
849 declare Text AttributeValue = _Control.DataAttributeGet(_AttributeName);
850 if (AttributeValue == "1" || ComponentMenuLibsTools_TL::ToLowerCase(AttributeValue ) == "true") {
851 return True;
852 }
853 }
854 return False;
855}
856
857CMlControl::AlignHorizontal ComponentMenuLibsTools_TextToHAlign(Text _HAlign) {
858 switch(ComponentMenuLibsTools_TL::ToLowerCase(ComponentMenuLibsTools_TL::Trim(_HAlign))) {
859 case ComponentMenuLibsTools_C_HAlign_Left: return CMlControl::AlignHorizontal::Left;
860 case ComponentMenuLibsTools_C_HAlign_Center: return CMlControl::AlignHorizontal::HCenter;
861 case ComponentMenuLibsTools_C_HAlign_Right: return CMlControl::AlignHorizontal::Right;
862 }
863
864 return CMlControl::AlignHorizontal::HCenter;
865}
866
867CMlControl::AlignVertical ComponentMenuLibsTools_TextToVAlign(Text _VAlign) {
868 switch(ComponentMenuLibsTools_TL::ToLowerCase(ComponentMenuLibsTools_TL::Trim(_VAlign))) {
869 case ComponentMenuLibsTools_C_VAlign_Top: return CMlControl::AlignVertical::Top;
870 case ComponentMenuLibsTools_C_VAlign_Center: return CMlControl::AlignVertical::VCenter2;
871 case ComponentMenuLibsTools_C_VAlign_Bottom: return CMlControl::AlignVertical::Bottom;
872 }
873
874 return CMlControl::AlignVertical::VCenter2;
875}
876
877Vec2 ComponentMenuLibsTools_TextToVec2(Text _Source) {
878 declare Text[] Values = ComponentMenuLibsTools_TL::Split(" ", ComponentMenuLibsTools_TL::Trim(_Source));
879
880 declare Real X = 0.;
881 if (Values.existskey(0)) {
882 X = ComponentMenuLibsTools_TL::ToReal(Values[0]);
883 }
884 declare Real Y = 0.;
885 if (Values.existskey(1)) {
886 Y = ComponentMenuLibsTools_TL::ToReal(Values[1]);
887 }
888
889 return <X, Y>;
890}
891
892Vec3 ComponentMenuLibsTools_TextToVec3(Text _Source) {
893 declare Text[] Values = ComponentMenuLibsTools_TL::Split(" ", ComponentMenuLibsTools_TL::Trim(_Source));
894
895 declare Real X = 0.;
896 if (Values.existskey(0)) {
897 X = ComponentMenuLibsTools_TL::ToReal(Values[0]);
898 }
899 declare Real Y = 0.;
900 if (Values.existskey(1)) {
901 Y = ComponentMenuLibsTools_TL::ToReal(Values[1]);
902 }
903 declare Real Z = 0.;
904 if (Values.existskey(2)) {
905 Z = ComponentMenuLibsTools_TL::ToReal(Values[2]);
906 }
907
908 return <X, Y, Z>;
909}
910
911Boolean ComponentMenuLibsTools_TextToBoolean(Text _Source) {
912 declare Text Value = ComponentMenuLibsTools_TL::ToLowerCase(ComponentMenuLibsTools_TL::Trim(_Source));
913 return (Value != "0" && Value != "false");
914}
915
916Text ComponentMenuLibsTools_MenuNavActionToText(CMlScriptEvent::EMenuNavAction _MenuNavAction) {
917 switch (_MenuNavAction) {
918 case CMlScriptEvent::EMenuNavAction::Up: return "up";
919 case CMlScriptEvent::EMenuNavAction::Right: return "right";
920 case CMlScriptEvent::EMenuNavAction::Left: return "left";
921 case CMlScriptEvent::EMenuNavAction::Down: return "down";
922 case CMlScriptEvent::EMenuNavAction::Select: return "select";
923 case CMlScriptEvent::EMenuNavAction::Cancel: return "cancel";
924 case CMlScriptEvent::EMenuNavAction::PageUp: return "pageup";
925 case CMlScriptEvent::EMenuNavAction::PageDown: return "pagedown";
926 case CMlScriptEvent::EMenuNavAction::AppMenu: return "appmenu";
927 case CMlScriptEvent::EMenuNavAction::Action1: return "action1";
928 case CMlScriptEvent::EMenuNavAction::Action2: return "action2";
929 case CMlScriptEvent::EMenuNavAction::ScrollUp: return "scrollup";
930 case CMlScriptEvent::EMenuNavAction::ScrollDown: return "scrolldown";
931 }
932
933 return "";
934}
935
936Vec3 ComponentMenuLibsTools_GetVisibleColorOnBackground(Vec3 _BackgroundColor, Vec3 _TargetColor, Real _Threshold) {
937 declare Real Threshold = ComponentMenuLibsTools_ML::Clamp(_Threshold, 0., 0.5);
938 declare Vec3 BackgroundColorHSV = ComponentMenuLibsTools_CL::RgbToHsv(_BackgroundColor);
939 declare Vec3 TargetColorHSV = ComponentMenuLibsTools_CL::RgbToHsv(_TargetColor);
940
941 if (ComponentMenuLibsTools_ML::Abs(BackgroundColorHSV.X - TargetColorHSV.X) > 0.1) {
942 return _TargetColor;
943 }
944
945 if (ComponentMenuLibsTools_ML::Abs(BackgroundColorHSV.Z - TargetColorHSV.Z) < Threshold) {
946 if (BackgroundColorHSV.Z > TargetColorHSV.Z) {
947 if (BackgroundColorHSV.Z - Threshold > 0.) {
948 TargetColorHSV.Z = BackgroundColorHSV.Z - Threshold;
949 } else {
950 TargetColorHSV.Z = BackgroundColorHSV.Z + Threshold;
951 }
952 } else {
953 if (BackgroundColorHSV.Z + Threshold < 1.) {
954 TargetColorHSV.Z = BackgroundColorHSV.Z + Threshold;
955 } else {
956 TargetColorHSV.Z = BackgroundColorHSV.Z - Threshold;
957 }
958 }
959 }
960
961 return ComponentMenuLibsTools_CL::HsvToRgb(TargetColorHSV);
962}
963Vec3 ComponentMenuLibsTools_GetVisibleColorOnBackground(Vec3 _BackgroundColor, Vec3 _TargetColor) {
964 return ComponentMenuLibsTools_GetVisibleColorOnBackground(_BackgroundColor, _TargetColor, 0.15);
965}
966
967Vec3 ComponentMenuLibsTools_GetBlinkingRed(Integer _BlinkingEndTime) {
968 declare Real A = ComponentMenuLibsTools_ML::Cos((_BlinkingEndTime - Now) / 200.);
969 declare Real B = (A * 0.5 * 0.2) + 0.9;
970 if (A > 0.) A *= 0.1;
971 A = (A * 0.9) + 0.9;
972 return <B, A, A>;
973}
974
975Vec3 ComponentMenuLibsTools_GetBlinkingColor(Integer _BlinkingEndTime, Integer _BlinkingFrequency, Integer _BlinkingDamping, Vec3 _BaseColor, Vec3 _BlinkColor) {
976 declare Vec3 DiffColor = _BlinkColor - _BaseColor;
977 declare Real Ratio = (ComponentMenuLibsTools_ML::Cos(((_BlinkingEndTime - Now) * ComponentMenuLibsTools_ML::Pi * 2.) / (_BlinkingFrequency * 1.)) * -0.5) + 0.5;
978 return _BaseColor + (DiffColor * ComponentMenuLibsTools_ML::Pow(Ratio, _BlinkingDamping * 1.));
979}
980Vec3 ComponentMenuLibsTools_GetBlinkingColor(Integer _BlinkingEndTime, Integer _BlinkingFrequency, Vec3 _BaseColor, Vec3 _BlinkColor) {
981 return ComponentMenuLibsTools_GetBlinkingColor(_BlinkingEndTime, _BlinkingFrequency, 1, _BaseColor, _BlinkColor);
982}
983
984Void ComponentMenuLibsTools_AlignFrame(CMlFrame _Frame_Align, Vec2 _Size, CMlControl::AlignHorizontal _HAlign, CMlControl::AlignVertical _Valign) {
985 switch (_HAlign) {
986 case CMlControl::AlignHorizontal::Left: {
987 _Frame_Align.RelativePosition_V3.X = 0.;
988 }
989 case CMlControl::AlignHorizontal::HCenter: {
990 _Frame_Align.RelativePosition_V3.X = _Size.X * -0.5;
991 }
992 case CMlControl::AlignHorizontal::Right: {
993 _Frame_Align.RelativePosition_V3.X = _Size.X * -1.;
994 }
995 }
996 switch (_Valign) {
997 case CMlControl::AlignVertical::Top: {
998 _Frame_Align.RelativePosition_V3.Y = 0.;
999 }
1000 case CMlControl::AlignVertical::VCenter2: {
1001 _Frame_Align.RelativePosition_V3.Y = _Size.Y * 0.5;
1002 }
1003 case CMlControl::AlignVertical::Bottom: {
1004 _Frame_Align.RelativePosition_V3.Y = _Size.Y * 1.;
1005 }
1006 }
1007}
1008
1009Void ComponentMenuLibsTools_AlignFrame(CMlFrame _Frame_Align, Vec2 _Size, Text _HAlign, Text _Valign) {
1010 ComponentMenuLibsTools_AlignFrame(_Frame_Align, _Size, ComponentMenuLibsTools_TextToHAlign(_HAlign), ComponentMenuLibsTools_TextToVAlign(_Valign));
1011}
1012
1013// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1014/** Make the text in the label fit inside without being cut.
1015 * Can only reduce label size, USE ONLY FOR STATIC LABELS.
1016 * For dynamic labels use overloaded version with settable Default Size
1017 *
1018 * Be careful to not use a too big initial text size with small steps
1019 * Otherwise the function will spend a long time reducing the
1020 * TextSize to make the text fit in the label
1021 * Which will cause performances problems
1022 *
1023 * @param _Label_Target The label to update
1024 * @param _MinTextSize Stop decreasing the label text size at this value
1025 */
1026Void ComponentMenuLibsTools_FitLabelValue(CMlLabel _Label_Target, Real _MinTextSize, Real _TextSizeStep) {
1027 declare MaxSteps = (_Label_Target.TextSizeReal - _MinTextSize) / _TextSizeStep;
1028 if (MaxSteps > ComponentMenuLibsTools_C_FitLabelMaxSteps) {
1029 log("WARNING [Tools] FitLabelValue() too many steps : "^MaxSteps^" > "^ComponentMenuLibsTools_C_FitLabelMaxSteps^" | Start : "^_Label_Target.TextSizeReal^" | Min : "^_MinTextSize^" | Step : "^_TextSizeStep^" | Label '"^_Label_Target.ControlId^"'");
1030 }
1031
1032 declare Text Value = ComponentMenuLibsTools_TL::GetTranslatedText(_Label_Target.Value);
1033 // When computing the height of a multilines label, the returned value might not always be up to date at first
1034 // It looks like reading the `ValueLineCount` property has the side effect of updating the label's properties
1035 // eg:
1036 // log(_Label_Target.ComputeHeight(Value)); => 10.
1037 // _Label_Target.ValueLineCount;
1038 // log(_Label_Target.ComputeHeight(Value)); => 50.
1039 // check /utils/script-documentation/-/issues/126 for more info
1040 declare Integer Tmp = _Label_Target.ValueLineCount;
1041
1042 // Fit height
1043 while (_Label_Target.ComputeHeight(Value) > _Label_Target.Size.Y && _Label_Target.TextSizeReal > _MinTextSize) {
1044 _Label_Target.TextSizeReal -= _TextSizeStep;
1045 }
1046 while (_Label_Target.MaxLine > 1 && _Label_Target.ValueLineCount > _Label_Target.MaxLine && _Label_Target.TextSizeReal > _MinTextSize) {
1047 _Label_Target.TextSizeReal -= _TextSizeStep;
1048 }
1049 // Fit width
1050 if (_Label_Target.ValueLineCount <= 1) {
1051 while (_Label_Target.ComputeWidth(Value) > _Label_Target.Size.X && _Label_Target.TextSizeReal > _MinTextSize) {
1052 _Label_Target.TextSizeReal -= _TextSizeStep;
1053 }
1054 }
1055 // Special case for multilines text
1056 // In this case ComputeWidth() return the text width as if it was on one line
1057 else {
1058 declare Words = ComponentMenuLibsTools_TL::Split("-", ComponentMenuLibsTools_TL::RegexReplace("[\\s-]", Value, "g", "-"));
1059 foreach (Word in Words) {
1060 while (_Label_Target.ComputeWidth(Word) > _Label_Target.Size.X && _Label_Target.TextSizeReal > _MinTextSize) {
1061 _Label_Target.TextSizeReal -= _TextSizeStep;
1062 }
1063 }
1064 }
1065
1066 if (_Label_Target.TextSizeReal < _MinTextSize) {
1067 _Label_Target.TextSizeReal = _MinTextSize;
1068 }
1069}
1070
1071// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1072/** Use this overload for dynamic labels
1073 *
1074 * @param _DefaultSize Initial text size before decreasing
1075 */
1076Void ComponentMenuLibsTools_FitLabelValue(CMlLabel _Label_Target, Real _DefaultSize, Real _MinTextSize, Real _TextSizeStep) {
1077 _Label_Target.TextSizeReal = _DefaultSize;
1078 ComponentMenuLibsTools_FitLabelValue(_Label_Target, _MinTextSize, _TextSizeStep);
1079}
1080
1081// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1082/** Format a rank into a top
1083 *
1084 * @param _Rank The rank to format
1085 * @param _PrefixWithTop Prefix the rank with top or not
1086 * @param _FormatLimit Above this limit, format the rank with "K" when above the thousands
1087 * @param _IsFromLiveApi Is the ranking coming from the Live API ?
1088 *
1089 * @return "Top 123", "Top 5K", "123", "5K"
1090 */
1091Text ComponentMenuLibsTools_FormatTop(Integer _Rank, Boolean _PrefixWithTop, Integer _FormatLimit, Boolean _IsFromLiveApi) {
1092 declare Integer Rank = _Rank;
1093 // The `TL::FormatRank()` function will format 1500 as 1K, but for a top it makes more sense to display "Top 2K",
1094 // so we round it up to the superior thousand.
1095 // If the rank comes from the Live API, it will already be rounded correctly above 10000,
1096 // so we don't have to correct the rounding ourselves.
1097 if (_FormatLimit >= 1000 && Rank % 1000 != 0 && Rank >= _FormatLimit && (!_IsFromLiveApi || Rank < ComponentMenuLibsTools_C_LiveApiRankRoundingStart)) {
1098 Rank += 1000;
1099 }
1100 declare Text Top = ""^Rank;
1101 if (Rank >= _FormatLimit) {
1102 Top = ComponentMenuLibsTools_TL::FormatRank(Rank, True);
1103 }
1104 if (_PrefixWithTop) {
1105 Top = ComponentMenuLibsTools_TL::Compose("Top %1", Top);
1106 }
1107 return Top;
1108}
1109Text ComponentMenuLibsTools_FormatTop(Integer _Rank, Boolean _PrefixWithTop, Integer _FormatLimit) {
1110 return ComponentMenuLibsTools_FormatTop(_Rank, _PrefixWithTop, _FormatLimit, True);
1111}
1112Text ComponentMenuLibsTools_FormatTop(Integer _Rank, Boolean _PrefixWithTop) {
1113 return ComponentMenuLibsTools_FormatTop(_Rank, _PrefixWithTop, 1000);
1114}
1115Text ComponentMenuLibsTools_FormatTop(Integer _Rank) {
1116 return ComponentMenuLibsTools_FormatTop(_Rank, True);
1117}
1118
1119// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1120/// Format a time diff to show the least number possible
1121Text ComponentMenuLibsTools_FormatTimeDiff(Integer _TimeDiff) {
1122 declare Text Diff = "";
1123
1124 if (_TimeDiff > -60000 && _TimeDiff < 60000) {
1125 Diff = ComponentMenuLibsTools_TL::FormatReal(_TimeDiff / 1000., 3, False, False);
1126 } else {
1127 Diff = ComponentMenuLibsTools_TL::TimeToText(_TimeDiff, True, True);
1128 }
1129
1130 if (_TimeDiff >= 0) {
1131 Diff = "+"^Diff;
1132 }
1133
1134 return Diff;
1135}
1136
1137// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1138// Check if a controller (keyboard, gamepad, mouse, ...)
1139// was used during the past frame
1140Boolean ComponentMenuLibsTools_ControllerWasUsed(Vec2 _PrevMousePos) {
1141 foreach (Event in PendingEvents) {
1142 if (
1143 Event.Type == CMlScriptEvent::Type::KeyPress ||
1144 Event.Type == CMlScriptEvent::Type::MenuNavigation ||
1145 Event.Type == CMlScriptEvent::Type::MouseClick ||
1146 Event.Type == CMlScriptEvent::Type::MouseRightClick
1147 ) {
1148 return True;
1149 }
1150 }
1151
1152 foreach (Event in Input.PendingEvents) {
1153 if (Event.Type == CInputEvent::EType::PadButtonPress) {
1154 return True;
1155 }
1156 }
1157
1158 if (
1159 _PrevMousePos != Input.MousePos ||
1160 Input.MouseLeftButton ||
1161 Input.MouseRightButton ||
1162 Input.MouseMiddleButton
1163 ) {
1164 return True;
1165 }
1166
1167 return False;
1168}
1169
1170// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1171/**
1172 * Remove completly the given tags in a given string
1173 *
1174 * @param _Source The text to clean
1175 * @param _ForbiddenTags The tags to remove in the source text
1176 */
1177Text ComponentMenuLibsTools_RemoveForbiddenTags(Text _Source, Text[] _ForbiddenTags) {
1178 if (_Source == "") return _Source;
1179
1180 declare Text CleanedText = _Source;
1181
1182 declare Boolean LoopAgain = True;
1183 while (LoopAgain) {
1184 LoopAgain = False;
1185
1186 foreach (Tag in _ForbiddenTags) {
1187 while (ComponentMenuLibsTools_TL::Find(Tag, CleanedText, True, False)) {
1188 CleanedText = ComponentMenuLibsTools_TL::Replace(CleanedText, Tag, "");
1189 LoopAgain = True;
1190 }
1191 }
1192 }
1193
1194 return CleanedText;
1195}
1196
1197
1198// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1199/**
1200 * Remove all $h, $l, \n and \r in the given text
1201 * First, the Regex will remove all the $h[] and $l[] tags, as well as the control characters \n and \r
1202 * Then it will remove the remaining forbidden tags and control characters
1203 *
1204 * @param _ToFormat The text to clean
1205 */
1206Text ComponentMenuLibsTools_FormatValue(Text _ToFormat) {
1207 return ComponentMenuLibsTools_RemoveForbiddenTags(
1208 ComponentMenuLibsTools_TL::RegexReplace("\\$[hl](?:\\[.*\\])?|[\\n\\r]", ComponentMenuLibsTools_TL::Trim(_ToFormat), "gi", ""),
1209 ["$h", "$l", "$<", "$>", "\\n", "\\r"]
1210 );
1211}
1212
1213// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1214/// Use to get only the CountryPath without the region
1215Text ComponentMenuLibsTools_GetCountryPath(Text _ZonePath) {
1216
1217 if (LibTMNextConfig_Get().DefaultMasterZone == "World") {
1218 declare Text[] Zones = ComponentMenuLibsTools_TL::Split("|", _ZonePath);
1219 if (Zones.count <= 3) {
1220 return _ZonePath;
1221 } else {
1222 return ComponentMenuLibsTools_TL::Join("|", ["World", Zones.get(1), Zones.get(2)]);
1223 }
1224 } else { //CN version
1225 return LibTMNextConfig_Get().DefaultMasterZone;
1226 }
1227
1228 return "";
1229}
1230
1231// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1232/** Parse a joinlink in Text format and
1233 * return a structure containing all
1234 * the joinlink parts
1235 */
1236ComponentMenuLibsTools_K_JoinLink ComponentMenuLibsTools_ParseJoinLink(Text _JoinLink) {
1237 declare Text[] Matches = ComponentMenuLibsTools_TL::RegexMatch("""#(\S+)=([^:@\s]+)(?::([^:@\s]+)?(?::([^:@\s]+))?)?(?:@(\S+))?""", _JoinLink, "");
1238 declare ComponentMenuLibsTools_K_JoinLink JoinLink = ComponentMenuLibsTools_K_JoinLink {
1239 Full = Matches[0],
1240 Type = Matches[1],
1241 ServerLoginOrIp = Matches[2],
1242 Password = Matches[3],
1243 Port = Matches[4],
1244 Title = Matches[5]
1245 };
1246 return JoinLink;
1247}
1248
1249// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1250/// Update the full joinlink inside a joinlink structure
1251ComponentMenuLibsTools_K_JoinLink ComponentMenuLibsTools_UpdateJoinLink(ComponentMenuLibsTools_K_JoinLink _JoinLink) {
1252 declare ComponentMenuLibsTools_K_JoinLink JoinLink = _JoinLink;
1253 JoinLink.Full = "#"^JoinLink.Type^"="^JoinLink.ServerLoginOrIp;
1254 if (JoinLink.Password != "") JoinLink.Full ^= ":"^JoinLink.Password;
1255 if (JoinLink.Port != "") {
1256 if (JoinLink.Password != "") JoinLink.Full ^= ":"^JoinLink.Port;
1257 else JoinLink.Full ^= "::"^JoinLink.Port;
1258 }
1259 if (JoinLink.Title != "") JoinLink.Full ^= "@"^JoinLink.Title;
1260 return JoinLink;
1261}
1262
1263// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1264/// Generate a Text joinlink from a joinlink structure
1265Text ComponentMenuLibsTools_GenerateJoinLink(ComponentMenuLibsTools_K_JoinLink _JoinLink) {
1266 return ComponentMenuLibsTools_UpdateJoinLink(_JoinLink).Full;
1267}
1268
1269// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1270/// Return the formatted club tag
1271Text ComponentMenuLibsTools_FormatClubTag(Text _ClubTag) {
1272 if (_ClubTag != "") {
1273 if (ComponentMenuLibsTools_TL::Find("$", _ClubTag, True, False)) {
1274 return "["^ComponentMenuLibsTools_TL::CloseStyleTags("$<"^ComponentMenuLibsTools_RemoveForbiddenTags(ComponentMenuLibsTools_TL::SubText(_ClubTag, 0, ComponentMenuLibsTools_C_TagMaxLength), ComponentMenuLibsTools_C_TagForbiddenTags)^"$>")^"]";
1275 } else {
1276 return "[$<"^ComponentMenuLibsTools_TL::SubText(_ClubTag, 0, ComponentMenuLibsTools_C_TagMaxLength)^"$>]";
1277 }
1278 }
1279 return _ClubTag;
1280}
1281
1282// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1283/// Return the user name with the tag of the user's current club as prefix
1284Text ComponentMenuLibsTools_GetNameWithClubTag(Text _Name, Text _ClubTag) {
1285 if (_ClubTag != "") return ComponentMenuLibsTools_FormatClubTag(_ClubTag)^" $<"^_Name^"$>";
1286 return "$<"^_Name^"$>";
1287}
1288Text ComponentMenuLibsTools_GetNameWithClubTag(CUser _User) {
1289 if (_User == Null) return "";
1290 return ComponentMenuLibsTools_GetNameWithClubTag(_User.Name, _User.ClubTag);
1291}
1292
1293
1294// */
1295// @Component end component-menulibs-tools
1296
1297// @Component start component-modelibs-uimodules
1298// /*
1299
1300ComponentModeLibsUIModules_K_Module[Text] ComponentModeLibsUIModules_Private_UpdateModulesProperties(ComponentModeLibsUIModules_K_Module[Text] _UIModules, ComponentModeLibsUIModules_K_ModuleProperties[Text] _ModulesProperties) {
1301 declare ComponentModeLibsUIModules_K_Module[Text] UIModules = _UIModules;
1302 foreach (ModuleId => Module in _UIModules) {
1303 // Module properties are customized
1304 if (_ModulesProperties.existskey(ModuleId)) {
1305 declare ComponentModeLibsUIModules_K_ModuleProperties ModuleProperties = _ModulesProperties[ModuleId];
1306 Module.Control.RelativePosition_V3 = ModuleProperties.Position;
1307 Module.Control.RelativeScale = ModuleProperties.Scale;
1308 Module.Control.Visible = ModuleProperties.Visible;
1309 UIModules[ModuleId].IsCustom = True;
1310 }
1311 // Module properties are not customized anymore
1312 else if (Module.IsCustom) {
1313 Module.Control.RelativePosition_V3 = Module.DefaultProperties.Position;
1314 Module.Control.RelativeScale = Module.DefaultProperties.Scale;
1315 Module.Control.Visible = Module.DefaultProperties.Visible;
1316 UIModules[ModuleId].IsCustom = False;
1317 }
1318 }
1319 return UIModules;
1320}
1321
1322ComponentModeLibsUIModules_K_Module[Text] ComponentModeLibsUIModules_Private_Initialize() {
1323 // Find UI modules controls
1324 declare ComponentModeLibsUIModules_K_Module[Text] ComponentModeLibsUIModules_UIModules;
1325 Page.GetClassChildren("component-modelibs-uimodules-module", Page.MainFrame, True);
1326 foreach (Control in Page.GetClassChildren_Result) {
1327 declare TrueControlHandle = Control;
1328 assert(TrueControlHandle.ControlId != "", "[UIModules] A UI module CMlControl must have an id");
1329 assert(!ComponentModeLibsUIModules_UIModules.existskey(TrueControlHandle.ControlId), "[UIModules] Two UI modules CMlControl cannot share the same id '"^TrueControlHandle.ControlId^"'");
1330 if (
1331 TrueControlHandle.DataAttributeExists("customizable-module-enabled") &&
1332 ComponentMenuLibsTools_TextToBoolean(TrueControlHandle.DataAttributeGet("customizable-module-enabled"))
1333 ) {
1334 ComponentModeLibsUIModules_UIModules[TrueControlHandle.ControlId] = ComponentModeLibsUIModules_K_Module {
1335 Control = TrueControlHandle,
1336 IsCustom = False,
1337 DefaultProperties = ComponentModeLibsUIModules_K_ModuleProperties {
1338 Position = TrueControlHandle.RelativePosition_V3,
1339 Scale = TrueControlHandle.RelativeScale,
1340 Visible = TrueControlHandle.Visible
1341 }
1342 };
1343 }
1344 }
1345 return ComponentModeLibsUIModules_UIModules;
1346}
1347
1348***MainInit***
1349***
1350declare netread ComponentModeLibsUIModules_K_ModuleProperties[Text] Net_LibUI3_CustomizableModule_Properties for Teams[0];
1351declare netread Integer Net_LibUI3_CustomizableModule_PropertiesUpdate for Teams[0];
1352
1353declare ComponentModeLibsUIModules_K_Module[Text] ComponentModeLibsUIModules_UIModules;
1354***
1355
1356***MainStart***
1357***
1358declare Integer ModulesPropertiesUpdate = Net_LibUI3_CustomizableModule_PropertiesUpdate;
1359
1360ComponentModeLibsUIModules_UIModules = ComponentModeLibsUIModules_Private_Initialize();
1361ComponentModeLibsUIModules_UIModules = ComponentModeLibsUIModules_Private_UpdateModulesProperties(ComponentModeLibsUIModules_UIModules, Net_LibUI3_CustomizableModule_Properties);
1362***
1363
1364***MainLoop***
1365***
1366if (ModulesPropertiesUpdate != Net_LibUI3_CustomizableModule_PropertiesUpdate) {
1367 ModulesPropertiesUpdate = Net_LibUI3_CustomizableModule_PropertiesUpdate;
1368 ComponentModeLibsUIModules_UIModules = ComponentModeLibsUIModules_Private_UpdateModulesProperties(ComponentModeLibsUIModules_UIModules, Net_LibUI3_CustomizableModule_Properties);
1369}
1370***
1371
1372// */
1373// @Component end component-modelibs-uimodules
1374
1375// @Component start share-menu-navigation
1376// /*
1377
1378declare ShareMenuNavigation_K_MenuNavigationEvent[] ShareMenuNavigation_PendingEvents;
1379
1380Boolean ShareMenuNavigation_Private_TextActionExists(Text _Text) {
1381 return ShareMenuNavigation_C_TextToMenuNavAction.existskey(_Text);
1382}
1383
1384CMlScriptEvent::EMenuNavAction ShareMenuNavigation_Private_TextToAction(Text _Text) {
1385 return ShareMenuNavigation_C_TextToMenuNavAction[_Text];
1386}
1387
1388***MainLoop***
1389***
1390ShareMenuNavigation_PendingEvents = [];
1391
1392foreach (Event in PendingEvents) {
1393 switch (Event.Type) {
1394 case CMlScriptEvent::Type::PluginCustomEvent: {
1395 switch (Event.CustomEventType) {
1396 case "ShareMenuNavigation_MenuNavigation": {
1397 if (Event.CustomEventData.count >= 3) {
1398 declare TextAction = Event.CustomEventData[0];
1399 if (ShareMenuNavigation_Private_TextActionExists(TextAction)) {
1400 declare ShareMenuNavigation_K_MenuNavigationEvent MenuNavigationEvent;
1401 MenuNavigationEvent.MenuNavAction = ShareMenuNavigation_Private_TextToAction(TextAction);
1402 MenuNavigationEvent.IsActionAutoRepeat = (ShareMenuNavigation_TL::ToLowerCase(Event.CustomEventData[1]) == "true");
1403 MenuNavigationEvent.UserIndex = ShareMenuNavigation_TL::ToInteger(Event.CustomEventData[2]);
1404 ShareMenuNavigation_PendingEvents.add(MenuNavigationEvent);
1405 }
1406 }
1407 }
1408 }
1409 }
1410 }
1411}
1412***
1413
1414// */
1415// @Component end share-menu-navigation
1416
1417// @Component start component-navigation
1418// /*
1419
1420declare CMlControl[Text][Ident] ComponentNavigation_G_NavigationControls;
1421declare CMlControl[][Text] ComponentNavigation_G_GroupControls;
1422declare Text[Text] ComponentNavigation_G_GroupParent;
1423declare CMlControl[Text] ComponentNavigation_G_Focus;
1424declare CMlControl[Text] ComponentNavigation_G_DefaultFocus;
1425declare Text[] ComponentNavigation_G_DisabledGroups;
1426declare Ident[] ComponentNavigation_G_DisabledContainers;
1427declare ComponentNavigation_K_NavigationEvent[] ComponentNavigation_PendingEvents;
1428declare Boolean ComponentNavigation_G_UseLocalEvents;
1429declare Text[] ComponentNavigation_G_NavigationDisabledBy;
1430declare Integer ComponentNavigation_G_MouseSleepDelay;
1431
1432// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1433// Users authorizations
1434// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1435Boolean ComponentNavigation_IsUserAuthorized(Integer _UserIndex) {
1436 declare Integer[] ComponentNavigation_AuthorizedUserIndexes for This;
1437 //if the array is empty, all users are authorized
1438 if (ComponentNavigation_AuthorizedUserIndexes.count == 0) { return True; }
1439 return ComponentNavigation_AuthorizedUserIndexes.exists(_UserIndex);
1440}
1441
1442Void ComponentNavigation_SetAuthorizedUsers(Integer[] _UserIndexes) {
1443 declare Integer[] ComponentNavigation_AuthorizedUserIndexes for This;
1444 ComponentNavigation_AuthorizedUserIndexes = [];
1445 foreach(UserIndex in _UserIndexes) { ComponentNavigation_AuthorizedUserIndexes.add(UserIndex); }
1446}
1447
1448Void ComponentNavigation_AuthorizeAllUsers() {
1449 ComponentNavigation_SetAuthorizedUsers([]);
1450}
1451
1452// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1453// Containers
1454// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1455
1456/**
1457 * Get the closest container of a given control
1458 *
1459 * @param _Container the control
1460 * @return the closest container
1461 *
1462 */
1463CMlFrame ComponentNavigation_FindClosestContainer(CMlControl _Control) {
1464 if (_Control != Null && _Control.Parent != Null) {
1465 if (_Control.Parent.HasClass("component-navigation-container")) {
1466 return _Control.Parent;
1467 } else {
1468 return ComponentNavigation_FindClosestContainer(_Control.Parent);
1469 }
1470 }
1471 return Null;
1472}
1473
1474/**
1475 * Get the ident of the closest container of a given control
1476 *
1477 * @param _Container the control
1478 * @return the id of the closest container
1479 *
1480 */
1481Ident ComponentNavigation_Private_FindClosestContainerId(CMlControl _Control) {
1482 declare CMlFrame Container = ComponentNavigation_FindClosestContainer(_Control);
1483 if (Container == Null) return NullId;
1484 return Container.Id;
1485}
1486
1487/**
1488 * Check if the incoming event is from a nested container (and not the global container)
1489 *
1490 * @param _ContainerId the container id
1491 * @return True if the container is nested, False otherwise (global)
1492 *
1493 */
1494Boolean ComponentNavigation_IsEventFromNestedContainer(CMlFrame _Container) {
1495 if (_Container == Null) return False;
1496 assert(ComponentNavigation_G_NavigationControls.existskey(_Container.Id), "[Navigation] The container you provided does not exist");
1497 return _Container.Id != NullId;
1498}
1499
1500/**
1501 * Check if the given container is enabled or not
1502 *
1503 * @param _ContainerId the container id
1504 * @return True if the container is enabled, False otherwise
1505 *
1506 */
1507Boolean ComponentNavigation_IsContainerEnabled(CMlFrame _Container) {
1508 assert(ComponentNavigation_G_NavigationControls.existskey(_Container.Id), "[Navigation] The container you provided does not exist");
1509 return !ComponentNavigation_G_DisabledContainers.exists(_Container.Id);
1510}
1511
1512/**
1513 * Enable or disable the given navigation container
1514 *
1515 * @param _Container the navigation container
1516 * @param _Enable the boolean to enable or disable the navigation container
1517 *
1518 */
1519Void ComponentNavigation_EnableContainer(CMlFrame _Container, Boolean _Enable) {
1520 if (_Container == Null) return;
1521
1522 assert(ComponentNavigation_G_NavigationControls.existskey(_Container.Id), "[Navigation] The container you provided does not exist");
1523
1524 if (_Enable && ComponentNavigation_G_DisabledContainers.exists(_Container.Id)) {
1525 ComponentNavigation_G_DisabledContainers.remove(_Container.Id);
1526 } else if (!_Enable && !ComponentNavigation_G_DisabledContainers.exists(_Container.Id)) {
1527 ComponentNavigation_G_DisabledContainers.add(_Container.Id);
1528 }
1529}
1530
1531/**
1532 * Get all navigation controls inside a given container
1533 * A NullId container will return all current page navigation controls
1534 *
1535 * @param _ContainerId the container id
1536 * @return An array containing controls inside of the given container
1537 *
1538 */
1539CMlControl[Text] ComponentNavigation_GetContainerControls(CMlFrame _Container) {
1540 if (!ComponentNavigation_G_NavigationControls.existskey(_Container.Id)) return [];
1541 return ComponentNavigation_G_NavigationControls[_Container.Id];
1542}
1543
1544// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1545// Groups
1546// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1547
1548// Get all the controls of a group
1549CMlControl[] ComponentNavigation_GetGroupControls(Text _GroupName, CMlControl[] _GroupControls) {
1550 declare CMlControl[] GroupControls = _GroupControls;
1551 if (ComponentNavigation_G_GroupControls.existskey(_GroupName)) {
1552 foreach (Control in ComponentNavigation_G_GroupControls[_GroupName]) {
1553 if (!GroupControls.exists(Control)) GroupControls.add(Control);
1554 }
1555 }
1556 if (ComponentNavigation_G_GroupParent.exists(_GroupName)) {
1557 foreach (Child => Parent in ComponentNavigation_G_GroupParent) {
1558 if (Parent == _GroupName) {
1559 declare CMlControl[] ChildControls = ComponentNavigation_GetGroupControls(Child, GroupControls);
1560 foreach (Control in ChildControls) {
1561 if (!GroupControls.exists(Control)) GroupControls.add(Control);
1562 }
1563 }
1564 }
1565 }
1566 return GroupControls;
1567}
1568CMlControl[] ComponentNavigation_GetGroupControls(Text _GroupName) {
1569 return ComponentNavigation_GetGroupControls(_GroupName, []);
1570}
1571CMlControl[] ComponentNavigation_GetGroupControls() {
1572 return ComponentNavigation_GetGroupControls("");
1573}
1574
1575// Get the group name of a control
1576Text ComponentNavigation_GetControlGroupName(CMlControl _Control) {
1577 if (_Control == Null) return "";
1578
1579 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1580
1581 return ComponentNavigation_NavigationProperties.Group;
1582}
1583
1584// Get the group hierarchy of a control
1585Text[] ComponentNavigation_Private_GetGroupHierarchy(Text _Group, Text[] _Groups, Boolean _AssertCircularRelationship) {
1586 declare Text[] Groups = _Groups;
1587 if (_AssertCircularRelationship) {
1588 assert(!Groups.exists(_Group), "[Navigation] You are creating a circular relationship. Hierarchy: "^Groups^" | Add: "^_Group);
1589 }
1590 Groups.add(_Group);
1591 if (ComponentNavigation_G_GroupParent.existskey(_Group)) {
1592 Groups = ComponentNavigation_Private_GetGroupHierarchy(ComponentNavigation_G_GroupParent[_Group], Groups, _AssertCircularRelationship);
1593 }
1594 return Groups;
1595}
1596Text[] ComponentNavigation_GetGroupHierarchy(Text _Group) {
1597 return ComponentNavigation_Private_GetGroupHierarchy(_Group, [], False);
1598}
1599Text[] ComponentNavigation_GetControlGroups(CMlControl _Control) {
1600 if (_Control == Null) return [];
1601 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1602 return ComponentNavigation_GetGroupHierarchy(ComponentNavigation_NavigationProperties.Group);
1603}
1604Text[] ComponentNavigation_AssertNoCircularRelationship(Text _Group) {
1605 return ComponentNavigation_Private_GetGroupHierarchy(_Group, [], True);
1606}
1607Text ComponentNavigation_GetGroupRoot(Text _Group) {
1608 declare Text Group = _Group;
1609 if (ComponentNavigation_G_GroupParent.existskey(Group)) {
1610 Group = ComponentNavigation_GetGroupRoot(ComponentNavigation_G_GroupParent[Group]);
1611 }
1612 return Group;
1613}
1614
1615// Check if a control is in a group or its parents
1616Boolean ComponentNavigation_Private_GroupIsDescendantFrom(Text _Group, Text _TargetGroup) {
1617 if (_Group == _TargetGroup) {
1618 return True;
1619 } else if (ComponentNavigation_G_GroupParent.existskey(_Group)) {
1620 return ComponentNavigation_Private_GroupIsDescendantFrom(ComponentNavigation_G_GroupParent[_Group], _TargetGroup);
1621 }
1622 return False;
1623}
1624Boolean ComponentNavigation_ControlIsInGroup(CMlControl _Control, Text _Group) {
1625 if (_Control == Null) return False;
1626 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1627 return ComponentNavigation_Private_GroupIsDescendantFrom(ComponentNavigation_NavigationProperties.Group, _Group);
1628}
1629
1630Void ComponentNavigation_SetControlGroupName(CMlControl _Control, Text _GroupName) {
1631 if (_Control == Null) return;
1632
1633 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1634 if (ComponentNavigation_G_GroupControls.existskey(ComponentNavigation_NavigationProperties.Group) && ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group].exists(_Control)) {
1635 ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group].remove(_Control);
1636 if (ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group].count <= 0) {
1637 ComponentNavigation_G_GroupControls.removekey(ComponentNavigation_NavigationProperties.Group);
1638 if (ComponentNavigation_G_Focus.existskey(ComponentNavigation_NavigationProperties.Group)) {
1639 ComponentNavigation_G_Focus.removekey(ComponentNavigation_NavigationProperties.Group);
1640 }
1641 if (ComponentNavigation_G_DefaultFocus.existskey(ComponentNavigation_NavigationProperties.Group)) {
1642 ComponentNavigation_G_DefaultFocus.removekey(ComponentNavigation_NavigationProperties.Group);
1643 }
1644 } else {
1645 if (ComponentNavigation_G_DefaultFocus[ComponentNavigation_NavigationProperties.Group] == _Control) {
1646 ComponentNavigation_G_DefaultFocus[ComponentNavigation_NavigationProperties.Group] = ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group][0];
1647 }
1648 if (ComponentNavigation_G_Focus[ComponentNavigation_NavigationProperties.Group] == _Control) {
1649 ComponentNavigation_G_Focus[ComponentNavigation_NavigationProperties.Group] = ComponentNavigation_G_DefaultFocus[ComponentNavigation_NavigationProperties.Group];
1650 }
1651 }
1652 }
1653
1654 if (!ComponentNavigation_G_GroupControls.existskey(_GroupName)) {
1655 ComponentNavigation_G_GroupControls[_GroupName] = [];
1656 ComponentNavigation_G_Focus[_GroupName] = Null;
1657 ComponentNavigation_G_DefaultFocus[_GroupName] = _Control;
1658 }
1659 ComponentNavigation_G_GroupControls[_GroupName].add(_Control);
1660 ComponentNavigation_NavigationProperties.Group = _GroupName;
1661}
1662
1663Boolean ComponentNavigation_IsEventFromGroup(ComponentNavigation_K_NavigationEvent _Event, Text _GroupName) {
1664 return ComponentNavigation_ControlIsInGroup(_Event.From, _GroupName) || ComponentNavigation_ControlIsInGroup(_Event.To, _GroupName);
1665}
1666
1667// Create/destroy a group hierarchy
1668Void ComponentNavigation_UnsetGroupParent(Text _Child) {
1669 if (!ComponentNavigation_G_GroupParent.existskey(_Child)) return;
1670
1671 declare Text OldParent = ComponentNavigation_G_GroupParent[_Child];
1672 ComponentNavigation_G_GroupParent.removekey(_Child);
1673
1674 // The old parent does not have any children left and it is not associated to any controls
1675 if (!ComponentNavigation_G_GroupParent.exists(OldParent) && !ComponentNavigation_G_GroupControls.existskey(OldParent)) {
1676 ComponentNavigation_G_DefaultFocus.removekey(OldParent);
1677 ComponentNavigation_G_Focus.removekey(OldParent);
1678 }
1679}
1680Void ComponentNavigation_SetGroupParent(Text _Child, Text _Parent) {
1681 if (ComponentNavigation_G_GroupParent.existskey(_Child) && ComponentNavigation_G_GroupParent[_Child] == _Parent) return;
1682
1683 // Destroy previous parent => child relationship
1684 ComponentNavigation_UnsetGroupParent(_Child);
1685
1686 // Create new parent => child relationship
1687 ComponentNavigation_G_GroupParent[_Child] = _Parent;
1688 ComponentNavigation_AssertNoCircularRelationship(_Child);
1689
1690 if (!ComponentNavigation_G_DefaultFocus.existskey(_Parent)) {
1691 ComponentNavigation_G_DefaultFocus[_Parent] = Null;
1692 }
1693 if (ComponentNavigation_G_DefaultFocus[_Parent] == Null && ComponentNavigation_G_DefaultFocus.existskey(_Child)) {
1694 ComponentNavigation_G_DefaultFocus[_Parent] = ComponentNavigation_G_DefaultFocus[_Child];
1695 }
1696 if (!ComponentNavigation_G_Focus.existskey(_Parent)) {
1697 ComponentNavigation_G_Focus[_Parent] = Null;
1698 }
1699 if (ComponentNavigation_G_Focus[_Parent] == Null) {
1700 ComponentNavigation_G_Focus[_Parent] = ComponentNavigation_G_DefaultFocus[_Parent];
1701 }
1702}
1703
1704Void ComponentNavigation_SetChildrenGroupParent(Text[] _Children, Text _Parent) {
1705 foreach (Child in _Children) {
1706 ComponentNavigation_SetGroupParent(Child, _Parent);
1707 }
1708}
1709
1710// Enable or disable the events generated
1711// by the given navigation group
1712CMlControl[] ComponentNavigation_EnableGroup(Text _GroupName, Boolean _Enabled) {
1713 if (_Enabled && ComponentNavigation_G_DisabledGroups.exists(_GroupName)) {
1714 ComponentNavigation_G_DisabledGroups.remove(_GroupName);
1715 } else if (!_Enabled && !ComponentNavigation_G_DisabledGroups.exists(_GroupName)) {
1716 ComponentNavigation_G_DisabledGroups.add(_GroupName);
1717 }
1718 return ComponentNavigation_GetGroupControls(_GroupName);
1719}
1720CMlControl[] ComponentNavigation_EnableGroup(Boolean _Enabled) {
1721 return ComponentNavigation_EnableGroup("", _Enabled);
1722}
1723
1724// Globally (all pages!) discard events
1725// coming from navigation groups other
1726// than the given groups
1727Void ComponentNavigation_SetGlobalSoloGroups(Text[] _Groups) {
1728 declare Text[] ComponentNavigation_SoloGroups for This;
1729 ComponentNavigation_SoloGroups = _Groups;
1730}
1731Void ComponentNavigation_ResetGlobalSoloGroups() {
1732 ComponentNavigation_SetGlobalSoloGroups([]);
1733}
1734Void ComponentNavigation_AddToGlobalSoloGroups(Text[] _GroupList) {
1735 declare Text[] ComponentNavigation_SoloGroups for This;
1736 foreach(Group in _GroupList) {
1737 ComponentNavigation_SoloGroups.add(Group);
1738 }
1739}
1740Void ComponentNavigation_AddToGlobalSoloGroups(Text _Group) {
1741 ComponentNavigation_AddToGlobalSoloGroups([_Group]);
1742}
1743Void ComponentNavigation_RemoveFromGlobalSoloGroups(Text[] _GroupList) {
1744 declare Text[] ComponentNavigation_SoloGroups for This;
1745 foreach(Group in _GroupList) {
1746 ComponentNavigation_SoloGroups.remove(Group);
1747 }
1748}
1749Void ComponentNavigation_RemoveFromGlobalSoloGroups(Text _Group) {
1750 ComponentNavigation_RemoveFromGlobalSoloGroups([_Group]);
1751}
1752Boolean ComponentNavigation_IsGlobalSoloGroup(Text _Group) {
1753 declare Text[] ComponentNavigation_SoloGroups for This;
1754 return (ComponentNavigation_SoloGroups.count <= 0 || ComponentNavigation_SoloGroups.containsoneof(ComponentNavigation_GetGroupHierarchy(_Group)));
1755}
1756Text[] ComponentNavigation_GetGlobalSoloGroups() {
1757 declare Text[] ComponentNavigation_SoloGroups for This;
1758 return ComponentNavigation_SoloGroups;
1759}
1760Boolean ComponentNavigation_IsInGlobalSoloGroups(Text _Group) {
1761 declare Text[] ComponentNavigation_SoloGroups for This;
1762 return ComponentNavigation_SoloGroups.exists(_Group);
1763}
1764
1765// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1766// Navigation
1767// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1768
1769// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
1770/** Create a navigation structure
1771 * than can be passed to the
1772 * data-nav attribute
1773 *
1774 * @param _InputTargets The controls targeted by each input
1775 * @param _Group The navigation group
1776 * @param _Zone The ControlId of the quads that can trigger mouse events
1777 * @param _Focused Is this control focused by default
1778 */
1779Text ComponentNavigation_Inject(Text[Text] _InputTargets, Text _Group, Text _Zone, Boolean _Focused) {
1780 declare ComponentNavigation_K_NavigationSettings NavigationSettings;
1781 NavigationSettings.InputTargets = _InputTargets;
1782 NavigationSettings.Group = _Group;
1783 NavigationSettings.Zone = _Zone;
1784 NavigationSettings.Focused = _Focused;
1785 return NavigationSettings.tojson();
1786}
1787
1788/** Use the local menu navigation events
1789 * instead of the events shared by the
1790 * ShareMenuNavigation component
1791 */
1792Void ComponentNavigation_UseLocalEvents(Boolean _Enable) {
1793 ComponentNavigation_G_UseLocalEvents = _Enable;
1794}
1795
1796// Disable all events generated by the navigation
1797Void ComponentNavigation_EnableNavigation(Boolean _Enabled, Text _Key) {
1798 if (_Enabled) {
1799 ComponentNavigation_G_NavigationDisabledBy.remove(_Key);
1800 } else {
1801 if (!ComponentNavigation_G_NavigationDisabledBy.exists(_Key)) ComponentNavigation_G_NavigationDisabledBy.add(_Key);
1802 }
1803}
1804// The navigation remains disabled until there are no key left in the array
1805Boolean ComponentNavigation_NavigationIsEnabled() {
1806 return ComponentNavigation_G_NavigationDisabledBy.count <= 0;
1807}
1808
1809Boolean ComponentNavigation_IsNavigationControl(CMlControl _Control) {
1810 if (_Control == Null) return False;
1811
1812 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1813 return ComponentNavigation_NavigationProperties.IsInitialized;
1814}
1815
1816// Get the control currently focused
1817// in the given navigation group
1818CMlControl ComponentNavigation_GetFocusedControl(Text _GroupName) {
1819 declare Text GroupRoot = ComponentNavigation_GetGroupRoot(_GroupName);
1820 if (ComponentNavigation_G_Focus.existskey(GroupRoot)) {
1821 return ComponentNavigation_G_Focus[GroupRoot];
1822 }
1823 return Null;
1824}
1825CMlControl ComponentNavigation_GetFocusedControl() {
1826 return ComponentNavigation_GetFocusedControl("");
1827}
1828
1829// Return true if the control is focused
1830// in the given navigation group
1831Boolean ComponentNavigation_IsFocused(CMlControl _Control, Text _GroupName) {
1832 return _Control == ComponentNavigation_GetFocusedControl(_GroupName);
1833}
1834
1835// Reset the focus of a group
1836Void ComponentNavigation_ResetFocus(Text _GroupName) {
1837 ComponentNavigation_G_Focus[ComponentNavigation_GetGroupRoot(_GroupName)] = Null;
1838}
1839Void ComponentNavigation_ResetFocus() {
1840 ComponentNavigation_ResetFocus("");
1841}
1842
1843// Focus the given control
1844Void ComponentNavigation_Focus(CMlControl _Control) {
1845 if (_Control == Null) return;
1846
1847 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1848 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to focus control \""^_Control.ControlId^"\" but it is not a navigation control");
1849
1850 if (ComponentNavigation_NavigationProperties.IsLocked) return;
1851
1852 ComponentNavigation_G_Focus[ComponentNavigation_GetGroupRoot(ComponentNavigation_NavigationProperties.Group)] = _Control;
1853}
1854
1855// Unfocus the given control
1856Void ComponentNavigation_Unfocus(CMlControl _Control) {
1857 if (_Control == Null) return;
1858
1859 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1860 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to unfocus control \""^_Control.ControlId^"\" but it is not a navigation control");
1861
1862 ComponentNavigation_ResetFocus(ComponentNavigation_GetGroupRoot(ComponentNavigation_NavigationProperties.Group));
1863}
1864
1865// Lock/Unlock the given control
1866Void ComponentNavigation_Lock(CMlControl _Control, Boolean _Lock) {
1867 if (_Control == Null) return;
1868
1869 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1870 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to lock control \""^_Control.ControlId^"\" but it is not a navigation control");
1871
1872 ComponentNavigation_NavigationProperties.IsLocked = _Lock;
1873}
1874
1875Boolean ComponentNavigation_IsLocked(CMlControl _Control) {
1876 if (_Control == Null) return False;
1877
1878 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1879 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to see if \""^_Control.ControlId^"\" is locked but it is not a navigation control");
1880
1881 return ComponentNavigation_NavigationProperties.IsLocked;
1882}
1883
1884// Apply an input navigation to a control
1885Void ComponentNavigation_ApplyInput(CMlControl _Control, CMlScriptEvent::EMenuNavAction _Action, Integer _UserIndex, CMlControl[] _ControlChain) {
1886 if (_Control == Null) return;
1887 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties as FromProperties for _Control;
1888 assert(FromProperties.IsInitialized, "[Navigation] You are trying to apply an action on control \""^_Control.ControlId^"\" but it is not a navigation control");
1889
1890 if (FromProperties.Actions.existskey(_Action)) {
1891 declare Target = FromProperties.Actions[_Action];
1892
1893 declare CanApplyInput = ComponentNavigation_IsGlobalSoloGroup(FromProperties.Group);
1894 if (Target != Null) {
1895 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties as ToProperties for Target;
1896 if (ComponentNavigation_G_DisabledGroups.containsoneof(ComponentNavigation_GetGroupHierarchy(ToProperties.Group))) {
1897 CanApplyInput = False;
1898 } else if (!ComponentNavigation_IsGlobalSoloGroup(ToProperties.Group)) {
1899 CanApplyInput = False;
1900 } else if (ComponentNavigation_G_DisabledContainers.count > 0 && ComponentNavigation_G_DisabledContainers.exists(ComponentNavigation_Private_FindClosestContainerId(_Control))) {
1901 CanApplyInput = False;
1902 }
1903
1904 if (CanApplyInput && ToProperties.IsLocked && (!_ControlChain.exists(Target) || Target == _Control)) {
1905 CanApplyInput = False;
1906 if (Target != _Control) {
1907 declare CMlControl[] ControlChain = _ControlChain;
1908 ControlChain.add(Target);
1909 ComponentNavigation_ApplyInput(Target, _Action, _UserIndex, ControlChain);
1910 }
1911 }
1912 }
1913
1914 if (CanApplyInput) {
1915 declare CMlControl OriginalFromControl = _Control;
1916 if (_ControlChain.existskey(0)) OriginalFromControl = _ControlChain[0];
1917
1918 if (!ComponentNavigation_IsLocked(Target)) { // Target Locked here means that the input cannot be applied to any controls in the target's control chain.
1919 declare ComponentNavigation_K_NavigationEvent NavigationEvent = ComponentNavigation_K_NavigationEvent {
1920 Type = ComponentNavigation_C_EventType_NavigateInput,
1921 From = OriginalFromControl,
1922 To = Target,
1923 Input = _Action,
1924 UserIndex = _UserIndex,
1925 Container = ComponentNavigation_FindClosestContainer(Target)
1926 };
1927 ComponentNavigation_PendingEvents.add(NavigationEvent);
1928 }
1929 }
1930 }
1931}
1932
1933// Apply a mouse navigation to a control
1934Void ComponentNavigation_ApplyMouse(CMlControl _Control, CMlScriptEvent::Type _Type, Integer _UserIndex) {
1935 if (_Control == Null) return;
1936
1937 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
1938 if (!ComponentNavigation_NavigationProperties.IsInitialized) return;
1939
1940 declare CMlControl FromControl;
1941 declare Text FromGroupRoot = ComponentNavigation_GetGroupRoot(ComponentNavigation_NavigationProperties.Group);
1942 if (ComponentNavigation_G_Focus.existskey(FromGroupRoot)) {
1943 FromControl = ComponentNavigation_G_Focus[FromGroupRoot];
1944 }
1945
1946 declare CMlControl ToControl;
1947 if (_Type == CMlScriptEvent::Type::MouseClick || _Type == CMlScriptEvent::Type::MouseOver) {
1948 if (ComponentNavigation_NavigationProperties.IsInitialized) {
1949 ToControl = _Control;
1950 }
1951 }
1952
1953 declare CanApplyMouse = ComponentNavigation_IsGlobalSoloGroup(ComponentNavigation_NavigationProperties.Group) && !ComponentNavigation_IsLocked(ToControl);
1954 if (ToControl != Null) {
1955 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties as ToProperties for ToControl;
1956 if (ComponentNavigation_G_DisabledGroups.containsoneof(ComponentNavigation_GetGroupHierarchy(ToProperties.Group))) {
1957 CanApplyMouse = False;
1958 } else if (!ComponentNavigation_IsGlobalSoloGroup(ToProperties.Group)) {
1959 CanApplyMouse = False;
1960 } else if (ComponentNavigation_G_DisabledContainers.count > 0 && ComponentNavigation_G_DisabledContainers.exists(ComponentNavigation_Private_FindClosestContainerId(_Control))) {
1961 CanApplyMouse = False;
1962 }
1963 }
1964
1965 if (CanApplyMouse) {
1966 declare ComponentNavigation_K_NavigationEvent NavigationEvent = ComponentNavigation_K_NavigationEvent {
1967 Type = ComponentNavigation_C_EventType_NavigateMouse,
1968 From = FromControl,
1969 To = ToControl,
1970 Mouse = _Type,
1971 UserIndex = _UserIndex,
1972 Container = ComponentNavigation_FindClosestContainer(ToControl)
1973 };
1974 ComponentNavigation_PendingEvents.add(NavigationEvent);
1975 }
1976}
1977
1978// Trigger a navigation event to the default
1979// focused control of a group
1980Void ComponentNavigation_ApplyDefaultFocus(Text _GroupName, CMlScriptEvent::EMenuNavAction _Action, Integer _UserIndex) {
1981 declare Text GroupRoot = ComponentNavigation_GetGroupRoot(_GroupName);
1982 declare Text[] GroupHierarchy = ComponentNavigation_GetGroupHierarchy(_GroupName);
1983 if (ComponentNavigation_G_DisabledGroups.containsoneof(GroupHierarchy)) return;
1984 if (!ComponentNavigation_G_DefaultFocus.existskey(GroupRoot)) return;
1985 if (!ComponentNavigation_IsGlobalSoloGroup(_GroupName)) return;
1986
1987 declare CMlControl ToControl;
1988 ToControl = ComponentNavigation_G_DefaultFocus[GroupRoot];
1989 if (ComponentNavigation_IsLocked(ToControl)) return;
1990
1991 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for ToControl;
1992 if (!ComponentNavigation_NavigationProperties.IsInitialized || !ComponentNavigation_NavigationProperties.Actions.existskey(_Action)) return;
1993
1994 declare CMlControl FromControl;
1995 if (ComponentNavigation_G_Focus.existskey(GroupRoot)) {
1996 FromControl = ComponentNavigation_G_Focus[GroupRoot];
1997 }
1998
1999 declare ComponentNavigation_K_NavigationEvent NavigationEvent = ComponentNavigation_K_NavigationEvent {
2000 Type = ComponentNavigation_C_EventType_NavigateInput,
2001 From = FromControl,
2002 To = ToControl,
2003 Input = _Action,
2004 UserIndex = _UserIndex,
2005 Container = ComponentNavigation_FindClosestContainer(ToControl)
2006 };
2007 ComponentNavigation_PendingEvents.add(NavigationEvent);
2008}
2009Void ComponentNavigation_ApplyDefaultFocus(Text _GroupName, Integer _UserIndex) {
2010 ComponentNavigation_ApplyDefaultFocus(_GroupName, CMlScriptEvent::EMenuNavAction::Down, _UserIndex);
2011}
2012Void ComponentNavigation_ApplyDefaultFocuses(CMlScriptEvent::EMenuNavAction _Action, Integer _UserIndex) {
2013 foreach (GroupName => Control in ComponentNavigation_G_DefaultFocus) {
2014 ComponentNavigation_ApplyDefaultFocus(GroupName, _Action, _UserIndex);
2015 }
2016}
2017Void ComponentNavigation_ApplyDefaultFocuses(Integer _UserIndex) {
2018 ComponentNavigation_ApplyDefaultFocuses(CMlScriptEvent::EMenuNavAction::Down, _UserIndex);
2019}
2020
2021CMlControl ComponentNavigation_Private_GetActivationZoneParent(CMlControl _Control) {
2022 if (_Control == Null) return _Control;
2023
2024 declare CMlControl ComponentNavigation_ParentNavigationControl for _Control;
2025 if (ComponentNavigation_ParentNavigationControl == Null) {
2026 return _Control;
2027 }
2028
2029 return ComponentNavigation_ParentNavigationControl;
2030}
2031
2032CMlScriptEvent::EMenuNavAction ComponentNavigation_Private_TextToAction(Text _Text) {
2033 declare ActionText = ComponentNavigation_TL::ToLowerCase(_Text);
2034
2035 switch (_Text) {
2036 case "up": return CMlScriptEvent::EMenuNavAction::Up;
2037 case "right": return CMlScriptEvent::EMenuNavAction::Right;
2038 case "left": return CMlScriptEvent::EMenuNavAction::Left;
2039 case "down": return CMlScriptEvent::EMenuNavAction::Down;
2040 case "select": return CMlScriptEvent::EMenuNavAction::Select;
2041 case "cancel": return CMlScriptEvent::EMenuNavAction::Cancel;
2042 case "pageup": return CMlScriptEvent::EMenuNavAction::PageUp;
2043 case "pagedown": return CMlScriptEvent::EMenuNavAction::PageDown;
2044 case "appmenu": return CMlScriptEvent::EMenuNavAction::AppMenu;
2045 case "action1": return CMlScriptEvent::EMenuNavAction::Action1;
2046 case "action2": return CMlScriptEvent::EMenuNavAction::Action2;
2047 case "scrollup": return CMlScriptEvent::EMenuNavAction::ScrollUp;
2048 case "scrolldown": return CMlScriptEvent::EMenuNavAction::ScrollDown;
2049 }
2050
2051 return CMlScriptEvent::EMenuNavAction::Select;
2052}
2053
2054/**
2055 * Enable or disable all navigation inputs on a given CMlControl
2056 *
2057 * @param _Control the given CMlControl
2058 * @param _Enable the boolean to enable or disable all navigation inputs
2059 *
2060 */
2061Void ComponentNavigation_EnableInputs(CMlControl _Control, Boolean _Enable) {
2062 if (_Control == Null) return;
2063
2064 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
2065 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to get \""^_Control.ControlId^"\" target but it is not a navigation control");
2066
2067 if (_Enable) {
2068 ComponentNavigation_NavigationProperties.Actions = ComponentNavigation_NavigationProperties.SavedActions;
2069 } else {
2070 ComponentNavigation_NavigationProperties.Actions = [];
2071 }
2072}
2073
2074/**
2075 * Enable or disable given navigation inputs on a given CMlControl
2076 *
2077 * @param _Control the given CMlControl
2078 * @param _Inputs the inputs list ("right", "left", etc.)
2079 * @param _Enable the boolean to enable or disable given navigation inputs
2080 *
2081 */
2082Void ComponentNavigation_EnableInputs(CMlControl _Control, Text[] _Inputs, Boolean _Enable) {
2083 if (_Control == Null) return;
2084
2085 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
2086 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to get \""^_Control.ControlId^"\" target but it is not a navigation control");
2087
2088 foreach (Input in _Inputs) {
2089 declare CMlScriptEvent::EMenuNavAction Action = ComponentNavigation_Private_TextToAction(Input);
2090 if (_Enable && ComponentNavigation_NavigationProperties.SavedActions.existskey(Action)) {
2091 ComponentNavigation_NavigationProperties.Actions[Action] = ComponentNavigation_NavigationProperties.SavedActions[Action];
2092 } else if (!_Enable && ComponentNavigation_NavigationProperties.Actions.existskey(Action)) {
2093 ComponentNavigation_NavigationProperties.Actions.remove(ComponentNavigation_NavigationProperties.Actions[Action]);
2094 }
2095 }
2096}
2097
2098CMlControl ComponentNavigation_GetControlTarget(CMlControl _Control, CMlScriptEvent::EMenuNavAction _Action) {
2099 if (_Control == Null) return Null;
2100
2101 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
2102 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to get \""^_Control.ControlId^"\" target but it is not a navigation control");
2103
2104 if (!ComponentNavigation_NavigationProperties.Actions.existskey(_Action)) return Null;
2105
2106 return ComponentNavigation_NavigationProperties.Actions[_Action];
2107}
2108CMlControl ComponentNavigation_GetControlTarget(CMlControl _Control, Text _Action) {
2109 return ComponentNavigation_GetControlTarget(_Control, ComponentNavigation_Private_TextToAction(_Action));
2110}
2111
2112Void ComponentNavigation_ChangeControlTarget(CMlControl _Container, CMlControl _Control, Text _Action, Text _TargetControlId) {
2113 if (_Control == Null) return;
2114
2115 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
2116 assert(ComponentNavigation_NavigationProperties.IsInitialized, "[Navigation] You are trying to change \""^_Control.ControlId^"\" target but it is not a navigation control");
2117
2118 declare Ident ContainerId = NullId;
2119 if (_Container != Null) ContainerId = _Container.Id;
2120 assert(ComponentNavigation_G_NavigationControls.existskey(ContainerId), "[Navigation] The container you provided does not exist");
2121
2122 if (ComponentNavigation_G_NavigationControls[ContainerId].existskey(_TargetControlId)) {
2123 ComponentNavigation_NavigationProperties.Actions[ComponentNavigation_Private_TextToAction(_Action)] = ComponentNavigation_G_NavigationControls[ContainerId][_TargetControlId];
2124 } else if (_TargetControlId == "_" || _TargetControlId == "") {
2125 ComponentNavigation_NavigationProperties.Actions[ComponentNavigation_Private_TextToAction(_Action)] = ComponentNavigation_G_NavigationControls[ContainerId][_Control.ControlId];
2126 }
2127
2128 ComponentNavigation_NavigationProperties.SavedActions = ComponentNavigation_NavigationProperties.Actions;
2129}
2130Void ComponentNavigation_ChangeControlTarget(CMlControl _Control, Text _Action, Text _TargetControlId) {
2131 ComponentNavigation_ChangeControlTarget(Null, _Control, _Action, _TargetControlId);
2132}
2133Void ComponentNavigation_ChangeControlTargets(CMlControl _Control, Text[] _Action, Text[] _TargetControlId) {
2134 foreach (Index => Action in _Action) {
2135 ComponentNavigation_ChangeControlTarget(Null, _Control, Action, _TargetControlId[Index]);
2136 }
2137}
2138
2139Void ComponentNavigation_Private_InitNavigationControl(Ident _ContainerId, CMlControl _Control) {
2140 if (_Control == Null) return;
2141
2142 assert(ComponentNavigation_G_NavigationControls.existskey(_ContainerId), "[Navigation] Invalid container id '"^_ContainerId^"'");
2143
2144 declare ComponentNavigation_K_NavigationProperties ComponentNavigation_NavigationProperties for _Control;
2145 declare UseNavigationSettings = _Control.DataAttributeExists("nav");
2146 declare ComponentNavigation_K_NavigationSettings NavigationSettings;
2147 declare CMlScriptEvent::EMenuNavAction[] Actions;
2148 declare CMlControl[] Targets;
2149
2150 if (UseNavigationSettings) {
2151 declare NavigationSettingsJson = _Control.DataAttributeGet("nav");
2152 declare Success = NavigationSettings.fromjson(NavigationSettingsJson);
2153
2154 foreach (ActionText => TargetControlId in NavigationSettings.InputTargets) {
2155 Actions.add(ComponentNavigation_Private_TextToAction(ActionText));
2156 if ((TargetControlId == "" || TargetControlId == "_") && ComponentNavigation_G_NavigationControls[_ContainerId].existskey(_Control.ControlId)) {
2157 Targets.add(ComponentNavigation_G_NavigationControls[_ContainerId][_Control.ControlId]);
2158 } else if (ComponentNavigation_G_NavigationControls[_ContainerId].existskey(TargetControlId)) {
2159 Targets.add(ComponentNavigation_G_NavigationControls[_ContainerId][TargetControlId]);
2160 } else {
2161 Targets.add(Null);
2162 }
2163 }
2164 } else {
2165 if (_Control.DataAttributeExists("nav-inputs")) {
2166 declare ActionsText = _Control.DataAttributeGet("nav-inputs");
2167 declare ActionsTextSplit = ComponentNavigation_TL::Split(";", ActionsText);
2168 foreach (ActionText in ActionsTextSplit) {
2169 Actions.add(ComponentNavigation_Private_TextToAction(ActionText));
2170 }
2171 }
2172
2173 if (_Control.DataAttributeExists("nav-targets")) {
2174 declare TargetControlIds = _Control.DataAttributeGet("nav-targets");
2175 declare TargetControlIdsSplit = ComponentNavigation_TL::Split(";", TargetControlIds);
2176 foreach (TargetControlId in TargetControlIdsSplit) {
2177 if (TargetControlId == "_" && ComponentNavigation_G_NavigationControls[_ContainerId].existskey(_Control.ControlId)) {
2178 Targets.add(ComponentNavigation_G_NavigationControls[_ContainerId][_Control.ControlId]);
2179 } else if (ComponentNavigation_G_NavigationControls[_ContainerId].existskey(TargetControlId)) {
2180 Targets.add(ComponentNavigation_G_NavigationControls[_ContainerId][TargetControlId]);
2181 } else {
2182 Targets.add(Null);
2183 }
2184 }
2185 }
2186 }
2187
2188 assert(Actions.count == Targets.count, "[Navigation] You must set the same number of actions and targets in the data attributes of control \""^_Control.ControlId^"\"");
2189
2190 ComponentNavigation_NavigationProperties.IsInitialized = True;
2191
2192 ComponentNavigation_NavigationProperties.Actions = [];
2193 foreach (Key => Action in Actions) {
2194 if (Targets.existskey(Key)) {
2195 ComponentNavigation_NavigationProperties.Actions[Action] = Targets[Key];
2196 }
2197 }
2198 ComponentNavigation_NavigationProperties.SavedActions = ComponentNavigation_NavigationProperties.Actions;
2199
2200 declare IsDefaultFocus = False;
2201 if (UseNavigationSettings) {
2202 IsDefaultFocus = NavigationSettings.Focused;
2203 ComponentNavigation_NavigationProperties.IsLocked = NavigationSettings.Locked;
2204 } else {
2205 if (_Control.DataAttributeExists("nav-selected")) {
2206 declare SelectedText = _Control.DataAttributeGet("nav-selected");
2207 if (SelectedText != "" && SelectedText != "0" && ComponentNavigation_TL::ToLowerCase(SelectedText) != "false") {
2208 IsDefaultFocus = True;
2209 }
2210 }
2211 if (_Control.DataAttributeExists("nav-locked")) {
2212 declare LockedText = _Control.DataAttributeGet("nav-locked");
2213 if (LockedText != "" && LockedText != "0" && ComponentNavigation_TL::ToLowerCase(LockedText) != "false") {
2214 ComponentNavigation_NavigationProperties.IsLocked = True;
2215 }
2216 }
2217 }
2218
2219 if (_Control is CMlFrame) {
2220 declare UseZone = False;
2221 declare ZoneControlId = "";
2222 if (UseNavigationSettings) {
2223 ZoneControlId = NavigationSettings.Zone;
2224 UseZone = True;
2225 } else if (_Control.DataAttributeExists("nav-zone")) {
2226 ZoneControlId = _Control.DataAttributeGet("nav-zone");
2227 UseZone = True;
2228 }
2229 if (UseZone) {
2230 Page.GetClassChildren("component-navigation-item-zone", (_Control as CMlFrame), True);
2231 foreach (ActivationZone in Page.GetClassChildren_Result) {
2232 if (ActivationZone.ControlId == ZoneControlId) {
2233 declare CMlControl ComponentNavigation_ParentNavigationControl for ActivationZone;
2234 ComponentNavigation_ParentNavigationControl = _Control;
2235 }
2236 }
2237 }
2238 }
2239
2240 ComponentNavigation_NavigationProperties.Group = "";
2241 if (UseNavigationSettings) {
2242 ComponentNavigation_NavigationProperties.Group = NavigationSettings.Group;
2243 } else if (_Control.DataAttributeExists("nav-group")) {
2244 ComponentNavigation_NavigationProperties.Group = _Control.DataAttributeGet("nav-group");
2245 }
2246
2247 if (!ComponentNavigation_G_GroupControls.existskey(ComponentNavigation_NavigationProperties.Group)) {
2248 ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group] = [];
2249 ComponentNavigation_G_Focus[ComponentNavigation_NavigationProperties.Group] = Null;
2250 ComponentNavigation_G_DefaultFocus[ComponentNavigation_NavigationProperties.Group] = _Control;
2251 }
2252 ComponentNavigation_G_GroupControls[ComponentNavigation_NavigationProperties.Group].add(_Control);
2253 if (IsDefaultFocus) {
2254 ComponentNavigation_G_DefaultFocus[ComponentNavigation_NavigationProperties.Group] = _Control;
2255 }
2256}
2257
2258Void ComponentNavigation_Initialize() {
2259 ComponentNavigation_G_NavigationControls = [NullId => []];
2260 ComponentNavigation_G_GroupControls = [];
2261 ComponentNavigation_G_Focus = [];
2262 ComponentNavigation_G_DefaultFocus = [];
2263 ComponentNavigation_G_DisabledGroups = [];
2264 ComponentNavigation_G_DisabledContainers = [];
2265 ComponentNavigation_G_NavigationDisabledBy = [];
2266
2267 ComponentNavigation_UseLocalEvents(False);
2268
2269 Page.GetClassChildren("component-navigation-item-zone", Page.MainFrame, True);
2270 foreach (Control in Page.GetClassChildren_Result) {
2271 declare CMlControl ComponentNavigation_ParentNavigationControl for Control;
2272 ComponentNavigation_ParentNavigationControl = Null;
2273 }
2274
2275 // Find containers
2276 declare CMlControl[] Containers;
2277 Page.GetClassChildren("component-navigation-container", Page.MainFrame, True);
2278 foreach (Control in Page.GetClassChildren_Result) {
2279 declare TrueControlHandle = Control;
2280 Containers.add(TrueControlHandle);
2281 ComponentNavigation_G_NavigationControls[TrueControlHandle.Id] = [];
2282 }
2283 foreach (Container in Containers) {
2284 Page.GetClassChildren("component-navigation-item", Page.MainFrame, True);
2285 foreach (Control in Page.GetClassChildren_Result) {
2286 declare Boolean ComponentNavigation_IsInsideContainer for Control;
2287 ComponentNavigation_IsInsideContainer = True;
2288 }
2289 }
2290
2291 // Find navigation controls
2292 Page.GetClassChildren("component-navigation-item", Page.MainFrame, True);
2293 foreach (Control in Page.GetClassChildren_Result) {
2294 declare TrueControlHandle = Control;
2295 assert(Control.ControlId != "", "[Navigation] A navigation control must have an id");
2296
2297 // Find container id
2298 declare Boolean ComponentNavigation_IsInsideContainer for TrueControlHandle = False;
2299 declare Ident ContainerId = NullId;
2300 if (ComponentNavigation_IsInsideContainer) {
2301 ContainerId = ComponentNavigation_Private_FindClosestContainerId(TrueControlHandle);
2302 }
2303
2304 assert(!ComponentNavigation_G_NavigationControls[ContainerId].existskey(TrueControlHandle.ControlId), "[Navigation] Two navigation controls cannot share the same id '"^TrueControlHandle.ControlId^"' in the same container '"^ContainerId^"'");
2305 ComponentNavigation_G_NavigationControls[ContainerId][TrueControlHandle.ControlId] = TrueControlHandle;
2306 }
2307 foreach (ContainerId => Controls in ComponentNavigation_G_NavigationControls) {
2308 foreach (Control in Controls) {
2309 ComponentNavigation_Private_InitNavigationControl(ContainerId, Control);
2310 }
2311 }
2312}
2313
2314Void ComponentNavigation_UpdateNavigationSettings(CMlControl _Control, Text _NavigationSettings) {
2315 if (_Control == Null || !_Control.DataAttributeExists("nav")) return;
2316
2317 _Control.DataAttributeSet("nav", _NavigationSettings);
2318 ComponentNavigation_Initialize();
2319}
2320
2321Boolean ComponentNavigation_MouseIsSleeping() {
2322 return (ComponentNavigation_G_MouseSleepDelay >= 0 && Input.TimeSinceLatestMouseActivity >= ComponentNavigation_G_MouseSleepDelay);
2323}
2324
2325// Use a negative value to disable
2326Void ComponentNavigation_SetMouseSleepDelay(Integer _Delay) {
2327 ComponentNavigation_G_MouseSleepDelay = _Delay;
2328}
2329
2330Integer ComponentNavigation_GetMouseSleepDelay() {
2331 return ComponentNavigation_G_MouseSleepDelay;
2332}
2333***MainInit***
2334***
2335ComponentNavigation_Initialize();
2336ComponentNavigation_SetMouseSleepDelay(ComponentNavigation_C_MouseSleepDelay);
2337***
2338
2339***MainLoop***
2340***
2341ComponentNavigation_PendingEvents = [];
2342
2343if (PageIsVisible && ComponentNavigation_NavigationIsEnabled()) {
2344 foreach (Event in PendingEvents) {
2345 switch (Event.Type) {
2346 case CMlScriptEvent::Type::MouseClick: {
2347 ComponentNavigation_ApplyMouse(ComponentNavigation_Private_GetActivationZoneParent(Event.Control), Event.Type, 0);
2348 }
2349 case CMlScriptEvent::Type::MouseRightClick: {
2350 ComponentNavigation_ApplyMouse(ComponentNavigation_Private_GetActivationZoneParent(Event.Control), Event.Type, 0);
2351 }
2352 case CMlScriptEvent::Type::MouseOver: {
2353 if (!ComponentNavigation_MouseIsSleeping()) {
2354 ComponentNavigation_ApplyMouse(ComponentNavigation_Private_GetActivationZoneParent(Event.Control), Event.Type, 0);
2355 }
2356 }
2357 case CMlScriptEvent::Type::MouseOut: {
2358 if (!ComponentNavigation_MouseIsSleeping()) {
2359 ComponentNavigation_ApplyMouse(ComponentNavigation_Private_GetActivationZoneParent(Event.Control), Event.Type, 0);
2360 }
2361 }
2362 case CMlScriptEvent::Type::MenuNavigation: {
2363 if (ComponentNavigation_G_UseLocalEvents) {
2364 foreach (GroupName => Control in ComponentNavigation_G_Focus) {
2365 // Only the group root can be focused and generate events
2366 if (!ComponentNavigation_G_GroupParent.existskey(GroupName)) {
2367 // If no control in the group was focus, then focus the default one
2368 if (Control == Null) {
2369 ComponentNavigation_ApplyDefaultFocus(GroupName, Event.MenuNavAction, 0);
2370 } else {
2371 // Only apply one input per yield to each control
2372 declare Integer ComponentNavigation_PreviousInputTime for Control;
2373 if (ComponentNavigation_PreviousInputTime != Now) {
2374 ComponentNavigation_PreviousInputTime = Now;
2375 ComponentNavigation_ApplyInput(Control, Event.MenuNavAction, 0, [Control]);
2376 }
2377 }
2378 }
2379 }
2380 }
2381 }
2382 }
2383 }
2384
2385 if (!ComponentNavigation_G_UseLocalEvents) {
2386 foreach (Event in ShareMenuNavigation_PendingEvents) {
2387 if (ComponentNavigation_IsUserAuthorized(Event.UserIndex)) {
2388 foreach (GroupName => Control in ComponentNavigation_G_Focus) {
2389 // Only the group root can be focused and generate events
2390 if (!ComponentNavigation_G_GroupParent.existskey(GroupName)) {
2391 // If no control in the group was focus, then focus the default one
2392 if (Control == Null) {
2393 ComponentNavigation_ApplyDefaultFocus(GroupName, Event.MenuNavAction, Event.UserIndex);
2394 } else {
2395 // Only apply one input per yield to each control
2396 declare Integer ComponentNavigation_PreviousInputTime for Control;
2397 if (ComponentNavigation_PreviousInputTime != Now) {
2398 ComponentNavigation_PreviousInputTime = Now;
2399 ComponentNavigation_ApplyInput(Control, Event.MenuNavAction, Event.UserIndex, [Control]);
2400 }
2401 }
2402 }
2403 }
2404 }
2405 }
2406 }
2407}
2408***
2409
2410// */
2411// @Component end component-navigation
2412
2413// @Component start component-commonlibs-audio-manager
2414// /*
2415
2416/** Play sound according to its name
2417 *
2418 * @param The name of the sound
2419 */
2420Void ComponentCommonLibsAudioManager_PlaySound(Text _SoundName, Real _PanRadiusLfeX) {
2421 SendCustomEvent("Event_PlaySound", [_SoundName, ""^_PanRadiusLfeX]);
2422}
2423Void ComponentCommonLibsAudioManager_PlaySound(Text _SoundName) {
2424 ComponentCommonLibsAudioManager_PlaySound(_SoundName, 0.);
2425}
2426
2427/** Stop sound according to its name
2428 *
2429 * @param The name of the sound
2430 */
2431Void ComponentCommonLibsAudioManager_StopSound(Text _SoundName) {
2432 SendCustomEvent("Event_StopSound", [_SoundName]);
2433}
2434Void ComponentCommonLibsAudioManager_StopSound(Text _SoundName, Boolean _RestartSound) {
2435 declare Text RestartSound = "False";
2436 if (_RestartSound) RestartSound = "True";
2437 SendCustomEvent("Event_StopSound", [_SoundName, RestartSound]);
2438}
2439
2440/** Stop all sounds
2441 */
2442Void ComponentCommonLibsAudioManager_StopAllSounds() {
2443 SendCustomEvent("Event_StopAllSounds", []);
2444}
2445
2446/** Change sound balance for scene, UI and music
2447 */
2448Void ComponentCommonLibsAudioManager_SetNewSoundBalance(Integer _NewState, Integer _FadeTime) {
2449 SendCustomEvent("Event_SetNewSoundBalance", [""^_NewState, ""^ _FadeTime]);
2450}
2451
2452/// Update sound fade duration
2453Void ComponentCommonLibsAudioManager_SetFadeDuration(Text _SoundName, Real _FadeDuration) {
2454 SendCustomEvent("Event_SetFadeDuration", [_SoundName, ""^_FadeDuration]);
2455}
2456
2457// */
2458// @Component end component-commonlibs-audio-manager
2459
2460// @Component start component-popupbackground
2461// /*
2462
2463declare ComponentPopUpBackground_K_Event[] ComponentPopUpBackground_PendingEvents;
2464declare Integer[CMlQuad] G_DownloadInProgress;
2465
2466Void ComponentPopUpBackground_LeavePopUp(CMlFrame _Frame_PopUpBackground, Boolean _FromCloseButton) {
2467 declare CMlControl Button_Leave = _Frame_PopUpBackground.GetFirstChild("ComponentPopUpBackground_button-leave");
2468 Button_Leave.RelativeScale = 1.;
2469
2470 declare Text ComponentPopUpBackground_PopUpName for _Frame_PopUpBackground;
2471 ComponentPopUpBackground_PendingEvents.add(ComponentPopUpBackground_K_Event {
2472 Type = ComponentPopUpBackground_C_Event_LeavePopUp,
2473 PopUpName = ComponentPopUpBackground_PopUpName,
2474 FromCloseButton = _FromCloseButton
2475 });
2476}
2477Void ComponentPopUpBackground_LeavePopUp(CMlFrame _Frame_PopUpBackground) {
2478 ComponentPopUpBackground_LeavePopUp(_Frame_PopUpBackground, False);
2479}
2480
2481Void TempDisableAlphaMask (CMlQuad _Quad, ComponentPopUpBackground_K_Image _ImageProperties) {
2482 if (_ImageProperties.Url != "") {
2483 // Disable alpha mask and re-enable once the image is downloaded
2484 // to avoid a bug where the image is stretch (see: trackmania-next/tmnext/-/issues/749)
2485 declare Text ComponentPopUpBackground_AlphaMaskUrl for _Quad;
2486 declare Real ComponentPopUpBackground_Opacity for _Quad;
2487 ComponentPopUpBackground_AlphaMaskUrl = _ImageProperties.AlphaMask;
2488 ComponentPopUpBackground_Opacity = _ImageProperties.Opacity;
2489 _Quad.Opacity = 0.;
2490 _Quad.AlphaMaskUrl = "";
2491 AnimMgr.Flush(_Quad);
2492 G_DownloadInProgress[_Quad] = Now;
2493 }
2494}
2495
2496Void ComponentPopUpBackground_ApplyProperties(CMlFrame _Frame_Container, ComponentPopUpBackground_K_Properties _Properties) {
2497 declare Quad_Header <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-header") as CMlQuad);
2498 declare Quad_HeaderBG <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-bg-header") as CMlQuad);
2499 declare Quad_BG <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-bg") as CMlQuad);
2500 declare Quad_Overlay <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-overlay") as CMlQuad);
2501 declare Quad_Footer <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-footer") as CMlQuad);
2502 declare Button_Leave <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_button-leave") as CMlQuad);
2503 declare Quad_HeaderOverlay <=> (_Frame_Container.GetFirstChild("ComponentPopUpBackground_quad-header-overlay") as CMlQuad);
2504
2505 // TO SET BEFORE TEMP DISABLE ALPHAMASK METHOD
2506 Quad_HeaderBG.AlphaMaskUrl = _Properties.HeaderBackground.AlphaMask;
2507 Quad_BG.AlphaMaskUrl = _Properties.Background.AlphaMask;
2508 Quad_Overlay.AlphaMaskUrl = _Properties.Overlay.AlphaMask;
2509 Quad_Footer.AlphaMaskUrl = _Properties.Footer.AlphaMask;
2510 Button_Leave.AlphaMaskUrl = _Properties.CloseButton.AlphaMask;
2511 Quad_HeaderOverlay.AlphaMaskUrl = _Properties.HeaderOverlay.AlphaMask;
2512 Quad_Header.AlphaMaskUrl = _Properties.Header.AlphaMask;
2513
2514 // TO SET BEFORE TEMP DISABLE ALPHAMASK METHOD
2515 Quad_HeaderBG.Opacity = _Properties.HeaderBackground.Opacity;
2516 Quad_BG.Opacity = _Properties.Background.Opacity;
2517 Quad_Overlay.Opacity = _Properties.Overlay.Opacity;
2518 Quad_Footer.Opacity = _Properties.Footer.Opacity;
2519 Button_Leave.Opacity = _Properties.CloseButton.Opacity;
2520 Quad_HeaderOverlay.Opacity = _Properties.HeaderOverlay.Opacity;
2521 Quad_Header.Opacity = _Properties.Header.Opacity;
2522
2523 Quad_HeaderBG.ChangeImageUrl(_Properties.HeaderBackground.Url);
2524 if (Quad_HeaderBG.DownloadInProgress) TempDisableAlphaMask(Quad_HeaderBG, _Properties.HeaderBackground);
2525
2526 Quad_BG.ChangeImageUrl(_Properties.Background.Url);
2527 if (Quad_BG.DownloadInProgress) TempDisableAlphaMask(Quad_BG, _Properties.Background);
2528
2529 Quad_Overlay.ChangeImageUrl(_Properties.Overlay.Url);
2530 if (Quad_Overlay.DownloadInProgress) TempDisableAlphaMask(Quad_Overlay, _Properties.Overlay);
2531
2532 Quad_Footer.ChangeImageUrl(_Properties.Footer.Url);
2533 if (Quad_Footer.DownloadInProgress) TempDisableAlphaMask(Quad_Footer, _Properties.Footer);
2534
2535 Button_Leave.ChangeImageUrl(_Properties.CloseButton.Url);
2536 if (Button_Leave.DownloadInProgress) TempDisableAlphaMask(Button_Leave, _Properties.CloseButton);
2537
2538 Quad_HeaderOverlay.ChangeImageUrl(_Properties.HeaderOverlay.Url);
2539 if (Quad_HeaderOverlay.DownloadInProgress) TempDisableAlphaMask(Quad_HeaderOverlay, _Properties.HeaderOverlay);
2540
2541 Quad_Header.ChangeImageUrl(_Properties.Header.Url);
2542 if (Quad_Header.DownloadInProgress) TempDisableAlphaMask(Quad_Header, _Properties.Header);
2543
2544 if (_Properties.HeaderBackground.Size != <-1., -1.>) {
2545 Quad_HeaderBG.Size = _Properties.HeaderBackground.Size;
2546 }
2547 if (_Properties.Background.Size != <-1., -1.>) {
2548 Quad_BG.Size = _Properties.Background.Size;
2549 }
2550 if (_Properties.Overlay.Size != <-1., -1.>) {
2551 Quad_Overlay.Size = _Properties.Overlay.Size;
2552 }
2553 if (_Properties.Footer.Size != <-1., -1.>) {
2554 Quad_Footer.Size = _Properties.Footer.Size;
2555 }
2556 if (_Properties.CloseButton.Size != <-1., -1.>) {
2557 Button_Leave.Size = _Properties.CloseButton.Size;
2558 }
2559 if (_Properties.HeaderOverlay.Size != <-1., -1.>) {
2560 Quad_HeaderOverlay.Size = _Properties.HeaderOverlay.Size;
2561 }
2562 if (_Properties.Header.Size != <-1., -1.>) {
2563 Quad_Header.Size = _Properties.Header.Size;
2564 }
2565
2566 Quad_HeaderBG.RelativePosition_V3 = _Properties.HeaderBackground.Position;
2567 Quad_BG.RelativePosition_V3 = _Properties.Background.Position;
2568 Quad_Overlay.RelativePosition_V3 = _Properties.Overlay.Position;
2569 Quad_Footer.RelativePosition_V3 = _Properties.Footer.Position;
2570 Button_Leave.RelativePosition_V3 = _Properties.CloseButton.Position;
2571 Quad_HeaderOverlay.RelativePosition_V3 = _Properties.HeaderOverlay.Position;
2572 Quad_Header.RelativePosition_V3 = _Properties.Header.Position;
2573
2574 Quad_HeaderBG.Colorize = _Properties.HeaderBackground.Colorize;
2575 Quad_BG.Colorize = _Properties.Background.Colorize;
2576 Quad_Overlay.Colorize = _Properties.Overlay.Colorize;
2577 Quad_Footer.Colorize = _Properties.Footer.Colorize;
2578 Button_Leave.Colorize = _Properties.CloseButton.Colorize;
2579 Quad_HeaderOverlay.Colorize = _Properties.HeaderOverlay.Colorize;
2580 Quad_Header.Colorize = _Properties.Header.Colorize;
2581
2582 _Frame_Container.GetFirstChild("ComponentPopUpBackground_frame-hitbox").Visible = _Properties.UseHitbox;
2583 _Frame_Container.GetFirstChild("ComponentPopUpBackground_frame-header").Visible = _Properties.ShowHeader;
2584}
2585
2586Void ComponentPopUpBackground_SetBackgroundHeaderImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2587 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2588 ComponentPopUpBackground_Properties.HeaderBackground.Url = _ImageUrl;
2589 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2590}
2591
2592Void ComponentPopUpBackground_SetBackgroundHeaderOpacity(CMlFrame _Frame_Container, Real _Opacity) {
2593 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2594 ComponentPopUpBackground_Properties.HeaderBackground.Opacity = _Opacity;
2595 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2596}
2597
2598Void ComponentPopUpBackground_SetBackgroundHeaderColorize(CMlFrame _Frame_Container, Vec3 _Color) {
2599 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2600 ComponentPopUpBackground_Properties.HeaderBackground.Colorize = _Color;
2601 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2602}
2603Void ComponentPopUpBackground_SetBackgroundHeaderColorize(CMlFrame _Frame_Container, Text _Color) {
2604 ComponentPopUpBackground_SetBackgroundHeaderColorize(_Frame_Container, ComponentPopUpBackground_CL::HexToRgb(_Color));
2605}
2606
2607Void ComponentPopUpBackground_SetBackgroundImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2608 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2609 ComponentPopUpBackground_Properties.Background.Url = _ImageUrl;
2610 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2611}
2612
2613Void ComponentPopUpBackground_SetBackgroundColorize(CMlFrame _Frame_Container, Vec3 _Color) {
2614 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2615 ComponentPopUpBackground_Properties.Background.Colorize = _Color;
2616 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2617}
2618Void ComponentPopUpBackground_SetBackgroundColorize(CMlFrame _Frame_Container, Text _Color) {
2619 ComponentPopUpBackground_SetBackgroundColorize(_Frame_Container, ComponentPopUpBackground_CL::HexToRgb(_Color));
2620}
2621
2622Void ComponentPopUpBackground_SetOverlayImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2623 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2624 ComponentPopUpBackground_Properties.Overlay.Url = _ImageUrl;
2625 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2626}
2627
2628Void ComponentPopUpBackground_SetOverlayOpacity(CMlFrame _Frame_Container, Real _Opacity) {
2629 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2630 ComponentPopUpBackground_Properties.Overlay.Opacity = _Opacity;
2631 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2632}
2633
2634Void ComponentPopUpBackground_SetOverlayColorize(CMlFrame _Frame_Container, Vec3 _Color) {
2635 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2636 ComponentPopUpBackground_Properties.Overlay.Colorize = _Color;
2637 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2638}
2639Void ComponentPopUpBackground_SetOverlayColorize(CMlFrame _Frame_Container, Text _Color) {
2640 ComponentPopUpBackground_SetOverlayColorize(_Frame_Container, ComponentPopUpBackground_CL::HexToRgb(_Color));
2641}
2642
2643Void ComponentPopUpBackground_SetBackgroundSize(CMlFrame _Frame_Container, Vec2 _Size) {
2644 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2645 ComponentPopUpBackground_Properties.Background.Size = _Size;
2646 ComponentPopUpBackground_Properties.Overlay.Size = _Size;
2647 ComponentPopUpBackground_Properties.HeaderBackground.Size = _Size;
2648 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2649}
2650
2651Void ComponentPopUpBackground_SetMaskImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2652 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2653 ComponentPopUpBackground_Properties.Background.AlphaMask = _ImageUrl;
2654 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2655}
2656
2657Void ComponentPopUpBackground_SetOverlayMask(CMlFrame _Frame_Container, Text _ImageUrl) {
2658 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2659 ComponentPopUpBackground_Properties.Overlay.AlphaMask = _ImageUrl;
2660 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2661}
2662
2663Void ComponentPopUpBackground_SetHeaderImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2664 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2665 ComponentPopUpBackground_Properties.Header.Url = _ImageUrl;
2666 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2667}
2668
2669Void ComponentPopUpBackground_SetHeaderOverlayImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2670 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2671 ComponentPopUpBackground_Properties.HeaderOverlay.Url = _ImageUrl;
2672 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2673}
2674
2675Void ComponentPopUpBackground_SetHeaderOverlayOpacity(CMlFrame _Frame_Container, Real _Opacity) {
2676 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2677 ComponentPopUpBackground_Properties.HeaderOverlay.Opacity = _Opacity;
2678 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2679}
2680
2681Void ComponentPopUpBackground_SetHeaderSize(CMlFrame _Frame_Container, Vec2 _Size) {
2682 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2683 ComponentPopUpBackground_Properties.Header.Size = _Size;
2684 ComponentPopUpBackground_Properties.HeaderOverlay.Size = <_Size.X, _Size.Y>;
2685 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2686}
2687
2688Void ComponentPopUpBackground_SetHeaderPosition(CMlFrame _Frame_Container, Vec2 _Position) {
2689 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2690 ComponentPopUpBackground_Properties.Header.Position = _Position;
2691 ComponentPopUpBackground_Properties.HeaderOverlay.Position = <_Position.X, _Position.Y>;
2692 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2693}
2694
2695Void ComponentPopUpBackground_SetFooterImage(CMlFrame _Frame_Container, Text _ImageUrl) {
2696 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2697 ComponentPopUpBackground_Properties.Footer.Url = _ImageUrl;
2698 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2699}
2700
2701Void ComponentPopUpBackground_SetFooterSize(CMlFrame _Frame_Container, Vec2 _Size) {
2702 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2703 ComponentPopUpBackground_Properties.Footer.Size = _Size;
2704 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2705}
2706
2707Void ComponentPopUpBackground_SetFooterPosition(CMlFrame _Frame_Container, Vec2 _Position) {
2708 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2709 ComponentPopUpBackground_Properties.Footer.Position = _Position;
2710 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2711}
2712
2713Void ComponentPopUpBackground_SetFooterColorize(CMlFrame _Frame_Container, Vec3 _Color) {
2714 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2715 ComponentPopUpBackground_Properties.Footer.Colorize = _Color;
2716 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2717}
2718Void ComponentPopUpBackground_SetFooterColorize(CMlFrame _Frame_Container, Text _Color) {
2719 ComponentPopUpBackground_SetFooterColorize(_Frame_Container, ComponentPopUpBackground_CL::HexToRgb(_Color));
2720}
2721
2722Void ComponentPopUpBackground_ShowHeader(CMlFrame _Frame_Container, Boolean _IsVisible) {
2723 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2724 ComponentPopUpBackground_Properties.ShowHeader = _IsVisible;
2725 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2726}
2727
2728Void ComponentPopUpBackground_SetCloseImageColor(CMlFrame _Frame_Container, Vec3 _Color) {
2729 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2730 ComponentPopUpBackground_Properties.CloseButton.Colorize = _Color;
2731 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2732}
2733Void ComponentPopUpBackground_SetCloseImageColor(CMlFrame _Frame_Container, Text _Color) {
2734 ComponentPopUpBackground_SetCloseImageColor(_Frame_Container, ComponentPopUpBackground_CL::HexToRgb(_Color));
2735}
2736
2737Void ComponentPopUpBackground_SetCloseImagePosition(CMlFrame _Frame_Container, Vec2 _Position) {
2738 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2739 ComponentPopUpBackground_Properties.CloseButton.Position = _Position;
2740 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);}
2741
2742Void ComponentPopUpBackground_UseHitbox(CMlFrame _Frame_Container, Boolean _UseHitbox) {
2743 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2744 ComponentPopUpBackground_Properties.UseHitbox = _UseHitbox;
2745 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2746}
2747
2748Void ComponentPopUpBackground_InitPopUpBackground(CMlFrame _Frame_Container) {
2749 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2750 ComponentPopUpBackground_Properties = ComponentPopUpBackground_C_Layout_Types[ComponentPopUpBackground_C_Layout_Type_Default];
2751
2752 if (_Frame_Container.DataAttributeExists("layout")) {
2753 declare LayoutType = ComponentPopUpBackground_TL::ToInteger(_Frame_Container.DataAttributeGet("layout"));
2754 if (ComponentPopUpBackground_C_Layout_Types.existskey(LayoutType)) {
2755 ComponentPopUpBackground_Properties = ComponentPopUpBackground_C_Layout_Types[LayoutType];
2756 }
2757 }
2758
2759 if (_Frame_Container.DataAttributeExists("show-header")) {
2760 ComponentPopUpBackground_Properties.ShowHeader = ComponentMenuLibsTools_GetBooleanAttribute(_Frame_Container, "show-header");
2761 }
2762 if (_Frame_Container.DataAttributeExists("use-hitbox")) {
2763 ComponentPopUpBackground_Properties.UseHitbox = ComponentMenuLibsTools_GetBooleanAttribute(_Frame_Container, "use-hitbox");
2764 }
2765
2766 if (_Frame_Container.DataAttributeExists("background-url")) {
2767 ComponentPopUpBackground_Properties.Background.Url = _Frame_Container.DataAttributeGet("background-url");
2768 }
2769 if (_Frame_Container.DataAttributeExists("background-alphamask")) {
2770 ComponentPopUpBackground_Properties.Background.AlphaMask = _Frame_Container.DataAttributeGet("background-alphamask");
2771 }
2772 if (_Frame_Container.DataAttributeExists("background-size")) {
2773 ComponentPopUpBackground_Properties.Background.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("background-size"));
2774 }
2775 if (_Frame_Container.DataAttributeExists("background-position")) {
2776 ComponentPopUpBackground_Properties.Background.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("background-position"));
2777 }
2778 if (_Frame_Container.DataAttributeExists("background-colorize")) {
2779 ComponentPopUpBackground_Properties.Background.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("background-colorize"));
2780 }
2781 if (_Frame_Container.DataAttributeExists("background-opacity")) {
2782 ComponentPopUpBackground_Properties.Background.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("background-opacity"));
2783 }
2784
2785 if (_Frame_Container.DataAttributeExists("overlay-url")) {
2786 ComponentPopUpBackground_Properties.Overlay.Url = _Frame_Container.DataAttributeGet("overlay-url");
2787 }
2788 if (_Frame_Container.DataAttributeExists("overlay-alphamask")) {
2789 ComponentPopUpBackground_Properties.Overlay.AlphaMask = _Frame_Container.DataAttributeGet("overlay-alphamask");
2790 }
2791 if (_Frame_Container.DataAttributeExists("overlay-size")) {
2792 ComponentPopUpBackground_Properties.Overlay.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("overlay-size"));
2793 }
2794 if (_Frame_Container.DataAttributeExists("overlay-position")) {
2795 ComponentPopUpBackground_Properties.Overlay.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("overlay-position"));
2796 }
2797 if (_Frame_Container.DataAttributeExists("overlay-colorize")) {
2798 ComponentPopUpBackground_Properties.Overlay.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("overlay-colorize"));
2799 }
2800 if (_Frame_Container.DataAttributeExists("overlay-opacity")) {
2801 ComponentPopUpBackground_Properties.Overlay.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("overlay-opacity"));
2802 }
2803
2804 if (_Frame_Container.DataAttributeExists("header-url")) {
2805 ComponentPopUpBackground_Properties.Header.Url = _Frame_Container.DataAttributeGet("header-url");
2806 }
2807 if (_Frame_Container.DataAttributeExists("header-alphamask")) {
2808 ComponentPopUpBackground_Properties.Header.AlphaMask = _Frame_Container.DataAttributeGet("header-alphamask");
2809 }
2810 if (_Frame_Container.DataAttributeExists("header-size")) {
2811 ComponentPopUpBackground_Properties.Header.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-size"));
2812 }
2813 if (_Frame_Container.DataAttributeExists("header-position")) {
2814 ComponentPopUpBackground_Properties.Header.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-position"));
2815 }
2816 if (_Frame_Container.DataAttributeExists("header-colorize")) {
2817 ComponentPopUpBackground_Properties.Header.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("header-colorize"));
2818 }
2819 if (_Frame_Container.DataAttributeExists("header-opacity")) {
2820 ComponentPopUpBackground_Properties.Header.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("header-opacity"));
2821 }
2822
2823 if (_Frame_Container.DataAttributeExists("header-overlay-url")) {
2824 ComponentPopUpBackground_Properties.HeaderOverlay.Url = _Frame_Container.DataAttributeGet("header-overlay-url");
2825 }
2826 if (_Frame_Container.DataAttributeExists("header-overlay-alphamask")) {
2827 ComponentPopUpBackground_Properties.HeaderOverlay.AlphaMask = _Frame_Container.DataAttributeGet("header-overlay-alphamask");
2828 }
2829 if (_Frame_Container.DataAttributeExists("header-overlay-size")) {
2830 ComponentPopUpBackground_Properties.HeaderOverlay.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-overlay-size"));
2831 }
2832 if (_Frame_Container.DataAttributeExists("header-overlay-position")) {
2833 ComponentPopUpBackground_Properties.HeaderOverlay.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-overlay-position"));
2834 }
2835 if (_Frame_Container.DataAttributeExists("header-overlay-colorize")) {
2836 ComponentPopUpBackground_Properties.HeaderOverlay.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("header-overlay-colorize"));
2837 }
2838 if (_Frame_Container.DataAttributeExists("header-overlay-opacity")) {
2839 ComponentPopUpBackground_Properties.HeaderOverlay.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("header-overlay-opacity"));
2840 }
2841
2842 if (_Frame_Container.DataAttributeExists("header-background-url")) {
2843 ComponentPopUpBackground_Properties.HeaderBackground.Url = _Frame_Container.DataAttributeGet("header-background-url");
2844 }
2845 if (_Frame_Container.DataAttributeExists("header-background-alphamask")) {
2846 ComponentPopUpBackground_Properties.HeaderBackground.AlphaMask = _Frame_Container.DataAttributeGet("header-background-alphamask");
2847 }
2848 if (_Frame_Container.DataAttributeExists("header-background-size")) {
2849 ComponentPopUpBackground_Properties.HeaderBackground.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-background-size"));
2850 }
2851 if (_Frame_Container.DataAttributeExists("header-background-position")) {
2852 ComponentPopUpBackground_Properties.HeaderBackground.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("header-background-position"));
2853 }
2854 if (_Frame_Container.DataAttributeExists("header-background-colorize")) {
2855 ComponentPopUpBackground_Properties.HeaderBackground.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("header-background-colorize"));
2856 }
2857 if (_Frame_Container.DataAttributeExists("header-background-opacity")) {
2858 ComponentPopUpBackground_Properties.HeaderBackground.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("header-background-opacity"));
2859 }
2860
2861 if (_Frame_Container.DataAttributeExists("footer-url")) {
2862 ComponentPopUpBackground_Properties.Footer.Url = _Frame_Container.DataAttributeGet("footer-url");
2863 }
2864 if (_Frame_Container.DataAttributeExists("footer-alphamask")) {
2865 ComponentPopUpBackground_Properties.Footer.AlphaMask = _Frame_Container.DataAttributeGet("footer-alphamask");
2866 }
2867 if (_Frame_Container.DataAttributeExists("footer-size")) {
2868 ComponentPopUpBackground_Properties.Footer.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("footer-size"));
2869 }
2870 if (_Frame_Container.DataAttributeExists("footer-position")) {
2871 ComponentPopUpBackground_Properties.Footer.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("footer-position"));
2872 }
2873 if (_Frame_Container.DataAttributeExists("footer-colorize")) {
2874 ComponentPopUpBackground_Properties.Footer.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("footer-colorize"));
2875 }
2876 if (_Frame_Container.DataAttributeExists("footer-opacity")) {
2877 ComponentPopUpBackground_Properties.Footer.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("footer-opacity"));
2878 }
2879
2880 if (_Frame_Container.DataAttributeExists("button-close-url")) {
2881 ComponentPopUpBackground_Properties.CloseButton.Url = _Frame_Container.DataAttributeGet("button-close-url");
2882 }
2883 if (_Frame_Container.DataAttributeExists("button-close-alphamask")) {
2884 ComponentPopUpBackground_Properties.CloseButton.AlphaMask = _Frame_Container.DataAttributeGet("button-close-alphamask");
2885 }
2886 if (_Frame_Container.DataAttributeExists("button-close-size")) {
2887 ComponentPopUpBackground_Properties.CloseButton.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("button-close-size"));
2888 }
2889 if (_Frame_Container.DataAttributeExists("button-close-position")) {
2890 ComponentPopUpBackground_Properties.CloseButton.Position = ComponentMenuLibsTools_TextToVec2(_Frame_Container.DataAttributeGet("button-close-position"));
2891 }
2892 if (_Frame_Container.DataAttributeExists("button-close-colorize")) {
2893 ComponentPopUpBackground_Properties.CloseButton.Colorize = ComponentPopUpBackground_CL::HexToRgb(_Frame_Container.DataAttributeGet("button-close-colorize"));
2894 }
2895 if (_Frame_Container.DataAttributeExists("button-close-opacity")) {
2896 ComponentPopUpBackground_Properties.CloseButton.Opacity = ComponentPopUpBackground_TL::ToReal(_Frame_Container.DataAttributeGet("button-close-opacity"));
2897 }
2898
2899 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2900}
2901
2902Void ComponentPopUpBackground_ApplyLayout(CMlFrame _Frame_Container, Integer _LayoutType) {
2903 if (ComponentPopUpBackground_C_Layout_Types.existskey(_LayoutType)) {
2904 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for _Frame_Container;
2905 ComponentPopUpBackground_Properties = ComponentPopUpBackground_C_Layout_Types[_LayoutType];
2906 ComponentPopUpBackground_ApplyProperties(_Frame_Container, ComponentPopUpBackground_Properties);
2907 }
2908}
2909
2910***MainInit***
2911***
2912declare CMlFrame ComponentPopUpBackground_Frame_Global;
2913declare CMlFrame[] ComponentPopUpBackground_Frame_PopUpBackgroundList;
2914declare CMlControl ComponentPopUpBackground_Button_Leave;
2915
2916declare Text ComponentPopUpBackground_PopUpName;
2917***
2918
2919***MainStart***
2920***
2921ComponentPopUpBackground_Frame_Global <=> (Page.GetFirstChild("ComponentPopUpBackground_frame-global") as CMlFrame);
2922ComponentPopUpBackground_Button_Leave <=> ComponentPopUpBackground_Frame_Global.GetFirstChild("ComponentPopUpBackground_button-leave");
2923
2924Page.GetClassChildren("class-popupbackground", Page.MainFrame, True);
2925foreach (Control in Page.GetClassChildren_Result) {
2926 if (Control.Parent is CMlFrame) {
2927 declare CMlFrame Frame_PopUpBackground = Control.Parent;
2928 ComponentPopUpBackground_Frame_PopUpBackgroundList.add(Frame_PopUpBackground);
2929
2930 ComponentPopUpBackground_InitPopUpBackground(Frame_PopUpBackground);
2931
2932 declare CMlControl Button_Leave = Frame_PopUpBackground.GetFirstChild("ComponentPopUpBackground_button-leave");
2933 declare Ident ComponentPopUpBackground_ParentFrameId for Button_Leave;
2934 ComponentPopUpBackground_ParentFrameId = Frame_PopUpBackground.Id;
2935
2936 if (Frame_PopUpBackground.DataAttributeExists("pop-up-name")) {
2937 declare Text ComponentPopUpBackground_PopUpName for Frame_PopUpBackground;
2938 ComponentPopUpBackground_PopUpName = Frame_PopUpBackground.DataAttributeGet("pop-up-name");
2939 } else {
2940 assert(False, "[PopUpBackground] You must define 'data-pop-up-name' in your frameinstance");
2941 }
2942 }
2943}
2944***
2945
2946***MainLoop***
2947***
2948ComponentPopUpBackground_PendingEvents = [];
2949
2950if (G_DownloadInProgress.count > 0) {
2951 declare TmpDownloadInProgress = G_DownloadInProgress;
2952 foreach (Quad => DownloadStartTime in TmpDownloadInProgress) {
2953 if (
2954 Now > DownloadStartTime &&
2955 !Quad.DownloadInProgress
2956 ) {
2957 declare Text ComponentPopUpBackground_AlphaMaskUrl for Quad;
2958 declare Real ComponentPopUpBackground_Opacity for Quad;
2959 Quad.AlphaMaskUrl = ComponentPopUpBackground_AlphaMaskUrl;
2960 AnimMgr.Add(Quad, "<quad opacity=\""^ComponentPopUpBackground_Opacity^"\"", 200, CAnimManager::EAnimManagerEasing::QuadOut);
2961 G_DownloadInProgress.removekey(Quad);
2962 }
2963 }
2964}
2965
2966if (PageIsVisible) {
2967 foreach (Frame_PopUpBackground in ComponentPopUpBackground_Frame_PopUpBackgroundList) {
2968 if (Frame_PopUpBackground.Parent.Visible) {
2969 foreach (Event in PendingEvents) {
2970 switch (Event.Type) {
2971 case CMlScriptEvent::Type::MouseOver: {
2972 if (Event.ControlId == "ComponentPopUpBackground_button-leave") {
2973 AnimMgr.Add(Event.Control, "<anim scale=\"1.2\"/>", 100, CAnimManager::EAnimManagerEasing::Linear);
2974 }
2975 }
2976 case CMlScriptEvent::Type::MouseOut: {
2977 if (Event.ControlId == "ComponentPopUpBackground_button-leave") {
2978 AnimMgr.Add(Event.Control, "<anim scale=\"1.\"/>", 100, CAnimManager::EAnimManagerEasing::Linear);
2979 }
2980 }
2981 case CMlScriptEvent::Type::MouseClick: {
2982 declare ComponentPopUpBackground_K_Properties ComponentPopUpBackground_Properties for Frame_PopUpBackground;
2983 if (Event.ControlId == "ComponentPopUpBackground_button-leave") {
2984 // Check if the control belongs to the Frame_PopUpBackground
2985 declare Ident ComponentPopUpBackground_ParentFrameId for Event.Control;
2986 if (ComponentPopUpBackground_ParentFrameId == Frame_PopUpBackground.Id) {
2987 ComponentCommonLibsAudioManager_StopSound("ClosePopUpButtonSelect");
2988 ComponentCommonLibsAudioManager_PlaySound("ClosePopUpButtonSelect");
2989 ComponentPopUpBackground_LeavePopUp(Frame_PopUpBackground, True);
2990 }
2991 } else if (
2992 (ComponentPopUpBackground_Properties.UseHitbox && Event.ControlId != "ComponentPopUpBackground_quad-hitbox") ||
2993 (!ComponentPopUpBackground_Properties.UseHitbox && Event.ControlId != "ComponentPopUpBackground_quad-bg")
2994 ) {
2995 // Check if the control belongs to the Frame_PopUpBackground
2996 declare CMlControl Control = Frame_PopUpBackground.GetFirstChild(Event.ControlId);
2997 if (Control != Null && Control.Id == Event.Control.Id) {
2998 ComponentCommonLibsAudioManager_StopSound("ClosePopUpButtonSelect");
2999 ComponentCommonLibsAudioManager_PlaySound("ClosePopUpButtonSelect");
3000 ComponentPopUpBackground_LeavePopUp(Frame_PopUpBackground, False);
3001 }
3002 }
3003 }
3004 }
3005 }
3006 }
3007 }
3008}
3009***
3010
3011// */
3012// @Component end component-popupbackground
3013
3014// @Component start menu-libs-scroll
3015// /*
3016
3017declare MenuLibsScroll_K_Event[] MenuLibsScroll_DelayedPendingEvents;
3018declare MenuLibsScroll_K_Event[] MenuLibsScroll_PendingEvents;
3019declare Boolean MenuLibsScroll_G_UseLocalEvents;
3020declare CMlFrame[] MenuLibsScroll_G_Frames_Scroll;
3021
3022Void MenuLibsScroll_Private_SetScrollBarSize(CMlFrame _Frame_ScrollBarQuads, Vec2 _Size) {
3023 declare CMlQuad Quad_Top <=> (_Frame_ScrollBarQuads.GetFirstChild("MenuLibsScroll_quad-top") as CMlQuad);
3024 declare CMlQuad Quad_Center <=> (_Frame_ScrollBarQuads.GetFirstChild("MenuLibsScroll_quad-center") as CMlQuad);
3025 declare CMlQuad Quad_Bottom <=> (_Frame_ScrollBarQuads.GetFirstChild("MenuLibsScroll_quad-bottom") as CMlQuad);
3026 Quad_Top.Size = <_Size.X, _Size.X * 0.5>;
3027 Quad_Bottom.Size = <_Size.X, _Size.X * 0.5>;
3028 Quad_Center.Size = <_Size.X, MenuLibsScroll_ML::Max(0., _Size.Y - Quad_Top.Size.Y - Quad_Bottom.Size.Y)>;
3029 _Frame_ScrollBarQuads.RelativePosition_V3.X = (_Size.X * 0.5) + 1.;
3030 Quad_Top.RelativePosition_V3.Y = -Quad_Top.Size.Y;
3031 Quad_Center.RelativePosition_V3.Y = Quad_Top.RelativePosition_V3.Y;
3032 Quad_Bottom.RelativePosition_V3.Y = Quad_Center.RelativePosition_V3.Y - Quad_Center.Size.Y;
3033 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for _Frame_ScrollBarQuads;
3034 MenuLibsScroll_ScrollBarState.Height = _Size.Y;
3035}
3036
3037Void MenuLibsScroll_Private_DisplayScrollBar(CMlFrame _Frame_ScrollBar, Boolean _Visible) {
3038 declare CMlFrame Frame_ScrollBarDuringScroll <=> (_Frame_ScrollBar.GetFirstChild("MenuLibsScroll_frame-scrollbar-during-scroll") as CMlFrame);
3039 declare CMlFrame Frame_ScrollBarFg <=> (Frame_ScrollBarDuringScroll.GetFirstChild("MenuLibsScroll_frame-scrollbar-fg") as CMlFrame);
3040 declare CMlFrame Frame_ScrollBarBg <=> (Frame_ScrollBarDuringScroll.GetFirstChild("MenuLibsScroll_frame-scrollbar-bg") as CMlFrame);
3041
3042 declare Real OpacityBg = 0.;
3043 declare Real OpacityFg = 0.;
3044 declare Boolean PlayAnimation = True;
3045 if (_Visible) {
3046 OpacityFg = 0.8;
3047 OpacityBg = 0.3;
3048 PlayAnimation = !Frame_ScrollBarDuringScroll.Visible;
3049 Frame_ScrollBarDuringScroll.Visible = True;
3050 } else {
3051 AnimMgr.Add(Frame_ScrollBarDuringScroll, "<a hidden=\"1\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
3052 }
3053
3054 if (PlayAnimation) {
3055 foreach (Control in Frame_ScrollBarFg.Controls) {
3056 AnimMgr.Add(Control, "<a opacity=\""^OpacityFg^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
3057 }
3058 foreach (Control in Frame_ScrollBarBg.Controls) {
3059 AnimMgr.Add(Control, "<a opacity=\""^OpacityBg^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
3060 }
3061 }
3062}
3063
3064MenuLibsScroll_K_ScrollPosition MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_K_State _State) {
3065 declare Integer Row = MenuLibsScroll_ML::Max(0, MenuLibsScroll_ML::FloorInteger((_State.ScrollOffset.Y - _State.Config.HeaderHeight) / (_State.Config.ElementSize.Y + _State.Config.MarginSize.Y)));
3066 declare Integer StartKey = Row * _State.Config.ElementsPerLine;
3067 declare Integer EndKey = StartKey + _State.Elements.count - 1;
3068 return MenuLibsScroll_K_ScrollPosition {
3069 Row = Row,
3070 StartKey = StartKey,
3071 EndKey = EndKey
3072 };
3073}
3074MenuLibsScroll_K_ScrollPosition MenuLibsScroll_Private_GetScrollPosition(CMlFrame _Frame_Scroll) {
3075 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3076 return MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State);
3077}
3078
3079Void MenuLibsScroll_Private_SetFocusedElementKey(CMlFrame _Frame_Scroll, Integer _StartElementKey, Integer _FocusedElementKey, Boolean _IsMouse, Boolean _SendFocusEvent) {
3080 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3081 declare MenuLibsScroll_K_Event Event = MenuLibsScroll_K_Event {
3082 Type = MenuLibsScroll_C_EventType_Focus,
3083 Scroll = _Frame_Scroll,
3084 From = MenuLibsScroll_State.FocusedElement,
3085 FromKey = MenuLibsScroll_State.FocusedElementKey,
3086 To = Null,
3087 ToKey = _FocusedElementKey,
3088 IsMouse = _IsMouse
3089 };
3090 declare Integer ElementKey = _FocusedElementKey - _StartElementKey;
3091 if (MenuLibsScroll_State.Elements.existskey(ElementKey)) {
3092 Event.To = MenuLibsScroll_State.Elements[ElementKey];
3093 }
3094
3095 MenuLibsScroll_State.FocusedElement = Event.To;
3096 MenuLibsScroll_State.FocusedElementKey = Event.ToKey;
3097 if (_SendFocusEvent) MenuLibsScroll_DelayedPendingEvents.add(Event);
3098}
3099Void MenuLibsScroll_Private_SetFocusedElementKey(CMlFrame _Frame_Scroll, Integer _StartElementKey, Integer _FocusedElementKey, Boolean _IsMouse) {
3100 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, _StartElementKey, _FocusedElementKey, _IsMouse, True);
3101}
3102Void MenuLibsScroll_Private_SetFocusedElementKey(CMlFrame _Frame_Scroll, Integer _StartElementKey, Integer _FocusedElementKey) {
3103 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, _StartElementKey, _FocusedElementKey, False, True);
3104}
3105Void MenuLibsScroll_SetFocusedElementKey(CMlFrame _Frame_Scroll, Integer _ElementKey, Boolean _IsMouse, Boolean _SendFocusEvent) {
3106 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3107 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, _ElementKey, _IsMouse, _SendFocusEvent);
3108}
3109
3110Void MenuLibsScroll_Private_ApplySkewToControl(MenuLibsScroll_K_State _State, Real _Offset, CMlControl _Control) {
3111 declare Real OffsetFromWindowTop = (-_Control.RelativePosition_V3.Y - _State.Config.HeaderHeight - _Offset);
3112 if (_State.Config.SkewVAlign == MenuLibsScroll_C_SkewVAlign_Center) {
3113 OffsetFromWindowTop -= ((_State.Config.WindowSize.Y - _State.Config.ElementSize.Y) * 0.5);
3114 } else if (_State.Config.SkewVAlign == MenuLibsScroll_C_SkewVAlign_Bottom) {
3115 OffsetFromWindowTop -= (_State.Config.WindowSize.Y - _State.Config.ElementSize.Y);
3116 }
3117 declare Real MenuLibsScroll_BasePosX for _Control;
3118 _Control.RelativePosition_V3.X = MenuLibsScroll_BasePosX + (OffsetFromWindowTop * MenuLibsScroll_ML::Tan(MenuLibsScroll_ML::DegToRad(_State.Config.Skew)));
3119}
3120
3121Void MenuLibsScroll_Private_ApplySkew(MenuLibsScroll_K_State _State) {
3122 if (_State.Config.Skew > -0.1 && _State.Config.Skew < 0.1) return;
3123
3124 declare Real Offset = 0.;
3125 if (_State.ScrollOffset.Y > _State.Config.HeaderHeight) {
3126 Offset = _State.ScrollOffset.Y - _State.Config.HeaderHeight;
3127 }
3128
3129 foreach (Key => Frame_Element in _State.Elements) {
3130 MenuLibsScroll_Private_ApplySkewToControl(_State, Offset, Frame_Element);
3131 }
3132
3133 foreach (Key => StickControl in _State.StickControls) {
3134 MenuLibsScroll_Private_ApplySkewToControl(_State, Offset, StickControl);
3135 }
3136}
3137
3138Void MenuLibsScroll_Private_UpdateElementsPosition(MenuLibsScroll_K_State _State, MenuLibsScroll_K_ScrollPosition _ScrollPosition) {
3139 foreach (Key => Frame_Element in _State.Elements) {
3140 declare Integer Row = _ScrollPosition.Row + (Key / _State.Config.ElementsPerLine);
3141 declare Integer Column = Key % _State.Config.ElementsPerLine;
3142 Frame_Element.RelativePosition_V3.Y = -_State.Config.HeaderHeight - (Row * (_State.Config.ElementSize.Y + _State.Config.MarginSize.Y));
3143 Frame_Element.RelativePosition_V3.X = _State.Config.ScrollPadding + (Column * (_State.Config.ElementSize.X + _State.Config.MarginSize.X));
3144
3145 declare Real MenuLibsScroll_BasePosX for Frame_Element;
3146 MenuLibsScroll_BasePosX = Frame_Element.RelativePosition_V3.X;
3147 }
3148
3149 MenuLibsScroll_Private_ApplySkew(_State);
3150}
3151
3152Boolean MenuLibsScroll_CanScroll(CMlFrame _Frame_Scroll) {
3153 return (_Frame_Scroll.ScrollMax.Y > MenuLibsScroll_ML::Pow(10., -3.)); //< Avoid precision error
3154}
3155
3156Void MenuLibsScroll_Private_Scroll(CMlFrame _Frame_Scroll, Real _ScrollDelta, Boolean _ForceUpdate, Boolean _IsAnim, Boolean _SendFocusEvent) {
3157 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3158
3159 if (!_IsAnim && MenuLibsScroll_State.Animation.StartTime >= 0) {
3160 MenuLibsScroll_State.Animation = MenuLibsScroll_K_ScrollAnimation {
3161 StartTime = -1,
3162 ScrollStart = 0.,
3163 ScrollDelta = 0.,
3164 Duration = 0
3165 };
3166 }
3167
3168 declare MenuLibsScroll_K_ScrollPosition OldScrollPosition = MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State);
3169 if (_ScrollDelta != 0.) {
3170 _Frame_Scroll.Scroll(<0., _ScrollDelta>);
3171
3172 if (
3173 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_DuringScroll &&
3174 MenuLibsScroll_State.ScrollBar != Null &&
3175 MenuLibsScroll_State.ScrollBar.Visible
3176 ) {
3177 MenuLibsScroll_State.ScrollBarHideTime = Now + MenuLibsScroll_C_ScrollBarVisibilityDuration;
3178 MenuLibsScroll_Private_DisplayScrollBar(MenuLibsScroll_State.ScrollBar, True);
3179 }
3180 }
3181 MenuLibsScroll_State.ScrollOffset = _Frame_Scroll.ScrollOffset;
3182 declare MenuLibsScroll_K_ScrollPosition NewScrollPosition = MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State);
3183
3184 if (_ForceUpdate || OldScrollPosition.StartKey != NewScrollPosition.StartKey) {
3185 // Update pager throttle
3186 if (
3187 MenuLibsScroll_State.Config.PagerPageSize > 0 && (
3188 MenuLibsScroll_State.Pager.ThrottleEndTime >= 0 ||
3189 NewScrollPosition.StartKey <= MenuLibsScroll_State.Pager.Limits.X ||
3190 NewScrollPosition.StartKey >= MenuLibsScroll_State.Pager.Limits.Y
3191 )
3192 ) {
3193 if (
3194 MenuLibsScroll_State.Pager.ThrottleEndTime >= 0 ||
3195 (MenuLibsScroll_State.Pager.CooldownEndTime >= 0 && Now < MenuLibsScroll_State.Pager.CooldownEndTime)
3196 ) {
3197 MenuLibsScroll_State.Pager.ThrottleEndTime = Now + MenuLibsScroll_C_PagerThrottleDuration;
3198 } else {
3199 MenuLibsScroll_State.Pager.ThrottleEndTime = Now;
3200 }
3201 }
3202
3203 declare MenuLibsScroll_K_Event Event = MenuLibsScroll_K_Event {
3204 Type = MenuLibsScroll_C_EventType_Update,
3205 Scroll = _Frame_Scroll,
3206 ElementsVisible = [],
3207 ElementsHidden = [],
3208 ScrollPosition = NewScrollPosition,
3209 Page = -1,
3210 DelayedElementsUpdate = !_ForceUpdate
3211 };
3212 if (MenuLibsScroll_State.Config.ElementsPerPage > 0) {
3213 Event.Page = (Event.ScrollPosition.StartKey / MenuLibsScroll_State.Config.ElementsPerPage) + 1;
3214 }
3215 foreach (Key => Frame_Element in MenuLibsScroll_State.Elements) {
3216 declare Integer ElementKey = NewScrollPosition.StartKey + Key;
3217 if (ElementKey >= 0) {
3218 if (ElementKey <= MenuLibsScroll_State.ElementsTotal - 1) {
3219 Event.ElementsVisible[ElementKey] = Frame_Element;
3220 } else {
3221 Event.ElementsHidden[ElementKey] = Frame_Element;
3222 }
3223 }
3224 }
3225 MenuLibsScroll_DelayedPendingEvents.add(Event);
3226
3227 if (!Event.DelayedElementsUpdate) {
3228 MenuLibsScroll_Private_UpdateElementsPosition(MenuLibsScroll_State, Event.ScrollPosition);
3229 }
3230 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, NewScrollPosition.StartKey, MenuLibsScroll_State.FocusedElementKey, False, _SendFocusEvent);
3231 }
3232
3233 MenuLibsScroll_Private_ApplySkew(MenuLibsScroll_State);
3234
3235 if (NewScrollPosition.EndKey >= MenuLibsScroll_State.ElementsTotal - 1) {
3236 if (!MenuLibsScroll_State.IsDisplayingEnd) {
3237 MenuLibsScroll_State.IsDisplayingEnd = True;
3238 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3239 Type = MenuLibsScroll_C_EventType_DisplayEnd,
3240 Scroll = _Frame_Scroll
3241 });
3242 }
3243 } else {
3244 MenuLibsScroll_State.IsDisplayingEnd = False;
3245 }
3246 if (NewScrollPosition.StartKey <= 0) {
3247 if (!MenuLibsScroll_State.IsDisplayingStart) {
3248 MenuLibsScroll_State.IsDisplayingStart = True;
3249 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3250 Type = MenuLibsScroll_C_EventType_DisplayStart,
3251 Scroll = _Frame_Scroll
3252 });
3253 }
3254 } else {
3255 MenuLibsScroll_State.IsDisplayingStart = False;
3256 }
3257
3258 if (MenuLibsScroll_State.EventGenerator != Null) {
3259 MenuLibsScroll_State.EventGenerator.RelativePosition_V3.Y = -MenuLibsScroll_State.ScrollOffset.Y;
3260 }
3261
3262 if (MenuLibsScroll_State.ScrollIndicator != Null) {
3263 if (MenuLibsScroll_CanScroll(_Frame_Scroll) && MenuLibsScroll_State.ScrollOffset.Y < _Frame_Scroll.ScrollMax.Y - 0.1) {
3264 MenuLibsScroll_State.ScrollIndicator.Visible = True;
3265 } else {
3266 MenuLibsScroll_State.ScrollIndicator.Visible = False;
3267 }
3268 }
3269
3270 if (MenuLibsScroll_State.ScrollBar != Null && MenuLibsScroll_State.ScrollBar.Visible) {
3271 declare Frame_ScrollBarFg <=> (MenuLibsScroll_State.ScrollBar.GetFirstChild("MenuLibsScroll_frame-scrollbar-fg") as CMlFrame);
3272 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for Frame_ScrollBarFg;
3273 Frame_ScrollBarFg.RelativePosition_V3.Y = (_Frame_Scroll.Size.Y - MenuLibsScroll_ScrollBarState.Height) * -(MenuLibsScroll_State.ScrollOffset.Y / _Frame_Scroll.ScrollMax.Y);
3274 }
3275
3276 if (MenuLibsScroll_State.ClampedControls.count > 0) {
3277 declare MenuLibsScroll_K_ClampedControl[] TmpClampedControls = MenuLibsScroll_State.ClampedControls;
3278 foreach (Key => ClampedControl in TmpClampedControls) {
3279 declare Boolean ClampUpdate = False;
3280 if (ClampedControl.Type == 2 || ClampedControl.Type == 0) {
3281 if (ClampedControl.Control.AbsolutePosition_V3.Y + ClampedControl.Origin > ClampedControl.Limit.X + ClampedControl.Control.RelativePosition_V3.Y) {
3282 ClampedControl.Control.RelativePosition_V3.Y += ClampedControl.Limit.X - ClampedControl.Control.AbsolutePosition_V3.Y;
3283 if (!ClampedControl.ClampedTop) {
3284 MenuLibsScroll_State.ClampedControls[Key].ClampedTop = True;
3285 ClampUpdate = True;
3286 }
3287 } else if (ClampedControl.ClampedTop) {
3288 ClampedControl.Control.RelativePosition_V3.Y = ClampedControl.Origin;
3289 MenuLibsScroll_State.ClampedControls[Key].ClampedTop = False;
3290 ClampUpdate = True;
3291 }
3292 }
3293 if (ClampedControl.Type == 2 || ClampedControl.Type == 1) {
3294 if (ClampedControl.Control.AbsolutePosition_V3.Y + ClampedControl.Origin < ClampedControl.Limit.Y + ClampedControl.Control.RelativePosition_V3.Y) {
3295 ClampedControl.Control.RelativePosition_V3.Y += ClampedControl.Limit.Y - ClampedControl.Control.AbsolutePosition_V3.Y;
3296 if (!ClampedControl.ClampedBottom) {
3297 MenuLibsScroll_State.ClampedControls[Key].ClampedBottom = True;
3298 ClampUpdate = True;
3299 }
3300 } else if (ClampedControl.ClampedBottom) {
3301 ClampedControl.Control.RelativePosition_V3.Y = ClampedControl.Origin;
3302 MenuLibsScroll_State.ClampedControls[Key].ClampedBottom = False;
3303 ClampUpdate = True;
3304 }
3305 }
3306 if (ClampUpdate) {
3307 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3308 Type = MenuLibsScroll_C_EventType_ClampUpdate,
3309 Scroll = _Frame_Scroll,
3310 ClampedControl = MenuLibsScroll_State.ClampedControls[Key]
3311 });
3312 }
3313 }
3314 }
3315}
3316
3317Void MenuLibsScroll_Scroll(CMlFrame _Frame_Scroll, Real _ScrollDelta) {
3318 MenuLibsScroll_Private_Scroll(_Frame_Scroll, _ScrollDelta, False, False, True);
3319}
3320
3321Void MenuLibsScroll_ScrollDelta(CMlFrame _Frame_Scroll, Real _ScrollDelta, Integer _AnimDuration) {
3322 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3323 if (_AnimDuration > 0 && MenuLibsScroll_State.Config.AnimEnabled) {
3324 MenuLibsScroll_State.Animation = MenuLibsScroll_K_ScrollAnimation {
3325 StartTime = Now,
3326 ScrollStart = MenuLibsScroll_State.ScrollOffset.Y,
3327 ScrollDelta = _ScrollDelta,
3328 Duration = _AnimDuration
3329 };
3330 } else {
3331 MenuLibsScroll_Private_Scroll(_Frame_Scroll, _ScrollDelta / _Frame_Scroll.ScrollGrid.Y, False, False, True);
3332 }
3333}
3334
3335Void MenuLibsScroll_ScrollToPosition(CMlFrame _Frame_Scroll, Real _ScrollTarget, Boolean _AllowAnimation) {
3336 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3337 if (_AllowAnimation && MenuLibsScroll_State.Config.AnimEnabled) {
3338 MenuLibsScroll_State.Animation = MenuLibsScroll_K_ScrollAnimation {
3339 StartTime = Now,
3340 ScrollStart = MenuLibsScroll_State.ScrollOffset.Y,
3341 ScrollDelta = _ScrollTarget - MenuLibsScroll_State.ScrollOffset.Y,
3342 Duration = 250
3343 };
3344 } else {
3345 MenuLibsScroll_Private_Scroll(_Frame_Scroll, (_ScrollTarget - MenuLibsScroll_State.ScrollOffset.Y) / _Frame_Scroll.ScrollGrid.Y, False, False, True);
3346 }
3347}
3348Void MenuLibsScroll_ScrollToPosition(CMlFrame _Frame_Scroll, Real _ScrollTarget) {
3349 MenuLibsScroll_ScrollToPosition(_Frame_Scroll, _ScrollTarget, True);
3350}
3351
3352Void MenuLibsScroll_ScrollToHeader(CMlFrame _Frame_Scroll) {
3353 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3354 if (MenuLibsScroll_State.ScrollOffset.Y > _Frame_Scroll.ScrollMin.Y) {
3355 MenuLibsScroll_ScrollToPosition(_Frame_Scroll, _Frame_Scroll.ScrollMin.Y);
3356 }
3357}
3358
3359Void MenuLibsScroll_ScrollToFooter(CMlFrame _Frame_Scroll) {
3360 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3361 if (MenuLibsScroll_State.ScrollOffset.Y < _Frame_Scroll.ScrollMax.Y) {
3362 MenuLibsScroll_ScrollToPosition(_Frame_Scroll, _Frame_Scroll.ScrollMax.Y);
3363 }
3364}
3365
3366Void MenuLibsScroll_ScrollToElement(CMlFrame _Frame_Scroll, Integer _ElementKey, Boolean _FocusElement) {
3367 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3368 if (MenuLibsScroll_State.ElementsTotal <= 0) {
3369 MenuLibsScroll_ScrollToHeader(_Frame_Scroll);
3370 } else {
3371 declare Integer ElementKey = MenuLibsScroll_ML::Clamp(_ElementKey, 0, MenuLibsScroll_State.ElementsTotal - 1);
3372
3373 if (_FocusElement) {
3374 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, _ElementKey);
3375 ElementKey = MenuLibsScroll_State.FocusedElementKey;
3376 }
3377
3378 declare Integer LineNb = ElementKey / MenuLibsScroll_State.Config.ElementsPerLine;
3379 declare Real StartY = MenuLibsScroll_State.Config.HeaderHeight + (LineNb * (MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y));
3380 declare Real EndY = StartY + MenuLibsScroll_State.Config.ElementSize.Y;
3381
3382 // Try to display one line above and below the current focus
3383 if (MenuLibsScroll_State.CanPreScroll) {
3384 if (MenuLibsScroll_State.Header != Null || ElementKey - MenuLibsScroll_State.Config.ElementsPerLine >= 0) {
3385 StartY -= MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y;
3386 }
3387 if (MenuLibsScroll_State.Footer != Null || ElementKey - (ElementKey % MenuLibsScroll_State.Config.ElementsPerLine) + MenuLibsScroll_State.Config.ElementsPerLine <= MenuLibsScroll_State.ElementsTotal - 1 ) {
3388 EndY += MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y;
3389 }
3390 }
3391
3392 // Use NearestInteger to avoid precision error (100. > 100. can be true and false)
3393 if (MenuLibsScroll_ML::NearestInteger(MenuLibsScroll_State.ScrollOffset.Y) > MenuLibsScroll_ML::NearestInteger(StartY)) {
3394 MenuLibsScroll_ScrollToPosition(_Frame_Scroll, StartY);
3395 } else if (MenuLibsScroll_ML::NearestInteger(MenuLibsScroll_State.ScrollOffset.Y + MenuLibsScroll_State.Config.WindowSize.Y) < MenuLibsScroll_ML::NearestInteger(EndY)) {
3396 MenuLibsScroll_ScrollToPosition(_Frame_Scroll, EndY - MenuLibsScroll_State.Config.WindowSize.Y);
3397 }
3398 }
3399}
3400Void MenuLibsScroll_ScrollToElement(CMlFrame _Frame_Scroll, Integer _ElementKey) {
3401 MenuLibsScroll_ScrollToElement(_Frame_Scroll, _ElementKey, False);
3402}
3403
3404Void MenuLibsScroll_Private_ApplyInput(CMlFrame _Frame_Scroll, CMlScriptEvent::EMenuNavAction _NavAction) {
3405 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3406 if (!MenuLibsScroll_State.IsFocused) return;
3407
3408 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3409 Type = MenuLibsScroll_C_EventType_NavAction,
3410 Scroll = _Frame_Scroll,
3411 To = MenuLibsScroll_State.FocusedElement,
3412 ToKey = MenuLibsScroll_State.FocusedElementKey,
3413 NavAction = _NavAction
3414 });
3415 switch (_NavAction) {
3416 case CMlScriptEvent::EMenuNavAction::Left: {
3417 if (MenuLibsScroll_State.FocusedElementKey % MenuLibsScroll_State.Config.ElementsPerLine != 0) {
3418 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.FocusedElementKey - 1);
3419 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3420 } else {
3421 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3422 Type = MenuLibsScroll_C_EventType_ReachLimit,
3423 Scroll = _Frame_Scroll,
3424 From = MenuLibsScroll_State.FocusedElement,
3425 FromKey = MenuLibsScroll_State.FocusedElementKey,
3426 NavAction = _NavAction
3427 });
3428 }
3429 }
3430 case CMlScriptEvent::EMenuNavAction::Right: {
3431 if (
3432 MenuLibsScroll_State.FocusedElementKey % MenuLibsScroll_State.Config.ElementsPerLine != MenuLibsScroll_State.Config.ElementsPerLine - 1 &&
3433 MenuLibsScroll_State.FocusedElementKey < MenuLibsScroll_State.ElementsTotal - 1
3434 ) {
3435 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.FocusedElementKey + 1);
3436 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3437 } else {
3438 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3439 Type = MenuLibsScroll_C_EventType_ReachLimit,
3440 Scroll = _Frame_Scroll,
3441 From = MenuLibsScroll_State.FocusedElement,
3442 FromKey = MenuLibsScroll_State.FocusedElementKey,
3443 NavAction = _NavAction
3444 });
3445 }
3446 }
3447 case CMlScriptEvent::EMenuNavAction::Up: {
3448 if (MenuLibsScroll_State.FocusedElementKey > MenuLibsScroll_State.Config.ElementsPerLine - 1) {
3449 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.FocusedElementKey - MenuLibsScroll_State.Config.ElementsPerLine);
3450 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3451 } else {
3452 if (MenuLibsScroll_State.Header != Null) {
3453 MenuLibsScroll_ScrollToHeader(_Frame_Scroll);
3454 }
3455 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3456 Type = MenuLibsScroll_C_EventType_ReachLimit,
3457 Scroll = _Frame_Scroll,
3458 From = MenuLibsScroll_State.FocusedElement,
3459 FromKey = MenuLibsScroll_State.FocusedElementKey,
3460 NavAction = _NavAction
3461 });
3462 }
3463 }
3464 case CMlScriptEvent::EMenuNavAction::Down: {
3465 if (MenuLibsScroll_State.FocusedElementKey + MenuLibsScroll_State.Config.ElementsPerLine < MenuLibsScroll_State.ElementsTotal) {
3466 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.FocusedElementKey + MenuLibsScroll_State.Config.ElementsPerLine);
3467 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3468 } else if (
3469 MenuLibsScroll_State.FocusedElementKey < MenuLibsScroll_State.ElementsTotal - 1 &&
3470 MenuLibsScroll_State.FocusedElementKey / MenuLibsScroll_State.Config.ElementsPerLine != (MenuLibsScroll_State.ElementsTotal - 1) / MenuLibsScroll_State.Config.ElementsPerLine
3471 ) {
3472 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.ElementsTotal - 1);
3473 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3474 } else {
3475 if (MenuLibsScroll_State.Footer != Null){
3476 MenuLibsScroll_ScrollToFooter(_Frame_Scroll);
3477 }
3478 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3479 Type = MenuLibsScroll_C_EventType_ReachLimit,
3480 Scroll = _Frame_Scroll,
3481 From = MenuLibsScroll_State.FocusedElement,
3482 FromKey = MenuLibsScroll_State.FocusedElementKey,
3483 NavAction = _NavAction
3484 });
3485 }
3486 }
3487 case CMlScriptEvent::EMenuNavAction::Select: {
3488 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3489 Type = MenuLibsScroll_C_EventType_Select,
3490 Scroll = _Frame_Scroll,
3491 To = MenuLibsScroll_State.FocusedElement,
3492 ToKey = MenuLibsScroll_State.FocusedElementKey
3493 });
3494 }
3495 case CMlScriptEvent::EMenuNavAction::Cancel: {
3496 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3497 Type = MenuLibsScroll_C_EventType_Cancel,
3498 Scroll = _Frame_Scroll,
3499 To = MenuLibsScroll_State.FocusedElement,
3500 ToKey = MenuLibsScroll_State.FocusedElementKey
3501 });
3502 }
3503 }
3504}
3505
3506Boolean MenuLibsScroll_IsScroll(CMlControl _Control_Scroll) {
3507 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Control_Scroll;
3508 return MenuLibsScroll_State.IsInitialized;
3509}
3510
3511Void MenuLibsScroll_Focus(CMlFrame _Frame_Scroll) {
3512 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3513 MenuLibsScroll_State.IsFocused = True;
3514
3515 declare Integer ElementKeyMax = MenuLibsScroll_State.ElementsTotal - 1;
3516 if (MenuLibsScroll_State.FocusedElementKey < 0) {
3517 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, 0, 0);
3518 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3519 } else if (MenuLibsScroll_State.FocusedElementKey > ElementKeyMax) {
3520 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, ElementKeyMax - (ElementKeyMax % MenuLibsScroll_State.Config.ElementsPerLine), ElementKeyMax);
3521 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3522 } else {
3523 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State).StartKey, MenuLibsScroll_State.FocusedElementKey);
3524 }
3525}
3526
3527Void MenuLibsScroll_Unfocus(CMlFrame _Frame_Scroll) {
3528 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3529 MenuLibsScroll_State.IsFocused = False;
3530
3531 // Send a focus event but do not update State.FocusedElement
3532 // This way we can go back to the previously
3533 // focused element the next time the scroll is focused
3534 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
3535 Type = MenuLibsScroll_C_EventType_Focus,
3536 Scroll = _Frame_Scroll,
3537 From = MenuLibsScroll_State.FocusedElement,
3538 FromKey = MenuLibsScroll_State.FocusedElementKey,
3539 To = Null,
3540 ToKey = -1
3541 });
3542}
3543
3544CMlFrame MenuLibsScroll_GetFocusedElement(CMlFrame _Frame_Scroll) {
3545 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3546 return MenuLibsScroll_State.FocusedElement;
3547}
3548
3549Integer MenuLibsScroll_GetFocusedElementKey(CMlFrame _Frame_Scroll) {
3550 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3551 return MenuLibsScroll_State.FocusedElementKey;
3552}
3553
3554Boolean MenuLibsScroll_IsFocused(CMlFrame _Frame_Scroll) {
3555 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3556 return MenuLibsScroll_State.IsFocused;
3557}
3558
3559/** Use the local menu navigation events
3560 * instead of the events shared by the
3561 * ShareMenuNavigation component
3562 */
3563Void MenuLibsScroll_UseLocalEvents(Boolean _Enable) {
3564 MenuLibsScroll_G_UseLocalEvents = _Enable;
3565}
3566
3567Void MenuLibsScroll_LockNavigation(CMlFrame _Frame_Scroll, Boolean _Locked) {
3568 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3569 // Update lock position only if the scroll was not already locked
3570 if (_Locked && MenuLibsScroll_State.ScrollLocked != _Locked) {
3571 MenuLibsScroll_State.ScrollLockPosition = MenuLibsScroll_State.ScrollOffset;
3572 }
3573 MenuLibsScroll_State.ScrollLocked = _Locked;
3574}
3575
3576Void MenuLibsScroll_LockNavigation(Boolean _Locked) {
3577 foreach (Frame_Scroll in MenuLibsScroll_G_Frames_Scroll) {
3578 MenuLibsScroll_LockNavigation(Frame_Scroll, _Locked);
3579 }
3580}
3581
3582Boolean MenuLibsScroll_NavigationIsLocked(CMlFrame _Frame_Scroll) {
3583 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3584 return MenuLibsScroll_State.ScrollLocked;
3585}
3586
3587Void MenuLibsScroll_Private_UpdateScrollBarState(CMlFrame _Frame_ScrollBarFg, Integer _Action) {
3588 declare Boolean MenuLibsScroll_Clicked for _Frame_ScrollBarFg;
3589 declare Boolean MenuLibsScroll_Overed for _Frame_ScrollBarFg;
3590
3591 switch (_Action) {
3592 case MenuLibsScroll_C_Action_Click: {
3593 MenuLibsScroll_Clicked = True;
3594 }
3595 case MenuLibsScroll_C_Action_Unclick: {
3596 MenuLibsScroll_Clicked = False;
3597 }
3598 case MenuLibsScroll_C_Action_Over: {
3599 MenuLibsScroll_Overed = True;
3600 }
3601 case MenuLibsScroll_C_Action_Out: {
3602 MenuLibsScroll_Overed = False;
3603 }
3604 }
3605
3606 foreach (Control in _Frame_ScrollBarFg.Controls) {
3607 declare CMlQuad Quad_ScrollBarFg = (Control as CMlQuad);
3608 if (MenuLibsScroll_Clicked) {
3609 Quad_ScrollBarFg.Colorize = MenuLibsScroll_CL::Hex6ToRgb("555555");
3610 } else if (MenuLibsScroll_Overed) {
3611 Quad_ScrollBarFg.Colorize = MenuLibsScroll_CL::Hex6ToRgb("777777");
3612 } else {
3613 Quad_ScrollBarFg.Colorize = MenuLibsScroll_CL::Hex6ToRgb("ffffff");
3614 }
3615 }
3616}
3617
3618Integer MenuLibsScroll_GetElementsTotal(CMlFrame _Frame_Scroll) {
3619 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3620 return MenuLibsScroll_State.ElementsTotal;
3621}
3622
3623Void MenuLibsScroll_SetElementsTotal(CMlFrame _Frame_Scroll, Integer _ElementsTotal, Boolean _SendFocusEvent) {
3624 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3625 if (!MenuLibsScroll_State.IsInitialized) return;
3626
3627 MenuLibsScroll_State.ElementsTotal = _ElementsTotal;
3628 MenuLibsScroll_State.IsDisplayingStart = False;
3629 MenuLibsScroll_State.IsDisplayingEnd = False;
3630
3631 declare Integer LinesNb = MenuLibsScroll_State.ElementsTotal / MenuLibsScroll_State.Config.ElementsPerLine;
3632 if (MenuLibsScroll_State.ElementsTotal % MenuLibsScroll_State.Config.ElementsPerLine > 0) LinesNb += 1;
3633 _Frame_Scroll.ScrollMax = <0., MenuLibsScroll_ML::Max(0., MenuLibsScroll_State.Config.HeaderHeight + (LinesNb * (MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y)) - MenuLibsScroll_State.Config.MarginSize.Y + MenuLibsScroll_State.Config.FooterHeight - _Frame_Scroll.Size.Y)>;
3634
3635 if (MenuLibsScroll_State.Footer != Null) {
3636 MenuLibsScroll_State.Footer.RelativePosition_V3.Y = -MenuLibsScroll_State.Config.HeaderHeight - (LinesNb * (MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y)) + MenuLibsScroll_State.Config.MarginSize.Y;
3637 }
3638
3639 if (MenuLibsScroll_State.ScrollBar != Null) {
3640 MenuLibsScroll_State.ScrollBar.Visible = MenuLibsScroll_CanScroll(_Frame_Scroll);
3641 MenuLibsScroll_Private_SetScrollBarSize((MenuLibsScroll_State.ScrollBar.GetFirstChild("MenuLibsScroll_frame-scrollbar-fg") as CMlFrame), <
3642 MenuLibsScroll_State.ScrollBarWidth,
3643 MenuLibsScroll_ML::Max(MenuLibsScroll_ML::Min(10., _Frame_Scroll.Size.Y), (_Frame_Scroll.Size.Y / (_Frame_Scroll.Size.Y + _Frame_Scroll.ScrollMax.Y)) * _Frame_Scroll.Size.Y)
3644 >);
3645 }
3646
3647 declare Integer ElementKeyMax = MenuLibsScroll_State.ElementsTotal - 1;
3648 if (MenuLibsScroll_State.FocusedElementKey > ElementKeyMax) {
3649 MenuLibsScroll_Private_SetFocusedElementKey(_Frame_Scroll, ElementKeyMax - (ElementKeyMax % MenuLibsScroll_State.Config.ElementsPerLine), ElementKeyMax, False, _SendFocusEvent);
3650 MenuLibsScroll_ScrollToElement(_Frame_Scroll, MenuLibsScroll_State.FocusedElementKey);
3651 }
3652
3653 // If an animation is ongoing check that it is
3654 // still inside the new bounds
3655 if (MenuLibsScroll_State.Animation.StartTime >= 0) {
3656 declare Real ScrollTarget = MenuLibsScroll_State.Animation.ScrollStart + MenuLibsScroll_State.Animation.ScrollDelta;
3657 if (ScrollTarget >= 0. && ScrollTarget <= _Frame_Scroll.ScrollMax.Y) {
3658 MenuLibsScroll_Private_Scroll(_Frame_Scroll, 0., True, True, _SendFocusEvent);
3659 } else {
3660 // Scroll to new bound
3661 ScrollTarget = MenuLibsScroll_ML::Clamp(ScrollTarget, 0., _Frame_Scroll.ScrollMax.Y);
3662 MenuLibsScroll_Private_Scroll(_Frame_Scroll, (ScrollTarget - MenuLibsScroll_State.ScrollOffset.Y) / _Frame_Scroll.ScrollGrid.Y, True, False, _SendFocusEvent);
3663 }
3664 } else {
3665 MenuLibsScroll_Private_Scroll(_Frame_Scroll, 0., True, False, _SendFocusEvent);
3666 }
3667}
3668Void MenuLibsScroll_SetElementsTotal(CMlFrame _Frame_Scroll, Integer _ElementsTotal) {
3669 MenuLibsScroll_SetElementsTotal(_Frame_Scroll, _ElementsTotal, True);
3670}
3671
3672Void MenuLibsScroll_TriggerPagerUpdate(CMlFrame _Frame_Scroll, Text[] _EventCustomData) {
3673 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3674 if (!MenuLibsScroll_State.IsInitialized) return;
3675 MenuLibsScroll_State.Pager.ThrottleEndTime = Now;
3676 MenuLibsScroll_State.EventCustomData.add(_EventCustomData);
3677}
3678Void MenuLibsScroll_TriggerPagerUpdate(CMlFrame _Frame_Scroll) {
3679 MenuLibsScroll_TriggerPagerUpdate(_Frame_Scroll, []);
3680}
3681
3682Void MenuLibsScroll_ClearAllCustomData(CMlFrame _Frame_Scroll) {
3683 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3684 MenuLibsScroll_State.EventCustomData = [];
3685
3686}
3687
3688CMlFrame[Integer] MenuLibsScroll_GetElementsVisible(CMlFrame _Frame_Scroll) {
3689 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3690 declare MenuLibsScroll_K_ScrollPosition ScrollPosition = MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_State);
3691 declare CMlFrame[Integer] ElementsVisible;
3692
3693 foreach (Key => Frame_Element in MenuLibsScroll_State.Elements) {
3694 declare Integer ElementKey = ScrollPosition.StartKey + Key;
3695 if (ElementKey >= 0 && ElementKey <= MenuLibsScroll_State.ElementsTotal - 1) {
3696 ElementsVisible[ElementKey] = Frame_Element;
3697 }
3698 }
3699
3700 return ElementsVisible;
3701}
3702
3703Integer MenuLibsScroll_GetElementsPerLine(CMlFrame _Frame_Scroll) {
3704 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3705 return MenuLibsScroll_State.Config.ElementsPerLine;
3706}
3707
3708Void MenuLibsScroll_SetHeaderHeight(CMlFrame _Frame_Scroll, Real _Height) {
3709 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3710 MenuLibsScroll_State.Config.HeaderHeight = _Height;
3711 MenuLibsScroll_SetElementsTotal(_Frame_Scroll, MenuLibsScroll_State.ElementsTotal, False);
3712}
3713
3714Void MenuLibsScroll_SetFooterHeight(CMlFrame _Frame_Scroll, Real _Height) {
3715 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3716 MenuLibsScroll_State.Config.FooterHeight = _Height;
3717 MenuLibsScroll_SetElementsTotal(_Frame_Scroll, MenuLibsScroll_State.ElementsTotal, False);
3718}
3719
3720Void MenuLibsScroll_Display(CMlFrame _Frame_Scroll, Boolean _Display) {
3721 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3722 _Frame_Scroll.Visible = _Display;
3723 if (MenuLibsScroll_State.ScrollBar != Null) {
3724 MenuLibsScroll_State.ScrollBar.Visible = _Frame_Scroll.Visible;
3725 }
3726 if (MenuLibsScroll_State.ScrollIndicator != Null) {
3727 MenuLibsScroll_State.ScrollIndicator.Visible = _Frame_Scroll.Visible;
3728 }
3729 if (_Display) {
3730 MenuLibsScroll_SetElementsTotal(_Frame_Scroll, MenuLibsScroll_State.ElementsTotal, False);
3731 }
3732}
3733Void MenuLibsScroll_Show(CMlFrame _Frame_Scroll) {
3734 MenuLibsScroll_Display(_Frame_Scroll, True);
3735}
3736Void MenuLibsScroll_Hide(CMlFrame _Frame_Scroll) {
3737 MenuLibsScroll_Display(_Frame_Scroll, False);
3738}
3739
3740Void MenuLibsScroll_Private_Init(CMlFrame _Frame_Scroll) {
3741 declare MenuLibsScroll_K_Config Config = MenuLibsScroll_K_Config {
3742 DefaultElementsTotal = 0,
3743 ElementsPerLine = 0,
3744 ElementsPerPage = -1,
3745 ElementSize = <0., 0.>,
3746 MarginSize = <0., 0.>,
3747 WindowSize = <0., 0.>,
3748 HeaderHeight = 0.,
3749 FooterHeight = 0.,
3750 ScrollIndicator = True,
3751 ScrollIndicatorYOffset = 0.,
3752 ScrollIndicatorXOffset = 0.,
3753 AnimEnabled = True,
3754 ScrollGrid = <8., 8.>,
3755 ScrollBarVisibility = MenuLibsScroll_C_ScrollBarVisibility_DuringScroll,
3756 ScrollPadding = 0.,
3757 Skew = 0.,
3758 SkewVAlign = MenuLibsScroll_C_SkewVAlign_Top,
3759 ScrollIndicatorColorize = <-1., -1., -1.>,
3760 PagerPageSize = 0,
3761 PagerTriggerSize = 0,
3762 PagerMarginSize = 0
3763 };
3764 if (_Frame_Scroll.DataAttributeExists("config")) {
3765 Config.fromjson(_Frame_Scroll.DataAttributeGet("config"));
3766 }
3767 if (_Frame_Scroll.DataAttributeExists("elements-total")) {
3768 Config.DefaultElementsTotal = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("elements-total"));
3769 }
3770 if (_Frame_Scroll.DataAttributeExists("elements-per-line")) {
3771 Config.ElementsPerLine = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("elements-per-line"));
3772 }
3773 if (_Frame_Scroll.DataAttributeExists("elements-per-page")) {
3774 Config.ElementsPerPage = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("elements-per-page"));
3775 }
3776 if (_Frame_Scroll.DataAttributeExists("element-size")) {
3777 Config.ElementSize = ComponentMenuLibsTools_TextToVec2(_Frame_Scroll.DataAttributeGet("element-size"));
3778 }
3779 if (_Frame_Scroll.DataAttributeExists("margin-size")) {
3780 Config.MarginSize = ComponentMenuLibsTools_TextToVec2(_Frame_Scroll.DataAttributeGet("margin-size"));
3781 }
3782 if (_Frame_Scroll.DataAttributeExists("window-size")) {
3783 Config.WindowSize = ComponentMenuLibsTools_TextToVec2(_Frame_Scroll.DataAttributeGet("window-size"));
3784 }
3785 if (_Frame_Scroll.DataAttributeExists("header-height")) {
3786 Config.HeaderHeight = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("header-height"));
3787 }
3788 if (_Frame_Scroll.DataAttributeExists("footer-height")) {
3789 Config.FooterHeight = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("footer-height"));
3790 }
3791 if (_Frame_Scroll.DataAttributeExists("scroll-indicator")) {
3792 Config.ScrollIndicator = ComponentMenuLibsTools_TextToBoolean(_Frame_Scroll.DataAttributeGet("scroll-indicator"));
3793 }
3794 if (_Frame_Scroll.DataAttributeExists("scroll-indicator-y-offset")) {
3795 Config.ScrollIndicatorYOffset = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("scroll-indicator-y-offset"));
3796 }
3797 if (_Frame_Scroll.DataAttributeExists("scroll-indicator-x-offset")) {
3798 Config.ScrollIndicatorXOffset = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("scroll-indicator-x-offset"));
3799 }
3800 if (_Frame_Scroll.DataAttributeExists("enable-anim")) {
3801 Config.AnimEnabled = ComponentMenuLibsTools_TextToBoolean(_Frame_Scroll.DataAttributeGet("enable-anim"));
3802 }
3803 if (_Frame_Scroll.DataAttributeExists("scroll-grid-size")) {
3804 Config.ScrollGrid = ComponentMenuLibsTools_TextToVec2(_Frame_Scroll.DataAttributeGet("scroll-grid-size"));
3805 }
3806 if (_Frame_Scroll.DataAttributeExists("scrollbar-visibility")) {
3807 Config.ScrollBarVisibility = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("scrollbar-visibility"));
3808 }
3809 if (_Frame_Scroll.DataAttributeExists("scrollpadding")) {
3810 Config.ScrollPadding = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("scrollpadding"));
3811 }
3812 if (_Frame_Scroll.DataAttributeExists("skew")) {
3813 Config.Skew = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("skew"));
3814 }
3815 if (_Frame_Scroll.DataAttributeExists("skew-valign")) {
3816 Config.SkewVAlign = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("skew-valign"));
3817 }
3818 if (_Frame_Scroll.DataAttributeExists("scroll-indicator-image")) {
3819 Config.ScrollIndicatorImage = _Frame_Scroll.DataAttributeGet("scroll-indicator-image");
3820 }
3821 if (_Frame_Scroll.DataAttributeExists("scroll-indicator-colorize")) {
3822 Config.ScrollIndicatorColorize = MenuLibsScroll_CL::HexToRgb(_Frame_Scroll.DataAttributeGet("scroll-indicator-colorize"));
3823 }
3824 if (_Frame_Scroll.DataAttributeExists("scroll-indicator-size")) {
3825 Config.ScrollIndicatorSize = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("scroll-indicator-size"));
3826 }
3827 if (_Frame_Scroll.DataAttributeExists("scrollbar-xoffset")) {
3828 Config.ScrollBarXOffset = MenuLibsScroll_TL::ToReal(_Frame_Scroll.DataAttributeGet("scrollbar-xoffset"));
3829 }
3830 if (_Frame_Scroll.DataAttributeExists("pager-page-size")) {
3831 Config.PagerPageSize = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("pager-page-size"));
3832 }
3833 if (_Frame_Scroll.DataAttributeExists("pager-trigger-size")) {
3834 Config.PagerTriggerSize = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("pager-trigger-size"));
3835 }
3836 if (_Frame_Scroll.DataAttributeExists("pager-margin-size")) {
3837 Config.PagerMarginSize = MenuLibsScroll_TL::ToInteger(_Frame_Scroll.DataAttributeGet("pager-margin-size"));
3838 }
3839
3840 assert(Config.DefaultElementsTotal >= 0, "Incorrect 'elements-total' value: "^Config.DefaultElementsTotal);
3841 assert(Config.ElementsPerLine > 0, "Incorrect 'elements-per-line' value: "^Config.ElementsPerLine);
3842 assert(Config.ElementSize.X > 0. && Config.ElementSize.Y > 0., "Incorrect 'element-size' value: "^Config.ElementSize);
3843 assert(Config.MarginSize.X >= 0. && Config.MarginSize.Y >= 0., "Incorrect 'margin-size' value: "^Config.MarginSize);
3844 assert(Config.WindowSize.X > 0. && Config.WindowSize.Y > 0., "Incorrect 'window-size' value: "^Config.WindowSize);
3845 assert(Config.HeaderHeight >= 0., "Incorrect 'header-height' value: "^Config.HeaderHeight);
3846 assert(Config.FooterHeight >= 0., "Incorrect 'footer-height' value: "^Config.FooterHeight);
3847 assert(Config.ScrollGrid.X >= 0. && Config.ScrollGrid.Y >= 0., "Incorrect 'scroll-grid-size' value: "^Config.ScrollGrid);
3848
3849 declare MenuLibsScroll_K_State MenuLibsScroll_State for _Frame_Scroll;
3850 MenuLibsScroll_State = MenuLibsScroll_K_State {
3851 Config = Config,
3852 Animation = MenuLibsScroll_K_ScrollAnimation {
3853 StartTime = -1,
3854 ScrollStart = 0.,
3855 ScrollDelta = 0.,
3856 Duration = 0
3857 },
3858 ElementsTotal = Config.DefaultElementsTotal,
3859 Elements = [],
3860 Header = Null,
3861 Footer = Null,
3862 IsFocused = False,
3863 FocusedElementKey = -1,
3864 FocusedElement = Null,
3865 ScrollIndicator = Null,
3866 CanPreScroll = False,
3867 IsDisplayingStart = False,
3868 IsDisplayingEnd = False,
3869 ScrollOffset = <0., 0.>,
3870 IsInitialized = True,
3871 ScrollBarWidth = 2.,
3872 ScrollBarHideTime = -1,
3873 ScrollLocked = False,
3874 ScrollLockPosition = <0., 0.>
3875 };
3876
3877 _Frame_Scroll.ScrollActive = True;
3878 _Frame_Scroll.ScrollOffset = <0., 0.>;
3879 _Frame_Scroll.ScrollGrid = MenuLibsScroll_State.Config.ScrollGrid;
3880 _Frame_Scroll.ScrollMin = <0., 0.>;
3881 _Frame_Scroll.Size = MenuLibsScroll_State.Config.WindowSize;
3882 _Frame_Scroll.Size.X += MenuLibsScroll_State.Config.ScrollPadding * 2.;
3883 _Frame_Scroll.RelativePosition_V3.X -= MenuLibsScroll_State.Config.ScrollPadding;
3884
3885 // Get scroll elements
3886 declare Integer VisibleLinesNb = MenuLibsScroll_ML::CeilingInteger(MenuLibsScroll_State.Config.WindowSize.Y / (MenuLibsScroll_State.Config.ElementSize.Y + MenuLibsScroll_State.Config.MarginSize.Y)) + 1;
3887 MenuLibsScroll_State.CanPreScroll = VisibleLinesNb > 3;
3888 declare Integer RequiredElementsNb = MenuLibsScroll_State.Config.ElementsPerLine * VisibleLinesNb;
3889 Page.GetClassChildren("menu-libs-scroll-element", _Frame_Scroll, False);
3890 declare CMlFrame[] Frames_Element;
3891 foreach (Control in Page.GetClassChildren_Result) {
3892 assert((Control is CMlFrame), "The 'Scroll::C_Class_Element' controls must be CMlFrame");
3893 declare CMlFrame Frame_Element = (Control as CMlFrame); //< Point to the frame instead of the array key
3894 Frames_Element.add(Frame_Element);
3895 }
3896 assert(Frames_Element.count == RequiredElementsNb, "You must add "^RequiredElementsNb^" frames with a class of 'Scroll::C_Class_Element' as direct child of the scroll frame '"^_Frame_Scroll.ControlId^"'. Found "^Frames_Element.count);
3897 MenuLibsScroll_State.Elements = Frames_Element;
3898
3899 // Get scroll header
3900 Page.GetClassChildren("menu-libs-scroll-header", _Frame_Scroll, False);
3901 declare CMlFrame Frame_Header;
3902 foreach (Control in Page.GetClassChildren_Result) {
3903 assert((Control is CMlFrame), "The 'Scroll::C_Class_Header' control must be CMlFrame");
3904 Frame_Header = (Control as CMlFrame); //< Point to the frame instead of the array key
3905 }
3906 MenuLibsScroll_State.Header = Frame_Header;
3907 if (MenuLibsScroll_State.Header != Null) {
3908 MenuLibsScroll_State.Header.RelativePosition_V3.X += MenuLibsScroll_State.Config.ScrollPadding;
3909 }
3910
3911 // Get scroll footer
3912 Page.GetClassChildren("menu-libs-scroll-footer", _Frame_Scroll, False);
3913 declare CMlFrame Frame_Footer;
3914 foreach (Control in Page.GetClassChildren_Result) {
3915 assert((Control is CMlFrame), "The 'Scroll::C_Class_Footer' control must be CMlFrame");
3916 Frame_Footer = (Control as CMlFrame); //< Point to the frame instead of the array key
3917 }
3918 MenuLibsScroll_State.Footer = Frame_Footer;
3919 if (MenuLibsScroll_State.Footer != Null) {
3920 MenuLibsScroll_State.Footer.RelativePosition_V3.X += MenuLibsScroll_State.Config.ScrollPadding;
3921 }
3922
3923 // Find elements activation zones
3924 foreach (RelativeKey => Element in MenuLibsScroll_State.Elements) {
3925 Page.GetClassChildren("menu-libs-scroll-activation-zone", Element, True);
3926 foreach (Control in Page.GetClassChildren_Result) {
3927 declare MenuLibsScroll_K_ActivationZone MenuLibsScroll_ActivationZone for Control;
3928 MenuLibsScroll_ActivationZone = MenuLibsScroll_K_ActivationZone {
3929 Scroll = _Frame_Scroll,
3930 ElementRelativeKey = RelativeKey,
3931 Element = Element
3932 };
3933 }
3934 }
3935
3936 // Find event generator
3937 Page.GetClassChildren("menu-libs-scroll-event", _Frame_Scroll, False);
3938 declare CMlQuad Quad_EventGenerator;
3939 foreach (Control in Page.GetClassChildren_Result) {
3940 assert((Control is CMlQuad), "The 'Scroll::C_Class_ScrollEvent' control must be CMlQuad");
3941 Quad_EventGenerator = (Control as CMlQuad); //< Point to the frame instead of the array key
3942 }
3943 if (Quad_EventGenerator != Null) {
3944 Quad_EventGenerator.RelativePosition_V3 = <0., 0.>;
3945 Quad_EventGenerator.Size = _Frame_Scroll.Size;
3946 Quad_EventGenerator.Opacity = 0.;
3947 }
3948 MenuLibsScroll_State.EventGenerator = Quad_EventGenerator;
3949
3950 // Find the scroll frameinstance associated to this scroll window
3951 declare CMlLabel Label_ScrollIndicator;
3952 declare CMlQuad Quad_ScrollIndicator;
3953 declare CMlFrame Frame_ScrollBar;
3954 if (
3955 MenuLibsScroll_State.Config.ScrollIndicator ||
3956 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_Always ||
3957 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_DuringScroll
3958 ) {
3959 Page.GetClassChildren("MenuLibsScroll_scroll-widgets", Page.MainFrame, True);
3960 foreach (Control in Page.GetClassChildren_Result) {
3961 if (Control.Parent.DataAttributeExists("scroll-parent")) {
3962 if (Control.Parent.DataAttributeGet("scroll-parent") == _Frame_Scroll.ControlId) {
3963 declare Frame_ScrollWidgets = (Control as CMlFrame);
3964 Label_ScrollIndicator <=> (Frame_ScrollWidgets.GetFirstChild("MenuLibsScroll_label-scroll-indicator") as CMlLabel);
3965 Quad_ScrollIndicator <=> (Frame_ScrollWidgets.GetFirstChild("MenuLibsScroll_quad-scroll-indicator") as CMlQuad);
3966 Frame_ScrollBar <=> (Frame_ScrollWidgets.GetFirstChild("MenuLibsScroll_frame-scrollbar") as CMlFrame);
3967 declare CMlFrame MenuLibsScroll_Scroll as ScrollForLabel for Label_ScrollIndicator;
3968 declare CMlFrame MenuLibsScroll_Scroll as ScrollForQuad for Quad_ScrollIndicator;
3969 ScrollForLabel = _Frame_Scroll;
3970 ScrollForQuad = _Frame_Scroll;
3971 break;
3972 }
3973 }
3974 }
3975 }
3976
3977 // Initialize scroll indicator
3978 if (MenuLibsScroll_State.Config.ScrollIndicator) {
3979 assert(Label_ScrollIndicator != Null, "You must add a 'Scroll::C_Name' frameinstance next to the scroll window frame to enable the scroll indicator");
3980 assert(Quad_ScrollIndicator != Null, "You must add a 'Scroll::C_Name' frameinstance next to the scroll window frame to enable the scroll indicator");
3981 Label_ScrollIndicator.RelativePosition_V3 = (_Frame_Scroll.AbsolutePosition_V3 - Label_ScrollIndicator.AbsolutePosition_V3) + <_Frame_Scroll.Size.X * 0.5 + Config.ScrollIndicatorXOffset, -_Frame_Scroll.Size.Y + Config.ScrollIndicatorYOffset>;
3982 Quad_ScrollIndicator.RelativePosition_V3 = (_Frame_Scroll.AbsolutePosition_V3 - Quad_ScrollIndicator.AbsolutePosition_V3) + <_Frame_Scroll.Size.X * 0.5 + Config.ScrollIndicatorXOffset, -_Frame_Scroll.Size.Y + Config.ScrollIndicatorYOffset>;
3983 if (MenuLibsScroll_State.Config.ScrollIndicatorSize > 0.) {
3984 Label_ScrollIndicator.TextSizeReal = MenuLibsScroll_State.Config.ScrollIndicatorSize;
3985 Quad_ScrollIndicator.Size = <MenuLibsScroll_State.Config.ScrollIndicatorSize, MenuLibsScroll_State.Config.ScrollIndicatorSize>;
3986 }
3987
3988 if (MenuLibsScroll_State.Config.ScrollIndicatorImage != "") {
3989 Quad_ScrollIndicator.ChangeImageUrl(MenuLibsScroll_State.Config.ScrollIndicatorImage);
3990 MenuLibsScroll_State.ScrollIndicator = Quad_ScrollIndicator;
3991 Quad_ScrollIndicator.Colorize = MenuLibsScroll_State.Config.ScrollIndicatorColorize;
3992 } else {
3993 MenuLibsScroll_State.ScrollIndicator = Label_ScrollIndicator;
3994 if (MenuLibsScroll_State.Config.ScrollIndicatorColorize != <-1., -1., -1.>) {
3995 Label_ScrollIndicator.TextColor = MenuLibsScroll_State.Config.ScrollIndicatorColorize;
3996 }
3997 }
3998 }
3999
4000 // Initialize scrollbar
4001 if (
4002 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_Always ||
4003 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_DuringScroll
4004 ) {
4005 assert(Frame_ScrollBar != Null, "You must add a 'Scroll::C_Name' frameinstance next to the scroll window frame to enable the scrollbar");
4006 declare CMlFrame Frame_ScrollBarBg <=> (Frame_ScrollBar.GetFirstChild("MenuLibsScroll_frame-scrollbar-bg") as CMlFrame);
4007 declare CMlFrame Frame_ScrollBarFg <=> (Frame_ScrollBar.GetFirstChild("MenuLibsScroll_frame-scrollbar-fg") as CMlFrame);
4008 MenuLibsScroll_State.ScrollBar = Frame_ScrollBar;
4009 declare Vec2 Size = <MenuLibsScroll_State.ScrollBarWidth, _Frame_Scroll.Size.Y>;
4010 declare Vec2 ScrollSize = <_Frame_Scroll.Size.X, 0.>;
4011 if (MenuLibsScroll_State.Config.Skew < 0.) ScrollSize.X -= MenuLibsScroll_State.Config.ScrollPadding;
4012 ScrollSize.X += MenuLibsScroll_State.Config.ScrollBarXOffset;
4013 Frame_ScrollBar.RelativePosition_V3 = (_Frame_Scroll.AbsolutePosition_V3 - Frame_ScrollBar.AbsolutePosition_V3) + Frame_ScrollBar.RelativePosition_V3 + ScrollSize;
4014 MenuLibsScroll_Private_SetScrollBarSize(Frame_ScrollBarBg, Size);
4015 MenuLibsScroll_Private_SetScrollBarSize(Frame_ScrollBarFg, Size);
4016 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for Frame_ScrollBarFg;
4017 MenuLibsScroll_ScrollBarState.Scroll = _Frame_Scroll;
4018 MenuLibsScroll_Private_DisplayScrollBar(MenuLibsScroll_State.ScrollBar, (MenuLibsScroll_State.Config.ScrollBarVisibility != MenuLibsScroll_C_ScrollBarVisibility_DuringScroll));
4019 }
4020
4021 // Initialize clamped controls
4022 Page.GetClassChildren("menu-libs-scroll-clamped-control", _Frame_Scroll, True);
4023 foreach (Control in Page.GetClassChildren_Result) {
4024 declare CMlControl ClampedControl = Control; //< Point to the frame instead of the array key
4025 declare Integer Type = 2;
4026 if (ClampedControl.DataAttributeExists("clamped-control-type")) {
4027 Type = MenuLibsScroll_TL::ToInteger(ClampedControl.DataAttributeGet("clamped-control-type"));
4028 }
4029 declare Integer VAlign = 0;
4030 if (ClampedControl.DataAttributeExists("clamped-control-valign")) {
4031 VAlign = MenuLibsScroll_TL::ToInteger(ClampedControl.DataAttributeGet("clamped-control-valign"));
4032 }
4033 declare Real Height = 0.;
4034 if (ClampedControl.DataAttributeExists("clamped-control-height")) {
4035 Height = MenuLibsScroll_TL::ToReal(ClampedControl.DataAttributeGet("clamped-control-height"));
4036 }
4037
4038 declare Real OffsetTop = 0.;
4039 if (VAlign == 1) {
4040 OffsetTop = Height * 0.5;
4041 } else if (VAlign == 2) {
4042 OffsetTop = Height;
4043 }
4044 declare Real OffsetBottom = 0.;
4045 if (VAlign == 1) {
4046 OffsetBottom = Height * 0.5;
4047 } else if (VAlign == 0) {
4048 OffsetBottom = Height;
4049 }
4050
4051 declare Real LimitTop = _Frame_Scroll.AbsolutePosition_V3.Y - OffsetTop;
4052 declare Real LimitBottom = _Frame_Scroll.AbsolutePosition_V3.Y - _Frame_Scroll.Size.Y + OffsetBottom;
4053
4054 MenuLibsScroll_State.ClampedControls.add(MenuLibsScroll_K_ClampedControl {
4055 Control = ClampedControl,
4056 Type = Type,
4057 Limit = <LimitTop, LimitBottom>,
4058 Origin = ClampedControl.RelativePosition_V3.Y,
4059 ClampedTop = False,
4060 ClampedBottom = False
4061 });
4062 }
4063
4064 // Initialize stick controls
4065 Page.GetClassChildren("menu-libs-scroll-stick-control", _Frame_Scroll, True);
4066 foreach (Control in Page.GetClassChildren_Result) {
4067 declare CMlControl StickControl = Control; //< Point to the frame instead of the array key
4068 declare Real MenuLibsScroll_BasePosX for StickControl;
4069 MenuLibsScroll_BasePosX = StickControl.RelativePosition_V3.X;
4070 MenuLibsScroll_State.StickControls.add(StickControl);
4071 }
4072
4073 // Initialize pager
4074 MenuLibsScroll_State.Pager = MenuLibsScroll_K_Pager {
4075 ThrottleEndTime = -1,
4076 CooldownEndTime = -1,
4077 Limits = <0, 0>
4078 };
4079 if (MenuLibsScroll_State.Config.PagerPageSize > 0) {
4080 if (MenuLibsScroll_State.Config.PagerTriggerSize <= 0) {
4081 MenuLibsScroll_State.Config.PagerTriggerSize = MenuLibsScroll_State.Config.PagerPageSize;
4082 }
4083 if (MenuLibsScroll_State.Config.PagerMarginSize <= 0) {
4084 MenuLibsScroll_State.Config.PagerMarginSize = MenuLibsScroll_ML::Max(1, MenuLibsScroll_State.Config.PagerPageSize / 2);
4085 }
4086 }
4087
4088 MenuLibsScroll_SetElementsTotal(_Frame_Scroll, MenuLibsScroll_State.ElementsTotal);
4089}
4090
4091***MainInit***
4092***
4093Page.GetClassChildren("menu-libs-scroll-window", Page.MainFrame, True);
4094foreach (Control in Page.GetClassChildren_Result) {
4095 declare CMlFrame Frame_Scroll = (Control as CMlFrame); //< Point to the frame instead of the array key
4096 MenuLibsScroll_G_Frames_Scroll.add(Frame_Scroll);
4097}
4098foreach (Frame_Scroll in MenuLibsScroll_G_Frames_Scroll) {
4099 MenuLibsScroll_Private_Init(Frame_Scroll);
4100}
4101
4102declare CMlFrame MenuLibsScroll_Frame_ActiveScrollBar;
4103***
4104
4105***MainStart***
4106***
4107MenuLibsScroll_Frame_ActiveScrollBar = Null;
4108***
4109
4110***MainLoop***
4111***
4112MenuLibsScroll_PendingEvents = MenuLibsScroll_DelayedPendingEvents;
4113MenuLibsScroll_DelayedPendingEvents = [];
4114
4115foreach (Event in MenuLibsScroll_PendingEvents) {
4116 if (Event.Type == MenuLibsScroll_C_EventType_Update && Event.DelayedElementsUpdate) {
4117 // Delay the elements placement until the component
4118 // user receive the event
4119 // This way we avoid a small flickering between
4120 // the two operations (elements placement => 1 frame => user receive event and update elements)
4121 // if the placement was done directly in the Private_Scroll function
4122 declare MenuLibsScroll_K_State MenuLibsScroll_State for Event.Scroll;
4123 MenuLibsScroll_Private_UpdateElementsPosition(MenuLibsScroll_State, Event.ScrollPosition);
4124 }
4125}
4126
4127if (PageIsVisible) {
4128 foreach (Event in PendingEvents) {
4129 switch (Event.Type) {
4130 case CMlScriptEvent::Type::MouseClick: {
4131 if (Event.Control.HasClass("menu-libs-scroll-activation-zone")) {
4132 declare MenuLibsScroll_K_ActivationZone MenuLibsScroll_ActivationZone for Event.Control;
4133 if (!MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ActivationZone.Scroll)) {
4134 declare MenuLibsScroll_K_ScrollPosition ScrollPosition = MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_ActivationZone.Scroll);
4135 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
4136 Type = MenuLibsScroll_C_EventType_Select,
4137 Scroll = MenuLibsScroll_ActivationZone.Scroll,
4138 To = MenuLibsScroll_ActivationZone.Element,
4139 ToKey = ScrollPosition.StartKey + MenuLibsScroll_ActivationZone.ElementRelativeKey,
4140 IsMouse = True
4141 });
4142 }
4143 } else if (Event.Control != Null && Event.Control.HasClass("MenuLibsScroll_scrollbar-fg")) {
4144 declare CMlFrame Frame_ScrollBar = Event.Control.Parent;
4145 MenuLibsScroll_Frame_ActiveScrollBar = Frame_ScrollBar;
4146 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for MenuLibsScroll_Frame_ActiveScrollBar;
4147 if (!MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ScrollBarState.Scroll)) {
4148 MenuLibsScroll_Private_UpdateScrollBarState(Frame_ScrollBar, MenuLibsScroll_C_Action_Click);
4149 MenuLibsScroll_ScrollBarState.AbsoluteTop = MenuLibsScroll_ScrollBarState.Scroll.AbsolutePosition_V3.Y;
4150 MenuLibsScroll_ScrollBarState.AbsoluteBottom = MenuLibsScroll_ScrollBarState.AbsoluteTop - MenuLibsScroll_ScrollBarState.Scroll.Size.Y + MenuLibsScroll_ScrollBarState.Height;
4151 MenuLibsScroll_ScrollBarState.ClickShift = Input.MousePos.Y - MenuLibsScroll_Frame_ActiveScrollBar.AbsolutePosition_V3.Y;
4152 }
4153 } else if (
4154 Event.Control != Null && (
4155 Event.Control.ControlId == "MenuLibsScroll_label-scroll-indicator" ||
4156 Event.Control.ControlId == "MenuLibsScroll_quad-scroll-indicator"
4157 )
4158 ) {
4159 declare CMlFrame MenuLibsScroll_Scroll for Event.Control;
4160 if (MenuLibsScroll_Scroll != Null && !MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_Scroll)) {
4161 declare MenuLibsScroll_K_State MenuLibsScroll_State for MenuLibsScroll_Scroll;
4162 MenuLibsScroll_ScrollToElement(MenuLibsScroll_Scroll, MenuLibsScroll_State.FocusedElementKey + MenuLibsScroll_State.Config.ElementsPerLine, True);
4163 }
4164 }
4165 }
4166 case CMlScriptEvent::Type::MouseOver: {
4167 if (Event.Control.HasClass("menu-libs-scroll-activation-zone")) {
4168 if (!ComponentNavigation_MouseIsSleeping()) {
4169 declare MenuLibsScroll_K_ActivationZone MenuLibsScroll_ActivationZone for Event.Control;
4170 if (!MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ActivationZone.Scroll)) {
4171 declare MenuLibsScroll_K_ScrollPosition ScrollPosition = MenuLibsScroll_Private_GetScrollPosition(MenuLibsScroll_ActivationZone.Scroll);
4172 MenuLibsScroll_Private_SetFocusedElementKey(MenuLibsScroll_ActivationZone.Scroll, ScrollPosition.StartKey, ScrollPosition.StartKey + MenuLibsScroll_ActivationZone.ElementRelativeKey, True);
4173 }
4174 }
4175 } else if (Event.Control != Null && Event.Control.HasClass("MenuLibsScroll_scrollbar-fg")) {
4176 if (!ComponentNavigation_MouseIsSleeping()) {
4177 declare CMlFrame Frame_ScrollBar = Event.Control.Parent;
4178 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for Frame_ScrollBar;
4179 if (!MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ScrollBarState.Scroll)) {
4180 MenuLibsScroll_Private_UpdateScrollBarState(Frame_ScrollBar, MenuLibsScroll_C_Action_Over);
4181 }
4182 }
4183 }
4184 }
4185 case CMlScriptEvent::Type::MouseOut: {
4186 if (Event.Control != Null && Event.Control.HasClass("MenuLibsScroll_scrollbar-fg")) {
4187 declare CMlFrame Frame_ScrollBar = Event.Control.Parent;
4188 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for Frame_ScrollBar;
4189 if (!MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ScrollBarState.Scroll)) {
4190 MenuLibsScroll_Private_UpdateScrollBarState(Frame_ScrollBar, MenuLibsScroll_C_Action_Out);
4191 }
4192 }
4193 }
4194 }
4195 }
4196
4197 if (MenuLibsScroll_G_UseLocalEvents) {
4198 foreach (Event in PendingEvents) {
4199 if (Event.Type == CMlScriptEvent::Type::MenuNavigation) {
4200 foreach (Frame_Scroll in MenuLibsScroll_G_Frames_Scroll) {
4201 if (!MenuLibsScroll_NavigationIsLocked(Frame_Scroll)) {
4202 MenuLibsScroll_Private_ApplyInput(Frame_Scroll, Event.MenuNavAction);
4203 }
4204 }
4205 }
4206 }
4207 } else if (ComponentNavigation_GetGlobalSoloGroups().count <= 0) {
4208 foreach (Event in ShareMenuNavigation_PendingEvents) {
4209 foreach (Frame_Scroll in MenuLibsScroll_G_Frames_Scroll) {
4210 if (!MenuLibsScroll_NavigationIsLocked(Frame_Scroll)) {
4211 MenuLibsScroll_Private_ApplyInput(Frame_Scroll, Event.MenuNavAction);
4212 }
4213 }
4214 }
4215 }
4216
4217 if (MenuLibsScroll_Frame_ActiveScrollBar != Null) {
4218 declare MenuLibsScroll_K_ScrollBarState MenuLibsScroll_ScrollBarState for MenuLibsScroll_Frame_ActiveScrollBar;
4219 if (Input.MouseLeftButton && !MenuLibsScroll_NavigationIsLocked(MenuLibsScroll_ScrollBarState.Scroll)) {
4220 declare Real AbsolutePosY = MenuLibsScroll_ML::Clamp(
4221 Input.MousePos.Y - MenuLibsScroll_ScrollBarState.ClickShift,
4222 MenuLibsScroll_ScrollBarState.AbsoluteBottom,
4223 MenuLibsScroll_ScrollBarState.AbsoluteTop
4224 );
4225 declare Real ScrollRatio = (MenuLibsScroll_ScrollBarState.AbsoluteTop - AbsolutePosY) / (MenuLibsScroll_ScrollBarState.AbsoluteTop - MenuLibsScroll_ScrollBarState.AbsoluteBottom);
4226 MenuLibsScroll_ScrollToPosition(MenuLibsScroll_ScrollBarState.Scroll, MenuLibsScroll_ScrollBarState.Scroll.ScrollMax.Y * ScrollRatio, False);
4227 } else {
4228 MenuLibsScroll_Private_UpdateScrollBarState(MenuLibsScroll_Frame_ActiveScrollBar, MenuLibsScroll_C_Action_Unclick);
4229 MenuLibsScroll_Frame_ActiveScrollBar = Null;
4230 }
4231 }
4232
4233 foreach (Frame_Scroll in MenuLibsScroll_G_Frames_Scroll) {
4234 declare MenuLibsScroll_K_State MenuLibsScroll_State for Frame_Scroll;
4235 if (MenuLibsScroll_NavigationIsLocked(Frame_Scroll) && Frame_Scroll.ScrollOffset != MenuLibsScroll_State.ScrollLockPosition) {
4236 Frame_Scroll.ScrollOffset = <
4237 MenuLibsScroll_ML::Clamp(MenuLibsScroll_State.ScrollLockPosition.X, Frame_Scroll.ScrollMin.X, Frame_Scroll.ScrollMax.X),
4238 MenuLibsScroll_ML::Clamp(MenuLibsScroll_State.ScrollLockPosition.Y, Frame_Scroll.ScrollMin.Y, Frame_Scroll.ScrollMax.Y)
4239 >;
4240 MenuLibsScroll_State.ScrollLockPosition = Frame_Scroll.ScrollOffset;
4241 }
4242 if (MenuLibsScroll_State.ScrollIndicator != Null && MenuLibsScroll_State.ScrollIndicator.Visible) {
4243 switchtype(MenuLibsScroll_State.ScrollIndicator) {
4244 case CMlQuad: (MenuLibsScroll_State.ScrollIndicator as CMlQuad).Opacity = (MenuLibsScroll_ML::Cos(Now * 0.005) * 0.5) + 0.5;
4245 case CMlLabel: (MenuLibsScroll_State.ScrollIndicator as CMlLabel).Opacity = (MenuLibsScroll_ML::Cos(Now * 0.005) * 0.5) + 0.5;
4246 }
4247 }
4248 if (
4249 MenuLibsScroll_State.Config.ScrollBarVisibility == MenuLibsScroll_C_ScrollBarVisibility_DuringScroll &&
4250 MenuLibsScroll_State.ScrollBar != Null &&
4251 MenuLibsScroll_State.ScrollBar.Visible &&
4252 MenuLibsScroll_State.ScrollBarHideTime >= 0 &&
4253 Now >= MenuLibsScroll_State.ScrollBarHideTime
4254 ) {
4255 MenuLibsScroll_Private_DisplayScrollBar(MenuLibsScroll_State.ScrollBar, False);
4256 MenuLibsScroll_State.ScrollBarHideTime = -1;
4257 }
4258 if (MenuLibsScroll_State.Animation.StartTime >= 0) {
4259 if (Now >= MenuLibsScroll_State.Animation.StartTime + MenuLibsScroll_State.Animation.Duration) {
4260 MenuLibsScroll_State.Animation.StartTime = -1;
4261 declare Real FinalOffsetY = MenuLibsScroll_State.Animation.ScrollStart + MenuLibsScroll_State.Animation.ScrollDelta;
4262 MenuLibsScroll_Private_Scroll(Frame_Scroll, (FinalOffsetY - MenuLibsScroll_State.ScrollOffset.Y) / Frame_Scroll.ScrollGrid.Y, False, True, True);
4263 } else {
4264 declare Real NewOffsetY = MenuLibsScroll_AL::EaseOutQuad(
4265 Now - MenuLibsScroll_State.Animation.StartTime,
4266 MenuLibsScroll_State.Animation.ScrollStart,
4267 MenuLibsScroll_State.Animation.ScrollDelta,
4268 MenuLibsScroll_State.Animation.Duration
4269 );
4270 MenuLibsScroll_Private_Scroll(Frame_Scroll, (NewOffsetY - MenuLibsScroll_State.ScrollOffset.Y) / Frame_Scroll.ScrollGrid.Y, False, True, True);
4271 }
4272 }
4273 if (MenuLibsScroll_State.ScrollOffset != Frame_Scroll.ScrollOffset) {
4274 MenuLibsScroll_ScrollToPosition(Frame_Scroll, Frame_Scroll.ScrollOffset.Y, False);
4275 }
4276 if (MenuLibsScroll_State.Pager.ThrottleEndTime >= 0 && Now >= MenuLibsScroll_State.Pager.ThrottleEndTime) {
4277 MenuLibsScroll_State.Pager.ThrottleEndTime = -1;
4278 MenuLibsScroll_State.Pager.CooldownEndTime = Now + MenuLibsScroll_C_PagerThrottleDuration;
4279 declare MenuLibsScroll_K_ScrollPosition ScrollPosition = MenuLibsScroll_Private_GetScrollPosition(Frame_Scroll);
4280 MenuLibsScroll_State.Pager.Limits = <
4281 ScrollPosition.StartKey - MenuLibsScroll_State.Config.PagerTriggerSize,
4282 ScrollPosition.StartKey + MenuLibsScroll_State.Config.PagerTriggerSize
4283 >;
4284 MenuLibsScroll_DelayedPendingEvents.add(MenuLibsScroll_K_Event {
4285 Type = MenuLibsScroll_C_EventType_PagerUpdate,
4286 Scroll = Frame_Scroll,
4287 PagerOffset = MenuLibsScroll_ML::Max(0, ScrollPosition.StartKey - MenuLibsScroll_State.Config.PagerTriggerSize - MenuLibsScroll_State.Config.PagerMarginSize),
4288 PagerCount = MenuLibsScroll_ML::Max(1, MenuLibsScroll_State.Config.PagerPageSize + (2 * MenuLibsScroll_State.Config.PagerTriggerSize) + (2 * MenuLibsScroll_State.Config.PagerMarginSize)),
4289 CustomData = MenuLibsScroll_State.EventCustomData
4290 });
4291 MenuLibsScroll_ClearAllCustomData(Frame_Scroll);
4292 }
4293 }
4294}
4295***
4296
4297// */
4298// @Component end menu-libs-scroll
4299
4300// @Component start component-menulibs-menusounds
4301// /*
4302
4303declare CMlScriptEvent::EMenuNavAction[] ComponentMenuLibsMenuSounds_G_DisabledForInputs;
4304declare CMlScriptEvent::Type[] ComponentMenuLibsMenuSounds_G_DisabledForMouses;
4305
4306Void ComponentMenuLibsMenuSounds_SetCustomFocusSound(CMlControl _Control, Text _SoundName) {
4307 if (_Control != Null) {
4308 declare Text ComponentMenuLibsMenuSounds_FocusSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Focus;
4309 ComponentMenuLibsMenuSounds_FocusSound = _SoundName;
4310 }
4311}
4312
4313Void ComponentMenuLibsMenuSounds_SetCustomSelectSound(CMlControl _Control, Text _SoundName) {
4314 if (_Control != Null) {
4315 declare Text ComponentMenuLibsMenuSounds_SelectSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Select;
4316 ComponentMenuLibsMenuSounds_SelectSound = _SoundName;
4317 }
4318}
4319
4320Void ComponentMenuLibsMenuSounds_SetCustomCancelSound(CMlControl _Control, Text _SoundName) {
4321 if (_Control != Null) {
4322 declare Text ComponentMenuLibsMenuSounds_CancelSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Cancel;
4323 ComponentMenuLibsMenuSounds_CancelSound = _SoundName;
4324 }
4325}
4326
4327Text ComponentMenuLibsMenuSounds_GetCustomFocusSound(CMlControl _Control) {
4328 declare Text Result = "";
4329 if (_Control != Null) {
4330 declare Text ComponentMenuLibsMenuSounds_FocusSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Focus;
4331 Result = ComponentMenuLibsMenuSounds_FocusSound;
4332 }
4333 return Result;
4334}
4335
4336Text ComponentMenuLibsMenuSounds_GetCustomSelectSound(CMlControl _Control) {
4337 declare Text Result = "";
4338 if (_Control != Null) {
4339 declare Text ComponentMenuLibsMenuSounds_SelectSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Select;
4340 Result = ComponentMenuLibsMenuSounds_SelectSound;
4341 }
4342 return Result;
4343}
4344
4345Text ComponentMenuLibsMenuSounds_GetCustomCancelSound(CMlControl _Control) {
4346 declare Text Result = "";
4347 if (_Control != Null) {
4348 declare Text ComponentMenuLibsMenuSounds_CancelSound for _Control = ComponentMenuLibsMenuSounds_C_Sound_Cancel;
4349 Result = ComponentMenuLibsMenuSounds_CancelSound;
4350 }
4351 return Result;
4352}
4353
4354Void ComponentMenuLibsMenuSounds_PlaySound(Text _Sound) {
4355 if (_Sound != "") {
4356 ComponentCommonLibsAudioManager_StopSound(_Sound);
4357 ComponentCommonLibsAudioManager_PlaySound(_Sound);
4358 }
4359}
4360
4361Void ComponentMenuLibsMenuSounds_PlayFocusSound(CMlControl _To) {
4362 declare Text SoundToPlay = ComponentMenuLibsMenuSounds_GetCustomFocusSound(_To);
4363 if (SoundToPlay != ComponentMenuLibsMenuSounds_C_Sound_Silent) {
4364 ComponentMenuLibsMenuSounds_PlaySound(SoundToPlay);
4365 }
4366}
4367
4368Void ComponentMenuLibsMenuSounds_PlaySelectSound(CMlControl _To) {
4369 declare Text SoundToPlay = ComponentMenuLibsMenuSounds_GetCustomSelectSound(_To);
4370 if (SoundToPlay != ComponentMenuLibsMenuSounds_C_Sound_Silent) {
4371 ComponentMenuLibsMenuSounds_PlaySound(SoundToPlay);
4372 }
4373}
4374
4375Void ComponentMenuLibsMenuSounds_PlayCancelSound(CMlControl _To) {
4376 declare Text SoundToPlay = ComponentMenuLibsMenuSounds_GetCustomCancelSound(_To);
4377 if (SoundToPlay != ComponentMenuLibsMenuSounds_C_Sound_Silent) {
4378 ComponentMenuLibsMenuSounds_PlaySound(SoundToPlay);
4379 }
4380}
4381
4382Void ComponentMenuLibsMenuSounds_InitControlSound(CMlControl _Control) {
4383 if (_Control.DataAttributeExists("menusounds-focussound")) {
4384 declare SoundText = _Control.DataAttributeGet("menusounds-focussound");
4385 ComponentMenuLibsMenuSounds_SetCustomFocusSound(_Control, SoundText);
4386 }
4387 if (_Control.DataAttributeExists("menusounds-selectsound")) {
4388 declare SoundText = _Control.DataAttributeGet("menusounds-selectsound");
4389 ComponentMenuLibsMenuSounds_SetCustomSelectSound(_Control, SoundText);
4390 }
4391 if (_Control.DataAttributeExists("menusounds-cancelsound")) {
4392 declare SoundText = _Control.DataAttributeGet("menusounds-cancelsound");
4393 ComponentMenuLibsMenuSounds_SetCustomCancelSound(_Control, SoundText);
4394 }
4395}
4396
4397Void ComponentMenuLibsMenuSounds_Initialize() {
4398 Page.GetClassChildren("component-menusounds-item", Page.MainFrame, True);
4399 foreach (Control in Page.GetClassChildren_Result) {
4400 ComponentMenuLibsMenuSounds_InitControlSound(Control);
4401 }
4402}
4403
4404Void ComponentMenuLibsMenuSounds_SetSoundBalanceState(Integer _SoundBalanceState, Integer _FadeTime) {
4405 ComponentCommonLibsAudioManager_SetNewSoundBalance(_SoundBalanceState, _FadeTime);
4406}
4407
4408Void ComponentMenuLibsMenuSounds_DisableForInput(CMlScriptEvent::EMenuNavAction _Input, Boolean _Disable) {
4409 if (_Disable) {
4410 if (!ComponentMenuLibsMenuSounds_G_DisabledForInputs.exists(_Input)) {
4411 ComponentMenuLibsMenuSounds_G_DisabledForInputs.add(_Input);
4412 }
4413 } else {
4414 ComponentMenuLibsMenuSounds_G_DisabledForInputs.remove(_Input);
4415 }
4416}
4417
4418Void ComponentMenuLibsMenuSounds_DisableForMouse(CMlScriptEvent::Type _Mouse, Boolean _Disable) {
4419 if (_Disable) {
4420 if (!ComponentMenuLibsMenuSounds_G_DisabledForMouses.exists(_Mouse)) {
4421 ComponentMenuLibsMenuSounds_G_DisabledForMouses.add(_Mouse);
4422 }
4423 } else {
4424 ComponentMenuLibsMenuSounds_G_DisabledForMouses.remove(_Mouse);
4425 }
4426}
4427
4428***MainStart***
4429***
4430ComponentMenuLibsMenuSounds_Initialize();
4431***
4432
4433***MainLoop***
4434***
4435if (This is CManiaAppTitleLayer || EnableMenuNavigationInputs) {
4436 foreach (Event in MenuLibsScroll_PendingEvents) {
4437 switch (Event.Type) {
4438 case MenuLibsScroll_C_EventType_Focus: {
4439 if (Event.IsMouse || Event.To != Null) {
4440 ComponentMenuLibsMenuSounds_PlayFocusSound(Event.To);
4441 }
4442 }
4443 case MenuLibsScroll_C_EventType_Select: {
4444 if (Event.To != Null) {
4445 ComponentMenuLibsMenuSounds_PlaySelectSound(Event.To);
4446 }
4447 }
4448 case MenuLibsScroll_C_EventType_Cancel: {
4449 if (Event.To != Null) {
4450 ComponentMenuLibsMenuSounds_PlayCancelSound(Event.To);
4451 }
4452 }
4453 }
4454 }
4455
4456 foreach (Event in ComponentNavigation_PendingEvents) {
4457 switch (Event.Type) {
4458 case ComponentNavigation_C_EventType_NavigateInput: {
4459 if (!ComponentMenuLibsMenuSounds_G_DisabledForInputs.exists(Event.Input)) {
4460 if (ComponentMenuLibsMenuSounds_C_FocusInputs.exists(Event.Input) && Event.From != Event.To && !MenuLibsScroll_IsScroll(Event.To)) {
4461 ComponentMenuLibsMenuSounds_PlayFocusSound(Event.To);
4462 } else if (Event.Input == CMlScriptEvent::EMenuNavAction::Select) {
4463 ComponentMenuLibsMenuSounds_PlaySelectSound(Event.To);
4464 } else if (Event.Input == CMlScriptEvent::EMenuNavAction::Cancel) {
4465 ComponentMenuLibsMenuSounds_PlayCancelSound(Event.To);
4466 }
4467 }
4468 }
4469 case ComponentNavigation_C_EventType_NavigateMouse: {
4470 if (!ComponentMenuLibsMenuSounds_G_DisabledForMouses.exists(Event.Mouse)) {
4471 if (Event.Mouse == CMlScriptEvent::Type::MouseClick) {
4472 ComponentMenuLibsMenuSounds_PlaySelectSound(Event.To);
4473 } else if (Event.Mouse == CMlScriptEvent::Type::MouseOver && Event.From != Event.To) {
4474 ComponentMenuLibsMenuSounds_PlayFocusSound(Event.To);
4475 }
4476 }
4477 }
4478 }
4479 }
4480}
4481***
4482
4483// */
4484// @Component end component-menulibs-menusounds
4485
4486// @Component start component-tmnext-button
4487// /*
4488
4489declare CMlQuad[] ComponentTMNextButton_G_QuadBlinking;
4490declare Boolean ComponentTMNextButton_G_ResetBlink;
4491declare Vec3 ComponentTMNextButton_G_DefaultColorFocus;
4492
4493Void ComponentTMNextButton_Focus(CMlFrame _Frame_Button) {
4494 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4495 if (!ComponentTMNextButton_Properties.IsButton || ComponentTMNextButton_Properties.IsLocked) return;
4496
4497 declare Label_Value <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
4498 declare Quad_Image <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-image") as CMlQuad);
4499 declare Quad_Contour <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-contour") as CMlQuad);
4500 declare Quad_Icon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-icon") as CMlQuad);
4501 declare Quad_FocusIcon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-icon") as CMlQuad);
4502 declare Quad_FocusBackground <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-background") as CMlQuad);
4503
4504 AnimMgr.Flush(Label_Value);
4505 AnimMgr.Flush(Quad_Contour);
4506 AnimMgr.Flush(Quad_FocusBackground);
4507 AnimMgr.Flush(Quad_FocusIcon);
4508 AnimMgr.Flush(Quad_Icon);
4509 AnimMgr.Flush(Quad_Image);
4510
4511 Quad_FocusIcon.Show();
4512 Quad_FocusBackground.Visible = ((ComponentTMNextButton_Properties.Background.FocusColor != ComponentTMNextButton_G_DefaultColorFocus || ComponentTMNextButton_Properties.Background.ImageFocus != "") && !ComponentTMNextButton_Properties.IsBgEmpty);
4513 Quad_Image.Visible = (!Quad_FocusBackground.Visible || ComponentTMNextButton_Properties.Background.ImageFocus != ComponentTMNextButton_Properties.Background.Image) && !ComponentTMNextButton_Properties.IsBgEmpty;
4514 Quad_Icon.Visible = !Quad_FocusIcon.Visible;
4515
4516 if (ComponentTMNextButton_Properties.IsBlink) {
4517 if (Quad_FocusBackground.Visible) {
4518 ComponentTMNextButton_G_QuadBlinking.add(Quad_FocusBackground);
4519 }
4520 if (ComponentTMNextButton_Properties.Background.ContourImage != "") {
4521 ComponentTMNextButton_G_QuadBlinking.add(Quad_Contour);
4522 }
4523 ComponentTMNextButton_G_ResetBlink = True;
4524 } else {
4525 ComponentTMNextButton_G_QuadBlinking = [];
4526 }
4527
4528 AnimMgr.Add(Label_Value, "<anim opacity=\"1.\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4529
4530 if (Quad_FocusBackground.Visible) {
4531 Label_Value.TextColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(ComponentTMNextButton_Properties.Background.FocusColor, ComponentTMNextButton_Properties.Label.FocusColor);
4532 if (ComponentTMNextButton_Properties.Background.ImageFocusOpacity != -1.) {
4533 AnimMgr.Add(Quad_FocusBackground, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.ImageFocusOpacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4534 Quad_Image.Opacity = ComponentTMNextButton_Properties.Background.ImageFocusOpacity;
4535 } else {
4536 AnimMgr.Add(Quad_FocusBackground, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4537 Quad_Image.Opacity = ComponentTMNextButton_Properties.Background.Opacity;
4538 }
4539 } else {
4540 Label_Value.TextColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(ComponentTMNextButton_Properties.Background.Color, ComponentTMNextButton_Properties.Label.FocusColor);
4541 if (ComponentTMNextButton_Properties.Background.ImageFocusOpacity != -1.) {
4542 AnimMgr.Add(Quad_Image, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.ImageFocusOpacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4543 } else {
4544 AnimMgr.Add(Quad_Image, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4545 }
4546 }
4547
4548 if (Quad_FocusIcon.Visible) {
4549 if (ComponentTMNextButton_Properties.Icon.ImageFocusOpacity != -1.) {
4550 AnimMgr.Add(Quad_FocusIcon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.ImageFocusOpacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4551 Quad_Icon.Opacity = ComponentTMNextButton_Properties.Icon.ImageFocusOpacity;
4552 } else {
4553 AnimMgr.Add(Quad_FocusIcon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4554 Quad_Icon.Opacity = ComponentTMNextButton_Properties.Icon.Opacity;
4555 }
4556 } else {
4557 if (ComponentTMNextButton_Properties.Icon.ImageFocusOpacity != -1.) {
4558 AnimMgr.Add(Quad_Icon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.ImageFocusOpacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4559 } else {
4560 AnimMgr.Add(Quad_Icon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4561 }
4562 }
4563
4564 if (ComponentTMNextButton_Properties.Background.ContourOpacityFocus != -1.) {
4565 AnimMgr.Add(Quad_Contour, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.ContourOpacityFocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4566 } else {
4567 AnimMgr.Add(Quad_Contour, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4568 }
4569
4570 ComponentTMNextButton_Properties.IsFocused = True;
4571}
4572
4573Void ComponentTMNextButton_Unfocus(CMlFrame _Frame_Button) {
4574 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4575 if (!ComponentTMNextButton_Properties.IsButton || ComponentTMNextButton_Properties.IsLocked) return;
4576
4577 declare Label_Value <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
4578 declare Quad_Image <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-image") as CMlQuad);
4579 declare Quad_Contour <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-contour") as CMlQuad);
4580 declare Quad_Icon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-icon") as CMlQuad);
4581 declare Quad_FocusIcon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-icon") as CMlQuad);
4582 declare Quad_FocusBackground <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-background") as CMlQuad);
4583
4584 AnimMgr.Flush(Label_Value);
4585 AnimMgr.Flush(Quad_Contour);
4586 AnimMgr.Flush(Quad_FocusBackground);
4587 AnimMgr.Flush(Quad_FocusIcon);
4588 AnimMgr.Flush(Quad_Icon);
4589 AnimMgr.Flush(Quad_Image);
4590
4591 Quad_Icon.Show();
4592 Quad_Image.Visible = !ComponentTMNextButton_Properties.IsBgEmpty;
4593 Quad_FocusBackground.Hide();
4594 Quad_FocusIcon.Hide();
4595 Label_Value.TextColor = ComponentTMNextButton_Properties.Label.Color;
4596
4597 ComponentTMNextButton_G_QuadBlinking = [];
4598
4599 if (ComponentTMNextButton_Properties.Icon.OpacityUnfocus != -1.) {
4600 AnimMgr.Add(Quad_Icon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4601 AnimMgr.Add(Quad_FocusIcon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4602 } else if (ComponentTMNextButton_Properties.OpacityUnfocus != -1.) {
4603 AnimMgr.Add(Quad_Icon, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4604 AnimMgr.Add(Quad_FocusIcon, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4605 } else {
4606 AnimMgr.Add(Quad_Icon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4607 AnimMgr.Add(Quad_FocusIcon, "<anim opacity=\""^ComponentTMNextButton_Properties.Icon.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4608 }
4609
4610 if (ComponentTMNextButton_Properties.Background.OpacityUnfocus != -1.) {
4611 AnimMgr.Add(Quad_Image, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4612 AnimMgr.Add(Quad_FocusBackground, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4613 } else if (ComponentTMNextButton_Properties.OpacityUnfocus != -1) {
4614 AnimMgr.Add(Quad_Image, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4615 AnimMgr.Add(Quad_FocusBackground, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4616 } else {
4617 AnimMgr.Add(Quad_Image, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4618 AnimMgr.Add(Quad_FocusBackground, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.Opacity^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4619 }
4620
4621 if (ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus != -1.) {
4622 AnimMgr.Add(Quad_Contour, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4623 } else if (ComponentTMNextButton_Properties.Background.OpacityUnfocus != -1.) {
4624 AnimMgr.Add(Quad_Contour, "<anim opacity=\""^ComponentTMNextButton_Properties.Background.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4625 } else {
4626 AnimMgr.Add(Quad_Contour, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4627 }
4628
4629 if (ComponentTMNextButton_Properties.Label.OpacityUnfocus == -1.) {
4630 AnimMgr.Add(Label_Value, "<anim opacity=\""^ComponentTMNextButton_Properties.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4631 } else {
4632 AnimMgr.Add(Label_Value, "<anim opacity=\""^ComponentTMNextButton_Properties.Label.OpacityUnfocus^"\" />", 250, CAnimManager::EAnimManagerEasing::QuadOut);
4633 }
4634
4635 ComponentTMNextButton_Properties.IsFocused = False;
4636}
4637
4638Void ComponentTMNextButton_Lock(CMlFrame _Frame_Button, Boolean _IsLocked) {
4639 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4640 if (!ComponentTMNextButton_Properties.IsButton) return;
4641
4642 declare CMlFrame Frame_Align <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_frame-align") as CMlFrame);
4643 declare CMlLabel Label_Value <=> (Frame_Align.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
4644 declare CMlQuad Quad_Icon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-icon") as CMlQuad);
4645 declare CMlQuad Quad_Image <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-image") as CMlQuad);
4646 declare CMlQuad Quad_Contour <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-contour") as CMlQuad);
4647 declare CMlQuad Quad_FocusIcon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-icon") as CMlQuad);
4648 declare CMlQuad Quad_FocusBackground <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-background") as CMlQuad);
4649
4650 ComponentTMNextButton_G_QuadBlinking = [];
4651 Quad_FocusBackground.Visible = False;
4652 Quad_FocusIcon.Visible = False;
4653 if (_IsLocked) {
4654 Quad_Icon.Opacity = .5;
4655 Quad_Image.Opacity = .5;
4656 Quad_Contour.Opacity = .5;
4657 Label_Value.Opacity = .5;
4658 } else {
4659 if (ComponentTMNextButton_Properties.Icon.OpacityUnfocus == -1.) {
4660 Quad_Icon.Opacity = ComponentTMNextButton_Properties.OpacityUnfocus;
4661 } else {
4662 Quad_Icon.Opacity = ComponentTMNextButton_Properties.Icon.OpacityUnfocus;
4663 }
4664 if (ComponentTMNextButton_Properties.Background.OpacityUnfocus == -1.) {
4665 Quad_Image.Opacity = ComponentTMNextButton_Properties.OpacityUnfocus;
4666 } else {
4667 Quad_Image.Opacity = ComponentTMNextButton_Properties.Background.OpacityUnfocus;
4668 }
4669 if (ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus != -1.) {
4670 Quad_Contour.Opacity = ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus;
4671 } else if (ComponentTMNextButton_Properties.Background.OpacityUnfocus != -1.) {
4672 Quad_Contour.Opacity = ComponentTMNextButton_Properties.Background.OpacityUnfocus;
4673 } else {
4674 Quad_Contour.Opacity = ComponentTMNextButton_Properties.OpacityUnfocus;
4675 }
4676 if (ComponentTMNextButton_Properties.Label.OpacityUnfocus == -1.) {
4677 Label_Value.Opacity = ComponentTMNextButton_Properties.OpacityUnfocus;
4678 } else {
4679 Label_Value.Opacity = ComponentTMNextButton_Properties.Label.OpacityUnfocus;
4680 }
4681 }
4682
4683 ComponentTMNextButton_Properties.IsLocked = _IsLocked;
4684}
4685
4686Boolean ComponentTMNextButton_IsButton(CMlControl _Frame_Button) {
4687 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4688 return ComponentTMNextButton_Properties.IsButton;
4689}
4690
4691Void ComponentTMNextButton_ApplyProperties(CMlFrame _Frame_Button, ComponentTMNextButton_K_Properties _Properties) {
4692 declare CMlFrame Frame_Align <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_frame-align") as CMlFrame);
4693 declare CMlQuad Quad_Icon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-icon") as CMlQuad);
4694 declare CMlQuad Quad_Hitbox <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-background") as CMlQuad);
4695 declare CMlQuad Quad_Image <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-image") as CMlQuad);
4696 declare CMlQuad Quad_Contour <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-contour") as CMlQuad);
4697 declare CMlQuad Quad_FocusIcon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-icon") as CMlQuad);
4698 declare CMlQuad Quad_FocusBackground <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-background") as CMlQuad);
4699 declare CMlLabel Label_Value <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
4700
4701 Label_Value.Value = _Properties.Label.Value;
4702 Label_Value.TextSizeReal = _Properties.Label.TextSize;
4703 Label_Value.TextPrefix = _Properties.Label.TextPrefix;
4704 Label_Value.TextFont = _Properties.Label.Font;
4705 Label_Value.HorizontalAlign = ComponentMenuLibsTools_TextToHAlign(_Properties.Label.HAlign);
4706 Label_Value.VerticalAlign = ComponentMenuLibsTools_TextToVAlign(_Properties.Label.VAlign);
4707 Label_Value.MaxLine = _Properties.Label.MaxLine;
4708 Label_Value.AutoNewLine = _Properties.Label.AutoNewLine;
4709 if (_Properties.IsFocused) {
4710 if (Quad_FocusBackground.Visible) {
4711 Label_Value.TextColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(_Properties.Background.FocusColor, _Properties.Label.FocusColor);
4712 } else {
4713 Label_Value.TextColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(_Properties.Background.Color, _Properties.Label.FocusColor);
4714 }
4715 } else {
4716 Label_Value.TextColor = _Properties.Label.Color;
4717 }
4718
4719 Quad_Contour.Visible = _Properties.Background.ContourImage != "";
4720 if (_Properties.Background.ContourImage != "") {
4721 Quad_Contour.ChangeImageUrl(_Properties.Background.ContourImage);
4722 Quad_Contour.KeepRatio = _Properties.Background.KeepRatio;
4723 switch (_Properties.Background.ColorType) {
4724 case ComponentTMNextButton_C_ColorType_ModulateColor: Quad_Contour.ModulateColor = _Properties.Background.ContourColor;
4725 case ComponentTMNextButton_C_ColorType_Colorize: Quad_Contour.Colorize = _Properties.Background.ContourColor;
4726 case ComponentTMNextButton_C_ColorType_None: {
4727 if (_Properties.Background.ContourColor != <-1., -1., -1.>) {
4728 Quad_Contour.Colorize = _Properties.Background.ContourColor;
4729 }
4730 }
4731 }
4732 if (_Properties.AlphaMask != "") {
4733 Quad_Contour.AlphaMaskUrl = _Properties.AlphaMask;
4734 }
4735 if (_Properties.IsFocused) {
4736 if (_Properties.Background.ContourOpacityFocus != -1.) {
4737 Quad_Contour.Opacity = _Properties.Background.ContourOpacityFocus;
4738 } else {
4739 Quad_Contour.Opacity = _Properties.Background.Opacity;
4740 }
4741 } else {
4742 if (_Properties.Background.ContourOpacityUnfocus != -1.) {
4743 Quad_Contour.Opacity = _Properties.Background.ContourOpacityUnfocus;
4744 } else if (_Properties.Background.OpacityUnfocus != -1.) {
4745 Quad_Contour.Opacity = _Properties.Background.OpacityUnfocus;
4746 } else {
4747 Quad_Contour.Opacity = _Properties.OpacityUnfocus;
4748 }
4749 }
4750 }
4751
4752 Quad_Image.Visible = !_Properties.IsBgEmpty;
4753 if (!_Properties.IsBgEmpty) {
4754 Quad_Image.BgColor = _Properties.Background.Color;
4755 Quad_Image.ChangeImageUrl(_Properties.Background.Image);
4756 Quad_Image.KeepRatio = _Properties.Background.KeepRatio;
4757 switch (_Properties.Background.ColorType) {
4758 case ComponentTMNextButton_C_ColorType_ModulateColor: Quad_Image.ModulateColor = _Properties.Background.Color;
4759 case ComponentTMNextButton_C_ColorType_Colorize: Quad_Image.Colorize = _Properties.Background.Color;
4760 }
4761 if (_Properties.Background.Image != "") {
4762 Quad_Image.AlphaMaskUrl = _Properties.AlphaMask;
4763 }
4764 if (_Properties.IsFocused) {
4765 Quad_Image.Opacity = _Properties.Background.Opacity;
4766 } else {
4767 if (_Properties.Background.OpacityUnfocus == -1.) {
4768 Quad_Image.Opacity = _Properties.OpacityUnfocus;
4769 } else {
4770 Quad_Image.Opacity = _Properties.Background.OpacityUnfocus;
4771 }
4772 }
4773 }
4774
4775 if ((_Properties.Background.FocusColor == ComponentTMNextButton_G_DefaultColorFocus || _Properties.Background.ImageFocus == "") && _Properties.IsBgEmpty) {
4776 Quad_FocusBackground.Visible = False;
4777 } else {
4778 Quad_FocusBackground.BgColor = _Properties.Background.FocusColor;
4779 Quad_FocusBackground.ChangeImageUrl(_Properties.Background.ImageFocus);
4780 Quad_FocusBackground.KeepRatio = _Properties.Background.KeepRatio;
4781
4782 switch (_Properties.Background.ColorType) {
4783 case ComponentTMNextButton_C_ColorType_ModulateColor: {
4784 Quad_FocusBackground.ModulateColor = _Properties.Background.FocusColor;
4785 }
4786 case ComponentTMNextButton_C_ColorType_Colorize: {
4787 Quad_FocusBackground.Colorize = _Properties.Background.FocusColor;
4788 }
4789 }
4790
4791 if (_Properties.Background.ImageFocus != "") {
4792 Quad_FocusBackground.AlphaMaskUrl = _Properties.AlphaMask;
4793 }
4794 if (_Properties.IsFocused) {
4795 if (_Properties.Background.ImageFocusOpacity == -1.) {
4796 Quad_FocusBackground.Opacity = _Properties.Background.Opacity;
4797 } else {
4798 Quad_FocusBackground.Opacity = _Properties.Background.ImageFocusOpacity;
4799 }
4800 } else {
4801 if (_Properties.Background.OpacityUnfocus == -1.) {
4802 Quad_FocusBackground.Opacity = _Properties.OpacityUnfocus;
4803 } else {
4804 Quad_FocusBackground.Opacity = _Properties.Background.OpacityUnfocus;
4805 }
4806 }
4807 }
4808
4809 Quad_Icon.Parent.Visible = _Properties.Icon.Image != "";
4810 if (_Properties.Icon.Image != "") {
4811 Quad_Icon.BgColor = _Properties.Icon.Color;
4812 Quad_FocusIcon.BgColor = _Properties.Icon.FocusColor;
4813 Quad_Icon.ChangeImageUrl(_Properties.Icon.Image);
4814 Quad_FocusIcon.ChangeImageUrl(_Properties.Icon.ImageFocus);
4815 switch (_Properties.Icon.ColorType) {
4816 case ComponentTMNextButton_C_ColorType_ModulateColor: {
4817 Quad_Icon.ModulateColor = _Properties.Icon.Color;
4818 Quad_FocusIcon.ModulateColor = _Properties.Icon.FocusColor;
4819 }
4820 case ComponentTMNextButton_C_ColorType_Colorize: {
4821 Quad_Icon.Colorize = _Properties.Icon.Color;
4822 Quad_FocusIcon.Colorize = _Properties.Icon.FocusColor;
4823 }
4824 }
4825 if (_Properties.Icon.Image != "") {
4826 Quad_Icon.AlphaMaskUrl = _Properties.AlphaMask;
4827 }
4828 if (_Properties.Icon.ImageFocus != "") {
4829 Quad_FocusIcon.AlphaMaskUrl = _Properties.AlphaMask;
4830 }
4831 if (_Properties.IsFocused) {
4832 Quad_FocusIcon.Opacity = _Properties.Icon.Opacity;
4833 } else {
4834 if (_Properties.Icon.OpacityUnfocus == -1.) {
4835 Quad_Icon.Opacity = _Properties.OpacityUnfocus;
4836 } else {
4837 Quad_Icon.Opacity = _Properties.Icon.OpacityUnfocus;
4838 }
4839 }
4840
4841 }
4842
4843 // Size
4844
4845 declare Vec2 SizeOfReference;
4846 if (_Properties.SizeHitbox == <-1., -1.>) {
4847 Quad_Hitbox.Size = _Properties.Background.Size;
4848 SizeOfReference = _Properties.Background.Size;
4849 } else {
4850 Quad_Hitbox.Size = _Properties.SizeHitbox;
4851 SizeOfReference = _Properties.SizeHitbox;
4852 }
4853
4854 Quad_Image.Size = _Properties.Background.Size;
4855 Quad_Contour.Size = _Properties.Background.Size;
4856 Quad_FocusBackground.Size = _Properties.Background.Size;
4857
4858 if (_Properties.Icon.Size == <-1., -1.>) {
4859 Quad_Icon.Size = SizeOfReference - <5., 5.>;
4860 Quad_FocusIcon.Size = SizeOfReference - <5., 5.>;
4861 } else {
4862 Quad_Icon.Size = _Properties.Icon.Size;
4863 Quad_FocusIcon.Size = _Properties.Icon.Size;
4864 }
4865
4866 if (_Properties.Label.Size == <-1., -1.>) {
4867 Label_Value.Size = SizeOfReference - <5., 1.>;
4868 } else {
4869 Label_Value.Size = _Properties.Label.Size;
4870 }
4871
4872 Label_Value.ItalicSlope = _Properties.Label.ItalicSlope;
4873
4874 Label_Value.RelativePosition_V3 = <SizeOfReference.X * _Properties.Label.PosX, SizeOfReference.Y * _Properties.Label.PosY>;
4875 Quad_Icon.RelativePosition_V3 = <SizeOfReference.X * _Properties.Icon.PosX - Quad_Icon.Size.X/2., SizeOfReference.Y * _Properties.Icon.PosY + Quad_Icon.Size.Y/2.>;
4876 Quad_FocusIcon.RelativePosition_V3 = <SizeOfReference.X * _Properties.Icon.PosX - Quad_Icon.Size.X/2., SizeOfReference.Y * _Properties.Icon.PosY + Quad_Icon.Size.Y/2.>;
4877 Quad_Hitbox.RelativePosition_V3 = <SizeOfReference.X * .5 - Quad_Hitbox.Size.X/2., SizeOfReference.Y * .5 - Quad_Hitbox.Size.Y/2.>;
4878 Quad_Image.RelativePosition_V3 = <SizeOfReference.X * .5 - Quad_Image.Size.X/2. + _Properties.Background.PosX, SizeOfReference.Y * -.5 + Quad_Image.Size.Y/2. + _Properties.Background.PosY>;
4879 Quad_Contour.RelativePosition_V3 = <SizeOfReference.X * .5 - Quad_Contour.Size.X/2. + _Properties.Background.PosX, SizeOfReference.Y * -.5 + Quad_Contour.Size.Y/2. + _Properties.Background.PosY>;
4880 Quad_FocusBackground.RelativePosition_V3 = <SizeOfReference.X * .5 - Quad_FocusBackground.Size.X/2.+ _Properties.Background.PosX, SizeOfReference.Y * -.5 + Quad_FocusBackground.Size.Y/2. + _Properties.Background.PosY>;
4881 Quad_Icon.RelativeRotation = _Properties.Icon.Rotation;
4882 Quad_FocusIcon.RelativeRotation = _Properties.Icon.Rotation;
4883
4884 // Align
4885 ComponentMenuLibsTools_AlignFrame(Frame_Align, SizeOfReference, _Properties.HAlign, _Properties.VAlign);
4886
4887 // Apply after every other properties are set on the label, especially its size
4888 if (_Properties.Label.Fit > 0.) {
4889 ComponentMenuLibsTools_FitLabelValue(Label_Value, _Properties.Label.Fit, _Properties.Label.FitStep);
4890 }
4891}
4892
4893Void ComponentTMNextButton_Show(CMlFrame _Frame_Button) {
4894 ComponentNavigation_Lock(_Frame_Button, False);
4895 _Frame_Button.Show();
4896}
4897Void ComponentTMNextButton_Hide(CMlFrame _Frame_Button) {
4898 ComponentNavigation_Lock(_Frame_Button, True);
4899 _Frame_Button.Hide();
4900}
4901Void ComponentTMNextButton_Visible(CMlFrame _Frame_Button, Boolean _IsVisible) {
4902 ComponentNavigation_Lock(_Frame_Button, !_IsVisible);
4903 _Frame_Button.Visible = _IsVisible;
4904}
4905
4906Void ComponentTMNextButton_SetIconColorType(CMlFrame _Frame_Button, Integer _ColorType) {
4907 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4908 ComponentTMNextButton_Properties.Icon.ColorType = _ColorType;
4909 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4910}
4911Void ComponentTMNextButton_SetBgIsEmpty(CMlFrame _Frame_Button, Boolean _IsBgEmpty) {
4912 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4913 ComponentTMNextButton_Properties.IsBgEmpty = _IsBgEmpty;
4914 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4915}
4916Void ComponentTMNextButton_SetIsBlink(CMlFrame _Frame_Button, Boolean _IsBlink) {
4917 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4918 ComponentTMNextButton_Properties.IsBlink = _IsBlink;
4919 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4920}
4921Void ComponentTMNextButton_SetAlphaMask(CMlFrame _Frame_Button, Text _AlphaMask) {
4922 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4923 ComponentTMNextButton_Properties.AlphaMask = _AlphaMask;
4924 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4925}
4926Void ComponentTMNextButton_SetBgColorType(CMlFrame _Frame_Button, Integer _ColorType) {
4927 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4928 ComponentTMNextButton_Properties.Background.ColorType = _ColorType;
4929 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4930}
4931Void ComponentTMNextButton_SetValue(CMlFrame _Frame_Button, Text _Value) {
4932 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4933 ComponentTMNextButton_Properties.Label.Value = _Value;
4934 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4935}
4936Void ComponentTMNextButton_SetSize(CMlFrame _Frame_Button, Vec2 _Size) {
4937 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4938 ComponentTMNextButton_Properties.Background.Size = _Size;
4939 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4940}
4941Void ComponentTMNextButton_SetSizeHitbox(CMlFrame _Frame_Button, Vec2 _SizeHitbox) {
4942 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4943 ComponentTMNextButton_Properties.SizeHitbox = _SizeHitbox;
4944 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4945}
4946Void ComponentTMNextButton_SetBackgroundOpacity(CMlFrame _Frame_Button, Real _Opacity) {
4947 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4948 ComponentTMNextButton_Properties.Background.Opacity = _Opacity;
4949 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4950}
4951Void ComponentTMNextButton_SetOpacityUnfocus(CMlFrame _Frame_Button, Real _Opacity) {
4952 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4953 ComponentTMNextButton_Properties.OpacityUnfocus = _Opacity;
4954 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4955}
4956Void ComponentTMNextButton_SetBgColor(CMlFrame _Frame_Button, Vec3 _BgColor) {
4957 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4958 ComponentTMNextButton_Properties.Background.Color = _BgColor;
4959 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4960}
4961Void ComponentTMNextButton_SetFocusColor(CMlFrame _Frame_Button, Vec3 _FocusColor) {
4962 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4963 ComponentTMNextButton_Properties.Background.FocusColor = _FocusColor;
4964 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4965}
4966Void ComponentTMNextButton_SetTextColor(CMlFrame _Frame_Button, Vec3 _TextColor) {
4967 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4968 ComponentTMNextButton_Properties.Label.Color = _TextColor;
4969 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4970}
4971Void ComponentTMNextButton_SetTextFocusColor(CMlFrame _Frame_Button, Vec3 _TextColor) {
4972 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4973 ComponentTMNextButton_Properties.Label.FocusColor = _TextColor;
4974 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4975}
4976Void ComponentTMNextButton_SetTextOpacityUnfocus(CMlFrame _Frame_Button, Real _Opacity) {
4977 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4978 ComponentTMNextButton_Properties.Label.OpacityUnfocus = _Opacity;
4979 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4980}
4981Void ComponentTMNextButton_SetTextSize(CMlFrame _Frame_Button, Real _TextSize) {
4982 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4983 ComponentTMNextButton_Properties.Label.TextSize = _TextSize;
4984 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4985}
4986Void ComponentTMNextButton_SetTextPrefix(CMlFrame _Frame_Button, Text _TextPrefix) {
4987 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4988 ComponentTMNextButton_Properties.Label.TextPrefix = _TextPrefix;
4989 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4990}
4991Void ComponentTMNextButton_SetTextFont(CMlFrame _Frame_Button, Text _TextFont) {
4992 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4993 ComponentTMNextButton_Properties.Label.Font = _TextFont;
4994 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
4995}
4996Void ComponentTMNextButton_SetTextItalicSlope(CMlFrame _Frame_Button, Real _ItalicSlope) {
4997 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
4998 ComponentTMNextButton_Properties.Label.ItalicSlope = _ItalicSlope;
4999 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5000}
5001Void ComponentTMNextButton_SetLabelSize(CMlFrame _Frame_Button, Vec2 _LabelSize) {
5002 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5003 ComponentTMNextButton_Properties.Label.Size = _LabelSize;
5004 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5005}
5006Void ComponentTMNextButton_SetImage(CMlFrame _Frame_Button, Text _ImageUrl) {
5007 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5008 ComponentTMNextButton_Properties.Background.Image = _ImageUrl;
5009 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5010}
5011Void ComponentTMNextButton_SetImageFocus(CMlFrame _Frame_Button, Text _ImageUrl) {
5012 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5013 ComponentTMNextButton_Properties.Background.ImageFocus = _ImageUrl;
5014 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5015}
5016Void ComponentTMNextButton_SetImageFocusOpacity(CMlFrame _Frame_Button, Real _ImageFocusOpacity) {
5017 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5018 ComponentTMNextButton_Properties.Background.ImageFocusOpacity = _ImageFocusOpacity;
5019 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5020}
5021Void ComponentTMNextButton_SetImageOffset(CMlFrame _Frame_Button, Vec2 _Offset) {
5022 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5023 ComponentTMNextButton_Properties.Background.PosX = _Offset.X;
5024 ComponentTMNextButton_Properties.Background.PosY = _Offset.Y;
5025 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5026}
5027Void ComponentTMNextButton_SetImageXOffset(CMlFrame _Frame_Button, Real _XOffset) {
5028 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5029 ComponentTMNextButton_Properties.Background.PosX = _XOffset;
5030 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5031}
5032Void ComponentTMNextButton_SetImageYOffset(CMlFrame _Frame_Button, Real _YOffset) {
5033 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5034 ComponentTMNextButton_Properties.Background.PosY = _YOffset;
5035 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5036}
5037Void ComponentTMNextButton_SetIcon(CMlFrame _Frame_Button, Text _ImageUrl) {
5038 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5039 ComponentTMNextButton_Properties.Icon.Image = _ImageUrl;
5040 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5041}
5042Void ComponentTMNextButton_SetIconFocus(CMlFrame _Frame_Button, Text _ImageUrl) {
5043 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5044 ComponentTMNextButton_Properties.Icon.ImageFocus = _ImageUrl;
5045 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5046}
5047Void ComponentTMNextButton_SetIconColor(CMlFrame _Frame_Button, Vec3 _Color) {
5048 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5049 ComponentTMNextButton_Properties.Icon.Color = _Color;
5050 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5051}
5052Void ComponentTMNextButton_SetIconFocusColor(CMlFrame _Frame_Button, Vec3 _Color) {
5053 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5054 ComponentTMNextButton_Properties.Icon.FocusColor = _Color;
5055 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5056}
5057Void ComponentTMNextButton_SetIconSize(CMlFrame _Frame_Button, Vec2 _Size) {
5058 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5059 ComponentTMNextButton_Properties.Icon.Size = _Size;
5060 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5061}
5062Void ComponentTMNextButton_SetIconXPos(CMlFrame _Frame_Button, Real _IconXPos) {
5063 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5064 ComponentTMNextButton_Properties.Icon.PosX = _IconXPos;
5065 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5066}
5067Void ComponentTMNextButton_SetIconYPos(CMlFrame _Frame_Button, Real _IconYPos) {
5068 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5069 ComponentTMNextButton_Properties.Icon.PosY = _IconYPos;
5070 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5071}
5072Void ComponentTMNextButton_SetIconRot(CMlFrame _Frame_Button, Real _Rotation) {
5073 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5074 ComponentTMNextButton_Properties.Icon.Rotation = _Rotation;
5075 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5076}
5077Void ComponentTMNextButton_SetTextXPos(CMlFrame _Frame_Button, Real _TextXPos) {
5078 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5079 ComponentTMNextButton_Properties.Label.PosX = _TextXPos;
5080 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5081}
5082Void ComponentTMNextButton_SetTextYPos(CMlFrame _Frame_Button, Real _TextYPos) {
5083 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5084 ComponentTMNextButton_Properties.Label.PosY = _TextYPos;
5085 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5086}
5087Void ComponentTMNextButton_SetTextHAlign(CMlFrame _Frame_Button, Text _HAlign) {
5088 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5089 ComponentTMNextButton_Properties.Label.HAlign = _HAlign;
5090 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5091}
5092Void ComponentTMNextButton_SetTextVAlign(CMlFrame _Frame_Button, Text _VAlign) {
5093 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5094 ComponentTMNextButton_Properties.Label.VAlign = _VAlign;
5095 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5096}
5097Void ComponentTMNextButton_SetHAlign(CMlFrame _Frame_Button, Text _HAlign) {
5098 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5099 ComponentTMNextButton_Properties.HAlign = _HAlign;
5100 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5101}
5102Void ComponentTMNextButton_SetVAlign(CMlFrame _Frame_Button, Text _VAlign) {
5103 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5104 ComponentTMNextButton_Properties.VAlign = _VAlign;
5105 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5106}
5107Void ComponentTMNextButton_SetMaxLine(CMlFrame _Frame_Button, Integer _MaxLine) {
5108 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5109 ComponentTMNextButton_Properties.Label.MaxLine = _MaxLine;
5110 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5111}
5112Void ComponentTMNextButton_SetAutoNewLine(CMlFrame _Frame_Button, Boolean _AutoNewLine) {
5113 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5114 ComponentTMNextButton_Properties.Label.AutoNewLine = _AutoNewLine;
5115 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5116}
5117Void ComponentTMNextButton_SetFitLabel(CMlFrame _Frame_Button, Real _MinTextSize) {
5118 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5119 ComponentTMNextButton_Properties.Label.Fit = _MinTextSize;
5120 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5121}
5122Void ComponentTMNextButton_SetFitLabelStep(CMlFrame _Frame_Button, Real _StepSize) {
5123 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5124 ComponentTMNextButton_Properties.Label.FitStep = _StepSize;
5125 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5126}
5127Void ComponentTMNextButton_SetBackgroundKeepRatio(CMlFrame _Frame_Button, CMlQuad::EKeepRatioMode _KeepRatio) {
5128 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5129 ComponentTMNextButton_Properties.Background.KeepRatio = _KeepRatio;
5130 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5131}
5132Void ComponentTMNextButton_SetContourImage(CMlFrame _Frame_Button, Text _ImageUrl) {
5133 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5134 ComponentTMNextButton_Properties.Background.ContourImage = _ImageUrl;
5135 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5136}
5137Void ComponentTMNextButton_SetContourOpacityFocus(CMlFrame _Frame_Button, Real _Opacity) {
5138 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5139 ComponentTMNextButton_Properties.Background.ContourOpacityFocus = _Opacity;
5140 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5141}
5142Void ComponentTMNextButton_SetContourOpacityUnfocus(CMlFrame _Frame_Button, Real _Opacity) {
5143 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5144 ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus = _Opacity;
5145 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5146}
5147Void ComponentTMNextButton_SetContourColor(CMlFrame _Frame_Button, Vec3 _Color) {
5148 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5149 ComponentTMNextButton_Properties.Background.ContourColor = _Color;
5150 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5151}
5152
5153Integer ComponentTMNextButton_GetIconColorType(CMlControl _Frame_Button) {
5154 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5155 return ComponentTMNextButton_Properties.Icon.ColorType;
5156}
5157Boolean ComponentTMNextButton_GetBgIsEmpty(CMlFrame _Frame_Button) {
5158 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5159 return ComponentTMNextButton_Properties.IsBgEmpty;
5160}
5161Boolean ComponentTMNextButton_GetIsBlink(CMlFrame _Frame_Button) {
5162 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5163 return ComponentTMNextButton_Properties.IsBlink;
5164}
5165Text ComponentTMNextButton_GetAlphaMask(CMlControl _Frame_Button) {
5166 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5167 return ComponentTMNextButton_Properties.AlphaMask;
5168}
5169Integer ComponentTMNextButton_GetBgColorType(CMlControl _Frame_Button) {
5170 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5171 return ComponentTMNextButton_Properties.Background.ColorType;
5172}
5173Text ComponentTMNextButton_GetValue(CMlControl _Frame_Button) {
5174 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5175 return ComponentTMNextButton_Properties.Label.Value;
5176}
5177Vec2 ComponentTMNextButton_GetSize(CMlControl _Frame_Button) {
5178 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5179 return ComponentTMNextButton_Properties.Background.Size;
5180}
5181Vec2 ComponentTMNextButton_GetSizeHitbox(CMlControl _Frame_Button) {
5182 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5183 return ComponentTMNextButton_Properties.SizeHitbox;
5184}
5185Real ComponentTMNextButton_GetBackgroundOpacity(CMlControl _Frame_Button) {
5186 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5187 return ComponentTMNextButton_Properties.Background.Opacity;
5188}
5189Real ComponentTMNextButton_GetOpacityUnfocus(CMlControl _Frame_Button) {
5190 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5191 return ComponentTMNextButton_Properties.OpacityUnfocus;
5192}
5193Vec3 ComponentTMNextButton_GetBgColor(CMlControl _Frame_Button) {
5194 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5195 return ComponentTMNextButton_Properties.Background.Color;
5196}
5197Vec3 ComponentTMNextButton_GetFocusColor(CMlControl _Frame_Button) {
5198 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5199 return ComponentTMNextButton_Properties.Background.FocusColor;
5200}
5201Vec3 ComponentTMNextButton_GetTextColor(CMlControl _Frame_Button) {
5202 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5203 return ComponentTMNextButton_Properties.Label.Color;
5204}
5205Vec3 ComponentTMNextButton_GetTextFocusColor(CMlControl _Frame_Button) {
5206 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5207 return ComponentTMNextButton_Properties.Label.FocusColor;
5208}
5209Real ComponentTMNextButton_GetTextSize(CMlControl _Frame_Button) {
5210 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5211 return ComponentTMNextButton_Properties.Label.TextSize;
5212}
5213Text ComponentTMNextButton_GetTextPrefix(CMlControl _Frame_Button) {
5214 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5215 return ComponentTMNextButton_Properties.Label.TextPrefix;
5216}
5217Real ComponentTMNextButton_GetTextItalicSlope(CMlFrame _Frame_Button) {
5218 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5219 return ComponentTMNextButton_Properties.Label.ItalicSlope;
5220}
5221Text ComponentTMNextButton_GetTextFont(CMlControl _Frame_Button) {
5222 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5223 return ComponentTMNextButton_Properties.Label.Font;
5224}
5225CMlLabel ComponentTMNextButton_GetLabel(CMlFrame _Frame_Button) {
5226 return (_Frame_Button.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
5227}
5228Vec2 ComponentTMNextButton_GetLabelSize(CMlControl _Frame_Button) {
5229 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5230 return ComponentTMNextButton_Properties.Label.Size;
5231}
5232Text ComponentTMNextButton_GetImage(CMlControl _Frame_Button) {
5233 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5234 return ComponentTMNextButton_Properties.Background.Image;
5235}
5236Text ComponentTMNextButton_GetImageFocus(CMlControl _Frame_Button) {
5237 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5238 return ComponentTMNextButton_Properties.Background.ImageFocus;
5239}
5240Real ComponentTMNextButton_GetImageFocusOpacity(CMlControl _Frame_Button) {
5241 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5242 return ComponentTMNextButton_Properties.Background.ImageFocusOpacity;
5243}
5244Vec2 ComponentTMNextButton_GetImageOffset(CMlControl _Frame_Button) {
5245 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5246 return <ComponentTMNextButton_Properties.Background.PosX, ComponentTMNextButton_Properties.Background.PosY>;
5247}
5248Real ComponentTMNextButton_GetImageXOffset(CMlControl _Frame_Button) {
5249 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5250 return ComponentTMNextButton_Properties.Background.PosX;
5251}
5252Real ComponentTMNextButton_GetImageYOffset(CMlControl _Frame_Button) {
5253 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5254 return ComponentTMNextButton_Properties.Background.PosY;
5255}
5256Text ComponentTMNextButton_GetIcon(CMlFrame _Frame_Button) {
5257 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5258 return ComponentTMNextButton_Properties.Icon.Image;
5259}
5260Text ComponentTMNextButton_GetIconFocus(CMlFrame _Frame_Button) {
5261 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5262 return ComponentTMNextButton_Properties.Icon.ImageFocus;
5263}
5264Vec3 ComponentTMNextButton_GetIconColor(CMlFrame _Frame_Button) {
5265 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5266 return ComponentTMNextButton_Properties.Icon.Color;
5267}
5268Vec3 ComponentTMNextButton_GetIconFocusColor(CMlFrame _Frame_Button) {
5269 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5270 return ComponentTMNextButton_Properties.Icon.FocusColor;
5271}
5272Vec2 ComponentTMNextButton_GetIconSize(CMlFrame _Frame_Button) {
5273 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5274 return ComponentTMNextButton_Properties.Icon.Size;
5275}
5276Real ComponentTMNextButton_GetIconXPos(CMlControl _Frame_Button) {
5277 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5278 return ComponentTMNextButton_Properties.Icon.PosX;
5279}
5280Real ComponentTMNextButton_GetIconYPos(CMlControl _Frame_Button) {
5281 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5282 return ComponentTMNextButton_Properties.Icon.PosY;
5283}
5284Real ComponentTMNextButton_GetIconRot(CMlControl _Frame_Button) {
5285 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5286 return ComponentTMNextButton_Properties.Icon.Rotation;
5287}
5288Text ComponentTMNextButton_GetTextHAlign(CMlControl _Frame_Button) {
5289 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5290 return ComponentTMNextButton_Properties.Label.HAlign;
5291}
5292Text ComponentTMNextButton_GetTextVAlign(CMlControl _Frame_Button) {
5293 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5294 return ComponentTMNextButton_Properties.Label.VAlign;
5295}
5296Real ComponentTMNextButton_GetTextXPos(CMlControl _Frame_Button) {
5297 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5298 return ComponentTMNextButton_Properties.Label.PosX;
5299}
5300Real ComponentTMNextButton_GetTextYPos(CMlControl _Frame_Button) {
5301 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5302 return ComponentTMNextButton_Properties.Label.PosY;
5303}
5304Text ComponentTMNextButton_GetHAlign(CMlControl _Frame_Button) {
5305 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5306 return ComponentTMNextButton_Properties.HAlign;
5307}
5308Text ComponentTMNextButton_GetVAlign(CMlControl _Frame_Button) {
5309 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5310 return ComponentTMNextButton_Properties.VAlign;
5311}
5312Integer ComponentTMNextButton_GetMaxLine(CMlControl _Frame_Button) {
5313 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5314 return ComponentTMNextButton_Properties.Label.MaxLine;
5315}
5316Boolean ComponentTMNextButton_GetAutoNewLine(CMlControl _Frame_Button) {
5317 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5318 return ComponentTMNextButton_Properties.Label.AutoNewLine;
5319}
5320Real ComponentTMNextButton_GetFitLabel(CMlControl _Frame_Button) {
5321 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5322 return ComponentTMNextButton_Properties.Label.Fit;
5323}
5324Real ComponentTMNextButton_GetFitLabelStep(CMlControl _Frame_Button) {
5325 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5326 return ComponentTMNextButton_Properties.Label.FitStep;
5327}
5328CMlQuad::EKeepRatioMode ComponentTMNextButton_GetBackgroundKeepRatio(CMlControl _Frame_Button) {
5329 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5330 return ComponentTMNextButton_Properties.Background.KeepRatio;
5331}
5332Text ComponentTMNextButton_GetContourImage(CMlControl _Frame_Button) {
5333 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5334 return ComponentTMNextButton_Properties.Background.ContourImage;
5335}
5336Real ComponentTMNextButton_GetContourOpacityFocus(CMlControl _Frame_Button) {
5337 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5338 return ComponentTMNextButton_Properties.Background.ContourOpacityFocus;
5339}
5340Real ComponentTMNextButton_GetContourOpacityUnfocus(CMlControl _Frame_Button) {
5341 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5342 return ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus;
5343}
5344Vec3 ComponentTMNextButton_GetContourColor(CMlControl _Frame_Button) {
5345 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5346 return ComponentTMNextButton_Properties.Background.ContourColor;
5347}
5348
5349Void ComponentTMNextButton_InitButton(CMlFrame _Frame_Button) {
5350 declare CMlQuad Quad_Icon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-icon") as CMlQuad);
5351 declare CMlQuad Quad_Image <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-image") as CMlQuad);
5352 declare CMlQuad Quad_FocusIcon <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-icon") as CMlQuad);
5353 declare CMlQuad Quad_FocusBackground <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_quad-focus-background") as CMlQuad);
5354 declare CMlLabel Label_Value <=> (_Frame_Button.GetFirstChild("ComponentTMNextButton_label-value") as CMlLabel);
5355
5356 declare ComponentTMNextButton_K_Properties ComponentTMNextButton_Properties for _Frame_Button;
5357 ComponentTMNextButton_Properties = ComponentTMNextButton_K_Properties {
5358 IsButton = True,
5359 IsLocked = False,
5360 IsBgEmpty = False,
5361 IsBlink = False,
5362 SizeHitbox = <-1., -1.>,
5363 AlphaMask = "",
5364 OpacityUnfocus = 1.,
5365 Label = ComponentTMNextButton_K_TextProperties {
5366 Size = <-1., -1.>,
5367 TextSize = Label_Value.TextSizeReal,
5368 TextPrefix = "$t$i",
5369 Value= "",
5370 Font = Label_Value.TextFont,
5371 PosX = 0.5,
5372 PosY = -0.5,
5373 Color = Label_Value.TextColor,
5374 FocusColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(ComponentMenuLibsTools_GetVisibleColorOnBackground(Quad_Image.BgColor, Quad_Image.BgColor), Label_Value.TextColor),
5375 ItalicSlope = 0.,
5376 HAlign = "center",
5377 VAlign = "center",
5378 MaxLine = -1,
5379 AutoNewLine = False,
5380 Fit = -1.,
5381 FitStep = 0.25,
5382 OpacityUnfocus = -1.
5383 },
5384 Icon = ComponentTMNextButton_K_ImageProperties {
5385 ColorType = ComponentTMNextButton_C_ColorType_Colorize,
5386 Size = Quad_Icon.Size,
5387 Image = Quad_Icon.ImageUrl,
5388 ImageFocus = Quad_FocusIcon.ImageUrl,
5389 PosX = 0.5,
5390 PosY = -0.5,
5391 Color = Quad_Icon.BgColor,
5392 FocusColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(Quad_Icon.BgColor, Quad_Icon.BgColor),
5393 Rotation = 0.,
5394 OpacityUnfocus = -1.,
5395 Opacity = 1.,
5396 ImageFocusOpacity = -1.,
5397 KeepRatio = CMlQuad::EKeepRatioMode::Inactive,
5398 ContourImage = "",
5399 ContourOpacityFocus = -1.,
5400 ContourOpacityUnfocus = -1.,
5401 ContourColor = <-1., -1., -1.>
5402 },
5403 Background = ComponentTMNextButton_K_ImageProperties {
5404 ColorType = ComponentTMNextButton_C_ColorType_Colorize,
5405 Size = Quad_Image.Size,
5406 Image = Quad_Image.ImageUrl,
5407 ImageFocus = Quad_FocusBackground.ImageUrl,
5408 PosX = 0.,
5409 PosY = 0.,
5410 Color = Quad_Image.BgColor,
5411 FocusColor = ComponentMenuLibsTools_GetVisibleColorOnBackground(Quad_Image.BgColor, Quad_Image.BgColor),
5412 Rotation = 0.,
5413 OpacityUnfocus = -1.,
5414 Opacity = 1.,
5415 ImageFocusOpacity = -1.,
5416 KeepRatio = CMlQuad::EKeepRatioMode::Inactive,
5417 ContourImage = "",
5418 ContourOpacityFocus = -1.,
5419 ContourOpacityUnfocus = -1.,
5420 ContourColor = <-1., -1., -1.>
5421 },
5422 HAlign = ComponentMenuLibsTools_C_HAlign_Left,
5423 VAlign = ComponentMenuLibsTools_C_VAlign_Top
5424 };
5425
5426 if (_Frame_Button.DataAttributeExists("iconcolortype")) {
5427 ComponentTMNextButton_Properties.Icon.ColorType = ComponentTMNextButton_TL::ToInteger(_Frame_Button.DataAttributeGet("iconcolortype"));
5428 }
5429 if (_Frame_Button.DataAttributeExists("bgempty")) {
5430 ComponentTMNextButton_Properties.IsBgEmpty = ComponentMenuLibsTools_GetBooleanAttribute(_Frame_Button, "bgempty");
5431 }
5432 if (_Frame_Button.DataAttributeExists("isblink")) {
5433 ComponentTMNextButton_Properties.IsBlink = ComponentMenuLibsTools_GetBooleanAttribute(_Frame_Button, "isblink");
5434 }
5435 if (_Frame_Button.DataAttributeExists("alphamask")) {
5436 ComponentTMNextButton_Properties.AlphaMask = _Frame_Button.DataAttributeGet("alphamask");
5437 }
5438 if (_Frame_Button.DataAttributeExists("backgroundcolortype")) {
5439 ComponentTMNextButton_Properties.Background.ColorType = ComponentTMNextButton_TL::ToInteger(_Frame_Button.DataAttributeGet("backgroundcolortype"));
5440 }
5441 if (_Frame_Button.DataAttributeExists("text")) {
5442 ComponentTMNextButton_Properties.Label.Value = _Frame_Button.DataAttributeGet("text");
5443 }
5444 if (_Frame_Button.DataAttributeExists("size")) {
5445 ComponentTMNextButton_Properties.Background.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Button.DataAttributeGet("size"));
5446 }
5447 if (_Frame_Button.DataAttributeExists("sizehitbox")) {
5448 ComponentTMNextButton_Properties.SizeHitbox = ComponentMenuLibsTools_TextToVec2(_Frame_Button.DataAttributeGet("sizehitbox"));
5449 }
5450 if (_Frame_Button.DataAttributeExists("opacity")) {
5451 ComponentTMNextButton_Properties.Background.Opacity = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("opacity"));
5452 }
5453 if (_Frame_Button.DataAttributeExists("opacityunfocus")) {
5454 ComponentTMNextButton_Properties.OpacityUnfocus = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("opacityunfocus"));
5455 }
5456 if (_Frame_Button.DataAttributeExists("bgcolor")) {
5457 ComponentTMNextButton_Properties.Background.Color = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("bgcolor"));
5458 }
5459 if (_Frame_Button.DataAttributeExists("focuscolor")) {
5460 ComponentTMNextButton_Properties.Background.FocusColor = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("focuscolor"));
5461 }
5462 if (_Frame_Button.DataAttributeExists("textcolor")) {
5463 ComponentTMNextButton_Properties.Label.Color = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("textcolor"));
5464 }
5465 if (_Frame_Button.DataAttributeExists("textfocuscolor")) {
5466 ComponentTMNextButton_Properties.Label.FocusColor = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("textfocuscolor"));
5467 }
5468 if (_Frame_Button.DataAttributeExists("textsize")) {
5469 ComponentTMNextButton_Properties.Label.TextSize = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("textsize"));
5470 }
5471 if (_Frame_Button.DataAttributeExists("textprefix")) {
5472 ComponentTMNextButton_Properties.Label.TextPrefix = _Frame_Button.DataAttributeGet("textprefix");
5473 }
5474 if (_Frame_Button.DataAttributeExists("textfont")) {
5475 ComponentTMNextButton_Properties.Label.Font = _Frame_Button.DataAttributeGet("textfont");
5476 }
5477 if (_Frame_Button.DataAttributeExists("textitalicslope")) {
5478 ComponentTMNextButton_Properties.Label.ItalicSlope = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("textitalicslope"));
5479 }
5480 if (_Frame_Button.DataAttributeExists("textopacityunfocus")) {
5481 ComponentTMNextButton_Properties.Label.OpacityUnfocus = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("textopacityunfocus"));
5482 }
5483 if (_Frame_Button.DataAttributeExists("labelsize")) {
5484 ComponentTMNextButton_Properties.Label.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Button.DataAttributeGet("labelsize"));
5485 }
5486 if (_Frame_Button.DataAttributeExists("image")) {
5487 ComponentTMNextButton_Properties.Background.Image = _Frame_Button.DataAttributeGet("image");
5488 }
5489 if (_Frame_Button.DataAttributeExists("imagefocus")) {
5490 ComponentTMNextButton_Properties.Background.ImageFocus = _Frame_Button.DataAttributeGet("imagefocus");
5491 }
5492 if (_Frame_Button.DataAttributeExists("imagefocusopacity")) {
5493 ComponentTMNextButton_Properties.Background.ImageFocusOpacity = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("imagefocusopacity"));
5494 }
5495 if (_Frame_Button.DataAttributeExists("imageoffset")) {
5496 declare Pos = ComponentMenuLibsTools_TextToVec2(_Frame_Button.DataAttributeGet("imageoffset"));
5497 ComponentTMNextButton_Properties.Background.PosX = Pos.X;
5498 ComponentTMNextButton_Properties.Background.PosY = Pos.Y;
5499 }
5500 if (_Frame_Button.DataAttributeExists("icon")) {
5501 ComponentTMNextButton_Properties.Icon.Image = _Frame_Button.DataAttributeGet("icon");
5502 }
5503 if (_Frame_Button.DataAttributeExists("iconfocus")) {
5504 ComponentTMNextButton_Properties.Icon.ImageFocus = _Frame_Button.DataAttributeGet("iconfocus");
5505 }
5506 if (_Frame_Button.DataAttributeExists("iconcolor")) {
5507 ComponentTMNextButton_Properties.Icon.Color = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("iconcolor"));
5508 }
5509 if (_Frame_Button.DataAttributeExists("iconfocuscolor")) {
5510 ComponentTMNextButton_Properties.Icon.FocusColor = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("iconfocuscolor"));
5511 }
5512 if (_Frame_Button.DataAttributeExists("iconsize")) {
5513 ComponentTMNextButton_Properties.Icon.Size = ComponentMenuLibsTools_TextToVec2(_Frame_Button.DataAttributeGet("iconsize"));
5514 }
5515 if (_Frame_Button.DataAttributeExists("iconxpos")) {
5516 ComponentTMNextButton_Properties.Icon.PosX = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("iconxpos"));
5517 }
5518 if (_Frame_Button.DataAttributeExists("iconypos")) {
5519 ComponentTMNextButton_Properties.Icon.PosY = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("iconypos"));
5520 }
5521 if (_Frame_Button.DataAttributeExists("iconrot")) {
5522 ComponentTMNextButton_Properties.Icon.Rotation = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("iconrot"));
5523 }
5524 if (_Frame_Button.DataAttributeExists("iconopacityunfocus")) {
5525 ComponentTMNextButton_Properties.Icon.OpacityUnfocus = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("iconopacityunfocus"));
5526 }
5527 if (_Frame_Button.DataAttributeExists("textxpos")) {
5528 ComponentTMNextButton_Properties.Label.PosX = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("textxpos"));
5529 }
5530 if (_Frame_Button.DataAttributeExists("textypos")) {
5531 ComponentTMNextButton_Properties.Label.PosY = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("textypos"));
5532 }
5533 if (_Frame_Button.DataAttributeExists("texthalign")) {
5534 ComponentTMNextButton_Properties.Label.HAlign = _Frame_Button.DataAttributeGet("texthalign");
5535 }
5536 if (_Frame_Button.DataAttributeExists("textvalign")) {
5537 ComponentTMNextButton_Properties.Label.VAlign = _Frame_Button.DataAttributeGet("textvalign");
5538 }
5539 if (_Frame_Button.DataAttributeExists("halign")) {
5540 ComponentTMNextButton_Properties.HAlign = _Frame_Button.DataAttributeGet("halign");
5541 }
5542 if (_Frame_Button.DataAttributeExists("valign")) {
5543 ComponentTMNextButton_Properties.VAlign = _Frame_Button.DataAttributeGet("valign");
5544 }
5545 if (_Frame_Button.DataAttributeExists("maxline")) {
5546 ComponentTMNextButton_Properties.Label.MaxLine = ComponentTMNextButton_TL::ToInteger(_Frame_Button.DataAttributeGet("maxline"));
5547 }
5548 if (_Frame_Button.DataAttributeExists("autonewline")) {
5549 ComponentTMNextButton_Properties.Label.AutoNewLine = ComponentMenuLibsTools_GetBooleanAttribute(_Frame_Button, "autonewline");
5550 }
5551 if (_Frame_Button.DataAttributeExists("fitlabel")) {
5552 ComponentTMNextButton_Properties.Label.Fit = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("fitlabel"));
5553 }
5554 if (_Frame_Button.DataAttributeExists("fitlabelstep")) {
5555 ComponentTMNextButton_Properties.Label.FitStep = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("fitlabelstep"));
5556 }
5557 if (_Frame_Button.DataAttributeExists("bgkeepratio")) {
5558 declare Text KeepRatio = ComponentTMNextButton_TL::ToLowerCase(_Frame_Button.DataAttributeGet("bgkeepratio"));
5559 switch (KeepRatio) {
5560 case "clip": ComponentTMNextButton_Properties.Background.KeepRatio = CMlQuad::EKeepRatioMode::Clip;
5561 case "fit": ComponentTMNextButton_Properties.Background.KeepRatio = CMlQuad::EKeepRatioMode::Fit;
5562 default: ComponentTMNextButton_Properties.Background.KeepRatio = CMlQuad::EKeepRatioMode::Inactive;
5563 }
5564 }
5565 if (_Frame_Button.DataAttributeExists("contourimage")) {
5566 ComponentTMNextButton_Properties.Background.ContourImage = _Frame_Button.DataAttributeGet("contourimage");
5567 }
5568 if (_Frame_Button.DataAttributeExists("contouropacityfocus")) {
5569 ComponentTMNextButton_Properties.Background.ContourOpacityFocus = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("contouropacityfocus"));
5570 }
5571 if (_Frame_Button.DataAttributeExists("contouropacityunfocus")) {
5572 ComponentTMNextButton_Properties.Background.ContourOpacityUnfocus = ComponentTMNextButton_TL::ToReal(_Frame_Button.DataAttributeGet("contouropacityunfocus"));
5573 }
5574 if (_Frame_Button.DataAttributeExists("contourimagecolor")) {
5575 ComponentTMNextButton_Properties.Background.ContourColor = ComponentTMNextButton_CL::HexToRgb(_Frame_Button.DataAttributeGet("contourimagecolor"));
5576 }
5577
5578 ComponentTMNextButton_ApplyProperties(_Frame_Button, ComponentTMNextButton_Properties);
5579 ComponentTMNextButton_Unfocus(_Frame_Button);
5580}
5581
5582***MainInit***
5583***
5584declare Integer ComponentTMNextButton_BlinkEndTime;
5585Page.GetClassChildren("ComponentTMNextButton_frame-button-container", Page.MainFrame, True);
5586foreach (Control in Page.GetClassChildren_Result) {
5587 declare CMlFrame Frame_ButtonContainer = (Control as CMlFrame);
5588 ComponentTMNextButton_InitButton(Frame_ButtonContainer.Parent);
5589}
5590ComponentTMNextButton_G_DefaultColorFocus = ComponentMenuLibsTools_GetVisibleColorOnBackground(ComponentTMNextButton_CL::Hex6ToRgb("005948"), ComponentTMNextButton_CL::Hex6ToRgb("005948"));
5591***
5592
5593***MainLoop***
5594***
5595if (ComponentTMNextButton_G_QuadBlinking.count > 0 && (Now >= ComponentTMNextButton_BlinkEndTime || ComponentTMNextButton_G_ResetBlink)) {
5596 foreach (Quad in ComponentTMNextButton_G_QuadBlinking) {
5597 AnimMgr.Flush(Quad);
5598 AnimMgr.Add(Quad, "<anim opacity=\"0.3\" />", 2*ComponentTMNextButton_C_AnimTime_Blink/5, CAnimManager::EAnimManagerEasing::QuadOut);
5599 AnimMgr.AddChain(Quad, "<anim opacity=\"0.85\" />", 3*ComponentTMNextButton_C_AnimTime_Blink/5, CAnimManager::EAnimManagerEasing::QuadOut);
5600 }
5601 ComponentTMNextButton_BlinkEndTime = Now + ComponentTMNextButton_C_AnimTime_Blink;
5602 ComponentTMNextButton_G_ResetBlink = False;
5603}
5604***
5605
5606// */
5607// @Component end component-tmnext-button
5608
5609Void SetTrophyImage(CMlQuad _Quad_Trophy, CMlLabel _Label_Reward, Text _Division, Text _CompetitionType) {
5610 if (_Quad_Trophy == Null) return;
5611
5612 declare Text ImgUrl;
5613 declare Integer TrophyType;
5614 declare Integer TrophyNb;
5615
5616 if (_CompetitionType == C_Daily_Competition_Rerun) {
5617 ImgUrl = C_DivisionToImages_Rerun.get(_Division);
5618 TrophyType = C_DivisionToTrophyType_Rerun.get(_Division);
5619 TrophyNb = C_DivisionToTrophyNumber_Rerun.get(_Division);
5620 } else {
5621 ImgUrl = C_DivisionToImages_Official.get(_Division);
5622 TrophyType = C_DivisionToTrophyType_Official.get(_Division);
5623 TrophyNb = C_DivisionToTrophyNumber_Official.get(_Division);
5624 }
5625
5626 _Quad_Trophy.ChangeImageUrl(ImgUrl);
5627 _Label_Reward.Value = TL::Compose("The winner earns $<$7FA%1 Trophy %2$>", ""^TrophyNb, ""^TrophyType);
5628}
5629
5630Void Focus(CMlControl _From, CMlControl _To) {
5631 if (_From != Null) {
5632 ComponentNavigation_Unfocus(_From);
5633 if (ComponentTMNextButton_IsButton(_From)) {
5634 ComponentTMNextButton_Unfocus((_From as CMlFrame));
5635 }
5636 }
5637
5638 if (_To != Null) {
5639 ComponentNavigation_Focus(_To);
5640 if (ComponentTMNextButton_IsButton(_To)) {
5641 ComponentTMNextButton_Focus((_To as CMlFrame));
5642 }
5643 }
5644}
5645
5646Void Toggle(CMlFrame _Frame_PopUp, Boolean _Enabled) {
5647 _Frame_PopUp.Visible = _Enabled;
5648}
5649
5650Void Select(CMlFrame _Frame_PopUp, CMlControl _Control) {
5651 if (_Control == Null) return;
5652
5653 switch (_Control.ControlId) {
5654 case "button-ok": Toggle(_Frame_PopUp, False);
5655 }
5656}
5657
5658***MainInit***
5659***
5660declare CMlFrame Frame_Global;
5661declare CMlFrame Frame_PopUp;
5662declare CMlFrame Button_Ok;
5663declare CMlQuad Quad_Trophy;
5664declare CMlLabel Label_Subtitle;
5665declare CMlLabel Label_Reward;
5666
5667declare netread Text Net_KnockoutDaily_WelcomePopUp_Division for Teams[0];
5668declare netread Text Net_KnockoutDaily_WelcomePopUp_CompetitionType for Teams[0];
5669
5670declare Boolean DisplayModule;
5671declare Text CurrentDivison;
5672declare Text CurrentCompetitionType;
5673***
5674
5675***MainStart***
5676***
5677Frame_Global <=> (Page.GetFirstChild("frame-global") as CMlFrame);
5678Frame_PopUp <=> (Frame_Global.GetFirstChild("frame-pop-up") as CMlFrame);
5679Button_Ok <=> (Frame_Global.GetFirstChild("button-ok") as CMlFrame);
5680Quad_Trophy <=> (Frame_PopUp.GetFirstChild("quad-trophy") as CMlQuad);
5681Label_Subtitle <=> (Frame_PopUp.GetFirstChild("label-subtitle") as CMlLabel);
5682Label_Reward <=> (Frame_PopUp.GetFirstChild("label-reward") as CMlLabel);
5683
5684DisplayModule = Frame_Global.Visible;
5685ComponentNavigation_UseLocalEvents(True);
5686Focus(ComponentNavigation_GetFocusedControl("navgroup-knockoutdaily-welcomepopup"), Button_Ok);
5687***
5688
5689***MainLoop***
5690***
5691if (Frame_PopUp.Visible && !EnableMenuNavigationInputs) {
5692 EnableMenuNavigation(True, False, False, Null, 1);
5693} else if (!Frame_PopUp.Visible && EnableMenuNavigationInputs) {
5694 EnableMenuNavigation(False, False, False, Null, 1);
5695}
5696
5697if (PageIsVisible) {
5698 declare Owner <=> Utils_GetOwner();
5699 if (Owner != Null) {
5700 declare netread Boolean Net_KnockoutDaily_WelcomePopUp_IsVisible for Owner;
5701 if (DisplayModule != Net_KnockoutDaily_WelcomePopUp_IsVisible) {
5702 DisplayModule = Net_KnockoutDaily_WelcomePopUp_IsVisible;
5703 Frame_Global.Visible = Net_KnockoutDaily_WelcomePopUp_IsVisible;
5704 }
5705 }
5706
5707 if (Owner == Null && DisplayModule) {
5708 DisplayModule = False;
5709 Frame_Global.Visible = DisplayModule;
5710 }
5711
5712 if (Frame_PopUp.Visible) {
5713 if (CurrentDivison != Net_KnockoutDaily_WelcomePopUp_Division || CurrentCompetitionType != Net_KnockoutDaily_WelcomePopUp_CompetitionType) {
5714 CurrentDivison = Net_KnockoutDaily_WelcomePopUp_Division;
5715 CurrentCompetitionType = Net_KnockoutDaily_WelcomePopUp_CompetitionType;
5716 SetTrophyImage(Quad_Trophy, Label_Reward, CurrentDivison, CurrentCompetitionType);
5717 if (Map != Null) Label_Subtitle.Value = Map.MapInfo.Name;
5718 }
5719
5720 foreach (Event in ComponentPopUpBackground_PendingEvents) {
5721 if (
5722 Event.Type == ComponentPopUpBackground_C_Event_LeavePopUp &&
5723 Event.PopUpName == "WelcomePopUp" &&
5724 Event.FromCloseButton
5725 ) {
5726 Toggle(Frame_PopUp, False);
5727 }
5728 }
5729
5730 foreach (Event in ComponentNavigation_PendingEvents) {
5731 switch (Event.Type) {
5732 case ComponentNavigation_C_EventType_NavigateInput: {
5733 if (ComponentNavigation_IsEventFromGroup(Event, "navgroup-knockoutdaily-welcomepopup")) {
5734 if (Event.Input == CMlScriptEvent::EMenuNavAction::Select) {
5735 Select(Frame_PopUp, Event.To);
5736 } else if (Event.Input == CMlScriptEvent::EMenuNavAction::Cancel) {
5737 Toggle(Frame_PopUp, False);
5738 } else {
5739 Focus(Event.From, Event.To);
5740 }
5741 }
5742 }
5743 case ComponentNavigation_C_EventType_NavigateMouse: {
5744 if (ComponentNavigation_IsEventFromGroup(Event, "navgroup-knockoutdaily-welcomepopup")) {
5745 if (Event.Mouse == CMlScriptEvent::Type::MouseClick) {
5746 Select(Frame_PopUp, Event.To);
5747 } else if (Event.Mouse == CMlScriptEvent::Type::MouseOver) {
5748 Focus(Event.From, Event.To);
5749 }
5750 }
5751 }
5752 }
5753 }
5754 }
5755}
5756***
5757
5758
5759Void ManiaView_DoNothing() {}
5760
5761main() {
5762 +++MainInit+++
5763 +++MainStart+++
5764 while (True) {
5765 yield;
5766 +++MainLoop+++
5767 }
5768 +++MainEnd+++
5769}
5770
5771