shield detail
This commit is contained in:
1 parent
95dacdb595
commit
1c305bb677
18 files changed
+3368
-824
No files matched your search
@@ -20,21 +20,23 @@ public class InterfaceIcon : VisualElement {
|
||||
public new class UxmlFactory : UxmlFactory<InterfaceIcon, UxmlTraits> {}
|
||||
public new class UxmlTraits : VisualElement.UxmlTraits {
|
||||
readonly UxmlEnumAttributeDescription<Icon> _iconAttribute = new() { name = "icon" };
|
||||
readonly UxmlStringAttributeDescription _detailAttribute = new UxmlStringAttributeDescription() { name = "text" };
|
||||
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) {
|
||||
base.Init(ve, bag, cc);
|
||||
var InterfaceIcon = (InterfaceIcon)ve;
|
||||
InterfaceIcon.icon = _iconAttribute.GetValueFromBag(bag, cc);
|
||||
InterfaceIcon.detail = _detailAttribute.GetValueFromBag(bag, cc);
|
||||
}
|
||||
}
|
||||
|
||||
static readonly Dictionary<Icon, char> _iconGlyphMap = new() {
|
||||
{ Icon.Acceleration, '\ue901' },
|
||||
{ Icon.Deceleration, '\ue902' },
|
||||
{ Icon.Strafing, '\ue903' },
|
||||
{ Icon.Shield, '\ue904' },
|
||||
{ Icon.Acceleration, '\u25bc' },
|
||||
{ Icon.Deceleration, '\u25b2' },
|
||||
{ Icon.Strafing, '\u2b94' },
|
||||
{ Icon.Shield, '\u26c9' },
|
||||
|
||||
{ Icon.Logo, '\ue900' },
|
||||
{ Icon.Logo, '\u26d0' },
|
||||
};
|
||||
|
||||
public Icon icon {
|
||||
@@ -45,8 +47,19 @@ public class InterfaceIcon : VisualElement {
|
||||
}
|
||||
}
|
||||
|
||||
public string detail {
|
||||
get => _detail;
|
||||
set {
|
||||
_detail = value;
|
||||
_detailLabel.text = value;
|
||||
}
|
||||
}
|
||||
|
||||
Icon _icon;
|
||||
string _detail;
|
||||
|
||||
Label _iconLabel;
|
||||
Label _detailLabel;
|
||||
|
||||
public InterfaceIcon() : this(Icon.Strafing) {}
|
||||
|
||||
@@ -59,6 +72,17 @@ public class InterfaceIcon : VisualElement {
|
||||
};
|
||||
|
||||
Add(_iconLabel);
|
||||
|
||||
_detailLabel = new Label {
|
||||
style = {
|
||||
position = Position.Absolute,
|
||||
},
|
||||
};
|
||||
|
||||
_detailLabel.AddToClassList("detail");
|
||||
|
||||
Add(_detailLabel);
|
||||
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user