Inheritance: Container, IMouseClickEventListener, IMouseMoveEventListener, IMouseScrollEventListener
Example #1
0
        /// <summary>
        /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt.
        /// Zudem ist die Angabe der Zeichenreihenfolge Pflicht.
        /// </summary>
        public ComboBox(IScreen screen, DisplayLayer drawOrder, string text)
            : base(screen, drawOrder, String.Empty)
        {
            dropdown = new Menu (screen: screen, drawOrder: Index + DisplayLayer.Menu);
            dropdown.Bounds.Position = ValueBounds.Position;
            dropdown.Bounds.Size = new ScreenPoint (Screen, () => ValueBounds.Size.OnlyX + ValueBounds.Size.OnlyY * 10);
            dropdown.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; // (s) => Container.ItemForegroundColor (s);
            dropdown.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; // (s) => Design.WidgetBackground;
            dropdown.BackgroundColorFunc = (s) => Design.WidgetBackground;
            dropdown.ItemAlignX = HorizontalAlignment.Left;
            dropdown.ItemAlignY = VerticalAlignment.Center;
            dropdown.IsVisible = false;
            dropdownBorder = new Border (
                screen: screen,
                drawOrder: Index + DisplayLayer.Menu,
                widget: dropdown,
                lineWidth: 2,
                padding: 2
            );

            currentValue = new InputItem (screen: screen, drawOrder: Index, text: text, inputText: String.Empty);
            currentValue.Bounds = Bounds;
            currentValue.ForegroundColorFunc = (s) => ForegroundColor;
            currentValue.BackgroundColorFunc = (s) => Color.Transparent;
            currentValue.IsVisible = IsVisible;
            currentValue.IsMouseClickEventEnabled = false;

            ValidKeys.Add (Keys.Escape);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public ChallengePauseDialog(IScreen screen, DisplayLayer drawOrder)
            : base(screen, drawOrder, "Pause")
        {
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;

            Bounds.Size = new ScreenPoint (screen, 0.3f, 0.31f);
            // Erstelle das Pause-Menü
            pauseMenu = new Menu (Screen, Index + DisplayLayer.Menu);
            pauseMenu.Bounds = ContentBounds;

            pauseMenu.ItemAlignX = HorizontalAlignment.Left;
            pauseMenu.ItemAlignY = VerticalAlignment.Center;

            MenuEntry settingsButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Settings",
            onClick: (time) => {
                Close (time);
                Screen.NextScreen = new GeneralSettingsScreen (Screen.Game);
            }
            );
            MenuEntry backButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Back to Game",
            onClick: (time) => {
                Close (time);
            }
            );

            backButton.AddKey (Keys.Escape);
            MenuEntry discardExitButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Abort Challenge",
            onClick: (time) => {
                Close (time);
                Screen.NextScreen = new StartScreen (Screen.Game);
            }
            );
            backButton.AddKey (Keys.Escape);

            pauseMenu.Add (settingsButton);
            pauseMenu.Add (backButton);
            pauseMenu.Add (discardExitButton);
        }
Example #3
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;
        }
Example #4
0
        /// <summary>
        /// Erstelle einen neuen TextInputDialog.
        /// </summary>
        public TextInputDialog(IScreen screen, DisplayLayer drawOrder, string title, string text, string inputText)
            : base(screen, drawOrder, title)
        {
            textItem = new TextItem (screen, drawOrder, String.Empty);

            Cancel = (time) => {
                Close (time);
            };
            Submit = (time) => {
                Close (time);
            };

            Bounds.Size = new ScreenPoint (screen, 0.5f, 0.3f);
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;
            menu = new Menu (Screen, Index + DisplayLayer.Menu);
            menu.Bounds = ContentBounds;
            menu.Bounds.Padding = new ScreenPoint (screen, 0.010f, 0.019f);
            menu.ItemAlignX = HorizontalAlignment.Left;
            menu.ItemAlignY = VerticalAlignment.Center;

            //die Texteingabe
            textInput = new InputItem (Screen, Index + DisplayLayer.MenuItem, text, inputText);
            menu.Add (textInput);
            menu.Add (textItem);
            textInput.IsEnabled = true;
            textInput.IsInputEnabled = true;
            textInput.NameWidth = 0.35f;
            textInput.ValueWidth = 0.65f;

            ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape });
        }
