Skip to content

Commit

Permalink
[PR] New build
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfcomp authored Jan 10, 2024
2 parents 631ad81 + b598f2e commit 9c97be3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
5 changes: 1 addition & 4 deletions DeepDungeonDex/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
global using DeepDungeonDex.Storage;
global using ImGuiNET;
global using Newtonsoft.Json;
global using Dalamud.Logging;
global using System.Reflection;
global using Dalamud.Interface.Windowing;
global using Dalamud.Game;
global using Dalamud.Game.ClientState.Conditions;
global using Dalamud.Plugin;
global using Dalamud.Plugin.Services;
global using Dalamud.Game.Gui;
global using Dalamud.Plugin.Services;
10 changes: 7 additions & 3 deletions DeepDungeonDex/Requests/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class Requests : IDisposable
{
private readonly CancellationTokenSource _token = new();
private readonly Thread _loadFileThread;
private readonly Thread _loadLangThread;
private Thread? _loadLangThread;
private readonly Regex _percentRegex = new("(%%)|(%)", RegexOptions.Compiled);
private IPluginLog _log;
private bool _loadedOnce;
Expand All @@ -28,10 +28,8 @@ public Requests(StorageHandler handler, IPluginLog log)
_log = log;
#pragma warning disable CS4014
_loadFileThread = new Thread(() => RefreshFileList());
_loadLangThread = new Thread(() => RefreshLang());
#pragma warning restore CS4014
_loadFileThread.Start();
_loadLangThread.Start();
}

public async Task<Dictionary<string, string[]>?> GetFileList()
Expand Down Expand Up @@ -91,6 +89,12 @@ public async Task RefreshFileList(bool continuous = true)
_loadedOnce = true;

RefreshEnd:

if (_loadLangThread == null)
{
_loadLangThread = new Thread(() => RefreshLang());
_loadLangThread.Start();
}
RequestingData = false;
if (continuous)
{
Expand Down
11 changes: 5 additions & 6 deletions DeepDungeonDex/Requests/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ public void ChangeLanguage()
_log.Verbose($"Changed language to {name} processing MobData descriptions");
foreach (var (_, files) in list)
{
foreach (var file in files)
foreach (var path in files)
{
if (file == "Job.yml")
if (path == "Job.yml")
continue;
var path = file.Replace(".yml", ".dat");
_log.Verbose($"Loading {path}");
var mobData = Handler.GetInstance<MobData>(path);
if (mobData == null)
continue;

_log.Verbose($"Processing MobData descriptions for {file}");
_log.Verbose($"Processing MobData descriptions for {path}");
try
{
_log.Verbose("Loading language file");
if (Handler.GetInstance($"{name}/{file}") is not Locale langData)
if (Handler.GetInstance($"{name}/{path}") is not Locale langData)
continue;
_log.Verbose("Looping through MobData");
foreach (var (id, _) in mobData.MobDictionary)
Expand Down Expand Up @@ -87,7 +86,7 @@ public async Task RefreshLang(bool continuous = true)
if (string.IsNullOrWhiteSpace(localization))
continue;
Handler.AddStorage(main, new Locale { TranslationDictionary = StorageHandler.Deserializer.Deserialize<Dictionary<string, string>>(localization) });
foreach (var (_, files) in list)
foreach (var (fileType, files) in list)
{
foreach (var file in files)
{
Expand Down
2 changes: 1 addition & 1 deletion DeepDungeonDex/Storage/MobData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void ProcessDescription(float width)
}
else
{
strList.Add(s[..^1]);
strList.Add(s.Length > 0 ? s[..^1] : "");
s = t + " ";
}
}
Expand Down
21 changes: 16 additions & 5 deletions DeepDungeonDex/Storage/StorageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ private Configuration LoadConfig()
}
binary.Close();
file.Close();
config.PrevLocale = config.Locale;
config.PrevFontSize = config.FontSize;
return config;
}
catch
Expand Down Expand Up @@ -176,7 +178,7 @@ public void Dispose()
{
foreach (var (_, obj) in Storage)
{
if(obj is IDisposable disposable)
if (obj is IDisposable disposable)
disposable.Dispose();
}
Storage.Clear();
Expand Down Expand Up @@ -213,12 +215,21 @@ public object ReadYaml(IParser parser, Type type)
var items = new List<string>();
if (type.GetCustomAttributes<FlagsAttribute>().Any())
{
parser.TryConsume<SequenceStart>(out _);
while (parser.TryConsume<Scalar>(out var scalar))
parser.TryConsume<SequenceStart>(out var sequence);
if (sequence != null)
{
items.Add(scalar.Value);
while (parser.TryConsume<Scalar>(out var scalar))
{
items.Add(scalar.Value);
}

parser.TryConsume<SequenceEnd>(out _);
}
else
{
if (parser.TryConsume<Scalar>(out var scalar))
items.Add(scalar.Value);
}
parser.TryConsume<SequenceEnd>(out _);
}
else if (parser.TryConsume<Scalar>(out var scalar))
items.Add(scalar.Value);
Expand Down

0 comments on commit 9c97be3

Please sign in to comment.