add generate modlist feature
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user