Example #5
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public VisualTestsScreen(GameCore game)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromLeft (0.60f));

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

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

            // 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[] validEdgeCounts = new float[] { 500, 1000, 2000, 3000, 4000, 5000, 7500, 10000, 15000 };
            optionEdgeCount = new FloatOption (
                section: "visualtests",
                name: "edgecount",
                defaultValue: validEdgeCounts.At (0),
                validValues: validEdgeCounts,
                configFile: Config.Default
            ) { Verbose = false };
            optionEdgeCount.Value = validEdgeCounts.At (0);
            itemEdgeCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Edges:"
            );
            itemEdgeCount.AddEntries (optionEdgeCount);
            itemEdgeCount.ValueChanged += OnEdgeCountChanged;

            itemDisplayTime = new InputItem (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Time:",
                inputText: ""
            );

            itemFPS = new InputItem (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "FPS:",
                inputText: ""
            );

            OnEdgeCountChanged (null);
        }
Example #6
0
        /// <summary>
        /// Erzeugt ein neues CreativeLoadScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public CreativeLoadScreen(GameCore game)
            : base(game)
        {
            savegameMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            savegameMenu.Bounds.Position = ScreenContentBounds.Position;
            savegameMenu.Bounds.Size = new ScreenPoint (this, 0.300f, ScreenContentBounds.Size.Relative.Y);
            savegameMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            savegameMenu.ItemAlignX = HorizontalAlignment.Left;
            savegameMenu.ItemAlignY = VerticalAlignment.Center;
            savegameMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            savegameMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            savegameMenu.RelativeItemHeight = Design.DataItemHeight;

            lines.AddPoints (.000f, .050f, .030f, .970f, .620f, .895f, .740f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f);

            title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Load Knot");
            title.Bounds.Position = ScreenTitleBounds.Position;
            title.Bounds.Size = ScreenTitleBounds.Size;
            title.ForegroundColorFunc = (s) => Color.White;

            infoTitle = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Knot Info:");
            infoTitle.Bounds.Position = new ScreenPoint (this, 0.45f, 0.62f);
            infoTitle.Bounds.Size = new ScreenPoint (this, 0.900f, 0.050f);
            infoTitle.ForegroundColorFunc = (s) => Color.White;

            knotInfo = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            knotInfo.Bounds.Position = new ScreenPoint (this, 0.47f, 0.70f);
            knotInfo.Bounds.Size = new ScreenPoint (this, 0.300f, 0.500f);
            knotInfo.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            knotInfo.ItemAlignX = HorizontalAlignment.Left;
            knotInfo.ItemAlignY = VerticalAlignment.Center;

            // Erstelle einen Parser für das Dateiformat
            KnotFileIO fileFormat = new KnotFileIO ();
            // Erstelle einen Spielstand-Loader
            loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots");

            // Preview
            Bounds previewBounds = new Bounds (this, 0.45f, 0.1f, 0.48f, 0.5f);
            previewWorld = new World (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.GameWorld,
                bounds: previewBounds
            );
            previewRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            previewWorld.Add (previewRenderer);
            previewBorder = new Border (
                screen: this,
                drawOrder: DisplayLayer.GameWorld,
                bounds: previewBounds,
                lineWidth: 2,
                padding: 0
            );
            previewInput = new KnotInputHandler (screen: this, world: previewWorld);
            previewMouseHandler = new ModelMouseHandler (screen: this, world: previewWorld);

            backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is CreativeLoadScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);
            backButton.AlignX = HorizontalAlignment.Center;

            startButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Load",
                onClick: (time) => NextScreen = new CreativeModeScreen (game: Game, knot: loader.FileFormat.Load (previewKnotMetaData.Filename))
            );
            startButton.IsVisible = false;
            startButton.AddKey (Keys.Enter);
            startButton.SetCoordinates (left: 0.630f, top: 0.910f, right: 0.730f, bottom: 0.960f);
            startButton.AlignX = HorizontalAlignment.Center;
        }
        /// <summary>
        /// Erzeugt eine neue Instanz eines ChallengeCreateScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game.
        /// </summary>
        public ChallengeCreateScreen(GameCore game)
            : base(game)
        {
            startKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            startKnotMenu.Bounds = ScreenContentBounds.FromLeft (0.47f).FromTop (0.98f);
            startKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            startKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            startKnotMenu.RelativeItemHeight = Design.DataItemHeight;

            targetKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            targetKnotMenu.Bounds = ScreenContentBounds.FromRight (0.47f).FromTop (0.98f);
            targetKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            targetKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            targetKnotMenu.RelativeItemHeight = Design.DataItemHeight;

            challengeName = new InputItem (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, "Name:", String.Empty);
            challengeName.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.Size.OnlyY + new ScreenPoint (this, 0f, 0.050f);
            challengeName.Bounds.Size = new ScreenPoint (this, 0.375f, 0.040f);
            challengeName.OnValueChanged += () => TryConstructChallenge ();
            challengeName.NameWidth = 0.2f;
            challengeName.ValueWidth = 0.8f;

            createButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Create!",
                onClick: OnCreateChallenge
            );
            createButton.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.FromLeft (0.50f).Size + new ScreenPoint (this, 0f, 0.050f);
            createButton.Bounds.Size = new ScreenPoint (this, 0.125f, 0.050f);

            createButtonBorder = new Border (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, createButton, 4, 4);
            createButton.AlignX = HorizontalAlignment.Center;

            startKnotMenu.Bounds.Padding = targetKnotMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            startKnotMenu.ItemAlignX = targetKnotMenu.ItemAlignX = HorizontalAlignment.Left;
            startKnotMenu.ItemAlignY = targetKnotMenu.ItemAlignY = VerticalAlignment.Center;

            lines.AddPoints (.000f, .050f, .030f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f);

            title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Create Challenge");
            title.Bounds.Position = ScreenTitleBounds.Position;
            title.Bounds.Size = ScreenTitleBounds.Size;
            title.ForegroundColorFunc = (s) => Color.White;

            // Erstelle einen Parser für das Dateiformat
            KnotFileIO fileFormat = new KnotFileIO ();
            // Erstelle einen Spielstand-Loader
            loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots");

            backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is ChallengeCreateScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);

            backButton.AlignX = HorizontalAlignment.Center;
        }
