Skip to content

Commit 4c87269

Browse files
Prompt user to select supported applications for a mod in the case where no compatible applications are found
1 parent c3c095f commit 4c87269

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,16 @@ public static void Init(IDictionaryResourceProvider provider)
220220
public static IDictionaryResource<string> ErrorStacktraceTitle { get; set; }
221221
public static IDictionaryResource<string> ErrorStacktraceSubtitle { get; set; }
222222

223-
// Update 1.X.X: New Progress Window for Local Mod Installation (UPDATE LAUNCHER VER BEFORE RELEASE)
223+
// Update 1.29.3: New Progress Window for Local Mod Installation
224224
public static IDictionaryResource<string> InstallModArchiveTitle { get; set; }
225225
public static IDictionaryResource<string> InstalledModName { get; set; }
226226
public static IDictionaryResource<string> InstallingModWait { get; set; }
227227
public static IDictionaryResource<string> ExtractingLocalModArchive { get; set; }
228+
229+
// Update 1.XX.XX: Add warning during installation of mods with no apps in their supported apps list or when no compatible app is installed (UPDATE LAUNCHER VER BEFORE RELEASE)
230+
public static IDictionaryResource<string> NoAppsInConfigTitle { get; set; }
231+
public static IDictionaryResource<string> NoAppsInConfigDescription { get; set; }
232+
public static IDictionaryResource<string> NoCompatibleAppsInConfigTitle { get; set; }
233+
public static IDictionaryResource<string> NoCompatibleAppsInConfigDescription { get; set; }
234+
public static IDictionaryResource<string> AppSelectionQuestion { get; set; }
228235
}

source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203
<sys:String x:Key="InstalledModName">Mod Name</sys:String>
204204
<sys:String x:Key="InstallingModWait">Please wait while we install the mod!</sys:String>
205205
<sys:String x:Key="ExtractingLocalModArchive">Extracting a local mod, please wait!</sys:String>
206+
207+
<!-- App Resolution Failure Message-->
208+
<sys:String x:Key="NoAppsInConfigTitle">Unable to find any supported app</sys:String>
209+
<sys:String x:Key="NoAppsInConfigDescription">Reloaded-II was unable to find any supported apps in the mod's config.</sys:String>
210+
<sys:String x:Key="NoCompatibleAppsInConfigTitle">Unable to find a compatible app</sys:String>
211+
<sys:String x:Key="NoCompatibleAppsInConfigDescription">Reloaded-II was unable to find an installed app which is compatible with this mod.</sys:String>
212+
<sys:String x:Key="AppSelectionQuestion">Do you want to select a supported app manually?</sys:String>
206213

207214
<!-- WMI Administrator Message -->
208215
<sys:String x:Key="RunAsAdminMessage">You need to run this application as administrator.&#x0a;Administrative privileges are needed to receive application launch/exit events from Windows Management Instrumentation (WMI).&#x0a;Developers: Run your favourite IDE e.g. Visual Studio as Admin.</sys:String>

source/Reloaded.Mod.Launcher/MainWindow.xaml.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NuGet.Common;
2+
using Reloaded.Mod.Launcher.Pages.BaseSubpages.Dialogs;
23
using Reloaded.Mod.Loader.Update.Providers.Web;
34
using Sewer56.DeltaPatchGenerator.Lib.Utility;
45
using Sewer56.Update.Extractors.SevenZipSharp;
@@ -132,7 +133,48 @@ private async void InstallMod_Drop(object sender, DragEventArgs e)
132133
foreach (var item in modConfigService.ItemsById.ToArray())
133134
{
134135
if (!modsBefore.ContainsKey(item.Key))
136+
{
135137
newConfigs.Add(item.Value.Config);
138+
if(item.Value.Config.IsUniversalMod || item.Value.Config.SupportedAppId.Length > 0)
139+
{
140+
var match = Lib.IoC.Get<ApplicationConfigService>().Items.FirstOrDefault(app => item.Value.Config.SupportedAppId.Contains(app.Config.AppId));
141+
if(match == null)
142+
{
143+
bool loadAppPage = Actions.DisplayMessagebox!.Invoke(
144+
NoCompatibleAppsInConfigTitle.Get(),
145+
$"{NoCompatibleAppsInConfigDescription.Get()}\n{AppSelectionQuestion.Get()}",
146+
new Actions.DisplayMessageBoxParams
147+
{
148+
Type = Actions.MessageBoxType.OkCancel
149+
});
150+
if (loadAppPage)
151+
{
152+
var createModDialog = new EditModDialog(new EditModDialogViewModel(item.Value, Lib.IoC.Get<ApplicationConfigService>(), modConfigService));
153+
createModDialog.Owner = System.Windows.Window.GetWindow(this);
154+
createModDialog.RealViewModel.Page = EditModPage.Special;
155+
createModDialog.ShowDialog();
156+
}
157+
}
158+
}
159+
else
160+
{
161+
bool loadAppPage = Actions.DisplayMessagebox!.Invoke(
162+
NoAppsInConfigTitle.Get(), $"{NoAppsInConfigDescription.Get()}\n{AppSelectionQuestion.Get()}"
163+
,
164+
new Actions.DisplayMessageBoxParams
165+
{
166+
Type = Actions.MessageBoxType.OkCancel
167+
});
168+
if (loadAppPage)
169+
{
170+
var createModDialog = new EditModDialog(new EditModDialogViewModel(item.Value, Lib.IoC.Get<ApplicationConfigService>(), modConfigService));
171+
createModDialog.Owner = System.Windows.Window.GetWindow(this);
172+
createModDialog.RealViewModel.Page = EditModPage.Special;
173+
createModDialog.ShowDialog();
174+
}
175+
}
176+
}
177+
136178
}
137179

138180
if (newConfigs.Count <= 0)

0 commit comments

Comments
 (0)