Exemple #1
0
        public DebugMenuState()
            : base("DebugMenu")
        {
            GuiWindow window = new GuiWindow(400, 500, "DEBUG");

            Add(window, 0, 0);

            int buttonIndex = 0;

            GuiButton testSerializationButton = new GuiButton("Serialization", -1);

            window.Add(testSerializationButton, 0, 50 + 40 * buttonIndex++);

            GuiButton ResetButton = new GuiButton("Reset", -1);

            ResetButton.ColorTransform = ColorTransform.BlackAndWhite;
            ResetButton.Color          = new Color(1f, 0.4f, 0.3f);
            window.Add(ResetButton, 0, 50 + 40 * buttonIndex++);

            testSerializationButton.OnMouseClicked += delegate {
                testDataSerialization();
            };

            ResetButton.OnMouseClicked += delegate {
                CoM.ConfirmAction(performGameReset, "Are you sure you want to reset the game?");
            };

            window.Add(Util.CreateBackButton(), 0, -10);
        }
Exemple #2
0
        public SelectPartyState(bool allowCreateParty = false)
            : base("SelectPartyState")
        {
            Util.Assert(CoM.CharacterList != null, "Select Party State requires character list to be created before initialization.");

            _allowCreateParty = allowCreateParty;

            GuiWindow window = new GuiWindow(GuiPartySpan.WIDTH + 40, 400);

            window.WindowStyle       = GuiWindowStyle.Titled;
            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = Colors.BackgroundGray;
            window.Title             = "Select Party";
            Add(window, 0, 100);

            partyList       = new GuiScrollableArea(100, 100, ScrollMode.VerticalOnly);
            partyList.Align = GuiAlignment.Full;
            window.Add(partyList);

            GuiWindow buttonsWindow = new GuiWindow(500, 80);

            buttonsWindow.Y = (int)window.Bounds.yMax - 5;
            Add(buttonsWindow, 0);

            GuiButton BackButton = new GuiButton("Back");

            buttonsWindow.Add(BackButton, 0, 0);

            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
        }
Exemple #3
0
        public AboutMenuState()
            : base("AboutState")
        {
            var window = new GuiWindow(420, 400, "About");

            Add(window, 0, 0);

            window.Add(Util.CreateBackButton("Done"), 0, -10);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.4f, 0.42f, 0.62f);

            var scrollBox = new GuiScrollableArea((int)window.ContentsFrame.width, (int)window.ContentsFrame.height - 40, ScrollMode.VerticalOnly);

            window.Add(scrollBox);

            var label = new GuiLabel(0, 20, AboutString, (int)window.ContentsBounds.width - 30);

            label.WordWrap  = true;
            label.TextAlign = TextAnchor.UpperCenter;
            scrollBox.Add(label);

            scrollBox.FitToChildren();
        }
Exemple #4
0
        public TownBuildingState(string name)
            : base(name)
        {
            int uiMargin = 10;

            GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town"));

            Background.BestFit(ContentsFrame);
            Add(Background, 0, 0);

            LeftTwoThirds = new GuiContainer(Width - 340, Height);
            Add(LeftTwoThirds);

            LowerSection = new GuiWindow(0, 0);
            LowerSection.Background.Color = new Color(0.4f, 0.4f, 0.4f);
            LeftTwoThirds.Add(LowerSection);

            MainWindow = new GuiWindow(600, 500, name);
            LeftTwoThirds.Add(MainWindow, 0, 0);

            BackButton = new GuiButton("Back");
            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            LowerSection.Add(BackButton);

            // UI

            Party       = new GuiPartyInfo(0, 0);
            Party.Party = CoM.Party;
            Add(Party, -uiMargin, -uiMargin);

            CharacterInfo = new GuiCharacterTabControl();
            Add(CharacterInfo, -uiMargin, uiMargin);

            ItemInventory = new GuiItemInventory();
            Add(ItemInventory, -uiMargin, CharacterInfo.Height + uiMargin);

            RepositionControls();
        }
