Esempio n. 1
0
        protected override void Init()
        {
            font             = Content.Load <SpriteFont>("fonts/menu_font");
            blank            = Content.Load <Texture2D>("textures/blank");
            background       = new ImageItem(blank);
            background.HGrow = background.VGrow = 1;
            background.Color = Color.Black;
            background.Alpha = 0.3f;

            TextItem msg = new TextItem(font, message);

            msg.HAlign = HAlignment.Center;

            ListMenu menu = new ListMenu();

            menu.VAlign = VAlignment.Center;

            VPane vPane = new VPane(msg, menu);

            vPane.HAlign = HAlignment.Center;
            vPane.VGrow  = 1;

            ImageItem vpBack = new ImageItem(blank);

            vpBack.HGrow = vpBack.VGrow = 1;
            vpBack.Color = Color.Black;
            vpBack.Alpha = 0.3f;

            StackPane sPane = new StackPane(vpBack, vPane);

            sPane.VAlign = VAlignment.Center;
            sPane.VGrow  = 0.2f;
            sPane.HGrow  = 1;

            responds.ForEach(respond => {
                if (respond != responds[0])
                {
                    MenuItem gap   = new MenuItem("   ", font);
                    gap.IsDisabled = true;
                    menu.AddItem(gap);
                }

                MenuItem item = new MenuItem(respond.Text, font);
                menu.AddItem(item);

                item.FocusGain += (s, a) => item.TextItem.Color = Color.Yellow;
                item.FocusLoss += (s, a) => item.TextItem.Color = Color.White;
                item.Action    += (s, a) => {
                    action = respond.Action;
                    Close();
                };
            });

            ViewPane.Clear();
            RootPane       = new StackPane(background, sPane);
            RootPane.HGrow = RootPane.VGrow = 1;
            ViewPane.Add(RootPane);
        }
Esempio n. 2
0
        protected override void Init()
        {
            revealedTextures = new Texture2D[10];
            hiddenTexture    = Content.Load <Texture2D>("textures/tile_hid_0");
            font             = Content.Load <SpriteFont>("fonts/menu_font");
            blank            = Content.Load <Texture2D>("textures/blank");

            for (int i = 0; i < 10; ++i)
            {
                revealedTextures[i] = Content.Load <Texture2D>("textures/tile_rev_" + i);
            }

            ElapsedTime = new TimeSpan();
            itemMap     = new Dictionary <MenuItem, Point>();
            Map         = new GameMap(mapTemplate.Width, mapTemplate.Height, mapTemplate.Density);

            HPane mapPane = new HPane();

            mapPane.HAlign = HAlignment.Center;
            mapPane.VAlign = VAlignment.Center;
            mapPane.HGrow  = Width / (float)Graphics.Viewport.Width;
            mapPane.VGrow  = Height / (float)Graphics.Viewport.Height;

            StackPane sPane = new StackPane(mapPane);

            sPane.HGrow = sPane.VGrow = 1;

            InfoPane iPane = new InfoPane(Map, Game, font, blank);

            iPane.HAlign = HAlignment.Center;
            iPane.HGrow  = 0.5f;

            ImageItem iBack = new ImageItem(blank);

            iBack.HGrow = iBack.VGrow = 1;
            iBack.Color = Color.Black;
            iBack.Alpha = 0.42f;

            StackPane iStack = new StackPane(iBack, iPane);

            iStack.HGrow = 1;

            VPane vPane = new VPane(iStack, sPane);

            vPane.HGrow = vPane.VGrow = 1;

            ImageItem backItem = new ImageItem(Parent.Background);

            backItem.HGrow = backItem.VGrow = 1;

            StackPane sBack = new StackPane(backItem, vPane);

            sBack.HGrow = sBack.VGrow = 1;

            InitMapPane(mapPane);
            ViewPane.Clear();
            ViewPane.Add(RootPane = sBack);
        }
