Exemplo n.º 1
0
        private void GettingQuestsBox_OnClose()
        {
            DaggerfallListPickerWindow questPicker = new DaggerfallListPickerWindow(uiManager, uiManager.TopWindow);

            questPicker.OnItemPicked += QuestPicker_OnItemPicked;
            // Populate a list with quests that the player can choose from.
            List <int> failures = new List <int>();

            for (int i = 0; i < questPool.Count; i++)
            {
                try
                {
                    // Partially loading the quest to get the human readable quest name.
                    Quest quest = GameManager.Instance.QuestListsManager.LoadQuest(questPool[i], GetFactionIdForGuild(), true);
                    questPicker.ListBox.AddItem(quest.DisplayName ?? quest.QuestName);
                    quest.Dispose();
                }
                catch (Exception)
                {
                    failures.Add(i);  // Add to list any that fail (partial) parsing
                }
            }
            // Remove any quests that failed partial parsing
            foreach (int i in failures)
            {
                questPool.RemoveAt(i);
            }

            uiManager.PushWindow(questPicker);
        }
        private void GettingQuestsBox_OnClose()
        {
            DaggerfallListPickerWindow questPicker = new DaggerfallListPickerWindow(uiManager, uiManager.TopWindow);

            questPicker.OnItemPicked += QuestPicker_OnItemPicked;
            for (int i = 0; i < questPool.Count; i++)
            {
                try
                {
                    Quest quest = GameManager.Instance.QuestListsManager.LoadQuest(questPool[i], GetFactionIdForGuild());
                    if (quest != null)
                    {
                        questPicker.ListBox.AddItem(quest.DisplayName == null ? quest.QuestName : quest.DisplayName);
                    }
                    else
                    {
                        questPool.RemoveAt(i);  // Remove any that fail compilation
                    }
                }
                catch (Exception)
                {
                    questPool.RemoveAt(i);  // Remove any that throw exceptions
                }
            }
            uiManager.PushWindow(questPicker);
        }
Exemplo n.º 3
0
        public void ConfirmTraining_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                if (playerEntity.GetGoldAmount() >= GetServicePrice())
                {
                    // Show skill picker loaded with guild training skills
                    DaggerfallListPickerWindow skillPicker = new DaggerfallListPickerWindow(uiManager, this);
                    skillPicker.OnItemPicked += TrainingSkill_OnItemPicked;

                    List <DFCareer.Skills> trainingSkills;
                    if (guildTrainingSkills.TryGetValue(service, out trainingSkills))
                    {
                        foreach (DFCareer.Skills skill in trainingSkills)
                        {
                            skillPicker.ListBox.AddItem(DaggerfallUnity.Instance.TextProvider.GetSkillName(skill));
                        }

                        uiManager.PushWindow(skillPicker);
                    }
                }
                else
                {
                    DaggerfallUI.MessageBox(notEnoughGoldId);
                }
            }
        }
Exemplo n.º 4
0
        private void SwitchCharButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallListPickerWindow picker = new DaggerfallListPickerWindow(uiManager, this);

            // Get ordered list of character names
            List <string> names = new List <string>();

            names.AddRange(GameManager.Instance.SaveLoadManager.CharacterNames);
            List <string> orderedNames = names.OrderBy(o => o).ToList();

            // Add to picker list
            foreach (string name in orderedNames)
            {
                picker.ListBox.AddItem(name);
            }

            // Select current character
            picker.ListBox.SelectedIndex = picker.ListBox.FindIndex(currentPlayerName);

            // Add event for selection
            picker.OnItemPicked += Picker_OnItemPicked;

            // Show window
            uiManager.PushWindow(picker);
        }
Exemplo n.º 5
0
 void HelpButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     helpPicker = new DaggerfallListPickerWindow(uiManager, this);
     foreach (string str in helpDict.Keys)
     {
         helpPicker.ListBox.AddItem(str);
     }
     helpPicker.OnItemPicked += HelpPicker_OnItemPicked;
     uiManager.PushWindow(helpPicker);
 }
Exemplo n.º 6
0
        void SetupPickers()
        {
            // Use a picker for power/side-effect primary selection
            enchantmentPrimaryPicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, 12);
            enchantmentPrimaryPicker.ListBox.OnUseSelectedItem += EnchantmentPrimaryPicker_OnUseSelectedItem;

            // Use another picker for power/side-effect secondary selection
            enchantmentSecondaryPicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, 12);
            enchantmentSecondaryPicker.ListBox.OnUseSelectedItem += EnchantmentSecondaryPicker_OnUseSelectedItem;
        }
        void SetupPickers()
        {
            // Use a picker for effect group
            effectGroupPicker = new DaggerfallListPickerWindow(uiManager, this);
            effectGroupPicker.ListBox.OnUseSelectedItem += AddEffectGroupListBox_OnUseSelectedItem;

            // Use another picker for effect subgroup
            // This allows user to hit escape and return to effect group list, unlike classic which dumps whole spellmaker UI
            effectSubGroupPicker = new DaggerfallListPickerWindow(uiManager, this);
            effectSubGroupPicker.ListBox.OnUseSelectedItem += AddEffectSubGroup_OnUseSelectedItem;
        }
