コード例 #1
0
ファイル: PopupViewModel.cs プロジェクト: Hostur/Games-Core
 private void Finalize(PopupResultType resultType)
 {
     this.Log($"Finalize popup with resultType '{resultType.ToString()}'.", LogLevel.DevelopmentInfo);
     _resultCallback?.Invoke(new PopupResult(resultType, _customPopupParam, _neverShowAgain));
     CoreGameEventsManager.Unsubscribe <HardwareBackButtonEvent>(OnHardwareBackButtonEvent);
     OnEnableDisable?.Invoke(false);
 }
コード例 #2
0
        public static void SubscribeMyEventHandlers <T>(this T obj)
        {
            var methods = obj.GetMethodsWithAttribute <T, CoreRegisterEventHandlerAttribute>();

            for (int i = 0; i < methods.Length; i++)
            {
                var attribute = methods[i].GetCustomAttribute <CoreRegisterEventHandlerAttribute>();

                EventHandler handler = (EventHandler)Delegate.CreateDelegate(
                    typeof(EventHandler), obj, methods[i]);

                CoreGameEventsManager.Subscribe(attribute.EventType, handler, attribute.Persistent);
            }
        }
コード例 #3
0
ファイル: PopupViewModel.cs プロジェクト: Hostur/Games-Core
        private void ShowPopup(ShowPopupEvent showPopupEvent)
        {
            if (string.IsNullOrEmpty(showPopupEvent.PopupTitleKey))
            {
                Title     = "Title";
                ShowTitle = false;
            }
            else
            {
                ShowTitle = true;
                Title     = Translate(showPopupEvent.PopupTitleKey);
            }

            Content = Translate(showPopupEvent.PopupContentKey);

            SizeOptions    = showPopupEvent.Size;
            PositiveButton = (!string.IsNullOrEmpty(showPopupEvent.PositiveButtonKey)) ? Translate(showPopupEvent.PositiveButtonKey) : Translate("OK");
            NegativeButton = (!string.IsNullOrEmpty(showPopupEvent.NegativeButtonKey)) ? Translate(showPopupEvent.NegativeButtonKey) : Translate("NO");
            CancelButton   = (!string.IsNullOrEmpty(showPopupEvent.CancelButtonKey)) ? Translate(showPopupEvent.CancelButtonKey) : Translate("CANCEL");

            ButtonOptions   = showPopupEvent.ButtonOptions;
            _resultCallback = showPopupEvent.ResultCallback;

            _cancelOnBackgroundAvailable = showPopupEvent.CancelOnBackgroundAvailable;
            _customPopupParam            = showPopupEvent.CustomParam;

            if (showPopupEvent.AllButtonsColor == new Color())
            {
                _buttonsColors = _defaultColors;
            }
            else
            {
                _buttonsColors = new[] { showPopupEvent.AllButtonsColor, showPopupEvent.AllButtonsColor, showPopupEvent.AllButtonsColor }
            };

            _showNeverShowAgainOption = showPopupEvent.ShowNeverShowAgainCheckbox;

            CoreGameEventsManager.Subscribe <HardwareBackButtonEvent>(OnHardwareBackButtonEvent);
            // Enabling popup cause Refreshing on view model so FireOnPropertyChanged will be invoked from Refresh function.
            OnEnableDisable?.Invoke(true);
        }
コード例 #4
0
 private void ReloadDictionary()
 {
   _dictionary = _languageDictionary.GetDictionary(LanguagesManager.CurrentLanguage);
   CoreGameEventsManager.Publish(this, new LanguageReloadedEvent());
 }
コード例 #5
0
 public GameTranslator()
 {
   _languageDictionary = UnityEngine.Resources.Load<ScriptableLanguageDictionary>("Balance/LanguageDictionary");
   ReloadDictionary();
   CoreGameEventsManager.Subscribe<LanguagesManager.AfterLanguageChangedEvent>(OnReloadLanguageEvent);
 }