public GamemodeWindow(Sidebar sidebar)
        {
            this.manager = sidebar.manager;
            this.sidebar = sidebar;

            window = new Window(manager);
            window.Init();
            window.Left = sidebar.master.Left;
            window.Width = sidebar.master.Width;
            window.Top = 0;
            window.Height = 600;
            window.Text = "Game Mode";
            manager.Add(window);

            TitlePanel titlePanel = new TitlePanel(sidebar, window, "Game Mode", true);
            titlePanel.btnBack.Click += (s, e) => window.Close();

            HeightCounter += titlePanel.topPanel.Height + LeftPadding * 2;

            lblMode = new Label(manager);
            lblMode.Init();
            lblMode.Parent = window;
            lblMode.Top = HeightCounter;
            lblMode.Left = LeftPadding;
            lblMode.Text = "Game Mode Options";
            lblMode.Width = 120;
            lblMode.TextColor = Color.Black;

            //cbMode = new ComboBox(manager);
            //cbMode.Init();
            //cbMode.Parent = window;
            //cbMode.Left = lblMode.Left + lblMode.Width;
            //cbMode.Top = HeightCounter;
            //cbMode.Width = 100;
            //
            //foreach (GameModes m in Enum.GetValues(typeof(GameModes)))
            //{
            //    cbMode.Items.Add(m);
            //}
            HeightCounter += lblMode.Height + LeftPadding * 3;

            insViewModes = new InspectorView(sidebar, window, LeftPadding, HeightCounter);
            insViewModes.Width -= 20;
            insViewModes.Height -= 100;
            HeightCounter += insViewModes.Height + LeftPadding * 3;
            insViewModes.SetRootObject(OrbIt.globalGameMode);

            //insViewGlobal = new InspectorView(sidebar, window, LeftPadding, HeightCounter);
            //insViewGlobal.Width -= 20;
            //insViewGlobal.Height -= 100;

            window.Refresh();
        }
        public OptionsWindow(Sidebar sidebar)
        {
            UserInterface.GameInputDisabled = true;
            this.manager = sidebar.manager;
            this.sidebar = sidebar;

            window = new Window(manager);
            window.Init();
            window.Left = sidebar.master.Left;
            window.Width = sidebar.master.Width;
            window.Top = 200;
            window.Height = 200;
            window.Width = 240;
            window.Text = "Options";
            window.Resizable = false;
            window.Movable = false;

            window.Closed += delegate { UserInterface.GameInputDisabled = false; };
            window.ShowModal();
            manager.Add(window);

            btnOk = new Button(manager);
            btnOk.Init();
            btnOk.Parent = window;
            btnOk.Left = LeftPadding;
            btnOk.Top = window.Height - (btnOk.Height * 3);
            btnOk.Text = "Ok";// +"\u2713";
            btnOk.Click += (s, e) => window.Close();

            //btnLoadLevel = new Button(manager);
            //btnLoadLevel.Init();
            //window.Add(btnLoadLevel);
            //btnLoadLevel.Width += 30;
            //btnLoadLevel.Left = window.Width - btnLoadLevel.Width - LeftPadding * 5;
            //btnLoadLevel.Text = "Load Level";
            //btnLoadLevel.Top = window.Height - (btnLoadLevel.Height * 3);
            //btnLoadLevel.Click += btnLoadLevel_Click;
            //
            //btnSaveLevel = new Button(manager);
            //btnSaveLevel.Init();
            //window.Add(btnSaveLevel);
            //btnSaveLevel.Width += 30;
            //btnSaveLevel.Left = window.Width - btnSaveLevel.Width - LeftPadding * 5;
            //btnSaveLevel.Text = "Save Level";
            //btnSaveLevel.Top = btnLoadLevel.Top - btnSaveLevel.Height - LeftPadding;
            //btnSaveLevel.Click += btnSaveLevel_Click;

            lblUserLevel = new Label(manager);
            lblUserLevel.Init();
            lblUserLevel.Parent = window;
            lblUserLevel.Left = LeftPadding;
            lblUserLevel.Top = HeightCounter;
            lblUserLevel.Text = "User Level";
            lblUserLevel.Width += 10;

            cbUserLevel = new ComboBox(manager);
            cbUserLevel.Init();
            cbUserLevel.Parent = window;
            cbUserLevel.Top = HeightCounter;
            cbUserLevel.Left = lblUserLevel.Width;
            cbUserLevel.Width = 150;
            HeightCounter += cbUserLevel.Height;
            cbUserLevel.TextColor = Color.Black;
            foreach(string ul in Enum.GetNames(typeof(UserLevel)))
            {
                cbUserLevel.Items.Add(ul);
            }
            cbUserLevel.ItemIndexChanged += (s, e) =>
            {
                sidebar.userLevel = (UserLevel)cbUserLevel.ItemIndex;

            };
            int count = 0;
            foreach(object s in cbUserLevel.Items)
            {
                if (s.ToString().Equals(sidebar.userLevel.ToString()))
                {
                    cbUserLevel.ItemIndex = count;
                }
                count++;
            }

            Label lblRes = new Label(manager);
            lblRes.Init();
            lblRes.Parent = window;
            lblRes.Left = LeftPadding;
            lblRes.Top = HeightCounter;
            lblRes.Text = "Resolution";
            lblRes.Width += 10;

            ComboBox cbResolutions = new ComboBox(manager);
            cbResolutions.Init();
            cbResolutions.Parent = window;
            cbResolutions.Top = HeightCounter;
            cbResolutions.Left = lblUserLevel.Width;
            cbResolutions.Width = 150;
            HeightCounter += cbResolutions.Height;
            cbUserLevel.TextColor = Color.Black;
            foreach (resolutions r in Enum.GetValues(typeof(resolutions)))
            {
                cbResolutions.Items.Add(r);
            }
            cbResolutions.ItemIndexChanged += (s, e) =>
            {
                OrbIt.game.setResolution((resolutions)cbResolutions.ItemIndex, OrbIt.game.Graphics.IsFullScreen);
                if (OrbIt.game.Graphics.IsFullScreen)
                    OrbIt.game.prefFullScreenResolution = (resolutions)cbResolutions.ItemIndex;
                else OrbIt.game.prefWindowedResolution = (resolutions)cbResolutions.ItemIndex;

            };

            CreateCheckBox("FullScreen", OrbIt.isFullScreen, (o, e) =>
            {
                if ((o as CheckBox).Checked) OrbIt.game.setResolution(resolutions.AutoFullScreen, true);
                else OrbIt.game.setResolution(resolutions.WXGA_1280x800, false);
            });
            CreateCheckBox("Hide Links", sidebar.ui.game.room.DrawLinks, (o, e) => sidebar.ui.game.room.DrawLinks = !(o as CheckBox).Checked);

            CreateCheckBox("Edit Selected Node", false, (o, e) => Utils.notImplementedException() );

            //CreateCheckBox("Edit Selected Node", sidebar.EditSelectedNode, (o, e) => sidebar.EditSelectedNode = (o as CheckBox).Checked);
        }
