Пример #1
0
        /**
         * Creates a new ModalList state.
         *
         * @param title Title to display at top of list
         * @param objects A list of objects that will be selected from
         * @param canCancel If true a cancel button is included which will close the window and return a null result
         */
        public ModalOptionListState(string title, List <T> objects, bool canCancel = true)
            : base(title)
        {
            GuiListBox <T> ListBox = new GuiListBox <T>(10, 10, Window.Width - 20, Window.Height - 80);

            foreach (T item in objects)
            {
                ListBox.Add(item);
            }

            GuiButton ConfirmationButton = new GuiButton("OK", 120, 30);

            ConfirmationButton.OnMouseClicked += delegate {
                Result = ListBox.Selected;
                Close();
            };

            GuiButton CancelButton = new GuiButton("Cancel", 120, 30);

            CancelButton.OnMouseClicked += delegate {
                Result = default(T);
                Close();
            };

            Window.Add(ListBox);
            Window.Add(ConfirmationButton, -20, -20);
            if (canCancel)
            {
                Window.Add(CancelButton, 20, -20);
            }
        }
Пример #2
0
 /** Updates list of monsters based on the current GameStats */
 private void CreateListings()
 {
     foreach (MonsterStatRecord record in CoM.GameStats.MonsterStats.Values)
     {
         if (record.NumberSeen == 0)
         {
             continue;
         }
         MonsterList.Add(record.Monster);
     }
     MonsterInfo.Monster = MonsterList.Selected;
 }
Пример #3
0
 /** Updates list of items based on the current GameStats */
 private void CreateListings()
 {
     foreach (ItemStatRecord record in CoM.GameStats.ItemStats.Values)
     {
         if (record.NumberFound == 0)
         {
             continue;
         }
         ItemList.Add(MDRItemInstance.Create(record.Item, record.IDLevel));
     }
     SyncItemInfo(null, null);
 }
Пример #4
0
 /**
  * Populates listbox with all dead characters currently in the morgue
  */
 private void PopulateDeadCharacterList()
 {
     deadCharactersList.Clear();
     foreach (MDRCharacter character in CoM.CharacterList)
     {
         if (character.IsDead && character.IsInTown)
         {
             deadCharactersList.Add(character);
         }
     }
     doUpdateRaiseInfo();
     raiseCharacterButton.SelfEnabled = deadCharactersList.Count > 0;
 }
Пример #5
0
        /**
         * Populates the guild list with guilds this character is able to join
         */
        private void updateGuildList()
        {
            GuildList.Clear();
            foreach (MDRGuild guild in CoM.Guilds)
            {
                if (guild.CanAcceptRace(Character.Race))
                {
                    GuildList.Add(guild);
                }
            }

            GuildList.Selected = Character.CurrentGuild;
        }
Пример #6
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();
        }