Example #8
0
        public SettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Settings";

            spriteBatch = new SpriteBatch (GraphicsDevice);

            navigationMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            navigationMenu.Bounds.Position = ScreenContentBounds.Position;
            navigationMenu.Bounds.Size = new ScreenPoint (this, 0.200f, ScreenContentBounds.Size.Relative.Y);
            navigationMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            navigationMenu.ItemAlignX = HorizontalAlignment.Left;
            navigationMenu.ItemAlignY = VerticalAlignment.Center;

            MenuEntry profileButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "General",
            onClick: (time) => {
                game.SkipNextScreenEffect =true;
                NextScreen = new GeneralSettingsScreen (Game);
            }
            );
            MenuEntry graphicsButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Graphics",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new GraphicsSettingsScreen (Game);
            }
            );
            MenuEntry audioButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Audio",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new AudioSettingsScreen (Game);
            }
            );
            MenuEntry controlsButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Controls",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new ControlSettingsScreen (Game);
            }
            );

            navigationMenu.Add (profileButton);
            navigationMenu.Add (graphicsButton);
            navigationMenu.Add (audioButton);
            navigationMenu.Add (controlsButton);

            initalizeDebugButton ();

            lines.AddPoints (0.000f, 0.050f,
                             0.030f, 0.970f,
                             0.760f, 0.895f,
                             0.880f, 0.970f,
                             0.970f, 0.050f,
                             1.000f
                            );

            backButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is SettingsScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);
            backButton.AlignX = HorizontalAlignment.Center;

            // this menu contains the actual settings and is filled in the subclasses
            settingsMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            settingsMenu.Bounds.Position = ScreenContentBounds.Position + navigationMenu.Bounds.Size.OnlyX;
            settingsMenu.Bounds.Size = ScreenContentBounds.Size - navigationMenu.Bounds.Size.OnlyX;;
            settingsMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            settingsMenu.ItemAlignX = HorizontalAlignment.Left;
            settingsMenu.ItemAlignY = VerticalAlignment.Center;
            settingsMenu.RelativeItemHeight = Design.DataItemHeight;
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        public HighscoreDialog(IScreen screen, DisplayLayer drawOrder, Challenge challenge)
            : base(screen, drawOrder, "Highscores")
        {
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;
            Bounds.Size = new ScreenPoint (screen, 0.60f, 0.5f);

            // Erstelle das Highscore-Menü
            highscoreList = new Menu (Screen, Index + DisplayLayer.Menu);
            highscoreList.Bounds = ContentBounds;
            highscoreList.ItemAlignX = HorizontalAlignment.Left;
            highscoreList.ItemAlignY = VerticalAlignment.Center;

            if (challenge.Highscore != null) {
                //sotiert die Highscoreliste wird nach der Zeit sotiert
                int highscoreCounter = 0;
                foreach (KeyValuePair<string, int> entry in challenge.Highscore.OrderBy (key => key.Value)) {
                    TimeSpan playTime = TimeSpan.FromSeconds (entry.Value);
                    string formattedPlayTime = (playTime.Hours * 60 + playTime.Minutes).ToString ("D2") + "m " + playTime.Seconds.ToString ("D2") + "s";

                    TextItem firstScore = new TextItem (screen, drawOrder, formattedPlayTime + "    " + entry.Key);
                    highscoreList.Add (firstScore);
                    highscoreCounter++;
                    if (highscoreCounter > 8) {
                        break;
                    }
                }
            }

            buttons = new Container (screen, Index + DisplayLayer.Menu);
            buttons.ItemBackgroundColor =(s) => Design.DialogBackground;
            buttons.ItemAlignX = HorizontalAlignment.Center;

            // Button zum Neustarten der Challenge
            Action<GameTime> restartAction = (time) => {
                Close (time);
                Screen.NextScreen = new ChallengeModeScreen (Screen.Game, challenge);
            };
            MenuEntry restartButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Restart challenge",
                onClick: restartAction
            );
            restartButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
            restartButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                            - restartButton.Bounds.Size.OnlyY;
            buttons.Add (restartButton);

            // Button für die Rückkehr zum StartScreen
            Action<GameTime> returnAction = (time) => {
                Close (time);
                Screen.NextScreen = new StartScreen (Screen.Game);
            };
            MenuEntry returnButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Return to menu",
                onClick: returnAction
            );
            returnButton.Bounds.Size = new ScreenPoint (screen, ContentBounds.Size.Relative.X / 2, 0.05f);
            returnButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - returnButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
            buttons.Add (returnButton);
        }