Ejemplo n.º 3
0
        private void CreateWelcomeMessage()
        {
            var padding = 15;
            var window = new Window(_gameInfo.Manager) { Width = 400, Height = 300, Text = "Welcome to Game of Life!", AutoScroll = false, Resizable = false };
            var label = new Label(_gameInfo.Manager) {
                Width = window.Width, Parent = window, Height = 180, Top = padding, Left = padding,
                Text = "You are about to begin the game.  \nThe camera can be controlled using the following keys: \n\n -W A S D \n -Up Down Left Right \n\nAny active game objects visible on screen will glow. \n\nObjects outside of the visible area will have \nclickable arrows pointing to them. \n\nClicking the arrow will adjust the camera automatically. \n\nClose this window to begin."
            };
            label.Init();

            var close = new Button(_gameInfo.Manager) { Text = "Close", Parent = window, Top = window.Height - 75, Left = window.Width / 2 - 50 };
            close.Click += (sender, args) => window.Close();
            window.Closed += (sender, args) => BeginGame();
            close.Init();

            window.Init();
            _gameInfo.Manager.Add(window);
        }
Ejemplo n.º 4
0
        private IGameState[] CardSelected(Manager manager, GameInfo gameInfo, Story story)
        {
            var storyGraphic = gameInfo.Content.Load<Texture2D>(story.StoryGraphic);
            const int spacing = 20;
            const int width = 400;
            var yPos = spacing;

            var window = new Window(manager) {
                Text =
                    String.Format("Your fate has been decided! You spun a {0} story", story.StoryType), AutoScroll = false
            };

            window.Init();

            var storybox = new GroupBox(manager) { Width = 400, Height = 100, Left = 30, Top = yPos, Parent = window, Color = story.StoryType == StoryType.Red ? Color.Red : Color.Black, Text = ""+story.StoryType, TextColor = Color.White };
            storybox.Init();

            var storylabel = new Label(manager)
            {
                Width = storybox.Width,
                Height = storybox.Height,
                Parent = storybox,
                Text = story.DisplayedMessage,
                Left = spacing,
                StayOnTop = true
            };
            storylabel.Init();

            var imageBox = new ImageBox(manager)
            {
                Left = window.Width/2-100,
                Top = 140,
                Image = storyGraphic,
                Color = Color.White,
                Width = storyGraphic.Width,
                Height = storyGraphic.Height
            };
            imageBox.Init();
            window.Add(imageBox);
            var close = new Button(manager) { Text = "OK", Top = window.Height-50-spacing, Left = window.Width / 2 - 50, Parent = window };
            close.Init();
            close.Click += (sender, args) => window.Close();

            window.Closed += (sender, args) => WindowClosed(gameInfo);

            manager.Add(window);

            if (story.Positive)
                gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play();
            else
                gameInfo.Content.Load<SoundEffect>("Sounds/sadtrombone").Play();

            return new[] { story.PureLogic, waitState };
        }
