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

111 lines
3.9 KiB
C#
Raw Normal View History

2022-10-23 19:02:39 +08:00
using System;
using System.Drawing;
2022-10-19 19:07:46 +08:00
using System.IO;
2022-10-23 19:02:39 +08:00
using GTA;
2022-10-19 19:07:46 +08:00
using GTA.Native;
2022-10-23 19:02:39 +08:00
using GTA.UI;
using LemonUI.Menus;
using Newtonsoft.Json;
using Console = GTA.Console;
namespace RageCoop.Client
{
2022-10-23 19:02:39 +08:00
internal class AnimDic
2022-10-19 19:07:46 +08:00
{
public string[] Animations;
2022-10-23 19:02:39 +08:00
public string DictionaryName;
2022-10-19 19:07:46 +08:00
}
2022-10-23 19:02:39 +08:00
internal static class DevToolMenu
{
2022-10-23 19:02:39 +08:00
private const string AnimationsPath = @"RageCoop\Data\animDictsCompact.json";
2022-10-19 19:07:46 +08:00
public static NativeMenu Menu = new NativeMenu("RAGECOOP", "DevTool", "Internal testing tools")
{
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
2022-09-06 21:46:35 +08:00
private static readonly NativeCheckboxItem enableItem = new NativeCheckboxItem("Enable");
2022-10-19 19:07:46 +08:00
public static readonly NativeItem dumpItem = new NativeItem("Dump vehicle weapons");
public static readonly NativeItem dumpFixItem = new NativeItem("Dump weapon fixes");
public static readonly NativeItem dumpWHashItem = new NativeItem("Dump WeaponHash.cs");
public static readonly NativeItem getAnimItem = new NativeItem("Get current animation");
public static readonly NativeItem dumpVWHashItem = new NativeItem("Dump VehicleWeaponHash.cs");
static DevToolMenu()
{
Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
Menu.Title.Color = Color.FromArgb(255, 165, 0);
2022-09-06 21:46:35 +08:00
enableItem.Activated += enableItem_Activated;
enableItem.Checked = false;
2022-10-19 19:07:46 +08:00
dumpItem.Activated += DumpItem_Activated;
2022-10-23 19:02:39 +08:00
dumpVWHashItem.Activated += (s, e) => WeaponUtil.DumpVehicleWeaponHashes();
2022-10-19 19:07:46 +08:00
dumpWHashItem.Activated += (s, e) => WeaponUtil.DumpWeaponHashes();
dumpFixItem.Activated += (s, e) => WeaponUtil.DumpWeaponFix();
getAnimItem.Activated += (s, e) =>
{
2022-10-19 19:07:46 +08:00
if (File.Exists(AnimationsPath))
{
var anims = JsonConvert.DeserializeObject<AnimDic[]>(File.ReadAllText(AnimationsPath));
2022-10-23 19:02:39 +08:00
foreach (var anim in anims)
foreach (var a in anim.Animations)
if (Function.Call<bool>(Hash.IS_ENTITY_PLAYING_ANIM, Main.P, anim.DictionaryName, a, 3))
2022-10-19 19:07:46 +08:00
{
2022-10-23 19:02:39 +08:00
Console.Info(anim.DictionaryName + " : " + a);
Notification.Show(anim.DictionaryName + " : " + a);
2022-10-19 19:07:46 +08:00
}
}
else
{
2022-10-23 19:02:39 +08:00
Notification.Show($"~r~{AnimationsPath} not found");
2022-10-19 19:07:46 +08:00
}
};
Menu.Add(enableItem);
2022-10-19 19:07:46 +08:00
Menu.Add(dumpItem);
Menu.Add(dumpVWHashItem);
Menu.Add(dumpWHashItem);
Menu.Add(dumpFixItem);
Menu.Add(getAnimItem);
}
2022-10-19 19:07:46 +08:00
private static void DumpItem_Activated(object sender, EventArgs e)
{
2022-10-19 19:07:46 +08:00
dumpItem.Enabled = false;
Directory.CreateDirectory(@"RageCoop\Data\tmp");
var input = @"RageCoop\Data\tmp\vehicles.json";
var dumpLocation = @"RageCoop\Data\VehicleWeapons.json";
try
{
2022-10-19 19:07:46 +08:00
VehicleWeaponInfo.Dump(input, dumpLocation);
2022-10-23 19:02:39 +08:00
Console.Info("Weapon info dumped to " + dumpLocation);
}
2022-10-19 19:07:46 +08:00
catch (Exception ex)
{
2022-10-23 19:02:39 +08:00
Console.Error("~r~" + ex);
2022-10-19 19:07:46 +08:00
}
finally
{
dumpItem.Enabled = true;
}
}
private static void enableItem_Activated(object sender, EventArgs e)
{
if (enableItem.Checked)
{
2022-09-06 21:46:35 +08:00
DevTool.ToMark = Game.Player.Character.CurrentVehicle;
2022-10-19 19:07:46 +08:00
DevTool.Instance.Resume();
}
else
{
2022-10-09 22:07:52 +08:00
DevTool.Instance.Pause();
2022-09-06 21:46:35 +08:00
DevTool.ToMark = null;
}
}
}
2022-10-23 19:02:39 +08:00
}