add generate modlist feature

This commit is contained in:
2025-01-28 20:38:27 +01:00
parent 2ce73ad032
commit 33a209a01a
12 changed files with 157 additions and 5 deletions

View File

@@ -1,7 +1,9 @@
using Microsoft.Extensions.Primitives;
using ModpackUpdater.Apps.Manager.Api.Model;
using ModpackUpdater.Apps.Manager.LangRes;
using ModpackUpdater.Apps.Manager.Ui;
using ModpackUpdater.Manager;
using OfficeOpenXml;
using Pilz.UI.Extensions;
using System.Text;
using Telerik.WinControls.UI;
@@ -209,4 +211,61 @@ internal static class SharedFunctions
return log.ToString().TrimEnd();
}
public static ExcelPackage? GenerateModlist(InstallInfos installInfos)
{
var pkg = new ExcelPackage();
var ws = pkg.Workbook.Worksheets.Add(GeneralLangRes.Text_Modlist);
var cr = 1;
var cc = 1;
// Header
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_Name;
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcTag;
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_Side;
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcType;
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcOwner;
ws.Cells[cr, cc++].Value = ActionsListLangRes.Col_SrcName;
cr += 1;
cc = 1;
// Rows
foreach (var action in installInfos.Actions)
{
if (action.IsExtra || action.IsZip || string.IsNullOrWhiteSpace(action.Id) || !action.Id.StartsWith("mod:"))
continue;
var cellName = ws.Cells[cr, cc++];
cellName.Value = action.Name;
if (!string.IsNullOrWhiteSpace(action.Website))
cellName.SetHyperlink(new Uri(action.Website));
var cellTag = ws.Cells[cr, cc++];
cellTag.Value = action.SourceTag;
if (!string.IsNullOrWhiteSpace(action.SourceUrl))
cellTag.SetHyperlink(new Uri(action.SourceUrl));
ws.Cells[cr, cc++].Value = action.Side.ToString();
ws.Cells[cr, cc++].Value = action.SourceType;
ws.Cells[cr, cc++].Value = action.SourceOwner;
ws.Cells[cr, cc++].Value = action.SourceName;
cr += 1;
cc = 1;
}
// Styling
cc = 1;
ws.Column(cc++).Width = 30;
ws.Column(cc++).Width = 15;
ws.Column(cc++).Width = 10;
ws.Column(cc++).Width = 20;
ws.Column(cc++).Width = 20;
ws.Column(cc++).Width = 30;
var tableDef = ws.Tables.Add(ws.Cells[1, 1, cr - 1, cc - 1], "Table");
tableDef.TableStyle = OfficeOpenXml.Table.TableStyles.Medium16;
tableDef.ShowHeader = true;
return pkg;
}
}

View File

@@ -0,0 +1,40 @@
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
using ModpackUpdater.Apps.Manager.LangRes;
using OfficeOpenXml;
using Pilz.Plugins.Advanced;
using Telerik.WinControls;
using Telerik.WinControls.UI;
namespace ModpackUpdater.Apps.Manager.Features.Tools;
internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistFeature>
{
public static GenerateModlistFeature Instance { get; } = new();
public GenerateModlistFeature() : base(FeatureTypes.Tools, "origin.genmodlist", FeatureNamesLangRes.GenerateModlistFeature)
{
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
}
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
{
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
return null;
using var pkg = SharedFunctions.GenerateModlist(p.Api.CurWorkspace.InstallInfos);
if (pkg is null)
return null;
using var sfd = new RadSaveFileDialog
{
Filter = "*.xlsx|*.xlsx|*|*"
};
if (sfd.ShowDialog(p.Api.MainWindow) == DialogResult.OK)
{
pkg.SaveAs(sfd.FileName);
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes., MsgBoxLangRes., MessageBoxButtons.OK, RadMessageIcon.Info);
}
return null;
}
}

View File

