public void AddToSelectedModLB(string modPath) { if (String.IsNullOrEmpty(modPath.Trim())) { return; } FileInfo f = new FileInfo(modPath); if (f.FullName.EndsWith(disabledKey)) { string newName = f.FullName.Replace(disabledKey, ""); if (File.Exists(newName)) { File.Delete(newName); } File.Move(f.FullName, newName); f = new FileInfo(newName); } modPaths.Add(f.FullName); if (!Settings.LoadedSettings.LastUsedMods.Contains(f.FullName)) { Settings.LoadedSettings.LastUsedMods.Add(f.FullName); Settings.LoadedSettings.Save(); } if (!SessionData.loadedMods.Contains(f.FullName)) { SessionData.loadedMods.Add(f.FullName); } SelectedMods_ListBox.Items.Add(f.Name); foreach (var modItem in modItems) { if (modItem.ToString().Replace(disabledKey, "") == modPath.Replace(disabledKey, "")) { modItem.Enable_CheckBox.IsChecked = true; } } SelectedMods_ListBox.SelectedIndex = SelectedMods_ListBox.Items.Count - 1; bool isBtd6ApiMod = f.Extension == ".btd6mod"; bool injectorExists = BtdApi_Handler.DoesInjectorExist(SessionData.ModsDir); bool shownInjectorNeededMsg = SessionData.ShownInjectorRequiredMessage; bool showErrorMessage = (isBtd6ApiMod && !injectorExists && !shownInjectorNeededMsg); if (showErrorMessage) { BtdApi_Handler.AskDownloadInjector(); SessionData.ShownInjectorRequiredMessage = true; Settings.LoadedSettings.ShownBtdApiInjectorMessage = true; } }
public void AddItemToModsList(FileInfo modFile) { string modName; bool isBtdApiMod = modFile.FullName.Contains(".btd6mod"); bool isLastUsedMod = Settings.LoadedSettings.LastUsedMods.Contains(modFile.FullName); bool isDisabled = modFile.FullName.EndsWith(disabledKey); if (!isLastUsedMod && !isDisabled) { string newPath = modFile.FullName + disabledKey; if (File.Exists(newPath)) { File.Delete(newPath); } File.Move(modFile.FullName, newPath); modFile = new FileInfo(newPath); } if (isBtdApiMod && !Settings.LoadedSettings.ShownBtdApiInjectorMessage) { Logger.Log("One or more of your mods are BTD API mods. This means you need to use an injector to inject them into BTD6.", OutputType.Both); string btd6ModsDir = SessionData.ModsDir; if (!BtdApi_Handler.DoesInjectorExist(SessionData.ModsDir)) { BtdApi_Handler.AskDownloadInjector(); } Settings.LoadedSettings.ShownBtdApiInjectorMessage = true; SessionData.ShownInjectorRequiredMessage = true; } modName = modFile.Name.Replace(disabledKey, ""); ModItem_UserControl item = new ModItem_UserControl(); item.MinWidth = Mods_ListBox.ActualWidth - 31; item.ModName.Text = modName; item.modName = modName; item.modPath = modFile.FullName; Thickness margin = item.Margin; if (Mods_ListBox.Items.Count == 0) { margin.Top = 10; item.Margin = margin; } Mods_ListBox.Items.Add(item); modItems.Add(item); }