Exemplo n.º 8
0
 void skillButton_OnMouseClick(BaseScreenComponent sender, Vector2 pos)
 {
     skillPicker = new DaggerfallListPickerWindow(uiManager, this);
     skillPicker.OnItemPicked += SkillPicker_OnItemPicked;
     foreach (string skillName in skillsList)
     {
         skillPicker.ListBox.AddItem(skillName);
     }
     lastSkillButtonId = (int)sender.Tag;
     uiManager.PushWindow(skillPicker);
 }
        private void GettingQuestsBox_OnClose()
        {
            DaggerfallListPickerWindow questPicker = new DaggerfallListPickerWindow(uiManager, uiManager.TopWindow);

            questPicker.OnItemPicked += QuestPicker_OnItemPicked;
            questPicker.OnClose      += QuestPicker_OnClose;
            // Populate a list with quests that the player can choose from.
            for (int i = 0; i < questPool.Count; i++)
            {
                // Fully loading the quest is currently the only way to get the human readable quest name.
                // @TODO: remove this when the QuestListsManager can get at display names too.
                Quest quest = GameManager.Instance.QuestListsManager.LoadQuest(questPool[i], GetFactionIdForGuild());
                if (quest != null)
                {
                    loadedQuests.Add(quest);
                    questPicker.ListBox.AddItem(quest.DisplayName ?? quest.QuestName);
                }
            }
            uiManager.PushWindow(questPicker);
        }
Exemplo n.º 10
0
        void AddAdvantageButton_OnMouseClick(BaseScreenComponent sender, Vector2 pos)
        {
            string[] items;

            if (advDisList.Count == maxItems)
            {
                return;
            }

            DaggerfallListPickerWindow advantagePicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, advPickerItemCount);

            advantagePicker.OnItemPicked += AdvantagePicker_OnItemPicked;

            items = isDisadvantages ? disadvantageStrings : advantageStrings;
            foreach (string s in items)
            {
                advantagePicker.ListBox.AddItem(s);
            }

            uiManager.PushWindow(advantagePicker);
        }
        protected virtual void DoFoodAndDrink()
        {
            CloseWindow();
            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            if ((gameMinutes - (GameManager.Instance.PlayerEntity.LastTimePlayerAteOrDrankAtTavern)) >= 240)
            {
                DaggerfallListPickerWindow foodAndDrinkPicker = new DaggerfallListPickerWindow(uiManager, this);
                foodAndDrinkPicker.OnItemPicked += FoodAndDrink_OnItemPicked;

                foreach (string menuItem in tavernMenu)
                {
                    foodAndDrinkPicker.ListBox.AddItem(menuItem);
                }

                uiManager.PushWindow(foodAndDrinkPicker);
            }
            else
            {
                DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("youAreNotHungry"));
            }
        }
Exemplo n.º 12
0
        private void FoodButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            CloseWindow();
            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            if ((gameMinutes - (GameManager.Instance.PlayerEntity.LastTimePlayerAteOrDrankAtTavern)) >= 240)
            {
                DaggerfallListPickerWindow foodAndDrinkPicker = new DaggerfallListPickerWindow(uiManager, this);
                foodAndDrinkPicker.OnItemPicked += FoodAndDrink_OnItemPicked;

                foreach (string menuItem in tavernMenu)
                {
                    foodAndDrinkPicker.ListBox.AddItem(menuItem);
                }

                uiManager.PushWindow(foodAndDrinkPicker);
            }
            else
            {
                DaggerfallUI.MessageBox(HardStrings.youAreNotHungry);
            }
        }
