示例#1
0
 private void _OrientHorizontal(bool reverse = false)
 {
     for (int i = 0; i < Items.Count; ++i)
     {
         HPane.Add(Items[reverse ? Items.Count - 1 - i : i]);
     }
 }
示例#2
0
        public MapObjectInfoPane(Cursor cursor)
        {
            VPane vpMain = new VPane();

            vpMain.PercentWidth = vpMain.PercentHeight = 100;
            vpMain.PPSFactor    = 1000;

            MapCursor = cursor;
            tiType    = new TextItem("", "fonts/game_font1");
            tiLife    = new TextItem("", "fonts/game_font1");
            tiInfo    = new TextItem("", "fonts/game_font1");
            textItems = new TextItem[] { tiType, tiLife, tiInfo };

            foreach (TextItem ti in textItems)
            {
                HPane gapL = new HPane();
                HPane cent = new HPane(gapL, ti);
                ti.HAlignment     = HAlignment.Left;
                ti.DefaultScale   = 0.5f;
                ti.PPSFactor      = 1000;
                cent.PercentWidth = 100;
                gapL.PercentWidth = 5;
                gapL.HAlignment   = HAlignment.Left;
                vpMain.add(cent);
            }

            add(vpMain);
        }
示例#3
0
        public DebugPane()
        {
            PercentWidth = 40;
            HAlignment   = HAlignment.Left;
            VAlignment   = VAlignment.Top;

            TextItem[] valueTextItems =
            {
                fpsText         = new TextItem("", "fonts/menu_font1"),
                slaveXText      = new TextItem("", "fonts/menu_font1"),
                slaveYText      = new TextItem("", "fonts/menu_font1"),
                mapWidthText    = new TextItem("", "fonts/menu_font1"),
                mapHeightText   = new TextItem("", "fonts/menu_font1"),
                entitiesText    = new TextItem("", "fonts/menu_font1"),
                projectilesText = new TextItem("", "fonts/menu_font1"),
                animationsText  = new TextItem("", "fonts/menu_font1")
            };

            TextItem[] titleTextItems =
            {
                new TextItem("FPS: ",         "fonts/menu_font1"),
                new TextItem("Slave X: ",     "fonts/menu_font1"),
                new TextItem("Slave Y: ",     "fonts/menu_font1"),
                new TextItem("Map Width: ",   "fonts/menu_font1"),
                new TextItem("Map Height",    "fonts/menu_font1"),
                new TextItem("Entities: ",    "fonts/menu_font1"),
                new TextItem("Projectiles: ", "fonts/menu_font1"),
                new TextItem("Animations: ",  "fonts/menu_font1")
            };

            for (int i = 0; i < valueTextItems.Length; ++i)
            {
                HPane leftPad = new HPane();
                HPane title   = new HPane(titleTextItems[i]);
                HPane value   = new HPane(valueTextItems[i]);
                HPane row     = new HPane(leftPad, title, value);

                leftPad.HAlignment = HAlignment.Left;
                title.HAlignment   = HAlignment.Left;
                value.HAlignment   = HAlignment.Left;

                titleTextItems[i].HAlignment   = HAlignment.Left;
                valueTextItems[i].HAlignment   = HAlignment.Left;
                titleTextItems[i].DefaultScale = 0.5f;
                valueTextItems[i].DefaultScale = 0.5f;
                titleTextItems[i].Color        = Color.Black;
                valueTextItems[i].Color        = Color.Black;

                leftPad.PercentWidth = 5;
                title.PercentWidth   = 20;
                row.PercentWidth     = 100;
                row.EffectAlpha      = 0.7f;
                row.Color            = i % 2 == 0
                    ? Color.DarkGray
                    : Color.Gray;

                add(row);
            }
        }
示例#4
0
        private void InitMapPane(HPane mapPane)
        {
            int w = Width / Map.Tiles.Length;
            int h = Height / Map.Tiles[0].Length;

            for (int x = 0; x < Map.Tiles.Length; ++x)
            {
                ListMenu vList = new ListMenu();
                vList.ItemsOrientation = Orientation.Vertical;
                // vList.KeyBoardEnabled = false;
                mapPane.Add(vList);

                for (int y = 0; y < Map.Tiles[0].Length; ++y)
                {
                    MenuItem item = new MenuItem(hiddenTexture, w, h);
                    itemMap.Add(item, new Point(x, y));
                    vList.AddItem(item);

                    item.FocusGain += (s, a) => item.ImageItem.Color = Color.Silver;
                    item.FocusLoss += (s, a) => item.ImageItem.Color = Color.White;

                    item.Action += (s, a) => {
                        Point p = itemMap[item];

                        while (Map.RevealedTiles == 0 &&
                               Map.Tiles[p.X][p.Y].HasMine)
                        {
                            Map.ShuffleMines();
                        }

                        if (Map.RevealTile(p.X, p.Y))
                        {
                            Media.PlaySound(1);
                        }
                        else
                        {
                            Media.PlaySound(0);
                        }

                        if (IsGameOver())
                        {
                            Manager.Add(CreateGameOverView());
                            State = ViewState.Suspended;
                        }
                    };

                    Map.Tiles[x][y].Revealed += (s, a) => {
                        MapTile tile = (MapTile)s;
                        item.IsDisabled      = !tile.IsHidden;
                        item.ImageItem.Image = tile.IsHidden ? hiddenTexture
                            : tile.HasMine ? revealedTextures[9]
                            : revealedTextures[tile.GetMineCount()];

                        // TODO test
                        tile.GetNeighbours().ToList().ForEach(n => CutOutMine(n));
                    };
                }
            }
        }