Ejemplo n.º 5
0
        private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black)
        {
            const int spacing = 20;
            const int width = 500;
            int yPos = spacing;
            var window = new Window(manager) { Text = "Story card", Width = 600 };
            window.Init();

            var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30};
            descriptionlabel.Text =
                "When this window closes you will be required to spin the spinner.\n" +
                "If the spinner lands on a black spot you will undergo what the black card says.\n" +
                "If the spinner lands on a red spot you will undergo what the red card says.\n\n" +
                "These are stories you are spinning for!";
            yPos += descriptionlabel.Height + spacing / 2;

            var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White};
            redstorybox.Init();
            yPos += redstorybox.Height;
            var redstorylabel = new Label(manager)
                                    {
                                        Width = redstorybox.Width,
                                        Height = redstorybox.Height,
                                        Parent = redstorybox,
                                        Text = red.DisplayedMessage,
                                        Left = spacing,
                                        StayOnTop = true
                                    };
            redstorylabel.Init();

            var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White };
            blackstorybox.Init();
            yPos += blackstorybox.Height+spacing/2;

            var blackstorylabel = new Label(manager)
            {
                Width = blackstorybox.Width,
                Height = blackstorybox.Height,
                Parent = blackstorybox,
                Text = black.DisplayedMessage,
                Left = spacing,
                StayOnTop = true
            };
            blackstorylabel.Init();

            var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window };
            close.Init();
            close.Click += (sender, args) => window.Close();
            yPos += close.Height + spacing;

            window.Add(descriptionlabel);
            window.Height = blackstorybox.Height + redstorybox.Height + yPos/2;
            manager.Add(window);

            window.Closed += (sender, args) => WindowClosed(gameInfo);

            gameInfo.CreateMessage("Click the spinner to see your story!");
        }
Ejemplo n.º 6
0
        void AddExitConfirmationWindow(Manager gui)
        {
            ExitConfirmationWindow = new Window(gui);
            ExitConfirmationWindow.Init();
            ExitConfirmationWindow.Text        = GlblRes.Really_quit;
            ExitConfirmationWindow.Width       = 290;
            ExitConfirmationWindow.Height      = 130;
            ExitConfirmationWindow.Resizable   = false;
            ExitConfirmationWindow.IconVisible = false;
            ExitConfirmationWindow.Movable     = false;
            ExitConfirmationWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT));
            ExitConfirmationWindow.Visible            = false;
            ExitConfirmationWindow.CloseButtonVisible = false;

            var Bevel = new Bevel(gui);

            Bevel.Parent = ExitConfirmationWindow;
            Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right;
            Bevel.Height = 35;
            Bevel.Style  = BevelStyle.Raised;
            Bevel.Top    = ExitConfirmationWindow.ClientHeight - Bevel.Height;
            Bevel.Width  = ExitConfirmationWindow.ClientWidth;


            var Text = new Label(gui);

            Text.Text   = GlblRes.Do_you_really_want_to_quit_the_game;
            Text.Parent = ExitConfirmationWindow;
            Text.Top    = 10;
            Text.Left   = 10;
            Text.Width  = ExitConfirmationWindow.ClientWidth - 20;
            Text.Height = 20;

            var Yes = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            Yes.Parent = Bevel;
            Yes.Width  = 100;
            Yes.Text   = GlblRes.Yes;
            Yes.Left   = 10;
            Yes.Top    = 5;
            Yes.Click += (se, ve) =>
            {
                Engine.Exit();
            };


            var No = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            No.Parent = Bevel;
            No.Text   = GlblRes.Menu_AddExitConfirmationWindow_No;
            No.Width  = 100;
            No.Left   = 165;
            No.Top    = 5;
            No.Click += (se, ev) =>
            {
                ExitConfirmationWindow.Close();
                ShowLogo(true);
            };

            gui.Add(ExitConfirmationWindow);
        }
