mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 23:27:14 -05:00
Show associated item names in ItemEditor
This commit is contained in:
parent
ae42737c02
commit
72b6944a82
|
|
@ -205,6 +205,26 @@ private static string GetItemName60000(ushort index)
|
|||
|
||||
return "???";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns clothing or item recolors not a part of ItemRemake with brackets in their names
|
||||
/// </summary>
|
||||
/// <param name="id">ItemID of the color variation search</param>
|
||||
/// <param name="baseItemName">Item name without the associated recolors</param>
|
||||
/// <returns>Map of ItemID, ItemName</returns>
|
||||
public List<ComboItem> GetAssociatedItems(ushort id, out string baseItemName)
|
||||
{
|
||||
var stringMatch = GetItemName(id);
|
||||
var index = stringMatch.IndexOf('(');
|
||||
if (index < 0)
|
||||
{
|
||||
baseItemName = string.Empty;
|
||||
return new List<ComboItem>();
|
||||
}
|
||||
|
||||
var search = baseItemName = stringMatch.Substring(0, index);
|
||||
return ItemDataSource.FindAll(x => x.Text.StartsWith(search));
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRemakeString
|
||||
|
|
|
|||
|
|
@ -80,6 +80,14 @@ public static void Add(this List<ComboItem> storage, IReadOnlyList<INamedValue>
|
|||
storage.Sort(initial, storage.Count - initial, Comparer);
|
||||
}
|
||||
|
||||
public static string ToStringList(this List<ComboItem> arr, bool includeValues)
|
||||
{
|
||||
string format = string.Empty;
|
||||
foreach (var ci in arr)
|
||||
format += includeValues ? $"{ci.Text} ({ci.Value:X})\n" : $"{ci.Text}\n";
|
||||
return format;
|
||||
}
|
||||
|
||||
public static void SortByText(this List<ComboItem> arr) => arr.Sort(Comparer);
|
||||
|
||||
private static readonly FunctorComparer<ComboItem> Comparer =
|
||||
|
|
|
|||
|
|
@ -185,8 +185,17 @@ private void CB_ItemID_SelectedValueChanged(object sender, EventArgs e)
|
|||
var remake = ItemRemakeUtil.GetRemakeIndex(itemID);
|
||||
if (remake < 0)
|
||||
{
|
||||
L_RemakeBody.Visible = false;
|
||||
L_RemakeFabric.Visible = false;
|
||||
var closeItems = GameInfo.Strings.GetAssociatedItems(itemID, out var bse);
|
||||
if (closeItems.Count > 1) // ignore if we are the only parenthesised item
|
||||
{
|
||||
L_RemakeBody.Text = $"{bse.Trim()}:\n" + closeItems.ToStringList(false);
|
||||
L_RemakeBody.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
L_RemakeBody.Visible = false;
|
||||
L_RemakeFabric.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user