From 3f02a9e87b234abc773a5d0c00861b1be99f315e Mon Sep 17 00:00:00 2001 From: Beu Date: Tue, 24 Jan 2023 01:25:19 +0100 Subject: [PATCH] Add newly developped plugins --- RPGOnlineSpectator/info.toml | 6 +++ RPGOnlineSpectator/src/main.as | 71 +++++++++++++++++++++++++++++ TMWTInterfacesHider/info.toml | 4 ++ TMWTInterfacesHider/main.as | 81 +++++++++++++++++++++++++++++++++ TMWTInterfacesHider/settings.as | 5 ++ TMWTScreenRemover/info.toml | 5 ++ TMWTScreenRemover/main.as | 67 +++++++++++++++++++++++++++ 7 files changed, 239 insertions(+) create mode 100644 RPGOnlineSpectator/info.toml create mode 100644 RPGOnlineSpectator/src/main.as create mode 100644 TMWTInterfacesHider/info.toml create mode 100644 TMWTInterfacesHider/main.as create mode 100644 TMWTInterfacesHider/settings.as create mode 100644 TMWTScreenRemover/info.toml create mode 100644 TMWTScreenRemover/main.as diff --git a/RPGOnlineSpectator/info.toml b/RPGOnlineSpectator/info.toml new file mode 100644 index 0000000..2677c73 --- /dev/null +++ b/RPGOnlineSpectator/info.toml @@ -0,0 +1,6 @@ +[meta] +name = "RPG Online Spectator" +category = "Online" +author = "Beu" +version = "1.0" +siteid = 287 \ No newline at end of file diff --git a/RPGOnlineSpectator/src/main.as b/RPGOnlineSpectator/src/main.as new file mode 100644 index 0000000..a6f8463 --- /dev/null +++ b/RPGOnlineSpectator/src/main.as @@ -0,0 +1,71 @@ +bool displayUI = true; + +void RenderMenu() { + auto App = cast(GetApp()); + auto Network = cast(App.Network); + auto ServerInfo = cast(Network.ServerInfo); + + if (Network !is null && ServerInfo !is null && ServerInfo.ServerLogin != "") { + if(UI::MenuItem("\\$77d" + Icons::VideoCamera + " \\$fffRPG Online Spectator", "", displayUI)) { + displayUI = !displayUI; + } + } else { + displayUI = false; + } +} + +void RenderInterface() { + auto App = cast(GetApp()); + auto Network = cast(App.Network); + auto ServerInfo = cast(Network.ServerInfo); + CGamePlayground@ Playground = GetApp().CurrentPlayground; + + if (Network !is null && ServerInfo !is null && ServerInfo.ServerLogin != "") { + if (Playground is null) return; + if (displayUI) { + auto ManiaApp = Network.ClientManiaAppPlayground; + UI::PushStyleVar(UI::StyleVar::WindowMinSize, vec2(200, 250)); + if (UI::Begin("\\$fc3" + Icons::VideoCamera + "\\$z RPG Online Spectator", displayUI)) { + UI::TextWrapped("Only use this plugin to spectate other players to not cancel your run"); + + if (ManiaApp.ClientUI.ForceSpectator) { + if (UI::Button("Continue your run")) { + ManiaApp.ClientUI.ForceSpectator = false; + } + } + + UI::Separator(); + + if (UI::BeginChild("playerlist")) { + + for (uint i = 0; i < Playground.Players.Length; i++) { + CSmPlayer@ Player = cast(Playground.Players[i]); + CSmScriptPlayer@ ScriptPlayer = cast(Player.ScriptAPI); + + if (Playground.Interface.ManialinkScriptHandler.LocalUser.Login == Player.User.Login) continue; + + bool isSpectator = Player.User.SpectatorMode == CGameNetPlayerInfo::ESpectatorMode::Watcher + || Player.User.SpectatorMode == CGameNetPlayerInfo::ESpectatorMode::LocalWatcher + || Player.SpawnIndex < 0; + + if (isSpectator) continue; + + if (UI::MenuItem(Player.User.Name)) { + ManiaApp.ClientUI.ForceSpectator = true; + + CGamePlaygroundClientScriptAPI@ Api = GetApp().CurrentPlayground.Interface.ManialinkScriptHandler.Playground; + Api.SetSpectateTarget(Player.User.Login); + } + } + + UI::EndChild(); + } + + UI::End(); + } + UI::PopStyleVar(); + } + } else { + displayUI = false; + } +} \ No newline at end of file diff --git a/TMWTInterfacesHider/info.toml b/TMWTInterfacesHider/info.toml new file mode 100644 index 0000000..f9c3eef --- /dev/null +++ b/TMWTInterfacesHider/info.toml @@ -0,0 +1,4 @@ +[meta] +name = "TMWT Interfaces Remover" +category = "TMWT" +version = "1.0" diff --git a/TMWTInterfacesHider/main.as b/TMWTInterfacesHider/main.as new file mode 100644 index 0000000..9300cc1 --- /dev/null +++ b/TMWTInterfacesHider/main.as @@ -0,0 +1,81 @@ +bool InterfacesAreHidden; +bool HideInterfaces; +string Last_ServerLogin; +CGameUILayer@ UILayer_LiveRanking; +CGameUILayer@ UILayer_TeamsScores; + +void RenderMenu() { + if(UI::MenuItem("\\$77d" + Icons::User + " \\$fffTMWT Interfaces Remover", "", HideInterfaces)) { + auto app = cast(GetApp()); + auto network = cast(app.Network); + auto serverinfo = cast(network.ServerInfo); + if (network !is null && serverinfo !is null && serverinfo.ServerLogin != "") { + HideInterfaces = !HideInterfaces; + } + } +} + +CGameUILayer@ findUILayer(const MwFastBuffer _UILayers, string _ManialinkId) { + for (uint i = 0; i < _UILayers.Length; i++) { + string manialink = _UILayers[i].ManialinkPage; + auto firstlines = manialink.Split("\n", 5); + if (firstlines.Length > 0) { + for (uint j = 0; j < firstlines.Length - 1; j++) { + if (firstlines[j].Contains(_ManialinkId)) { + return _UILayers[i]; + } + } + } + } + return null; +} + +void Main() { + while(true) { + auto app = cast(GetApp()); + auto network = cast(app.Network); + auto serverinfo = cast(network.ServerInfo); + + if (network !is null && serverinfo !is null) { + if (Last_ServerLogin != serverinfo.ServerLogin) { + Last_ServerLogin = serverinfo.ServerLogin; + HideInterfaces = false; + InterfacesAreHidden = false; + } + + CGameManiaAppPlayground@ ManiaApp = cast(network.ClientManiaAppPlayground); + if (ManiaApp !is null) { + if (UILayer_LiveRanking is null) { + @UILayer_LiveRanking = findUILayer(ManiaApp.UILayers, "UIModule_TMWTTeams_LiveRanking"); + } + if (UILayer_TeamsScores is null) { + @UILayer_TeamsScores = findUILayer(ManiaApp.UILayers, "UIModule_TMWTTeams_Header"); + } + if (HideInterfaces && !InterfacesAreHidden && ManiaApp.UI.UISequence == CGamePlaygroundUIConfig::EUISequence::Playing) { + if (HideLiveRanking && UILayer_LiveRanking !is null) { + UILayer_LiveRanking.IsVisible = false; + } + if (HideTeamsScores && UILayer_TeamsScores !is null) { + UILayer_TeamsScores.IsVisible = false; + } + InterfacesAreHidden = true; + } else if (InterfacesAreHidden && (!HideInterfaces || ManiaApp.UI.UISequence != CGamePlaygroundUIConfig::EUISequence::Playing)) { + if (UILayer_LiveRanking !is null) { + UILayer_LiveRanking.IsVisible = true; + } + if (UILayer_TeamsScores !is null) { + UILayer_TeamsScores.IsVisible = true; + } + InterfacesAreHidden = false; + } + } + } else { + Last_ServerLogin = ""; + HideInterfaces = false; + InterfacesAreHidden = false; + @UILayer_LiveRanking = null; + @UILayer_TeamsScores = null; + } + yield(); + } +} diff --git a/TMWTInterfacesHider/settings.as b/TMWTInterfacesHider/settings.as new file mode 100644 index 0000000..16ad88e --- /dev/null +++ b/TMWTInterfacesHider/settings.as @@ -0,0 +1,5 @@ +[Setting category="Interfaces" name="Hide Live Ranking"] +bool HideLiveRanking = true; + +[Setting category="Interfaces" name="Hide Teams Scores"] +bool HideTeamsScores = true; \ No newline at end of file diff --git a/TMWTScreenRemover/info.toml b/TMWTScreenRemover/info.toml new file mode 100644 index 0000000..bfc6fbf --- /dev/null +++ b/TMWTScreenRemover/info.toml @@ -0,0 +1,5 @@ +[meta] +name = "TMWT Screen Remover" +category = "TMWT" +version = "1.2" +siteid = 183 diff --git a/TMWTScreenRemover/main.as b/TMWTScreenRemover/main.as new file mode 100644 index 0000000..1260337 --- /dev/null +++ b/TMWTScreenRemover/main.as @@ -0,0 +1,67 @@ +string last_serverlogin = ""; +bool removesign; +bool signremoved; + +void RenderMenu() { + if(UI::MenuItem("\\$77d" + Icons::User + " \\$fffTMWT Screen Remover", "", removesign)) { + auto app = cast(GetApp()); + auto network = cast(app.Network); + auto serverinfo = cast(network.ServerInfo); + if (network !is null && serverinfo !is null && serverinfo.ServerLogin != "") { + removesign = true; + signremoved = false; + } + } +} + +void Main() { + while(true) { + + auto app = cast(GetApp()); + auto network = cast(app.Network); + auto serverinfo = cast(network.ServerInfo); + + if (network !is null && serverinfo !is null) { + if (last_serverlogin != serverinfo.ServerLogin) { + last_serverlogin = serverinfo.ServerLogin; + if (removesign) { + removesign = false; + } + if (signremoved) { + signremoved = false; + } + } + + if (removesign && !signremoved) { + auto maniaapp = network.ClientManiaAppPlayground; + if (maniaapp !is null) { + signremoved = true; + auto uilayers = maniaapp.UILayers; + for (uint i = 0; i < uilayers.Length; i++) { + string manialink = uilayers[i].ManialinkPage; + auto firstlines = manialink.Split("\n", 5); + if (firstlines.Length > 0) { + for (uint j = 0; j < firstlines.Length - 1; j++) { + if (firstlines[j].Contains("UIModule_TMWTTeams_Sign")) { + maniaapp.UILayerDestroy(uilayers[i]); + } + } + } + } + } + } + } else { + if (last_serverlogin != "") { + last_serverlogin = ""; + } + if (removesign) { + removesign = false; + } + if (signremoved) { + signremoved = false; + } + } + + sleep(1000); + } +}