示例#5
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);
        }
示例#6
0
        private TabPane CreateScoresPane(List <Highscore> scores)
        {
            int p = Int32.MaxValue;
            int i = 1;

            List <VPane> pages = new List <VPane>();
            VPane        page  = null;

            scores.ForEach(score => {
                if (p > EntriesPerPage)
                {
                    page       = new VPane();
                    page.HGrow = page.VGrow = 1;
                    pages.Add(page);
                    p = 1;
                }

                TextItem index = new TextItem(font, i.ToString("D3") + ": ");
                TextItem diff  = new TextItem(font, score.Difficulty.ToString());
                TextItem name  = new TextItem(font, score.Name);
                TextItem time  = new TextItem(font, score.Time.ToString(@"hh\:mm\:ss\.ff"));
                TextItem hits  = new TextItem(font, score.MinesHit.ToString("D2"));
                TextItem total = new TextItem(font, "/" + score.TotalMines.ToString("D2"));
                index.HAlign   = diff.HAlign = name.HAlign = time.HAlign = hits.HAlign = total.HAlign = HAlignment.Center;

                HPane hIndex = new HPane(index);
                HPane hDiff  = new HPane(diff);
                HPane hName  = new HPane(name);
                HPane hTime  = new HPane(time);
                HPane hHits  = new HPane(hits, total);
                hDiff.HGrow  = hName.HGrow = hTime.HGrow = hHits.HGrow = 2;
                hIndex.HGrow = 1;

                HPane hPane  = new HPane(hIndex, hDiff, hName, hTime, hHits);
                hPane.VAlign = VAlignment.Center;
                hPane.HGrow  = 1;
                page.Add(hPane);
                ++p;
                ++i;
            });

            TabPane tPane = new TabPane(pages.ToArray());

            tPane.HGrow = tPane.VGrow = 1;
            return(tPane);
        }
示例#7
0
        private LayoutPane CreateTextInputPane(string msg)
        {
            MenuItem  confirm   = new MenuItem("Confirm", font);
            TextItem  message   = new TextItem(font, msg);
            TextField textField = new TextField(Game.Window, font, blank);

            confirm.HAlign = message.HAlign = textField.HAlign = HAlignment.Center;
            confirm.VAlign = message.VAlign = textField.VAlign = VAlignment.Center;

            textField.TextAlignment = HAlignment.Center;
            textField.HGrow         = 0.8f;

            confirm.IsDisabled = textField.Text.Length < Minestory.MIN_NAME_LEN;
            confirm.Alpha      = confirm.IsDisabled ? 0.5f : 1;

            HPane hConfirm   = new HPane(confirm);
            HPane hMessage   = new HPane(message);
            HPane hTextField = new HPane(textField);
            VPane vPane      = new VPane(hMessage, hTextField, hConfirm);

            hConfirm.HGrow = hMessage.HGrow = hTextField.HGrow = 1;
            vPane.HAlign   = HAlignment.Center;
            vPane.VAlign   = VAlignment.Center;
            vPane.HGrow    = vPane.VGrow = 1;

            textField.TextInput += (s, a) => {
                confirm.IsDisabled = textField.Text.Length < Minestory.MIN_NAME_LEN;
                confirm.Alpha      = confirm.IsDisabled ? 0.5f : 1;

                int cx = (int)(confirm.X + confirm.Width / 2);
                int cy = (int)(confirm.Y + confirm.Height / 2);
                Mouse.SetPosition(cx, cy + (confirm.IsDisabled ? +1 : 0));  // forces focus gain

                if (textField.Text.Length > Minestory.MAX_NAME_LEN)
                {
                    textField.Text = textField.Text.Remove(Minestory.MAX_NAME_LEN);
                }
            };

            confirm.FocusGain += (s, a) => confirm.TextItem.Color = Color.Yellow;
            confirm.FocusLoss += (s, a) => confirm.TextItem.Color = Color.White;
            confirm.Action    += (s, a) => SaveScores(textField, vPane);

            return(vPane);
        }
示例#8
0
        private LayoutPane CreateNavPane()
        {
            MenuItem newGame  = new MenuItem("New Game", font);
            MenuItem mainMenu = new MenuItem("Main Menu", font);

            newGame.HAlign = mainMenu.HAlign = HAlignment.Center;

            HPane hNewGame  = new HPane(newGame);
            HPane hMainMenu = new HPane(mainMenu);

            hNewGame.VAlign = hMainMenu.VAlign = VAlignment.Center;
            hNewGame.HGrow  = hMainMenu.HGrow = 1;

            HPane hPane = new HPane(hNewGame, hMainMenu);

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

            newGame.FocusGain += (s, a) => newGame.TextItem.Color = Color.Yellow;
            newGame.FocusLoss += (s, a) => newGame.TextItem.Color = Color.White;

            mainMenu.FocusGain += (s, a) => mainMenu.TextItem.Color = Color.Yellow;
            mainMenu.FocusLoss += (s, a) => mainMenu.TextItem.Color = Color.White;

            newGame.Action += (s, a) => {
                Manager.Add(Game.CreateMapView(Parent.Parent));
                Parent.Close();
                Close();
            };

            mainMenu.Action += (s, a) => {
                Parent.Close();
                Close();
            };

            return(hPane);
        }