Ejemplo n.º 7
0
        private void CreateMessage(Manager manager, GameInfo gameInfo, IGameState waitState)
        {
            var currentPlayer = gameInfo.CurrentPlayer;

            var messageWindow = new Window(manager) { Text = "Pay Day!", AutoScroll = false, CloseButtonVisible = false};
            messageWindow.Init();
            messageWindow.SetSize(400, 230);
            var message = new Label(manager) { Text = "Well Done! you have received your Pay Day! \nBelow are the details.", Width = 400, Height = 40, Left = 5, Top = 10 };
            message.Init();
            message.Parent = messageWindow;
            var careerImage = gameInfo.Content.Load<Texture2D>("Images/career_icons/" +
                                                               gameInfo.CurrentPlayer.CurrentCareer);
            var career = new ImageBox(manager) {
                Image = careerImage,
                Width = careerImage.Width,
                Height = careerImage.Height,
                Top = 50,
                Left = 16,
                StayOnBack = true
            };
            career.Init();
            career.Parent = messageWindow;

            var icon = new ImageBox(manager) {
                Image =
                    gameInfo.Content.Load<Texture2D>("Images/payday"),
                Top = 60,
                Left = career.Left + career.Width + 70
            };
            icon.Init();
            icon.Parent = messageWindow;

            var job = new Label(manager) { Text = "Current Career:\n" + currentPlayer.CurrentCareer.Title, Top = 110, Left = 10, Width = 150, Height = 50 };
            job.Init();
            job.Parent = messageWindow;

            var salary = new Label(manager) {
                Text = String.Format("Level {1} Promotion\nReceived: ${0:N0}",
                currentPlayer.CurrentCareer.Salary[currentPlayer.PromotionLevel],
                currentPlayer.PromotionLevel + 1),
                Top = 110, Left = 140, Width = 140, Height = 50
            };
            salary.Init();
            salary.Parent = messageWindow;

            var close = new Button(manager) { Text = "OK", Top = 160, Left = messageWindow.Width / 2 - 50 };
            close.Init();
            close.Parent = messageWindow;
            close.Click += (sender, args) => { messageWindow.Close(); WindowClosed(gameInfo, waitState); };
            messageWindow.Closed += (sender, args) => WindowClosed(gameInfo, waitState);
            gameInfo.Manager.Add(messageWindow);
            messageWindow.Init();
            gameInfo.Content.Load<SoundEffect>("Sounds/coins").Play();
        }
Ejemplo n.º 8
0
        private void CreateCareerWindow(Manager manager, GameInfo gameInfo, Career[] randomJobs, IGameState waitState)
        {
            const int spacing = 20;
            const int width = 500;

            int yPos = spacing;
            int xPos = spacing * 4;
            var window = new Window(manager) {
                Text = "Choose a career!",
                Width = width,
                CloseButtonVisible = false,
                Resizable = false
            };

            window.Init();

            var description = new Label(manager) { Text = "Choose a random unknown career!\nWhen you select the career it will show you your fate!", Width = 400, Left = 16, Top = 16, Height = 40 };
            description.Init();
            yPos += description.Height + spacing;
            window.Add(description);

            var chosenJob = new Label(manager) { Text = String.Empty, Width = 400, Left = 16, Top = 16, Height = 70 };
            chosenJob.Init();
            window.Add(chosenJob);

            var possibleJobImages = new List<Button>();
            var chooseCareerTexture = gameInfo.Content.Load<Texture2D>("Images/career_icons/BlankJob");
            foreach (var career in randomJobs) {
                var chosenCareer = career;

                var careerButton = new Button(manager) {
                    Top = yPos,
                    Left = xPos,
                    StayOnBack = true,
                    Width = 100,
                    Height = 100,
                    Glyph = new Glyph(chooseCareerTexture)
                };
                possibleJobImages.Add(careerButton);
                careerButton.Init();
                window.Add(careerButton);

                careerButton.Click += (sender, args) => {
                    gameInfo.CurrentPlayer.CurrentCareer = chosenCareer;
                    window.CloseButtonVisible = true;

                    chosenJob.Text = "Congratulations! You have become a " +
                                       chosenCareer.Title
                                       + "\n\nClose the window to receive your first Pay Day!";

                    int i = 0;
                    foreach (var possibleJob in possibleJobImages) {
                        possibleJob.Glyph = new Glyph(gameInfo.Content.Load<Texture2D>("images/career_icons/" + randomJobs[i++].Title));
                        possibleJob.Enabled = false;
                        possibleJob.SetSize(100, 100);
                    }

                    careerButton.Color = Color.Red;

                    yPos += chosenJob.Height + 16;

                    var close = new Button(manager) { Text = "OK", Parent = window, Top = yPos, Left = window.Width / 2 - 50 };
                    close.Click += (s, a) => {window.Close(); WindowClosed(gameInfo, waitState);};
                    close.Init();
                };

                xPos += careerButton.Width + 20;
            }

            yPos += possibleJobImages[0].Height + 16;

            chosenJob.Top = yPos;
            manager.Add(window);
            window.Closed += (sender, args) => WindowClosed(gameInfo, waitState);
        }
