Files
RAGECOOP-V/Client/Scripts/Menus/Sub/DebugMenu.cs

125 lines
4.3 KiB
C#
Raw Normal View History

2022-10-23 19:02:39 +08:00
using System;
2022-09-06 21:46:35 +08:00
using System.Drawing;
2022-10-23 19:02:39 +08:00
using GTA;
using GTA.UI;
using LemonUI.Menus;
using RageCoop.Client.GUI;
2022-10-23 19:02:39 +08:00
using RageCoop.Client.Loader;
2022-05-22 15:55:26 +08:00
namespace RageCoop.Client
{
internal static class DebugMenu
{
2022-07-20 17:50:01 +08:00
public static NativeMenu Menu = new NativeMenu("RAGECOOP", "Debug", "Debug settings")
{
UseMouse = false,
2022-10-23 19:02:39 +08:00
Alignment = Main.Settings.FlipMenu ? Alignment.Right : Alignment.Left
};
2022-10-23 19:02:39 +08:00
public static NativeMenu DiagnosticMenu = new NativeMenu("RAGECOOP", "Diagnostic", "Performence and Diagnostic")
{
2022-05-22 15:55:26 +08:00
UseMouse = false,
2022-10-23 19:02:39 +08:00
Alignment = Main.Settings.FlipMenu ? Alignment.Right : Alignment.Left
2022-05-22 15:55:26 +08:00
};
2022-10-23 19:02:39 +08:00
2022-10-15 17:06:19 +08:00
public static NativeItem ReloadItem = new NativeItem("Reload", "Reload RAGECOOP and associated scripts");
2022-10-23 19:02:39 +08:00
public static NativeItem SimulatedLatencyItem =
new NativeItem("Simulated network latency", "Simulated network latency in ms (one way)", "0");
public static NativeCheckboxItem ShowOwnerItem = new NativeCheckboxItem("Show entity owner",
"Show the owner name of the entity you're aiming at", false);
private static readonly NativeCheckboxItem ShowNetworkInfoItem =
new NativeCheckboxItem("Show Network Info", Networking.ShowNetworkInfo);
2022-08-04 17:47:57 +08:00
private static readonly NativeCheckboxItem DxHookTest =
new NativeCheckboxItem("Enable D3D11 hook", false);
private static readonly NativeCheckboxItem CefTest =
new NativeCheckboxItem("Test CEF overlay", false);
private static CefClient _testCef;
2022-05-22 15:55:26 +08:00
static DebugMenu()
{
Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
Menu.Title.Color = Color.FromArgb(255, 165, 0);
2022-05-22 15:55:26 +08:00
2022-09-06 21:46:35 +08:00
DiagnosticMenu.Opening += (sender, e) =>
{
DiagnosticMenu.Clear();
2022-05-23 19:19:56 +08:00
DiagnosticMenu.Add(new NativeItem("EntityPool", EntityPool.DumpDebug()));
foreach (var pair in Debug.TimeStamps)
2022-10-23 19:02:39 +08:00
DiagnosticMenu.Add(
new NativeItem(pair.Key.ToString(), pair.Value.ToString(), pair.Value.ToString()));
};
2022-09-06 21:46:35 +08:00
SimulatedLatencyItem.Activated += (s, e) =>
2022-08-04 17:14:07 +08:00
{
try
{
2022-10-23 19:02:39 +08:00
SimulatedLatencyItem.AltTitle =
((Networking.SimulatedLatency =
int.Parse(Game.GetUserInput(SimulatedLatencyItem.AltTitle)) * 0.002f) * 500).ToString();
}
catch (Exception ex)
{
Main.Logger.Error(ex);
2022-08-04 17:14:07 +08:00
}
};
2022-10-23 19:02:39 +08:00
ShowNetworkInfoItem.CheckboxChanged += (s, e) =>
{
Networking.ShowNetworkInfo = ShowNetworkInfoItem.Checked;
};
ShowOwnerItem.CheckboxChanged += (s, e) =>
{
Main.Settings.ShowEntityOwnerName = ShowOwnerItem.Checked;
Util.SaveSettings();
};
DxHookTest.CheckboxChanged += Hook;
CefTest.CheckboxChanged += CefTestChange;
;
ReloadItem.Activated += ReloadDomain;
2022-08-04 17:14:07 +08:00
Menu.Add(SimulatedLatencyItem);
2022-09-06 21:46:35 +08:00
Menu.Add(ShowNetworkInfoItem);
2022-08-23 17:43:24 +08:00
Menu.Add(ShowOwnerItem);
Menu.Add(ReloadItem);
2022-08-04 17:14:07 +08:00
Menu.AddSubMenu(DiagnosticMenu);
Menu.Add(DxHookTest);
Menu.Add(CefTest);
}
private static void CefTestChange(object sender, EventArgs e)
{
if (CefTest.Checked)
{
_testCef = CefManager.CreateClient(new Size(640, 480));
_testCef.Scale = 0.8f;
_testCef.Opacity = 128;
Script.Wait(2000);
_testCef.Controller.LoadUrl("https://ragecoop.online/");
CefManager.ActiveClient = _testCef;
}
else
{
CefManager.DestroyClient(_testCef);
}
2022-11-16 17:40:07 +08:00
DxHookTest.Checked = HookManager.Hooked;
}
private static void Hook(object sender, EventArgs e)
{
if (DxHookTest.Checked)
HookManager.Initialize();
else
HookManager.CleanUp();
2022-05-22 15:55:26 +08:00
}
2022-05-26 17:11:37 +08:00
private static void ReloadDomain(object sender, EventArgs e)
2022-10-09 22:07:52 +08:00
{
2022-10-23 19:02:39 +08:00
LoaderContext.RequestUnload();
2022-10-09 22:07:52 +08:00
}
2022-05-22 15:55:26 +08:00
}
2022-10-23 19:02:39 +08:00
}