示例#9
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());
                }
            });
        }
示例#10
0
        public GameplaySettingsPane(GameConfig gameConfig)
        {
            hlLang = new HList();
            foreach (Language lang in GameConfig.SupportedLanguages)
            {
                hlLang.add(new TextItem(lang.Title, "fonts/menu_font1"));
            }

            VList vlNames    = new VList(new TextItem(gameConfig.Language.translate("Language"), "fonts/menu_font1"));
            VPane vpSettings = new VPane(hlLang);

            hlLang.VisibleRange = 2;

            vlNames.SelectedEvent += (sender, args)
                                     => hlLang.IsFocused = args.SelectedIndex == 0;

            vlNames.CancelEvent += (sender, args) => {
                hlLang.IsFocused = false;
                hide(0.5f);
            };

            hlLang.SelectedEvent += (sender, args)
                                    => gameConfig.Language = GameConfig.SupportedLanguages[args.SelectedIndex];

            Language[] langs = GameConfig.SupportedLanguages;
            int        index = langs.Length - 1;

            for (; index >= 0 && gameConfig.Language.ID != langs[index].ID; --index)
            {
                ;
            }
            hlLang.select(index < 0 ? 0 : index);
            hlLang.SelectedColor = Color.White;

            vlNames.PercentWidth  = 30;
            vlNames.PercentHeight = 100;
            vlNames.HAlignment    = HAlignment.Left;
            vlNames.EffectAlpha   = 0.5f;
            vlNames.Color         = Color.Black;

            vpSettings.PercentWidth  = 70;
            vpSettings.PercentHeight = 100;
            vpSettings.HAlignment    = HAlignment.Left;
            vpSettings.EffectAlpha   = 0.5f;
            vpSettings.Color         = Color.Gray;

            FocusRequestEvent += (s, a) => {
                vlNames.select(0);
                vlNames.IsFocused = true;
            };

            FocusLossEvent += (s, a) => {
                vlNames.IsFocused     = false;
                vlNames.SelectedIndex = -1;
            };

            HPane hpMain = new HPane(vlNames, vpSettings);

            hpMain.PercentWidth  = 100;
            hpMain.PercentHeight = 100;
            add(hpMain);
        }
