void GetLoadedMods() { var mods = ModManager.Instance.GetAllMods(); modList.ClearItems(); if (modSettings == null || modSettings.Length != mods.Length) { modSettings = new ModSettings[mods.Length]; } for (int i = 0; i < mods.Length; i++) { ModSettings modsett = new ModSettings(); modsett.modInfo = mods[i].ModInfo; modsett.enabled = mods[i].Enabled; modSettings[i] = modsett; modList.AddItem(modsett.modInfo.ModTitle, out ListBox.ListItem item); item.textColor = modsett.enabled ? unselectedTextColor : disabledModTextColor; } if (modList.SelectedIndex < 0 || modList.SelectedIndex >= modList.Count) { modList.SelectedIndex = 0; } mods = null; }
void Refresh() { ListBox.ClearItems(); foreach (DaggerfallUnityItem magicUseItem in magicUseItems) { ListBox.AddItem(magicUseItem.LongName); } }
void RefreshSpellsList() { // Clear existing list spellsListBox.ClearItems(); // Add spells based on mode if (buyMode) { // Load spells for sale offeredSpells.Clear(); List <SpellRecord.SpellRecordData> standardSpells = DaggerfallSpellReader.ReadSpellsFile(Path.Combine(DaggerfallUnity.Arena2Path, spellsFilename)); if (standardSpells == null || standardSpells.Count == 0) { Debug.LogError("Failed to load SPELLS.STD for spellbook in buy mode."); return; } for (int i = 0; i < standardSpells.Count; i++) { // Filter internal spells starting with exclamation point '!' if (standardSpells[i].spellName.StartsWith("!")) { continue; } // NOTE: Classic allows purchase of duplicate spells // If ever changing this, must ensure spell is an *exact* duplicate (i.e. not a custom spell with same name) // Just allowing duplicates for now as per classic and let user manage preference // Get effect bundle settings from classic spell EffectBundleSettings bundle; if (!GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(standardSpells[i], BundleTypes.Spell, out bundle)) { continue; } // Store offered spell and add to list box offeredSpells.Add(bundle); spellsListBox.AddItem(standardSpells[i].spellName); } } else { // Add player spells to list EffectBundleSettings[] spellbook = GameManager.Instance.PlayerEntity.GetSpells(); if (spellbook != null) { for (int i = 0; i < spellbook.Length; i++) { // Show spell name and cost // Costs can change based on player skills and stats so must be calculated each time int goldCost, spellPointCost; FormulaHelper.CalculateTotalEffectCosts(spellbook[i].Effects, spellbook[i].TargetType, out goldCost, out spellPointCost); spellsListBox.AddItem(string.Format("{0} - {1}", spellPointCost, spellbook[i].Name)); } } } }
void UpdateSavesList() { // Clear saves list savesList.ClearItems(); // Get most recent save int mostRecentSave = GameManager.Instance.SaveLoadManager.FindMostRecentSave(); if (mode == Modes.LoadGame && mostRecentSave == -1) { // No saves found, prompt to load a classic save promptLabel.Text = HardStrings.noSavesFound; return; } else { // If set to display most recent character use that instead if (displayMostRecentChar) { SaveInfo_v1 latestSaveInfo = GameManager.Instance.SaveLoadManager.GetSaveInfo(mostRecentSave); currentPlayerName = latestSaveInfo.characterName; } } // Build list of saves List <SaveInfo_v1> saves = new List <SaveInfo_v1>(); int[] saveKeys = GameManager.Instance.SaveLoadManager.GetCharacterSaveKeys(currentPlayerName); foreach (int key in saveKeys) { SaveInfo_v1 saveInfo = GameManager.Instance.SaveLoadManager.GetSaveInfo(key); saves.Add(saveInfo); } // Order by save time List <SaveInfo_v1> orderedSaves = saves.OrderByDescending(o => o.dateAndTime.realTime).ToList(); // Updates saves list foreach (SaveInfo_v1 saveInfo in orderedSaves) { savesList.AddItem(saveInfo.saveName); } savesScroller.TotalUnits = savesList.Count; // Update prompt string promptText = string.Empty; if (mode == Modes.SaveGame) { promptText = savePromptText; } else if (mode == Modes.LoadGame) { promptText = loadPromptText; } promptLabel.Text = string.Format("{0} for '{1}'", promptText, currentPlayerName); }
void RefreshSpellsList(bool preservePosition) { // Preserve indices before ClearItems() int oldScrollIndex = spellsListBox.ScrollIndex; int oldSelectedIndex = spellsListBox.SelectedIndex; // Clear existing list spellsListBox.ClearItems(); // Add spells based on mode if (buyMode) { LoadSpellsForSale(); // I'm not sure GameManager.Instance.PlayerEntity.MaxMagicka would be a good idea here PopulateSpellsList(offeredSpells, null); } else { // Add player spells to list EffectBundleSettings[] spellbook = GameManager.Instance.PlayerEntity.GetSpells(); if (spellbook != null) { PopulateSpellsList(spellbook.ToList(), GameManager.Instance.PlayerEntity.CurrentMagicka); } } if (preservePosition) { spellsListBox.ScrollIndex = oldScrollIndex; if (oldSelectedIndex >= spellsListBox.Count) { if (spellsListBox.Count > 0) { spellsListBox.SelectedIndex = spellsListBox.Count - 1; } else { spellsListBox.SelectNone(); } } else { spellsListBox.SelectedIndex = oldSelectedIndex; } } }
void RefreshSpellsList() { // Clear existing list spellsListBox.ClearItems(); // Add player spells to list EffectBundleSettings[] spellbook = GameManager.Instance.PlayerEntity.GetSpells(); if (spellbook != null) { for (int i = 0; i < spellbook.Length; i++) { // Show spell name and cost // Costs can change based on player skills and stats so must be calculated each time int goldCost, spellPointCost; FormulaHelper.CalculateTotalEffectCosts(spellbook[i].Effects, spellbook[i].TargetType, out goldCost, out spellPointCost); spellsListBox.AddItem(string.Format("{0} - {1}", spellPointCost, spellbook[i].Name)); } } }
void GetLoadedMods() { var mods = ModManager.Instance.GetAllMods(true); modList.ClearItems(); if (modSettings == null || modSettings.Length != mods.Length) { modSettings = new ModSettings[mods.Length]; } for (int i = 0; i < mods.Length; i++) { ModSettings modsett = new ModSettings(); modsett.modInfo = mods[i].ModInfo; modsett.enabled = mods[i].Enabled; modSettings[i] = modsett; modList.AddItem(modsett.modInfo.ModFileName); } mods = null; }
void Refresh() { ItemCollection playerItems = GameManager.Instance.PlayerEntity.Items; for (int i = 0; i < playerItems.Count; i++) { DaggerfallUnityItem item = playerItems.GetItem(i); if (item.IsEnchanted) { foreach (DaggerfallEnchantment enchantment in item.Enchantments) { if (enchantment.type == EnchantmentTypes.CastWhenUsed) { magicUseItems.Add(item); break; } } } else if (item.IsPotion) { magicUseItems.Add(item); } } if (magicUseItems.Count > 0) { ListBox.ClearItems(); foreach (DaggerfallUnityItem magicUseItem in magicUseItems) { ListBox.AddItem(magicUseItem.LongName); } } else { CloseWindow(); } }