@@ -105,6 +105,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Generate modlist ähnelt.
/// </summary>
internal static string GenerateModlistFeature {
get {
return ResourceManager.GetString("GenerateModlistFeature", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die GitLab workspace ähnelt.
/// </summary>

View File

@@ -132,6 +132,9 @@
<data name="GenerateChangelogFeature" xml:space="preserve">
<value>Generate changelog</value>
</data>
<data name="GenerateModlistFeature" xml:space="preserve">
<value>Generate modlist</value>
</data>
<data name="GitLabWorkspace" xml:space="preserve">
<value>GitLab workspace</value>
</data>

View File

@@ -77,5 +77,14 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
return ResourceManager.GetString("Node_Update", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Modlist ähnelt.
/// </summary>
internal static string Text_Modlist {
get {
return ResourceManager.GetString("Text_Modlist", resourceCulture);
}
}
}
}

View File

@@ -123,4 +123,7 @@
<data name="Node_Update" xml:space="preserve">
<value>Update: {0}</value>
</data>
<data name="Text_Modlist" xml:space="preserve">
<value>Modlist</value>
</data>
</root>

View File

@@ -78,6 +78,24 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die The modlist has been generated successfully and saved to the selected location. ähnelt.
/// </summary>
internal static string ModlistGenerated {
get {
return ResourceManager.GetString("ModlistGenerated", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Modlist generated successfully ähnelt.
/// </summary>
internal static string ModlistGenerated_Title {
get {
return ResourceManager.GetString("ModlistGenerated_Title", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Are you sure that you want to delete this update? ähnelt.
/// </summary>

View File

@@ -123,6 +123,12 @@
<data name="ChangelogCopiedToClipboard_Title" xml:space="preserve">
<value>Changelog generated successfully</value>
</data>
<data name="ModlistGenerated" xml:space="preserve">
<value>The modlist has been generated successfully and saved to the selected location.</value>
</data>
<data name="ModlistGenerated_Title" xml:space="preserve">
<value>Modlist generated successfully</value>
</data>
<data name="RemoveUpdate" xml:space="preserve">
<value>Are you sure that you want to delete this update?</value>
</data>

View File

@@ -11,15 +11,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NGitLab" Version="6.59.0" />
<PackageReference Include="EPPlus" Version="7.5.3" />
<PackageReference Include="NGitLab" Version="7.3.0" />
<PackageReference Include="Pilz.Configuration" Version="3.2.0" />
<PackageReference Include="Pilz.Plugins.Advanced" Version="2.10.2" />
<PackageReference Include="Pilz.Plugins.Advanced.UI" Version="1.8.3" />
<PackageReference Include="Pilz.Plugins.Advanced.UI.Telerik" Version="1.7.2" />
<PackageReference Include="Pilz.UI" Version="2.3.14" />
<PackageReference Include="Pilz.UI.Telerik" Version="2.8.1" />
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
<PackageReference Include="UI.for.WinForms.GridView" Version="2024.3.806" />
<PackageReference Include="Pilz.UI" Version="2.4.5" />
<PackageReference Include="Pilz.UI.Telerik" Version="2.9.5" />
<PackageReference Include="UI.for.WinForms.Common" Version="2024.4.1113" />
<PackageReference Include="UI.for.WinForms.GridView" Version="2024.4.1113" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,3 +1,4 @@
using OfficeOpenXml;
using Pilz;
using Pilz.Configuration;
using Pilz.Plugins.Advanced;
@@ -14,6 +15,7 @@ public static class Program
static Program()
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
settingsManager = new(GetSettingsPath(), true);
}

View File

@@ -35,4 +35,5 @@ public enum AppSymbols
heart_with_pulse,
broom,
renew,
list_view,
}

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#B2EBF2" d="M7 4H41V44H7z"/><path fill="#00ACC1" d="M13 26H17V30H13zM13 18H17V22H13zM13 34H17V38H13zM13 10H17V14H13zM21 26H35V30H21zM21 18H35V22H21zM21 34H35V38H21zM21 10H35V14H21z"/></svg>

After

Width:  |  Height:  |  Size: 284 B