示例#11
0
        public BattlePane(BattleManager battleManager)
        {
            BattleManager = battleManager;

            StackPane spMain = new StackPane();

            spMain.PercentWidth = spMain.PercentHeight = 100;
            PercentWidth        = PercentHeight = 100;

            hlThumbs               = new HList();
            hlThumbs.HAlignment    = HAlignment.Left;
            hlThumbs.VAlignment    = VAlignment.Top;
            hlThumbs.PercentWidth  = 15;
            hlThumbs.PercentHeight = 15;
            hlThumbs.VisibleRange  = 5;
            hlThumbs.Color         = Color.Black;
            hlThumbs.Alpha         = 0.5f;

            hpApCost              = new HPane();
            hpApCost.VAlignment   = VAlignment.Top;
            hpApCost.PercentWidth = 100;
            hpApCost.Color        = Color.Gray;
            hpApCost.Alpha        = 0.5f;

            vlSkills = new VList();
            vlSkills.PercentWidth = 100;
            vlSkills.VisibleRange = 3;
            vlSkills.IsStatic     = false;
            vlSkills.Color        = Color.Gray;
            vlSkills.Alpha        = 0.5f;

            skillPane            = new VPane(hpApCost, vlSkills);
            skillPane.HAlignment = HAlignment.Left;
            // skillPane.HAlignment = HAlignment.Left;
            // skillPane.VAlignment = VAlignment.Bottom;
            // skillPane.PercentWidth = 15;
            // skillPane.PercentHeight = 30;
            skillPane.PercentWidth  = 100;
            skillPane.PercentHeight = 100;
            skillPane.Color         = Color.Black;
            skillPane.Alpha         = 0.5f;

            teamInfo               = new TeamInfoPane();
            teamInfo.HAlignment    = HAlignment.Right;
            teamInfo.VAlignment    = VAlignment.Bottom;
            teamInfo.PercentWidth  = 40;
            teamInfo.PercentHeight = 20;
            teamInfo.Color         = Color.Black;
            teamInfo.Alpha         = 0.5f;

            objectInfo               = new MapObjectInfoPane();
            objectInfo.HAlignment    = HAlignment.Right;
            objectInfo.VAlignment    = VAlignment.Bottom;
            objectInfo.PercentWidth  = 25;
            objectInfo.PercentHeight = 20;
            objectInfo.Color         = Color.Black;
            objectInfo.Alpha         = 0.5f;

            abilityInfo            = new AbilityInfoPane();
            abilityInfo.HAlignment = HAlignment.Left;
            abilityInfo.VAlignment = VAlignment.Bottom;
            // abilityInfo.HAlignment = HAlignment.Center;
            // abilityInfo.VAlignment = VAlignment.Bottom;
            abilityInfo.Color = Color.Black;
            abilityInfo.Alpha = 0.5f;

            HPane hpSkills = new HPane(skillPane, abilityInfo);

            hpSkills.HAlignment    = HAlignment.Left;
            hpSkills.VAlignment    = VAlignment.Bottom;
            hpSkills.PercentWidth  = 15;
            hpSkills.PercentHeight = 30;

            vlSkills.ActionEvent += (sender, args) => {
                int s = args.SelectedIndex;

                if (player.ContainingMap.Slave is Cursor)
                {
                    if (s == 0)
                    {
                        if (moveCost > player.AP || moveCost <= 0)
                        {
                            return;
                        }

                        movePath = new Queue <Point>(pathCache);
                        moveCost = getMoveCost(player, movePath.Count);
                    }
                    else if (s > 0)
                    {
                        nextAbility = player.Abilities[s - 1];
                    }

                    vlSkills.ControlLock = false;
                    player.ContainingMap.hideCursor();
                    cursor.MoveStartedEvent -= onCursorMove;
                    objectInfo.hide();
                    abilityInfo.hide();
                    hideSkillList();
                    // teamInfo.show(); // TODO looks to busy
                }
                else
                {
                    int cost = s == 0 ? 10 : player.Abilities[s - 1].APCost; // TODO move cost
                    if (cost > player.AP)
                    {
                        return;
                    }

                    playerPF = new Pathfinder(player);
                    player.ContainingMap.showCursor(player.Position);
                    cursor = player.ContainingMap.Cursor;
                    cursor.MoveStartedEvent -= onCursorMove;
                    cursor.MoveStartedEvent += onCursorMove;
                    objectInfo.MapCursor     = cursor;
                    vlSkills.ControlLock     = true;
                    objectInfo.show();
                    teamInfo.hide();
                    abilityInfo.hide();
                }
            };

            vlSkills.CancelEvent += (sender, args) => {
                if (cursor == null)
                {
                    return;
                }
                vlSkills.ControlLock = false;
                player.ContainingMap.hideCursor();
                cursor.MoveStartedEvent -= onCursorMove;
                cursor = null;
                objectInfo.hide();
                teamInfo.show();
            };

            vlSkills.SelectedEvent += (sender, args) => {
                int sel = args.SelectedIndex;
                if (sel > 0)
                {
                    abilityInfo.Ability = player.Abilities[sel - 1];
                    abilityInfo.show();
                }
                else
                {
                    abilityInfo.hide();
                }
            };

            hlThumbs.SelectedEvent += (sender, args) => {
                int sel = args.SelectedIndex;
                int off = sel + hlThumbs.VisibleRange;
                if (off < hlThumbs.Children.Count)
                {
                    (hlThumbs.Children[off] as MenuItem).Disabled = false;
                }
            };

            // spMain.add(hlThumbs, skillPane, objectInfo, teamInfo, abilityInfo);
            spMain.add(hlThumbs, objectInfo, teamInfo, hpSkills);
            add(spMain);
            hide();
        }
示例#12
0
        public AudioSettingsPane(GameConfig gameConfig)
        {
            hlMusic = new HList(new TextItem("Off", "fonts/menu_font1"));
            hlSFX   = new HList(new TextItem("Off", "fonts/menu_font1"));

            for (int i = 10; i <= 100; i += 10)
            {
                hlMusic.add(new TextItem(" " + i.ToString() + " ", "fonts/menu_font1"));
                hlSFX.add(new TextItem(" " + i.ToString() + " ", "fonts/menu_font1"));
            }

            VList vlNames = new VList(
                new TextItem("Music Volume", "fonts/menu_font1"),
                new TextItem("Audio Volume", "fonts/menu_font1")
                );

            hlSFX.VisibleRange   = 4;
            hlMusic.VisibleRange = 4;
            VPane vpSettings = new VPane(hlMusic, hlSFX);

            vlNames.SelectedEvent += (sender, args) => {
                hlMusic.IsFocused = args.SelectedIndex == 0;
                hlSFX.IsFocused   = args.SelectedIndex == 1;
            };

            vlNames.CancelEvent += (sender, args) => {
                hlMusic.IsFocused = false;
                hlSFX.IsFocused   = false;
                vlNames.select(0);
                hide(0.5f);
            };

            hlMusic.SelectedEvent += (sender, args)
                                     => gameConfig.MusicVolume = args.SelectedIndex * 10;

            hlSFX.SelectedEvent += (sender, args)
                                   => gameConfig.SFXVolume = args.SelectedIndex * 10;

            hlMusic.select(gameConfig.MusicVolume / 10);
            hlSFX.select(gameConfig.SFXVolume / 10);
            hlMusic.SelectedColor = Color.White;
            hlSFX.SelectedColor   = Color.White;

            vlNames.PercentWidth  = 30;
            vlNames.PercentHeight = 100;
            vlNames.HAlignment    = HAlignment.Left;
            vlNames.EffectAlpha   = 0.5f;
            vlNames.Color         = Color.Black;

            vpSettings.PercentWidth  = 70;
            vpSettings.PercentHeight = 100;
            vpSettings.HAlignment    = HAlignment.Left;
            vpSettings.EffectAlpha   = 0.5f;
            vpSettings.Color         = Color.Gray;

            FocusRequestEvent += (s, a) => {
                vlNames.select(0);
                vlNames.IsFocused = true;
            };

            FocusLossEvent += (s, a) => {
                vlNames.IsFocused     = false;
                vlNames.SelectedIndex = -1;
            };

            HPane hpMain = new HPane(vlNames, vpSettings);

            hpMain.PercentWidth  = 100;
            hpMain.PercentHeight = 100;
            add(hpMain);
        }
