コード例 #1
0
        public void LoadContent(GraphicsDevice graphicsDevice, Settings settings, Point clientSize)
        {
            _GraphicsDevice = graphicsDevice ?? throw new ArgumentNullException(nameof(graphicsDevice));

            var titleFont    = _ContentManager.Load <SpriteFont>(Content.Assets.Fonts.CinzelDecorative);
            var textFont     = _ContentManager.Load <SpriteFont>(Content.Assets.Fonts.OpenSansCondensed);
            var dialogueFont = _ContentManager.Load <SpriteFont>(Content.Assets.Fonts.NothingYouCouldDo);
            var uiTexture    = _ContentManager.Load <Texture2D>(Content.Assets.Gfx.ui);

            _WindowManager.LoadContent();

            _MainMenuWindow = new Window("MainMenuWindow", FrameType.LargeScroll, titleFont, Strings.MainMenu_Title)
            {
                TitlePadding = new Padding(8, 0, 8, 0),
            };
            _PauseMenuWindow = new Window("PauseMenuWindow", FrameType.MediumScroll, titleFont, Strings.PauseMenu_Title)
            {
                TitlePadding = new Padding(8, 0, 8, 0),
            };
            _ConfirmQuitWindow = new Window("ConfirmQuitWindow", FrameType.SmallScroll, titleFont);
            _SettingsWindow    = new Window("SettingsWindow", FrameType.MediumScroll, titleFont, Strings.SettingsMenu_Title);

            _InventoryWindow = new Window("InventoryWindow", FrameType.SmallScroll, titleFont);

            _MainMenuWindow.Control = new Menu("MainMenu", textFont)
                                      .WithItem(Strings.MainMenu_Item0_Label, null, false)    // Continue
                                      .WithItem(Strings.MainMenu_Item1_Label, NewGame, true)  // New Game
                                      .WithItem(Strings.MainMenu_Item2_Label, Settings, true) // Settings
                                      .WithItem(Strings.MainMenu_Item3_Label, Quit, true)     // Quit
                                      .SelectFirstEnabledItem();

            _PauseMenuWindow.Control = new Menu("PauseMenu", textFont)
                                       .WithItem(Strings.PauseMenu_Item0_Label, Resume, true)   // Resume
                                       .WithItem(Strings.PauseMenu_Item1_Label, null, false)    // Save
                                       .WithItem(Strings.PauseMenu_Item2_Label, Settings, true) // Settings
                                       .WithItem(Strings.PauseMenu_Item3_Label, MainMenu, true) // Main Menu
                                       .WithItem(Strings.PauseMenu_Item4_Label, Quit, true)     // Quit
                                       .SelectFirstEnabledItem();

            var confirmQuitWindowLayout = new GridPanel("confirmQuitWindowLayout");

            confirmQuitWindowLayout.AddControl(new Label("confirmQuitLabel", Strings.AreYouSure_Label, textFont, Color.White), 0, 0, 1, 2);

            var yesButton = new Button("confirmQuitYesButton", Strings.Yes_Button, textFont);

            yesButton.Click += (s, a) => ConfirmQuit();
            confirmQuitWindowLayout.AddControl(yesButton, 1, 0);
            confirmQuitWindowLayout.SetCellAlign(yesButton, Alignment.Middle, Alignment.Middle);

            var noButton = new Button("confirmQuitNoButton", Strings.No_Button, textFont);

            noButton.Click += (s, a) => _WindowManager.CloseWindow();
            confirmQuitWindowLayout.AddControl(noButton, 1, 1);
            confirmQuitWindowLayout.SetCellAlign(noButton, Alignment.Middle, Alignment.Middle);

            _ConfirmQuitWindow.Control = confirmQuitWindowLayout;

            var settingsWindowLayout = new GridPanel("settingsWindowLayout");

            var fullscreenCheckbox = new Checkbox("settingsFullscreen")
            {
                LabelFont  = textFont,
                LabelText  = Strings.Fullscreen_Label,
                LabelColor = Color.White,
                Checked    = settings.Fullscreen,
            };

            settingsWindowLayout.AddControl(fullscreenCheckbox, 0, 0, 1, 2);

            var okButton = new Button("settingsOkButton", Strings.OK_Button, textFont)
            {
                AutoSize     = false,
                ExplicitSize = new Point(128, 48),
            };

            okButton.Click += OnSettingsOkClick;
            settingsWindowLayout.AddControl(okButton, 2, 0);
            settingsWindowLayout.SetCellAlign(okButton, Alignment.Middle, Alignment.Middle);

            var cancelButton = new Button("settingsCancelButton", Strings.Cancel_Button, textFont)
            {
                AutoSize     = false,
                ExplicitSize = new Point(128, 48),
            };

            cancelButton.Click += (s, a) => _WindowManager.CloseWindow();
            settingsWindowLayout.AddControl(cancelButton, 2, 1);
            settingsWindowLayout.SetCellAlign(cancelButton, Alignment.Middle, Alignment.Middle);

            _SettingsWindow.Control = settingsWindowLayout;

            _InteractionWindow = new Window("InteractionWindow", FrameType.SmallScroll, titleFont)
            {
                Dock           = DockMode.LowerThird,
                TitleAlignment = Alignment.Near,
                Margin         = new Padding(16)
            };

            // TODO More interaction window stuff (player icon, etc)
            var interactionDialogue = new DialogueLabel("interactionDialog", dialogueFont)
            {
                Padding  = new Padding(8),
                Color    = Color.Black,
                TextRate = TimeSpan.FromMilliseconds(40),
            };

            interactionDialogue.Accept += (sender, e) => { _WindowManager.CloseWindow(_InteractionWindow); _State = GameState.SceneIdle; };
            _InteractionWindow.Control  = interactionDialogue;

            SetClientSize(clientSize);
            _WindowManager.OpenWindow(_MainMenuWindow);
        }