hellbound/Assets/Scripts/Game/UI/Windows/SettingsWindow.cs

99 lines
2.9 KiB
C#

using UnityEngine;
using UnityEngine.UI;
public class SettingsWindow : ParameterlessWindow
{
[SerializeField] private Button _closeButton;
[SerializeField] private Button _backupItemsButton;
[SerializeField] private Button _gdprButton;
[SerializeField] private CheckBox _soundBox;
[SerializeField] private CheckBox _vibrationBox;
[SerializeField] private CheckBox _adsBox;
[SerializeField] private CheckBox _ccpaBox;
public override int ZOrder => -5;
protected override void OnInit()
{
_closeButton.onClick.AddListener(Close);
_soundBox.SetState(GameSettings.SoundIsActive);
_soundBox.OnChangeState += OnSoundBoxClick;
_vibrationBox.SetState(GameSettings.VibrationIsActive);
_vibrationBox.OnChangeState += OnVibrationBoxClick;
if(_backupItemsButton)
_backupItemsButton.onClick.AddListener(OnBackupItemsClick);
if(_gdprButton)
_gdprButton.onClick.AddListener(OpenInformationWindow);
if (_ccpaBox)
{
bool showCCPAButton = false; // установить
_ccpaBox.SetInteractable(showCCPAButton);
_ccpaBox.SetState(false);
_ccpaBox.OnChangeState += OnCCPABoxClick;
if (showCCPAButton)
{
bool user_allow_share = false; // установить
_ccpaBox.SetState(user_allow_share);
}
else
_ccpaBox.gameObject.SetActive(false);
_ccpaBox.gameObject.SetActive(false);
}
if (_adsBox)
{
_adsBox.OnChangeState += OnAdsBoxClick;
bool adsState = true; // установить
bool adsIsEnabled = true; // установить
_adsBox.SetState(adsState);
_adsBox.SetInteractable(adsIsEnabled);
}
}
private void OpenInformationWindow()
{
UI.ShowWindow<GDPRWindow>();
}
private void OnBackupItemsClick()
{
// PurchaseController.instance.RestorePurchase();
}
private void OnSoundBoxClick(bool isCheckboxEnabled)
{
GameSettings.SoundToggle();
}
private void OnVibrationBoxClick(bool isCheckboxEnabled)
{
GameSettings.VibrationToggle();
}
private void OnAdsBoxClick(bool isCheckboxEnabled)
{ //if(checkboxState == CheckboxState.Inactive && !ADsManager.Instance.ADSIsRemoved)
// PurchaseController.instance.RemoveAds();
}
private void OnCCPABoxClick(bool isCheckboxEnabled)
{
//MRGSGDPR.MRGSCCPAUserPreference result = checkboxState == CheckboxState.Inactive
// ? MRGSGDPR.MRGSCCPAUserPreference.MRGSCCPAUserPreferenceShare
// : MRGSGDPR.MRGSCCPAUserPreference.MRGSCCPAUserPreferenceNotSharing;
//MRGSGDPR.getInstance().setUserChangedCCPAPrefrences(result);
}
}