示例#13
0
        public void initMainContainer()
        {
            VList vlSaves = new VList();

            vlSaves.PercentWidth = vlSaves.PercentHeight = 100;

            VPane vpMain = new VPane(vlSaves, inputInfoPane);

            vpMain.PercentWidth  = 50;
            vpMain.PercentHeight = 100;
            vpMain.Color         = Color.Black;
            vpMain.Alpha         = 0.5f;

            if (GameManager.SaveStates.Count < MAX_SAVES)
            {
                vlSaves.add(tiNewGame);
            }

            int i = 0;

            GameManager.SaveStates.Sort((s1, s2) => - DateTime.Compare(s1.SavedDate, s2.SavedDate));
            GameManager.SaveStates.ForEach(saveState => {
                TextItem saveInfo       = new TextItem("", "fonts/menu_font1");
                TextItem saveDetail     = new TextItem("", "fonts/menu_font2");
                ImageItem saveThumbnail = new ImageItem("images/world/entities/npcs/neutral/kevin_sheet", new Rectangle(0, 32, 16, 16));
                VPane textPane          = new VPane(saveInfo, saveDetail);
                HPane saveEntry         = new HPane(saveThumbnail, textPane);
                saveEntry.PercentWidth  = 100;
                saveEntry.Color         = i % 2 == 0 ? Color.Black : Color.Gray;
                saveEntry.Alpha         = 0.3f;
                textPane.PercentWidth   = 70;

                saveDetail.SecondaryColor    = Color.Yellow;
                saveInfo.SecondaryColor      = Color.Yellow;
                saveThumbnail.SecondaryColor = Color.White;
                saveThumbnail.DefaultScale   = 4;
                saveThumbnail.MillisPerScale = 128;

                saveInfo.Text   = "" + saveState.SavedDate;
                saveDetail.Text = "Created at: "
                                  + saveState.CreationDate + ", Total Playtime: "
                                  + saveState.Playtime;

                saveInfos.Add(saveInfo);
                saveDetails.Add(saveDetail);
                saveThumbnails.Add(saveThumbnail);
                vlSaves.add(saveEntry);
                ++i;
            });

            vlSaves.SelectedEvent += (sender, args) => {
                if (!(args.SelectedItem is Container))
                {
                    return;
                }
                int selected = args.SelectedIndex - (vlSaves.Children.Contains(tiNewGame) ? 1 : 0);
                saveInfos[selected].IsSelected      = true;
                saveDetails[selected].IsSelected    = true;
                saveThumbnails[selected].IsSelected = true;
            };

            vlSaves.DeselectedEvent += (sender, args) => {
                if (!(args.SelectedItem is Container))
                {
                    return;
                }
                int selected = args.SelectedIndex - (vlSaves.Children.Contains(tiNewGame) ? 1 : 0);
                saveInfos[selected].IsSelected      = false;
                saveDetails[selected].IsSelected    = false;
                saveThumbnails[selected].IsSelected = false;
            };

            vlSaves.ActionKeys.Add(deleteKey);
            vlSaves.ActionButtons.Add(deleteButton);

            vlSaves.ActionEvent += (sender, args) => {
                if (Keyboard.GetState().IsKeyDown(deleteKey) ||
                    GamePad.GetState(0).IsButtonDown(deleteButton))
                {
                    if (args.SelectedItem is Container)
                    {
                        ScreenManager.AddScreen(new ConfirmDialog(ParentScreen, answer => {
                            if (answer == 0 || answer == 2)
                            {
                                if (answer == 0)
                                {
                                    GameManager.SaveStates.RemoveAt(args.SelectedIndex - (vlSaves.Children.Contains(tiNewGame) ? 1 : 0));
                                    ScreenManager.AddScreen(new SaveMenuScreen(ParentScreen), null);
                                }

                                Alpha = 0;
                                ExitScreen();
                            }
                        },

                                                                  "Do you really want to delete this Savegame?",
                                                                  "This action cannot be undone!"),
                                                null);
                    }

                    return;
                }

                GameManager.ActiveSave = (args.SelectedItem is TextItem) ? new SaveState()
                    : GameManager.SaveStates[args.SelectedIndex - (vlSaves.Children.Contains(tiNewGame) ? 1 : 0)];

                ExitScreen();
                ParentScreen.ExitScreen();
                ((Besmash)ScreenManager.Game).loadSave();
                ScreenManager.AddScreen(new GameplayScreen(ParentScreen), null);
            };

            vlSaves.CancelEvent += (sender, args) => {
                Alpha = 0;
                ExitScreen();
            };

            vlSaves.select(0);
            vlSaves.IsFocused = true;
            MainContainer.add(vpMain);
        }
