diff --git a/SeventhHeavenUI/Classes/ResourceHelper.cs b/SeventhHeavenUI/Classes/ResourceHelper.cs new file mode 100644 index 00000000..831c765d --- /dev/null +++ b/SeventhHeavenUI/Classes/ResourceHelper.cs @@ -0,0 +1,56 @@ +using SeventhHeavenUI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SeventhHeaven.Classes +{ + public enum StringKey + { + Play, + PlayWithMods, + StartedClickHereToViewAppLog, + HintLabel, + CheckingForUpdates, + ModRequiresModsIsMissingWarning, + UnsupportedModVersionsWarning, + ThisModRequiresYouActivateFollowingMods, + ModRequiresYouDeactivateTheFollowingMods, + CannotActivateModBecauseItIsIncompatibleWithOtherMod, + CannotActivateModBecauseDependentIsIncompatible, + SelectAll, + Unknown, + UpdateAvailable, + UpdateDownloading, + NoUpdates, + UpdatesIgnored, + AutoUpdate, + FollowingErrorsFoundInConfiguration, + ErrorsFoundInGeneralSettingsViewAppLog, + AppUpdateIsAvailableMessage, + NewVersionAvailable, + ThisModContainsDataThatCouldHarm, + CannotOpenHelp, + SubscriptionIsAlreadyAdded, + AddedToSubscriptions, + IrosLinkMayBeFormatedIncorrectly, + FailedToSetBackgroundImageFromTheme + } + + public static class ResourceHelper + { + public static string GetString(StringKey key) + { + try + { + return App.Current.Resources[key.ToString()].ToString(); + } + catch (Exception) + { + return ""; + } + } + } +} diff --git a/SeventhHeavenUI/Resources/Languages/StringResources.de.xaml b/SeventhHeavenUI/Resources/Languages/StringResources.de.xaml index 9f0fd572..0ce26f2d 100644 --- a/SeventhHeavenUI/Resources/Languages/StringResources.de.xaml +++ b/SeventhHeavenUI/Resources/Languages/StringResources.de.xaml @@ -1,7 +1,7 @@  - + @@ -236,4 +236,78 @@ Stop Reset to Mod Defaults + + started - Click here to view the app log. + Hint: + Checking for app updates ... + Select All + Unknown + + Update Available + Update Downloading + + No Updates + Updates Ignored + Auto Update + + The following errors were found in your configuration: + Errors found in general settings. View app.log for details on error(s). + + An update is available for {0} +Click 'Yes' to open the download page in a browser. + +{1} Release Notes: {2} + + New Version Available! + + This mod '{0}' contains data that could potentially harm your computer. You should only activate mods you trust. + +Do you still want to activate this mod? + + Cannot open help - Resources/Help/index.html file not found + + The subscription {0} is already added. + Added {0} to subscriptions. + The iros:// link {0} may be formatted incorrectly. Could not add to subscriptions. + + Failed to set background image from theme. + + + + + + + + + + + + + This mod requires the following mods to also be active, but they could not be found: +{0} +It may not work correctly unless you install them. + + This mod requires the following mods, but you do not have a supported version: +{0} +You may need to update these mods. + + This mod requires that you activate the following mods: +{0} +They will be automatically turned on. + + This mod requires that you deactivate the following mods: +{0} +They will be automatically turned off. + + + You cannot activate this mod, because it is incompatible with {0}. You will have to deactivate {0} before you can enable this mod. + + You cannot activate this mod, because it requires {0} to be active, but {0} is incompatible with {1}. You will have to deactivate {1} before you can enable this mod. + + + + + + + \ No newline at end of file diff --git a/SeventhHeavenUI/Resources/Languages/StringResources.es.xaml b/SeventhHeavenUI/Resources/Languages/StringResources.es.xaml index 9f0fd572..47f85f4c 100644 --- a/SeventhHeavenUI/Resources/Languages/StringResources.es.xaml +++ b/SeventhHeavenUI/Resources/Languages/StringResources.es.xaml @@ -1,9 +1,9 @@  - - + + Play Play With Mods (default) @@ -236,4 +236,78 @@ Stop Reset to Mod Defaults + + started - Click here to view the app log. + Hint: + Checking for app updates ... + Select All + Unknown + + Update Available + Update Downloading + + No Updates + Updates Ignored + Auto Update + + The following errors were found in your configuration: + Errors found in general settings. View app.log for details on error(s). + + An update is available for {0} +Click 'Yes' to open the download page in a browser. + +{1} Release Notes: {2} + + New Version Available! + + This mod '{0}' contains data that could potentially harm your computer. You should only activate mods you trust. + +Do you still want to activate this mod? + + Cannot open help - Resources/Help/index.html file not found + + The subscription {0} is already added. + Added {0} to subscriptions. + The iros:// link {0} may be formatted incorrectly. Could not add to subscriptions. + + Failed to set background image from theme. + + + + + + + + + + + + + This mod requires the following mods to also be active, but they could not be found: +{0} +It may not work correctly unless you install them. + + This mod requires the following mods, but you do not have a supported version: +{0} +You may need to update these mods. + + This mod requires that you activate the following mods: +{0} +They will be automatically turned on. + + This mod requires that you deactivate the following mods: +{0} +They will be automatically turned off. + + + You cannot activate this mod, because it is incompatible with {0}. You will have to deactivate {0} before you can enable this mod. + + You cannot activate this mod, because it requires {0} to be active, but {0} is incompatible with {1}. You will have to deactivate {1} before you can enable this mod. + + + + + + + \ No newline at end of file diff --git a/SeventhHeavenUI/Resources/Languages/StringResources.fr.xaml b/SeventhHeavenUI/Resources/Languages/StringResources.fr.xaml index 9f0fd572..0ce26f2d 100644 --- a/SeventhHeavenUI/Resources/Languages/StringResources.fr.xaml +++ b/SeventhHeavenUI/Resources/Languages/StringResources.fr.xaml @@ -1,7 +1,7 @@  - + @@ -236,4 +236,78 @@ Stop Reset to Mod Defaults + + started - Click here to view the app log. + Hint: + Checking for app updates ... + Select All + Unknown + + Update Available + Update Downloading + + No Updates + Updates Ignored + Auto Update + + The following errors were found in your configuration: + Errors found in general settings. View app.log for details on error(s). + + An update is available for {0} +Click 'Yes' to open the download page in a browser. + +{1} Release Notes: {2} + + New Version Available! + + This mod '{0}' contains data that could potentially harm your computer. You should only activate mods you trust. + +Do you still want to activate this mod? + + Cannot open help - Resources/Help/index.html file not found + + The subscription {0} is already added. + Added {0} to subscriptions. + The iros:// link {0} may be formatted incorrectly. Could not add to subscriptions. + + Failed to set background image from theme. + + + + + + + + + + + + + This mod requires the following mods to also be active, but they could not be found: +{0} +It may not work correctly unless you install them. + + This mod requires the following mods, but you do not have a supported version: +{0} +You may need to update these mods. + + This mod requires that you activate the following mods: +{0} +They will be automatically turned on. + + This mod requires that you deactivate the following mods: +{0} +They will be automatically turned off. + + + You cannot activate this mod, because it is incompatible with {0}. You will have to deactivate {0} before you can enable this mod. + + You cannot activate this mod, because it requires {0} to be active, but {0} is incompatible with {1}. You will have to deactivate {1} before you can enable this mod. + + + + + + + \ No newline at end of file diff --git a/SeventhHeavenUI/Resources/StringResources.xaml b/SeventhHeavenUI/Resources/StringResources.xaml index 1b040a01..3c169e05 100644 --- a/SeventhHeavenUI/Resources/StringResources.xaml +++ b/SeventhHeavenUI/Resources/StringResources.xaml @@ -233,5 +233,79 @@ Preview Stop Reset to Mod Defaults + + + started - Click here to view the app log. + Hint: + Checking for app updates ... + Select All + Unknown + + Update Available + Update Downloading + + No Updates + Updates Ignored + Auto Update + + The following errors were found in your configuration: + Errors found in general settings. View app.log for details on error(s). + + An update is available for {0} +Click 'Yes' to open the download page in a browser. + +{1} Release Notes: {2} + + New Version Available! + + This mod '{0}' contains data that could potentially harm your computer. You should only activate mods you trust. + +Do you still want to activate this mod? + + Cannot open help - Resources/Help/index.html file not found + + The subscription {0} is already added. + Added {0} to subscriptions. + The iros:// link {0} may be formatted incorrectly. Could not add to subscriptions. + + Failed to set background image from theme. + + + + + + + + + + + + + This mod requires the following mods to also be active, but they could not be found: +{0} +It may not work correctly unless you install them. + + This mod requires the following mods, but you do not have a supported version: +{0} +You may need to update these mods. + + This mod requires that you activate the following mods: +{0} +They will be automatically turned on. + + This mod requires that you deactivate the following mods: +{0} +They will be automatically turned off. + + + You cannot activate this mod, because it is incompatible with {0}. You will have to deactivate {0} before you can enable this mod. + + You cannot activate this mod, because it requires {0} to be active, but {0} is incompatible with {1}. You will have to deactivate {1} before you can enable this mod. + + + + + + \ No newline at end of file diff --git a/SeventhHeavenUI/SeventhHeavenUI.csproj b/SeventhHeavenUI/SeventhHeavenUI.csproj index cf8886c9..9055c9a2 100644 --- a/SeventhHeavenUI/SeventhHeavenUI.csproj +++ b/SeventhHeavenUI/SeventhHeavenUI.csproj @@ -153,6 +153,7 @@ + diff --git a/SeventhHeavenUI/ViewModels/CatalogViewModel.cs b/SeventhHeavenUI/ViewModels/CatalogViewModel.cs index 6399864f..3ef1d1e0 100644 --- a/SeventhHeavenUI/ViewModels/CatalogViewModel.cs +++ b/SeventhHeavenUI/ViewModels/CatalogViewModel.cs @@ -383,14 +383,13 @@ public CatalogModItemViewModel GetSelectedMod() return selected; } - internal Task CheckForCatalogUpdatesAsync(object state) + internal Task CheckForCatalogUpdatesAsync(bool forceCheck = false) { object countLock = new object(); Task t = Task.Factory.StartNew(() => { List pingIDs = null; - var options = (CatCheckOptions)state; string catFile = Path.Combine(Sys.SysFolder, "catalog.xml"); Directory.CreateDirectory(Path.Combine(Sys.SysFolder, "temp")); @@ -398,7 +397,7 @@ internal Task CheckForCatalogUpdatesAsync(object state) int subTotalCount = Sys.Settings.SubscribedUrls.Count; // amount of subscriptions to update int subUpdateCount = 0; // amount of subscriptions updated - if (options.ForceCheck) + if (forceCheck) { // on force check, initialize a new catalog to ignore any cached items Sys.SetNewCatalog(new Catalog()); @@ -423,7 +422,7 @@ internal Task CheckForCatalogUpdatesAsync(object state) Sys.Settings.Subscriptions.Add(sub); } - if ((sub.LastSuccessfulCheck < DateTime.Now.AddDays(-1)) || options.ForceCheck) + if ((sub.LastSuccessfulCheck < DateTime.Now.AddDays(-1)) || forceCheck) { Logger.Info($"Checking subscription {sub.Url}"); @@ -559,7 +558,7 @@ internal void PauseOrResumeDownload(DownloadItemViewModel downloadItem) internal void ForceCheckCatalogUpdateAsync() { - Task t = CheckForCatalogUpdatesAsync(new CatCheckOptions() { ForceCheck = true }); + Task t = CheckForCatalogUpdatesAsync(forceCheck: true); t.ContinueWith((taskResult) => { diff --git a/SeventhHeavenUI/ViewModels/ConfigureModViewModel.cs b/SeventhHeavenUI/ViewModels/ConfigureModViewModel.cs index 15bc0c9d..e6124209 100644 --- a/SeventhHeavenUI/ViewModels/ConfigureModViewModel.cs +++ b/SeventhHeavenUI/ViewModels/ConfigureModViewModel.cs @@ -597,7 +597,7 @@ private void UpdateViewForDropdownSelectionChanged() _values[_selectedOption.Option.ID] = o.Value; } - internal static void DeleteTempFolder() + internal static void DeleteTempConfigModFolder() { string config_temp_folder = Path.Combine(Sys.PathToTempFolder, "configmod"); if (Directory.Exists(config_temp_folder)) diff --git a/SeventhHeavenUI/ViewModels/FilterItemViewModel.cs b/SeventhHeavenUI/ViewModels/FilterItemViewModel.cs index 8a7f1e77..f49c86fe 100644 --- a/SeventhHeavenUI/ViewModels/FilterItemViewModel.cs +++ b/SeventhHeavenUI/ViewModels/FilterItemViewModel.cs @@ -1,6 +1,7 @@ using Iros._7th; using Iros._7th.Workshop; using Iros.Mega; +using SeventhHeaven.Classes; using System; using System.Collections.Generic; using System.IO; @@ -111,11 +112,14 @@ public static bool FilterByCategory(Mod mod, IEnumerable ca if (categories == null) categories = new List(); - string modCategory = mod.Category; + string modCategory = mod?.Category; + + // treat missing mod category as 'Unknown' + if (string.IsNullOrWhiteSpace(modCategory)) + modCategory = ResourceHelper.GetString(StringKey.Unknown); return categories.Count() == 0 || - categories.Any(c => c.Name.Equals(modCategory, StringComparison.InvariantCultureIgnoreCase)) || - (categories.Any(c => c.Name == MainWindowViewModel._unknownText) && string.IsNullOrEmpty(modCategory)); + categories.Any(c => c.Name.Equals(modCategory, StringComparison.InvariantCultureIgnoreCase)); } } } diff --git a/SeventhHeavenUI/ViewModels/MainWindowViewModel.cs b/SeventhHeavenUI/ViewModels/MainWindowViewModel.cs index 40267e3b..a4fec648 100644 --- a/SeventhHeavenUI/ViewModels/MainWindowViewModel.cs +++ b/SeventhHeavenUI/ViewModels/MainWindowViewModel.cs @@ -30,33 +30,8 @@ public class MainWindowViewModel : ViewModelBase private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); - internal const string _msgReqMissing = - @"This mod requires the following mods to also be active, but they could not be found: -{0} -It may not work correctly unless you install them."; - - internal const string _msgBadVer = - @"This mod requires the following mods, but you do not have a supported version: -{0} -You may need to update these mods."; - - internal const string _msgRequired = - @"This mod requires that you activate the following mods: -{0} -They will be automatically turned on."; - - internal const string _msgRemove = - @"This mod requires that you deactivate the following mods: -{0} -They will be automatically turned off."; - - internal const string _forbidMain = - @"You cannot activate this mod, because it is incompatible with {0}. You will have to deactivate {0} before you can enable this mod."; - - internal const string _forbidDependent = - @"You cannot activate this mod, because it requires {0} to be active, but {0} is incompatible with {1}. You will have to deactivate {1} before you can enable this mod."; - internal const string _showAllText = "Select All"; - internal const string _unknownText = "Unknown"; + internal string _showAllText; + internal string _unknownText; public List AppHints = new List() { @@ -438,11 +413,11 @@ public string UpdateModButtonText ModStatus status = Sys.GetStatus(selected.InstallInfo.ModID); if (status != ModStatus.Downloading && status != ModStatus.Updating) { - return "Update Available"; + return ResourceHelper.GetString(StringKey.UpdateAvailable); } else { - return "Update Downloading"; + return ResourceHelper.GetString(StringKey.UpdateDownloading); } } else @@ -450,13 +425,13 @@ public string UpdateModButtonText switch (selected.InstallInfo.UpdateType) { case UpdateType.Notify: - return "No Updates"; + return ResourceHelper.GetString(StringKey.NoUpdates); case UpdateType.Ignore: - return "Updates Ignored"; + return ResourceHelper.GetString(StringKey.UpdatesIgnored); case UpdateType.Install: - return "Auto Update"; + return ResourceHelper.GetString(StringKey.AutoUpdate); } } } @@ -610,12 +585,6 @@ public bool IsPlayToggleButtonEnabled } } - internal void ShowCatalogCreationTool() - { - CatalogCreationToolWindow window = new CatalogCreationToolWindow(); - window.Show(); - } - public bool IsGameLaunching { get @@ -647,6 +616,14 @@ public MainWindowViewModel() CatalogMods.SelectedModChanged += CatalogViewModel_SelectedModChanged; LoadingGifVisibility = Visibility.Hidden; + + InitStringsForLanguage(); + } + + private void InitStringsForLanguage() + { + _showAllText = ResourceHelper.GetString(StringKey.SelectAll); + _unknownText = ResourceHelper.GetString(StringKey.Unknown); } @@ -706,9 +683,9 @@ public void InitViewModel() IEnumerable errors = Sys.Settings.VerifySettings(); if (errors.Any()) { - string msg = "The following errors were found in your configuration:\n" + string.Join("\n", errors); + string msg = $"{ResourceHelper.GetString(StringKey.FollowingErrorsFoundInConfiguration)}\n" + string.Join("\n", errors); Logger.Warn(msg); - Sys.Message(new WMessage("Errors found in general settings. View app.log for details on error(s).")); + Sys.Message(new WMessage(ResourceHelper.GetString(StringKey.ErrorsFoundInGeneralSettingsViewAppLog))); showSettings = true; } } @@ -726,7 +703,7 @@ public void InitViewModel() CatalogMods.ReloadModList(); - CatalogMods.CheckForCatalogUpdatesAsync(new CatCheckOptions()); + CatalogMods.CheckForCatalogUpdatesAsync(); ReloadAvailableFilters(); @@ -735,10 +712,10 @@ public void InitViewModel() // ... the temp images are used for the configure mod window // ... the app does not release the file lock on the images at runtime of the app so // ... this will ensure the images from last app session are deleted - ConfigureModViewModel.DeleteTempFolder(); + ConfigureModViewModel.DeleteTempConfigModFolder(); Sys.AppVersion = App.GetAppVersion(); - StatusMessage = $"{App.GetAppName()} v{Sys.AppVersion.ToString()} started - Click here to view the app log. | Hint: {GetRandomHint()}"; + StatusMessage = $"{App.GetAppName()} v{Sys.AppVersion.ToString()} {ResourceHelper.GetString(StringKey.StartedClickHereToViewAppLog)} | {ResourceHelper.GetString(StringKey.HintLabel)} {GetRandomHint()}"; MyMods.ScanForModUpdates(); @@ -748,7 +725,7 @@ public void InitViewModel() Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(5000); // wait 5 seconds after init before checking for update to let UI render - Sys.Message(new WMessage("Checking for app updates ...", WMessageLogLevel.LogOnly)); + Sys.Message(new WMessage(ResourceHelper.GetString(StringKey.CheckingForUpdates), WMessageLogLevel.LogOnly)); UpdateChecker.Instance.CheckForUpdates(); }); } @@ -758,8 +735,8 @@ private void AppUpdater_UpdateCheckCompleted(bool wasSuccessful) { if (wasSuccessful && UpdateChecker.IsNewVersionAvailable(Sys.LastCheckedVersion)) { - string message = $"An update is available for {App.GetAppName()} - {App.GetAppVersion()}\nClick 'Yes' to open the download page in a browser.\n\n{Sys.LastCheckedVersion.Version} Release Notes: {Sys.LastCheckedVersion.ReleaseNotes}"; - var dialogResult = MessageDialogWindow.Show(message, $"New Version ({Sys.LastCheckedVersion.Version}) Available!", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); + string message = string.Format(ResourceHelper.GetString(StringKey.AppUpdateIsAvailableMessage), $"{App.GetAppName()} - {App.GetAppVersion()}", Sys.LastCheckedVersion.Version, Sys.LastCheckedVersion.ReleaseNotes); + var dialogResult = MessageDialogWindow.Show(message, ResourceHelper.GetString(StringKey.NewVersionAvailable), MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (dialogResult.Result == MessageBoxResult.Yes) { @@ -1028,7 +1005,8 @@ private void InitActiveProfile() } catch (Exception e) { - Logger.Warn(e, "Failed to load current profile xml ... Setting current profile to null"); + Logger.Warn(e); + Logger.Warn("Failed to load current profile xml ... Setting current profile to null"); Sys.Settings.CurrentProfile = null; } } @@ -1153,7 +1131,8 @@ private void LoadCatalogXmlFile() } catch (Exception e) { - Logger.Warn(e, "failed to load catalog.xml - initializing empty catalog ..."); + Logger.Warn(e); + Logger.Warn("failed to load catalog.xml - initializing empty catalog ..."); Sys.SetNewCatalog(new Catalog()); } } @@ -1197,8 +1176,7 @@ internal static bool CheckAllowedActivate(Guid modID) // invoke the message on the Dispatcher UI Thread since this could be called from background threads return App.Current.Dispatcher.Invoke(() => { - string msg = "This mod '{0}' contains data that could potentially harm your computer. You should only activate mods you trust.\n\nDo you still want to activate this mod?"; - msg = String.Format(msg, mod.CachedDetails.Name); + string msg = String.Format(ResourceHelper.GetString(StringKey.ThisModContainsDataThatCouldHarm), mod.CachedDetails.Name); AllowModToRunWindow warningWindow = new AllowModToRunWindow(msg); warningWindow.ShowDialog(); @@ -1352,74 +1330,6 @@ internal void OpenPreviewModReadMe() } - /// - /// Opens the 'Profiles' window to manage and switch profiles - /// - internal void ShowProfilesWindow() - { - SaveActiveProfile(); // ensure current profile is saved to disk so it shows in list of profiles - - OpenProfileWindow profileWindow = new OpenProfileWindow(); - bool? dialogResult = profileWindow.ShowDialog(); - - if (dialogResult.GetValueOrDefault(false)) - { - RefreshProfile(); - } - } - - internal void ShowChunkToolWindow() - { - ChunkToolWindow toolWindow = new ChunkToolWindow() - { - WindowStartupLocation = WindowStartupLocation.CenterScreen - }; - toolWindow.ShowDialog(); - } - - internal void ShowGeneralSettingsWindow() - { - GeneralSettingsWindow settingsWindow = new GeneralSettingsWindow() - { - WindowStartupLocation = WindowStartupLocation.CenterScreen - }; - bool? didSave = settingsWindow.ShowDialog(); - - if (didSave.GetValueOrDefault(false)) - { - if (settingsWindow.ViewModel.SubscriptionsChanged) - { - CatalogMods.ForceCheckCatalogUpdateAsync(); - } - - if (settingsWindow.ViewModel.HasChangedInstalledModUpdateTypes && SelectedTabIndex == (int)TabIndex.MyMods) - { - MyMods.ScanForModUpdates(); - UpdateModPreviewInfo(MyMods.GetSelectedMod(), true); - } - } - } - - internal void ShowIroToolsWindow() - { - IroCreateWindow createWindow = new IroCreateWindow() - { - WindowStartupLocation = WindowStartupLocation.CenterScreen - }; - createWindow.ShowDialog(); - } - - internal void ShowGameDriverConfigWindow() - { - string uiXml = Path.Combine(Sys._7HFolder, "7H_GameDriver_UI.xml"); - string driverCfg = Path.Combine(Path.GetDirectoryName(Sys.Settings.FF7Exe), "7H_GameDriver.cfg"); - - ConfigureGLWindow gLWindow = new ConfigureGLWindow() { WindowStartupLocation = WindowStartupLocation.CenterScreen }; - gLWindow.Init(uiXml, driverCfg); - gLWindow.ShowDialog(); - } - - /// /// sets IsChecked to value of for all items in except for the 'Show All' category /// @@ -1483,7 +1393,7 @@ internal List GetCategoriesForSelectedTab() categories = Sys.Catalog.Mods.Select(c => { if (string.IsNullOrEmpty(c.Category)) - return "Unknown"; + return _unknownText; return c.Category; }) @@ -1494,7 +1404,7 @@ internal List GetCategoriesForSelectedTab() categories = MyMods.ModList.Select(c => { if (string.IsNullOrEmpty(c.Category)) - return "Unknown"; + return _unknownText; return c.Category; }) @@ -1588,7 +1498,7 @@ internal void LaunchHelpPage() if (!File.Exists(helpFile)) { - Sys.Message(new WMessage("Cannot open help - Resources/Help/index.html file not found")); + Sys.Message(new WMessage(ResourceHelper.GetString(StringKey.CannotOpenHelp))); return; } @@ -1611,12 +1521,6 @@ internal string GetRandomHint() return AppHints[r.Next(0, AppHints.Count)]; } - internal void ShowGameLaunchSettingsWindow() - { - GameLaunchSettingsWindow launchSettingsWindow = new GameLaunchSettingsWindow(); - launchSettingsWindow.ShowDialog(); - } - internal void LaunchGame(bool variableDump = false, bool debugLogging = false, bool noMods = false) { IsGameLaunching = true; @@ -1636,21 +1540,21 @@ internal void AddIrosUrlToSubscriptions(string irosUrl) { if (Sys.Settings.Subscriptions.Any(s => s.Url.Equals(irosUrl, StringComparison.InvariantCultureIgnoreCase))) { - Sys.Message(new WMessage($"The subscription {irosUrl} is already added.", true)); + Sys.Message(new WMessage(string.Format(ResourceHelper.GetString(StringKey.SubscriptionIsAlreadyAdded), irosUrl), true)); return; } GeneralSettingsViewModel.ResolveCatalogNameFromUrl(irosUrl, name => { Sys.Settings.Subscriptions.Add(new Subscription() { Url = irosUrl, Name = name }); - Sys.Message(new WMessage($"Added {irosUrl} to subscriptions.", true)); + Sys.Message(new WMessage(string.Format(ResourceHelper.GetString(StringKey.AddedToSubscriptions), irosUrl), true)); CatalogMods.ForceCheckCatalogUpdateAsync(); }); } else { - Sys.Message(new WMessage($"The iros:// link {irosUrl} may be formatted incorrectly. Could not add to subscriptions.", WMessageLogLevel.LogOnly)); + Sys.Message(new WMessage(string.Format(ResourceHelper.GetString(StringKey.IrosLinkMayBeFormatedIncorrectly), irosUrl), WMessageLogLevel.LogOnly)); } } @@ -1703,7 +1607,6 @@ internal void UpdateSelectedMod() } } - internal void UpdateBackgroundImage(byte[] newImage) { try @@ -1730,18 +1633,96 @@ internal void UpdateBackgroundImage(byte[] newImage) catch (Exception e) { Logger.Warn(e); - Sys.Message(new WMessage("Failed to set background image from theme.", true)); + Sys.Message(new WMessage(ResourceHelper.GetString(StringKey.FailedToSetBackgroundImageFromTheme), true)); MyMods.ThemeImage = null; CatalogMods.ThemeImage = null; } } - } - internal class CatCheckOptions - { - public bool ForceCheck { get; set; } - } + #region Show Window Methods + + /// + /// Opens the 'Profiles' window to manage and switch profiles + /// + internal void ShowProfilesWindow() + { + SaveActiveProfile(); // ensure current profile is saved to disk so it shows in list of profiles + + OpenProfileWindow profileWindow = new OpenProfileWindow(); + bool? dialogResult = profileWindow.ShowDialog(); + + if (dialogResult.GetValueOrDefault(false)) + { + RefreshProfile(); + } + } + + internal void ShowChunkToolWindow() + { + ChunkToolWindow toolWindow = new ChunkToolWindow() + { + WindowStartupLocation = WindowStartupLocation.CenterScreen + }; + toolWindow.ShowDialog(); + } + + internal void ShowGeneralSettingsWindow() + { + GeneralSettingsWindow settingsWindow = new GeneralSettingsWindow() + { + WindowStartupLocation = WindowStartupLocation.CenterScreen + }; + bool? didSave = settingsWindow.ShowDialog(); + + if (didSave.GetValueOrDefault(false)) + { + if (settingsWindow.ViewModel.SubscriptionsChanged) + { + CatalogMods.ForceCheckCatalogUpdateAsync(); + } + + if (settingsWindow.ViewModel.HasChangedInstalledModUpdateTypes && SelectedTabIndex == (int)TabIndex.MyMods) + { + MyMods.ScanForModUpdates(); + UpdateModPreviewInfo(MyMods.GetSelectedMod(), true); + } + } + } + + internal void ShowIroToolsWindow() + { + IroCreateWindow createWindow = new IroCreateWindow() + { + WindowStartupLocation = WindowStartupLocation.CenterScreen + }; + createWindow.ShowDialog(); + } + internal void ShowGameDriverConfigWindow() + { + string uiXml = Path.Combine(Sys._7HFolder, "7H_GameDriver_UI.xml"); + string driverCfg = Path.Combine(Path.GetDirectoryName(Sys.Settings.FF7Exe), "7H_GameDriver.cfg"); + + ConfigureGLWindow gLWindow = new ConfigureGLWindow() { WindowStartupLocation = WindowStartupLocation.CenterScreen }; + gLWindow.Init(uiXml, driverCfg); + gLWindow.ShowDialog(); + } + + internal void ShowGameLaunchSettingsWindow() + { + GameLaunchSettingsWindow launchSettingsWindow = new GameLaunchSettingsWindow(); + launchSettingsWindow.ShowDialog(); + } + + internal void ShowCatalogCreationTool() + { + CatalogCreationToolWindow window = new CatalogCreationToolWindow(); + window.Show(); + } + + #endregion + + } } diff --git a/SeventhHeavenUI/ViewModels/MyModsViewModel.cs b/SeventhHeavenUI/ViewModels/MyModsViewModel.cs index 15af1820..c23c0142 100644 --- a/SeventhHeavenUI/ViewModels/MyModsViewModel.cs +++ b/SeventhHeavenUI/ViewModels/MyModsViewModel.cs @@ -20,6 +20,19 @@ public class MyModsViewModel : ViewModelBase { private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); + internal string _msgReqMissing; + + internal string _msgBadVer; + + internal string _msgRequired; + + internal string _msgRemove; + + internal string _forbidMain; + + internal string _forbidDependent; + + public delegate void OnSelectionChanged(object sender, InstalledModViewModel selected); public event OnSelectionChanged SelectedModChanged; @@ -89,6 +102,13 @@ public BitmapImage ThemeImage public MyModsViewModel() { _previousReloadOptions = new ReloadListOption(); + + _msgReqMissing = ResourceHelper.GetString(StringKey.ModRequiresModsIsMissingWarning); + _msgBadVer = ResourceHelper.GetString(StringKey.UnsupportedModVersionsWarning); + _msgRequired = ResourceHelper.GetString(StringKey.ThisModRequiresYouActivateFollowingMods); + _msgRemove = ResourceHelper.GetString(StringKey.ModRequiresYouDeactivateTheFollowingMods); + _forbidMain = ResourceHelper.GetString(StringKey.CannotActivateModBecauseItIsIncompatibleWithOtherMod); + _forbidDependent = ResourceHelper.GetString(StringKey.CannotActivateModBecauseDependentIsIncompatible); } /// @@ -513,9 +533,9 @@ internal void ToggleActivateMod(Guid modID, bool reloadList = true) if (!forbid.Versions.Any() || forbid.Versions.Contains(Sys.Library.GetItem(mID).LatestInstalled.VersionDetails.Version)) { if (mID.Equals(modID)) - MessageDialogWindow.Show(String.Format(MainWindowViewModel._forbidMain, Sys.Library.GetItem(active.ModID).CachedDetails.Name), "Warning"); + MessageDialogWindow.Show(String.Format(_forbidMain, Sys.Library.GetItem(active.ModID).CachedDetails.Name), "Warning"); else - MessageDialogWindow.Show(String.Format(MainWindowViewModel._forbidDependent, Sys.Library.GetItem(mID).CachedDetails.Name, Sys.Library.GetItem(active.ModID).CachedDetails.Name), "Warning"); + MessageDialogWindow.Show(String.Format(_forbidDependent, Sys.Library.GetItem(mID).CachedDetails.Name, Sys.Library.GetItem(active.ModID).CachedDetails.Name), "Warning"); return; } } @@ -524,19 +544,19 @@ internal void ToggleActivateMod(Guid modID, bool reloadList = true) if (missing.Any()) { - MessageDialogWindow.Show(String.Format(MainWindowViewModel._msgReqMissing, String.Join("\n", missing)), "Missing Requirements"); + MessageDialogWindow.Show(String.Format(_msgReqMissing, String.Join("\n", missing)), "Missing Requirements"); } if (badVersion.Any()) { - MessageDialogWindow.Show(String.Format(MainWindowViewModel._msgBadVer, String.Join("\n", badVersion.Select(ii => ii.CachedDetails.Name))), "Unsupported Version"); + MessageDialogWindow.Show(String.Format(_msgBadVer, String.Join("\n", badVersion.Select(ii => ii.CachedDetails.Name))), "Unsupported Version"); } if (pulledIn.Any()) { - MessageDialogWindow.Show(String.Format(MainWindowViewModel._msgRequired, String.Join("\n", pulledIn.Select(ii => ii.CachedDetails.Name))), "Missing Required Active Mods"); + MessageDialogWindow.Show(String.Format(_msgRequired, String.Join("\n", pulledIn.Select(ii => ii.CachedDetails.Name))), "Missing Required Active Mods"); } if (remove.Any()) { - MessageDialogWindow.Show(String.Format(MainWindowViewModel._msgRemove, String.Join("\n", remove.Select(pi => Sys.Library.GetItem(pi.ModID).CachedDetails.Name))), "Deactivate Mods Warning"); + MessageDialogWindow.Show(String.Format(_msgRemove, String.Join("\n", remove.Select(pi => Sys.Library.GetItem(pi.ModID).CachedDetails.Name))), "Deactivate Mods Warning"); } DoActivate(modID, reloadList); @@ -801,7 +821,8 @@ internal void ShowConfigureModWindow(InstalledModViewModel modToConfigure) } catch (Exception e) { - Logger.Warn(e, "Failed to write image to file"); + Logger.Warn(e); + Logger.Warn("Failed to write image to file"); return null; } }