add/remove action rows
This commit is contained in:
@@ -2,5 +2,6 @@
|
||||
|
||||
public interface IMainApi
|
||||
{
|
||||
public IWorkspace? Workspace { get; }
|
||||
public IWorkspace? CurWorkspace { get; }
|
||||
public IActionSetInfos? CurActionSet { get; }
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Install to {0} ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Installation: {0} ähnelt.
|
||||
/// </summary>
|
||||
internal static string Node_Install {
|
||||
get {
|
||||
@@ -70,7 +70,7 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Update to {0} ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Update: {0} ähnelt.
|
||||
/// </summary>
|
||||
internal static string Node_Update {
|
||||
get {
|
||||
|
||||
@@ -118,9 +118,9 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Node_Install" xml:space="preserve">
|
||||
<value>Install to {0}</value>
|
||||
<value>Installation: {0}</value>
|
||||
</data>
|
||||
<data name="Node_Update" xml:space="preserve">
|
||||
<value>Update to {0}</value>
|
||||
<value>Update: {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -161,9 +161,8 @@ partial class MainForm
|
||||
//
|
||||
//
|
||||
//
|
||||
radGridView_Actions.MasterTemplate.AllowAddNewRow = false;
|
||||
radGridView_Actions.MasterTemplate.AddNewRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom;
|
||||
radGridView_Actions.MasterTemplate.AllowColumnChooser = false;
|
||||
radGridView_Actions.MasterTemplate.AllowDeleteRow = false;
|
||||
radGridView_Actions.MasterTemplate.AllowDragToGroup = false;
|
||||
radGridView_Actions.MasterTemplate.AllowRowResize = false;
|
||||
radGridView_Actions.MasterTemplate.AllowSearchRow = true;
|
||||
@@ -173,6 +172,9 @@ partial class MainForm
|
||||
radGridView_Actions.Size = new Size(590, 416);
|
||||
radGridView_Actions.TabIndex = 0;
|
||||
radGridView_Actions.CellFormatting += RadGridView_Actions_CellFormatting;
|
||||
radGridView_Actions.UserAddingRow += RadGridView_Actions_UserAddingRow;
|
||||
radGridView_Actions.UserAddedRow += RadGridView_Actions_UserAddedRow;
|
||||
radGridView_Actions.UserDeletedRow += RadGridView_Actions_UserDeletedRow;
|
||||
radGridView_Actions.CellValueChanged += RadGridView_Actions_CellValueChanged;
|
||||
//
|
||||
// radMenuItem_Workspace
|
||||
@@ -185,7 +187,7 @@ partial class MainForm
|
||||
//
|
||||
radMenuItem_WorkspacePreferences.Name = "radMenuItem_WorkspacePreferences";
|
||||
radMenuItem_WorkspacePreferences.Text = "Preferences";
|
||||
radMenuItem_WorkspacePreferences.Click += this.RadMenuItem_WorkspacePreferences_Click;
|
||||
radMenuItem_WorkspacePreferences.Click += RadMenuItem_WorkspacePreferences_Click;
|
||||
//
|
||||
// radMenuItem_SaveWorkspace
|
||||
//
|
||||
|
||||
@@ -18,7 +18,9 @@ public partial class MainForm : RadForm, IMainApi
|
||||
{
|
||||
private WorkspaceTag? wsInfo;
|
||||
|
||||
IWorkspace? IMainApi.Workspace => wsInfo?.Workspace;
|
||||
IWorkspace? IMainApi.CurWorkspace => wsInfo?.Workspace;
|
||||
|
||||
public IActionSetInfos? CurActionSet => CurActionSet as IActionSetInfos;
|
||||
|
||||
private record RecentFilesItemTag(WorkspaceConfig Config, WorkspaceFeature Feature);
|
||||
|
||||
@@ -510,4 +512,32 @@ public partial class MainForm : RadForm, IMainApi
|
||||
radListControl_Updates.Items.Remove(radListControl_Updates.SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void RadGridView_Actions_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
|
||||
{
|
||||
foreach (var row in e.Rows)
|
||||
row.Tag = CurActionSet is UpdateInfo ? new UpdateAction() : new InstallAction();
|
||||
}
|
||||
|
||||
private void RadGridView_Actions_UserAddedRow(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
foreach (var row in e.Rows)
|
||||
{
|
||||
if (row.Tag is UpdateAction uaction && CurActionSet is UpdateInfo uinfo && !uinfo.Actions.Contains(uaction))
|
||||
uinfo.Actions.Add(uaction);
|
||||
else if (row.Tag is InstallAction iaction && CurActionSet is InstallInfos iinfo && !iinfo.Actions.Contains(iaction))
|
||||
iinfo.Actions.Add(iaction);
|
||||
}
|
||||
}
|
||||
|
||||
private void RadGridView_Actions_UserDeletedRow(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
foreach (var row in e.Rows)
|
||||
{
|
||||
if (row.Tag is UpdateAction uaction && CurActionSet is UpdateInfo uinfo)
|
||||
uinfo.Actions.Remove(uaction);
|
||||
else if (row.Tag is InstallAction iaction && CurActionSet is InstallInfos iinfo)
|
||||
iinfo.Actions.Remove(iaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,8 +104,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
foreach (var action in checkingVersion.Actions)
|
||||
{
|
||||
// Resolve inherits
|
||||
if (!string.IsNullOrWhiteSpace(action.InheritFrom) && installInfos.Actions.FirstOrDefault(a => a.Id == action.InheritFrom) is InstallAction iaction)
|
||||
JsonConvert.PopulateObject(JsonConvert.SerializeObject(iaction), action);
|
||||
ResolveInherit(action, installInfos);
|
||||
|
||||
// Check & add
|
||||
if (action.Side.IsSide(options.Side) && (!action.IsExtra || options.IncludeExtras) && !result.Actions.Any(n => n.DestPath == action.DestPath))
|
||||
@@ -125,6 +124,17 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void ResolveInherit(UpdateAction action, InstallInfos installInfos)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(action.InheritFrom) && installInfos.Actions.FirstOrDefault(a => a.Id == action.InheritFrom) is InstallAction iaction)
|
||||
DuplicateTo(iaction, action);
|
||||
}
|
||||
|
||||
public static void DuplicateTo(InstallAction source, InstallAction destination)
|
||||
{
|
||||
JsonConvert.PopulateObject(JsonConvert.SerializeObject(source), destination);
|
||||
}
|
||||
|
||||
public async Task<bool?> Install(UpdateCheckResult checkResult)
|
||||
{
|
||||
var processed = 0;
|
||||
|
||||
Reference in New Issue
Block a user