示例#14
0
        /// Initializes structural components
        protected void build()
        {
            remove(Children.ToArray());
            tiPlayerName  = new TextItem();
            tiPlayerLevel = new TextItem();
            tiPlayerEXP   = new TextItem();
            tiPlayerHP    = new TextItem();
            tiPlayerAP    = new TextItem();
            tiStatTypes   = new TextItem[6];
            tiPlayerStats = new TextItem[6];

            tiPlayerName.DefaultScale  = 0.7f;
            tiPlayerLevel.DefaultScale = 0.7f;
            tiPlayerEXP.DefaultScale   = 0.7f;
            tiPlayerHP.DefaultScale    = 0.7f;
            tiPlayerAP.DefaultScale    = 0.7f;

            HPane hpThumbs = new HPane(hlThumbnails);
            VPane vpInfo   = new VPane();
            VPane vpStats  = new VPane();
            VPane vpMain   = new VPane(hpThumbs, vpInfo, vpStats);

            add(vpMain);

            vpMain.PercentWidth  = 100;
            vpMain.PercentHeight = 100;

            hpThumbs.PercentWidth  = 100;
            hpThumbs.PercentHeight = 20;
            hpThumbs.Color         = Color.Black;
            hpThumbs.EffectAlpha   = 0.5f;

            vpInfo.PercentWidth  = 100;
            vpInfo.PercentHeight = 10;
            vpInfo.Color         = Color.Gray;
            vpInfo.EffectAlpha   = 0.5f;

            vpStats.PercentWidth  = 60;
            vpStats.PercentHeight = 70;
            vpStats.Color         = Color.Black;
            vpStats.EffectAlpha   = 0.5f;

            HPane hpName  = new HPane(tiPlayerName);
            HPane hpLevel = new HPane(tiPlayerLevel);
            HPane hpExp   = new HPane(tiPlayerEXP);
            HPane hpHP    = new HPane(tiPlayerHP);
            HPane hpAP    = new HPane(tiPlayerAP);
            HPane hpTop   = new HPane(hpName, hpLevel, hpExp);
            HPane hpBot   = new HPane(hpHP, hpAP);

            hpTop.PercentWidth   = 100;
            hpBot.PercentWidth   = 100;
            hpName.PercentWidth  = 20;
            hpLevel.PercentWidth = 20;
            hpLevel.PercentWidth = 20;
            hpHP.PercentWidth    = 20;
            hpAP.PercentWidth    = 20;
            vpInfo.add(hpTop, hpBot);

            for (int i = 0; i < 6; ++i)
            {
                tiPlayerStats[i] = new TextItem();
                tiStatTypes[i]   = new TextItem(((StatType)i).ToString() + ":");

                HPane hpL = new HPane(tiStatTypes[i]);
                HPane hpR = new HPane(tiPlayerStats[i]);
                HPane hpC = new HPane(hpL, hpR);

                hpL.PercentWidth = 40;
                hpR.PercentWidth = 40;
                hpC.PercentWidth = 100;
                vpStats.add(hpC);
            }
        }
示例#15
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();
        }
示例#16
0
        // private GameConfig gameConfig;

        public VideoSettingsPane(GameConfig gameConfig)
        {
            hlResolutions = new HList();
            hlFullscreen  = new HList(
                new TextItem("Enabled", "fonts/menu_font1"),
                new TextItem("Disabled", "fonts/menu_font1")
                );

            foreach (Point res in GameConfig.CommonResolutions)
            {
                hlResolutions.add(new TextItem(resToStr(res), "fonts/menu_font1"));
            }

            VList vlNames = new VList(
                new TextItem("Resolution", "fonts/menu_font1"),
                new TextItem("Fullscreen", "fonts/menu_font1")
                );

            VPane vpSettings = new VPane(hlResolutions, hlFullscreen);

            vlNames.SelectedEvent += (sender, args) => {
                hlResolutions.IsFocused = args.SelectedIndex == 0;
                hlFullscreen.IsFocused  = args.SelectedIndex == 1;
            };

            vlNames.CancelEvent += (sender, args) => {
                hlResolutions.IsFocused = false;
                hlFullscreen.IsFocused  = false;
                vlNames.select(0);
                hide(0.5f);
            };

            hlResolutions.SelectedEvent += (sender, args)
                                           => gameConfig.Resolution = GameConfig.CommonResolutions[args.SelectedIndex];

            hlFullscreen.SelectedEvent += (sender, args)
                                          => gameConfig.IsFullscreen = args.SelectedIndex == 0;

            int selectedFullscreen = gameConfig.IsFullscreen ? 0 : 1;
            int selectedResolution = 0;

            for (int i = 0; i < GameConfig.CommonResolutions.Length; ++i)
            {
                if (GameConfig.CommonResolutions[i].Equals(gameConfig.Resolution))
                {
                    selectedResolution = i;
                    break;
                }
            }

            hlResolutions.select(selectedResolution);
            hlFullscreen.select(selectedFullscreen);
            hlResolutions.SelectedColor = Color.White;
            hlFullscreen.SelectedColor  = Color.White;

            vlNames.PercentWidth  = 30;
            vlNames.PercentHeight = 100;
            vlNames.HAlignment    = HAlignment.Left;
            vlNames.EffectAlpha   = 0.5f;
            vlNames.Color         = Color.Black;

            vpSettings.PercentWidth  = 70;
            vpSettings.PercentHeight = 100;
            vpSettings.HAlignment    = HAlignment.Left;
            vpSettings.EffectAlpha   = 0.5f;
            vpSettings.Color         = Color.Gray;

            FocusRequestEvent += (s, a) => {
                vlNames.select(0);
                vlNames.IsFocused = true;
            };

            FocusLossEvent += (s, a) => {
                vlNames.IsFocused     = false;
                vlNames.SelectedIndex = -1;
            };

            HPane hpMain = new HPane(vlNames, vpSettings);

            hpMain.PercentWidth  = 100;
            hpMain.PercentHeight = 100;
            add(hpMain);
        }