Ejemplo n.º 9
0
        private void CreateMessage(Manager manager, GameInfo gameInfo, IGameState waitState)
        {
            var currentPlayer = gameInfo.CurrentPlayer;
            var previousPromotionLevel = currentPlayer.PromotionLevel;
            currentPlayer.IncreaseSalary();
            var newPromotionLevel = currentPlayer.PromotionLevel;

            gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play();
            var messageWindow = new Window(manager) { Text = "Promotion!", AutoScroll = false, CloseButtonVisible = false};
            messageWindow.SetSize(400, 230);

            if (previousPromotionLevel != newPromotionLevel) {
                var message = new Label(manager) { Text = "Well Done! You have received a  promotion!!\nYou will now receive a higher salary.", Width = 300, Height = 40, Left = 5, Top = 10 };
                message.Init();
                message.Parent = messageWindow;
                var career = new ImageBox(manager) {
                    Image =
                        gameInfo.Content.Load<Texture2D>("Images/career_icons/" +
                                                         gameInfo.CurrentPlayer.CurrentCareer),
                    Top = 50,
                    Left = 10,
                    StayOnBack = true
                };
                career.Init();
                career.Parent = messageWindow;

                var job = new Label(manager) { Text = "Current Career:\n" + currentPlayer.CurrentCareer.Title, Top = 110, Left = 10, Width = 150, Height = 50 };
                job.Init();
                job.Parent = messageWindow;

                var salary = new Label(manager) {
                    Text = String.Format("New Promotion Level : {0}\n\n" +
                                         "Previous Salary : ${1:N0}\n\n" +
                                         "New Salary: ${2:N0}",
                   newPromotionLevel + 1, currentPlayer.CurrentCareer.Salary[previousPromotionLevel], currentPlayer.CurrentCareer.Salary[newPromotionLevel]),
                    Top = 65, Left = 140, Width = 200, Height = 300,
                    Alignment = Alignment.TopLeft
                };
                salary.Init();
                salary.Parent = messageWindow;

            } else {
                var message = new Label(manager) {
                    Text = String.Format("You have reached the maximum promotion level of {0} for being a {1} ",
                    currentPlayer.PromotionLevel, currentPlayer.CurrentCareer),
                    Width = 300,
                    Height = 40,
                    Left = 5,
                    Top = 10
                };
                message.Init();
                message.Parent = messageWindow;
            }

            var close = new Button(manager) { Text = "OK", Top = 150, Left = messageWindow.Width / 2 - 50 };
            close.Init();
            close.Parent = messageWindow;
            close.Click += (sender, args) => { messageWindow.Close(); gameInfo.Fsm.Remove(waitState); };
            gameInfo.Manager.Add(messageWindow);
            messageWindow.Init();
            gameInfo.Content.Load<SoundEffect>("Sounds/coins").Play();
        }
Ejemplo n.º 10
0
		void AddCreepsButton_Click(object sender, EventArgs e) {
			try {
				int health = Convert.ToInt32(_healthOfCreeps.Text);
				int speed = Convert.ToInt32(_speedOfCreeps.Text);
				int number = Convert.ToInt32(_numberOfCreeps.Text);
				string texture = _creepTexture.Text.Substring(0, 3).ToLower();
				for (int i = 0; i < number; i++) {
					_currentCreepList.Add(new Creep(health, speed, texture));
				}
				UpdateCreepBox();
			} catch (Exception) {
				_isEditorActive = false;
				var msg = new Window(_manager);
				msg.Init();
				msg.Text = "Fehler";
				msg.Visible = true;
				msg.Width = 255;
				msg.Height = 100;
				msg.Center();
				msg.Closed += delegate { _isEditorActive = true; };
				var lbl = new Label(_manager);
				lbl.Init();
				lbl.Text = "Bitte verwenden Sie korrekte Eingaben!";
				lbl.Parent = msg;
				lbl.Width = 230;
				lbl.Left = 5;
				lbl.Top = 5;

				var close = new Button(_manager);
				close.Init();
				close.Text = "Schließen";
				close.Width = 100;
				close.Parent = msg;
				close.Left = (msg.ClientWidth / 2) - (close.Width / 2);
				close.Top = msg.ClientHeight - close.Height - 8;
				close.Anchor = Anchors.Bottom;
				close.Click += delegate { msg.Close(); };

				_manager.Add(msg);
			}
		}
