示例#1
0
        /// <summary>
        /// Display single option (value, buttons and description)
        /// </summary>
        /// <param name="ID">Index of option in current category. Used for coloring odd/even options</param>
        /// <param name="optionID">Name of an option</param>
        /// <param name="value">Value to display</param>
        /// <param name="y">Position Y</param>
        /// <param name="second">Display in second column</param>
        private void DisplayOption(int ID, string optionID, Func <string> value, int y, bool secondColumn = false)
        {
            int half_size = (_config.WindowWidth - 288) / 2;
            int x         = 288 + (secondColumn ? half_size : 0);

            if (ID % 2 == 0)
            {
                DH.Box(x, y, half_size, 32, ColorsManager.DarkGray * .25f);
            }
            DH.Text(_font, value?.Invoke( ), x + 75, y + 18, false, align: AlignType.CM);
            DH.Text(_font, LANG.Get(optionID).ToUpper( ), x + 160, y + 18, false, align: AlignType.LM);
        }
示例#2
0
        /// <summary>
        /// Change language to previous or next from <see cref="_translations"/>
        /// </summary>
        /// <param name="toLeft">Is previous value from <see cref="_translations"/></param>
        private void ChangeLanguage(bool toLeft)
        {
            List <string> data      = _translations.Keys.ToList( );
            int           currentID = data.IndexOf(_cfg["language"].ToString( ));

            currentID += toLeft ? -1 : 1;

            if (currentID < 0)
            {
                currentID = data.Count - 1;
            }
            else if (currentID >= data.Count)
            {
                currentID = 0;
            }

            _cfg["language"] = _translations.ElementAt(currentID).Key;
            LANG.LoadTranslations <LanguageModel>(_cfg["language"].ToString( ));
        }
示例#3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="content"><see cref="ContentService"/></param>
        /// <param name="input"><see cref="InputService"/></param>
        /// <param name="config"><see cref="ConfigurationService"/></param>
        /// <param name="state"><see cref="StateService"/></param>
        public SettingsState(ContentService content, InputService input, ConfigurationService config, StateService state)
        {
            _input   = input;
            _config  = config;
            _content = content;
            _state   = state;
            _font    = content.GetFont(FontType.Small);

            OnStateLoad = () => {
                _cfg                  = config.Configuration.ToDictionary(entry => entry.Key, entry => entry.Value);
                _changedConfig        = new List <string>( );
                _translations         = LANG.GetAllTranslations <LanguageModel>( );
                _supportedResolutions = content.Device.Adapter.SupportedDisplayModes
                                        .Where(mode => mode.Width >= 1024 && mode.Height >= 768)
                                        .OrderBy(entry => entry.Width)
                                        .ToList( );
            };

            Initialize(content);
        }
示例#4
0
        /// <summary>
        /// State's render
        /// </summary>
        /// <param name="time"><see cref="GameTime"/></param>
        public override void Render(GameTime time)
        {
            DH.RenderScene(Scene, () => {
                DH.Raw(_content.TEXUI_MenuBG, 32, 0);

                _backButton.Display( );
                if (_changedConfig.Count > 0)
                {
                    _saveButton.Display( );
                }

                int half_size = (_config.WindowWidth - 288) / 2;

                DH.Text(_font, "section_general", 296, 48, align: AlignType.LB);
                DH.Line(288, 56, 288 + half_size, 56);
                DisplayOption(0, "language", () => _translations[_cfg["language"].ToString( )], 56);

                DH.Text(_font, "section_graphics", 296, 120, align: AlignType.LB);
                DH.Line(288, 128, 288 + half_size, 128);
                DisplayOption(0, "window_mode", () => LANG.Get("mode_" + ((bool)_cfg["window_fullscreen"] ? "fullscreen" : "window")), 128);
                DisplayOption(1, "resolution", () => $"{_cfg["window_width"]}x{_cfg["window_height"]}", 160);

                DH.Text(_font, "section_audio", 296, 224, align: AlignType.LB);
                DH.Line(288, 232, 288 + half_size, 232);
                DisplayOption(0, "master_volume", () => $"{((float)_cfg["master_volume"] * 100):0}%", 232);
                DisplayOption(1, "music_volume", () => $"{((float)_cfg["music_volume"] * 100):0}%", 264);
                DisplayOption(2, "sound_volume", () => $"{((float)_cfg["sound_volume"] * 100):0}%", 296);

                DH.Text(_font, "section_controls", 296 + half_size, 48, align: AlignType.LB);
                DH.Line(288 + half_size, 56, _config.WindowWidth, 56);
                DisplayOption(0, "key_console", () => $"{_cfg["key_console"]}", 56, true);
                DisplayOption(1, "key_pause", () => $"{_cfg["key_pause"]}", 88, true);
                DisplayOption(2, "key_move_up", () => $"{_cfg["key_move_up"]}", 120, true);
                DisplayOption(3, "key_move_down", () => $"{_cfg["key_move_down"]}", 152, true);
                DisplayOption(4, "key_move_left", () => $"{_cfg["key_move_left"]}", 184, true);
                DisplayOption(5, "key_move_right", () => $"{_cfg["key_move_right"]}", 216, true);

                DH.Line(288 + half_size, 56, 288 + half_size, 256);
            });
        }