Esempio n. 3
0
        protected override void Init()
        {
            font             = Content.Load <SpriteFont>("fonts/menu_font");
            blank            = Content.Load <Texture2D>("textures/blank");
            background       = new ImageItem(blank);
            background.HGrow = background.VGrow = 1;
            background.Color = Color.Black;
            background.Alpha = 0.5f;

            TextItem gameOver = new TextItem(font, "Game Over");

            gameOver.HAlign       = HAlignment.Center;
            gameOver.VAlign       = VAlignment.Center;
            gameOver.IsSizeScaled = true;
            gameOver.Scale        = 2;

            HPane hGameOver = new HPane(gameOver);

            hGameOver.HGrow = hGameOver.VGrow = 1;

            ImageItem bTop = new ImageItem(blank);

            bTop.HGrow = bTop.VGrow = 1;
            bTop.Color = Color.DarkGray;
            bTop.Alpha = 0.5f;

            ImageItem bBot = new ImageItem(blank);

            bBot.HGrow = bBot.VGrow = 1;
            bBot.Color = Color.Black;
            bBot.Alpha = 0.5f;

            StackPane sTop = new StackPane(bTop, hGameOver);

            sTop.VAlign = VAlignment.Center;
            sTop.HAlign = HAlignment.Center;
            sTop.HGrow  = 0.5f;
            sTop.VGrow  = 1;

            mainPane        = new StackPane(bBot);
            mainPane.HAlign = HAlignment.Center;
            mainPane.VAlign = VAlignment.Center;
            mainPane.HGrow  = 0.5f;
            mainPane.VGrow  = 1;

            VPane vPane = new VPane(sTop, mainPane);

            vPane.HGrow = vPane.VGrow = 1;

            ViewPane.Clear();
            RootPane       = new StackPane(background, vPane);
            RootPane.HGrow = RootPane.VGrow = 1;
            ViewPane.Add(RootPane);

            Task.Run(() => {
                Game.Scores = FileManager.LoadHighscores(Game.ScoresPath);
                int pos     = Game.AddHighscore(score, out kicked);

                if (score.MinesHit < score.TotalMines &&
                    pos <= Minestory.MAX_SCORES_PER_DIFF)
                {
                    message = "New Highscore! Rank " + pos + ". Enter your Name:";
                    mainPane.Add(CreateTextInputPane(message));
                }
                else
                {
                    mainPane.Add(CreateNavPane());
                }
            });
        }
Esempio n. 4
0
        protected override void Init()
        {
            Background     = Content.Load <Texture2D>("textures/home_back");
            banner         = Content.Load <Texture2D>("textures/banner");
            font           = Content.Load <SpriteFont>("fonts/menu_font");
            backItem       = new ImageItem(Background);
            backItem.HGrow = backItem.VGrow = 1;

            MenuItem start     = new MenuItem("Start Game", font);
            MenuItem highscore = new MenuItem("Highscores", font);
            MenuItem settings  = new MenuItem("Settings", font);
            MenuItem quit      = new MenuItem("Quit", font);

            start.FocusGain     += (s, a) => start.TextItem.Color = Color.Yellow;
            settings.FocusGain  += (s, a) => settings.TextItem.Color = Color.Yellow;
            highscore.FocusGain += (s, a) => highscore.TextItem.Color = Color.Yellow;
            quit.FocusGain      += (s, a) => quit.TextItem.Color = Color.Yellow;

            start.FocusLoss     += (s, a) => start.TextItem.Color = Color.White;
            settings.FocusLoss  += (s, a) => settings.TextItem.Color = Color.White;
            highscore.FocusLoss += (s, a) => highscore.TextItem.Color = Color.White;
            quit.FocusLoss      += (s, a) => quit.TextItem.Color = Color.White;

            // ListMenu menu = new ListMenu(start, settings, highscore, quit); // TODO fix ctor
            ListMenu menu = new ListMenu();

            menu.ItemsOrientation = Orientation.Vertical;
            menu.VAlign           = VAlignment.Top;
            menu.AddItem(start);
            menu.AddItem(highscore);
            menu.AddItem(settings);
            menu.AddItem(quit);

            HPane menuPane = new HPane(menu);

            menuPane.HAlign = HAlignment.Center;
            menuPane.VGrow  = 1;

            ImageItem bannerItem = new ImageItem(banner, 400, 200);

            bannerItem.VAlign = VAlignment.Center;
            bannerItem.HGrow  = 1;

            HPane bannerPane = new HPane(bannerItem);

            bannerPane.HGrow = bannerPane.VGrow = 1;

            VPane vPane = new VPane(bannerPane, menuPane);

            vPane.HAlign = HAlignment.Center;
            vPane.HGrow  = 0.8f;
            vPane.VGrow  = 1;

            ViewPane.Clear();
            RootPane       = new StackPane(backItem, vPane);
            RootPane.HGrow = RootPane.VGrow = 1;
            ViewPane.Add(RootPane);

            start.Action += (s, a) => {
                Manager.Add(Game.CreateMapView(this));
                Hide();
            };

            settings.Action += (s, a) => {
                Manager.Add(new SettingsView(this, Game));
                Hide();
            };

            highscore.Action += (s, a) => {
                Manager.Add(new HighscoreView(this, Game));
                Hide();
            };

            quit.Action += (s, a) => Close();
        }
