Diese Klasse repräsentiert eine Option, die einen Wert aus einer distinkten Werteliste annehmen kann.
Inheritance: Option
Exemplo n.º 1
0
        private void OnDirectionsChanged(GameTime time)
        {
            float[] validAngles = new float[] {
                0, 45, 90, 135, 180, 225, 270, 315
            };
            string[] validModelnames = AvailableModels;
            if (validModelnames.Length == 0) {
                throw new Exception ("No models are available!");
            }

            for (int i = 0; i < JunctionCount; ++i) {
                FloatOption optionBumpRotation = new FloatOption (
                    section: NodeConfigKey (Directions),
                    name: "bump" + i.ToString (),
                    defaultValue: 0,
                    validValues: validAngles,
                    configFile: Config.Models
                );
                itemBumpRotation [i].AddEntries (optionBumpRotation);
                if (time != null) {
                    RemoveGameComponents (time, itemBumpRotation [i]);
                    AddGameComponents (time, itemBumpRotation [i]);
                }

                DistinctOption optionModel = new DistinctOption (
                    section: NodeConfigKey (Directions),
                    name: "modelname" + i.ToString (),
                    defaultValue: validModelnames [0],
                    validValues: validModelnames,
                    configFile: Config.Models
                );
                itemModels [i].AddEntries (optionModel);
                if (time != null) {
                    RemoveGameComponents (time, itemModels [i]);
                    AddGameComponents (time, itemModels [i]);
                }
            }

            knotRenderer.Render (directions: Directions);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public JunctionEditorScreen(GameCore game)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromLeft (0.60f));
            // der Input-Handler
            knotInput = new KnotInputHandler (screen: this, world: world);
            // der Mauszeiger
            pointer = new MousePointer (screen: this);
            // der Maus-Handler für die 3D-Modelle
            modelMouseHandler = new ModelMouseHandler (screen: this, world: world);

            // der Knoten-Renderer
            knotRenderer = new JunctionEditorRenderer (screen: this, position: Vector3.Zero);
            world.Add (knotRenderer);

            // visualisiert die BoundingSpheres
            debugBoundings = new DebugBoundings (screen: this, position: Vector3.Zero);
            world.Add (debugBoundings);

            // Hintergrund
            SkyCube skyCube = new SkyCube (screen: this, position: Vector3.Zero, distance: 10000);
            world.Add (skyCube);

            // Backbutton
            backButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = new StartScreen (Game)
            );
            backButton.AddKey (Keys.Escape);
            backButton.IsVisible = true;

            // Menü
            settingsMenu = new Menu (this, DisplayLayer.Overlay + DisplayLayer.Menu);
            settingsMenu.Bounds = Bounds.FromRight (0.40f).FromBottom (0.9f).FromLeft (0.8f);
            settingsMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            settingsMenu.RelativeItemHeight = 0.030f;

            float[] validJunctionCounts = new float[] { 1, 2, 3 };
            optionJunctionCount = new FloatOption (
                section: "debug",
                name: "debug_junction_count",
                defaultValue: validJunctionCounts.At (-1),
                validValues: validJunctionCounts,
                configFile: Config.Default
            );
            itemJunctionCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Junctions #"
            );
            itemJunctionCount.AddEntries (optionJunctionCount);
            itemJunctionCount.ValueChanged += OnJunctionCountChanged;

            Direction[] validDirections = Direction.Values;
            optionJuctionDirection = new DistinctOption [3];
            itemJunctionDirection = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                DistinctOption option = new DistinctOption (
                    section: "debug",
                    name: "debug_junction_direction" + i.ToString (),
                    defaultValue: validDirections [i * 2],
                    validValues: validDirections.Select (d => d.Name),
                    configFile: Config.Default
                );
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Direction ") + i.ToString ()
                );
                item.AddEntries (option);
                optionJuctionDirection [i] = option;
                item.ValueChanged += OnDirectionsChanged;
                itemJunctionDirection [i] = item;
            }

            itemBumpRotation = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Bump Angle ") + i.ToString ()
                );
                item.ValueChanged += OnAnglesChanged;
                itemBumpRotation [i] = item;
            }

            itemModels = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Model ") + i.ToString ()
                );
                item.ValueChanged += OnModelsChanged;
                itemModels [i] = item;
            }

            OnDirectionsChanged (null);
            OnJunctionCountChanged (null);

            world.Camera.PositionToTargetDistance = 180;
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Fügt Einträge in das Dropdown-Menü ein, die auf Einstellungsoptionen basieren.
 /// </summary>
 public void AddEntries(DistinctOption option)
 {
     dropdown.Clear ();
     foreach (string _value in new HashSet<string>(option.DisplayValidValues.Keys)) {
         string value = _value; // create a copy for the action
         Action<GameTime> onSelected = (time) => {
             Log.Debug ("OnClick: ", value);
             option.Value = option.DisplayValidValues [value];
             currentValue.InputText = option.DisplayValue;
             dropdown.IsVisible = false;
             ValueChanged (time);
         };
         MenuEntry button = new MenuEntry (
             screen: Screen,
             drawOrder: Index + DisplayLayer.MenuItem,
             name: value,
             onClick: onSelected
         );
         button.IsSelectable = false;
         dropdown.Add (button);
     }
     currentValue.InputText = option.DisplayValue;
     updateCurrentValue = (t) => currentValue.InputText = option.DisplayValue;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Erzeugt ein neues DebugSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public DebugSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Debug";

            CheckBoxItem showOverlay = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Overlay",
                option: new BooleanOption ("video", "camera-overlay", false, Config.Default)
            );
            settingsMenu.Add (showOverlay);

            CheckBoxItem showFps = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show FPS",
                option: new BooleanOption ("video", "fps-overlay", false, Config.Default)
            );
            settingsMenu.Add (showFps);

            CheckBoxItem showProfiler = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Profiler",
                option: new BooleanOption ("video", "profiler-overlay", false, Config.Default)
            );
            settingsMenu.Add (showProfiler);

            CheckBoxItem showBoundings = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Bounding Boxes",
                option: new BooleanOption ("debug", "show-boundings", false, Config.Default)
            );
            settingsMenu.Add (showBoundings);

            CheckBoxItem showStartEdgeArrow = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Start Edge Direction",
                option: new BooleanOption ("debug", "show-startedge-direction", false, Config.Default)
            );
            settingsMenu.Add (showStartEdgeArrow);

            string[] unprojectMethods = { "SelectedObject", "NearFarAverage" };
            DistinctOption unprojectOption = new DistinctOption ("debug", "unproject", unprojectMethods [0], unprojectMethods, Config.Default);
            ComboBox unprojectItem = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Unproject"
            );
            unprojectItem.AddEntries (unprojectOption);
            settingsMenu.Add (unprojectItem);

            /*
            CheckBoxItem shaderPascal = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Use Pascal's Shader",
                option: new BooleanOptionInfo ("video", "pascal-shader", false, Options.Default)
            );te
            settingsMenu.Add (shaderPascal);

            CheckBoxItem shaderCel = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Use Cel Shader",
                option: new BooleanOptionInfo ("video", "cel-shading", false, Options.Default)
            );
            settingsMenu.Add (shaderCel);
            */
        }