Exemplo n.º 13
0
        protected override void Setup()
        {
            // Load textures
            LoadTextures();

            // Always dim background
            ParentPanel.BackgroundColor = ScreenDimColor;

            // Setup native panel background
            NativePanel.BackgroundColor   = new Color(0, 0, 0, 0.60f);
            NativePanel.BackgroundTexture = baseTexture;

            // Setup UI
            SetupLabels();
            SetupButtons();
            SetupItemListScrollers();

            recipePicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, 12);
            recipePicker.OnItemPicked += RecipePicker_OnItemPicked;

            Refresh();
        }
        protected virtual void ConfirmTraining_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                if (playerEntity.GetGoldAmount() >= Guild.GetTrainingPrice())
                {
                    // Show skill picker loaded with guild training skills
                    DaggerfallListPickerWindow skillPicker = new DaggerfallListPickerWindow(uiManager, this);
                    skillPicker.OnItemPicked += TrainingSkill_OnItemPicked;

                    foreach (DFCareer.Skills skill in GetTrainingSkills())
                    {
                        skillPicker.ListBox.AddItem(DaggerfallUnity.Instance.TextProvider.GetSkillName(skill));
                    }

                    uiManager.PushWindow(skillPicker);
                }
                else
                {
                    DaggerfallUI.MessageBox(DaggerfallTradeWindow.NotEnoughGoldId);
                }
            }
        }
        //creates a ListPickerWindow with a list of locations from current region
        //locations displayed will be filtered out depending on the dungeon / town / temple / home button settings
        private void ShowLocationPicker()
        {
            if (!RegionSelected || currentDFRegion.LocationCount < 1)
                return;

            //int filteredCount = 0;
            //if (townsFilterButtonEnabled)
            //    filteredCount++;
            //if (dungeonFilterButtonEnabled)
            //    filteredCount++;
            //if (templesFilterButtonEnabled)
            //    filteredCount++;
            //if (townsFilterButtonEnabled)
            //    filteredCount++;

            DaggerfallListPickerWindow locationPicker = new DaggerfallListPickerWindow(uiManager, this);
            locationPicker.OnItemPicked += HandleLocationPickEvent;
            locationPicker.ListBox.MaxCharacters = 29;

            string[] locations = currentDFRegion.MapNames.OrderBy(p => p).ToArray();

            for (int i = 0; i < locations.Length; i++)
            {

                //if (locationPicker.ListBox.Count > 500)
                //{
                //    if (filteredCount > 1)
                //    {
                //        DaggerfallMessageBox errorBox = new DaggerfallMessageBox(uiManager, this);
                //        errorBox.AllowCancel = true;
                //        errorBox.ClickAnywhereToClose = true;
                //        errorBox.SetText("Too many location to display. Please use filters");
                //        uiManager.PushWindow(errorBox);
                //        locations = null;
                //        locationPicker = null;
                //        return;
                //    }
                //}

                int index = currentDFRegion.MapNameLookup[locations[i]];
                if (GetPixelColorIndex(currentDFRegion.MapTable[index].LocationType) == -1)
                    continue;
                else
                    locationPicker.ListBox.AddItem(locations[i]);
            }

            uiManager.PushWindow(locationPicker);
        }
        private void SwitchCharButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallListPickerWindow picker = new DaggerfallListPickerWindow(uiManager, this);

            // Get ordered list of character names
            List<string> names = new List<string>();
            names.AddRange(GameManager.Instance.SaveLoadManager.CharacterNames);
            List<string> orderedNames = names.OrderBy(o => o).ToList();

            // Add to picker list
            foreach (string name in orderedNames)
            {
                picker.ListBox.AddItem(name);
            }

            // Select current character
            picker.ListBox.SelectedIndex = picker.ListBox.FindIndex(currentPlayerName);

            // Add event for selection
            picker.OnItemPicked += Picker_OnItemPicked;

            // Show window
            uiManager.PushWindow(picker);
        }
