Files
GlamourBrowser/GlamourBrowser/DataCache.cs
Administrator 935a89847f
All checks were successful
Build and Release / Build (push) Successful in 25s
Add dye selection functionality and related UI updates
2026-01-01 14:30:20 +02:00

37 lines
1.7 KiB
C#

using Dalamud.Game;
using Lumina.Excel.Sheets;
using Lumina.Extensions;
using System;
using System.Collections.Immutable;
using System.Linq;
namespace Glamaholic {
internal class DataCache {
public static Lazy<ImmutableList<Item>> EquippableItems { get; } =
new(() => Service.DataManager.GetExcelSheet<Item>(ClientLanguage.English)!
.Where(row => row.EquipSlotCategory.RowId != 0 &&
row.EquipSlotCategory.Value!.SoulCrystal == 0)
.ToImmutableList());
public static Lazy<ImmutableDictionary<string, byte>> StainLookup { get; } =
new (() =>
Service.DataManager.GetExcelSheet<Stain>(ClientLanguage.English)!
.Where(static row => row.RowId != 0 && !row.Name.IsEmpty)
.ToImmutableDictionary(static row =>
row.Name.ExtractText().Trim().ToLower(), static row => (byte) row.RowId));
public static Lazy<ImmutableList<(byte Id, string Name, uint Color, bool Gloss)>> AllStains { get; } =
new(() => Service.DataManager.GetExcelSheet<Stain>(ClientLanguage.English)!
.Where(row => row.RowId != 0 && !row.Name.IsEmpty)
.Select(row => ((byte)row.RowId, row.Name.ExtractText(), SeColorToRgba(row.Color), row.IsMetallic))
.ToImmutableList());
// Convert SE's BGR color format to RGBA
private static uint SeColorToRgba(uint color)
=> ((color & 0xFF) << 16) | ((color >> 16) & 0xFF) | (color & 0xFF00) | 0xFF000000;
public static int GetNumStainSlots(uint itemId) =>
Service.DataManager.GetExcelSheet<Item>(ClientLanguage.English)!.GetRowOrDefault(itemId)?.DyeCount ?? 0;
}
}