124 lines
5.1 KiB
C#
Raw Normal View History

2022-07-20 17:50:01 +08:00
using GTA;
using LemonUI.Menus;
using System;
2022-07-20 17:50:01 +08:00
using System.Drawing;
using System.Windows.Forms;
namespace RageCoop.Client.Menus
{
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
internal static class SettingsMenu
{
public static NativeMenu Menu = 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 static readonly NativeCheckboxItem _disableTrafficItem = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.Settings.DisableTraffic);
private static readonly NativeCheckboxItem _flipMenuItem = new NativeCheckboxItem("Flip menu", Main.Settings.FlipMenu);
private static readonly NativeCheckboxItem _disablePauseAlt = new NativeCheckboxItem("Disable Alternate Pause", "Don't freeze game time when Esc pressed", Main.Settings.DisableTraffic);
private static readonly NativeCheckboxItem _showNetworkInfoItem = new NativeCheckboxItem("Show Network Info", Networking.ShowNetworkInfo);
2022-07-20 17:50:01 +08:00
private static NativeItem _menuKey = new NativeItem("Menu Key", "The key to open menu", Main.Settings.MenuKey.ToString());
private static NativeItem _passengerKey = new NativeItem("Passenger Key", "The key to enter a vehicle as passenger", Main.Settings.PassengerKey.ToString());
2022-07-20 17:50:01 +08:00
private static NativeItem _vehicleSoftLimit = new NativeItem("Vehicle limit (soft)", "The game won't spawn more NPC traffic if the limit is exceeded. \n-1 for unlimited (not recommended).", Main.Settings.WorldVehicleSoftLimit.ToString());
2021-12-03 20:30:00 +01:00
/// <summary>
/// Don't use it!
/// </summary>
static SettingsMenu()
{
Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
Menu.Title.Color = Color.FromArgb(255, 165, 0);
2022-04-06 02:18:24 +02:00
_disableTrafficItem.CheckboxChanged += DisableTrafficCheckboxChanged;
_disablePauseAlt.CheckboxChanged+=_disablePauseAlt_CheckboxChanged;
_flipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
_showNetworkInfoItem.CheckboxChanged += ShowNetworkInfoCheckboxChanged;
_menuKey.Activated+=ChaneMenuKey;
_passengerKey.Activated+=ChangePassengerKey;
_vehicleSoftLimit.Activated+=vehicleSoftLimit_Activated;
Menu.Add(_disableTrafficItem);
Menu.Add(_disablePauseAlt);
Menu.Add(_flipMenuItem);
Menu.Add(_showNetworkInfoItem);
Menu.Add(_menuKey);
Menu.Add(_passengerKey);
Menu.Add(_vehicleSoftLimit);
}
private static void _disablePauseAlt_CheckboxChanged(object sender, EventArgs e)
{
Main.Settings.DisableAlternatePause=_disablePauseAlt.Checked;
Util.SaveSettings();
}
private static void vehicleSoftLimit_Activated(object sender, EventArgs e)
{
try
{
Main.Settings.WorldVehicleSoftLimit =int.Parse(
Game.GetUserInput(WindowTitle.EnterMessage20,
Main.Settings.WorldVehicleSoftLimit.ToString(), 20));
_menuKey.AltTitle=Main.Settings.WorldVehicleSoftLimit.ToString();
Util.SaveSettings();
}
catch { }
}
private static void ChaneMenuKey(object sender, EventArgs e)
{
try
{
Main.Settings.MenuKey =(Keys)Enum.Parse(
typeof(Keys),
Game.GetUserInput(WindowTitle.EnterMessage20,
Main.Settings.MenuKey.ToString(), 20));
_menuKey.AltTitle=Main.Settings.MenuKey.ToString();
2022-05-23 15:01:55 +08:00
Util.SaveSettings();
}
catch { }
}
private static void ChangePassengerKey(object sender, EventArgs e)
{
try
{
Main.Settings.PassengerKey =(Keys)Enum.Parse(
typeof(Keys),
Game.GetUserInput(WindowTitle.EnterMessage20,
Main.Settings.PassengerKey.ToString(), 20));
_passengerKey.AltTitle=Main.Settings.PassengerKey.ToString();
2022-05-23 15:01:55 +08:00
Util.SaveSettings();
}
catch { }
}
public static void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
2021-08-22 13:59:15 +02:00
{
Main.Settings.DisableTraffic = _disableTrafficItem.Checked;
2022-07-20 17:50:01 +08:00
Util.SaveSettings();
2021-08-22 13:59:15 +02:00
}
public static void FlipMenuCheckboxChanged(object a, System.EventArgs b)
{
CoopMenu.Menu.Alignment = _flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
Menu.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();
}
public static void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
2021-08-18 11:47:59 +02:00
{
Networking.ShowNetworkInfo = _showNetworkInfoItem.Checked;
2021-08-18 11:47:59 +02:00
}
}
}