From f30ba88c7ffa61625fd35f1995be082043a3bd6c Mon Sep 17 00:00:00 2001 From: Goose Bomb Date: Wed, 17 Feb 2021 18:57:20 +0800 Subject: [PATCH 01/15] Set default background effect as BlurBehind --- GBCLV3/Services/ConfigService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GBCLV3/Services/ConfigService.cs b/GBCLV3/Services/ConfigService.cs index dbb5ad7..c635c4f 100644 --- a/GBCLV3/Services/ConfigService.cs +++ b/GBCLV3/Services/ConfigService.cs @@ -2,6 +2,7 @@ using GBCLV3.Models.Authentication; using GBCLV3.Models.Download; using GBCLV3.Models.Launch; +using GBCLV3.Models.Theme; using GBCLV3.Utils; using System; using System.Collections.Generic; @@ -48,6 +49,7 @@ public void Load() WindowHeight = 480, AfterLaunch = AfterLaunchBehavior.Hide, DownloadSource = DownloadSource.Official, + BackgroundEffect = BackgroundEffect.BlurBehind, }; } From ab08ab42a5e1f109f38487f72eb0755ecfff8902 Mon Sep 17 00:00:00 2001 From: Goose Bomb Date: Wed, 17 Feb 2021 18:59:57 +0800 Subject: [PATCH 02/15] Update copyright year --- GBCLV3/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GBCLV3/Properties/AssemblyInfo.cs b/GBCLV3/Properties/AssemblyInfo.cs index f70c01e..9789751 100644 --- a/GBCLV3/Properties/AssemblyInfo.cs +++ b/GBCLV3/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Goose Bomb")] [assembly: AssemblyProduct("Goose Bomb's Minecraft Launcher V3")] -[assembly: AssemblyCopyright("Copyright © Goose Bomb 2020")] +[assembly: AssemblyCopyright("Copyright © Goose Bomb 2019-2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.13.197")] From 11af5df654fb162a1cf463fb53dfb57bb6bc41a8 Mon Sep 17 00:00:00 2001 From: Goose Bomb Date: Wed, 17 Feb 2021 19:12:44 +0800 Subject: [PATCH 03/15] Allow HEIF/AVIF format background image --- GBCLV3/Services/ThemeService.cs | 5 +++-- GBCLV3/ViewModels/Tabs/LauncherSettingsViewModel.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/GBCLV3/Services/ThemeService.cs b/GBCLV3/Services/ThemeService.cs index 71b4326..deddce0 100644 --- a/GBCLV3/Services/ThemeService.cs +++ b/GBCLV3/Services/ThemeService.cs @@ -19,6 +19,8 @@ public class ThemeService : PropertyChangedBase { #region Binding Properties + public static string[] ImageExtenstions { get; } = { ".png", ".jpg", ".jpeg", ".jfif", ".bmp", ".tif", ".tiff", ".webp", ".heif", ".heic", ".avif" }; + public BitmapImage BackgroundImage { get; private set; } public StreamGeometry BackgroundIcon { get; private set; } @@ -98,9 +100,8 @@ public void UpdateBackgroundImage() string imgSearchDir = Environment.CurrentDirectory + "/bg"; if (Directory.Exists(imgSearchDir)) { - string[] imgExtensions = { ".png", ".jpg", ".jpeg", ".jfif", ".bmp", ".tif", ".tiff", ".webp" }; string[] imgFiles = Directory.EnumerateFiles(imgSearchDir) - .Where(file => imgExtensions.Any(file.ToLower().EndsWith)) + .Where(file => ImageExtenstions.Any(file.ToLower().EndsWith)) .ToArray(); if (imgFiles.Any()) diff --git a/GBCLV3/ViewModels/Tabs/LauncherSettingsViewModel.cs b/GBCLV3/ViewModels/Tabs/LauncherSettingsViewModel.cs index 9b73cc9..28cf904 100644 --- a/GBCLV3/ViewModels/Tabs/LauncherSettingsViewModel.cs +++ b/GBCLV3/ViewModels/Tabs/LauncherSettingsViewModel.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Text; using System.Windows; using GBCLV3.Models; using GBCLV3.Models.Download; @@ -154,10 +155,16 @@ public async void CheckUpdate() public void SelectBackgoundImagePath() { + var sb = new StringBuilder("Images |"); + foreach(var extenstion in ThemeService.ImageExtenstions) + { + sb.Append($"*{extenstion};"); + } + var dialog = new Microsoft.Win32.OpenFileDialog() { Title = _languageService.GetEntry("SelectImagePath"), - Filter = "Images | *.jpg; *.jpeg; *.jfif; *.bmp; *.png; *.tif; *.tiff; *.webp;", + Filter = sb.ToString(), }; if (dialog.ShowDialog() ?? false) From c94fe4f2d1970155f1847906c946001698f90ea2 Mon Sep 17 00:00:00 2001 From: Goose Bomb Date: Tue, 23 Feb 2021 22:18:41 +0800 Subject: [PATCH 04/15] Add shaderpacks manager --- GBCLV3/Bootstrapper.cs | Bin 15162 -> 15314 bytes GBCLV3/Models/Auxiliary/ShaderPack.cs | 17 ++ GBCLV3/Resources/Languages/Strings/en-US.xaml | 6 +- .../Services/Auxiliary/ShaderPackService.cs | 113 +++++++++++ GBCLV3/Services/Launch/GamePathService.cs | 2 + GBCLV3/ViewModels/Tabs/ShaderPackViewModel.cs | 42 ++++ GBCLV3/Views/Pages/AuxiliariesRootView.xaml | 4 + GBCLV3/Views/Tabs/ShaderPackView.xaml | 189 ++++++++++++++++++ 8 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 GBCLV3/Models/Auxiliary/ShaderPack.cs create mode 100644 GBCLV3/Services/Auxiliary/ShaderPackService.cs create mode 100644 GBCLV3/ViewModels/Tabs/ShaderPackViewModel.cs create mode 100644 GBCLV3/Views/Tabs/ShaderPackView.xaml diff --git a/GBCLV3/Bootstrapper.cs b/GBCLV3/Bootstrapper.cs index 58b49558f32a23bf09bf282ee9ee35c6b0665a1a..b1724a3b46abe3c4ec930fa08063dc63ed7cf97e 100644 GIT binary patch delta 22 dcmdm0cBy>B9zo6whD3%GhE#^4&ANiTS^#De2P^;p delta 12 TcmcaqzN>7*9>L8aLUoz|E1w0o diff --git a/GBCLV3/Models/Auxiliary/ShaderPack.cs b/GBCLV3/Models/Auxiliary/ShaderPack.cs new file mode 100644 index 0000000..03f29c1 --- /dev/null +++ b/GBCLV3/Models/Auxiliary/ShaderPack.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GBCLV3.Models.Auxiliary +{ + public class ShaderPack + { + public string Name => System.IO.Path.GetFileName(Path); + + public string Path { get; set; } + + public bool IsEnabled { get; set; } + + public bool IsExtracted { get; set; } + } +} diff --git a/GBCLV3/Resources/Languages/Strings/en-US.xaml b/GBCLV3/Resources/Languages/Strings/en-US.xaml index 623dfee..d1bf02e 100644 --- a/GBCLV3/Resources/Languages/Strings/en-US.xaml +++ b/GBCLV3/Resources/Languages/Strings/en-US.xaml @@ -224,13 +224,16 @@ Disable When adding new mods, copy instead of moving them from source directory - Enabled Packs Select Resourcepacks Disabled Packs Open + + Available Shaderpacks + Select Shaderpacks + Dependencies Thanks to @@ -270,6 +273,7 @@ Fabric Install Mods Resourcepacks + Shaderpacks Saves Skins About diff --git a/GBCLV3/Services/Auxiliary/ShaderPackService.cs b/GBCLV3/Services/Auxiliary/ShaderPackService.cs new file mode 100644 index 0000000..6c25f95 --- /dev/null +++ b/GBCLV3/Services/Auxiliary/ShaderPackService.cs @@ -0,0 +1,113 @@ +using GBCLV3.Models.Auxiliary; +using GBCLV3.Services.Launch; +using GBCLV3.Utils; +using StyletIoC; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace GBCLV3.Services.Auxiliary +{ + public class ShaderPackService + { + #region Private Fields + + // IoC + private readonly GamePathService _gamePathService; + + #endregion + + #region Constructor + + [Inject] + public ShaderPackService(GamePathService gamePathService) + { + _gamePathService = gamePathService; + } + + #endregion + + #region Public Methods + + public IEnumerable LoadAll() + { + string opttionsFile = _gamePathService.RootDir + "/optionsshaders.txt"; + string enabledPackId = null; + + if (File.Exists(opttionsFile)) + { + using var reader = new StreamReader(opttionsFile, Encoding.Default); + string line; + + while ((line = reader.ReadLine()) != null) + { + if (line.StartsWith("shaderPack=")) + { + enabledPackId = line[..11]; + break; + } + } + } + + // Make sure "gameroot/shaderpacks" dir exists + Directory.CreateDirectory(_gamePathService.ShaderPacksDir); + + return Directory.EnumerateFileSystemEntries(_gamePathService.ShaderPacksDir) + .Select(path => Load(path, enabledPackId)) + .Where(pack => pack != null); + } + + public void WriteToOptions(string enabledPackId) + { + string opttionsFile = _gamePathService.RootDir + "/optionsshaders.txt"; + if (!File.Exists(opttionsFile)) return; + + string options = File.ReadAllText(opttionsFile, Encoding.Default); + options = Regex.Replace(options, "shaderPack=.*", $"shaderPack={enabledPackId}"); + File.WriteAllText(opttionsFile, options, Encoding.Default); + } + + public ValueTask DeleteFromDiskAsync(ShaderPack pack) + { + return pack.IsExtracted + ? SystemUtil.SendDirToRecycleBinAsync(pack.Path) + : SystemUtil.SendFileToRecycleBinAsync(pack.Path); + } + + #endregion + + #region Helper Methods + + private static ShaderPack Load(string path, string enabledPackId) + { + bool isZip = path.EndsWith(".zip"); + + if (isZip) + { + using var archive = ZipFile.OpenRead(path); + if (archive.GetEntry("shaders/composite.fsh") == null) + { + return null; + } + } + else if (!File.Exists(path + "/shaders/composite.fsh")) + { + return null; + } + + return new ShaderPack + { + Path = path, + IsEnabled = (Path.GetFileName(path) == enabledPackId), + IsExtracted = !isZip + }; + } + + #endregion + } +} diff --git a/GBCLV3/Services/Launch/GamePathService.cs b/GBCLV3/Services/Launch/GamePathService.cs index 714b246..d231e2e 100644 --- a/GBCLV3/Services/Launch/GamePathService.cs +++ b/GBCLV3/Services/Launch/GamePathService.cs @@ -25,6 +25,8 @@ public class GamePathService public string ResourcePacksDir => WorkingDir + "/resourcepacks"; + public string ShaderPacksDir => WorkingDir + "/shaderpacks"; + public string SavesDir => WorkingDir + "/saves"; public string LogsDir => WorkingDir + "/logs"; diff --git a/GBCLV3/ViewModels/Tabs/ShaderPackViewModel.cs b/GBCLV3/ViewModels/Tabs/ShaderPackViewModel.cs new file mode 100644 index 0000000..02197fa --- /dev/null +++ b/GBCLV3/ViewModels/Tabs/ShaderPackViewModel.cs @@ -0,0 +1,42 @@ +using GBCLV3.Models.Auxiliary; +using GBCLV3.Services.Auxiliary; +using GBCLV3.Services.Launch; +using Stylet; +using StyletIoC; +using System; +using System.Collections.Generic; +using System.Text; + +namespace GBCLV3.ViewModels.Tabs +{ + public class ShaderPackViewModel : Screen + { + + #region Private Fields + + private readonly GamePathService _gamePathService; + private readonly ShaderPackService _shaderPackService; + + #endregion + + #region Constructor + + [Inject] + public ShaderPackViewModel(GamePathService gamePathService, ShaderPackService shaderPackService) + { + _gamePathService = gamePathService; + _shaderPackService = shaderPackService; + } + + #endregion + + #region Bindings + + public BindableCollection ShaderPacks { get; } + + + + + #endregion + } +} diff --git a/GBCLV3/Views/Pages/AuxiliariesRootView.xaml b/GBCLV3/Views/Pages/AuxiliariesRootView.xaml index fe42023..45849d0 100644 --- a/GBCLV3/Views/Pages/AuxiliariesRootView.xaml +++ b/GBCLV3/Views/Pages/AuxiliariesRootView.xaml @@ -14,6 +14,10 @@ + + + + diff --git a/GBCLV3/Views/Tabs/ShaderPackView.xaml b/GBCLV3/Views/Tabs/ShaderPackView.xaml new file mode 100644 index 0000000..373d596 --- /dev/null +++ b/GBCLV3/Views/Tabs/ShaderPackView.xaml @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +