Initial commit: AetherBags + KamiToolKit for FC Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Lumina.Excel;
|
||||
|
||||
namespace KamiToolKit.Nodes;
|
||||
|
||||
public class LuminaDropDownNode<T> : DropDownNode<LuminaButtonListNode<T>, T> where T : struct, IExcelRow<T> {
|
||||
|
||||
public LuminaDropDownNode() {
|
||||
OptionListNode.OnOptionSelected += OptionSelectedHandler;
|
||||
}
|
||||
|
||||
public Action<T>? OnOptionSelected { get; set; }
|
||||
|
||||
public LuminaButtonListNode<T>.GetLabel? LabelFunction {
|
||||
get => OptionListNode.LabelFunction;
|
||||
set {
|
||||
OptionListNode.LabelFunction = value;
|
||||
ResolveOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public LuminaButtonListNode<T>.ShouldShow? FilterFunction {
|
||||
get => OptionListNode.FilterFunction;
|
||||
set {
|
||||
OptionListNode.FilterFunction = value;
|
||||
ResolveOptions();
|
||||
}
|
||||
}
|
||||
|
||||
private void OptionSelectedHandler(T option) {
|
||||
OnOptionSelected?.Invoke(option);
|
||||
UpdateLabel(option);
|
||||
Toggle(false);
|
||||
}
|
||||
|
||||
private void ResolveOptions() {
|
||||
if (LabelFunction is null) return;
|
||||
if (FilterFunction is null) return;
|
||||
|
||||
OptionListNode.SelectDefaultOption();
|
||||
LabelNode.String = LabelFunction.Invoke(OptionListNode.SelectedOption);
|
||||
}
|
||||
|
||||
protected override void UpdateLabel(T option) {
|
||||
LabelNode.String = LabelFunction?.Invoke(option) ?? "ERROR: Label Function Not Set";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user