Skip to content

Commit 6a2b349

Browse files
committed
Ask reselect environment path until it is valid
1 parent bf259dc commit 6a2b349

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,44 @@ internal IEnumerable<PluginPair> Setup()
6969

7070
var selectedFile = GetFileFromDialog(msg, FileDialogFilter);
7171

72-
if (!string.IsNullOrEmpty(selectedFile)) PluginsSettingsFilePath = selectedFile;
73-
72+
if (!string.IsNullOrEmpty(selectedFile))
73+
{
74+
PluginsSettingsFilePath = selectedFile;
75+
}
7476
// Nothing selected because user pressed cancel from the file dialog window
75-
if (string.IsNullOrEmpty(selectedFile)) InstallEnvironment();
77+
else
78+
{
79+
var forceDownloadMessage = string.Format(
80+
API.GetTranslation("runtimeExecutableInvalidChooseDownload"),
81+
Language,
82+
EnvName,
83+
Environment.NewLine
84+
);
85+
86+
// Let users select valid path or choose to download
87+
while (string.IsNullOrEmpty(selectedFile))
88+
{
89+
if (API.ShowMsgBox(forceDownloadMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
90+
{
91+
// Continue select file
92+
selectedFile = GetFileFromDialog(msg, FileDialogFilter);
93+
}
94+
else
95+
{
96+
// User selected no, break the loop
97+
break;
98+
}
99+
}
100+
101+
if (!string.IsNullOrEmpty(selectedFile))
102+
{
103+
PluginsSettingsFilePath = selectedFile;
104+
}
105+
else
106+
{
107+
InstallEnvironment();
108+
}
109+
}
76110
}
77111
else
78112
{

Flow.Launcher/Languages/en.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
Click no if it's already installed, and you will be prompted to select the folder that contains the {1} executable
1010
</system:String>
1111
<system:String x:Key="runtimePluginChooseRuntimeExecutable">Please select the {0} executable</system:String>
12+
<system:String x:Key="runtimeExecutableInvalidChooseDownload">
13+
Your selected {0} executable is invalid.
14+
{2}{2}
15+
Click yes if you would like select the {0} executable agian. Click no if you would like to download {1}
16+
</system:String>
1217
<system:String x:Key="runtimePluginUnableToSetExecutablePath">Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom).</system:String>
1318
<system:String x:Key="failedToInitializePluginsTitle">Fail to Init Plugins</system:String>
1419
<system:String x:Key="failedToInitializePluginsMessage">Plugins: {0} - fail to load and would be disabled, please contact plugin creator for help</system:String>

0 commit comments

Comments
 (0)