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,53 +157,6 @@ foreach (Event in UIManager.PendingEvents) {
}
case "DebugMode.VarInsp.ForVars.Dump.Player": {
declare CSmPlayer Player;
+++DebugMode_FindPlayer+++
if (Player == Null) {
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;
} 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 {
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": {
declare CSmPlayer Player;
+++DebugMode_FindPlayer+++
if (Player == Null) {
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;
} 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 {
Net_DebugMode_Logs = Prefix ^ "UI ForVars dump for " ^ Player.User.Name ^ ":\n" ^ UI ^"\n" ^ Net_DebugMode_Logs;
}
}
}
default: {
Net_DebugMode_Logs = Prefix ^ "Struct Event received: " ^ Event.CustomEventType ^"\n" ^ Net_DebugMode_Logs;
}
}
}
+++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) {
@ -219,26 +169,63 @@ if (TL::Length(Event.CustomEventData[0]) == 36) {
}
}
}
***
***DebugMode_LogEvents***
***
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 ^ ":\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;
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) {
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 ^ ":\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;
}
}
}
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) {
@ -246,20 +233,19 @@ if (Event.Type == CSmModeEvent::EType::OnPlayerAdded) {
Layers::Attach(C_DebugMode_MainUI, Event.Player);
}
}
***
}
***DebugMode_XmlRpcPendingEvents***
***
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 {
Net_DebugMode_Logs = Prefix ^ "XmlRpc PendingEvent: " ^ Event.Param1 ^"\n" ^ Net_DebugMode_Logs;
}
***
}
***DebugMode_RacePendingEvents***
***
declare RacePendingEvents = Race::GetPendingEvents();
foreach (Event in RacePendingEvents) {
+++DebugMode_LogFormat+++
declare Text Type = "Unknown";
switch (Event.Type) {
@ -271,6 +257,7 @@ switch (Event.Type) {
case 6: Type = "Eliminated";
}
Net_DebugMode_Logs = Prefix ^ "Race Pending Event: " ^ Type ^"\n" ^ Net_DebugMode_Logs;
}
***
***DebugMode_LogFormat***
@ -295,6 +282,7 @@ 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;
***
@ -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,6 +506,7 @@ 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>
@ -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;
}
}
}
}