From ae3cd60033b9dbc11f43ac59f101ff99e20b8f1a Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Wed, 13 Mar 2024 22:54:19 -0500 Subject: [PATCH] Begin switch to UIX --- ZuneModdingHelper.sln | 49 ++ .../AbstractUIGroupDialog.xaml.cs | 1 - ZuneModdingHelper/App.cs | 62 ++ ZuneModdingHelper/App.xaml | 19 - ZuneModdingHelper/App.xaml.cs | 52 -- ZuneModdingHelper/Controls/TOPTOOLBAR.UIX | 698 ++++++++++++++++++ ZuneModdingHelper/Home.uix | 384 ++++++++++ ZuneModdingHelper/MainWindow.xaml.cs | 28 +- ZuneModdingHelper/ZuneModdingHelper.csproj | 67 +- libs/MicrosoftIris | 2 +- 10 files changed, 1245 insertions(+), 117 deletions(-) create mode 100644 ZuneModdingHelper/App.cs delete mode 100644 ZuneModdingHelper/App.xaml delete mode 100644 ZuneModdingHelper/App.xaml.cs create mode 100644 ZuneModdingHelper/Controls/TOPTOOLBAR.UIX create mode 100644 ZuneModdingHelper/Home.uix diff --git a/ZuneModdingHelper.sln b/ZuneModdingHelper.sln index f3a7bd6..0098bba 100644 --- a/ZuneModdingHelper.sln +++ b/ZuneModdingHelper.sln @@ -9,6 +9,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZuneModCore", "ZuneModCore\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OwlCore.Wpf", "OwlCore.Wpf\OwlCore.Wpf.csproj", "{BD87C032-C255-409E-8402-2DE16BFCE801}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{8B47E55D-134C-4308-838A-F48A25302FC6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIX", "libs\MicrosoftIris\UIX\UIX.csproj", "{78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IrisShell", "libs\MicrosoftIris\IrisShell\IrisShell.csproj", "{8EE5F27A-A763-45BB-97A5-E7C690FC594B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIX.RenderApi", "libs\MicrosoftIris\UIX.RenderApi\UIX.RenderApi.csproj", "{CB2B7609-C7B8-4E2A-82D8-DD631B70B621}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,10 +63,51 @@ Global {BD87C032-C255-409E-8402-2DE16BFCE801}.Release|x64.Build.0 = Release|Any CPU {BD87C032-C255-409E-8402-2DE16BFCE801}.Release|x86.ActiveCfg = Release|Any CPU {BD87C032-C255-409E-8402-2DE16BFCE801}.Release|x86.Build.0 = Release|Any CPU + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|x64.ActiveCfg = Debug|x64 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|x64.Build.0 = Debug|x64 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|x86.ActiveCfg = Debug|x86 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Debug|x86.Build.0 = Debug|x86 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|Any CPU.Build.0 = Release|Any CPU + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|x64.ActiveCfg = Release|x64 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|x64.Build.0 = Release|x64 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|x86.ActiveCfg = Release|x86 + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9}.Release|x86.Build.0 = Release|x86 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|x64.ActiveCfg = Debug|x64 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|x64.Build.0 = Debug|x64 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|x86.ActiveCfg = Debug|x86 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Debug|x86.Build.0 = Debug|x86 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|Any CPU.Build.0 = Release|Any CPU + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|x64.ActiveCfg = Release|x64 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|x64.Build.0 = Release|x64 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|x86.ActiveCfg = Release|x86 + {8EE5F27A-A763-45BB-97A5-E7C690FC594B}.Release|x86.Build.0 = Release|x86 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|x64.ActiveCfg = Debug|x64 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|x64.Build.0 = Debug|x64 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|x86.ActiveCfg = Debug|x86 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Debug|x86.Build.0 = Debug|x86 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|Any CPU.Build.0 = Release|Any CPU + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|x64.ActiveCfg = Release|x64 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|x64.Build.0 = Release|x64 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|x86.ActiveCfg = Release|x86 + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {78A8B08C-C0E9-4BAC-9AF6-58D3A55C05C9} = {8B47E55D-134C-4308-838A-F48A25302FC6} + {8EE5F27A-A763-45BB-97A5-E7C690FC594B} = {8B47E55D-134C-4308-838A-F48A25302FC6} + {CB2B7609-C7B8-4E2A-82D8-DD631B70B621} = {8B47E55D-134C-4308-838A-F48A25302FC6} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CB6377CF-90C6-4056-BA04-3AF40B6CEE1B} EndGlobalSection diff --git a/ZuneModdingHelper/AbstractUIGroupDialog.xaml.cs b/ZuneModdingHelper/AbstractUIGroupDialog.xaml.cs index b2aa71a..9e7214c 100644 --- a/ZuneModdingHelper/AbstractUIGroupDialog.xaml.cs +++ b/ZuneModdingHelper/AbstractUIGroupDialog.xaml.cs @@ -15,7 +15,6 @@ namespace ZuneModdingHelper { ViewModel = viewModel; DataContext = ViewModel; - InitializeComponent(); } public AbstractUIGroupDialog(AbstractUICollection group) : this(new AbstractUICollectionViewModel(group)) { diff --git a/ZuneModdingHelper/App.cs b/ZuneModdingHelper/App.cs new file mode 100644 index 0000000..d61e115 --- /dev/null +++ b/ZuneModdingHelper/App.cs @@ -0,0 +1,62 @@ +using System; +using CommunityToolkit.Mvvm.DependencyInjection; +using IrisShell; +using Microsoft.AppCenter; +using Microsoft.AppCenter.Analytics; +using Microsoft.AppCenter.Crashes; + +namespace ZuneModdingHelper; + +/// +/// Interaction logic for App.xaml +/// +public class App : IrisAppBase +{ + public static readonly ReleaseVersion Version = new(2021, 12, 30, 0, Phase.Alpha); + public static readonly string VersionStr = Version.ToString(); + + public const string DonateLink = "http://josh.askharoun.com/donate"; + + public override string Title => "Zune Modding Helper"; + + public override string WindowSource => "clr-res://ZuneModdingHelper!Home.uix"; + + public App() + { + ServiceProviderReady += OnServiceProviderReady; + } + + [STAThread] + public static int Main(string[] args) + { + ConfigureAppCenter(); + App app = new(); + return app.Run(args); + } + + public static void OpenInBrowser(string url) + { + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) + { + UseShellExecute = true + }); + } + + private static void ConfigureAppCenter() + { + // Set up App Center analytics + AppCenter.SetCountryCode(System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName); + AppCenter.Start("24903c19-b3d9-4ab5-b445-b981ca647125", typeof(Analytics), typeof(Crashes)); + +#if DEBUG + // Disable crash and event analytics when in debug + AppCenter.SetEnabledAsync(false); +#endif + } + + private void OnServiceProviderReady(object sender, IServiceProvider serviceProvider) + { + ServiceProviderReady -= OnServiceProviderReady; + Ioc.Default.ConfigureServices(serviceProvider); + } +} diff --git a/ZuneModdingHelper/App.xaml b/ZuneModdingHelper/App.xaml deleted file mode 100644 index 9fb4a2b..0000000 --- a/ZuneModdingHelper/App.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - Assets/ZMH_Icons.ttf#ZMHIcons - - - diff --git a/ZuneModdingHelper/App.xaml.cs b/ZuneModdingHelper/App.xaml.cs deleted file mode 100644 index cb62e11..0000000 --- a/ZuneModdingHelper/App.xaml.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Windows; -using CommunityToolkit.Mvvm.DependencyInjection; -using Microsoft.AppCenter; -using Microsoft.AppCenter.Analytics; -using Microsoft.AppCenter.Crashes; -using Microsoft.Extensions.DependencyInjection; - -namespace ZuneModdingHelper -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - public const string Title = "Zune Modding Helper"; - - public static readonly ReleaseVersion Version = new(2021, 12, 30, 0, Phase.Alpha); - public static readonly string VersionStr = Version.ToString(); - - public const string DonateLink = "http://josh.askharoun.com/donate"; - - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - - // Set up App Center analytics - AppCenter.SetCountryCode(System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName); - AppCenter.Start("24903c19-b3d9-4ab5-b445-b981ca647125", typeof(Analytics), typeof(Crashes)); - -#if DEBUG - // Disable crash and event analytics when in debug - AppCenter.SetEnabledAsync(false); -#endif - - ConfigureServices(); - } - - public static void OpenInBrowser(string url) - { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) - { - UseShellExecute = true - }); - } - - private static void ConfigureServices() - { - ServiceCollection services = new(); - Ioc.Default.ConfigureServices(services.BuildServiceProvider()); - } - } -} diff --git a/ZuneModdingHelper/Controls/TOPTOOLBAR.UIX b/ZuneModdingHelper/Controls/TOPTOOLBAR.UIX new file mode 100644 index 0000000..73fbabf --- /dev/null +++ b/ZuneModdingHelper/Controls/TOPTOOLBAR.UIX @@ -0,0 +1,698 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZuneModdingHelper/Home.uix b/ZuneModdingHelper/Home.uix new file mode 100644 index 0000000..8be798c --- /dev/null +++ b/ZuneModdingHelper/Home.uix @@ -0,0 +1,384 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZuneModdingHelper/MainWindow.xaml.cs b/ZuneModdingHelper/MainWindow.xaml.cs index 800b929..6868b08 100644 --- a/ZuneModdingHelper/MainWindow.xaml.cs +++ b/ZuneModdingHelper/MainWindow.xaml.cs @@ -4,6 +4,7 @@ using MahApps.Metro.Controls; using MahApps.Metro.Controls.Dialogs; using Microsoft.AppCenter.Analytics; using Microsoft.WindowsAPICodePack.Dialogs; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OwlCore.AbstractUI.Models; using Syroot.Windows.IO; @@ -33,7 +34,6 @@ namespace ZuneModdingHelper public MainWindow() { - InitializeComponent(); // https://github.com/Arlodotexe/OwlCore/issues/1 OwlCore.Threading.SetPrimarySynchronizationContext(System.Threading.SynchronizationContext.Current!); OwlCore.Threading.SetPrimaryThreadInvokeHandler(RunOnUI); @@ -41,8 +41,8 @@ namespace ZuneModdingHelper ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncWithAppMode; ThemeManager.Current.SyncTheme(); - ModList.ItemsSource = Mod.AvailableMods; - ZuneInstallDirBox.Text = Mod.ZuneInstallDir; + //ModList.ItemsSource = Mod.AvailableMods; + //ZuneInstallDirBox.Text = Mod.ZuneInstallDir; } private async System.Threading.Tasks.Task RunOnUI(Action action) => await Dispatcher.BeginInvoke(action); @@ -65,7 +65,7 @@ namespace ZuneModdingHelper { var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to apply mod", settings: defaultMetroDialogSettings); Mod mod = (Mod)((FrameworkElement)sender).DataContext; - Mod.ZuneInstallDir = ZuneInstallDirBox.Text; + Mod.ZuneInstallDir = "";// ZuneInstallDirBox.Text; progDialog.Maximum = 3; int numCompleted = 0; @@ -122,7 +122,7 @@ namespace ZuneModdingHelper if (sender is FrameworkElement elem && elem.DataContext is Mod mod) { var progDialog = await this.ShowProgressAsync("Getting ready...", "Preparing to reset mod", settings: defaultMetroDialogSettings); - Mod.ZuneInstallDir = ZuneInstallDirBox.Text; + Mod.ZuneInstallDir = "";// ZuneInstallDirBox.Text; progDialog.Maximum = 2; int numCompleted = 0; @@ -167,8 +167,8 @@ namespace ZuneModdingHelper private void AboutButton_Click(object sender, RoutedEventArgs e) { - AboutFlyout.Width = Math.Max(Math.Min(500, ActualWidth), ActualWidth / 3); - AboutFlyout.IsOpen = true; + //AboutFlyout.Width = Math.Max(Math.Min(500, ActualWidth), ActualWidth / 3); + //AboutFlyout.IsOpen = true; } private void Link_RequestNavigate(object sender, RequestNavigateEventArgs e) @@ -184,11 +184,15 @@ namespace ZuneModdingHelper try { + var request = "https://api.github.com/repos/ZuneDev/ZuneModdingHelper/releases" + .WithHeader("User-Agent", App.Current.Title.Replace(" ", "") + "/" + App.VersionStr); + var response = await request.GetStreamAsync(); + // Get releases list from GitHub - List releases = await "https://api.github.com/repos/ZuneDev/ZuneModdingHelper/releases" - .WithHeader("User-Agent", App.Title.Replace(" ", "") + "/" + App.VersionStr) - .GetJsonAsync>(); - JObject latest = releases[0]; + StreamReader streamReader = new(response); + var jsonReader = new JsonTextReader(streamReader); + var releases = await JArray.LoadAsync(jsonReader); + JObject latest = releases.OfType().First(); string latestVerStr = latest["tag_name"].Value(); if (!ReleaseVersion.TryParse(latestVerStr, out var latestVer) || App.Version >= latestVer) { @@ -284,7 +288,7 @@ namespace ZuneModdingHelper CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { - ZuneInstallDirBox.Text = dialog.FileName; + //ZuneInstallDirBox.Text = dialog.FileName; } } else diff --git a/ZuneModdingHelper/ZuneModdingHelper.csproj b/ZuneModdingHelper/ZuneModdingHelper.csproj index 602a52c..e47794a 100644 --- a/ZuneModdingHelper/ZuneModdingHelper.csproj +++ b/ZuneModdingHelper/ZuneModdingHelper.csproj @@ -1,39 +1,42 @@  - - WinExe - net5.0-windows - true - app.manifest - 2021.12.30.0 - Joshua "Yoshi" Askharoun - https://github.com/ZuneDev/ZuneModdingHelper - git - x64;x86 - latest - Assets\ZMH_Icon.ico - + + WinExe + net6.0-windows + app.manifest + 2021.12.30.0 + Joshua "Yoshi" Askharoun + https://github.com/ZuneDev/ZuneModdingHelper + git + x64;x86 + latest + Assets\ZMH_Icon.ico + - - - - + + + + + - - - - - - - - - - + + + + + + + + + + - - - PreserveNewest - - + + + + + + PreserveNewest + + diff --git a/libs/MicrosoftIris b/libs/MicrosoftIris index 3050703..be3f2a1 160000 --- a/libs/MicrosoftIris +++ b/libs/MicrosoftIris @@ -1 +1 @@ -Subproject commit 3050703ab16ea3aa165be853f1b0e737fd71f174 +Subproject commit be3f2a10b6575fe30738a57824ed5e5137b7d1e6