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

103 lines
3.2 KiB
C#
Raw Permalink Normal View History

2021-12-29 20:50:11 +03:00
using UnityEngine;
using UnityEngine.UI;
namespace RND
{
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.Show<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);
}
}
}