Exemple #5
0
        /** Creates the UI componenets required to display the gui */
        private void CreateUIComponents()
        {
            var window = new GuiWindow(800, 560);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.5f, 0.5f, 0.5f);
            PositionComponent(window, 0, 0);
            Add(window);

            // ------------------

            nameInput               = new GuiTextField(0, 0, 200);
            nameInput.Value         = CharacterNameGenerator.GenerateName();
            nameInput.LabelText     = "Name";
            nameInput.LabelPosition = LabelPosition.Left;
            window.Add(nameInput, 0, 20);

            var randomButton = new GuiButton("random", -1, 20);

            window.Add(randomButton, (int)nameInput.Bounds.xMax + 10, 25);

            // ------------------

            var genderListFrame = new FramedListBox <MDRGender>(200, 100, "Gender");

            window.Add(genderListFrame, 260, 100);

            portraitSelector          = new GuiPictureSeletor();
            portraitSelector.Pictures = CoM.Instance.Portraits.GetEntries().ToArray();
            window.Add(portraitSelector, 460, 70 + 18 + 20);

            allRacesToggle                 = new GuiToggleButton();
            allRacesToggle.LabelText       = "Show All";
            allRacesToggle.LabelPosition   = LabelPosition.Right;
            allRacesToggle.X               = (int)portraitSelector.Bounds.xMax + 10;
            allRacesToggle.Y               = (int)portraitSelector.Bounds.y + 30;
            allRacesToggle.Value           = false;
            allRacesToggle.OnValueChanged += delegate {
                updatePortraits();
            };
            window.Add(allRacesToggle);

            // ------------------

            var raceListFrame = new FramedListBox <MDRRace>(200, 240, "Race");

            window.Add(raceListFrame, 20, 240);

            statList = new GuiStatList(new MDRStats());
            window.Add(statList, 220 + 20, 240);

            var characterInfo = new GuiWindow(250, 240, "Info");

            window.Add(characterInfo, 470 + 40, 240);

            characterInfoText          = new GuiLabel(0, 0, "");
            characterInfoText.Align    = GuiAlignment.Full;
            characterInfoText.WordWrap = true;
            characterInfo.Add(characterInfoText);

            // ------------------

            // ------------------

            GuiButton cancelButton = new GuiButton("Cancel", 100);

            window.Add(cancelButton, 20, -20);

            GuiButton doneButton = new GuiButton("Save", 100);

            window.Add(doneButton, -20, -20);


            raceList = raceListFrame.ListBox;
            foreach (MDRRace race in CoM.Races)
            {
                raceList.Add(race);
            }

            genderList = genderListFrame.ListBox;
            genderList.Add(MDRGender.Male);
            genderList.Add(MDRGender.Female);

            genderList.OnSelectedChanged += delegate {
                updateGender();
            };
            raceList.OnSelectedChanged += delegate {
                updateRace();
            };

            doneButton.OnMouseClicked += delegate {
                if (statList.FreePoints != 0)
                {
                    Engine.ConfirmAction(saveAndClose, "This character still has " + Util.Colorise(statList.FreePoints, Color.green) + " stat points left to spend.\nAre you sure you want to save the character without spending them?");
                }
                else
                {
                    saveAndClose();
                }
            };

            cancelButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            randomButton.OnMouseClicked += delegate {
                nameInput.Value = CharacterNameGenerator.GenerateName();
            };

            updateRace();
            updateGender();
        }
