diff --git a/ModpackUpdater.Apps.Manager/Extensions.cs b/ModpackUpdater.Apps.Manager/Extensions.cs new file mode 100644 index 0000000..78f142a --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Extensions.cs @@ -0,0 +1,11 @@ +namespace ModpackUpdater.Apps.Manager; + +internal static class Extensions +{ + public static string? Nullify(this string? @this) + { + if (string.IsNullOrEmpty(@this)) + return null; + return @this; + } +} diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs index b76f3ec..5f67f54 100644 --- a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs +++ b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs @@ -7,6 +7,9 @@ namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspace { + private string? rawInstallInfos = null; + private string? rawUpdateInfos = null; + public WorkspaceConfig Config => ConfigX; public GitLabRepoWorkspaceConfig ConfigX { get; } = config; @@ -19,19 +22,38 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac public async Task Load() { - InstallInfos = InstallInfos.Parse(await GetContent(ConfigX.FileLocationInstallJson)); - UpdateInfos = UpdateInfos.Parse(await GetContent(ConfigX.FileLocationUpdateJson)); + rawInstallInfos = await GetContent(ConfigX.FileLocationInstallJson); + InstallInfos = InstallInfos.Parse(rawInstallInfos); + + rawUpdateInfos = await GetContent(ConfigX.FileLocationUpdateJson); + UpdateInfos = UpdateInfos.Parse(rawUpdateInfos); + ConfigX.RepoName = (await Gitlab.Projects.GetByIdAsync((int)ConfigX.RepoId, new())).Name; + return InstallInfos != null && UpdateInfos != null; } public async Task Save() { if (InstallInfos != null) - await SaveContent(ConfigX.FileLocationInstallJson, InstallInfos.ToString()); + { + var newInstallInfos = InstallInfos.ToString(); + if (newInstallInfos != rawInstallInfos) + { + await SaveContent(ConfigX.FileLocationInstallJson, newInstallInfos); + rawInstallInfos = newInstallInfos; + } + } if (UpdateInfos != null) - await SaveContent(ConfigX.FileLocationUpdateJson, UpdateInfos.ToString()); + { + var newUpdateInfos = UpdateInfos.ToString(); + if (newUpdateInfos != rawUpdateInfos) + { + await SaveContent(ConfigX.FileLocationUpdateJson, newUpdateInfos); + rawUpdateInfos = newUpdateInfos; + } + } return true; } diff --git a/ModpackUpdater.Apps.Manager/Form1.Designer.cs b/ModpackUpdater.Apps.Manager/Form1.Designer.cs index 7fcbf59..ed934db 100644 --- a/ModpackUpdater.Apps.Manager/Form1.Designer.cs +++ b/ModpackUpdater.Apps.Manager/Form1.Designer.cs @@ -169,6 +169,7 @@ partial class Form1 radGridView_Actions.Size = new Size(590, 416); radGridView_Actions.TabIndex = 0; radGridView_Actions.CellFormatting += RadGridView_Actions_CellFormatting; + radGridView_Actions.CellValueChanged += RadGridView_Actions_CellValueChanged; // // radMenuItem_Workspace // diff --git a/ModpackUpdater.Apps.Manager/Form1.cs b/ModpackUpdater.Apps.Manager/Form1.cs index 3b6d685..5353cef 100644 --- a/ModpackUpdater.Apps.Manager/Form1.cs +++ b/ModpackUpdater.Apps.Manager/Form1.cs @@ -6,6 +6,7 @@ using ModpackUpdater.Apps.Manager.Settings; using Pilz.Plugins.Advanced; using Pilz.Plugins.Advanced.UI.Telerik; using Pilz.UI.Symbols; +using Pilz.UI.Telerik.Extensions; using Telerik.WinControls; using Telerik.WinControls.UI; @@ -138,11 +139,20 @@ public partial class Form1 : RadForm, IMainApi // Add columns radGridView_Actions.Columns.AddRange([ + new GridViewTextBoxColumn + { + Name = "id", + HeaderText = ActionsListLangRes.Col_Id, + Width = 150, + IsVisible = infos is not UpdateInfo, + IsPinned = true, + }, new GridViewTextBoxColumn { Name = "name", HeaderText = ActionsListLangRes.Col_Name, Width = 150, + IsVisible = infos is not UpdateInfo, }, new GridViewTextBoxColumn { @@ -150,6 +160,7 @@ public partial class Form1 : RadForm, IMainApi HeaderText = ActionsListLangRes.Col_InheritFrom, Width = 150, IsVisible = infos is UpdateInfo, + IsPinned = true, }, new GridViewComboBoxColumn { @@ -159,6 +170,19 @@ public partial class Form1 : RadForm, IMainApi DataSource = Enum.GetValues(), IsVisible = infos is UpdateInfo, }, + new GridViewComboBoxColumn + { + Name = "side", + HeaderText = ActionsListLangRes.Col_Side, + Width = 150, + DataSource = Enum.GetValues(), + }, + new GridViewCheckBoxColumn + { + Name = "isextra", + HeaderText = ActionsListLangRes.Col_IsExtra, + Width = 50, + }, new GridViewCheckBoxColumn { Name = "iszip", @@ -191,18 +215,12 @@ public partial class Form1 : RadForm, IMainApi HeaderText = ActionsListLangRes.Col_DestPath, Width = 250, }, - new GridViewTextBoxColumn - { - Name = "srcurl", - HeaderText = ActionsListLangRes.Col_SrcUrl, - Width = 350, - }, new GridViewComboBoxColumn { Name = "srctype", HeaderText = ActionsListLangRes.Col_SrcType, - DataSource = Enum.GetValues(), Width = 150, + DataSource = Enum.GetValues(), }, new GridViewTextBoxColumn { @@ -228,18 +246,17 @@ public partial class Form1 : RadForm, IMainApi HeaderText = ActionsListLangRes.Col_SrcTag, Width = 150, }, - new GridViewComboBoxColumn + new GridViewTextBoxColumn { - Name = "side", - HeaderText = ActionsListLangRes.Col_Side, - DataSource = Enum.GetValues(), - Width = 150, + Name = "srcurl", + HeaderText = ActionsListLangRes.Col_SrcUrl, + Width = 350, }, - new GridViewCheckBoxColumn + new GridViewTextBoxColumn { - Name = "isextra", - HeaderText = ActionsListLangRes.Col_IsExtra, - Width = 50, + Name = "website", + HeaderText = ActionsListLangRes.Col_Website, + Width = 350, }, ]); @@ -248,6 +265,7 @@ public partial class Form1 : RadForm, IMainApi { var row = radGridView_Actions.Rows.AddNew(); row.Tag = action; + row.Cells["id"].Value = action.Id; row.Cells["name"].Value = action.Name; row.Cells["iszip"].Value = action.IsZip; row.Cells["zippath"].Value = action.ZipPath; @@ -327,4 +345,84 @@ public partial class Form1 : RadForm, IMainApi // cellElement.ResetValue(LightVisualElement.ImageAlignmentProperty, ValueResetFlags.Local); //} } + + private void RadGridView_Actions_CellValueChanged(object sender, GridViewCellEventArgs e) + { + if (e.Row?.Tag is not InstallAction action) + return; + + var uaction = action as UpdateAction; + var newValue = e.Row.Cells[e.Column.Name].Value; + var colName = e.Column.Name; + + if (newValue is string valueStr) + { + var valueNullStr = valueStr.Nullify(); + + switch (colName) + { + case "id": + action.Id = valueNullStr; + break; + case "name": + action.Name = valueNullStr; + break; + case "zippath": + action.ZipPath = valueNullStr; + break; + case "destpath": + action.DestPath = valueNullStr; + break; + case "srcurl": + action.SourceUrl = valueNullStr; + break; + case "srctype": + action.SourceType = Enum.Parse(valueStr); + break; + case "srcowner": + action.SourceOwner = valueNullStr; + break; + case "srcname": + action.SourceName = valueNullStr; + break; + case "srcregex": + action.SourceTag = valueNullStr; + break; + case "srctag": + action.SourceTag = valueNullStr; + break; + case "side": + action.Side = Enum.Parse(valueStr); + break; + case "inherit": + if (uaction is not null) + uaction.InheritFrom = valueNullStr; + break; + case "utype": + if (uaction is not null) + uaction.Type = Enum.Parse(valueStr); + break; + case "srcpath": + if (uaction is not null) + uaction.SrcPath = valueNullStr; + break; + } + } + else if (newValue is bool valueBool) + { + switch (colName) + { + case "iszip": + action.IsZip = valueBool; + break; + case "isextra": + action.IsExtra = valueBool; + break; + case "isdir": + if (uaction is not null) + uaction.IsDirectory = valueBool; + break; + } + } + } } diff --git a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs index ec6473c..dff9749 100644 --- a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs +++ b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs @@ -69,6 +69,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Id ähnelt. + /// + internal static string Col_Id { + get { + return ResourceManager.GetString("Col_Id", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Inherit from ähnelt. /// @@ -195,6 +204,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Website ähnelt. + /// + internal static string Col_Website { + get { + return ResourceManager.GetString("Col_Website", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die ZIP archive path ähnelt. /// diff --git a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx index 4b24ee5..563d029 100644 --- a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx +++ b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx @@ -120,6 +120,9 @@ Destination path + + Id + Inherit from @@ -162,6 +165,9 @@ Update type + + Website + ZIP archive path diff --git a/ModpackUpdater/InstallAction.cs b/ModpackUpdater/InstallAction.cs index 9a31df6..a52cc22 100644 --- a/ModpackUpdater/InstallAction.cs +++ b/ModpackUpdater/InstallAction.cs @@ -5,9 +5,15 @@ namespace ModpackUpdater; public class InstallAction { + [DefaultValue(null)] + public string Id { get; set; } + [DefaultValue(null)] public string Name { get; set; } + [DefaultValue(null)] + public string Website { get; set; } + [DefaultValue(false)] public bool IsZip { get; set; }