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

98 lines
3.4 KiB
C#
Raw Normal View History

2022-05-22 15:55:26 +08:00
#undef DEBUG
using System.Drawing;
2022-04-06 02:18:24 +02:00
using LemonUI.Menus;
2022-05-22 15:55:26 +08:00
namespace RageCoop.Client.Menus.Sub
{
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
public class Settings
{
2022-05-22 15:55:26 +08:00
public NativeMenu MainMenu = new NativeMenu("RAGECOOP", "Settings", "Go to the settings")
{
UseMouse = false,
2022-05-22 15:55:26 +08:00
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
};
2021-08-18 11:47:59 +02:00
private readonly NativeCheckboxItem _disableTrafficItem = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.DisableTraffic);
2022-05-22 15:55:26 +08:00
private readonly NativeCheckboxItem _flipMenuItem = new NativeCheckboxItem("Flip menu", Main.Settings.FlipMenu);
2021-08-22 13:59:15 +02:00
#if DEBUG
private readonly NativeCheckboxItem _useDebugItem = new NativeCheckboxItem("Debug", Main.UseDebug);
private readonly NativeCheckboxItem _showNetworkInfoItem = 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()
{
2022-04-06 02:18:24 +02:00
MainMenu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
MainMenu.Title.Color = Color.FromArgb(255, 165, 0);
_disableTrafficItem.CheckboxChanged += DisableTrafficCheckboxChanged;
_flipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
#if DEBUG
_useDebugItem.CheckboxChanged += UseDebugCheckboxChanged;
_showNetworkInfoItem.CheckboxChanged += ShowNetworkInfoCheckboxChanged;
#endif
MainMenu.Add(_disableTrafficItem);
MainMenu.Add(_flipMenuItem);
#if DEBUG
MainMenu.Add(_useDebugItem);
MainMenu.Add(_showNetworkInfoItem);
#endif
}
2022-05-22 15:55:26 +08:00
public void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
2021-08-22 13:59:15 +02:00
{
Main.DisableTraffic = _disableTrafficItem.Checked;
2021-08-22 13:59:15 +02:00
}
2022-05-22 15:55:26 +08:00
public 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.MainMenu.ServerList.MainMenu.Alignment = _flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
2022-05-22 15:55:26 +08:00
Main.Settings.FlipMenu = _flipMenuItem.Checked;
Util.SaveSettings();
}
2021-08-22 13:59:15 +02:00
#if DEBUG
2022-05-22 15:55:26 +08:00
public 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
2022-05-22 15:55:26 +08:00
public void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
2021-08-18 11:47:59 +02:00
{
Main.MainNetworking.ShowNetworkInfo = _showNetworkInfoItem.Checked;
2021-08-18 11:47:59 +02:00
if (!Main.MainNetworking.ShowNetworkInfo)
{
Main.MainNetworking.BytesReceived = 0;
Main.MainNetworking.BytesSend = 0;
}
}
2021-08-22 13:59:15 +02:00
#endif
}
}