Move trade filters into runtime projection
This commit is contained in:
parent
5f068a4737
commit
6f0ff70336
3 changed files with 315 additions and 89 deletions
|
|
@ -4647,12 +4647,16 @@ static void RequireTradeFilterAndRowActionsUseEveSurface(string root)
|
|||
var requiredSymbols = new[]
|
||||
{
|
||||
"RenderFilterSurface(",
|
||||
"BuildFilterSurfaceCommands(",
|
||||
"_filterSurfaceProjection = ProjectTradeFilterSurface();",
|
||||
"HandleFilterSurfaceCommand(",
|
||||
"AetheriaEveUnitySurfaceHost.RenderRuntime(",
|
||||
"AetheriaEveUnitySurfaceHost.Hide(_filterSurfaceDocument)",
|
||||
"AetheriaRuntimeTradeInteractionSurfaceBuilder.BuildFilter(ProjectTradeFilterSurfaceState(",
|
||||
"ProjectTradeFilterSurfaceState(",
|
||||
"AetheriaRuntimeTradeInteractionSurfaceBuilder.BuildFilter(_filterSurfaceProjection.State)",
|
||||
"ProjectTradeFilterSurface(",
|
||||
"AetheriaRuntimeTradeInteractionSurfaceBuilder.ProjectFilters(",
|
||||
"_filterSurfaceProjection?.TryResolve(command.Command, out var selection) == true",
|
||||
"ExecuteTradeFilterSelection(",
|
||||
"new AetheriaRuntimeTradeFilterOption(",
|
||||
"RenderRowActionSurface(",
|
||||
"HandleRowActionSurfaceCommand(",
|
||||
"AetheriaEveUnitySurfaceHost.Hide(_rowActionSurfaceDocument)",
|
||||
|
|
@ -4700,6 +4704,10 @@ static void RequireTradeFilterAndRowActionsUseEveSurface(string root)
|
|||
"string.Equals(request.Command, AetheriaRuntimeTradeInteractionSurfaceBuilder.CloseFilter",
|
||||
"string.Equals(request.Command, AetheriaRuntimeTradeInteractionSurfaceBuilder.CloseRowAction",
|
||||
"_filterSurfaceCommands.TryGetValue(request.Command",
|
||||
"private readonly Dictionary<string, Action> _filterSurfaceCommands",
|
||||
"BuildFilterSurfaceCommands(",
|
||||
"ProjectTradeFilterSurfaceState(",
|
||||
"AddTradeFilterGroup(",
|
||||
"_rowActionSurfaceCommands.TryGetValue(request.Command",
|
||||
"private readonly Dictionary<string, Action> _rowActionSurfaceCommands",
|
||||
"BuildRowActionSurfaceCommands(",
|
||||
|
|
@ -4730,6 +4738,10 @@ static void RequireTradeFilterAndRowActionsUseEveSurface(string root)
|
|||
"public static bool TryReadFilter(",
|
||||
"public static bool TryReadRowAction(",
|
||||
"AetheriaRuntimeTradeFilterSurfaceState",
|
||||
"AetheriaRuntimeTradeFilterOption",
|
||||
"AetheriaRuntimeTradeFilterSelectionKind",
|
||||
"AetheriaRuntimeTradeFilterSelection",
|
||||
"AetheriaRuntimeTradeFilterSurfaceProjection",
|
||||
"AetheriaRuntimeTradeRowActionSurfaceState",
|
||||
"AetheriaRuntimeTradeRowActionOption",
|
||||
"AetheriaRuntimeTradeRowActionSelection",
|
||||
|
|
@ -4738,6 +4750,8 @@ static void RequireTradeFilterAndRowActionsUseEveSurface(string root)
|
|||
"AetheriaRuntimeTradeSurfaceOption",
|
||||
"public static string HardpointFilterCommand(",
|
||||
"public static string RowActionCommand(",
|
||||
"public static AetheriaRuntimeTradeFilterSurfaceProjection ProjectFilters(",
|
||||
"public bool TryResolve(string command, out AetheriaRuntimeTradeFilterSelection selection)",
|
||||
"public static AetheriaRuntimeTradeRowActionSurfaceProjection ProjectRowActions(",
|
||||
"public bool TryResolve(string command, out AetheriaRuntimeTradeRowActionSelection selection)",
|
||||
"public static AetheriaRuntimeSurfaceDocument BuildFilter(",
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ public class TradeMenu : MonoBehaviour
|
|||
private (ItemFilter filter, SimpleCommodityCategory type) _commodityFilter;
|
||||
private (ItemFilter filter, CompoundCommodityCategory type) _compoundCommodityFilter;
|
||||
private List<BehaviorFilter> _behaviorFilters = new List<BehaviorFilter>();
|
||||
private readonly Dictionary<string, Action> _filterSurfaceCommands = new Dictionary<string, Action>(StringComparer.Ordinal);
|
||||
private readonly Dictionary<string, (EquippedCargoBay Cargo, string Label)> _cargoSelectionCommands =
|
||||
new Dictionary<string, (EquippedCargoBay Cargo, string Label)>(StringComparer.Ordinal);
|
||||
private UIDocument _cargoSelectorSurfaceDocument;
|
||||
|
|
@ -40,6 +39,7 @@ public class TradeMenu : MonoBehaviour
|
|||
private readonly AetheriaEveUnitySurfaceChrome _filterSurfaceChrome = PanelChrome(420f, 520f, Align.FlexStart);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _rowActionSurfaceChrome = PanelChrome(320f, 360f, Align.FlexStart);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _tradeItemSurfaceChrome = PanelChrome(420f, 520f, Align.FlexStart);
|
||||
private AetheriaRuntimeTradeFilterSurfaceProjection _filterSurfaceProjection;
|
||||
private Action[] _rowActionCallbacks = Array.Empty<Action>();
|
||||
private AetheriaRuntimeTradeRowActionSurfaceProjection _rowActionSurfaceProjection;
|
||||
|
||||
|
|
@ -658,62 +658,18 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
private void RenderFilterSurface()
|
||||
{
|
||||
BuildFilterSurfaceCommands();
|
||||
_filterSurfaceProjection = ProjectTradeFilterSurface();
|
||||
|
||||
_filterSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime(
|
||||
transform,
|
||||
_filterSurfaceDocument,
|
||||
"Aetheria Trade Filter Surface",
|
||||
AetheriaRuntimeTradeInteractionSurfaceBuilder.BuildFilter(ProjectTradeFilterSurfaceState()),
|
||||
AetheriaRuntimeTradeInteractionSurfaceBuilder.BuildFilter(_filterSurfaceProjection.State),
|
||||
HandleFilterSurfaceCommand,
|
||||
_filterSurfaceChrome,
|
||||
sortingOrder: 1001);
|
||||
}
|
||||
|
||||
private void BuildFilterSurfaceCommands()
|
||||
{
|
||||
_filterSurfaceCommands.Clear();
|
||||
|
||||
foreach (var hardpointType in ((HardpointType[])Enum.GetValues(typeof(HardpointType)))
|
||||
.Where(type => _hardpointFilter.filter == null || type != _hardpointFilter.type))
|
||||
{
|
||||
var command = AetheriaRuntimeTradeInteractionSurfaceBuilder.HardpointFilterCommand(hardpointType.ToString());
|
||||
_filterSurfaceCommands[command] = () => ApplyHardpointFilter(hardpointType);
|
||||
}
|
||||
|
||||
foreach (var commodityType in ((SimpleCommodityCategory[])Enum.GetValues(typeof(SimpleCommodityCategory)))
|
||||
.Where(type => _commodityFilter.filter == null || type != _commodityFilter.type))
|
||||
{
|
||||
var command = AetheriaRuntimeTradeInteractionSurfaceBuilder.SimpleCommodityFilterCommand(commodityType.ToString());
|
||||
_filterSurfaceCommands[command] = () => ApplySimpleCommodityFilter(commodityType);
|
||||
}
|
||||
|
||||
foreach (var commodityType in ((CompoundCommodityCategory[])Enum.GetValues(typeof(CompoundCommodityCategory)))
|
||||
.Where(type => _compoundCommodityFilter.filter == null || type != _compoundCommodityFilter.type))
|
||||
{
|
||||
var command = AetheriaRuntimeTradeInteractionSurfaceBuilder.CompoundCommodityFilterCommand(commodityType.ToString());
|
||||
_filterSurfaceCommands[command] = () => ApplyCompoundCommodityFilter(commodityType);
|
||||
}
|
||||
|
||||
foreach (var metadata in AetheriaRuntimeBehaviorMetadataCatalog.All
|
||||
.Where(option => _behaviorFilters.All(filter => filter.Kind != option.Kind))
|
||||
.OrderBy(option => option.Kind, StringComparer.Ordinal))
|
||||
{
|
||||
var command = AetheriaRuntimeTradeInteractionSurfaceBuilder.BehaviorFilterCommand(metadata.Kind);
|
||||
_filterSurfaceCommands[command] = () => ApplyBehaviorFilter(metadata);
|
||||
}
|
||||
|
||||
if (!MinimumSizeFilter.gameObject.activeSelf)
|
||||
{
|
||||
_filterSurfaceCommands[AetheriaRuntimeTradeInteractionSurfaceBuilder.MinimumSizeFilterCommand()] = EnableMinimumSizeFilter;
|
||||
}
|
||||
|
||||
if (!MaximumSizeFilter.gameObject.activeSelf)
|
||||
{
|
||||
_filterSurfaceCommands[AetheriaRuntimeTradeInteractionSurfaceBuilder.MaximumSizeFilterCommand()] = EnableMaximumSizeFilter;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleFilterSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
{
|
||||
if (!AetheriaRuntimeTradeInteractionSurfaceCommands.TryReadFilter(request, out var command))
|
||||
|
|
@ -729,9 +685,9 @@ public class TradeMenu : MonoBehaviour
|
|||
}
|
||||
|
||||
if (command.Kind == AetheriaRuntimeTradeInteractionCommandKind.Select &&
|
||||
_filterSurfaceCommands.TryGetValue(command.Command, out var action))
|
||||
_filterSurfaceProjection?.TryResolve(command.Command, out var selection) == true)
|
||||
{
|
||||
action();
|
||||
ExecuteTradeFilterSelection(selection);
|
||||
HideFilterSurface();
|
||||
return;
|
||||
}
|
||||
|
|
@ -747,49 +703,94 @@ public class TradeMenu : MonoBehaviour
|
|||
AetheriaEveUnitySurfaceHost.Hide(_filterSurfaceDocument);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeTradeFilterSurfaceState ProjectTradeFilterSurfaceState()
|
||||
private AetheriaRuntimeTradeFilterSurfaceProjection ProjectTradeFilterSurface()
|
||||
{
|
||||
var groups = new List<AetheriaRuntimeTradeSurfaceGroup>();
|
||||
AddTradeFilterGroup(groups, "hardpoint", "Gear Type", command => command.Contains(".hardpoint."));
|
||||
AddTradeFilterGroup(groups, "simple", "Simple Commodity", command => command.Contains(".simple."));
|
||||
AddTradeFilterGroup(groups, "compound", "Compound Commodity", command => command.Contains(".compound."));
|
||||
AddTradeFilterGroup(groups, "behavior", "Item Behavior", command => command.Contains(".behavior."));
|
||||
AddTradeFilterGroup(
|
||||
groups,
|
||||
"size",
|
||||
"Size",
|
||||
command => command.Contains(".size."),
|
||||
command => command.EndsWith(".minimum", StringComparison.Ordinal) ? "Minimum Size" : "Maximum Size");
|
||||
var options = new List<AetheriaRuntimeTradeFilterOption>();
|
||||
options.AddRange(((HardpointType[])Enum.GetValues(typeof(HardpointType)))
|
||||
.Where(type => _hardpointFilter.filter == null || type != _hardpointFilter.type)
|
||||
.Select(type => new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.Hardpoint,
|
||||
type.ToString(),
|
||||
type.ToString().FormatTypeName())));
|
||||
options.AddRange(((SimpleCommodityCategory[])Enum.GetValues(typeof(SimpleCommodityCategory)))
|
||||
.Where(type => _commodityFilter.filter == null || type != _commodityFilter.type)
|
||||
.Select(type => new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity,
|
||||
type.ToString(),
|
||||
type.ToString().FormatTypeName())));
|
||||
options.AddRange(((CompoundCommodityCategory[])Enum.GetValues(typeof(CompoundCommodityCategory)))
|
||||
.Where(type => _compoundCommodityFilter.filter == null || type != _compoundCommodityFilter.type)
|
||||
.Select(type => new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity,
|
||||
type.ToString(),
|
||||
type.ToString().FormatTypeName())));
|
||||
options.AddRange(AetheriaRuntimeBehaviorMetadataCatalog.All
|
||||
.Where(option => _behaviorFilters.All(filter => filter.Kind != option.Kind))
|
||||
.OrderBy(option => option.Kind, StringComparer.Ordinal)
|
||||
.Select(option => new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.Behavior,
|
||||
option.Kind,
|
||||
option.Kind.FormatTypeName())));
|
||||
|
||||
return new AetheriaRuntimeTradeFilterSurfaceState(
|
||||
if (!MinimumSizeFilter.gameObject.activeSelf)
|
||||
{
|
||||
options.Add(new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.MinimumSize,
|
||||
"minimum",
|
||||
"Minimum Size"));
|
||||
}
|
||||
|
||||
if (!MaximumSizeFilter.gameObject.activeSelf)
|
||||
{
|
||||
options.Add(new AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind.MaximumSize,
|
||||
"maximum",
|
||||
"Maximum Size"));
|
||||
}
|
||||
|
||||
return AetheriaRuntimeTradeInteractionSurfaceBuilder.ProjectFilters(
|
||||
BuildFilterSummary(),
|
||||
groups,
|
||||
options,
|
||||
DateTime.UtcNow.ToString("O"));
|
||||
}
|
||||
|
||||
private void AddTradeFilterGroup(
|
||||
List<AetheriaRuntimeTradeSurfaceGroup> groups,
|
||||
string key,
|
||||
string title,
|
||||
Func<string, bool> commandFilter,
|
||||
Func<string, string> labelFactory = null)
|
||||
private void ExecuteTradeFilterSelection(AetheriaRuntimeTradeFilterSelection selection)
|
||||
{
|
||||
var options = _filterSurfaceCommands.Keys
|
||||
.Where(commandFilter)
|
||||
.OrderBy(command => command, StringComparer.Ordinal)
|
||||
.Select(command => new AetheriaRuntimeTradeSurfaceOption(
|
||||
command,
|
||||
labelFactory?.Invoke(command) ?? command.Split('.').Last().FormatTypeName(),
|
||||
command))
|
||||
.ToArray();
|
||||
|
||||
if (options.Length == 0)
|
||||
return;
|
||||
|
||||
groups.Add(new AetheriaRuntimeTradeSurfaceGroup(
|
||||
$"{AetheriaRuntimeTradeInteractionSurfaceBuilder.FilterSurfaceId}.{key}.card",
|
||||
title,
|
||||
options));
|
||||
switch (selection.Kind)
|
||||
{
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Hardpoint:
|
||||
if (Enum.TryParse(selection.Token, out HardpointType hardpointType))
|
||||
{
|
||||
ApplyHardpointFilter(hardpointType);
|
||||
}
|
||||
return;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity:
|
||||
if (Enum.TryParse(selection.Token, out SimpleCommodityCategory simpleCategory))
|
||||
{
|
||||
ApplySimpleCommodityFilter(simpleCategory);
|
||||
}
|
||||
return;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity:
|
||||
if (Enum.TryParse(selection.Token, out CompoundCommodityCategory compoundCategory))
|
||||
{
|
||||
ApplyCompoundCommodityFilter(compoundCategory);
|
||||
}
|
||||
return;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Behavior:
|
||||
var metadata = AetheriaRuntimeBehaviorMetadataCatalog.All
|
||||
.FirstOrDefault(option => string.Equals(option.Kind, selection.Token, StringComparison.Ordinal));
|
||||
if (metadata != null)
|
||||
{
|
||||
ApplyBehaviorFilter(metadata);
|
||||
}
|
||||
return;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MinimumSize:
|
||||
EnableMinimumSizeFilter();
|
||||
return;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MaximumSize:
|
||||
EnableMaximumSizeFilter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderRowActionSurface(string title, params (string Label, Action Action)[] actions)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,73 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public string UpdatedAtUtc { get; }
|
||||
}
|
||||
|
||||
public enum AetheriaRuntimeTradeFilterSelectionKind
|
||||
{
|
||||
Unknown = 0,
|
||||
Hardpoint = 1,
|
||||
SimpleCommodity = 2,
|
||||
CompoundCommodity = 3,
|
||||
Behavior = 4,
|
||||
MinimumSize = 5,
|
||||
MaximumSize = 6
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeTradeFilterOption
|
||||
{
|
||||
public AetheriaRuntimeTradeFilterOption(
|
||||
AetheriaRuntimeTradeFilterSelectionKind kind,
|
||||
string token,
|
||||
string label)
|
||||
{
|
||||
Kind = kind;
|
||||
Token = token ?? "";
|
||||
Label = label ?? "";
|
||||
}
|
||||
|
||||
public AetheriaRuntimeTradeFilterSelectionKind Kind { get; }
|
||||
public string Token { get; }
|
||||
public string Label { get; }
|
||||
}
|
||||
|
||||
public readonly struct AetheriaRuntimeTradeFilterSelection
|
||||
{
|
||||
public AetheriaRuntimeTradeFilterSelection(
|
||||
AetheriaRuntimeTradeFilterSelectionKind kind,
|
||||
string command,
|
||||
string token)
|
||||
{
|
||||
Kind = kind;
|
||||
Command = command ?? "";
|
||||
Token = token ?? "";
|
||||
}
|
||||
|
||||
public AetheriaRuntimeTradeFilterSelectionKind Kind { get; }
|
||||
public string Command { get; }
|
||||
public string Token { get; }
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeTradeFilterSurfaceProjection
|
||||
{
|
||||
public AetheriaRuntimeTradeFilterSurfaceProjection(
|
||||
AetheriaRuntimeTradeFilterSurfaceState state,
|
||||
IReadOnlyDictionary<string, AetheriaRuntimeTradeFilterSelection> selections)
|
||||
{
|
||||
State = state ?? new AetheriaRuntimeTradeFilterSurfaceState(
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeTradeSurfaceGroup>(),
|
||||
"");
|
||||
Selections = selections ?? new Dictionary<string, AetheriaRuntimeTradeFilterSelection>(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public AetheriaRuntimeTradeFilterSurfaceState State { get; }
|
||||
public IReadOnlyDictionary<string, AetheriaRuntimeTradeFilterSelection> Selections { get; }
|
||||
|
||||
public bool TryResolve(string command, out AetheriaRuntimeTradeFilterSelection selection)
|
||||
{
|
||||
return Selections.TryGetValue(command ?? "", out selection);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaRuntimeTradeRowActionSurfaceState
|
||||
{
|
||||
public AetheriaRuntimeTradeRowActionSurfaceState(
|
||||
|
|
@ -158,6 +225,59 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return $"{RowActionSurfaceId}.action_{index}";
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeTradeFilterSurfaceProjection ProjectFilters(
|
||||
string filterSummary,
|
||||
IEnumerable<AetheriaRuntimeTradeFilterOption> options,
|
||||
string updatedAtUtc)
|
||||
{
|
||||
var selections = new Dictionary<string, AetheriaRuntimeTradeFilterSelection>(StringComparer.Ordinal);
|
||||
var grouped = new Dictionary<string, (AetheriaRuntimeTradeFilterSelectionKind Kind, List<AetheriaRuntimeTradeSurfaceOption> Options)>(StringComparer.Ordinal);
|
||||
|
||||
foreach (var option in options ?? Array.Empty<AetheriaRuntimeTradeFilterOption>())
|
||||
{
|
||||
if (option == null || option.Kind == AetheriaRuntimeTradeFilterSelectionKind.Unknown)
|
||||
continue;
|
||||
|
||||
var command = FilterCommand(option.Kind, option.Token);
|
||||
if (string.IsNullOrWhiteSpace(command))
|
||||
continue;
|
||||
|
||||
var groupKey = FilterGroupKey(option.Kind);
|
||||
if (!grouped.TryGetValue(groupKey, out var group))
|
||||
{
|
||||
group = (option.Kind, new List<AetheriaRuntimeTradeSurfaceOption>());
|
||||
grouped[groupKey] = group;
|
||||
}
|
||||
|
||||
group.Options.Add(new AetheriaRuntimeTradeSurfaceOption(
|
||||
$"{FilterSurfaceId}.{groupKey}.{StableToken(option.Token)}",
|
||||
string.IsNullOrWhiteSpace(option.Label) ? option.Token : option.Label,
|
||||
command));
|
||||
selections[command] = new AetheriaRuntimeTradeFilterSelection(
|
||||
option.Kind,
|
||||
command,
|
||||
option.Token);
|
||||
}
|
||||
|
||||
var groups = grouped
|
||||
.OrderBy(entry => FilterGroupOrder(entry.Value.Kind))
|
||||
.Select(entry => new AetheriaRuntimeTradeSurfaceGroup(
|
||||
$"{FilterSurfaceId}.{entry.Key}.card",
|
||||
FilterGroupTitle(entry.Value.Kind),
|
||||
entry.Value.Options
|
||||
.OrderBy(option => option.Label, StringComparer.Ordinal)
|
||||
.ToArray()))
|
||||
.Where(group => group.Options.Count > 0)
|
||||
.ToArray();
|
||||
|
||||
return new AetheriaRuntimeTradeFilterSurfaceProjection(
|
||||
new AetheriaRuntimeTradeFilterSurfaceState(
|
||||
filterSummary,
|
||||
groups,
|
||||
updatedAtUtc),
|
||||
selections);
|
||||
}
|
||||
|
||||
public static AetheriaRuntimeTradeRowActionSurfaceProjection ProjectRowActions(
|
||||
string title,
|
||||
IEnumerable<AetheriaRuntimeTradeRowActionOption> actions,
|
||||
|
|
@ -339,6 +459,97 @@ namespace GameCult.Aetheria.State.Verse
|
|||
.ToDictionary(prop => prop.Key, prop => prop.Value ?? "", StringComparer.Ordinal),
|
||||
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>());
|
||||
}
|
||||
|
||||
private static string FilterCommand(AetheriaRuntimeTradeFilterSelectionKind kind, string token)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Hardpoint:
|
||||
return HardpointFilterCommand(token);
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity:
|
||||
return SimpleCommodityFilterCommand(token);
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity:
|
||||
return CompoundCommodityFilterCommand(token);
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Behavior:
|
||||
return BehaviorFilterCommand(token);
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MinimumSize:
|
||||
return MinimumSizeFilterCommand();
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MaximumSize:
|
||||
return MaximumSizeFilterCommand();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static string FilterGroupKey(AetheriaRuntimeTradeFilterSelectionKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Hardpoint:
|
||||
return "hardpoint";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity:
|
||||
return "simple";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity:
|
||||
return "compound";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Behavior:
|
||||
return "behavior";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MinimumSize:
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MaximumSize:
|
||||
return "size";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
private static string FilterGroupTitle(AetheriaRuntimeTradeFilterSelectionKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Hardpoint:
|
||||
return "Gear Type";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity:
|
||||
return "Simple Commodity";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity:
|
||||
return "Compound Commodity";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Behavior:
|
||||
return "Item Behavior";
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MinimumSize:
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MaximumSize:
|
||||
return "Size";
|
||||
default:
|
||||
return "Filters";
|
||||
}
|
||||
}
|
||||
|
||||
private static int FilterGroupOrder(AetheriaRuntimeTradeFilterSelectionKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Hardpoint:
|
||||
return 0;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.SimpleCommodity:
|
||||
return 1;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.CompoundCommodity:
|
||||
return 2;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.Behavior:
|
||||
return 3;
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MinimumSize:
|
||||
case AetheriaRuntimeTradeFilterSelectionKind.MaximumSize:
|
||||
return 4;
|
||||
default:
|
||||
return 99;
|
||||
}
|
||||
}
|
||||
|
||||
private static string StableToken(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return "empty";
|
||||
|
||||
return new string(value
|
||||
.Select(character => char.IsLetterOrDigit(character) ? char.ToLowerInvariant(character) : '-')
|
||||
.ToArray()).Trim('-');
|
||||
}
|
||||
}
|
||||
|
||||
public enum AetheriaRuntimeTradeInteractionCommandKind
|
||||
|
|
|
|||
Loading…
Reference in a new issue