示例#17
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();
        }
示例#18
0
        public SettingsScreen(BesmashScreen parent)
            : base(parent)
        {
            IsPopup = true; // TODO test

            VList vlItems = new VList(
                new TextItem("Video", PRIMARY_FONT),
                new TextItem("Audio", PRIMARY_FONT),
                new TextItem("Controls", PRIMARY_FONT),
                new TextItem("Gameplay", PRIMARY_FONT),
                new TextItem("Back", PRIMARY_FONT)
                );

            Config = new GameConfig(GameManager.Configuration);
            VideoSettingsPane    vsPane     = new VideoSettingsPane(Config);
            AudioSettingsPane    asPane     = new AudioSettingsPane(Config);
            ControlSettingsPane  csPane     = new ControlSettingsPane(Config);
            GameplaySettingsPane gsPane     = new GameplaySettingsPane(Config);
            MessagePane          msPane     = new MessagePane(this, "Return to Main Menu");
            StackPane            spSettings = new StackPane(vsPane, asPane, csPane, gsPane, msPane);
            HPane hpMain = new HPane(vlItems, spSettings);

            hpMain.PercentWidth      = 100;
            hpMain.PercentHeight     = 100;
            spSettings.PercentWidth  = 100;
            spSettings.PercentHeight = 100;
            spSettings.HAlignment    = HAlignment.Left;

            vlItems.ActionEvent += (sender, args) => {
                showPane(vlItems.SelectedIndex, vsPane, asPane, csPane, gsPane);
                vlItems.IsFocused = args.SelectedIndex == 4;
                if (args.SelectedIndex == 4)
                {
                    close();
                }
            };

            vsPane.PercentWidth    = 80;
            vsPane.PercentHeight   = 100;
            vsPane.HAlignment      = HAlignment.Left;
            vsPane.FocusLossEvent += (sender, args)
                                     => vlItems.IsFocused = true;

            asPane.PercentWidth    = 80;
            asPane.PercentHeight   = 100;
            asPane.HAlignment      = HAlignment.Left;
            asPane.FocusLossEvent += (sender, args)
                                     => vlItems.IsFocused = true;

            gsPane.PercentWidth    = 80;
            gsPane.PercentHeight   = 100;
            gsPane.HAlignment      = HAlignment.Left;
            gsPane.FocusLossEvent += (sender, args)
                                     => vlItems.IsFocused = true;

            csPane.PercentWidth    = 80;
            csPane.PercentHeight   = 100;
            csPane.HAlignment      = HAlignment.Left;
            csPane.FocusLossEvent += (sender, args)
                                     => vlItems.IsFocused = true;

            msPane.PercentWidth  = 80;
            msPane.PercentHeight = 100;
            msPane.HAlignment    = HAlignment.Left;

            vlItems.SelectedEvent += (sender, args) => {
                if (args.SelectedIndex == 0)
                {
                    vsPane.show(false, 0.5f);
                }
                if (args.SelectedIndex == 1)
                {
                    asPane.show(false, 0.5f);
                }
                if (args.SelectedIndex == 2)
                {
                    csPane.show(false, 0.5f);
                }
                if (args.SelectedIndex == 3)
                {
                    gsPane.show(false, 0.5f);
                }
                if (args.SelectedIndex == 4)
                {
                    msPane.show(false, 0.5f);
                }
            };

            vlItems.DeselectedEvent += (sender, args) => {
                if (args.SelectedIndex == 0)
                {
                    vsPane.hide(false);
                }
                if (args.SelectedIndex == 1)
                {
                    asPane.hide(false);
                }
                if (args.SelectedIndex == 2)
                {
                    csPane.hide(false);
                }
                if (args.SelectedIndex == 3)
                {
                    gsPane.hide(false);
                }
                if (args.SelectedIndex == 4)
                {
                    msPane.hide(false);
                }
            };

            vlItems.CancelEvent += (sender, args)
                                   => close();

            vlItems.Color         = Color.DarkSlateBlue;
            vlItems.Alpha         = 0.3f;
            vlItems.IsFocused     = true;
            vlItems.IsStatic      = true;
            vlItems.PercentHeight = 100;
            vlItems.PercentWidth  = 20;
            vlItems.HAlignment    = HAlignment.Left;

            asPane.hide();
            csPane.hide();
            gsPane.hide();
            msPane.hide();
            vlItems.select(0);
            MainContainer.add(hpMain);
        }
