mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move ExtraIniItem to Core
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SabreTools.Core.Filter;
|
|
||||||
using SabreTools.IO.Logging;
|
using SabreTools.IO.Logging;
|
||||||
using SabreTools.IO.Readers;
|
using SabreTools.IO.Readers;
|
||||||
|
|
||||||
namespace SabreTools.Filtering
|
namespace SabreTools.Core.Filter
|
||||||
{
|
{
|
||||||
public class ExtraIniItem
|
public class ExtraIniItem
|
||||||
{
|
{
|
||||||
@@ -25,9 +24,11 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
public ExtraIniItem(string itemName, string fieldName)
|
public ExtraIniItem(string itemName, string fieldName, string ini)
|
||||||
{
|
{
|
||||||
Key = new FilterKey(itemName, fieldName);
|
Key = new FilterKey(itemName, fieldName);
|
||||||
|
if (!PopulateFromFile(ini))
|
||||||
|
Mappings.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -46,7 +47,7 @@ namespace SabreTools.Filtering
|
|||||||
/// the value is boolean. If there's another section name, then that is set
|
/// the value is boolean. If there's another section name, then that is set
|
||||||
/// as the value instead.
|
/// as the value instead.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public bool PopulateFromFile(string ini)
|
private bool PopulateFromFile(string ini)
|
||||||
{
|
{
|
||||||
// Prepare all intenral variables
|
// Prepare all intenral variables
|
||||||
IniReader ir = new(ini) { ValidateRows = false };
|
IniReader ir = new(ini) { ValidateRows = false };
|
||||||
@@ -67,8 +67,8 @@ namespace SabreTools.Filtering
|
|||||||
string fileString = inputTrimmed.Substring(fieldString.Length + 1).Trim('"', ' ', '\t');
|
string fileString = inputTrimmed.Substring(fieldString.Length + 1).Trim('"', ' ', '\t');
|
||||||
|
|
||||||
FilterParser.ParseFilterId(fieldString, out string itemName, out string fieldName);
|
FilterParser.ParseFilterId(fieldString, out string itemName, out string fieldName);
|
||||||
var item = new ExtraIniItem(itemName, fieldName);
|
var item = new ExtraIniItem(itemName, fieldName, fileString);
|
||||||
if (item.PopulateFromFile(fileString))
|
if (item.Mappings.Count > 0)
|
||||||
Items.Add(item);
|
Items.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -342,8 +342,7 @@ Reset the internal state: reset();";
|
|||||||
|
|
||||||
// Create the extra INI
|
// Create the extra INI
|
||||||
var extraIni = new ExtraIni();
|
var extraIni = new ExtraIni();
|
||||||
var extraIniItem = new ExtraIniItem(itemName, fieldName);
|
var extraIniItem = new ExtraIniItem(itemName, fieldName, extraFile);
|
||||||
extraIniItem.PopulateFromFile(extraFile);
|
|
||||||
extraIni.Items.Add(extraIniItem);
|
extraIni.Items.Add(extraIniItem);
|
||||||
|
|
||||||
// Apply the extra INI blindly
|
// Apply the extra INI blindly
|
||||||
|
|||||||
Reference in New Issue
Block a user