Compare commits
10 Commits
bad8dd4f58
...
63dabc4806
Author | SHA1 | Date | |
---|---|---|---|
63dabc4806 | |||
c0ed46492b | |||
3e6f2e29ec | |||
a56c3e89ec | |||
74adae2a8c | |||
a2640c6bb8 | |||
d111eacbd7 | |||
b4b38e0592 | |||
10b8151df8 | |||
3ed7103bb8 |
@ -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/TrackMania/TM_TimeAttack_Online.Script.txt"
|
||||
#Extends "Modes/TM_TeamsCup.Script.txt"
|
||||
|
||||
// #RequireContext CSmMode
|
||||
|
||||
#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"
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
#Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils
|
||||
|
||||
#Setting S_ScriptEnvironment "development"
|
||||
|
||||
***Match_AfterLoadHud***
|
||||
***
|
||||
@ -31,6 +32,7 @@ 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);
|
||||
@ -75,10 +77,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: Add bot \"" ^ User.Name ^ "\"\n" ^ Net_DebugMode_Logs;
|
||||
} else {
|
||||
if (User == Null) {
|
||||
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 {
|
||||
@ -145,9 +147,10 @@ foreach (Event in UIManager.PendingEvents) {
|
||||
}
|
||||
}
|
||||
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 = 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;
|
||||
@ -157,66 +160,40 @@ foreach (Event in UIManager.PendingEvents) {
|
||||
}
|
||||
case "DebugMode.VarInsp.ForVars.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+++DebugMode_FindPlayer+++
|
||||
|
||||
if (Player != Null) {
|
||||
if (Event.CustomEventData[1] == "player") {
|
||||
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 ^ ":\n" ^ Dbg_DumpDeclareForVariables(UI, False) ^"\n" ^ Net_DebugMode_Logs;
|
||||
} else {
|
||||
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 ^ "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": {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+++DebugMode_FindPlayer+++
|
||||
|
||||
if (Player != Null) {
|
||||
if (Event.CustomEventData[1] == "player") {
|
||||
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 ^ ":\n" ^ UI ^"\n" ^ Net_DebugMode_Logs;
|
||||
} else {
|
||||
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 ^ "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: {
|
||||
@ -225,39 +202,75 @@ 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_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_PendingEvents+++
|
||||
}
|
||||
|
||||
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_XmlRpcPendingEvents+++
|
||||
}
|
||||
|
||||
declare RacePendingEvents = Race::GetPendingEvents();
|
||||
declare Events::K_RaceEvent[] RacePendingEvents = Race::GetPendingEvents();
|
||||
foreach (Event in RacePendingEvents) {
|
||||
+++DebugMode_LogFormat+++
|
||||
declare Text Type = "Unknown";
|
||||
switch (Event.Type) {
|
||||
+++DebugMode_RacePendingEvents+++
|
||||
}
|
||||
***
|
||||
|
||||
***DebugMode_PendingEvents***
|
||||
***
|
||||
+++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) {
|
||||
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***
|
||||
***
|
||||
+++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***
|
||||
@ -282,15 +295,14 @@ 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"/>
|
||||
@ -301,7 +313,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="50">
|
||||
<frame id="frame-global" z-index="100">
|
||||
<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"/>
|
||||
@ -355,7 +367,11 @@ 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"/>
|
||||
@ -403,6 +419,8 @@ 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:"/>
|
||||
@ -431,6 +449,8 @@ 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:"/>
|
||||
@ -446,6 +466,8 @@ 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"/>
|
||||
@ -506,16 +528,15 @@ 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.;
|
||||
@ -531,9 +552,9 @@ Text GetManialink() {
|
||||
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);
|
||||
@ -547,9 +568,9 @@ Text GetManialink() {
|
||||
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;
|
||||
|
||||
@ -564,9 +585,9 @@ Text GetManialink() {
|
||||
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);
|
||||
@ -717,13 +738,9 @@ Text GetManialink() {
|
||||
}
|
||||
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];
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -885,8 +908,8 @@ Text GetManialink() {
|
||||
TextEdit_Logs.Value = Net_DebugMode_Logs;
|
||||
}
|
||||
}
|
||||
}
|
||||
--></script>
|
||||
</manialink>
|
||||
""";
|
||||
}
|
||||
--></script>
|
||||
</manialink>
|
||||
""";
|
||||
}
|
Loading…
Reference in New Issue
Block a user