install keys

This commit is contained in:
Schedel Pascal
2024-06-21 08:55:46 +02:00
parent f1185c242c
commit 20c1e5dc8e
12 changed files with 216 additions and 75 deletions

View File

@@ -56,7 +56,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
if (installInfos is not null && installInfos.Actions.Count != 0)
{
var actions = installInfos.Actions.Where(n => n.Side.IsSide(options.Side) && (!n.IsExtra || updateConfig.AllowExtras));
var actions = installInfos.Actions.Where(n => n.Side.IsSide(options.Side) && (!n.IsExtra || options.IncludeExtras));
if (actions.Any())
{
result.Actions.AddRange(installInfos.Actions);
@@ -88,7 +88,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
foreach (var action in checkingVersion.Actions)
{
if (action.Side.IsSide(options.Side) && (!action.IsExtra || updateConfig.AllowExtras) && !result.Actions.Any(n => n.DestPath == action.DestPath))
if (action.Side.IsSide(options.Side) && (!action.IsExtra || options.IncludeExtras) && !result.Actions.Any(n => n.DestPath == action.DestPath))
actionsToAdd.Add(action);
}

View File

@@ -7,4 +7,5 @@ public class UpdateCheckOptions
public bool IgnoreMaintenance { get; set; }
public bool AllowUpdaterAfterInstall { get; set; } = true;
public Side Side { get; set; } = Side.Client;
public bool IncludeExtras { get; set; }
}

View File

@@ -6,9 +6,9 @@ public class ModpackConfig
{
public bool Maintenance { get; set; }
public string Name { get; set; }
public string Key { get; set; }
public string UpdateUrl { get; set; }
public string InstallUrl { get; set; }
public bool AllowExtras { get; set; }
[JsonIgnore]
public string ConfigUrl { get; set; }

View File

@@ -11,6 +11,8 @@ public class ModpackInfo
[JsonConverter(typeof(VersionConverter))]
public Version Version { get; set; }
public string ConfigUrl { get; set; }
public string ExtrasKey { get; set; }
[JsonIgnore]
public string LocaLPath { get; private set; }
[JsonIgnore]

View File

@@ -8,15 +8,18 @@ public class AppConfig : IChildSettings, ISettingsIdentifier
public static string Identifier => "pilz.appconfig";
public string LastMinecraftProfilePath { get; set; }
public string LastConfigFilePath { get; set; }
public bool LastIncludeExtras { get; set; }
public List<string> KeepLocalFiles { get; } = [];
[JsonIgnore, Obsolete]
public string ConfigFilePath { get; private set; }
[JsonProperty("ConfigFilePath"), Obsolete]
private string ConfigFilePathLegacy
{
set => ConfigFilePath = value;
}
public void Reset()
{
LastMinecraftProfilePath = null;
LastConfigFilePath = null;
KeepLocalFiles.Clear();
}
public static AppConfig Instance => Program.Settings.Get<AppConfig>();

View File

@@ -0,0 +1,81 @@
using ModpackUpdater.Model;
using Unleash;
namespace ModpackUpdater;
public enum AppFeatures
{
AllowExtras
}
public static class AppFeaturesExtensions
{
private const string apiUrl = "https://git.pilzinsel64.de/api/v4/feature_flags/unleash/2";
private const string instanceId = "glffct-3vCzJXChAnxjsgvoHijR";
private static IUnleash api;
private static UnleashContext context;
private static UnleashSettings settings;
public static bool IsEnabled(this AppFeatures feature, AppFeatureContext context)
{
return feature switch
{
AppFeatures.AllowExtras => CheckFeature("allow-extras", false, context),
_ => throw new NotSupportedException(),
};
}
public static bool IsEnabled(this AppFeatures feature)
{
return feature switch
{
_ => throw new NotSupportedException(),
};
}
private static bool InitializeApi()
{
if (api == null)
{
settings = new UnleashSettings
{
AppName = "Modpack Updater",
UnleashApi = new Uri(apiUrl),
FetchTogglesInterval = TimeSpan.FromSeconds(60 * 5),
InstanceTag = instanceId,
};
api = new DefaultUnleash(settings);
}
return api != null;
}
private static bool CheckFeature(string name, bool defaultValue, AppFeatureContext context)
{
return InitializeApi() && api.IsEnabled(name, GetContext(context), defaultValue);
}
private static UnleashContext GetContext(AppFeatureContext ccontext)
{
context ??= new();
context.CurrentTime = DateTime.Now;
ccontext?.Apply(context);
return context;
}
}
public abstract class AppFeatureContext
{
public abstract void Apply(UnleashContext context);
}
public class AllowExtrasFeatureContext(ModpackInfo info, ModpackConfig config) : AppFeatureContext
{
public override void Apply(UnleashContext context)
{
context.UserId = info.ExtrasKey;
context.Environment = config.Key;
}
}

View File

@@ -44,9 +44,11 @@ namespace ModpackUpdater
RadButton_Install = new Telerik.WinControls.UI.RadButton();
RadButton_CheckForUpdates = new Telerik.WinControls.UI.RadButton();
RadButton_PasteModpackConfig = new Telerik.WinControls.UI.RadButton();
RadButton_SearchModpackConfig = new Telerik.WinControls.UI.RadButton();
RadButton_SearchMinecraftProfileFolder = new Telerik.WinControls.UI.RadButton();
tableLayoutPanel1 = new TableLayoutPanel();
radLabel4 = new Telerik.WinControls.UI.RadLabel();
radTextBoxControl_InstallKey = new Telerik.WinControls.UI.RadTextBoxControl();
radButton_PasteInstallKey = new Telerik.WinControls.UI.RadButton();
radButton_RefreshConfig = new Telerik.WinControls.UI.RadButton();
((System.ComponentModel.ISupportInitialize)RadLabel1).BeginInit();
((System.ComponentModel.ISupportInitialize)RadLabel2).BeginInit();
@@ -57,9 +59,11 @@ namespace ModpackUpdater
((System.ComponentModel.ISupportInitialize)RadButton_Install).BeginInit();
((System.ComponentModel.ISupportInitialize)RadButton_CheckForUpdates).BeginInit();
((System.ComponentModel.ISupportInitialize)RadButton_PasteModpackConfig).BeginInit();
((System.ComponentModel.ISupportInitialize)RadButton_SearchModpackConfig).BeginInit();
((System.ComponentModel.ISupportInitialize)RadButton_SearchMinecraftProfileFolder).BeginInit();
tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)radLabel4).BeginInit();
((System.ComponentModel.ISupportInitialize)radTextBoxControl_InstallKey).BeginInit();
((System.ComponentModel.ISupportInitialize)radButton_PasteInstallKey).BeginInit();
((System.ComponentModel.ISupportInitialize)radButton_RefreshConfig).BeginInit();
((System.ComponentModel.ISupportInitialize)this).BeginInit();
SuspendLayout();
@@ -88,7 +92,7 @@ namespace ModpackUpdater
//
RadLabel3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
RadLabel3.AutoSize = false;
RadLabel3.Location = new Point(3, 119);
RadLabel3.Location = new Point(3, 177);
RadLabel3.Name = "RadLabel3";
RadLabel3.Size = new Size(144, 22);
RadLabel3.TabIndex = 2;
@@ -99,7 +103,7 @@ namespace ModpackUpdater
RadLabel_Status.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
RadLabel_Status.AutoSize = false;
tableLayoutPanel1.SetColumnSpan(RadLabel_Status, 6);
RadLabel_Status.Location = new Point(153, 119);
RadLabel_Status.Location = new Point(153, 177);
RadLabel_Status.Name = "RadLabel_Status";
RadLabel_Status.Size = new Size(266, 22);
RadLabel_Status.TabIndex = 3;
@@ -124,7 +128,7 @@ namespace ModpackUpdater
RadTextBoxControl_ModpackConfig.IsReadOnly = true;
RadTextBoxControl_ModpackConfig.Location = new Point(153, 61);
RadTextBoxControl_ModpackConfig.Name = "RadTextBoxControl_ModpackConfig";
RadTextBoxControl_ModpackConfig.NullText = "No file loaded!";
RadTextBoxControl_ModpackConfig.NullText = "No config url provided.";
RadTextBoxControl_ModpackConfig.Size = new Size(266, 22);
RadTextBoxControl_ModpackConfig.TabIndex = 5;
//
@@ -133,7 +137,7 @@ namespace ModpackUpdater
RadButton_Install.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_Install, 2);
RadButton_Install.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_Install.Location = new Point(325, 147);
RadButton_Install.Location = new Point(325, 205);
RadButton_Install.Name = "RadButton_Install";
RadButton_Install.Size = new Size(94, 24);
RadButton_Install.TabIndex = 10;
@@ -147,7 +151,7 @@ namespace ModpackUpdater
RadButton_CheckForUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_CheckForUpdates, 3);
RadButton_CheckForUpdates.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_CheckForUpdates.Location = new Point(175, 147);
RadButton_CheckForUpdates.Location = new Point(175, 205);
RadButton_CheckForUpdates.Name = "RadButton_CheckForUpdates";
RadButton_CheckForUpdates.Size = new Size(144, 24);
RadButton_CheckForUpdates.TabIndex = 0;
@@ -161,7 +165,7 @@ namespace ModpackUpdater
RadButton_PasteModpackConfig.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_PasteModpackConfig, 2);
RadButton_PasteModpackConfig.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_PasteModpackConfig.Location = new Point(225, 89);
RadButton_PasteModpackConfig.Location = new Point(325, 89);
RadButton_PasteModpackConfig.Name = "RadButton_PasteModpackConfig";
RadButton_PasteModpackConfig.Size = new Size(94, 24);
RadButton_PasteModpackConfig.TabIndex = 7;
@@ -170,20 +174,6 @@ namespace ModpackUpdater
RadButton_PasteModpackConfig.TextImageRelation = TextImageRelation.ImageBeforeText;
RadButton_PasteModpackConfig.Click += RadButton_PasteModpackConfig_Click;
//
// RadButton_SearchModpackConfig
//
RadButton_SearchModpackConfig.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(RadButton_SearchModpackConfig, 2);
RadButton_SearchModpackConfig.ImageAlignment = ContentAlignment.MiddleRight;
RadButton_SearchModpackConfig.Location = new Point(325, 89);
RadButton_SearchModpackConfig.Name = "RadButton_SearchModpackConfig";
RadButton_SearchModpackConfig.Size = new Size(94, 24);
RadButton_SearchModpackConfig.TabIndex = 7;
RadButton_SearchModpackConfig.Text = "Search";
RadButton_SearchModpackConfig.TextAlignment = ContentAlignment.MiddleLeft;
RadButton_SearchModpackConfig.TextImageRelation = TextImageRelation.ImageBeforeText;
RadButton_SearchModpackConfig.Click += ButtonX_SearchUpdateConfig_Click;
//
// RadButton_SearchMinecraftProfileFolder
//
RadButton_SearchMinecraftProfileFolder.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -208,37 +198,76 @@ namespace ModpackUpdater
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 50F));
tableLayoutPanel1.Controls.Add(RadButton_CheckForUpdates, 2, 5);
tableLayoutPanel1.Controls.Add(RadButton_CheckForUpdates, 2, 7);
tableLayoutPanel1.Controls.Add(RadLabel1, 0, 0);
tableLayoutPanel1.Controls.Add(RadLabel2, 0, 2);
tableLayoutPanel1.Controls.Add(RadTextBoxControl_MinecraftProfileFolder, 1, 0);
tableLayoutPanel1.Controls.Add(RadTextBoxControl_ModpackConfig, 1, 2);
tableLayoutPanel1.Controls.Add(RadLabel_Status, 1, 4);
tableLayoutPanel1.Controls.Add(RadLabel3, 0, 4);
tableLayoutPanel1.Controls.Add(RadLabel_Status, 1, 6);
tableLayoutPanel1.Controls.Add(RadLabel3, 0, 6);
tableLayoutPanel1.Controls.Add(RadButton_SearchMinecraftProfileFolder, 5, 1);
tableLayoutPanel1.Controls.Add(RadButton_SearchModpackConfig, 5, 3);
tableLayoutPanel1.Controls.Add(RadButton_PasteModpackConfig, 3, 3);
tableLayoutPanel1.Controls.Add(RadButton_Install, 5, 5);
tableLayoutPanel1.Controls.Add(radButton_RefreshConfig, 2, 3);
tableLayoutPanel1.Controls.Add(RadButton_Install, 5, 7);
tableLayoutPanel1.Controls.Add(radLabel4, 0, 4);
tableLayoutPanel1.Controls.Add(radTextBoxControl_InstallKey, 1, 4);
tableLayoutPanel1.Controls.Add(radButton_PasteInstallKey, 5, 5);
tableLayoutPanel1.Controls.Add(RadButton_PasteModpackConfig, 5, 3);
tableLayoutPanel1.Controls.Add(radButton_RefreshConfig, 4, 3);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 6;
tableLayoutPanel1.RowCount = 8;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Size = new Size(422, 174);
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Size = new Size(422, 232);
tableLayoutPanel1.TabIndex = 7;
//
// radLabel4
//
radLabel4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
radLabel4.AutoSize = false;
radLabel4.Location = new Point(3, 119);
radLabel4.Name = "radLabel4";
radLabel4.Size = new Size(144, 22);
radLabel4.TabIndex = 12;
radLabel4.Text = "Installation key:";
//
// radTextBoxControl_InstallKey
//
radTextBoxControl_InstallKey.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(radTextBoxControl_InstallKey, 6);
radTextBoxControl_InstallKey.IsReadOnly = true;
radTextBoxControl_InstallKey.Location = new Point(153, 119);
radTextBoxControl_InstallKey.Name = "radTextBoxControl_InstallKey";
radTextBoxControl_InstallKey.NullText = "No key provided. Only for private servers.";
radTextBoxControl_InstallKey.Size = new Size(266, 22);
radTextBoxControl_InstallKey.TabIndex = 13;
//
// radButton_PasteInstallKey
//
radButton_PasteInstallKey.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.SetColumnSpan(radButton_PasteInstallKey, 2);
radButton_PasteInstallKey.ImageAlignment = ContentAlignment.MiddleRight;
radButton_PasteInstallKey.Location = new Point(325, 147);
radButton_PasteInstallKey.Name = "radButton_PasteInstallKey";
radButton_PasteInstallKey.Size = new Size(94, 24);
radButton_PasteInstallKey.TabIndex = 14;
radButton_PasteInstallKey.Text = "Paste";
radButton_PasteInstallKey.TextAlignment = ContentAlignment.MiddleLeft;
radButton_PasteInstallKey.TextImageRelation = TextImageRelation.ImageBeforeText;
radButton_PasteInstallKey.Click += RadButton_PasteInstallKey_Click;
//
// radButton_RefreshConfig
//
radButton_RefreshConfig.Anchor = AnchorStyles.Top | AnchorStyles.Right;
radButton_RefreshConfig.DisplayStyle = Telerik.WinControls.DisplayStyle.Image;
radButton_RefreshConfig.ImageAlignment = ContentAlignment.MiddleCenter;
radButton_RefreshConfig.Location = new Point(195, 89);
radButton_RefreshConfig.Location = new Point(295, 89);
radButton_RefreshConfig.Name = "radButton_RefreshConfig";
radButton_RefreshConfig.Size = new Size(24, 24);
radButton_RefreshConfig.TabIndex = 11;
@@ -250,7 +279,7 @@ namespace ModpackUpdater
AutoScaleBaseSize = new Size(7, 15);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(422, 174);
ClientSize = new Size(422, 232);
Controls.Add(tableLayoutPanel1);
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
@@ -269,9 +298,11 @@ namespace ModpackUpdater
((System.ComponentModel.ISupportInitialize)RadButton_Install).EndInit();
((System.ComponentModel.ISupportInitialize)RadButton_CheckForUpdates).EndInit();
((System.ComponentModel.ISupportInitialize)RadButton_PasteModpackConfig).EndInit();
((System.ComponentModel.ISupportInitialize)RadButton_SearchModpackConfig).EndInit();
((System.ComponentModel.ISupportInitialize)RadButton_SearchMinecraftProfileFolder).EndInit();
tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)radLabel4).EndInit();
((System.ComponentModel.ISupportInitialize)radTextBoxControl_InstallKey).EndInit();
((System.ComponentModel.ISupportInitialize)radButton_PasteInstallKey).EndInit();
((System.ComponentModel.ISupportInitialize)radButton_RefreshConfig).EndInit();
((System.ComponentModel.ISupportInitialize)this).EndInit();
ResumeLayout(false);
@@ -285,10 +316,12 @@ namespace ModpackUpdater
internal Telerik.WinControls.UI.RadTextBoxControl RadTextBoxControl_ModpackConfig;
internal Telerik.WinControls.UI.RadButton RadButton_Install;
internal Telerik.WinControls.UI.RadButton RadButton_CheckForUpdates;
internal Telerik.WinControls.UI.RadButton RadButton_SearchModpackConfig;
internal Telerik.WinControls.UI.RadButton RadButton_SearchMinecraftProfileFolder;
internal Telerik.WinControls.UI.RadButton RadButton_PasteModpackConfig;
private TableLayoutPanel tableLayoutPanel1;
private Telerik.WinControls.UI.RadButton radButton_RefreshConfig;
internal Telerik.WinControls.UI.RadLabel radLabel4;
internal Telerik.WinControls.UI.RadTextBoxControl radTextBoxControl_InstallKey;
internal Telerik.WinControls.UI.RadButton radButton_PasteInstallKey;
}
}

