seperated cli & some work for options
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pilz.Cryptography" Version="2.1.2" />
|
||||
<PackageReference Include="Pilz.IO" Version="2.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Configuration;
|
||||
|
||||
namespace ModpackUpdater.Apps.Client;
|
||||
namespace ModpackUpdater.Apps.Client.Gui;
|
||||
|
||||
public class AppConfig : IChildSettings, ISettingsIdentifier
|
||||
public class AppConfig : ISettingsNode, ISettingsIdentifier
|
||||
{
|
||||
public static string Identifier => "pilz.appconfig";
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Pilz.Extensions;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ModpackUpdater.Apps.Client;
|
||||
namespace ModpackUpdater.Apps.Client.Gui;
|
||||
|
||||
public class AppUpdater
|
||||
public class AppUpdater(string updateUrl)
|
||||
{
|
||||
private class UpdateInfo
|
||||
{
|
||||
@@ -15,7 +14,6 @@ public class AppUpdater
|
||||
public string DownloadUrl { get; set; }
|
||||
}
|
||||
|
||||
private const string UPDATE_URL = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json";
|
||||
private readonly HttpClient httpClient = new();
|
||||
private UpdateInfo info;
|
||||
|
||||
@@ -26,7 +24,7 @@ public class AppUpdater
|
||||
try
|
||||
{
|
||||
var appVersion = Assembly.GetExecutingAssembly().GetAppVersion().Version;
|
||||
var result = await httpClient.GetStringAsync(UPDATE_URL);
|
||||
var result = await httpClient.GetStringAsync(updateUrl);
|
||||
info = JsonConvert.DeserializeObject<UpdateInfo>(result);
|
||||
|
||||
if (info is not null && info.Version > appVersion)
|
||||
@@ -58,10 +56,10 @@ public class AppUpdater
|
||||
// Download the new file
|
||||
using (var tempFileStream = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite))
|
||||
{
|
||||
Stream downloadStream = null;
|
||||
Stream? downloadStream = null;
|
||||
try
|
||||
{
|
||||
var url = info.DownloadUrl;
|
||||
var url = info?.DownloadUrl;
|
||||
downloadStream = await client.GetStreamAsync(url);
|
||||
await downloadStream.CopyToAsync(tempFileStream);
|
||||
}
|
||||
@@ -75,7 +73,10 @@ public class AppUpdater
|
||||
}
|
||||
|
||||
// Replace current application file with new file
|
||||
if (!string.IsNullOrWhiteSpace(appFileName))
|
||||
{
|
||||
File.Move(appFileName, oldFileName, true);
|
||||
File.Move(tempFileName, appFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace ModpackUpdater.My.Resources {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModpackUpdater.Apps.Client.FiledialogFilters", typeof(FiledialogFilters).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModpackUpdater.Apps.Client.Gui.FiledialogFilters", typeof(FiledialogFilters).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -39,7 +39,7 @@ namespace ModpackUpdater.My.Resources {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModpackUpdater.Apps.Client.LangRes", typeof(LangRes).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModpackUpdater.Apps.Client.Gui.LangRes", typeof(LangRes).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
@@ -3,7 +3,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ModpackUpdater.Apps.Client
|
||||
namespace ModpackUpdater.Apps.Client.Gui
|
||||
{
|
||||
[Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
|
||||
|
||||
@@ -8,11 +8,11 @@ using System.Reflection;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Client;
|
||||
namespace ModpackUpdater.Apps.Client.Gui;
|
||||
|
||||
public partial class MainForm
|
||||
{
|
||||
private readonly UpdateCheckOptionsAdv updateOptions;
|
||||
private readonly UpdateCheckOptions updateOptions = new();
|
||||
private ModpackInfo modpackInfo = new();
|
||||
private ModpackConfig updateConfig = new();
|
||||
private ModpackFeatures features;
|
||||
@@ -21,14 +21,8 @@ public partial class MainForm
|
||||
private bool loadingData;
|
||||
private int curOptionsRow = 3;
|
||||
|
||||
public MainForm() : this(new())
|
||||
public MainForm()
|
||||
{
|
||||
}
|
||||
|
||||
public MainForm(UpdateCheckOptionsAdv updateOptions)
|
||||
{
|
||||
this.updateOptions = updateOptions;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Text = $"{Text} (v{Assembly.GetExecutingAssembly().GetAppVersion()})";
|
||||
@@ -60,14 +54,24 @@ public partial class MainForm
|
||||
private void LoadProfileToUi()
|
||||
{
|
||||
loadingData = true;
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
|
||||
RadTextBox_MinecraftProfileFolder.Text = modpackInfo?.LocaLPath ?? updateOptions.ProfileFolder ?? AppConfig.Instance.LastMinecraftProfilePath ?? RadTextBox_MinecraftProfileFolder.Text;
|
||||
RadTextBox_ModpackConfig.Text = modpackInfo?.ConfigUrl ?? updateOptions.ModpackConfig ?? RadTextBox_ModpackConfig.Text;
|
||||
radTextBox_InstallKey.Text = modpackInfo?.ExtrasKey ?? updateOptions.ExtrasKey ?? radTextBox_InstallKey.Text;
|
||||
RadTextBox_MinecraftProfileFolder.Text = modpackInfo?.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? RadTextBox_MinecraftProfileFolder.Text;
|
||||
RadTextBox_ModpackConfig.Text = modpackInfo?.ConfigUrl ?? RadTextBox_ModpackConfig.Text;
|
||||
radTextBox_InstallKey.Text = modpackInfo?.ExtrasKey ?? radTextBox_InstallKey.Text;
|
||||
|
||||
tableLayoutPanel1.ResumeLayout();
|
||||
loadingData = false;
|
||||
}
|
||||
|
||||
private void LoadOptionsToUi()
|
||||
{
|
||||
//foreach (var set in )
|
||||
//{
|
||||
// // ...
|
||||
//}
|
||||
}
|
||||
|
||||
private async void CheckStatusAndUpdate(bool loadProfileToUi)
|
||||
{
|
||||
if (CheckStatus(loadProfileToUi))
|
||||
@@ -121,6 +125,7 @@ public partial class MainForm
|
||||
RadButton_Install.Enabled = false;
|
||||
return false;
|
||||
}
|
||||
LoadOptionsToUi();
|
||||
RadButton_CheckForUpdates.Enabled = true;
|
||||
RadButton_Install.Enabled = true;
|
||||
return true;
|
||||
@@ -131,11 +136,7 @@ public partial class MainForm
|
||||
// Ensure set extras key
|
||||
modpackInfo.ExtrasKey = radTextBox_InstallKey.Text.Trim();
|
||||
|
||||
var updater = new ModpackInstaller(updateConfig, modpackInfo)
|
||||
{
|
||||
OverwriteRefTag = Program.Options.RefTag,
|
||||
OverwriteVersion = Program.Options.Version,
|
||||
};
|
||||
var updater = new ModpackInstaller(updateConfig, modpackInfo);
|
||||
updater.InstallProgessUpdated += Update_InstallProgessUpdated;
|
||||
updater.CheckingProgressUpdated += Updated_CheckingProgresssUpdated;
|
||||
|
||||
@@ -192,6 +193,10 @@ public partial class MainForm
|
||||
return;
|
||||
}
|
||||
|
||||
// Load options
|
||||
// lastUpdateCheckResult.OptionsAvailable...
|
||||
// lastUpdateCheckResult.OptionsEnabled...
|
||||
|
||||
// No updates available
|
||||
if (!lastUpdateCheckResult.HasUpdates)
|
||||
{
|
||||
@@ -257,8 +262,8 @@ public partial class MainForm
|
||||
|
||||
private async void Form1_Shown(object sender, EventArgs e)
|
||||
{
|
||||
var updater = new AppUpdater();
|
||||
if (!updateOptions.NoUpdate && await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info).IsYes())
|
||||
var updater = new AppUpdater(Program.UPDATE_URL);
|
||||
if (await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info).IsYes())
|
||||
{
|
||||
SetStatus(LangRes.StatusText_InstallingAppUpdate, AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
|
||||
Enabled = false;
|
||||
@@ -0,0 +1,64 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ApplicationIcon>minecraft modpack updater.ico</ApplicationIcon>
|
||||
<AssemblyName>Minecraft Modpack Updater</AssemblyName>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Version.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FiledialogFilters.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>FiledialogFilters.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LangRes.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>LangRes.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="FiledialogFilters.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>ModpackUpdater.My.Resources</CustomToolNamespace>
|
||||
<LastGenOutput>FiledialogFilters.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="LangRes.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>ModpackUpdater.My.Resources</CustomToolNamespace>
|
||||
<LastGenOutput>LangRes.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.2.6" />
|
||||
<PackageReference Include="Pilz.Cryptography" Version="2.1.2" />
|
||||
<PackageReference Include="Pilz.IO" Version="2.1.0" />
|
||||
<PackageReference Include="Pilz.UI" Version="3.0.0" />
|
||||
<PackageReference Include="Pilz.UI.WinForms" Version="2.6.2" />
|
||||
<PackageReference Include="Pilz.UI.WinForms.Telerik" Version="2.13.3" />
|
||||
<PackageReference Include="Pilz.UI.WinForms.Telerik.Symbols" Version="1.2.1" />
|
||||
<PackageReference Include="UI.for.WinForms.Common" Version="2025.2.612-preview" />
|
||||
<PackageReference Include="UI.for.WinForms.Themes" Version="2025.2.612-preview" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ModpackUpdater.Apps.AppUpdates\ModpackUpdater.Apps.AppUpdates.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater.Apps\ModpackUpdater.Apps.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater.Manager\ModpackUpdater.Manager.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater\ModpackUpdater.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
64
ModpackUpdater.Apps.Client.Gui/Program.cs
Normal file
64
ModpackUpdater.Apps.Client.Gui/Program.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Castle.Core.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Configuration;
|
||||
|
||||
namespace ModpackUpdater.Apps.Client.Gui;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public const string UPDATE_URL = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json";
|
||||
|
||||
private static readonly SettingsManager settingsManager;
|
||||
private static readonly ILogger log = new ConsoleLogger();
|
||||
|
||||
public static ISettings Settings => settingsManager.Instance;
|
||||
public static ILogger Log => log;
|
||||
|
||||
static Program()
|
||||
{
|
||||
settingsManager = new(GetSettingsPath(2), true);
|
||||
MigrateLegacySettings(GetSettingsPath(null));
|
||||
}
|
||||
|
||||
[STAThread]
|
||||
internal static void Main(string[] args)
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
AppGlobals.Initialize();
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 3)
|
||||
{
|
||||
const string AppDataDirectoryName = "MinecraftModpackUpdater";
|
||||
var fileNamePostfix = settingsVersion == null ? string.Empty : $"V{settingsVersion}";
|
||||
var SettingsFileName = $"Settings{fileNamePostfix}.json";
|
||||
|
||||
var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName);
|
||||
Directory.CreateDirectory(settingsPath);
|
||||
settingsPath = Path.Combine(settingsPath, SettingsFileName);
|
||||
|
||||
return settingsPath;
|
||||
}
|
||||
|
||||
private static void MigrateLegacySettings(string settingsPath)
|
||||
{
|
||||
// Try load legacy config file
|
||||
if (!File.Exists(settingsPath) || JsonConvert.DeserializeObject<AppConfig>(File.ReadAllText(settingsPath)) is not AppConfig legacyConfig)
|
||||
return;
|
||||
|
||||
// Migrate
|
||||
var newConfig = Settings.Get<AppConfig>();
|
||||
newConfig.LastMinecraftProfilePath = legacyConfig.LastMinecraftProfilePath;
|
||||
|
||||
if (ModpackInfo.TryLoad(legacyConfig.LastMinecraftProfilePath) is ModpackInfo info)
|
||||
#pragma warning disable CS0612 // Typ oder Element ist veraltet
|
||||
info.ConfigUrl = legacyConfig.ConfigFilePath;
|
||||
|
||||
// Ensure save settings
|
||||
settingsManager.Save();
|
||||
|
||||
// Delete legacy config file
|
||||
File.Delete(settingsPath);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>bin\publish\windows\</PublishDir>
|
||||
<PublishDir>..\publish\ui\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
|
||||
<SelfContained>false</SelfContained>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
</PropertyGroup>
|
||||
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -2,56 +2,24 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ApplicationIcon>minecraft modpack updater.ico</ApplicationIcon>
|
||||
<AssemblyName>Minecraft Modpack Updater</AssemblyName>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FiledialogFilters.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>FiledialogFilters.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="LangRes.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>LangRes.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="FiledialogFilters.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>ModpackUpdater.My.Resources</CustomToolNamespace>
|
||||
<LastGenOutput>FiledialogFilters.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="LangRes.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>ModpackUpdater.My.Resources</CustomToolNamespace>
|
||||
<LastGenOutput>LangRes.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="..\Version.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.2.6" />
|
||||
<PackageReference Include="Pilz.Cryptography" Version="2.1.2" />
|
||||
<PackageReference Include="Pilz.IO" Version="2.1.0" />
|
||||
<PackageReference Include="Pilz.UI" Version="3.0.0" />
|
||||
<PackageReference Include="Pilz.UI.WinForms" Version="2.6.2" />
|
||||
<PackageReference Include="Pilz.UI.WinForms.Telerik" Version="2.13.3" />
|
||||
<PackageReference Include="Pilz.UI.WinForms.Telerik.Symbols" Version="1.2.1" />
|
||||
<PackageReference Include="UI.for.WinForms.Common" Version="2025.2.612-preview" />
|
||||
<PackageReference Include="UI.for.WinForms.Themes" Version="2025.2.612-preview" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ModpackUpdater.Apps\ModpackUpdater.Apps.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater.Apps.AppUpdates\ModpackUpdater.Apps.AppUpdates.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater.Manager\ModpackUpdater.Manager.csproj" />
|
||||
<ProjectReference Include="..\ModpackUpdater\ModpackUpdater.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -10,9 +10,8 @@ internal class Options
|
||||
public IReadOnlyList<string> Additionals => additionals;
|
||||
public bool Help { get; private set; }
|
||||
public bool Silent { get; private set; }
|
||||
public bool NoUi { get; private set; }
|
||||
public string RefTag { get; private set; }
|
||||
public string Version { get; private set; }
|
||||
public string? RefTag { get; private set; }
|
||||
public string? Version { get; private set; }
|
||||
public UpdateCheckOptionsAdv UpdateOptions { get; } = new();
|
||||
|
||||
public Options(string[] args)
|
||||
@@ -21,12 +20,10 @@ internal class Options
|
||||
{
|
||||
{ "silent", "Do not output anything.", s => Silent = true },
|
||||
{ "h|help", "Writes the help text as output.", h => Help = true },
|
||||
{ "n|noui", "Install without user interface.", n => NoUi = true },
|
||||
{ "p|profile=", "Sets the minecraft profile folder.", p => UpdateOptions.ProfileFolder = p },
|
||||
{ "c|config=", "Sets the modpack update info url.", c => UpdateOptions.ModpackConfig = c },
|
||||
{ "s|side=", "Sets the installation side.\nDefault side is Client.\nAvailable: Client, Server", s => UpdateOptions.Side = Enum.Parse<Side>(s)},
|
||||
{ "u|uai", "Disallow an update directly after install. This only has effect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = false},
|
||||
{ "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = true},
|
||||
{ "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = true},
|
||||
{ "i|nonpublic", "Include non public (currently hidden) updates.", i => UpdateOptions.IncludeNonPublic = true},
|
||||
{ "k|key=", "An key for retriving extra files on updates.", k => UpdateOptions.ExtrasKey = k},
|
||||
|
||||
@@ -1,34 +1,14 @@
|
||||
using Castle.Core.Logging;
|
||||
using ModpackUpdater.Manager;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz;
|
||||
using Pilz.Configuration;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyAppVersion("1.9.2.0")]
|
||||
|
||||
namespace ModpackUpdater.Apps.Client;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
private static readonly SettingsManager settingsManager;
|
||||
private static readonly ILogger log = new ConsoleLogger();
|
||||
|
||||
public static ISettings Settings => settingsManager.Instance;
|
||||
public static ILogger Log => log;
|
||||
internal static Options Options { get; private set; }
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern nint GetConsoleWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ShowWindow(nint hWnd, int nCmdShow);
|
||||
|
||||
static Program()
|
||||
{
|
||||
settingsManager = new(GetSettingsPath(2), true);
|
||||
MigrateLegacySettings(GetSettingsPath(null));
|
||||
}
|
||||
internal static Options Options { get; private set; } = null!;
|
||||
|
||||
[STAThread]
|
||||
internal static void Main(string[] args)
|
||||
@@ -36,61 +16,14 @@ public static class Program
|
||||
Options = new Options(args);
|
||||
if (Options.Help)
|
||||
Options.DrawHelp();
|
||||
else if (Options.NoUi)
|
||||
InstallWithoutGui(Options.UpdateOptions, Options.Silent);
|
||||
else
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
ShowWindow(GetConsoleWindow(), 0);
|
||||
RunApp(Options.UpdateOptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RunApp(UpdateCheckOptionsAdv updateOptions)
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
AppGlobals.Initialize();
|
||||
Application.Run(new MainForm(updateOptions));
|
||||
}
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 3)
|
||||
{
|
||||
const string AppDataDirectoryName = "MinecraftModpackUpdater";
|
||||
var fileNamePostfix = settingsVersion == null ? string.Empty : $"V{settingsVersion}";
|
||||
var SettingsFileName = $"Settings{fileNamePostfix}.json";
|
||||
|
||||
var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName);
|
||||
Directory.CreateDirectory(settingsPath);
|
||||
settingsPath = Path.Combine(settingsPath, SettingsFileName);
|
||||
|
||||
return settingsPath;
|
||||
}
|
||||
|
||||
private static void MigrateLegacySettings(string settingsPath)
|
||||
{
|
||||
// Try load legacy config file
|
||||
if (!File.Exists(settingsPath) || JsonConvert.DeserializeObject<AppConfig>(File.ReadAllText(settingsPath)) is not AppConfig legacyConfig)
|
||||
return;
|
||||
|
||||
// Migrate
|
||||
var newConfig = Settings.Get<AppConfig>();
|
||||
newConfig.LastMinecraftProfilePath = legacyConfig.LastMinecraftProfilePath;
|
||||
|
||||
if (ModpackInfo.TryLoad(legacyConfig.LastMinecraftProfilePath) is ModpackInfo info)
|
||||
#pragma warning disable CS0612 // Typ oder Element ist veraltet
|
||||
info.ConfigUrl = legacyConfig.ConfigFilePath;
|
||||
|
||||
// Ensure save settings
|
||||
settingsManager.Save();
|
||||
|
||||
// Delete legacy config file
|
||||
File.Delete(settingsPath);
|
||||
InstallWithoutGui(Options.UpdateOptions, Options.Silent);
|
||||
}
|
||||
|
||||
private static void InstallWithoutGui(UpdateCheckOptionsAdv updateOptions, bool silent)
|
||||
{
|
||||
var info = ModpackInfo.TryLoad(updateOptions.ProfileFolder);
|
||||
var config = ModpackConfig.LoadFromUrl(CheckModpackConfigUrl(updateOptions.ModpackConfig, info));
|
||||
var config = ModpackConfig.LoadFromUrl(CheckModpackConfigUrl(updateOptions.ModpackConfig!, info));
|
||||
var features = new ModpackFeatures(config);
|
||||
|
||||
// Check features
|
||||
@@ -108,9 +41,6 @@ public static class Program
|
||||
};
|
||||
var result = installer.Check(updateOptions).Result;
|
||||
|
||||
if (!silent && !updateOptions.NoUpdate && new AppUpdater().Check().Result)
|
||||
Log.Info("A new version is available!");
|
||||
|
||||
if (result.HasUpdates)
|
||||
{
|
||||
var success = installer.Install(result).Result;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>..\publish\cli\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -4,8 +4,7 @@ namespace ModpackUpdater.Apps.Client;
|
||||
|
||||
public class UpdateCheckOptionsAdv : UpdateCheckOptions
|
||||
{
|
||||
public string ProfileFolder { get; set; }
|
||||
public string ModpackConfig { get; set; }
|
||||
public bool NoUpdate { get; set; }
|
||||
public string ExtrasKey { get; set; }
|
||||
public string? ProfileFolder { get; set; }
|
||||
public string? ModpackConfig { get; set; }
|
||||
public string? ExtrasKey { get; set; }
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ using Pilz;
|
||||
using Pilz.Configuration;
|
||||
using Pilz.Plugins.Advanced;
|
||||
|
||||
[assembly: AssemblyAppVersion("1.0.0.0")]
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager;
|
||||
|
||||
public static class Program
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>H:\Applications\Minecraft Modpack Manager</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -33,13 +33,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
http.Dispose();
|
||||
}
|
||||
|
||||
private async Task<UpdateInfos> DownloadUpdateInfos()
|
||||
public async Task<UpdateInfos> DownloadUpdateInfos()
|
||||
{
|
||||
var content = await http.GetStringAsync(updateConfig.GetUpdateUrl(overwriteRefTag: OverwriteRefTag));
|
||||
return UpdateInfos.Parse(content);
|
||||
}
|
||||
|
||||
private async Task<InstallInfos> DownloadInstallInfos()
|
||||
public async Task<InstallInfos> DownloadInstallInfos()
|
||||
{
|
||||
var content = await http.GetStringAsync(updateConfig.GetInstallUrl(overwriteRefTag: OverwriteRefTag));
|
||||
return InstallInfos.Parse(content);
|
||||
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32526.322
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModpackUpdater.Apps.Client", "ModpackUpdater.Apps.Client\ModpackUpdater.Apps.Client.csproj", "{81F9A2F7-D36B-0F08-12D7-9EC2606C9080}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModpackUpdater.Apps.Client.Gui", "ModpackUpdater.Apps.Client.Gui\ModpackUpdater.Apps.Client.Gui.csproj", "{81F9A2F7-D36B-0F08-12D7-9EC2606C9080}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModpackUpdater", "ModpackUpdater\ModpackUpdater.csproj", "{0E6B6470-8C1D-0CDD-3681-461297A01960}"
|
||||
EndProject
|
||||
@@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.Manager
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps", "ModpackUpdater.Apps\ModpackUpdater.Apps.csproj", "{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.Client", "ModpackUpdater.Apps.Client\ModpackUpdater.Apps.Client.csproj", "{415A7854-C358-4DCD-8C9E-D8413097A06D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.AppUpdates", "ModpackUpdater.Apps.AppUpdates\ModpackUpdater.Apps.AppUpdates.csproj", "{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -43,6 +47,14 @@ Global
|
||||
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{415A7854-C358-4DCD-8C9E-D8413097A06D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{415A7854-C358-4DCD-8C9E-D8413097A06D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{415A7854-C358-4DCD-8C9E-D8413097A06D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{415A7854-C358-4DCD-8C9E-D8413097A06D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7D8F9265-7BAC-4541-A6A8-168F45D0EA56}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -53,6 +65,8 @@ Global
|
||||
{D3A92EBD-FF6E-09D0-00A1-20221AAA198E} = {96B711FA-1AF2-469B-BC02-6D1E540E8E9D}
|
||||
{227A37AA-73F0-431D-B976-B9B3A8ADD8C2} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
|
||||
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
|
||||
{415A7854-C358-4DCD-8C9E-D8413097A06D} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
|
||||
{7D8F9265-7BAC-4541-A6A8-168F45D0EA56} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {322E6A6B-9F3E-4E88-8945-C98A9EF613BF}
|
||||
|
||||
3
Version.cs
Normal file
3
Version.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
using Pilz;
|
||||
|
||||
[assembly: AssemblyAppVersion("1.9.3.0")]
|
||||
Reference in New Issue
Block a user