From 3be25d7070784f6546e0567d9be8215a273dc850 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 20 Jun 2024 22:34:38 +0200 Subject: [PATCH] include extras --- ModpackUpdater.Manager/ModpackInstaller.cs | 8 +++-- ModpackUpdater.Manager/UpdateCheckResult.cs | 1 + ModpackUpdater.Model/ModpackInfo.cs | 1 + ModpackUpdater/AppConfig.cs | 1 + ModpackUpdater/Form1.Designer.cs | 34 ++++++++++----------- ModpackUpdater/Form1.cs | 8 +++++ 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 0c2f3f4..a7f0a52 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -39,10 +39,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf public async Task Check(UpdateCheckOptions options) { - var result = new UpdateCheckResult(); - var hasConfig = modpackInfo.Exists; InstallInfos installInfos = null; UpdateInfos updateInfos = null; + var hasConfig = modpackInfo.Exists; + var result = new UpdateCheckResult + { + HasExtras = options.IncludeExtraActions + }; if (updateConfig.Maintenance && !options.IgnoreMaintenance) { @@ -174,6 +177,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf // Save new modpack info modpackInfo.Version = checkResult.LatestVersion; modpackInfo.ConfigUrl = updateConfig.ConfigUrl; + modpackInfo.IncludeExtras = checkResult.HasExtras; modpackInfo.Save(); // Delete cached zip files diff --git a/ModpackUpdater.Manager/UpdateCheckResult.cs b/ModpackUpdater.Manager/UpdateCheckResult.cs index 658f208..49f1b62 100644 --- a/ModpackUpdater.Manager/UpdateCheckResult.cs +++ b/ModpackUpdater.Manager/UpdateCheckResult.cs @@ -11,4 +11,5 @@ public class UpdateCheckResult public bool HasError { get; set; } public bool IsInMaintenance { get; set; } public bool HasUpdates => !IsInstalled || CurrentVersion < LatestVersion; + public bool HasExtras { get; set; } } \ No newline at end of file diff --git a/ModpackUpdater.Model/ModpackInfo.cs b/ModpackUpdater.Model/ModpackInfo.cs index 5ca74b1..eb09a51 100644 --- a/ModpackUpdater.Model/ModpackInfo.cs +++ b/ModpackUpdater.Model/ModpackInfo.cs @@ -11,6 +11,7 @@ public class ModpackInfo [JsonConverter(typeof(VersionConverter))] public Version Version { get; set; } public string ConfigUrl { get; set; } + public bool IncludeExtras { get; set; } [JsonIgnore] public string LocaLPath { get; private set; } [JsonIgnore] diff --git a/ModpackUpdater/AppConfig.cs b/ModpackUpdater/AppConfig.cs index d4d578f..70f7c72 100644 --- a/ModpackUpdater/AppConfig.cs +++ b/ModpackUpdater/AppConfig.cs @@ -9,6 +9,7 @@ public class AppConfig : IChildSettings, ISettingsIdentifier public string LastMinecraftProfilePath { get; set; } public string LastConfigFilePath { get; set; } + public bool LastIncludeExtras { get; set; } public List KeepLocalFiles { get; } = []; public void Reset() diff --git a/ModpackUpdater/Form1.Designer.cs b/ModpackUpdater/Form1.Designer.cs index 11979be..552dea5 100644 --- a/ModpackUpdater/Form1.Designer.cs +++ b/ModpackUpdater/Form1.Designer.cs @@ -43,12 +43,12 @@ namespace ModpackUpdater RadTextBoxControl_ModpackConfig = new Telerik.WinControls.UI.RadTextBoxControl(); RadButton_Install = new Telerik.WinControls.UI.RadButton(); RadButton_CheckForUpdates = new Telerik.WinControls.UI.RadButton(); - RadButton_EditModpackConfig = 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(); radButton_RefreshConfig = new Telerik.WinControls.UI.RadButton(); + radCheckBox_IncludeExtras = new Telerik.WinControls.UI.RadCheckBox(); ((System.ComponentModel.ISupportInitialize)RadLabel1).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadLabel2).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadLabel3).BeginInit(); @@ -57,12 +57,12 @@ namespace ModpackUpdater ((System.ComponentModel.ISupportInitialize)RadTextBoxControl_ModpackConfig).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadButton_Install).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadButton_CheckForUpdates).BeginInit(); - ((System.ComponentModel.ISupportInitialize)RadButton_EditModpackConfig).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadButton_PasteModpackConfig).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadButton_SearchModpackConfig).BeginInit(); ((System.ComponentModel.ISupportInitialize)RadButton_SearchMinecraftProfileFolder).BeginInit(); tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)radButton_RefreshConfig).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radCheckBox_IncludeExtras).BeginInit(); ((System.ComponentModel.ISupportInitialize)this).BeginInit(); SuspendLayout(); // @@ -158,19 +158,6 @@ namespace ModpackUpdater RadButton_CheckForUpdates.TextImageRelation = TextImageRelation.ImageBeforeText; RadButton_CheckForUpdates.Click += ButtonX_CheckForUpdates_Click; // - // RadButton_EditModpackConfig - // - RadButton_EditModpackConfig.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - RadButton_EditModpackConfig.ImageAlignment = ContentAlignment.MiddleRight; - RadButton_EditModpackConfig.Location = new Point(3, 147); - RadButton_EditModpackConfig.Name = "RadButton_EditModpackConfig"; - RadButton_EditModpackConfig.Size = new Size(144, 24); - RadButton_EditModpackConfig.TabIndex = 8; - RadButton_EditModpackConfig.Text = "Edit modpack config"; - RadButton_EditModpackConfig.TextAlignment = ContentAlignment.MiddleLeft; - RadButton_EditModpackConfig.TextImageRelation = TextImageRelation.ImageBeforeText; - RadButton_EditModpackConfig.Visible = false; - // // RadButton_PasteModpackConfig // RadButton_PasteModpackConfig.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; @@ -226,7 +213,6 @@ namespace ModpackUpdater tableLayoutPanel1.Controls.Add(RadButton_CheckForUpdates, 2, 5); tableLayoutPanel1.Controls.Add(RadLabel1, 0, 0); tableLayoutPanel1.Controls.Add(RadLabel2, 0, 2); - tableLayoutPanel1.Controls.Add(RadButton_EditModpackConfig, 0, 5); tableLayoutPanel1.Controls.Add(RadTextBoxControl_MinecraftProfileFolder, 1, 0); tableLayoutPanel1.Controls.Add(RadTextBoxControl_ModpackConfig, 1, 2); tableLayoutPanel1.Controls.Add(RadLabel_Status, 1, 4); @@ -236,6 +222,7 @@ namespace ModpackUpdater tableLayoutPanel1.Controls.Add(RadButton_PasteModpackConfig, 3, 3); tableLayoutPanel1.Controls.Add(RadButton_Install, 5, 5); tableLayoutPanel1.Controls.Add(radButton_RefreshConfig, 2, 3); + tableLayoutPanel1.Controls.Add(radCheckBox_IncludeExtras, 0, 5); tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.Location = new Point(0, 0); tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -261,6 +248,17 @@ namespace ModpackUpdater radButton_RefreshConfig.Text = "Reload"; radButton_RefreshConfig.Click += RadButton_RefreshConfig_Click; // + // radCheckBox_IncludeExtras + // + radCheckBox_IncludeExtras.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + radCheckBox_IncludeExtras.AutoSize = false; + radCheckBox_IncludeExtras.Location = new Point(3, 147); + radCheckBox_IncludeExtras.Name = "radCheckBox_IncludeExtras"; + radCheckBox_IncludeExtras.Size = new Size(144, 24); + radCheckBox_IncludeExtras.TabIndex = 12; + radCheckBox_IncludeExtras.Text = "Include extra files"; + radCheckBox_IncludeExtras.ToggleStateChanged += RadCheckBox_IncludeExtras_ToggleStateChanged; + // // Form1 // AutoScaleBaseSize = new Size(7, 15); @@ -284,12 +282,12 @@ namespace ModpackUpdater ((System.ComponentModel.ISupportInitialize)RadTextBoxControl_ModpackConfig).EndInit(); ((System.ComponentModel.ISupportInitialize)RadButton_Install).EndInit(); ((System.ComponentModel.ISupportInitialize)RadButton_CheckForUpdates).EndInit(); - ((System.ComponentModel.ISupportInitialize)RadButton_EditModpackConfig).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)radButton_RefreshConfig).EndInit(); + ((System.ComponentModel.ISupportInitialize)radCheckBox_IncludeExtras).EndInit(); ((System.ComponentModel.ISupportInitialize)this).EndInit(); ResumeLayout(false); } @@ -302,11 +300,11 @@ 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_EditModpackConfig; 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; + private Telerik.WinControls.UI.RadCheckBox radCheckBox_IncludeExtras; } } \ No newline at end of file diff --git a/ModpackUpdater/Form1.cs b/ModpackUpdater/Form1.cs index e3edda5..c772d0d 100644 --- a/ModpackUpdater/Form1.cs +++ b/ModpackUpdater/Form1.cs @@ -113,6 +113,7 @@ public partial class Form1 LoadUpdateConfigFile(modpackInfo.ConfigUrl); else RadButton_CheckForUpdates.PerformClick(); + radCheckBox_IncludeExtras.Checked = modpackInfo.IncludeExtras; } else ClearStatus(); @@ -261,10 +262,12 @@ public partial class Form1 { AppConfig.Instance.LastMinecraftProfilePath = RadTextBoxControl_MinecraftProfileFolder.Text; AppConfig.Instance.LastConfigFilePath = RadTextBoxControl_ModpackConfig.Text; + AppConfig.Instance.LastIncludeExtras = radCheckBox_IncludeExtras.Checked; } private void Form1_Load(object sender, EventArgs e) { + radCheckBox_IncludeExtras.Checked = updateOptions.IncludeExtraActions || AppConfig.Instance.LastIncludeExtras; if (Directory.Exists(AppConfig.Instance.LastMinecraftProfilePath)) LoadMinecraftProfile(AppConfig.Instance.LastMinecraftProfilePath); if (!string.IsNullOrWhiteSpace(AppConfig.Instance.LastConfigFilePath)) @@ -282,4 +285,9 @@ public partial class Form1 Application.Restart(); } } + + private void RadCheckBox_IncludeExtras_ToggleStateChanged(object sender, StateChangedEventArgs args) + { + updateOptions.IncludeExtraActions = radCheckBox_IncludeExtras.Checked; + } } \ No newline at end of file