View File

@@ -20,9 +20,6 @@ public partial class Form1
{
this.updateOptions = updateOptions;
if (!string.IsNullOrWhiteSpace(updateOptions.ModpackConfig))
LoadUpdateConfigFile(updateOptions.ModpackConfig);
if (!string.IsNullOrWhiteSpace(updateOptions.ProfileFolder))
LoadMinecraftProfile(updateOptions.ProfileFolder);
}
@@ -37,7 +34,7 @@ public partial class Form1
RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small);
radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SvgImageSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
RadButton_SearchModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
radButton_PasteInstallKey.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small);
}
@@ -102,6 +99,7 @@ public partial class Form1
try
{
modpackInfo = ModpackInfo.TryLoad(folderPath);
radTextBoxControl_InstallKey.Text = modpackInfo.ExtrasKey;
}
catch
{
@@ -110,7 +108,7 @@ public partial class Form1
if (string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text) && !string.IsNullOrWhiteSpace(modpackInfo?.ConfigUrl))
LoadUpdateConfigFile(modpackInfo.ConfigUrl);
else
else if (IsUpdateConfigLoaded())
RadButton_CheckForUpdates.PerformClick();
}
else
@@ -119,24 +117,31 @@ public partial class Form1
private void LoadUpdateConfigFile(string filePath)
{
static ModpackConfig loadConfig(string filePath)
{
try
{
return ModpackConfig.LoadFromUrl(filePath);
}
catch (Exception)
{
}
return null;
}
RadTextBoxControl_ModpackConfig.Text = filePath;
try
if (!string.IsNullOrWhiteSpace(filePath) && loadConfig(filePath) is ModpackConfig modpackConfig)
{
if (IsUpdateConfigLoaded())
updateConfig = ModpackConfig.LoadFromUrl(filePath);
if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small));
else
RadButton_CheckForUpdates.PerformClick();
}
catch
{
RadTextBoxControl_ModpackConfig.Text = string.Empty;
}
if (updateConfig != null && updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small));
else if (IsMinecaftProfileLoaded())
RadButton_CheckForUpdates.PerformClick();
else
{
ClearStatus();
}
}
private async Task ExecuteUpdate(bool doInstall)
@@ -150,6 +155,10 @@ public partial class Form1
{
SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small));
// Check for extras once again
modpackInfo.ExtrasKey = radTextBoxControl_InstallKey.Text.Trim();
updateOptions.IncludeExtras = AppFeatures.AllowExtras.IsEnabled(new AllowExtrasFeatureContext(modpackInfo, updateConfig));
try
{
lastUpdateCheckResult = await updater.Check(updateOptions);
@@ -214,26 +223,24 @@ public partial class Form1
private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e)
{
var ofd = new RadOpenFolderDialog();
if (ofd.ShowDialog(this) == DialogResult.OK)
LoadMinecraftProfile(ofd.FileName);
}
private void ButtonX_SearchUpdateConfig_Click(object sender, EventArgs e)
{
var ofd = new RadOpenFileDialog() { Filter = FiledialogFilters.JSON_Display + "|" + FiledialogFilters.JSON_Filter };
if (ofd.ShowDialog(this) == DialogResult.OK)
LoadUpdateConfigFile(ofd.FileName);
}
private void RadButton_PasteModpackConfig_Click(object sender, EventArgs e)
{
string text = Clipboard.GetText();
var text = Clipboard.GetText();
if (text.StartsWith("http"))
LoadUpdateConfigFile(text);
}
private void RadButton_PasteInstallKey_Click(object sender, EventArgs e)
{
if (modpackInfo == null)
return;
radTextBoxControl_InstallKey.Text = modpackInfo.ExtrasKey = Clipboard.GetText();
}
private void RadButton_RefreshConfig_Click(object sender, EventArgs e)
{
LoadUpdateConfigFile(RadTextBoxControl_ModpackConfig.Text);
@@ -259,15 +266,12 @@ public partial class Form1
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
AppConfig.Instance.LastMinecraftProfilePath = RadTextBoxControl_MinecraftProfileFolder.Text;
AppConfig.Instance.LastConfigFilePath = RadTextBoxControl_ModpackConfig.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
if (Directory.Exists(AppConfig.Instance.LastMinecraftProfilePath))
LoadMinecraftProfile(AppConfig.Instance.LastMinecraftProfilePath);
if (!string.IsNullOrWhiteSpace(AppConfig.Instance.LastConfigFilePath))
LoadUpdateConfigFile(AppConfig.Instance.LastConfigFilePath);
}
private async void Form1_Shown(object sender, EventArgs e)

