Exemplo n.º 1
0
        public Credits(Panel parent)
            : base(parent)
        {
            Visible = false;

            _lblMainText    = new Label(this, "" , ContentLoadAuto.Get<Credits, SpriteFont>("FontMain"));
            _lblFluffText   = new Label(this, "" , ContentLoadAuto.Get<Credits, SpriteFont>("FontFluff"));
            _lblFluffPrompt = new Label(this, "_", ContentLoadAuto.Get<Credits, SpriteFont>("FontFluff"));

            _lblFluffPrompt.ContentsEncompass();

            _tmrMainTextFade.Progression += perc   => { _lblMainText.Colour = _tmrMainTextFade.ValueCurrent; };
            _tmrMainTextFade.Completed   += active => { if (!active) EntryNext(); };
            _tmrNextEntry   .Trigger     += delay  => { _tmrMainTextFade.Active = false; };
            _tmrPromptFlash .Trigger     += delay  => { _lblFluffPrompt.Colour = (_lblFluffPrompt.Colour == Color.White) ? s_colBlackAlpha : Color.White; };

            parent.OnResize += () => Size = parent.Size;
                   OnResize += () => LayoutInvalidate();
            Size = parent.Size;
        }
Exemplo n.º 2
0
        public Menu(ViewRoot parent)
            : base(parent)
        {
            var families = ContentLoadAuto.Get<Menu, DMI>("Planet").Families;
            var planet = new PanelImage(this, families["planet"].Directions[0].Image(0));
            planet.Size = new Vector2(527, 495);
            planet.Position = new Vector2(50, 100);

            _pnlEntries = new PanelList(this);
            _lblTitle   = new Label(this, "Marooned", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia_big"));
            _pnlCredits = new Credits(this);

            /// \note Assume mono-spaced font.
            var btnNewGame = new ButtonLabel(_pnlEntries, "  New Game", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnOptions = new ButtonLabel(_pnlEntries, "Options ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnCredits = new ButtonLabel(_pnlEntries, "Credits ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnExit = new ButtonLabel(_pnlEntries, "Exit       ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));

            btnNewGame.ContentsEncompass(); btnNewGame.ColourHovered.ValueActive = Color.Orange;
            btnOptions.ContentsEncompass(); btnOptions.ColourHovered.ValueActive = Color.Orange;
            btnCredits.ContentsEncompass(); btnCredits.ColourHovered.ValueActive = Color.Orange;
            btnExit   .ContentsEncompass(); btnExit   .ColourHovered.ValueActive = Color.Red;

            btnOptions.InputEnabledMouse = false;

            _lblTitle.ContentsEncompass();
            _pnlEntries.Size = new Vector2(_pnlEntries.Select(p => p.Size.X).Max()
                                          ,_pnlEntries.Sum   (p => p.Size.Y));

            btnNewGame.OnClicked += (eButton) => { if (eButton != Buttons.A) return;
                                                   parent.Game = new GameInfo();
                                                   Visible = false; };
            btnExit   .OnClicked += (eButton) => { if (eButton != Buttons.A) return;
                                                   Marooned.Instance.Exit(); };
            btnCredits.OnClicked       += (eButton) => { ItsGameOverManGameOver(Credits.PlayType.GameOver); };
            btnCredits.OnClickedDouble += (eButton) => { ItsGameOverManGameOver(Credits.PlayType.Success ); };

                   OnResize += () => LayoutInvalidate();
            parent.OnResize += () => Size = parent.Size;

            OnVisibilityChanged += () => {
                if (Visible)
                {
                    CellActive = null;
                    if (parent.Game == null) return;
                    CellActive = parent.Game.World.ActiveCell;
                    parent.Game.World.ActiveCell = null;
                }
                else
                    parent.Game.World.ActiveCell = CellActive ?? parent.Game.World.ActiveCell;
            };

            OnInputKey += (eKey, bRelease) => {
                if (!bRelease          ) return;
                if (eKey != Keys.Escape) return;

                if (_pnlCredits.Play != Credits.PlayType.None)
                {
                    _pnlCredits.Play = Credits.PlayType.None;
                    return;
                }

                if (parent.Game == null) return;
                Visible = false;
            };
        }