RAGECOOP-V/Client/Menus/Sub/Settings.cs

108 lines
3.8 KiB
C#
Raw Normal View History

using LemonUI.Menus;
namespace CoopClient.Menus.Sub
{
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
public class Settings
{
2021-12-03 20:30:00 +01:00
internal NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
{
UseMouse = false,
Alignment = Main.MainSettings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
};
2021-08-18 11:47:59 +02:00
2021-12-12 20:05:55 +01:00
private readonly NativeCheckboxItem DisableTraffic = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.DisableTraffic);
2021-12-13 18:16:31 +01:00
private readonly NativeCheckboxItem ShareNPCsItem = new NativeCheckboxItem("Share NPCs", "~y~WARNING:~s~ High network traffic!", Main.ShareNpcsWithPlayers) { Enabled = false };
private readonly NativeCheckboxItem FlipMenuItem = new NativeCheckboxItem("Flip menu", Main.MainSettings.FlipMenu);
2021-08-22 13:59:15 +02:00
#if DEBUG
private readonly NativeCheckboxItem UseDebugItem = new NativeCheckboxItem("Debug", Main.UseDebug);
2021-08-18 11:47:59 +02:00
private readonly NativeCheckboxItem ShowNetworkInfo = new NativeCheckboxItem("Show Network Info", Main.MainNetworking.ShowNetworkInfo);
2021-08-22 13:59:15 +02:00
#endif
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
public Settings()
{
2021-08-22 13:59:15 +02:00
DisableTraffic.CheckboxChanged += DisableTrafficCheckboxChanged;
ShareNPCsItem.CheckboxChanged += (item, check) => { Main.ShareNpcsWithPlayers = ShareNPCsItem.Checked; };
FlipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
#if DEBUG
UseDebugItem.CheckboxChanged += UseDebugCheckboxChanged;
2021-08-18 11:47:59 +02:00
ShowNetworkInfo.CheckboxChanged += ShowNetworkInfoCheckboxChanged;
#endif
2021-08-22 13:59:15 +02:00
MainMenu.Add(DisableTraffic);
MainMenu.Add(ShareNPCsItem);
MainMenu.Add(FlipMenuItem);
#if DEBUG
MainMenu.Add(UseDebugItem);
2021-08-18 11:47:59 +02:00
MainMenu.Add(ShowNetworkInfo);
#endif
}
2021-12-03 20:30:00 +01:00
internal void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
2021-08-22 13:59:15 +02:00
{
Main.DisableTraffic = DisableTraffic.Checked;
if (DisableTraffic.Checked)
{
if (ShareNPCsItem.Checked)
2021-08-22 13:59:15 +02:00
{
ShareNPCsItem.Checked = false;
2021-08-22 13:59:15 +02:00
}
ShareNPCsItem.Enabled = false;
2021-08-22 13:59:15 +02:00
}
else if (Main.NpcsAllowed && !ShareNPCsItem.Enabled)
2021-08-22 13:59:15 +02:00
{
ShareNPCsItem.Enabled = true;
2021-08-22 13:59:15 +02:00
}
}
2021-12-03 20:30:00 +01:00
internal void FlipMenuCheckboxChanged(object a, System.EventArgs b)
{
#if !NON_INTERACTIVE
Main.MainMenu.MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
#endif
MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
Main.MainSettings.FlipMenu = FlipMenuItem.Checked;
Util.SaveSettings();
}
2021-08-22 13:59:15 +02:00
#if DEBUG
2021-12-03 20:30:00 +01:00
internal void UseDebugCheckboxChanged(object a, System.EventArgs b)
{
Main.UseDebug = UseDebugItem.Checked;
if (!UseDebugItem.Checked && Main.DebugSyncPed != null)
{
if (Main.DebugSyncPed.Character.Exists())
{
Main.DebugSyncPed.Character.Kill();
Main.DebugSyncPed.Character.Delete();
}
Main.DebugSyncPed = null;
2021-08-15 11:33:52 +02:00
Main.LastFullDebugSync = 0;
2021-08-16 14:03:05 +02:00
Main.Players.Remove(0);
}
}
2021-08-18 11:47:59 +02:00
2021-12-03 20:30:00 +01:00
internal void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
2021-08-18 11:47:59 +02:00
{
Main.MainNetworking.ShowNetworkInfo = ShowNetworkInfo.Checked;
if (!Main.MainNetworking.ShowNetworkInfo)
{
Main.MainNetworking.BytesReceived = 0;
Main.MainNetworking.BytesSend = 0;
}
}
2021-08-22 13:59:15 +02:00
#endif
}
}