Example #10
0
        /// <summary>
        /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt.
        /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht.
        /// [base=screen, drawOrder, title, text]
        /// </summary>
        public ConfirmDialog(IScreen screen, DisplayLayer drawOrder, string title)
            : base(screen, drawOrder, title)
        {
            // Der Titel-Text ist mittig ausgerichtet
            AlignX = HorizontalAlignment.Center;

            Cancel = (time) => {
                Close (time);
            };
            Submit = (time) => {
                Close (time);
            };

            // Keys
            ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape });

            // Menü, in dem die Textanzeige angezeigt wird
            menu = new Menu (Screen, Index + DisplayLayer.Menu);
            menu.Bounds = ContentBounds;
            menu.ItemForegroundColor = (s) => Color.White;
            menu.ItemBackgroundColor = (s) => Color.Transparent;
            menu.ItemAlignX = HorizontalAlignment.Left;
            menu.ItemAlignY = VerticalAlignment.Center;

            // Button-Container
            buttons = new Container (screen, Index + DisplayLayer.Menu);
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemBackgroundColor = (s) => Design.DialogBackground;

            // Button zum Canceln
            Action<GameTime> cancelAction = (time) => {
                Cancel (time);
            };
            MenuEntry cancelButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Cancel",
                onClick: cancelAction
            );
            cancelButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
            cancelButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - cancelButton.Bounds.Size.OnlyY;
            buttons.Add (cancelButton);

            // Button zum Submitten
            Action<GameTime> submitAction = (time) => {
                Submit (time);
            };
            MenuEntry submitButton = new MenuEntry (
                screen: Screen,
                drawOrder: Index + DisplayLayer.MenuItem,
                name: "Confirm",
                onClick: submitAction
            );
            submitButton.Bounds.Size = new ScreenPoint (screen, ()=>ContentBounds.Size.Relative.X / 2, ()=>0.05f);
            submitButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY
                                           - submitButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2;
            buttons.Add (submitButton);

            // Buttons zum Menü hinzufügen
            menu.Add (buttons);
        }