Ejemplo n.º 11
0
        void AddSettingsWindow(Manager gui)
        {
            SettingsWindow                    = new Window(gui);
            SettingsWindow.Width              = 300;
            SettingsWindow.Height             = 200;
            SettingsWindow.CloseButtonVisible = false;
            SettingsWindow.Text               = GlblRes.Settings;
            SettingsWindow.Parent             = MainMenuBackground;
            SettingsWindow.Init();
            SettingsWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT));
            SettingsWindow.Visible     = false;
            SettingsWindow.Resizable   = false;
            SettingsWindow.IconVisible = false;
            SettingsWindow.DragAlpha   = 255;
            SettingsWindow.Movable     = false;

            var MusicVolumeLabel = new Label(gui);

            MusicVolumeLabel.Init();
            MusicVolumeLabel.Width  = 120;
            MusicVolumeLabel.Parent = SettingsWindow;
            MusicVolumeLabel.Text   = GlblRes.Music_Volume;
            MusicVolumeLabel.Top    = 5;
            MusicVolumeLabel.Left   = 5;

            var MusicVolumeBar = new TrackBar(gui);

            MusicVolumeBar.Init();
            MusicVolumeBar.Width         = 160;
            MusicVolumeBar.Value         = (int)(GameSettings.MusicVolume * 100);
            MusicVolumeBar.ValueChanged += (o, e) =>
            {
                GameSettings.MusicVolume = (float)MusicVolumeBar.Value / 100f;
                Engine.ApplyGameSettingsVolume();
                MediaPlayer.Volume = MathHelper.Clamp(GameSettings.MusicVolume, 0.0f, 1.0f);
                MainMenuLabel.Text = string.Empty;
            };
            MusicVolumeBar.Top    = 5;
            MusicVolumeBar.Left   = 120;
            MusicVolumeBar.Parent = SettingsWindow;

            var SoundVolumeLabel = new Label(gui);

            SoundVolumeLabel.Init();
            SoundVolumeLabel.Width  = 120;
            SoundVolumeLabel.Parent = SettingsWindow;
            SoundVolumeLabel.Text   = GlblRes.Sound_Volume;
            SoundVolumeLabel.Top    = 30;
            SoundVolumeLabel.Left   = 5;

            var SoundVolumeBar = new TrackBar(gui);

            SoundVolumeBar.Init();
            SoundVolumeBar.Width         = 160;
            SoundVolumeBar.Value         = (int)(GameSettings.SoundEffectVolume * 100);
            SoundVolumeBar.ValueChanged += (o, e) =>
            {
                GameSettings.SoundEffectVolume = (float)SoundVolumeBar.Value / 100f;
                Engine.ApplyGameSettingsVolume();
                MainMenuLabel.Text = string.Empty;
            };
            SoundVolumeBar.Top    = 30;
            SoundVolumeBar.Left   = 120;
            SoundVolumeBar.Parent = SettingsWindow;

            var BloomLabel = new Label(gui);

            BloomLabel.Init();
            BloomLabel.Width  = 120;
            BloomLabel.Parent = SettingsWindow;
            BloomLabel.Text   = GlblRes.Bloom;
            BloomLabel.Top    = 55;
            BloomLabel.Left   = 5;

            var BloomCheckBox = new CheckBox(gui);

            BloomCheckBox.Init();
            BloomCheckBox.Parent          = SettingsWindow;
            BloomCheckBox.Text            = string.Empty;
            BloomCheckBox.Checked         = GameSettings.Bloom;
            BloomCheckBox.CheckedChanged += (o, e) =>
            {
                GameSettings.Bloom = BloomCheckBox.Checked;
                MainMenuLabel.Text = GlblRes.Restart_the_game_for_this_setting_to_take_effect;
            };
            BloomCheckBox.Top  = 55;
            BloomCheckBox.Left = 120;

            var VSyncLabel = new Label(gui);

            VSyncLabel.Init();
            VSyncLabel.Width  = 120;
            VSyncLabel.Parent = SettingsWindow;
            VSyncLabel.Text   = GlblRes.VSync;
            VSyncLabel.Top    = 80;
            VSyncLabel.Left   = 5;

            var VSyncCheckBox = new CheckBox(gui);

            VSyncCheckBox.Init();
            VSyncCheckBox.Parent          = SettingsWindow;
            VSyncCheckBox.Text            = string.Empty;
            VSyncCheckBox.Checked         = GameSettings.VSync;
            VSyncCheckBox.CheckedChanged += (o, e) =>
            {
                GameSettings.VSync = VSyncCheckBox.Checked;
                MainMenuLabel.Text = GlblRes.Restart_the_game_for_this_setting_to_take_effect;
            };
            VSyncCheckBox.Top  = 80;
            VSyncCheckBox.Left = 120;

            var DisplayModeLabel = new Label(gui);

            DisplayModeLabel.Init();
            DisplayModeLabel.Width  = 120;
            DisplayModeLabel.Parent = SettingsWindow;
            DisplayModeLabel.Text   = GlblRes.Display_Mode;
            DisplayModeLabel.Top    = 105;
            DisplayModeLabel.Left   = 5;

            var DisplayModeCombo = new ComboBox(gui);

            DisplayModeCombo.Init();

            DisplayModeCombo.Items             = GetDisplayModes();
            DisplayModeCombo.Width             = 120;
            DisplayModeCombo.Parent            = SettingsWindow;
            DisplayModeCombo.Width             = 160;
            DisplayModeCombo.Text              = DisplayModeToString(GameSettings.DisplayMode);
            DisplayModeCombo.ItemIndexChanged += (o, e) =>
            {
                GameSettings.DisplayMode = StringToDisplayMode(DisplayModeCombo.Text);
                MainMenuLabel.Text       = GlblRes.Restart_the_game_for_this_setting_to_take_effect;
            };
            DisplayModeCombo.Top  = 105;
            DisplayModeCombo.Left = 120;

            var Bevel = new Bevel(gui);

            Bevel.Parent = SettingsWindow;
            Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right;
            Bevel.Height = 35;
            Bevel.Style  = BevelStyle.Raised;
            Bevel.Top    = SettingsWindow.ClientHeight - Bevel.Height;
            Bevel.Width  = SettingsWindow.ClientWidth;

            var OKButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            OKButton.Init();
            OKButton.Parent = Bevel;
            OKButton.Text   = GlblRes.OK;
            OKButton.Click += (s, e) =>
            {
                SettingsWindow.Close();
                ShowLogo(true);
                GameSettings.Save(Engine.Game.SaveGameFolder);
            };
            OKButton.Width = 130;
            OKButton.Left  = 150;
            OKButton.Top   = 5;

            gui.Add(SettingsWindow);
        }
