Implement overall improvements for code stability, fallbacks and keyboard interactions
This commit is contained in:
@@ -50,6 +50,7 @@ namespace KernelPanic.UI
|
||||
private UnitDetailTab _unitDetailTab = UnitDetailTab.Overview;
|
||||
private PackageSlot? _packagePickerSlot;
|
||||
private bool _unitDetailReturnsToOverview = true;
|
||||
private bool _unitDetailReadOnly;
|
||||
private DistroDefinition _equipWindowUnit;
|
||||
private PackageSlot _equipWindowSlot;
|
||||
private int _selectedUnitIndex;
|
||||
@@ -111,6 +112,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
ClosePackageEquipWindow();
|
||||
_mode = CollectionMode.Units;
|
||||
_unitDetailReadOnly = false;
|
||||
CurrentTitle = "$ ls ~/collection";
|
||||
CurrentHint = "[esc] back [left/right] tabs [tab] focus [up/down] select [enter] select";
|
||||
RenderUnits();
|
||||
@@ -238,6 +240,7 @@ namespace KernelPanic.UI
|
||||
|
||||
if (_mode == CollectionMode.UnitDetail && _units.Count > 0)
|
||||
{
|
||||
if (_unitDetailReadOnly) return;
|
||||
DistroDefinition unit = _units[_selectedUnitIndex];
|
||||
switch (_unitDetailTab)
|
||||
{
|
||||
@@ -257,7 +260,7 @@ namespace KernelPanic.UI
|
||||
|
||||
public void SwitchUnitDetailTabRelative(int delta)
|
||||
{
|
||||
if (_mode != CollectionMode.UnitDetail || _units.Count == 0)
|
||||
if (_mode != CollectionMode.UnitDetail || _units.Count == 0 || _unitDetailReadOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -270,10 +273,10 @@ namespace KernelPanic.UI
|
||||
ViewChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void ShowUnitDetail(DistroDefinition unit, bool returnToOverview)
|
||||
public void ShowUnitDetail(DistroDefinition unit, bool returnToOverview, bool readOnly = false)
|
||||
{
|
||||
SelectUnitById(unit?.Id);
|
||||
OpenUnitDetail(unit, true, returnToOverview);
|
||||
OpenUnitDetail(unit, true, returnToOverview, readOnly);
|
||||
}
|
||||
|
||||
private void RenderUnits()
|
||||
@@ -621,7 +624,7 @@ namespace KernelPanic.UI
|
||||
string upgradeMarker = CanUpgradeUnit(unit) ? " *" : string.Empty;
|
||||
string listing = LsText($"{"drwxr-xr-x",-12}{"player",-8}{$"{GetDistroStars(unit)}★",-6}{$"{version}/{GachaTuning.MaxVersion}",-6}{languages,-20}{unit.Id}/{upgradeMarker}");
|
||||
|
||||
Button row = new();
|
||||
Button row = new() { name = $"CollectionUnit_{unit.Id}" };
|
||||
row.AddToClassList("collection-row");
|
||||
row.AddToClassList("unit-overview-row");
|
||||
row.AddToClassList(RarityPresentation.ForStars(GetDistroStars(unit)).ClassName);
|
||||
@@ -796,14 +799,14 @@ namespace KernelPanic.UI
|
||||
_rows[selectedIndex].Focus();
|
||||
}
|
||||
|
||||
private void OpenUnitDetail(DistroDefinition unit, bool notify, bool returnToOverview = true)
|
||||
private void OpenUnitDetail(DistroDefinition unit, bool notify, bool returnToOverview = true, bool readOnly = false)
|
||||
{
|
||||
if (unit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_mode != CollectionMode.UnitDetail)
|
||||
if (_mode != CollectionMode.UnitDetail || readOnly)
|
||||
{
|
||||
_unitDetailTab = UnitDetailTab.Overview;
|
||||
_packagePickerSlot = null;
|
||||
@@ -811,6 +814,7 @@ namespace KernelPanic.UI
|
||||
}
|
||||
|
||||
_unitDetailReturnsToOverview = returnToOverview;
|
||||
_unitDetailReadOnly = readOnly;
|
||||
_mode = CollectionMode.UnitDetail;
|
||||
CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf";
|
||||
CurrentHint = GetUnitDetailHint();
|
||||
@@ -834,12 +838,12 @@ namespace KernelPanic.UI
|
||||
CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf";
|
||||
CurrentHint = GetUnitDetailHint();
|
||||
|
||||
string identity = unit.Id + ":" + GetUnitVersion(unit);
|
||||
string identity = unit.Id + ":" + GetUnitVersion(unit) + (_unitDetailReadOnly ? ":preview" : ":owned");
|
||||
if (_headerIdentity != identity)
|
||||
{
|
||||
_contextHeader.Clear();
|
||||
_contextHeader.Add(BuildUnitDetailHeader(unit));
|
||||
_contextHeader.Add(BuildUnitDetailTabs(unit));
|
||||
if (!_unitDetailReadOnly) _contextHeader.Add(BuildUnitDetailTabs(unit));
|
||||
_headerIdentity = identity;
|
||||
}
|
||||
_contextHeader.RemoveFromClassList("hidden");
|
||||
@@ -2135,6 +2139,7 @@ namespace KernelPanic.UI
|
||||
|
||||
private string GetUnitDetailHint()
|
||||
{
|
||||
if (_unitDetailReadOnly) return "[esc] back";
|
||||
string action = _unitDetailTab switch
|
||||
{
|
||||
UnitDetailTab.Upgrade => "[enter] upgrade",
|
||||
|
||||
Reference in New Issue
Block a user