Exemplo n.º 17
0
        void AdvantagePicker_OnItemPicked(int index, string advantageName)
        {
            CloseWindow();

            SpecialAdvDis s = new SpecialAdvDis
            {
                primaryString     = advantageName
                , secondaryString = string.Empty
            };

            string[] secondaryList = null;
            // advantages/disadvantages with secondary options
            switch (advantageName)
            {
            case HardStrings.bonusToHit:
            case HardStrings.phobia:
                secondaryList = enemyTypeStrings;
                break;

            case HardStrings.expertiseIn:
            case HardStrings.forbiddenWeaponry:
                secondaryList = weaponTypeStrings;
                break;

            case HardStrings.immunity:
            case HardStrings.resistance:
            case HardStrings.criticalWeakness:
                secondaryList = effectTypeStrings;
                break;

            case HardStrings.increasedMagery:
                // limit to 1 magery increase advantage for the character
                bool alreadyAdded = false;
                foreach (SpecialAdvDis item in advDisList)
                {
                    if (item.primaryString == HardStrings.increasedMagery)
                    {
                        alreadyAdded = true;
                    }
                }
                if (alreadyAdded)
                {
                    return;
                }
                secondaryList = increasedMageryStrings;
                break;

            case HardStrings.rapidHealing:
            case HardStrings.spellAbsorption:
                secondaryList = effectEnvStrings;
                break;

            case HardStrings.regenerateHealth:
                secondaryList = regenHealthStrings;
                break;

            case HardStrings.damage:
                secondaryList = damageEnvStrings;
                break;

            case HardStrings.darknessPoweredMagery:
                secondaryList = darknessPoweredStrings;
                break;

            case HardStrings.forbiddenArmorType:
                secondaryList = armorTypeStrings;
                break;

            case HardStrings.forbiddenMaterial:
                secondaryList = materialStrings;
                break;

            case HardStrings.forbiddenShieldTypes:
                secondaryList = shieldTypeStrings;
                break;

            case HardStrings.lightPoweredMagery:
                secondaryList = lightPoweredStrings;
                break;

            case HardStrings.lowTolerance:
                secondaryList = effectTypeStrings;
                break;

            default:
                break;
            }
            if (secondaryList == null)
            {
                if (CannotAddAdvantage(s))
                {
                    return;
                }
                s = new SpecialAdvDis
                {
                    primaryString     = advantageName
                    , secondaryString = string.Empty
                    , difficulty      = GetAdvDisAdjustment(advantageName, string.Empty)
                };
                advDisList.Add(s);
                UpdateLabels();
                UpdateDifficultyAdjustment();
            }
            else
            {
                DaggerfallListPickerWindow secondaryPicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, advPickerItemCount);
                secondaryPicker.ListBox.Font  = DaggerfallUI.SmallFont;
                secondaryPicker.OnItemPicked += SecondaryPicker_OnItemPicked;
                secondaryPicker.OnCancel     += SecondaryPicker_OnCancel;
                foreach (string secondaryString in secondaryList)
                {
                    secondaryPicker.ListBox.AddItem(secondaryString);
                }
                uiManager.PushWindow(secondaryPicker);
                advDisList.Add(s);
            }
        }
Exemplo n.º 18
0
        protected override void Setup()
        {
            if (IsSetup)
            {
                return;
            }

            base.Setup();

            // Load native texture
            nativeTexture        = DaggerfallUI.GetTextureFromImg(nativeImgName);
            nativeOverlayTexture = DaggerfallUI.GetTextureFromImg(nativeImgOverlayName);
            if (!nativeTexture || !nativeOverlayTexture)
            {
                throw new Exception("CreateCharSpecialAdvantage: Could not load native texture.");
            }

            // Create panel for window
            advantagePanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName);
            advantagePanel.HorizontalAlignment     = HorizontalAlignment.Left;
            advantagePanel.VerticalAlignment       = VerticalAlignment.Top;
            advantagePanel.BackgroundTexture       = nativeTexture;
            advantagePanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill;
            NativePanel.Components.Add(advantagePanel);

            // Setup UI components
            font = DaggerfallUI.SmallFont;
            Panel buttonPanel = NativePanel;

            if (!isDisadvantages)  // Adding this overlay makes it appear as Special Advantages instead of Disadvantages
            {
                overlayPanel.Size = TextureReplacement.GetSize(nativeOverlayTexture, nativeImgOverlayName);
                overlayPanel.HorizontalAlignment     = HorizontalAlignment.Left;
                overlayPanel.VerticalAlignment       = VerticalAlignment.Top;
                overlayPanel.BackgroundTexture       = nativeOverlayTexture;
                overlayPanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill;
                advantagePanel.Components.Add(overlayPanel);
                buttonPanel = overlayPanel;
            }
            addAdvantageButton = DaggerfallUI.AddButton(addAdvantageButtonRect, buttonPanel);
            addAdvantageButton.OnMouseClick += AddAdvantageButton_OnMouseClick;
            addAdvantageButton.ClickSound    = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick);
            exitButton = DaggerfallUI.AddButton(exitButtonRect, NativePanel);
            exitButton.OnMouseClick += ExitButton_OnMouseClick;
            exitButton.ClickSound    = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick);
            for (int i = 0; i < maxLabels; i++)
            {
                advantageLabels[i] = DaggerfallUI.AddTextLabel(font, new Vector2(8, 35 + i * labelSpacing), string.Empty, NativePanel);
                advantageLabels[i].OnMouseClick += AdvantageLabel_OnMouseClick;
                advantageLabels[i].Tag           = -1;
            }
            UpdateLabels();
            InitializeAdjustmentDict();

            primaryPicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, advPickerItemCount);
            primaryPicker.OnItemPicked += PrimaryPicker_OnItemPicked;

            secondaryPicker = new DaggerfallListPickerWindow(uiManager, this, DaggerfallUI.SmallFont, advPickerItemCount);
            secondaryPicker.ListBox.Font  = DaggerfallUI.SmallFont;
            secondaryPicker.OnItemPicked += SecondaryPicker_OnItemPicked;
            secondaryPicker.OnCancel     += SecondaryPicker_OnCancel;

            IsSetup = true;
        }