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

106 lines
4.1 KiB
C#
Raw Normal View History

using LemonUI.Menus;
namespace CoopClient.Menus.Sub
{
public class Settings
{
public 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-08-18 18:20:55 +02:00
private readonly NativeCheckboxItem DeactivateTraffic = new NativeCheckboxItem("Deactivate Traffic", Main.DeactivateTraffic);
private readonly NativeCheckboxItem ShareNpcsItem = new NativeCheckboxItem("Share Npcs", Main.ShareNpcsWithPlayers) { Enabled = false };
private readonly NativeSliderItem StreamedNpcsItem = new NativeSliderItem(string.Format("Streamed Npcs ({0})", Main.MainSettings.StreamedNpc), 20, Main.MainSettings.StreamedNpc);
private readonly NativeCheckboxItem FlipMenuItem = new NativeCheckboxItem("Flip menu", Main.MainSettings.FlipMenu);
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);
public Settings()
{
2021-08-18 18:20:55 +02:00
DeactivateTraffic.CheckboxChanged += DisableTrafficCheckboxChanged;
ShareNpcsItem.CheckboxChanged += (item, check) => { Main.ShareNpcsWithPlayers = ShareNpcsItem.Checked; };
StreamedNpcsItem.ValueChanged += StreamedNpcsValueChanged;
FlipMenuItem.CheckboxChanged += FlipMenuCheckboxChanged;
#if DEBUG
UseDebugItem.CheckboxChanged += UseDebugCheckboxChanged;
2021-08-18 11:47:59 +02:00
ShowNetworkInfo.CheckboxChanged += ShowNetworkInfoCheckboxChanged;
#endif
2021-08-18 18:20:55 +02:00
MainMenu.Add(DeactivateTraffic);
MainMenu.Add(ShareNpcsItem);
MainMenu.Add(StreamedNpcsItem);
MainMenu.Add(FlipMenuItem);
#if DEBUG
MainMenu.Add(UseDebugItem);
2021-08-18 11:47:59 +02:00
MainMenu.Add(ShowNetworkInfo);
#endif
}
public void StreamedNpcsValueChanged(object a, System.EventArgs b)
{
Main.MainSettings.StreamedNpc = StreamedNpcsItem.Value;
Util.SaveSettings();
StreamedNpcsItem.Title = string.Format("Streamed Npcs ({0})", Main.MainSettings.StreamedNpc);
}
public void FlipMenuCheckboxChanged(object a, System.EventArgs b)
{
Main.MainMenu.MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
MainMenu.Alignment = FlipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
Main.MainSettings.FlipMenu = FlipMenuItem.Checked;
Util.SaveSettings();
}
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
public void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
{
Main.MainNetworking.ShowNetworkInfo = ShowNetworkInfo.Checked;
if (!Main.MainNetworking.ShowNetworkInfo)
{
Main.MainNetworking.BytesReceived = 0;
Main.MainNetworking.BytesSend = 0;
}
}
public void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
{
2021-08-18 18:20:55 +02:00
Main.DeactivateTraffic = DeactivateTraffic.Checked;
2021-08-18 11:47:59 +02:00
2021-08-18 18:20:55 +02:00
if (DeactivateTraffic.Checked)
2021-08-18 11:47:59 +02:00
{
if (ShareNpcsItem.Checked)
{
ShareNpcsItem.Checked = false;
}
ShareNpcsItem.Enabled = false;
}
else if (Main.NpcsAllowed && !ShareNpcsItem.Enabled)
{
ShareNpcsItem.Enabled = true;
}
}
}
}