Esempio n. 5
0
        protected override void Init()
        {
            arrRight = Content.Load <Texture2D>("textures/arrow_right");
            arrLeft  = Content.Load <Texture2D>("textures/arrow_left");
            font     = Content.Load <SpriteFont>("fonts/menu_font");
            blank    = Content.Load <Texture2D>("textures/blank");
            tabMap   = new Dictionary <MapDifficulty, TabPane>();
            selMap   = new Dictionary <MapDifficulty, int>();

            MenuItem leftDiff  = new MenuItem(arrLeft, 32, 32);
            MenuItem rightDiff = new MenuItem(arrRight, 32, 32);
            MenuItem leftPage  = new MenuItem(arrLeft, 32, 32);
            MenuItem rightPage = new MenuItem(arrRight, 32, 32);
            MenuItem back      = new MenuItem("Back", font);

            leftDiff.VAlign = rightDiff.VAlign = VAlignment.Center;
            leftDiff.HAlign = rightDiff.HAlign = HAlignment.Center;
            leftPage.VAlign = rightPage.VAlign = VAlignment.Center;
            leftPage.HAlign = rightPage.HAlign = HAlignment.Center;
            back.HAlign     = HAlignment.Center;
            back.VAlign     = VAlignment.Top;

            TextItem diff = new TextItem(font, "Difficulty: " + game.Settings.Difficulty);

            diff.HAlign = HAlignment.Center;
            diff.VAlign = VAlignment.Center;

            HPane hDiff = new HPane(diff);

            hDiff.HAlign = HAlignment.Center;
            hDiff.HGrow  = 0.4f;

            HPane hDiffArr = new HPane(leftDiff, hDiff, rightDiff);

            hDiffArr.HGrow = 1;

            tabMap.Add(MapDifficulty.Easy, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Easy).ToList()));
            tabMap.Add(MapDifficulty.Medium, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Medium).ToList()));
            tabMap.Add(MapDifficulty.Hard, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Hard).ToList()));
            tabMap.Add(MapDifficulty.Custom, CreateScoresPane(game.Scores.Where(s => s.Difficulty == MapDifficulty.Custom).ToList()));

            TabPane tPane = new TabPane(
                tabMap[MapDifficulty.Easy],
                tabMap[MapDifficulty.Medium],
                tabMap[MapDifficulty.Hard],
                tabMap[MapDifficulty.Custom]);

            ImageItem tBack = new ImageItem(blank);

            tBack.HGrow = tBack.VGrow = 1;
            tBack.Color = Color.Black;
            tBack.Alpha = 0.42f;

            StackPane sPane = new StackPane(tBack, tPane);

            sPane.HAlign = HAlignment.Center;
            sPane.HGrow  = sPane.VGrow = 1;
            tPane.HGrow  = tPane.VGrow = 1;

            HPane hPane = new HPane(leftPage, sPane, rightPage);

            hPane.HAlign = HAlignment.Center;
            hPane.HGrow  = hPane.VGrow = 1;

            VPane vPane = new VPane(hDiffArr, hPane, back);

            vPane.HGrow = vPane.VGrow = 1;

            ImageItem backItem = new ImageItem(Parent.Background);

            backItem.HGrow = backItem.VGrow = 1;

            ViewPane.Clear();
            RootPane       = new StackPane(backItem, vPane);
            RootPane.HGrow = RootPane.VGrow = 1;
            ViewPane.Add(RootPane);

            leftDiff.FocusGain  += (s, a) => leftDiff.ImageItem.Color = Color.Yellow;
            leftDiff.FocusLoss  += (s, a) => leftDiff.ImageItem.Color = Color.White;
            rightDiff.FocusGain += (s, a) => rightDiff.ImageItem.Color = Color.Yellow;
            rightDiff.FocusLoss += (s, a) => rightDiff.ImageItem.Color = Color.White;

            leftPage.FocusGain  += (s, a) => leftPage.ImageItem.Color = Color.Yellow;
            leftPage.FocusLoss  += (s, a) => leftPage.ImageItem.Color = Color.White;
            rightPage.FocusGain += (s, a) => rightPage.ImageItem.Color = Color.Yellow;
            rightPage.FocusLoss += (s, a) => rightPage.ImageItem.Color = Color.White;

            MapDifficulty selectedDiff = game.Settings.Difficulty;

            for (int i = 0; i < (int)selectedDiff; ++i)
            {
                tPane.NextTab();
            }

            leftDiff.IsDisabled  = (int)(selectedDiff) == 0;
            rightDiff.IsDisabled = (int)(selectedDiff) == 3;
            UpdateArrow(leftDiff);
            UpdateArrow(rightDiff);

            leftDiff.Action += (s, a) => {
                if (tPane.PrevTab())
                {
                    --selectedDiff;
                }
                leftDiff.IsDisabled  = (int)(selectedDiff) == 0;
                rightDiff.IsDisabled = (int)(selectedDiff) == 3;
                diff.Text            = "Difficulty: " + (MapDifficulty)selectedDiff;
                UpdateArrow(leftDiff);
                UpdateArrow(rightDiff);

                int sel = selMap[selectedDiff];
                rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1;
                leftPage.IsDisabled  = sel <= 0;
                UpdateArrow(leftPage);
                UpdateArrow(rightPage);
            };

            rightDiff.Action += (s, a) => {
                if (tPane.NextTab())
                {
                    ++selectedDiff;
                }
                leftDiff.IsDisabled  = (int)(selectedDiff) == 0;
                rightDiff.IsDisabled = (int)(selectedDiff) == 3;
                diff.Text            = "Difficulty: " + (MapDifficulty)selectedDiff;
                UpdateArrow(leftDiff);
                UpdateArrow(rightDiff);

                int sel = selMap[selectedDiff];
                rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1;
                leftPage.IsDisabled  = sel <= 0;
                UpdateArrow(leftPage);
                UpdateArrow(rightPage);
            };

            leftPage.IsDisabled = true;
            if (PageCount(selectedDiff) < 2)
            {
                rightPage.IsDisabled = true;
            }
            UpdateArrow(leftPage);
            UpdateArrow(rightPage);

            selMap.Add(MapDifficulty.Easy, 0);
            selMap.Add(MapDifficulty.Medium, 0);
            selMap.Add(MapDifficulty.Hard, 0);
            selMap.Add(MapDifficulty.Custom, 0);

            leftPage.Action += (s, a) => {
                int sel = (selMap[selectedDiff] = Math.Max(0, selMap[selectedDiff] - 1));
                rightPage.IsDisabled = sel >= PageCount(selectedDiff) - 1;
                leftPage.IsDisabled  = sel <= 0;
                tabMap[selectedDiff].PrevTab();
                UpdateArrow(leftPage);
                UpdateArrow(rightPage);
            };

            rightPage.Action += (s, a) => {
                int pc  = PageCount(selectedDiff);
                int sel = (selMap[selectedDiff] = Math.Min(pc - 1, selMap[selectedDiff] + 1));
                rightPage.IsDisabled = sel >= pc - 1;
                leftPage.IsDisabled  = sel <= 0;
                tabMap[selectedDiff].NextTab();
                UpdateArrow(leftPage);
                UpdateArrow(rightPage);
            };

            back.FocusGain += (s, a) => back.TextItem.Color = Color.Yellow;
            back.FocusLoss += (s, a) => back.TextItem.Color = Color.White;
            back.Action    += (s, a) => Close();
        }