Ejemplo n.º 12
0
        void AddLoadGameWindow(Manager gui)
        {
            var LoadButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            LoadGameWindow                    = new Window(gui);
            LoadGameWindow.Width              = 300;
            LoadGameWindow.Height             = 200;
            LoadGameWindow.CloseButtonVisible = false;
            LoadGameWindow.Text               = GlblRes.Load_Savegame;
            LoadGameWindow.Parent             = MainMenuBackground;
            LoadGameWindow.Init();
            LoadGameWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT));
            LoadGameWindow.Visible     = false;
            LoadGameWindow.Resizable   = false;
            LoadGameWindow.IconVisible = false;
            LoadGameWindow.DragAlpha   = 255;
            LoadGameWindow.Movable     = false;

            var SaveGameScreenshot = new ImageBox(gui);

            SaveGameScreenshot.Parent   = MainMenuBackground;
            SaveGameScreenshot.Width    = MainMenuBackground.Width;
            SaveGameScreenshot.Height   = MainMenuBackground.Height;
            SaveGameScreenshot.Visible  = false;
            SaveGameScreenshot.SizeMode = SizeMode.Stretched;

            LoadGameWindow.Closed += (s, e) => { LoadGameListbox.ItemIndex = -1; };

            LoadGameListbox                   = new ListBox(gui);
            LoadGameListbox.Width             = LoadGameWindow.ClientWidth;
            LoadGameListbox.Parent            = LoadGameWindow;
            LoadGameListbox.Height            = LoadGameWindow.ClientHeight - 35;
            LoadGameListbox.ItemIndexChanged += (s, e) =>
            {
                ClickSound.Play(GameSettings.SoundEffectVolume, 0f, 0f);
                MainMenuLabel.Text = string.Empty;
                if (LoadGameListbox.ItemIndex > -1)
                {
                    if (SaveGameScreenshot.Image != null)
                    {
                        SaveGameScreenshot.Image.Dispose();
                    }

                    var Screenshot = SaveGames[SaveGames.Keys.ElementAt(LoadGameListbox.ItemIndex)].Screenshot;
                    if (Screenshot != null)
                    {
                        using (Stream ScreenshotStream = new MemoryStream(Screenshot))
                        {
                            SaveGameScreenshot.Image = Texture2D.FromStream(Engine.Renderer.GraphicsDevice, ScreenshotStream);
                        }
                    }

                    SaveGameScreenshot.Show();
                    LoadButton.Enabled = true;
                }
                else
                {
                    SaveGameScreenshot.Hide();
                    LoadButton.Enabled = false;
                }
            };

            var Bevel = new Bevel(gui);

            Bevel.Parent = LoadGameWindow;
            Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right;
            Bevel.Height = 35;
            Bevel.Style  = BevelStyle.Raised;
            Bevel.Top    = LoadGameWindow.ClientHeight - Bevel.Height;
            Bevel.Width  = LoadGameWindow.ClientWidth;

            LoadButton.Init();
            LoadButton.Parent  = Bevel;
            LoadButton.Enabled = false;
            LoadButton.Text    = GlblRes.Load_Savegame;
            LoadButton.Click  += (s, e) =>
            {
                MainMenuLabel.Text = string.Empty;
                try
                {
                    Engine.LoadState(SaveGames.Keys.ElementAt(LoadGameListbox.ItemIndex));
                }
                catch
                {
                    MainMenuLabel.Text = GlblRes.Could_not_load_save_game_Maybe_it_was_created_in_an_earlier_game_version;
                    return;
                }

                LoadGameWindow.Close();
                MainMenuBackground.Hide();
                Engine.Resume();
                Engine.Renderer.GUIManager.ShowSoftwareCursor = false;
            };
            LoadButton.Width = 130;
            LoadButton.Left  = 5;
            LoadButton.Top   = 5;

            var CancelButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            CancelButton.Init();
            CancelButton.Parent = Bevel;
            CancelButton.Text   = GlblRes.Cancel;
            CancelButton.Click += (s, e) =>
            {
                LoadGameWindow.Close();
                ShowLogo(true);
            };
            CancelButton.Width = 130;
            CancelButton.Left  = 150;
            CancelButton.Top   = 5;

            gui.Add(LoadGameWindow);
        }
