|
- using System;
- using CIG;
- using CIG.Extensions;
- using CIG.Translation;
- using CIGEnums;
- using SUISSEngine;
- using UnityEngine;
-
- public class QuestsPopupView : PopupBaseView
- {
- protected void OnDestroy()
- {
- this._tabView.TabIndexChangedEvent -= this.OnTabIndexChangedEvent;
- }
-
- public override void Init()
- {
- base.Init();
- this._tabView.TabIndexChangedEvent += this.OnTabIndexChangedEvent;
- }
-
- public void SwitchTab(QuestsMenuTabs menuTab)
- {
- if (this._activeQuestTabView != null)
- {
- this._activeQuestTabView.DeinitView();
- this._activeQuestTabView.gameObject.SetActive(false);
- }
- this._tabView.ActiveTabIndex = (int)menuTab;
- this.CancelInvoke(new Action(this.UpdateTimer));
- this._remainingTimeSection.alpha = 0f;
- if (menuTab != QuestsMenuTabs.DailyQuests)
- {
- if (menuTab != QuestsMenuTabs.OngoingQuests)
- {
- UnityEngine.Debug.LogWarning("[QuestsPopupView] No content for tab " + menuTab + ", redirecting to OngoingQuests tab");
- this._activeQuestTabView = this._ongoingQuestsView;
- }
- else
- {
- this._activeQuestTabView = this._ongoingQuestsView;
- }
- }
- else
- {
- this._activeQuestTabView = this._dailyQuestsView;
- this._remainingTimeSection.alpha = 1f;
- this.InvokeRepeating(new Action(this.UpdateTimer), 0f, 1f, true);
- }
- this._activeQuestTabView.gameObject.SetActive(true);
- this._activeQuestTabView.InitView();
- this._titleText.LocalizedString = this._tabView.GetLocalizedTitle(this._tabView.ActiveTabIndex);
- }
-
- private void OnTabIndexChangedEvent(int oldIndex, int newIndex)
- {
- this.SwitchTab((QuestsMenuTabs)newIndex);
- }
-
- private void UpdateTimer()
- {
- this._remainingTimeText.LocalizedString = Localization.TimeSpan(TimeSpan.FromSeconds((double)Singleton<Daily>.Instance.CurrentDay.CalculateTimeRemaining()), false);
- }
-
- [SerializeField]
- private LocalizedText _titleText;
-
- [SerializeField]
- private TabView _tabView;
-
- [SerializeField]
- private CanvasGroup _remainingTimeSection;
-
- [SerializeField]
- private LocalizedText _remainingTimeText;
-
- [Header("Tab Contents")]
- [SerializeField]
- private OngoingQuestsView _ongoingQuestsView;
-
- [SerializeField]
- private DailyQuestsView _dailyQuestsView;
-
- private QuestTabContentView _activeQuestTabView;
- }
|