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