Diese Klasse repräsentiert eine Option, welche die Werte \glqq Wahr\grqq~oder \glqq Falsch\grqq~annehmen kann.
상속: DistinctOption
예제 #1
0
        public void BooleanOptionInfo_Constructor_Test()
        {
            string name = "test-option";
            string section = "test-section";
            bool defaultValue = false;

            ConfigFile configFile = new ConfigFile (TestHelper.RandomFilename (extension: "ini"));

            BooleanOption option = new BooleanOption (section, name, defaultValue, configFile);

            Assert.IsFalse (option.Value);
            string falseStr = option.DisplayValue;
            Assert.IsTrue (option.DisplayValidValues.ContainsKey (falseStr));

            option.Value = true;
            Assert.IsTrue (option.Value);
            string trueStr = option.DisplayValue;
            Assert.IsTrue (option.DisplayValidValues.ContainsKey (trueStr));

            Assert.AreNotEqual (falseStr, trueStr);

            option.Value = !option.Value;
            Assert.IsFalse (option.Value);
            Assert.AreEqual (falseStr, option.DisplayValue);

            option.Value = !option.Value;
            Assert.IsTrue (option.Value);
            Assert.AreEqual (trueStr, option.DisplayValue);

            (option as DistinctOption).Value = "invalid!!";
            Assert.AreEqual (option.Value, defaultValue);
        }
예제 #2
0
 /// <summary>
 /// Erzeugt ein neues CheckBoxItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt.
 /// Zudem sind Angaben zur Zeichenreihenfolge und der Auswahloption Pflicht.
 /// </summary>
 public CheckBoxItem(IScreen screen, DisplayLayer drawOrder, string text, BooleanOption option)
     : base(screen, drawOrder, text)
 {
     this.option = option;
     currentValue = option.Value;
 }
