예제 #1
0
        public override void Initialize(IUIContext context)
        {
            base.Initialize(context);

            ButtonResume.OnPointerSelect
            .Subscribe(_ => Remove(), Debug.LogError)
            .AddTo(this);

            ButtonQuit.OnPointerSelect
            .Subscribe(_ => Game.Quit(), Debug.LogError)
            .AddTo(this);

            OnRemove
            .Where(_ => Controller.Active)
            .Subscribe(_ => ResumeGame(_playerControlEnabled), Debug.LogError);

            LocaleService.OnLocaleChange
            .Select(_ => LocaleService.SupportedLocales)
            .Select(l => l.Select(i => new DropdownItem(i.ToString(), i.NativeName)))
            .Subscribe(i => ChoiceLanguage.Items = i.ToList(), Debug.LogError)
            .AddTo(this);

            ChoiceLanguage.Value = LocaleService.Locale.ToString();
            ChoiceLanguage.OnValueChange
            .Select(k => new LanguageTag(k).ToCulture())
            .Subscribe(l => LocaleService.Locale = l, Debug.LogError)
            .AddTo(this);

            ChoiceStyle.Items = Styles.Select(s => new DropdownItem(s.Name, s.Name)).ToList();
            ChoiceStyle.Value = UIContext.Style.Name;
            ChoiceStyle.OnValueChange
            .Select(v => Styles.ToList().Find(s => s.Name == v))
            .Subscribe(s => UIContext.Style = s, Debug.LogError)
            .AddTo(this);

            _playerControlEnabled = Controller.PlayerControlEnabled;

            PauseGame();

            Visible = true;
        }