//updates labels / icons etc. when something has changed
        void UpdateSelection()
        {
            if (!ValidIndex)
            {
                if (listBox.Count > 0)
                {
                    listBox.SelectedIndex = 0;
                    scrollBar.ScrollIndex = 0;
                }
                else
                {
                    return;
                }
            }

            scrollBar.Reset(listBox.RowsDisplayed, listBox.Count, listBox.ScrollIndex);
            scrollBar.TotalUnits  = listBox.Count;
            scrollBar.ScrollIndex = listBox.ScrollIndex;
            spellName.Text        = listBox.SelectedItem;

            ///TODO:
            ///1. set spell icons
            ///2. set spell effect labels
            ///3. update magica cost

            Refresh = false;
        }
Exemple #2
0
 private void StartGameBehaviour_OnNewGame()
 {
     // Reset certain elements on a new game
     if (IsSetup)
     {
         SelectActionMode(ActionModes.Equip);
         SelectTabPage(TabPages.WeaponsAndArmor);
         localItemsScrollBar.Reset(listDisplayUnits);
         remoteItemsScrollBar.Reset(listDisplayUnits);
     }
 }
Exemple #3
0
        void SelectTabPage(TabPages tabPage)
        {
            // Select new tab page
            selectedTabPage = tabPage;

            // Reset scrollbar
            localItemsScrollBar.Reset(listDisplayUnits);

            // Clear all button selections
            weaponsAndArmorButton.BackgroundTexture = weaponsAndArmorNotSelected;
            magicItemsButton.BackgroundTexture      = magicItemsNotSelected;
            clothingAndMiscButton.BackgroundTexture = clothingAndMiscNotSelected;
            ingredientsButton.BackgroundTexture     = ingredientsNotSelected;

            // Set new button selection texture background
            switch (tabPage)
            {
            case TabPages.WeaponsAndArmor:
                weaponsAndArmorButton.BackgroundTexture = weaponsAndArmorSelected;
                break;

            case TabPages.MagicItems:
                magicItemsButton.BackgroundTexture = magicItemsSelected;
                break;

            case TabPages.ClothingAndMisc:
                clothingAndMiscButton.BackgroundTexture = clothingAndMiscSelected;
                break;

            case TabPages.Ingredients:
                ingredientsButton.BackgroundTexture = ingredientsSelected;
                break;
            }

            // Update filtered list
            FilterLocalItems();
            UpdateLocalItemsDisplay();
        }
Exemple #4
0
        /// <summary>
        /// Gets safe scroll index.
        /// Scroller will be adjust to always be inside display range where possible.
        /// </summary>
        int GetSafeScrollIndex(VerticalScrollBar scroller)
        {
            int scrollIndex = scroller.ScrollIndex;

            if (scrollIndex + scroller.DisplayUnits > scroller.TotalUnits)
            {
                scrollIndex = scroller.TotalUnits - scroller.DisplayUnits;
                if (scrollIndex < 0)
                {
                    scrollIndex = 0;
                }
                scroller.Reset(scroller.DisplayUnits, scroller.TotalUnits, scrollIndex);
            }

            return(scrollIndex);
        }
Exemple #5
0
        void UpdateSelection()
        {
            // Update spell list scroller
            spellsListScrollBar.Reset(spellsListBox.RowsDisplayed, spellsListBox.Count, spellsListBox.ScrollIndex);
            spellsListScrollBar.TotalUnits  = spellsListBox.Count;
            spellsListScrollBar.ScrollIndex = spellsListBox.ScrollIndex;

            // Get spell and exit if spell index not found
            EffectBundleSettings spellSettings;

            if (!GameManager.Instance.PlayerEntity.GetSpell(spellsListBox.SelectedIndex, out spellSettings))
            {
                return;
            }

            // Update spell name label
            spellNameLabel.Text = spellSettings.Name;

            // Update effect labels
            for (int i = 0; i < 3; i++)
            {
                if (i < spellSettings.Effects.Length)
                {
                    SetEffectLabels(spellSettings.Effects[i].Key, i);
                }
                else
                {
                    SetEffectLabels(string.Empty, i);
                }
            }

            // Update spell icons
            spellIconPanel.BackgroundTexture        = GetSpellIcon(spellSettings.IconIndex);
            spellTargetIconPanel.BackgroundTexture  = GetSpellTargetIcon(spellSettings.TargetType);
            spellElementIconPanel.BackgroundTexture = GetSpellElementIcon(spellSettings.ElementType);
        }
        void UpdateSelection()
        {
            // Update spell list scroller
            spellsListScrollBar.Reset(spellsListBox.RowsDisplayed, spellsListBox.Count, spellsListBox.ScrollIndex);
            spellsListScrollBar.TotalUnits  = spellsListBox.Count;
            spellsListScrollBar.ScrollIndex = spellsListBox.ScrollIndex;

            // Get spell settings selected from player spellbook or offered spells
            EffectBundleSettings spellSettings;

            if (buyMode)
            {
                spellSettings = offeredSpells[spellsListBox.SelectedIndex];

                // The price shown in buy mode is the player casting cost * 4
                int goldCost, spellPointCost;
                FormulaHelper.CalculateTotalEffectCosts(spellSettings.Effects, spellSettings.TargetType, out goldCost, out spellPointCost);
                presentedCost = spellPointCost * 4;

                // Presented cost is halved on Witches Festival holiday
                uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
                int  holidayID   = FormulaHelper.GetHolidayId(gameMinutes, 0);
                if (holidayID == (int)DaggerfallConnect.DFLocation.Holidays.Witches_Festival)
                {
                    presentedCost >>= 1;
                    if (presentedCost == 0)
                    {
                        presentedCost = 1;
                    }
                }

                spellCostLabel.Text = presentedCost.ToString();
            }
            else
            {
                // Get spell and exit if spell index not found
                if (!GameManager.Instance.PlayerEntity.GetSpell(spellsListBox.SelectedIndex, out spellSettings))
                {
                    spellNameLabel.Text = string.Empty;
                    ClearEffectLabels();
                    ShowIcons(false);
                    return;
                }
            }

            // Update spell name label
            spellNameLabel.Text = spellSettings.Name;

            // Update effect labels
            for (int i = 0; i < 3; i++)
            {
                if (i < spellSettings.Effects.Length)
                {
                    SetEffectLabels(spellSettings.Effects[i].Key, i);
                }
                else
                {
                    SetEffectLabels(string.Empty, i);
                }
            }

            // Update spell icons
            spellIconPanel.BackgroundTexture        = GetSpellIcon(spellSettings.Icon);
            spellTargetIconPanel.BackgroundTexture  = GetSpellTargetIcon(spellSettings.TargetType);
            spellTargetIconPanel.ToolTipText        = GetTargetTypeDescription(spellSettings.TargetType);
            spellElementIconPanel.BackgroundTexture = GetSpellElementIcon(spellSettings.ElementType);
            spellElementIconPanel.ToolTipText       = GetElementDescription(spellSettings.ElementType);
            ShowIcons(true);
        }