From 428a1708cab21785f90c7740259a63d876265874 Mon Sep 17 00:00:00 2001 From: Beu Date: Sun, 26 Sep 2021 17:19:38 +0200 Subject: [PATCH] Support toogle UI --- PhysicsController.Script.txt | 253 ++++++++++++++++++++--------------- 1 file changed, 144 insertions(+), 109 deletions(-) diff --git a/PhysicsController.Script.txt b/PhysicsController.Script.txt index 849bd0d..c491de7 100644 --- a/PhysicsController.Script.txt +++ b/PhysicsController.Script.txt @@ -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, "", 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, "", 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,33 +519,39 @@ 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)) { - declare Text Effect = TL::Replace(Event.ControlId, "_EffectButton", ""); - declare Text Target; - if (Net_PlayerIsAdmin && Last_ControledByAdmins) Target = "all"; - else Target = Owner.User.Login; - 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"]); + 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"; + else Target = Owner.User.Login; + 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,103 +577,108 @@ Void SetML() {