Compare commits

..

No commits in common. "63dabc4806238509fc02edf8e1d04d7c04dbdcd1" and "bad8dd4f58edce68cf5ecfdb7738e344fca08e5a" have entirely different histories.

View File

@ -3,13 +3,13 @@
* This mode is used to debug your modes during development.
* To use it, you just have to change the line below to put the path of your mode:
*/
#Extends "Modes/TM_TeamsCup.Script.txt"
#Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt"
// #RequireContext CSmMode
#Setting S_DebugLib_RestrictUIto "" as "Restrict UI Admin to comma separated logins (all if empty)"
#Const C_DebugMode_Version "2023-08-28"
#Const C_DebugMode_Version "2023-02-09"
#Const C_DebugMode_MainUI "DebugMode_MainUI"
@ -19,7 +19,6 @@
#Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils
#Setting S_ScriptEnvironment "development"
***Match_AfterLoadHud***
***
@ -32,7 +31,6 @@ Layers::SetType(C_DebugMode_MainUI, CUILayer::EUILayerType::Normal);
if (S_DebugLib_RestrictUIto == "") {
Layers::Attach(C_DebugMode_MainUI);
} else {
Layers::Detach(C_DebugMode_MainUI);
foreach (Login in TL::Split(",", S_DebugLib_RestrictUIto)) {
declare CSmPlayer Player = GetPlayer(Login);
if (Player != Null) Layers::Attach(C_DebugMode_MainUI, Player);
@ -77,10 +75,10 @@ foreach (Event in UIManager.PendingEvents) {
if (TeamId != -1 && Teams.existskey(TeamId)) {
for (I, 1, NumberOfBots) {
declare CUser User = Users_CreateFake(Name, TeamId);
if (User == Null) {
Net_DebugMode_Logs = Prefix ^ "Bots: unknown error while adding bot \"" ^ Name ^ "\"\n" ^ Net_DebugMode_Logs;
} else {
if (User != Null) {
Net_DebugMode_Logs = Prefix ^ "Bots: Add bot \"" ^ User.Name ^ "\"\n" ^ Net_DebugMode_Logs;
} else {
Net_DebugMode_Logs = Prefix ^ "Bots: unknown error while adding bot \"" ^ Name ^ "\"\n" ^ Net_DebugMode_Logs;
}
}
} else {
@ -147,10 +145,9 @@ foreach (Event in UIManager.PendingEvents) {
}
}
case "DebugMode.VarInsp.Dump.Teams0": {
// prevent to dump Net_DebugMode_Logs in the dump
declare Text Tmp = Net_DebugMode_Logs;
declare Text tmp = Net_DebugMode_Logs;
Net_DebugMode_Logs = "";
Net_DebugMode_Logs = Prefix ^ "Teams[0] dump:\n" ^ Dbg_DumpDeclareForVariables(Teams[0], False) ^"\n" ^ Tmp;
Net_DebugMode_Logs = Prefix ^ "Teams[0] dump:\n" ^ Dbg_DumpDeclareForVariables(Teams[0], False) ^"\n" ^ tmp;
}
case "DebugMode.VarInsp.Dump.UIAll": {
Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs;
@ -160,41 +157,67 @@ foreach (Event in UIManager.PendingEvents) {
}
case "DebugMode.VarInsp.ForVars.Dump.Player": {
declare CSmPlayer Player;
+++DebugMode_FindPlayer+++
if (TL::Length(Event.CustomEventData[0]) == 36) {
Player <=> ModeUtils::GetPlayerFromAccountId(Event.CustomEventData[0]);
} else if (TL::Length(Event.CustomEventData[0]) == 22) {
Player <=> GetPlayer(Event.CustomEventData[0]);
} else {
foreach (TmpPlayer in AllPlayers) {
if (TL::ToLowerCase(Event.CustomEventData[0]) == TL::ToLowerCase(TmpPlayer.User.Name)) {
Player <=> TmpPlayer;
break;
}
}
}
if (Player == Null) {
Net_DebugMode_Logs = Prefix ^ "ForVars dump: player not found\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "player") {
if (Player != Null) {
if (Event.CustomEventData[1] == "player") {
Net_DebugMode_Logs = Prefix ^ "Player ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player, False) ^"\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "score") {
Net_DebugMode_Logs = Prefix ^ "Score ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player.Score, False) ^"\n" ^ Net_DebugMode_Logs;
} else {
declare CUIConfig UI = UIManager.GetUI(Player);
if (UI == Null) {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
} else {
if (UI != Null) {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(UI, False) ^"\n" ^ Net_DebugMode_Logs;
} else {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
}
}
} else {
Net_DebugMode_Logs = Prefix ^ "ForVars dump: player not found\n" ^ Net_DebugMode_Logs;
}
}
case "DebugMode.VarInsp.Struct.Dump.Player": {
declare CSmPlayer Player;
+++DebugMode_FindPlayer+++
if (TL::Length(Event.CustomEventData[0]) == 36) {
Player <=> ModeUtils::GetPlayerFromAccountId(Event.CustomEventData[0]);
} else if (TL::Length(Event.CustomEventData[0]) == 22) {
Player <=> GetPlayer(Event.CustomEventData[0]);
} else {
foreach (TmpPlayer in AllPlayers) {
if (TL::ToLowerCase(Event.CustomEventData[0]) == TL::ToLowerCase(TmpPlayer.User.Name)) {
Player <=> TmpPlayer;
break;
}
}
}
if (Player == Null) {
Net_DebugMode_Logs = Prefix ^ "Struct dump: player not found\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "player") {
if (Player != Null) {
if (Event.CustomEventData[1] == "player") {
Net_DebugMode_Logs = Prefix ^ "Player Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player ^"\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "score") {
Net_DebugMode_Logs = Prefix ^ "Score Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player.Score ^"\n" ^ Net_DebugMode_Logs;
} else {
declare CUIConfig UI = UIManager.GetUI(Player);
if (UI == Null) {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
} else {
if (UI != Null) {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ UI ^"\n" ^ Net_DebugMode_Logs;
} else {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
}
}
} else {
Net_DebugMode_Logs = Prefix ^ "Struct dump: player not found\n" ^ Net_DebugMode_Logs;
}
}
default: {
Net_DebugMode_Logs = Prefix ^ "Struct Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs;
@ -202,75 +225,39 @@ foreach (Event in UIManager.PendingEvents) {
}
}
+++DebugMode_LogEvents+++
***
***DebugMode_FindPlayer***
***
if (TL::Length(Event.CustomEventData[0]) == 36) {
Player <=> ModeUtils::GetPlayerFromAccountId(Event.CustomEventData[0]);
} else if (TL::Length(Event.CustomEventData[0]) == 22) {
Player <=> GetPlayer(Event.CustomEventData[0]);
} else {
foreach (TmpPlayer in AllPlayers) {
if (TL::ToLowerCase(Event.CustomEventData[0]) == TL::ToLowerCase(TmpPlayer.User.Name)) {
Player <=> TmpPlayer;
break;
}
}
}
***
***DebugMode_LogEvents***
***
foreach (Event in PendingEvents) {
+++DebugMode_PendingEvents+++
}
foreach (Event in XmlRpc.PendingEvents) {
+++DebugMode_XmlRpcPendingEvents+++
}
declare Events::K_RaceEvent[] RacePendingEvents = Race::GetPendingEvents();
foreach (Event in RacePendingEvents) {
+++DebugMode_RacePendingEvents+++
}
***
***DebugMode_PendingEvents***
***
+++DebugMode_LogFormat+++
Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs;
if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) {
+++DebugMode_LogFormat+++
Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs;
if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) {
if (Event.Player != Null && TL::Split(",", S_DebugLib_RestrictUIto).exists(Event.Player.User.Login)) {
Layers::Attach(C_DebugMode_MainUI, Event.Player);
}
}
}
***
***DebugMode_XmlRpcPendingEvents***
***
+++DebugMode_LogFormat+++
if (Event.Type == CXmlRpcEvent::EType::CallbackArray) {
foreach (Event in XmlRpc.PendingEvents) {
+++DebugMode_LogFormat+++
if (Event.Type == CXmlRpcEvent::EType::CallbackArray) {
Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.ParamArray1 ^"\n" ^ Net_DebugMode_Logs;
} else {
} else {
Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.Param1 ^"\n" ^ Net_DebugMode_Logs;
}
}
***
***DebugMode_RacePendingEvents***
***
+++DebugMode_LogFormat+++
declare Text Type = "Unknown";
switch (Event.Type) {
declare RacePendingEvents = Race::GetPendingEvents();
foreach (Event in RacePendingEvents) {
+++DebugMode_LogFormat+++
declare Text Type = "Unknown";
switch (Event.Type) {
case 1: Type = "Waypoint";
case 2: Type = "GiveUp";
case 3: Type = "Respawn";
case 4: Type = "SkipOutro";
case 5: Type = "StartLine";
case 6: Type = "Eliminated";
}
Net_DebugMode_Logs = Prefix ^ "Race Pending Event: " ^ Type ^"\n" ^ Net_DebugMode_Logs;
}
Net_DebugMode_Logs = Prefix ^ "Race Pending Event: " ^ Type ^"\n" ^ Net_DebugMode_Logs;
***
***DebugMode_LogFormat***
@ -295,14 +282,15 @@ if (TL::Length(Net_DebugMode_Logs) > 1000000) {
Net_DebugMode_Logs = TL::SubString(Net_DebugMode_Logs, 0, 1000000);
}
declare netwrite Integer Net_DebugMode_Logs_Serial for Teams[0];
Net_DebugMode_Logs_Serial += 1;
***
Text GetManialink() {
return """
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink name="DebugMode_UI" version="3">
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink name="DebugMode_UI" version="3">
<stylesheet>
<style class="text" halign="left" textsize="1" textcolor="FFFFFFFF"/>
<style class="entry" halign="left" textsize="1" textcolor="FFFFFFFF" valign="center2" focusareacolor1="000000f0" focusareacolor2="000000f0"/>
@ -313,7 +301,7 @@ Text GetManialink() {
<framemodel id="framemodel-tooltip">
<quad size="4 4" bgcolor="FFF" style="UICommon64_1" substyle="Info_light" scriptevents="1"/>
</framemodel>
<frame id="frame-global" z-index="100">
<frame id="frame-global" z-index="50">
<frame id="frame-displaybutton" pos="-160 -60" z-index="-10">
<quad id="quad-displaybutton" class="button" pos="0 0" size="5 5" z-index="-1" bgcolor="000" opacity="0.5" scriptevents="1"/>
<quad pos="0 0" size="5 5" style="UICommon64_1" substyle="Debug_light"/>
@ -367,11 +355,7 @@ Text GetManialink() {
</frame>
</frame>
</frame>
<frame id="frame-rightpanel" pos="26 0">
<frame id="frame-rightpanel-logs" hidden=1>
<frame>
<quad id="quad-clearlogs" class="button" pos="0 0" size="15 4" z-index="-1" bgcolor="666" opacity="0.5" scriptevents="1"/>
@ -419,8 +403,6 @@ Text GetManialink() {
<label class="rightpanel-text-button" size="5 3" pos="3 -2" text="+50"/>
</frame>
</frame>
<frame id="frame-rightpanel-playerscontrol" hidden=1>
<frame>
<label class="text" size="8 3" pos="0 -1" text="Speed:"/>
@ -449,8 +431,6 @@ Text GetManialink() {
</frame>
</frame>
</frame>
<frame id="frame-rightpanel-customevent" hidden=1>
<frame>
<label class="text" size="30 3" pos="0 -1" text="Custom Event Name:"/>
@ -466,8 +446,6 @@ Text GetManialink() {
<label class="rightpanel-text-button" size="23 3" pos="12.5 -2" text="Send Custom Event"/>
</frame>
</frame>
<frame id="frame-rightpanel-varinsp" hidden=1>
<frame pos="0 0">
<quad id="quad-varinsp-forvars-dumpthis" class="button" pos="0 0" size="47 4" z-index="-1" bgcolor="666" opacity="0.5" scriptevents="1"/>
@ -528,15 +506,16 @@ Text GetManialink() {
</frame>
</frame>
</frame>
<!--<frameinstance pos="20 -10" modelid="framemodel-tooltip" tooltip="OMG This is a very very long tooltip, so important"/>-->
</frame>
</frame>
</frame>
<script><!--
#Include "TextLib" as TL
#Include "MathLib" as ML
// #RequireContext CSmMlScriptIngame
<script><!--
#Include "TextLib" as TL
#Include "MathLib" as ML
// #RequireContext CSmMlScriptIngame
Real ComputeBackgroundSize(CMlLabel _Label, Text _Value, Real _MaxLineWidth) {
Real ComputeBackgroundSize(CMlLabel _Label, Text _Value, Real _MaxLineWidth) {
declare Real SpaceSize = _Label.ComputeWidth(" ");
declare Real MaxLineSize = 0.;
@ -552,9 +531,9 @@ Real ComputeBackgroundSize(CMlLabel _Label, Text _Value, Real _MaxLineWidth) {
if (CurrentLineSize > MaxLineSize) MaxLineSize = CurrentLineSize;
}
return MaxLineSize;
}
}
Boolean MaximizeMinimizeWindow(CMlQuad _MaximizeButton, CMlFrame _MainUI, Vec2 _MinimizedPos, CMlQuad _Background, Vec2 _MinimizedSize) {
Boolean MaximizeMinimizeWindow(CMlQuad _MaximizeButton, CMlFrame _MainUI, Vec2 _MinimizedPos, CMlQuad _Background, Vec2 _MinimizedSize) {
_MaximizeButton.StyleSelected = !_MaximizeButton.StyleSelected;
AnimMgr.Flush(_MainUI);
@ -568,9 +547,9 @@ Boolean MaximizeMinimizeWindow(CMlQuad _MaximizeButton, CMlFrame _MainUI, Vec2 _
AnimMgr.Add(_Background, "<quad size=\"" ^ _MinimizedSize.X ^ " " ^ _MinimizedSize.Y ^ "\" />", Now, 250, CAnimManager::EAnimManagerEasing::CubicOut);
}
return _MaximizeButton.StyleSelected;
}
}
Void SwitchToTab(Text _CurrentTab, Text _NexTab) {
Void SwitchToTab(Text _CurrentTab, Text _NexTab) {
declare CMlQuad Quad;
declare CMlFrame Frame;
@ -585,9 +564,9 @@ Void SwitchToTab(Text _CurrentTab, Text _NexTab) {
if (Quad != Null) Quad.Opacity = .2;
Frame <=> (Page.GetFirstChild("frame-rightpanel-" ^ TL::Split("-", _NexTab)[2]) as CMlFrame);
if (Frame != Null) Frame.Visible = True;
}
}
main() {
main() {
declare CMlFrame Frame_MainUI = (Page.GetFirstChild("frame-mainui") as CMlFrame);
declare CMlFrame Frame_Tooltip = (Page.GetFirstChild("frame-tooltip") as CMlFrame);
@ -738,9 +717,13 @@ main() {
}
if (TL::StartsWith("quad-bots-delbots-", Event.Control.ControlId)) {
SendCustomEvent("DebugMode.Bots.DelBots", [Entry_Bots_Name.Value, TL::Split("-",Event.Control.ControlId)[3]]);
SwitchToTab(P_DebugMode_SelectedTab, "quad-leftpanel-logs");
P_DebugMode_SelectedTab = "quad-leftpanel-logs";
}
if (TL::StartsWith("quad-bots-addbots-", Event.Control.ControlId)) {
SendCustomEvent("DebugMode.Bots.AddBots", [Entry_Bots_Name.Value, Entry_Bots_TeamId.Value, TL::Split("-",Event.Control.ControlId)[3]]);
SwitchToTab(P_DebugMode_SelectedTab, "quad-leftpanel-logs");
P_DebugMode_SelectedTab = "quad-leftpanel-logs";
}
if (TL::StartsWith("quad-playerscontrol-player-", Event.Control.ControlId)) {
declare Text Target = TL::Split("-",Event.Control.ControlId)[3];
@ -834,12 +817,6 @@ main() {
}
}
}
case CMlScriptEvent::Type::KeyPress: {
if (Event.KeyCode == 38) { // F1
Frame_MainUI.Visible = !Frame_MainUI.Visible;
P_DebugMode_Window_Open = Frame_MainUI.Visible;
}
}
}
}
@ -908,8 +885,8 @@ main() {
TextEdit_Logs.Value = Net_DebugMode_Logs;
}
}
}
--></script>
</manialink>
""";
}
--></script>
</manialink>
""";
}