Небольшие исправления модели и обработчиков

This commit is contained in:
2025-05-21 15:57:43 +04:00
parent 00de4cb319
commit 4d01b100d1
13 changed files with 77 additions and 152 deletions
+6 -6
View File
@@ -7,7 +7,8 @@ using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Processors;
using Pf2eDataScrapper.WPF;
using Pf2eDataScrapper.WPF.EntityViewer;
using Pf2eDataScrapper.WPF.Views;
using Pf2eDataScrapper.WPF.ProgressForm;
using Pf2eDataScrapper.WPF.StartForm;
using Pf2eModel;
using Slugify;
@@ -50,7 +51,7 @@ internal sealed class ImportApplication : Application
#endregion
#region "Формы"
#region "Жизненный цикл"
private StartForm? _startFormWpf;
@@ -58,10 +59,6 @@ internal sealed class ImportApplication : Application
private EntityForm? _entityForm;
#endregion
#region "Жизненный цикл"
private Window? CurrentWpfForm { get; set; }
public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage);
@@ -133,6 +130,9 @@ internal sealed class ImportApplication : Application
break;
case ApplicationStage.ImportProcess:
_progressFormWpf!.Hide();
_progressFormWpf!.Close();
_progressFormWpf = null;
break;
case ApplicationStage.Viewer:
@@ -59,14 +59,14 @@ internal partial class StringHelper
}
/// <summary>
/// Извлечение информации о названии источника.
/// Извлечение суффикса из описания источника.
/// </summary>
/// <param name="input">Исходная строка.</param>
/// <returns>Название источника.</returns>
public string ResolveSource(string input)
/// <returns>Суффикс.</returns>
public string ResolveSourceSuffix(string input)
{
Match match = SourceSuffixRegex().Match(input);
return match.Captures.Count > 0 ? match.Captures[0].Value : "";
return match.Captures.Count > 0 ? match.Groups[1].Value : "";
}
/// <summary>
@@ -173,7 +173,9 @@ internal abstract class AbstractEntityProcessor(
{
Entity = Entity,
SourceId = Globals.SourceIds[sourceName],
Suffix = StringHelper.ResolveSource(Input.GetRequired<string>("source_markdown")),
Suffix = StringHelper.ResolveSourceSuffix(
Input.GetRequired<string>("source_markdown")
),
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null,
};
@@ -195,6 +197,7 @@ internal abstract class AbstractEntityProcessor(
Md5 = Input.Md5(),
};
Entity.Externals.Add(external);
Context.EntityExternals.Add(external);
}
@@ -33,16 +33,17 @@ internal class LegacyRemasterProcessors(ProcessorInput input) : AbstractInputPro
{
Context.LegacyRemasters.Add(new() { LegacyId = entityId, RemasterId = remasterId });
}
/*
foreach (int legacyId in GetEntityIds("legacy_id"))
{
Context.LegacyRemasters.Add(new() { LegacyId = legacyId, RemasterId = entityId });
}
*/
}
protected List<int> GetEntityIds(string path)
{
List<string> aonprdIds = (Input.GetOptional<JArray>("path") ?? [])
List<string> aonprdIds = (Input.GetOptional<JArray>(path) ?? [])
.Select(token => token.ToString())
.ToList();
@@ -109,6 +109,10 @@ internal class SpellProcessor(
{
A(new() { Spell = Object, Type = SpellAreaType.Square });
}
if (areaDetails.Contains("fungi"))
{
areaDetails = [areaDetails[0] + " or " + areaDetails[1]];
}
if (areaTypes.Count != areaDetails.Count)
{