/// <summary> /// Updates the UI to reflect the new values from the scripts. /// </summary> public void UpdateUI() { //if the app is starting up, don't continue (otherwise we get issues that you don't want) if (startingUp) { return; } bool ifModSelected = ui_modmanager_modlist_listview.SelectedIndex != -1 && ui_modmanager_modlist_listview.SelectedItem != null; bool ifModsExist = ui_modmanager_modlist_listview.Items.Count != 0; bool ifCanLaunchGame = ui_launcher_gameversion_combobox.SelectedIndex != -1 && appSettings.IsGameSetupAndValid(); //launcher stuff string gameExePath = appSettings.Get_Current_GameVersionSettings_GameExeLocation(); ui_launcher_gameversion_combobox.ItemsSource = GameVersion_Functions.Get_Versions_StringList(true); ui_launcher_launchgame_tile_gameModsAmount_textBlock.Text = string.Format("Mods: {0}", modManager.mods.Count); ui_launcher_launchgame_tile.IsEnabled = ifCanLaunchGame; ui_window_appversion_label.Content = appSettings.appVersionString; if (ui_launcher_gameversion_combobox.SelectedItem != null) { ui_launcher_launchgame_tile_gameTitle_textBlock.Text = ui_launcher_gameversion_combobox.SelectedItem.ToString(); } ui_launcher_launchgame_tile_exeIcon_image.Source = null; if (System.IO.File.Exists(gameExePath)) { ui_launcher_launchgame_tile_exeIcon_image.Source = GetFileIcon(gameExePath); } //mod manager stuff ui_modmanager_addmod_button.IsEnabled = ifCanLaunchGame; ui_modmanager_removemod_button.IsEnabled = ifModSelected; ui_modmanager_viewmod_button.IsEnabled = ifModSelected; ui_modmanager_openmodfolder_button.IsEnabled = ifCanLaunchGame; ui_modmanager_purgemod_button.IsEnabled = ifModsExist; ui_modmanager_refreshmodfolder_button.IsEnabled = ifCanLaunchGame; ui_modmanager_modlist_listview.IsEnabled = ifCanLaunchGame; ui_modmanager_modlist_listview.ItemsSource = modManager.mods; ui_modmanager_modlist_listview.Items.Refresh(); ui_modmanager_modlist_listview_contextmenu_add.IsEnabled = ui_modmanager_addmod_button.IsEnabled; ui_modmanager_modlist_listview_contextmenu_remove.IsEnabled = ui_modmanager_removemod_button.IsEnabled; ui_modmanager_modlist_listview_contextmenu_openmodfolder.IsEnabled = ui_modmanager_openmodfolder_button.IsEnabled; ui_modmanager_modlist_listview_contextmenu_refreshmods.IsEnabled = ui_modmanager_refreshmodfolder_button.IsEnabled; ui_modmanager_modlist_listview_contextmenu_view.IsEnabled = ui_modmanager_viewmod_button.IsEnabled; ui_modmanager_gameversion_label.Content = appSettings.Get_Current_GameVersionName(); ui_modmanager_gameversion_label.Content = string.Format("Game: {0}", appSettings.Get_Current_GameVersionName().ToString().Replace("_", " ")); //settings stuff ui_settings_gameversion_label.Content = string.Format("Current Game: {0}", appSettings.Get_Current_GameVersionName().ToString().Replace("_", " ")); ui_settings_gameversion_combobox.ItemsSource = GameVersion_Functions.Get_Versions_StringList(true); ui_settings_gameversion_combobox.SelectedIndex = (int)appSettings.appSettingsFile.Default_Game_Version; ui_settings_gamedirectoryexe_textbox.Text = appSettings.Get_Current_GameVersionSettings_GameExeLocation(); }
/// <summary> /// Updates the UI elements to reflect the new data from the objects. /// </summary> public void UpdateUI() { string darkmodeTheme = appSettings.Get_AppSettings_LightMode() ? "Light.Blue" : "Dark.Blue"; ThemeManager.Current.ChangeTheme(this, darkmodeTheme); ui_window_appversion_label.Content = appSettings.appVersionString; ui_gamesetup_gameversion_combobox.ItemsSource = GameVersion_Functions.Get_Versions_StringList(true); ui_gamesetup_gamedirectoryexe_textbox.Text = appSettings.Get_Current_GameVersionSettings_GameExeLocation(); }
private void ui_gamesetup_done_Click(object sender, RoutedEventArgs e) { GameVersion selectedGameVersion = GameVersion_Functions.Get_Versions_ParseIntValue(ui_gamesetup_gameversion_combobox.SelectedIndex); appSettings.ChangeGameVersion(selectedGameVersion); modManager.ChangedGameVersion(); if (appSettings.IsGameSetupAndValid(true) == false) { return; } appSettings.UpdateChangesToFile(); this.Hide(); mainWindow.Show(); mainWindow.Activate(); }
/// <summary> /// Adds a mod with a bunch of validation checks. /// <para>If a validation check fails, it will not add the mod.</para> /// </summary> /// <param name="newMod"></param> public void ValidateAndAddMod(Mod newMod) { //if there are no mods in the list, go ahead and install it if (mods.Count < 1) { mods.Add(newMod); ExtractModZipFileContents_ToDirectory(newMod); return; //dont continue } //if there are mods, then loop through each one to check their properties foreach (Mod mod in mods) { //if mod shares the name if (mod.ModDisplayName.Equals(newMod.ModDisplayName)) { if (mod.ModVersion.Equals(newMod.ModVersion)) //if the mod is the same version and has the same name, this mod is a duplicate! stop! { string message = string.Format("You already have '{0}' version '{1}' installed!. Do you wish to replace it anyway?", mod.ModDisplayName, mod.ModVersion, newMod.ModVersion); if (MessageBoxes.Info_Confirm(message, "Replace Mod")) { ReplaceMod(mod, newMod); } return; } else //if the mod has the same name but is a different version, then prompt the user if they want to replace it with the given version. { string message = string.Format("You have '{0}' installed with version '{1}'. Do you wish to replace it with this version {2}?", mod.ModDisplayName, mod.ModVersion, newMod.ModVersion); if (MessageBoxes.Info_Confirm(message, "Replace Mod")) { ReplaceMod(mod, newMod); } return; } } //now check the mod's compatiblity GameVersion parsedModCompatiblity; try { //attempt to parse the mods game version string as a game version enum parsedModCompatiblity = GameVersion_Functions.Get_Versions_ParseStringValue(newMod.ModCompatibility); } catch (Exception e) { //the parsing failed, show the exception MessageBoxes.Error(e.Message, e.ToString()); return; //dont continue } //if the parse is sucessful, now check if it matches the current game version we have selected if (parsedModCompatiblity.Equals(appSettings.Get_Current_GameVersionName()) == false) { //for ui string current_gameVersionString = Enum.GetName(typeof(GameVersion), appSettings.Get_Current_GameVersionName()); string mod_gameVersionString = Enum.GetName(typeof(GameVersion), parsedModCompatiblity); string message = string.Format("'{0}' is incompatible with your current game version '{1}'. The mod was built for the following game version '{2}'.", mod.ModDisplayName, current_gameVersionString, mod_gameVersionString); //notify the user //NOTE: Future addition - add an option for the user to convert the mod version, but warn them that this may not work. MessageBoxes.Error(message, "Incompatible Game Version!"); return;//dont continue } } //if all checks pass, do a final check to check the contents of the mod with the existing ones CheckModContents_WithExistingMods(newMod, true); }