-
Notifications
You must be signed in to change notification settings - Fork 0
/
TM_AnimationEasingsExample.Script.txt
145 lines (120 loc) · 4.54 KB
/
TM_AnimationEasingsExample.Script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
This gamemode is just an UI with all animations easings displayed.
*/
#Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt"
#Const C_Anims [
"Linear",
"QuadIn", "QuadOut", "QuadInOut",
"CubicIn", "CubicOut", "CubicInOut",
"QuartIn", "QuartOut", "QuartInOut",
"QuintIn", "QuintOut", "QuintInOut",
"SineIn", "SineOut", "SineInOut",
"ExpIn", "ExpOut", "ExpInOut",
"CircIn", "CircOut", "CircInOut",
"BackIn", "BackOut", "BackInOut",
"ElasticIn", "ElasticOut", "ElasticInOut",
"ElasticIn2", "ElasticOut2", "ElasticInOut2",
"BounceIn", "BounceOut", "BounceInOut"
]
***Match_AfterLoadHud***
***
SetMl();
***
Void SetMl() {
declare Integer IndexX = 0;
declare Integer IndexY = 0;
declare Text FrameInstances;
for (I, 0, C_Anims.count - 1) {
FrameInstances ^= """<frameinstance modelid="framemodel" pos="{{{IndexX * 15.}}} {{{IndexY * -20.}}}"/>""";
if (IndexX == 4) {
IndexX = 0;
IndexY += 1;
} else {
IndexX += 1;
}
}
declare Text MLText = """
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="3" name="AnimationEasingsExamples">
<framemodel id="framemodel">
<quad id="quad-background" size="15 18" halign="center" bgcolor="fff" opacity="0" scriptevents="1"/>
<frame pos="0 -0.5">
<quad id="quad-graph-brackground" size="14 14" halign="center" bgcolor="000"/>
<graph id="graph" pos="0.5 -0.5" size="13 13" halign="center" min="0 -0.3" max="105. 1.3"/>
</frame>
<label id="label-name" size="14 10" pos="0 -15" textsize="1" halign="center" textcolor="ffffff" textfont="GameFontRegular"/>
</framemodel>
<frame z-index=20>
<quad z-index="-2" halign="center" valign="center" size="250 150" bgcolor="222" />
<frame id="frame-anims" pos="-115 68">
{{{FrameInstances}}}
</frame>
<frame pos="-40 50">
<quad size="150 0.2" bgcolor="aaa"/>
<quad id="quad-point1" size="5 5" bgcolor="fff"/>
<quad pos="0 -80" size="150 0.2" bgcolor="aaa"/>
</frame>
<frame pos="-30 -50">
<quad pos="0 2.5" size="0.2 10" bgcolor="aaa"/>
<quad id="quad-point2" size="5 5" bgcolor="fff"/>
<quad pos="130 2.5" size="0.2 10" bgcolor="aaa"/>
</frame>
<label id="label-currentanimname" pos="40 -65" textsize="3" halign="center" textcolor="ffffff" textfont="GameFontSemiBold" text="Linear"/>
</frame>
<script><!--
#Include "AnimLib" as AL
#Include "TimeLib" as TiL
#Include "MathLib" as ML
#Const ScriptName "AnimationEasingsExamples"
#Const Version "2024-02-19"
#Const C_Anims {{{dump(C_Anims)}}}
#Const C_AnimationDuration 1500
Void InitFrameInstances() {
declare CMlFrame Frame_Anims <=> Page.GetFirstChild("frame-anims") as CMlFrame;
declare Integer Index = 0;
foreach (AnimName in C_Anims) {
declare CMlFrame Frame <=> Frame_Anims.Controls[Index] as CMlFrame;
declare Text AnimationName for Frame;
AnimationName = AnimName;
declare CMlLabel Label_Name <=> Frame.GetFirstChild("label-name") as CMlLabel;
Label_Name.Value = AnimName;
declare CMlGraph Graph = Frame.GetFirstChild("graph") as CMlGraph;
declare CMlGraphCurve Curve = Graph.AddCurve();
Curve.Width = 0.3;
for (I, 0, 100) {
Curve.Points.add(<I * 1., AL::Ease(AnimName, I * 1., 0., 1., 100.)>);
}
Index += 1;
}
}
main() {
InitFrameInstances();
declare CMlLabel Label_CurrentAnimName <=> Page.GetFirstChild("label-currentanimname") as CMlLabel;
declare CMlQuad Quad_Point1 <=> Page.GetFirstChild("quad-point1") as CMlQuad;
declare CMlQuad Quad_Point2 <=> Page.GetFirstChild("quad-point2") as CMlQuad;
declare Integer Last_PlayAnimationTime;
while (True) {
yield;
foreach (Event in PendingEvents) {
if (Event.Type == CMlScriptEvent::Type::MouseOver) {
(Event.Control as CMlQuad).Opacity = 0.2;
} else if (Event.Type == CMlScriptEvent::Type::MouseOut) {
(Event.Control as CMlQuad).Opacity = 0.;
} else if (Event.Type == CMlScriptEvent::Type::MouseClick) {
declare Text AnimationName for Event.Control.Parent;
Label_CurrentAnimName.Value = AnimationName;
Last_PlayAnimationTime = Now;
}
}
Quad_Point1.RelativePosition_V3.X = AL::Ease("Linear", Now - Last_PlayAnimationTime * 1., 0., 145., C_AnimationDuration * 1.);
Quad_Point1.RelativePosition_V3.Y = AL::Ease(Label_CurrentAnimName.Value, Now - Last_PlayAnimationTime * 1., 0., -75., C_AnimationDuration * 1.);
Quad_Point2.RelativePosition_V3.X = AL::Ease(Label_CurrentAnimName.Value, Now - Last_PlayAnimationTime * 1., 0., 125., C_AnimationDuration * 1.);
}
}
--></script>
</manialink>
""";
Layers::Create("AnimationEasingsExamples", MLText);
Layers::SetType("AnimationEasingsExamples", CUILayer::EUILayerType::Normal);
Layers::Attach("AnimationEasingsExamples");
}