Support toogle UI

This commit is contained in:
Beu 2021-09-26 17:19:38 +02:00
parent eeed1df1cf
commit 428a1708ca

View File

@ -296,6 +296,30 @@ Void SetML() {
return True;
}
Void ToggleUI() {
declare CMlFrame Frame_Global <=> (Page.GetFirstChild("frame-global") as CMlFrame);
declare CMlFrame Frame_UI <=> (Page.GetFirstChild("frame-UI") as CMlFrame);
declare CMlQuad Quad_Toggle <=> (Page.GetFirstChild("Toggle_SettingButton") as CMlQuad);
AnimMgr.Flush(Frame_Global);
AnimMgr.Flush(Frame_UI);
declare Real GlobalEndPosX;
if (Frame_UI.Visible) {
Quad_Toggle.ChangeImageUrl("file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/128x128/ICON_ARROW_RIGHT_OBLIQUE.dds");
Quad_Toggle.RelativePosition_V3.X = 5.;
GlobalEndPosX = -220.;
AnimMgr.Add(Frame_UI, "<frame hidden=\"1\" />", Now, 250, CAnimManager::EAnimManagerEasing::Linear);
} else {
Quad_Toggle.ChangeImageUrl("file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/128x128/ICON_ARROW_LEFT_OBLIQUE.dds");
Quad_Toggle.RelativePosition_V3.X = 0.;
GlobalEndPosX = -160.;
Frame_UI.Visible = True;
}
AnimMgr.Add(Frame_Global, "<frame pos=\"" ^GlobalEndPosX^" "^Frame_Global.RelativePosition_V3.Y^ "\" />", Now, 250, CAnimManager::EAnimManagerEasing::Linear);
}
Void UpdateSliderValues() {
declare Slider_Cruise <=> (Page.GetFirstChild("Cruise_Slider") as CMlSlider);
declare Slider_AccelCoef <=> (Page.GetFirstChild("AccelCoef_Slider") as CMlSlider);
@ -495,7 +519,9 @@ Void SetML() {
foreach(Event in PendingEvents) {
DevLog("[PendingEvents] Event.Type: " ^ Event.Type);
if (Owner != Null /*&& Owner.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned*/) {
if (Event.Type == CMlScriptEvent::Type::MouseClick && TL::Find("_EffectButton", Event.ControlId, True, True)) {
log("[DEBUG] GUIPlayer.SpawnStatus: " ^ GUIPlayer.SpawnStatus ^ " / InputPlayer.SpawnStatus: " ^ InputPlayer.SpawnStatus);
if (Event.Type == CMlScriptEvent::Type::MouseClick ) {
if (TL::Find("_EffectButton", Event.ControlId, True, True)) {
declare Text Effect = TL::Replace(Event.ControlId, "_EffectButton", "");
declare Text Target;
if (Net_PlayerIsAdmin && Last_ControledByAdmins) Target = "all";
@ -503,24 +529,28 @@ Void SetML() {
DevLog("[PendingEvents] Request of " ^ Effect ^ " to " ^ Target);
if (GetValueOfAnEffect(Last_PlayerPhysics, Effect) == "1") SendCustomEvent("Request.PlayerPhysics." ^ Effect, [Target, "0"]);
else SendCustomEvent("Request.PlayerPhysics." ^ Effect, [Target, "1"]);
} else if (Event.Type == CMlScriptEvent::Type::MouseClick && TL::Find("_Slider", Event.ControlId, True, True)) {
Timer_NeedToSendCommandSlider = Now + 100;
Last_SliderValueToSend = Event.ControlId;
UpdateSliderValues();
} else if (Event.ControlId == "AllowSpectatorsControl_SettingButton") {
DevLog("[PendingEvents] Request ControlBySpectators " ^ !Last_PlayerAllowToBeControledBySpectators ^ " to " ^ Owner.User.Login);
if (Last_PlayerAllowToBeControledBySpectators) SendCustomEvent("Request.ControlBySpectators", [Owner.User.Login, "0"]);
else SendCustomEvent("Request.ControlBySpectators", [Owner.User.Login, "1"]);
} else if (Event.ControlId == "ControledByAdmins_SettingButton") {
DevLog("[PendingEvents] Request ControledByAdmins " ^ !Last_ControledByAdmins ^ " by " ^ Owner.User.Login);
if (Last_ControledByAdmins) SendCustomEvent("Request.AdminLock", ["", "0"]); // TODO: Secure with a token
else SendCustomEvent("Request.AdminLock", ["", "1"]);
} else if (Event.ControlId == "Toggle_SettingButton") {
DevLog("[PendingEvents] Toggle UI by " ^ Owner.User.Login);
ToggleUI();
}
} else if (Event.Type == CMlScriptEvent::Type::MouseOver && TL::Find("_EffectButton", Event.ControlId, True, True)) {
declare Quad <=> (Page.GetFirstChild(Event.ControlId) as CMlQuad);
Quad.Opacity = 0.7;
} else if (Event.Type == CMlScriptEvent::Type::MouseOut && TL::Find("_EffectButton", Event.ControlId, True, True)) {
declare Quad <=> (Page.GetFirstChild(Event.ControlId) as CMlQuad);
Quad.Opacity = 0.5;
} else if (Event.Type == CMlScriptEvent::Type::MouseClick && TL::Find("_Slider", Event.ControlId, True, True)) {
Timer_NeedToSendCommandSlider = Now + 100;
Last_SliderValueToSend = Event.ControlId;
UpdateSliderValues();
} else if (Event.Type == CMlScriptEvent::Type::MouseClick && Event.ControlId == "AllowSpectatorsControl_SettingButton") {
DevLog("[PendingEvents] Request ControlBySpectators " ^ !Last_PlayerAllowToBeControledBySpectators ^ " to " ^ Owner.User.Login);
if (Last_PlayerAllowToBeControledBySpectators) SendCustomEvent("Request.ControlBySpectators", [Owner.User.Login, "0"]);
else SendCustomEvent("Request.ControlBySpectators", [Owner.User.Login, "1"]);
} else if (Event.Type == CMlScriptEvent::Type::MouseClick && Event.ControlId == "ControledByAdmins_SettingButton") {
DevLog("[PendingEvents] Request ControledByAdmins " ^ !Last_ControledByAdmins ^ " by " ^ Owner.User.Login);
if (Last_ControledByAdmins) SendCustomEvent("Request.AdminLock", ["", "0"]); // TODO: Secure with a token
else SendCustomEvent("Request.AdminLock", ["", "1"]);
}
} else {
UpdateUISlider(Last_PlayerPhysics); // To update Slider Right Value
@ -547,7 +577,11 @@ Void SetML() {
<style class="text-suffix" textfont="GameFontBlack" textcolor="ffffff" textsize="0.7" halign="center" valign="center" textprefix="$i$t"/>
<style class="quad-effects" halign="center" valign="center" />
</stylesheet>
<frame pos="-160 40">
<frame id="frame-global" pos="-160 40">
<frame pos="58 -2.5" id="frame-toggle">
<quad id="Toggle_SettingButton" pos="0 0" size="4 4" class="quad-base" z-index="3" opacity="0.9" scriptevents="1" halign="center" valign="center" image="file://Media/Manialinks/Nadeo/TMNext/Menus/Icons/128x128/ICON_ARROW_LEFT_OBLIQUE.dds" colorize="fff"/>
</frame>
<frame id="frame-UI">
<quad id="quad-bg" pos="0 0" z-index="-1" size="60 74" bgcolor="000" opacity="0.5" /> <!-- 85 for regular, 74 without spec control-->
<quad id="quad-fg" pos="0 0" z-index="5" size="60 74" bgcolor="000" opacity="0.5" hidden=1 scriptevents="1" />
<label id="label-warning" class="text-suffix" hidden=1 z-index="6" pos="30 -35" textsize="2.5" size="50 10" autonewline="1"/>
@ -647,6 +681,7 @@ Void SetML() {
</frame>
</frame>
</frame>
</frame>
</manialink>
""";
Layers::Create("PhysicsDiscovery_UI", MLText);