Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using DG.Tweening;
- using DG.Tweening.Core;
- using DG.Tweening.Plugins.Options;
- using UnityEngine;
- using UnityEngine.UI;
- // Token: 0x02000135 RID: 309
- public class UiCellphoneAppCode : UiCellphoneApp
- {
- // Token: 0x0600065D RID: 1629 RVA: 0x0003321C File Offset: 0x0003141C
- private void Start()
- {
- this.titleBar.Populate(null, this.titleLabelText);
- this.resultsRectTransform.localScale = Vector3.one * 0.25f;
- this.resultsCanvasGroup.alpha = 0f;
- this._currentFieldText = (this.inputField.text = "");
- this.submitButton.ButtonPressedEvent += this.OnSubmitButtonPressed;
- this.inputField.Select();
- this.Refresh();
- }
- // Token: 0x0600065E RID: 1630 RVA: 0x000332A6 File Offset: 0x000314A6
- private void Update()
- {
- if (this._currentFieldText != this.inputField.text)
- {
- this.Refresh();
- }
- }
- // Token: 0x0600065F RID: 1631 RVA: 0x000332C8 File Offset: 0x000314C8
- public override void Refresh()
- {
- this._currentFieldText = (this.inputField.text = this.inputField.text.ToUpper());
- if (!StringUtils.IsEmpty(this.inputField.text))
- {
- this.submitButton.Enable();
- return;
- }
- this.submitButton.Disable();
- }
- // Token: 0x06000660 RID: 1632 RVA: 0x00033324 File Offset: 0x00031524
- private void OnSubmitButtonPressed(ButtonBehavior buttonBehavior)
- {
- string input = this.inputField.text.ToUpper().Trim();
- this._currentFieldText = (this.inputField.text = "");
- this.inputField.Select();
- this.Refresh();
- string key = StringUtils.MD5(input);
- if (Game.Manager.Settings.unlockCodes.ContainsKey(key))
- {
- CodeDefinition codeDefinition = Game.Manager.Settings.unlockCodes[key];
- CodeType codeType = codeDefinition.codeType;
- if (codeType != CodeType.TOGGLE)
- {
- if (codeType == CodeType.UNLOCK)
- {
- if (!Game.Persistence.playerData.unlockedCodes.Contains(codeDefinition))
- {
- Game.Persistence.playerData.unlockedCodes.Add(codeDefinition);
- this.ShowCodeResult(codeDefinition.onMessage, false);
- }
- else
- {
- this.ShowCodeResult(this.resultMsgRepeat, true);
- }
- }
- }
- else if (!Game.Persistence.playerData.unlockedCodes.Contains(codeDefinition))
- {
- Game.Persistence.playerData.unlockedCodes.Add(codeDefinition);
- this.ShowCodeResult(codeDefinition.onMessage, false);
- }
- else
- {
- Game.Persistence.playerData.unlockedCodes.Remove(codeDefinition);
- this.ShowCodeResult(codeDefinition.offMessage, false);
- }
- }
- else
- {
- this.ShowCodeResult(this.resultMsgInvalid, true);
- }
- if (Game.Manager.Ui.currentCanvas.titleCanvas)
- {
- Game.Manager.Ui.currentCanvas.GetComponent<UiTitleCanvas>().coverArt.Refresh();
- }
- }
- // Token: 0x06000661 RID: 1633 RVA: 0x000334A4 File Offset: 0x000316A4
- private void ShowCodeResult(string resultMessage, bool error = false)
- {
- Game.Manager.Time.KillTween(this._resultSequence, false, true);
- this.resultsRectTransform.localScale = Vector3.one * 0.25f;
- this.resultsCanvasGroup.alpha = 0f;
- this.resultsLabel.text = resultMessage;
- this.resultsBackground.sizeDelta = new Vector2(Mathf.Min(this.resultsLabel.preferredWidth + 80f, this.resultsLabel.rectTransform.sizeDelta.x + 80f), this.resultsLabel.preferredHeight + 40f);
- this._resultSequence = DOTween.Sequence();
- this._resultSequence.Insert(0f, this.resultsRectTransform.DOScale(Vector3.one, 0.25f).SetEase(Ease.OutBack));
- this._resultSequence.Insert(0f, this.resultsCanvasGroup.DOFade(1f, 0.25f).SetEase(Ease.Linear));
- Game.Manager.Time.Play(this._resultSequence, this.pauseBehavior.pauseDefinition, 0f);
- if (!error)
- {
- Game.Manager.Audio.Play(AudioCategory.SOUND, Game.Manager.Ui.sfxCellphoneNotification, base.cellphone.pauseBehavior.pauseDefinition);
- }
- else
- {
- Game.Manager.Audio.Play(AudioCategory.SOUND, Game.Manager.Ui.sfxReject, base.cellphone.pauseBehavior.pauseDefinition);
- }
- if (!error)
- {
- this._codeUnlocked = true;
- }
- }
- // Token: 0x06000662 RID: 1634 RVA: 0x00033648 File Offset: 0x00031848
- private void OnDestroy()
- {
- Game.Manager.Time.KillTween(this._resultSequence, false, true);
- this.submitButton.ButtonPressedEvent -= this.OnSubmitButtonPressed;
- if (this._codeUnlocked)
- {
- Game.Manager.Settings.SaveSettings();
- }
- }
- // Token: 0x04000AD0 RID: 2768
- public UiAppTitleBar titleBar;
- // Token: 0x04000AD1 RID: 2769
- public InputField inputField;
- // Token: 0x04000AD2 RID: 2770
- public ButtonBehavior submitButton;
- // Token: 0x04000AD3 RID: 2771
- public RectTransform resultsRectTransform;
- // Token: 0x04000AD4 RID: 2772
- public CanvasGroup resultsCanvasGroup;
- // Token: 0x04000AD5 RID: 2773
- public RectTransform resultsBackground;
- // Token: 0x04000AD6 RID: 2774
- public Text resultsLabel;
- // Token: 0x04000AD7 RID: 2775
- public string titleLabelText;
- // Token: 0x04000AD8 RID: 2776
- public string resultMsgInvalid;
- // Token: 0x04000AD9 RID: 2777
- public string resultMsgRepeat;
- // Token: 0x04000ADA RID: 2778
- private string _currentFieldText;
- // Token: 0x04000ADB RID: 2779
- private bool _codeUnlocked;
- // Token: 0x04000ADC RID: 2780
- private Sequence _resultSequence;
- }
Add Comment
Please, Sign In to add comment