Пример #1
0
        public ConfirmDialog(BesmashScreen parent,
                             Callback onConfirm, params string[] messageLines) : base(parent)
        {
            VPane vpMessage = new VPane();

            foreach (string line in messageLines)
            {
                vpMessage.add(new TextItem(line, "fonts/menu_font1"));
            }

            HList hlAnswers = new HList(
                new TextItem("Yes", "fonts/menu_font1"),
                new TextItem("No", "fonts/menu_font1"),
                new TextItem("Cancel", "fonts/menu_font1")
                );

            hlAnswers.ActionEvent += (sender, args) => {
                onConfirm(args.SelectedIndex);
                Alpha = 0;
                ExitScreen();
            };

            VPane vpMain = new VPane(vpMessage, hlAnswers);

            vpMain.Color        = Color.Black;
            vpMain.PercentWidth = 100;
            vpMain.Alpha        = 0.7f;

            hlAnswers.select(0);
            hlAnswers.IsFocused = true;
            MainContainer.Alpha = 0.5f;
            MainContainer.Color = Color.Black;
            MainContainer.add(vpMain);
        }
Пример #2
0
        public override void LoadContent()
        {
            debugPane = new DebugPane();
            MainContainer.remove(MainContainer.Children.ToArray());
            MainContainer.add(debugPane);

            // TODO temporary solution?
            BattleManager = ((Besmash)ScreenManager.Game).BattleManager;
            BattlePane    = new BattlePane(BattleManager);
            MainContainer.add(BattlePane);
            base.LoadContent();

            TileMap.MapAlpha = 0;
        }
Пример #3
0
        public MainMenuScreen(string backgroundImage, GameManager gameManager) : base(null, gameManager)
        {
            TextItem itemSettings = new TextItem("Settings", PRIMARY_FONT);
            TextItem itemPlay     = new TextItem("Play", PRIMARY_FONT);
            TextItem itemQuit     = new TextItem("Quit", PRIMARY_FONT);
            VList    vlItems      = new VList(itemSettings, itemPlay, itemQuit);

            itemSettings.DefaultScale = 1.5f;
            itemPlay.DefaultScale     = 1.5f;
            itemQuit.DefaultScale     = 1.5f;

            // debug
            // vlItems.Color = Color.Gray;

            vlItems.IsFocused     = true;
            vlItems.IsStatic      = false;
            vlItems.SelectedIndex = 1;
            vlItems.PercentHeight = 50;
            vlItems.VAlignment    = VAlignment.Bottom;
            vlItems.ActionEvent  += (sender, args) => {
                if (args.SelectedItem == itemSettings)
                {
                    ScreenManager.AddScreen(
                        new SettingsScreen(this), null);
                }

                if (args.SelectedItem == itemPlay)
                {
                    ScreenManager.AddScreen(
                        new SaveMenuScreen(this), null);
                }

                if (args.SelectedItem == itemQuit)
                {
                    ScreenManager.Game.Exit();
                }
            };

            MainContainer.TextureFile = backgroundImage;
            MainContainer.add(vlItems);
        }
Пример #4
0
        public InputDialog(BesmashScreen parent, UserInput input,
                           string message, int time, Callback callback) : base(parent)
        {
            this.time     = time;
            this.input    = input;
            this.message  = message;
            this.callback = callback;

            tiTime    = new TextItem(time + "", "fonts/menu_font1");
            tiMessage = new TextItem("", "fonts/menu_font1");

            // TODO make this somehow accessible from outside
            VPane vpMain = new VPane(tiMessage, tiTime);

            vpMain.Color        = Color.Black;
            vpMain.PercentWidth = 100;
            vpMain.Alpha        = 0.7f;

            MainContainer.Color = Color.Black;
            MainContainer.Alpha = 0.5f;
            MainContainer.add(vpMain);
        }
Пример #5
0
        public GameMenuScreen(GameplayScreen parent) : base(parent)
        {
            TextItem entryStatus    = new TextItem("Status", "fonts/menu_font1");
            TextItem entryFormation = new TextItem("Formation", "fonts/menu_font1");
            TextItem entryInventory = new TextItem("Inventory", "fonts/menu_font1");
            TextItem entrySettings  = new TextItem("Settings", "fonts/menu_font1");
            TextItem entryQuit      = new TextItem("Quit", "fonts/menu_font1");
            VList    menuEntries    = new VList(entryStatus, entryFormation, entryInventory, entrySettings, entryQuit);

            menuEntries.PercentWidth  = 25;
            menuEntries.PercentHeight = 100;
            menuEntries.HAlignment    = HAlignment.Left;
            menuEntries.Color         = Color.Black;
            menuEntries.Alpha         = 0.5f;
            menuEntries.IsFocused     = true;
            IsPopup = true;

            TeamStatusPane teamStatus = new TeamStatusPane();

            teamStatus.PercentWidth  = 75;
            teamStatus.PercentHeight = 100;
            teamStatus.HAlignment    = HAlignment.Right;

            TeamFormationPane teamFormation = new TeamFormationPane();

            teamFormation.PercentWidth  = 75;
            teamFormation.PercentHeight = 100;
            teamFormation.HAlignment    = HAlignment.Right;

            teamStatus.FocusLossEvent += (sender, args)
                                         => menuEntries.IsFocused = true;

            teamFormation.FocusLossEvent += (sender, args)
                                            => menuEntries.IsFocused = true;

            menuEntries.ActionEvent += (sender, args) => {
                if (args.SelectedItem == entryStatus)
                {
                    menuEntries.IsFocused = false;
                    teamStatus.Team       = GameManager.ActiveSave.Team;
                    teamStatus.show();
                }

                if (args.SelectedItem == entryFormation)
                {
                    menuEntries.IsFocused = false;
                    teamFormation.Team    = GameManager.ActiveSave.Team;
                    teamFormation.show();
                }

                if (args.SelectedItem == entryInventory)
                {
                    // TODO
                }

                if (args.SelectedItem == entrySettings)
                {
                    // if(IsHidden) show(); else hide();
                    SettingsScreen settingsScreen = new SettingsScreen(this);
                    ScreenManager.AddScreen(settingsScreen, null);
                }

                if (args.SelectedItem == entryQuit)
                {
                    ExitScreen();
                    parent.quit(true);
                }
            };

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

            HideParent          = false;
            MainContainer.Alpha = 0.5f;
            MainContainer.Color = Color.Black;

            StackPane sp = new StackPane(menuEntries, teamStatus, teamFormation);

            sp.PercentWidth = sp.PercentHeight = 100;
            MainContainer.add(sp);
        }
Пример #6
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);
        }
Пример #7
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);
        }