View File

@@ -54,6 +54,7 @@
<PackageReference Include="Pilz.UI.Telerik.SymbolFactory" Version="2.0.3" />
<PackageReference Include="Pilz.Win32" Version="2.0.0" />
<PackageReference Include="UI.for.WinForms.Common" Version="2024.2.514" />
<PackageReference Include="Unleash.Client" Version="4.1.9" />
</ItemGroup>
<ItemGroup>

View File

@@ -21,9 +21,10 @@ internal class Options
{ "p|profile=", "Sets the minecraft profile folder.", p => UpdateOptions.ProfileFolder = p },
{ "c|config=", "Sets the minecraft profile folder.", c => UpdateOptions.ModpackConfig = c },
{ "s|side=", "Sets the minecraft profile folder.\nDefault side is Client.\nAvailable: Client, Server", s => UpdateOptions.Side = Enum.Parse<Side>(s)},
{ "uai", "Allow an update directly after install. This only has affect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = uai != null},
{ "u|uai", "Allow an update directly after install. This only has affect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = uai != null},
{ "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = noupdate != null},
{ "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = m != null},
{ "k|key=", "An key for retriving extra files on updates.", k => UpdateOptions.ExtrasKey = k},
};
additionals.AddRange(options.Parse(args));

View File

@@ -62,7 +62,13 @@ public static class Program
// Migrate
var newConfig = Settings.Get<AppConfig>();
newConfig.LastMinecraftProfilePath = legacyConfig.LastMinecraftProfilePath;
newConfig.LastConfigFilePath = legacyConfig.LastConfigFilePath;
if (ModpackInfo.TryLoad(legacyConfig.LastMinecraftProfilePath) is ModpackInfo info)
{
#pragma warning disable CS0612 // Typ oder Element ist veraltet
info.ConfigUrl = legacyConfig.ConfigFilePath;
#pragma warning restore CS0612 // Typ oder Element ist veraltet
}
// Ensure save settings
settingsManager.Save();
@@ -75,6 +81,14 @@ public static class Program
{
var info = ModpackInfo.TryLoad(updateOptions.ProfileFolder);
var config = ModpackConfig.LoadFromUrl(CheckModpackConfigUrl(updateOptions.ModpackConfig, info));
// Check features
if (!string.IsNullOrWhiteSpace(updateOptions.ExtrasKey))
info.ExtrasKey = updateOptions.ExtrasKey;
if (!string.IsNullOrWhiteSpace(info.ExtrasKey))
updateOptions.IncludeExtras = AppFeatures.AllowExtras.IsEnabled(new AllowExtrasFeatureContext(info, config));
// Check for update
var installer = new ModpackInstaller(config, info);
var result = installer.Check(updateOptions).Result;

View File

@@ -7,4 +7,5 @@ public class UpdateCheckOptionsAdv : UpdateCheckOptions
public string ProfileFolder { get; set; }
public string ModpackConfig { get; set; }
public bool NoUpdate { get; set; }
public string ExtrasKey { get; set; }
}