context: using System;
  using System.Collections;
  using DeveloperConsole;
  using ProjectPorcupine.Localization;
  using UnityEngine.UI;
  using UnityEngine;
  
  /// <summary>
  /// This class is what the settings menu will call to retrieve the classes.
  /// </summary>
  public static class SettingsMenuFunctions
  {
      public static GenericToggle GetGenericToggle()
      {
          return new GenericToggle();
      }
  
      public static GenericInputField GetGenericInputField()
      {
          return new GenericInputField();
      }
  
      public static GenericSlider GetGenericSlider()
      {
          return new GenericSlider();
      }
  
      public static AutosaveIntervalInputField GetAutosaveIntervalInputField()
      {
          return new AutosaveIntervalInputField();
      }
  
      public static LocalizationComboBox GetLocalizationComboBox()
      {
          return new LocalizationComboBox();
      }
  
      public static UISkinComboBox GetUISkinComboBox()
      {
          return new UISkinComboBox();
      }
  
      public static QualityComboBox GetQualityComboBox()
      {
          return new QualityComboBox();
      }
  
      public static VSyncComboBox GetVSyncComboBox()
      {
          return new VSyncComboBox();
      }
  
      public static ResolutionComboBox GetResolutionComboBox()
      {
          return new ResolutionComboBox();
      }
  
      public static PerformanceHUDComboBox GetPerformanceHUDComboBox()
      {
          return new PerformanceHUDComboBox();
      }
  
      public static AnisotropicFilteringComboBox GetAnisotropicFilteringComboBox()
      {
          return new AnisotropicFilteringComboBox();
      }
  
      public static ShadowComboBox GetShadowComboBox()
      {
          return new ShadowComboBox();
      }
  
      public static AAComboBox GetAAComboBox()
      {
          return new AAComboBox();
      }
  
      public static SoundDeviceComboBox GetSoundDeviceComboBox()
      {
          return new SoundDeviceComboBox();
      }
  
      public static DeveloperConsoleSlider GetDeveloperConsoleSlider()
      {
          return new DeveloperConsoleSlider();
      }
  
      public static UIScaleSlider GetUIScaleSlider()
      {
          return new UIScaleSlider();
      }
  
      public static SoundSlider GetSoundSlider()
      {
          return new SoundSlider();
      }
  
      public static DeveloperConsoleToggle GetDeveloperConsoleToggle()
      {
          return new DeveloperConsoleToggle();
      }
  
      public static FullScreenToggle GetFullScreenToggle()
      {
          return new FullScreenToggle();
      }
  
      public static SoftParticlesToggle GetSoftParticlesToggle()
      {
          return new SoftParticlesToggle();
      }
  }
  
  /// <summary>
  /// A generic toggle.
  /// </summary>
  public class GenericToggle : BaseSettingsElement
  {
      protected bool isOn;
      protected Toggle toggleElement;
  
      public override GameObject InitializeElement()
      {
          string type = this.parameterData.ContainsKey("Type") ? this.parameterData["Type"].ToString() : "Toggle";
          GameObject element = GetHorizontalBaseElement(type, 120, 60, TextAnchor.MiddleLeft);
  
          Text text = CreateText(option.name, true);
          text.transform.SetParent(element.transform);
  
          toggleElement = CreateToggle(type);
          toggleElement.transform.SetParent(element.transform);
  
          isOn = getValue();
          toggleElement.isOn = isOn;
  
          toggleElement.onValueChanged.AddListener(
              (bool v) =>
              {
                  if (v != isOn)
                  {
                      valueChanged = true;
                      isOn = v;
                  }
              });
  
          LayoutElement layout = toggleElement.gameObject.AddComponent<LayoutElement>();
          layout.ignoreLayout = true;
  
          RectTransform rTransform = toggleElement.GetComponent<RectTransform>();
          rTransform.sizeDelta = type == "Switch" ? new Vector2(60, 30) : new Vector2(40, 40);
          rTransform.anchorMax = new Vector2(0.5f, 0.5f);
          rTransform.anchorMin = new Vector2(0.5f, 0.5f);
          rTransform.localPosition = new Vector3(45, 0, 0);
  
          return element;
      }
  
      public override void CancelSetting()
      {
      }
  
      public override void ApplySetting()
      {
          Settings.SetSetting(option.key, isOn);
      }
  
      public bool getValue()
      {
          bool temp;
          return Settings.GetSetting(option.key, out temp) ? temp : option.defaultValue.ToLower() == "true" ? true : false;
      }
  }
  
  /// <summary>
  /// A generic input field.
  /// </summary>
  public class GenericInputField : BaseSettingsElement
  {
      protected InputField fieldElement;
      protected string value;
  
      public override GameObject InitializeElement()
      {
          GameObject element = GetFluidHorizontalBaseElement("InputField", true, false, TextAnchor.MiddleLeft, 10);
  
          Text text = CreateText(option.name, true);
          text.transform.SetParent(element.transform);
          value = getValue();
  
          fieldElement = CreateInputField(value);
          fieldElement.transform.SetParent(element.transform);
          fieldElement.textComponent.alignment = TextAnchor.MiddleCenter;
          fieldElement.onValueChanged.AddListener(
              (string v) =>
              {
                  if (v != value)
                  {
                      valueChanged = true;
                      value = v;
                  }
              });
  
          LayoutElement layout = fieldElement.gameObject.AddComponent<LayoutElement>();
          layout.minWidth = 60;
          layout.minHeight = 30;
  
          string verification = this.parameterData.ContainsKey("Verification") ? this.parameterData["Verification"].ToString() : "Standard";
  
          switch (verification)
          {
              case "PositiveInteger":
                  fieldElement.onValidateInput += ValidateInputForPositiveNumber;
                  break;
              case "Integer":
                  fieldElement.contentType = InputField.ContentType.IntegerNumber;
                  break;
              case "Alphanumeric":
                  fieldElement.contentType = InputField.ContentType.Alphanumeric;
                  break;
              case "Decimal":
                  fieldElement.contentType = InputField.ContentType.DecimalNumber;
                  break;
              case "Pin":
                  fieldElement.contentType = InputField.ContentType.Pin;
                  break;
              case "Password":
                  fieldElement.contentType = InputField.ContentType.Password;
                  break;
              case "Name":
                  fieldElement.contentType = InputField.ContentType.Name;
                  break;
              case "EmailAddress":
                  fieldElement.contentType = InputField.ContentType.EmailAddress;
                  break;
              case "Autocorrected":
                  fieldElement.contentType = InputField.ContentType.Autocorrected;
                  break;
          }
  
          return element;
      }
  
      public char ValidateInputForPositiveNumber(string text, int charIndex, char addedChar)
      {
          char output = addedChar;
  
          if (addedChar != '1'
  
gt:             && addedChar != '2'