Exemple #6
0
        public MainMenuState()
            : base("Main Menu")
        {
            CoM.EnableCamera = true;

            window = new GuiWindow(350, 280);
            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = Colors.BackgroundRed;

            Add(window, 0, 50);

            GuiLabel title = new GuiLabel(0, 0, "ENDURANCE");

            title.Font           = CoM.Instance.TextFont;
            title.FontSize       = 48;
            title.FontColor      = new Color(1, 1, 1, 0.5f);
            title.DropShadow     = true;
            title.ShadowDistance = 2;
            title.Interactive    = true;
            window.Add(title, 0, 22);

            int       currentButtonPosition = 100;
            const int buttonSpacing         = 50;

            bool needsExitButton  = Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.LinuxPlayer;
            bool needsDebugButton = Settings.Advanced.PowerMode;

            // ----------------------------------------

            // ----------------------------------------

            GuiButton PlayButton = new GuiButton("Play");

            window.PositionComponent(PlayButton, 0, currentButtonPosition);
            window.Add(PlayButton);
            currentButtonPosition += buttonSpacing;

            GuiButton SettingsButtton = new GuiButton("Settings");

            window.PositionComponent(SettingsButtton, 0, currentButtonPosition);
            window.Add(SettingsButtton);
            currentButtonPosition += buttonSpacing;

            GuiButton AboutButton = new GuiButton("About");

            window.PositionComponent(AboutButton, 0, currentButtonPosition);
            window.Add(AboutButton);
            currentButtonPosition += buttonSpacing;

            GuiButton ExitButton = new GuiButton("Exit");

            if (needsExitButton)
            {
                window.PositionComponent(ExitButton, 0, currentButtonPosition);
                window.Add(ExitButton);
                currentButtonPosition += buttonSpacing;
                window.Height         += buttonSpacing;
            }

            GuiButton DebugButton = new GuiButton("Debug", 140);

            DebugButton.ColorTransform = ColorTransform.BlackAndWhite;
            DebugButton.Color          = new Color(0.6f, 1.0f, 0.7f);

            if (needsDebugButton)
            {
                window.PositionComponent(DebugButton, 0, currentButtonPosition);
                window.Add(DebugButton);
                window.Height += buttonSpacing;
            }

            title.OnDoubleClicked += delegate {
                if (Settings.Advanced.PowerMode == false)
                {
                    Settings.Advanced.PowerMode = true;
                    window.Add(DebugButton, 0, currentButtonPosition + (4 * buttonSpacing));
                    window.Height += buttonSpacing;
                }
            };

            // ----------------------------------------

            if (Engine.isWeb)
            {
                GuiWindow WebWarningWindow = new GuiWindow(500, 90);
                WebWarningWindow.Add(
                    new GuiLabel(Util.Colorise("Browser preview.\nFor the best experience download the standalone version.", new Color(1f, 0.75f, 0.45f)))
                {
                    TextAlign = TextAnchor.MiddleCenter
                },
                    0, 0);
                Add(WebWarningWindow, 0, -50);
            }

            // ----------------------------------------

            VersionLabel           = new GuiLabel("");
            VersionLabel.FontColor = Color.yellow;
            Add(VersionLabel, -20, 10, true);

            PlayButton.OnMouseClicked += delegate {
                Engine.PushState(new SelectPartyState(true));
            };
            SettingsButtton.OnMouseClicked += delegate {
                Engine.PushState(new SettingsMenuState());
            };
            AboutButton.OnMouseClicked += delegate {
                Engine.PushState(new AboutMenuState());
            };
            ExitButton.OnMouseClicked += delegate {
                Application.Quit();
            };
            DebugButton.OnMouseClicked += delegate {
                Engine.PushState(new DebugMenuState());
            };
            OnStateShow += delegate {
                SoundManager.PlayMusicPlaylist("Intro");
            };

            DefaultControl = PlayButton;

            CoM.Instance.StartCoroutine(updateFadeIn(2f));
        }
