Compare commits

..

10 Commits

View File

@ -3,13 +3,13 @@
* This mode is used to debug your modes during development. * 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: * To use it, you just have to change the line below to put the path of your mode:
*/ */
#Extends "Modes/TrackMania/TM_TimeAttack_Online.Script.txt" #Extends "Modes/TM_TeamsCup.Script.txt"
// #RequireContext CSmMode // #RequireContext CSmMode
#Setting S_DebugLib_RestrictUIto "" as "Restrict UI Admin to comma separated logins (all if empty)" #Setting S_DebugLib_RestrictUIto "" as "Restrict UI Admin to comma separated logins (all if empty)"
#Const C_DebugMode_Version "2023-02-09" #Const C_DebugMode_Version "2023-08-28"
#Const C_DebugMode_MainUI "DebugMode_MainUI" #Const C_DebugMode_MainUI "DebugMode_MainUI"
@ -19,6 +19,7 @@
#Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils #Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils
#Setting S_ScriptEnvironment "development"
***Match_AfterLoadHud*** ***Match_AfterLoadHud***
*** ***
@ -31,6 +32,7 @@ Layers::SetType(C_DebugMode_MainUI, CUILayer::EUILayerType::Normal);
if (S_DebugLib_RestrictUIto == "") { if (S_DebugLib_RestrictUIto == "") {
Layers::Attach(C_DebugMode_MainUI); Layers::Attach(C_DebugMode_MainUI);
} else { } else {
Layers::Detach(C_DebugMode_MainUI);
foreach (Login in TL::Split(",", S_DebugLib_RestrictUIto)) { foreach (Login in TL::Split(",", S_DebugLib_RestrictUIto)) {
declare CSmPlayer Player = GetPlayer(Login); declare CSmPlayer Player = GetPlayer(Login);
if (Player != Null) Layers::Attach(C_DebugMode_MainUI, Player); if (Player != Null) Layers::Attach(C_DebugMode_MainUI, Player);
@ -75,10 +77,10 @@ foreach (Event in UIManager.PendingEvents) {
if (TeamId != -1 && Teams.existskey(TeamId)) { if (TeamId != -1 && Teams.existskey(TeamId)) {
for (I, 1, NumberOfBots) { for (I, 1, NumberOfBots) {
declare CUser User = Users_CreateFake(Name, TeamId); declare CUser User = Users_CreateFake(Name, TeamId);
if (User != Null) { 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; Net_DebugMode_Logs = Prefix ^ "Bots: unknown error while adding bot \"" ^ Name ^ "\"\n" ^ Net_DebugMode_Logs;
} else {
Net_DebugMode_Logs = Prefix ^ "Bots: Add bot \"" ^ User.Name ^ "\"\n" ^ Net_DebugMode_Logs;
} }
} }
} else { } else {
@ -145,9 +147,10 @@ foreach (Event in UIManager.PendingEvents) {
} }
} }
case "DebugMode.VarInsp.Dump.Teams0": { case "DebugMode.VarInsp.Dump.Teams0": {
declare Text tmp = Net_DebugMode_Logs; // prevent to dump Net_DebugMode_Logs in the dump
declare Text Tmp = Net_DebugMode_Logs;
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": { case "DebugMode.VarInsp.Dump.UIAll": {
Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "UIAll dump:\n" ^ Dbg_DumpDeclareForVariables(UIManager.UIAll, False) ^"\n" ^ Net_DebugMode_Logs;
@ -157,66 +160,40 @@ foreach (Event in UIManager.PendingEvents) {
} }
case "DebugMode.VarInsp.ForVars.Dump.Player": { case "DebugMode.VarInsp.ForVars.Dump.Player": {
declare CSmPlayer Player; declare CSmPlayer Player;
if (TL::Length(Event.CustomEventData[0]) == 36) { +++DebugMode_FindPlayer+++
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) { if (Player == Null) {
if (Event.CustomEventData[1] == "player") { Net_DebugMode_Logs = Prefix ^ "ForVars dump: player not found\n" ^ Net_DebugMode_Logs;
} else 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; 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") { } 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; Net_DebugMode_Logs = Prefix ^ "Score ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(Player.Score, False) ^"\n" ^ Net_DebugMode_Logs;
} else { } else {
declare CUIConfig UI = UIManager.GetUI(Player); declare CUIConfig UI = UIManager.GetUI(Player);
if (UI != Null) { 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; Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
}
}
} else { } else {
Net_DebugMode_Logs = Prefix ^ "ForVars dump: player not found\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ Dbg_DumpDeclareForVariables(UI, False) ^"\n" ^ Net_DebugMode_Logs;
}
} }
} }
case "DebugMode.VarInsp.Struct.Dump.Player": { case "DebugMode.VarInsp.Struct.Dump.Player": {
declare CSmPlayer Player; declare CSmPlayer Player;
if (TL::Length(Event.CustomEventData[0]) == 36) { +++DebugMode_FindPlayer+++
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) { if (Player == Null) {
if (Event.CustomEventData[1] == "player") { Net_DebugMode_Logs = Prefix ^ "Struct dump: player not found\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "player") {
Net_DebugMode_Logs = Prefix ^ "Player Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player ^"\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "Player Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player ^"\n" ^ Net_DebugMode_Logs;
} else if (Event.CustomEventData[1] == "score") { } else if (Event.CustomEventData[1] == "score") {
Net_DebugMode_Logs = Prefix ^ "Score Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player.Score ^"\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "Score Struct dump for " ^ Player.User.Name ^ ":\n" ^ Player.Score ^"\n" ^ Net_DebugMode_Logs;
} else { } else {
declare CUIConfig UI = UIManager.GetUI(Player); declare CUIConfig UI = UIManager.GetUI(Player);
if (UI != Null) { 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; Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ": no UI found (it's a bot?)\n" ^ Net_DebugMode_Logs;
}
}
} else { } else {
Net_DebugMode_Logs = Prefix ^ "Struct dump: player not found\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ UI ^"\n" ^ Net_DebugMode_Logs;
}
} }
} }
default: { default: {
@ -225,7 +202,43 @@ 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) { 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+++ +++DebugMode_LogFormat+++
Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs; Net_DebugMode_Logs = Prefix ^ "CSmMode PendingEvent: " ^ Event.Type ^"\n" ^ Net_DebugMode_Logs;
if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) { if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) {
@ -233,19 +246,20 @@ foreach (Event in PendingEvents) {
Layers::Attach(C_DebugMode_MainUI, Event.Player); Layers::Attach(C_DebugMode_MainUI, Event.Player);
} }
} }
} ***
foreach (Event in XmlRpc.PendingEvents) { ***DebugMode_XmlRpcPendingEvents***
***
+++DebugMode_LogFormat+++ +++DebugMode_LogFormat+++
if (Event.Type == CXmlRpcEvent::EType::CallbackArray) { if (Event.Type == CXmlRpcEvent::EType::CallbackArray) {
Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.ParamArray1 ^"\n" ^ Net_DebugMode_Logs; 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; Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.Param1 ^"\n" ^ Net_DebugMode_Logs;
} }
} ***
declare RacePendingEvents = Race::GetPendingEvents(); ***DebugMode_RacePendingEvents***
foreach (Event in RacePendingEvents) { ***
+++DebugMode_LogFormat+++ +++DebugMode_LogFormat+++
declare Text Type = "Unknown"; declare Text Type = "Unknown";
switch (Event.Type) { switch (Event.Type) {
@ -257,7 +271,6 @@ foreach (Event in RacePendingEvents) {
case 6: Type = "Eliminated"; 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*** ***DebugMode_LogFormat***
@ -282,7 +295,6 @@ if (TL::Length(Net_DebugMode_Logs) > 1000000) {
Net_DebugMode_Logs = TL::SubString(Net_DebugMode_Logs, 0, 1000000); Net_DebugMode_Logs = TL::SubString(Net_DebugMode_Logs, 0, 1000000);
} }
declare netwrite Integer Net_DebugMode_Logs_Serial for Teams[0]; declare netwrite Integer Net_DebugMode_Logs_Serial for Teams[0];
Net_DebugMode_Logs_Serial += 1; Net_DebugMode_Logs_Serial += 1;
*** ***
@ -301,7 +313,7 @@ Text GetManialink() {
<framemodel id="framemodel-tooltip"> <framemodel id="framemodel-tooltip">
<quad size="4 4" bgcolor="FFF" style="UICommon64_1" substyle="Info_light" scriptevents="1"/> <quad size="4 4" bgcolor="FFF" style="UICommon64_1" substyle="Info_light" scriptevents="1"/>
</framemodel> </framemodel>
<frame id="frame-global" z-index="50"> <frame id="frame-global" z-index="100">
<frame id="frame-displaybutton" pos="-160 -60" z-index="-10"> <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 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"/> <quad pos="0 0" size="5 5" style="UICommon64_1" substyle="Debug_light"/>
@ -355,7 +367,11 @@ Text GetManialink() {
</frame> </frame>
</frame> </frame>
</frame> </frame>
<frame id="frame-rightpanel" pos="26 0"> <frame id="frame-rightpanel" pos="26 0">
<frame id="frame-rightpanel-logs" hidden=1> <frame id="frame-rightpanel-logs" hidden=1>
<frame> <frame>
<quad id="quad-clearlogs" class="button" pos="0 0" size="15 4" z-index="-1" bgcolor="666" opacity="0.5" scriptevents="1"/> <quad id="quad-clearlogs" class="button" pos="0 0" size="15 4" z-index="-1" bgcolor="666" opacity="0.5" scriptevents="1"/>
@ -403,6 +419,8 @@ Text GetManialink() {
<label class="rightpanel-text-button" size="5 3" pos="3 -2" text="+50"/> <label class="rightpanel-text-button" size="5 3" pos="3 -2" text="+50"/>
</frame> </frame>
</frame> </frame>
<frame id="frame-rightpanel-playerscontrol" hidden=1> <frame id="frame-rightpanel-playerscontrol" hidden=1>
<frame> <frame>
<label class="text" size="8 3" pos="0 -1" text="Speed:"/> <label class="text" size="8 3" pos="0 -1" text="Speed:"/>
@ -431,6 +449,8 @@ Text GetManialink() {
</frame> </frame>
</frame> </frame>
</frame> </frame>
<frame id="frame-rightpanel-customevent" hidden=1> <frame id="frame-rightpanel-customevent" hidden=1>
<frame> <frame>
<label class="text" size="30 3" pos="0 -1" text="Custom Event Name:"/> <label class="text" size="30 3" pos="0 -1" text="Custom Event Name:"/>
@ -446,6 +466,8 @@ Text GetManialink() {
<label class="rightpanel-text-button" size="23 3" pos="12.5 -2" text="Send Custom Event"/> <label class="rightpanel-text-button" size="23 3" pos="12.5 -2" text="Send Custom Event"/>
</frame> </frame>
</frame> </frame>
<frame id="frame-rightpanel-varinsp" hidden=1> <frame id="frame-rightpanel-varinsp" hidden=1>
<frame pos="0 0"> <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"/> <quad id="quad-varinsp-forvars-dumpthis" class="button" pos="0 0" size="47 4" z-index="-1" bgcolor="666" opacity="0.5" scriptevents="1"/>
@ -506,7 +528,6 @@ Text GetManialink() {
</frame> </frame>
</frame> </frame>
</frame> </frame>
<!--<frameinstance pos="20 -10" modelid="framemodel-tooltip" tooltip="OMG This is a very very long tooltip, so important"/>-->
</frame> </frame>
</frame> </frame>
</frame> </frame>
@ -717,13 +738,9 @@ Text GetManialink() {
} }
if (TL::StartsWith("quad-bots-delbots-", Event.Control.ControlId)) { if (TL::StartsWith("quad-bots-delbots-", Event.Control.ControlId)) {
SendCustomEvent("DebugMode.Bots.DelBots", [Entry_Bots_Name.Value, TL::Split("-",Event.Control.ControlId)[3]]); 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)) { 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]]); 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)) { if (TL::StartsWith("quad-playerscontrol-player-", Event.Control.ControlId)) {
declare Text Target = TL::Split("-",Event.Control.ControlId)[3]; declare Text Target = TL::Split("-",Event.Control.ControlId)[3];
@ -817,6 +834,12 @@ Text GetManialink() {
} }
} }
} }
case CMlScriptEvent::Type::KeyPress: {
if (Event.KeyCode == 38) { // F1
Frame_MainUI.Visible = !Frame_MainUI.Visible;
P_DebugMode_Window_Open = Frame_MainUI.Visible;
}
}
} }
} }