Ejemplo n.º 13
0
        void AddSaveGameWindow(Manager gui)
        {
            var SaveButton  = new MenuButton(gui, ClickSound, FocusSound, GameSettings);
            var NameTextBox = new TextBox(gui);

            SaveGameWindow                    = new Window(gui);
            SaveGameWindow.Width              = 300;
            SaveGameWindow.Height             = 240;
            SaveGameWindow.CloseButtonVisible = false;
            SaveGameWindow.Text               = GlblRes.Save;
            SaveGameWindow.IconVisible        = false;
            SaveGameWindow.Parent             = MainMenuBackground;
            SaveGameWindow.Init();
            SaveGameWindow.Visible   = false;
            SaveGameWindow.Resizable = false;
            SaveGameWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT));
            SaveGameWindow.Movable = false;

            SaveGameWindow.Closed += (s, e) => { SaveGameListbox.ItemIndex = -1; };

            SaveGameListbox                   = new ListBox(gui);
            SaveGameListbox.Width             = SaveGameWindow.ClientWidth;
            SaveGameListbox.Parent            = SaveGameWindow;
            SaveGameListbox.Height            = SaveGameWindow.ClientHeight - 35 - 30;
            SaveGameListbox.ItemIndexChanged += (s, e) =>
            {
                ClickSound.Play(GameSettings.SoundEffectVolume, 0f, 0f);
                if (SaveGameListbox.ItemIndex > -1)
                {
                    NameTextBox.Text = SaveGames[SaveGames.Keys.ElementAt(SaveGameListbox.ItemIndex)].Name;
                }
            };

            var Bevel = new Bevel(gui);

            Bevel.Parent = SaveGameWindow;
            Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right;
            Bevel.Height = 35;
            Bevel.Style  = BevelStyle.Raised;
            Bevel.Top    = SaveGameWindow.ClientHeight - Bevel.Height;
            Bevel.Width  = SaveGameWindow.ClientWidth;

            SaveButton.Init();
            SaveButton.Parent  = Bevel;
            SaveButton.Enabled = false;
            SaveButton.Text    = GlblRes.Save;
            SaveButton.Click  += (s, e) =>
            {
                Engine.SaveState(NameTextBox.Text);
                ShowLogo(true);
                SaveGameWindow.Close();
                RefreshSaveGames();
            };
            SaveButton.Width = 130;
            SaveButton.Left  = 5;
            SaveButton.Top   = 5;

            var CancelButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings);

            CancelButton.Init();
            CancelButton.Parent = Bevel;
            CancelButton.Text   = GlblRes.Cancel;
            CancelButton.Click += (s, e) =>
            {
                SaveGameWindow.Close();
                ShowLogo(true);
            };
            CancelButton.Width = 130;
            CancelButton.Left  = Bevel.ClientWidth - 130 - 5;
            CancelButton.Top   = 5;

            gui.Add(SaveGameWindow);

            var SaveGameNameLabel = new Label(gui);

            SaveGameNameLabel.Parent = SaveGameWindow;
            SaveGameNameLabel.Top    = SaveGameListbox.Height + 5;
            SaveGameNameLabel.Left   = 5;
            SaveGameNameLabel.Width  = 95;
            SaveGameNameLabel.Text   = GlblRes.Name;

            NameTextBox.Parent = SaveGameWindow;
            NameTextBox.Init();
            NameTextBox.Left         = 60;
            NameTextBox.Top          = SaveGameListbox.Height + 5;
            NameTextBox.Width        = 220;
            NameTextBox.Height       = 20;
            NameTextBox.TextChanged += (s, e) =>
            {
                SaveButton.Enabled = !string.IsNullOrWhiteSpace(NameTextBox.Text);
            };
            NameTextBox.KeyPress += (s, e) =>
            {
                if (e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
                {
                    Engine.SaveState(NameTextBox.Text);
                    SaveGameWindow.Close();
                    ShowLogo(true);
                    RefreshSaveGames();
                }
            };

            gui.Add(SaveGameWindow);
        }