Projektdateien hinzufügen.

This commit is contained in:
2024-05-05 15:59:49 +02:00
parent 74da0c6962
commit 7c28a6ee17
242 changed files with 23697 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SM64Lib.Text.Exporters
{
public class ExcelExporter
{
public ExcelExporter()
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
}
public async Task Export(string destFilePath, TextGroup[] groups)
{
var pkg = new ExcelPackage();
foreach (var tg in groups)
{
var ws = pkg.Workbook.Worksheets.Add(tg.TextGroupInfo.Name);
var hasDialogCells = false;
ws.Cells.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
ws.Cells.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
ws.Row(1).Style.Font.Bold = true;
ws.Cells[1, 1].Value = "#";
ws.Cells[1, 2].Value = "Text";
for (int i = 0; i < tg.Count; i++)
{
var ti = tg[i];
var ri = i + 2;
ws.Cells[ri, 1].Value = i;
ws.Cells[ri, 2].Value = ti.Text;
if (ti is TextTableDialogItem)
hasDialogCells = true;
}
for (int ri = 1; ri <= ws.Cells.Rows; ri++)
{
var r = ws.Row(ri);
r.CustomHeight = false;
}
if (hasDialogCells)
{
var c = ws.Column(2);
c.Style.WrapText = true;
c.Width = 30;
}
for (int ci = 1; ci <= 2; ci++)
{
var c = ws.Column(ci);
if (!c.Style.WrapText)
c.AutoFit();
}
}
await pkg.SaveAsAsync(new FileInfo(destFilePath));
pkg.Dispose();
}
public async Task Import(string filePath, TextGroup[] groups)
{
try
{
var pkg = new ExcelPackage();
await pkg.LoadAsync(new FileInfo(filePath));
foreach (var tg in groups)
{
var ws = pkg.Workbook.Worksheets[tg.TextGroupInfo.Name];
if (ws is not null)
{
for (int iti = 0; iti < tg.Count; iti++)
{
var ti = tg[iti];
var ri = iti + 2;
var c = ws.Cells[ri, 2];
ti.Text = ((string)c.Value).Replace("\r\n", "\n").Replace("\n", "\r\n");
tg.NeedToSave = true;
}
}
}
pkg.Dispose();
}
catch (Exception)
{
}
}
}
}

View File

@@ -0,0 +1,11 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("e6305a1d-e5da-4bb6-992e-3a341bc99a7b")]

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<AssemblyTitle>SM64Lib.Text.Exporters</AssemblyTitle>
<Product>SM64Lib.Text.Exporters</Product>
<Copyright>Copyright © 2020</Copyright>
<Platforms>AnyCPU</Platforms>
<Configurations>Debug;Release;ReleaseBundle;ReleaseStandalone</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SM64Lib\SM64Lib.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="7.1.2" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SM64Lib.Text.Exporters
{
public class TxtExporter
{
public async Task Export(string destFilePath, TextGroup[] groups)
{
var sw = new StreamWriter(destFilePath);
for (int itg = 0; itg < groups.Length; itg++)
{
var tg = groups[itg];
if (itg != 0)
await sw.WriteLineAsync("------------------------------\n");
await sw.WriteLineAsync($"Text Group - {tg.TextGroupInfo.Name}\n");
await sw.WriteLineAsync("------------------------------\n");
for (int iti = 0; iti < tg.Count; iti++)
{
var ti = tg[iti];
if (ti is TextTableDialogItem)
{
await sw.WriteLineAsync($"Dialog #{iti}\n");
await sw.WriteLineAsync(ti.Text);
await sw.WriteLineAsync("\n\n");
}
else
{
await sw.WriteLineAsync($"Text Item #{iti}");
await sw.WriteLineAsync(ti.Text);
await sw.WriteLineAsync();
}
}
}
await sw.FlushAsync();
sw.Close();
}
}
}