예제 #3
0
        /// <summary>
        /// Erzeugt ein neues GraphicsSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public GraphicsSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Graphics";

            CheckBoxItem itemShowArrows = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Arrows",
                option: new BooleanOption ("video", "arrows", false, Config.Default)
            );
            settingsMenu.Add (itemShowArrows);

            // blinking stars
            BooleanOption optionBlinkingStars = new BooleanOption ("video", "stars-blinking", true, Config.Default);
            CheckBoxItem itemBlinkingStars = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Blinking Stars",
                option: optionBlinkingStars
            );
            itemBlinkingStars.OnValueChanged += () => {
                (game as Knot3Game).NotAvailableOnXNA ();
            };
            settingsMenu.Add (itemBlinkingStars);

            // star count
            float[] validStarCounts = {
                100, 250, 500, 750, 1000, 1250, 1500, 2000, 2500, 3000, 5000
            };
            FloatOption optionStarCount = new FloatOption (
                section: "video",
                name: "stars-count",
                defaultValue: validStarCounts [4],
                validValues: validStarCounts,
                configFile: Config.Default
            );
            ComboBox itemStarCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Number of stars"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemStarCount.AddEntries (optionStarCount);
            settingsMenu.Add (itemStarCount);

            // show sun
            BooleanOption optionShowSun = new BooleanOption ("video", "show-sun", false, Config.Default);
            CheckBoxItem itemShowSun = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Sun",
                option: optionShowSun
            );
            settingsMenu.Add (itemShowSun);

            // day cycle
            float[] validDayCycles = {
                10, 20, 30, 60, 120, 300, 600, 900, 1200, 3600, 7200
            };
            FloatOption optionDayCycle = new FloatOption (
                section: "video",
                name: "day-cycle-seconds",
                defaultValue: validDayCycles [3],
                validValues: validDayCycles,
                configFile: Config.Default
            );
            ComboBox itemDayCycle = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Day cycle in seconds"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemDayCycle.AddEntries (optionDayCycle);
            settingsMenu.Add (itemDayCycle);

            // selective rendering
            CheckBoxItem itemSelectiveRender = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Selective Rendering",
                option: new BooleanOption ("video", "selectiveRendering", false, Config.Default)
            );
            settingsMenu.Add (itemSelectiveRender);

            // auto camera when moving
            CheckBoxItem itemAutoCameraMove = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Auto Camera (edge move)",
                option: new BooleanOption ("video", "auto-camera-move", true, Config.Default)
            );
            settingsMenu.Add (itemAutoCameraMove);

            // auto camera
            CheckBoxItem itemAutoCamera = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Auto Camera",
                option: new BooleanOption ("video", "auto-camera-nomove", false, Config.Default)
            );
            settingsMenu.Add (itemAutoCamera);

            // Resolutions
            string currentResolution = GraphicsManager.GraphicsDevice.DisplayMode.Width.ToString ()
                                       + "x"
                                       + GraphicsManager.GraphicsDevice.DisplayMode.Height.ToString ();

            DisplayModeCollection modes = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes;
            HashSet<string> reso = new HashSet<string> ();
            foreach (DisplayMode mode in modes) {
                reso.Add (mode.Width + "x" + mode.Height);
            }
            reso.Add ("1024x600");
            string[] validResolutions = reso.ToArray ();
            validResolutions = validResolutions.OrderBy (x => Decimal.Parse (x.Split ('x') [0], System.Globalization.NumberStyles.Any)).ToArray ();
            DistinctOption optionResolution = new DistinctOption (
                section: "video",
                name: "resolution",
                defaultValue: currentResolution,
                validValues: validResolutions,
                configFile: Config.Default
            );
            ComboBox itemResolution = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Resolution"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemResolution.AddEntries (optionResolution);
            settingsMenu.Add (itemResolution);

            // Supersampling
            float[] validSupersamples = {
                1f, 1.25f, 1.5f, 1.75f, 2f
            };
            FloatOption optionSupersamples = new FloatOption (
                section: "video",
                name: "Supersamples",
                defaultValue: 2f,
                validValues: validSupersamples,
                configFile: Config.Default
            );
            ComboBox itemSupersamples = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Supersamples"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemSupersamples.AddEntries (optionSupersamples);
            settingsMenu.Add (itemSupersamples);

            // fullscreen
            BooleanOption optionFullscreen = new BooleanOption ("video", "fullscreen", false, Config.Default);
            CheckBoxItem itemFullscreen = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Fullscreen",
                option: optionFullscreen
            );
            itemFullscreen.OnValueChanged += () => Game.IsFullScreen = optionFullscreen.Value;
            settingsMenu.Add (itemFullscreen);

            // Model quality
            SliderItem sliderModelQuality = new SliderItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Model Quality",
                max: 1000,
                min: 0,
                value: 0
            );
            sliderModelQuality.Value = (int)(Primitive.ModelQualityOption.Value * 1000f);
            sliderModelQuality.OnValueChanged = (time) => {
                float quality = (float)sliderModelQuality.Value / 1000f;
                Primitive.ModelQualityOption.Value = quality;
                Primitive.OnModelQualityChanged (time);
            };
            settingsMenu.Add (sliderModelQuality);

            // Rendereffects
            RenderEffectOption optionRenderEffect = new RenderEffectOption (
                section: "video",
                name: "current-world-effect",
                configFile: Config.Default
            );
            ComboBox itemRenderEffect = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Render Effect"
            );
            itemRenderEffect.ValueChanged += (time) => {
                RenderEffectLibrary.RenderEffectChanged (Config.Default ["video", "current-world-effect", "default"], time);
            };
            itemRenderEffect.AddEntries (optionRenderEffect);
            settingsMenu.Add (itemRenderEffect);

            // Projector Mode
            BooleanOption optionProjectorMode = new BooleanOption ("debug", "projector-mode", false, Config.Default);
            CheckBoxItem itemProjectorMode = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Video projector mode",
                option: optionProjectorMode
            );
            itemProjectorMode.OnValueChanged += () => {
                if (optionProjectorMode.Value) {
                    new ProjectorDesign ().Apply ();
                    Config.Default ["video", "camera-overlay", false] = false;
                    Config.Default ["video", "profiler-overlay", false] = false;
                    Config.Default ["video", "current-world-effect", "default"] = "default";
                    Config.Default ["video", "Supersamples", 2f] = 2f;
                    Config.Default ["video", "arrows", false] = false;
                    Config.Default ["language", "current", "en"] = "de";
                    Config.Default ["video", "day-cycle-seconds", 60] = 10;
                }
                else {
                    new HfGDesign ().Apply ();
                }
                NextScreen = new StartScreen (game);
            };
            settingsMenu.Add (itemProjectorMode);
        }