Exemple #7
0
        public TownState()
            : base("TownState")
        {
            GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town"));

            Background.BestFit(ContentsFrame);
            Add(Background, 0, 0);

            GuiWindow window = new GuiWindow(400, 260, "Town");

            window.Background.Color = Colors.BackgroundGray;
            Add(window, 0, 0);

            GuiButton MainMenuButton = new GuiButton("Exit", 150);

            MainMenuButton.ColorTransform  = ColorTransform.BlackAndWhite;
            MainMenuButton.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f);
            MainMenuButton.Color           = new Color(1f, 0.4f, 0.3f);

            GuiButton storeButton  = new GuiButton("General Store", 150);
            GuiButton templeButton = new GuiButton("Temple", 150);
            GuiButton guildButton  = new GuiButton("Guild", 150);

            GuiButton tavernButton  = new GuiButton("Tavern", 150);
            GuiButton libraryButton = new GuiButton("Library", 150);
            GuiButton bankButton    = new GuiButton("Bank", 150);
            GuiButton dungeonButton = new GuiButton("Dungeon", 150);

            int buttonY = 25;

            window.Add(MainMenuButton, 0, buttonY - 5);

            window.Add(storeButton, 20, buttonY + 40 * 1);
            window.Add(templeButton, 20, buttonY + 40 * 2);
            window.Add(guildButton, 20, buttonY + 40 * 3);

            window.Add(tavernButton, -20, buttonY + 40 * 1);
            window.Add(libraryButton, -20, buttonY + 40 * 2);
            window.Add(bankButton, -20, buttonY + 40 * 3);

            window.Add(dungeonButton, 0, -20);

            storeButton.OnMouseClicked += delegate {
                Engine.PushState(new StoreState());
            };

            guildButton.OnMouseClicked += delegate {
                Engine.PushState(new GuildState());
            };

            templeButton.OnMouseClicked += delegate {
                Engine.PushState(new TempleState());
            };

            bankButton.OnMouseClicked += delegate {
                Engine.PushState(new BankState());
            };

            libraryButton.OnMouseClicked += delegate {
                Engine.PushState(new LibraryState());
            };


            MainMenuButton.OnMouseClicked += CoM.ReturnToMainMenu;

            OnStateShow += delegate {
                SoundManager.PlayMusicPlaylist("City");
            };

            // these are not implemented yet.
            tavernButton.SelfEnabled = false;
            bankButton.SelfEnabled   = false;

            dungeonButton.OnMouseClicked += delegate {
                if (CoM.Party.LivingMembers == 0)
                {
                    Engine.ShowModal("Can Not Enter Dungeon.", "All party memebers are dead.");
                }
                else
                {
                    CoM.Party.Depth = 1;
                    PartyController.Instance.SyncCamera();
                    Engine.PopState();
                }
            };
        }
Exemple #8
0
        public SettingsMenuState() : base("Settings Menu")
        {
            TransparentDraw = true;

            MainWindow = new GuiWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Settings");
            Add(MainWindow, 0, 0);

            var buttonsGroup = new GuiRadioButtonGroup();

            buttonsGroup.AddItem("General");
            if (Settings.Advanced.PowerMode)
            {
                buttonsGroup.AddItem("Advanced");
            }
            if (Settings.Advanced.PowerMode)
            {
                buttonsGroup.AddItem("Information");
            }
            buttonsGroup.OnValueChanged += delegate {
                switch (buttonsGroup.SelectedIndex)
                {
                case 0:
                    setSettingsGroup(generalGroup);
                    break;

                case 1:
                    setSettingsGroup(advancedGroup);
                    break;

                case 2:
                    setSettingsGroup(informationGroup);
                    break;
                }
            };
            buttonsGroup.EnableBackground = false;
            buttonsGroup.Align            = GuiAlignment.Top;
            MainWindow.Add(buttonsGroup);

            var closeButton = new GuiButton("Close");

            MainWindow.Add(closeButton, -10, -10);

            var resetButton = new GuiButton("Reset");

            MainWindow.Add(resetButton, 10, -10);

            CreateSettingsControls();

            previousSoundFXLevel = Settings.General.SoundFXVolume;

            closeButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            resetButton.OnMouseClicked += delegate {
                Engine.ConfirmAction(Settings.ResetSettings, "Are you sure you want to reset the settings?");
            };

            Settings.Advanced.OnValueChanged += UpdateControls;
            Settings.General.OnValueChanged  += UpdateControls;

            setSettingsGroup(generalGroup);
        }
Exemple #9
0
 private void CreateSettingsControls()
 {
     generalGroup     = MainWindow.Add(CreateUIFromSettingsGroup(Settings.General), 0, 0);
     advancedGroup    = MainWindow.Add(CreateUIFromSettingsGroup(Settings.Advanced), 0, 0);
     informationGroup = MainWindow.Add(CreateUIFromSettingsGroup(Settings.Information), 0, 0);
 }