add side
This commit is contained in:
@@ -37,7 +37,12 @@ public class ModpackInstaller(ModpackConfig updateConfig, string localPath)
|
||||
return InstallInfos.Parse(content);
|
||||
}
|
||||
|
||||
public async Task<UpdateCheckResult> Check(bool allowUpdaterAfterInstall = true)
|
||||
public Task<UpdateCheckResult> Check()
|
||||
{
|
||||
return Check(Side.Client, true);
|
||||
}
|
||||
|
||||
public async Task<UpdateCheckResult> Check(Side side, bool allowUpdaterAfterInstall)
|
||||
{
|
||||
var result = new UpdateCheckResult();
|
||||
var hasConfig = ModpackInfo.HasModpackInfo(localPath);
|
||||
|
||||
@@ -6,4 +6,5 @@ public class InstallAction
|
||||
public string ZipPath { get; set; }
|
||||
public string DestPath { get; set; }
|
||||
public string DownloadUrl { get; set; }
|
||||
public Side Side { get; set; } = Side.Both;
|
||||
}
|
||||
12
ModpackUpdater.Model/Side.cs
Normal file
12
ModpackUpdater.Model/Side.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace ModpackUpdater.Model;
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter)), Flags]
|
||||
public enum Side
|
||||
{
|
||||
Client = 1,
|
||||
Server = 2,
|
||||
Both = Client | Server,
|
||||
}
|
||||
@@ -12,9 +12,15 @@ public partial class Form1
|
||||
private ModpackConfig updateConfig = new();
|
||||
private bool currentUpdating = false;
|
||||
private UpdateCheckResult lastUpdateCheckResult = null;
|
||||
private readonly bool allowUpdateCheck;
|
||||
private readonly bool allowUpdaterAfterInstall;
|
||||
private readonly Side side;
|
||||
|
||||
public Form1(string modpackConfig, string profilePath) : this()
|
||||
public Form1(string modpackConfig, string profilePath, Side side, bool allowUpdaterAfterInstall, bool allowUpdateCheck) : this()
|
||||
{
|
||||
this.allowUpdaterAfterInstall = allowUpdaterAfterInstall;
|
||||
this.side = side;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(modpackConfig))
|
||||
LoadUpdateConfigFile(modpackConfig);
|
||||
|
||||
@@ -123,7 +129,7 @@ public partial class Form1
|
||||
|
||||
try
|
||||
{
|
||||
lastUpdateCheckResult = await updater.Check();
|
||||
lastUpdateCheckResult = await updater.Check(side, allowUpdaterAfterInstall);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -239,7 +245,7 @@ public partial class Form1
|
||||
private async void Form1_Shown(object sender, EventArgs e)
|
||||
{
|
||||
var updater = new AppUpdater();
|
||||
if (await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info) == DialogResult.Yes)
|
||||
if (allowUpdateCheck && await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info) == DialogResult.Yes)
|
||||
{
|
||||
SetStatus(LangRes.StatusText_InstallingAppUpdate, MySymbols.icons8_software_installer_16px);
|
||||
Enabled = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Mono.Options;
|
||||
using ModpackUpdater.Model;
|
||||
using Mono.Options;
|
||||
|
||||
namespace ModpackUpdater;
|
||||
|
||||
@@ -9,6 +10,9 @@ internal class Options
|
||||
public IReadOnlyList<string> Additionals => additionals;
|
||||
public bool Silent { get; private set; }
|
||||
public bool NoUi { get; private set; }
|
||||
public bool NoUpdate { get; private set; };
|
||||
public bool AllowUpdaterAfterInstall { get; private set; } = true;
|
||||
public Side Side { get; private set; } = Side.Client;
|
||||
public string ProfileFolder { get; private set; }
|
||||
public string ModpackConfig { get; private set; }
|
||||
|
||||
@@ -16,10 +20,13 @@ internal class Options
|
||||
{
|
||||
var options = new OptionSet
|
||||
{
|
||||
{ "s|silent", "Do not output anything.", s => Silent = s != null },
|
||||
{ "silent", "Do not output anything.", s => Silent = s != null },
|
||||
{ "n|noui", "Install without user interface.", n => NoUi = n != null },
|
||||
{ "p|profile=", "Sets the minecraft profile folder.", p => ProfileFolder = p },
|
||||
{ "c|config=", "Sets the minecraft profile folder.", c => ModpackConfig = c },
|
||||
{ "s|side=", "Sets the minecraft profile folder.\nDefault side is Client.\nAvailable: Client, Server", s => Side = Enum.Parse<Side>(s)},
|
||||
{ "uai", "Allow an update directly after install. This only has affect if there is no existing installation.", uai => AllowUpdaterAfterInstall = uai != null},
|
||||
{ "noupdate", "Skip the update check wich happens when opening the user interface.", noupdate => NoUpdate = noupdate != null},
|
||||
};
|
||||
|
||||
var additional = options.Parse(args);
|
||||
|
||||
@@ -24,12 +24,12 @@ public static class Program
|
||||
{
|
||||
var options = new Options(args);
|
||||
if (options.NoUi)
|
||||
InstallWithoutGui(options.ModpackConfig, options.ProfileFolder, options.Silent);
|
||||
InstallWithoutGui(options.ModpackConfig, options.ProfileFolder, options.Silent, options.Side, options.AllowUpdaterAfterInstall);
|
||||
else
|
||||
RunApp(options.ModpackConfig, options.ProfileFolder);
|
||||
RunApp(options.ModpackConfig, options.ProfileFolder, options.Side, options.AllowUpdaterAfterInstall, !options.NoUpdate);
|
||||
}
|
||||
|
||||
private static void RunApp(string modpackConfig, string profileFolder)
|
||||
private static void RunApp(string modpackConfig, string profileFolder, Side side, bool allowUpdaterAfterInstall, bool allowUpdateCheck)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
@@ -38,7 +38,7 @@ public static class Program
|
||||
if (ThemeResolutionService.LoadPackageResource("ModpackUpdater.CustomThemes.Office2019DarkBluePurple.tssp"))
|
||||
ThemeResolutionService.ApplicationThemeName = "Office2019DarkBluePurple";
|
||||
|
||||
Application.Run(new Form1(modpackConfig, profileFolder));
|
||||
Application.Run(new Form1(modpackConfig, profileFolder, side, allowUpdaterAfterInstall, allowUpdateCheck));
|
||||
}
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 2)
|
||||
@@ -72,11 +72,11 @@ public static class Program
|
||||
File.Delete(settingsPath);
|
||||
}
|
||||
|
||||
private static void InstallWithoutGui(string modpackConfig, string profileFolder, bool silent)
|
||||
private static void InstallWithoutGui(string modpackConfig, string profileFolder, bool silent, Side side, bool allowUpdaterAfterInstall)
|
||||
{
|
||||
var config = ModpackConfig.LoadFromUrl(modpackConfig);
|
||||
var installer = new ModpackInstaller(config, profileFolder);
|
||||
var result = installer.Check().Result;
|
||||
var result = installer.Check(side, allowUpdaterAfterInstall).Result;
|
||||
|
||||
if (result.HasUpdates)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user