Skip to content

Commit

Permalink
Basic string exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaDesigns committed Dec 11, 2022
1 parent 94a7c75 commit 80589fb
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Charm/TagListView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Field;
using Microsoft.Toolkit.Mvvm.Input;
using Serilog;
using System.Text;

namespace Charm;

Expand Down Expand Up @@ -1313,6 +1314,7 @@ private void LoadStringContainer(TagHash tagHash)
// Would be nice to do something with colour formatting.
private void LoadStrings(TagHash tagHash)
{
var viewer = GetViewer();
_allTagItems = new ConcurrentBag<TagItem>();
StringContainer stringContainer = PackageHandler.GetTag(typeof(StringContainer), tagHash);
Parallel.ForEach(stringContainer.Header.StringHashTable, hash =>
Expand All @@ -1325,12 +1327,32 @@ private void LoadStrings(TagHash tagHash)
});
});
RefreshItemList();
SetExportFunction(ExportString, (int)EExportTypeFlag.Full);
viewer.ExportControl.SetExportInfo(tagHash);
}

private void ExportString(ExportInfo info)
{

StringContainer stringContainer = PackageHandler.GetTag(typeof(StringContainer), new TagHash(info.Hash));
StringBuilder text = new StringBuilder();

Parallel.ForEach(stringContainer.Header.StringHashTable, hash =>
{
text.Append($"{hash} : {stringContainer.GetStringFromHash(ELanguage.English, hash)} \n");
});

string saveDirectory = ConfigHandler.GetExportSavePath() + $"/Strings/{info.Hash}_{info.Name}/";
Directory.CreateDirectory(saveDirectory);

File.WriteAllText(saveDirectory + "strings.txt", text.ToString());

}

#endregion

#region Sound

private async Task LoadSoundsPackagesList()
{
// If there are packages, we don't want to reload the view as very poor for performance.
Expand Down

0 comments on commit 80589fb

Please sign in to comment.