Overhaul UI and overall QoL
This commit is contained in:
@@ -13,8 +13,17 @@ namespace KernelPanic.UI
|
||||
|
||||
public void Bind(VisualElement panel, string title, string hint, Action onBack)
|
||||
{
|
||||
// TemplateContainer is a real layout node; hiding only its child leaves a flex slot.
|
||||
if (panel.parent is TemplateContainer template)
|
||||
{
|
||||
template.AddToClassList("screen-slot");
|
||||
template.EnableInClassList("hidden", panel.ClassListContains("hidden"));
|
||||
}
|
||||
_titleLabel = panel.Q<Label>(className: "screen-frame-title");
|
||||
_hintLabel = panel.Q<Label>(className: "screen-frame-hint");
|
||||
var back = new Button(() => onBack?.Invoke()) { text = "[Esc] back" };
|
||||
back.AddToClassList("screen-back");
|
||||
panel.Q(className: "screen-frame-footer")?.Insert(0, back);
|
||||
|
||||
if (_titleLabel != null)
|
||||
{
|
||||
@@ -23,8 +32,7 @@ namespace KernelPanic.UI
|
||||
|
||||
if (_hintLabel != null)
|
||||
{
|
||||
_hintLabel.text = hint;
|
||||
_hintLabel.RegisterCallback<ClickEvent>(_ => onBack?.Invoke());
|
||||
_hintLabel.text = hint?.Replace("[esc] back", "").Trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +40,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
if (_hintLabel != null)
|
||||
{
|
||||
_hintLabel.text = hint;
|
||||
_hintLabel.text = hint?.Replace("[esc] back", "").Trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user