summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/GameOptionsMenu.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/GameOptionsMenu.cs')
-rw-r--r--Client/Assembly-CSharp/GameOptionsMenu.cs133
1 files changed, 133 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GameOptionsMenu.cs b/Client/Assembly-CSharp/GameOptionsMenu.cs
new file mode 100644
index 0000000..1c44375
--- /dev/null
+++ b/Client/Assembly-CSharp/GameOptionsMenu.cs
@@ -0,0 +1,133 @@
+using System;
+using UnityEngine;
+
+public class GameOptionsMenu : MonoBehaviour
+{
+ private GameOptionsData cachedData;
+
+ public GameObject ResetButton;
+
+ private OptionBehaviour[] Children;
+
+ public void Start()
+ {
+ this.Children = base.GetComponentsInChildren<OptionBehaviour>();
+ this.cachedData = PlayerControl.GameOptions;
+ for (int i = 0; i < this.Children.Length; i++)
+ {
+ OptionBehaviour optionBehaviour = this.Children[i];
+ optionBehaviour.OnValueChanged = new Action<OptionBehaviour>(this.ValueChanged);
+ if (AmongUsClient.Instance && !AmongUsClient.Instance.AmHost)
+ {
+ optionBehaviour.SetAsPlayer();
+ }
+ }
+ }
+
+ public void Update()
+ {
+ if (this.cachedData != PlayerControl.GameOptions)
+ {
+ this.cachedData = PlayerControl.GameOptions;
+ this.RefreshChildren();
+ }
+ }
+
+ private void RefreshChildren()
+ {
+ for (int i = 0; i < this.Children.Length; i++)
+ {
+ OptionBehaviour optionBehaviour = this.Children[i];
+ optionBehaviour.enabled = false;
+ optionBehaviour.enabled = true;
+ }
+ }
+
+ public void ValueChanged(OptionBehaviour option)
+ {
+ if (!AmongUsClient.Instance || !AmongUsClient.Instance.AmHost)
+ {
+ return;
+ }
+ if (option.Title == StringNames.GameRecommendedSettings)
+ {
+ if (this.cachedData.isDefaults)
+ {
+ this.cachedData.isDefaults = false;
+ }
+ else
+ {
+ this.cachedData.SetRecommendations(GameData.Instance.PlayerCount, AmongUsClient.Instance.GameMode);
+ }
+ this.RefreshChildren();
+ }
+ else
+ {
+ GameOptionsData gameOptions = PlayerControl.GameOptions;
+ StringNames title = option.Title;
+ switch (title)
+ {
+ case StringNames.GameMapName:
+ gameOptions.MapId = (byte)option.GetInt();
+ break;
+ case StringNames.GameNumImpostors:
+ gameOptions.NumImpostors = option.GetInt();
+ break;
+ case StringNames.GameNumMeetings:
+ gameOptions.NumEmergencyMeetings = option.GetInt();
+ break;
+ case StringNames.GameDiscussTime:
+ gameOptions.DiscussionTime = option.GetInt();
+ break;
+ case StringNames.GameVotingTime:
+ gameOptions.VotingTime = option.GetInt();
+ break;
+ case StringNames.GamePlayerSpeed:
+ gameOptions.PlayerSpeedMod = option.GetFloat();
+ break;
+ case StringNames.GameCrewLight:
+ gameOptions.CrewLightMod = option.GetFloat();
+ break;
+ case StringNames.GameImpostorLight:
+ gameOptions.ImpostorLightMod = option.GetFloat();
+ break;
+ case StringNames.GameKillCooldown:
+ gameOptions.KillCooldown = option.GetFloat();
+ break;
+ case StringNames.GameKillDistance:
+ gameOptions.KillDistance = option.GetInt();
+ break;
+ case StringNames.GameCommonTasks:
+ gameOptions.NumCommonTasks = option.GetInt();
+ break;
+ case StringNames.GameLongTasks:
+ gameOptions.NumLongTasks = option.GetInt();
+ break;
+ case StringNames.GameShortTasks:
+ gameOptions.NumShortTasks = option.GetInt();
+ break;
+ default:
+ if (title != StringNames.GameEmergencyCooldown)
+ {
+ Debug.Log("Ono, unrecognized setting: " + option.Title);
+ }
+ else
+ {
+ gameOptions.EmergencyCooldown = option.GetInt();
+ }
+ break;
+ }
+ if (gameOptions.isDefaults && option.Title != StringNames.GameMapName)
+ {
+ gameOptions.isDefaults = false;
+ this.RefreshChildren();
+ }
+ }
+ PlayerControl localPlayer = PlayerControl.LocalPlayer;
+ if (localPlayer == null)
+ {
+ return;
+ }
+ localPlayer.RpcSyncSettings(PlayerControl.GameOptions);
+ }
+}