示例#19
0
        public ControlSettingsPane(GameConfig gameConfig)
        {
            StackPane spSettings = new StackPane();
            VPane     vpMain     = new VPane(hlCategories, spSettings);

            hlCategories.PercentWidth = 100;
            spSettings.PercentWidth   = 100;

            hlCategories.PercentHeight = 10;
            spSettings.PercentHeight   = 90;

            hlCategories.Color       = Color.Black;
            hlCategories.EffectAlpha = 0.5f;

            gameConfig.KeyMaps.Keys.ToList().ForEach(key => {
                hlCategories.add(new TextItem(key, "fonts/menu_font1"));
                VList vlNames    = new VList();
                VList vlKeys     = new VList();
                VList vlButtons  = new VList();
                HPane hpBorder   = new HPane();
                HPane hpControls = new HPane(vlNames, vlKeys, hpBorder, vlButtons);

                hpControls.PercentWidth  = 100;
                hpControls.PercentHeight = 100;

                vlNames.PercentWidth   = 25;
                vlKeys.PercentWidth    = 25;
                hpBorder.PercentWidth  = 5;
                vlButtons.PercentWidth = 45;

                vlNames.PercentHeight   = 100;
                vlKeys.PercentHeight    = 100;
                hpBorder.PercentHeight  = 100;
                vlButtons.PercentHeight = 100;

                vlNames.Color   = Color.Black;
                vlKeys.Color    = Color.Gray;
                hpBorder.Color  = Color.Black;
                vlButtons.Color = Color.Gray;

                vlNames.EffectAlpha   = 0.5f;
                vlKeys.EffectAlpha    = 0.5f;
                hpBorder.EffectAlpha  = 0.5f;
                vlButtons.EffectAlpha = 0.5f;

                List <UserInput> input_refs = new List <UserInput>();
                List <TextItem> key_refs    = new List <TextItem>();
                List <TextItem> button_refs = new List <TextItem>();

                vlNames.ActionEvent += (sender, args) => {
                    ParentScreen.ScreenManager.AddScreen(new InputDialog(
                                                             (BesmashScreen)ParentScreen,
                                                             input_refs[args.SelectedIndex],
                                                             "Press a new Key or Button", 5,
                                                             a => initKeyTextItems(input_refs[args.SelectedIndex],
                                                                                   key_refs[args.SelectedIndex],
                                                                                   button_refs[args.SelectedIndex])
                                                             ), null);
                };

                spSettings.add(hpControls);
                hPanes.Add(hpControls);
                vLists.Add(vlNames);

                gameConfig.KeyMaps[key].Keys.ToList().ForEach(key2 => {
                    List <Keys> keys       = gameConfig.KeyMaps[key][key2].TriggerKeys;
                    List <Buttons> buttons = gameConfig.KeyMaps[key][key2].TriggerButtons;
                    string title_key       = "", title_button = "";
                    int i;

                    for (i = 0; i < keys.Count(); ++i)
                    {
                        title_key += (i > 0 ? ", " : "") + keys[i].ToString();
                    }

                    for (i = 0; i < buttons.Count(); ++i)
                    {
                        title_button += (i > 0 ? ", " : "") + buttons[i].ToString();
                    }

                    TextItem tiName    = new TextItem(key2, "fonts/menu_font1");
                    TextItem tiKeys    = new TextItem("", "fonts/menu_font1");
                    TextItem tiButtons = new TextItem("", "fonts/menu_font1");
                    initKeyTextItems(gameConfig.KeyMaps[key][key2], tiKeys, tiButtons);

                    vlNames.add(new TextItem(key2, "fonts/menu_font1"));
                    vlKeys.add(tiKeys);
                    vlButtons.add(tiButtons);

                    key_refs.Add(tiKeys);
                    button_refs.Add(tiButtons);
                    input_refs.Add(gameConfig.KeyMaps[key][key2]);
                });

                vlNames.SelectedIndex = 0;
            });

            hlCategories.SelectedEvent += (sender, args) => {
                if (hlCategories.IsFocused)
                {
                    vLists[args.SelectedIndex].IsFocused = true;
                    show(true, 1);
                }
            };

            hlCategories.DeselectedEvent += (sender, args)
                                            => vLists[args.SelectedIndex].IsFocused = false;

            hlCategories.CancelEvent += (sender, args) => {
                vLists[hlCategories.SelectedIndex].IsFocused = false;
                hide(0.5f);
            };

            FocusRequestEvent += (s, a) => {
                vLists[hlCategories.SelectedIndex].IsFocused = true;
                hlCategories.IsFocused = true;
            };

            FocusLossEvent += (s, a)
                              => hlCategories.IsFocused = false;

            vpMain.PercentWidth    = 100;
            vpMain.PercentHeight   = 100;
            hlCategories.IsFocused = false;
            hlCategories.select(0);
            add(vpMain);
        }