Skip to content

Commit 2ecd808

Browse files
authored
Merge branch 'main' into qolPatch
2 parents 9782ce8 + 7223a6a commit 2ecd808

File tree

3 files changed

+49
-26
lines changed

3 files changed

+49
-26
lines changed

MainWindow.xaml.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.UI.Xaml.Media;
66
using Microsoft.UI.Xaml.Navigation;
77
using System;
8+
using System.Collections.Generic;
89
using WinDurango.UI.Dialogs;
910
using WinDurango.UI.Pages;
1011
using WinDurango.UI.Settings;
@@ -96,9 +97,27 @@ public MainWindow()
9697

9798
private async void appTitleBar_Loaded(object sender, RoutedEventArgs e)
9899
{
99-
// have to do it here otherwise instance error
100+
Dictionary<string, string> missing = [];
101+
102+
if (String.IsNullOrEmpty(FSHelper.FindFileOnPath("vcruntime140d.dll")))
103+
missing.Add("Microsoft Visual C++ Redistributable", null);
104+
100105
var devNotice = new NoticeDialog($"This UI is very early in development, and mainly developed by a C# learner... There WILL be bugs, and some things will NOT work...\n\nDevelopers, check Readme.md in the repo for the todolist.", "Important");
101106
await devNotice.ShowAsync();
107+
108+
if (missing.Count != 0)
109+
{
110+
// todo: properly provide download link
111+
string notice = $"You are missing the following dependencies, which may be required to run some packages.\n";
112+
foreach (KeyValuePair<string, string> ms in missing)
113+
{
114+
notice += $"\n - {ms.Key}";
115+
}
116+
117+
var missingNotice = new NoticeDialog(notice, "Missing dependencies");
118+
await missingNotice.ShowAsync();
119+
}
120+
102121
if (ExtendsContentIntoTitleBar)
103122
{
104123
SetupTitleBar();

Utils/FSHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,13 @@ public static void OpenFolder(string folder)
4343
{
4444
Process.Start(new ProcessStartInfo(folder) { UseShellExecute = true });
4545
}
46+
47+
public static string FindFileOnPath(string file)
48+
{
49+
return Environment
50+
.GetEnvironmentVariable("PATH")
51+
.Split(Path.PathSeparator)
52+
.FirstOrDefault(p => File.Exists(Path.Combine(p, file)));
53+
}
4654
}
4755
}

Utils/WinDurangoPatcher.cs

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,26 @@ public static async Task<bool> PatchPackage(Package package, bool forceRedownloa
5353
public static async Task<bool> PatchPackage(installedPackage package, bool forceRedownload,
5454
ProgressController controller)
5555
{
56-
// Artifact dll package link
57-
const string dllLink =
58-
"https://nightly.link/WinDurango/WinDurango/workflows/msbuild/main/WinDurango-DEBUG.zip";
59-
56+
string patchesPath = Path.Combine(App.DataDir, "WinDurangoCore");
6057
controller?.Update($"Patching {package.FamilyName}", 0);
6158
string curDate = DateTime.UtcNow.ToString("yyyy-MM-dd_HH-mm-ss");
6259
string installPath = package.InstallPath;
6360

6461
controller?.Update("Getting latest release", 10);
6562
await GetOrReuseRelease(); // don't use the return value since wdRelease is set regardless
6663

67-
// This should be further improved...
68-
bool isDownloadSourceArtifact = App.Settings.Settings.DownloadSource == UiConfigData.PatchSource.Artifact;
69-
70-
string dlLink = isDownloadSourceArtifact
71-
? dllLink
72-
: wdRelease.DownloadLink;
73-
74-
string relName = isDownloadSourceArtifact
75-
? "latest GitHub Actions artifact"
76-
: wdRelease.Name;
77-
78-
string dlPath = isDownloadSourceArtifact
79-
? "WinDurangoCore-ARTIFACT.zip"
80-
: "WinDurangoCore.zip";
64+
string dlLink = wdRelease.DownloadLink;
65+
string relName = wdRelease.Name;
66+
string dlPath = $"WinDurangoCore.zip";
8167

82-
string patchesPath = isDownloadSourceArtifact
83-
? Path.Combine(App.DataDir, "WinDurangoCore-ARTIFACT")
84-
: Path.Combine(App.DataDir, "WinDurangoCore");
68+
// see this is quite messy but just needed to get it to work
69+
if (App.Settings.Settings.DownloadSource == UiConfigData.PatchSource.Artifact)
70+
{
71+
dlLink = "https://nightly.link/WinDurango/WinDurango/workflows/msbuild/main/WinDurango-Release.zip";
72+
dlPath = $"WinDurangoCore-ARTIFACT.zip";
73+
patchesPath = Path.Combine(App.DataDir, "WinDurangoCore-ARTIFACT");
74+
relName = $"latest GitHub Actions artifact";
75+
}
8576

8677
if (!Path.Exists(patchesPath) || forceRedownload)
8778
{
@@ -285,12 +276,17 @@ private static async Task<GitHubRelease> GetLatestRelease()
285276

286277
JsonElement.ArrayEnumerator assets = newestRelease.GetProperty("assets").EnumerateArray();
287278

288-
if (!assets.MoveNext())
289-
throw new Exception("Couldn't find any assets?????");
279+
foreach (var asset in assets)
280+
{
281+
if (!asset.GetProperty("name").GetString().EndsWith(".zip"))
282+
continue;
290283

291-
string download = assets.Current.GetProperty("browser_download_url").GetString();
284+
string download = asset.GetProperty("browser_download_url").GetString();
285+
release.DownloadLink = download;
286+
}
292287

293-
release.DownloadLink = download;
288+
if (String.IsNullOrEmpty(release.DownloadLink))
289+
throw new Exception("Couldn't find release with zip file");
294290

295291
wdRelease = release;
296292
return release;

0 commit comments

Comments
 (0)