diff --git a/client/src/components/inventory.tsx b/client/src/components/inventory.tsx index c379859..95a5980 100644 --- a/client/src/components/inventory.tsx +++ b/client/src/components/inventory.tsx @@ -90,21 +90,24 @@ function InventoryList({items, docType, openDoc, defaultTab=null, level=undefine (x, y) => +(docType == "Lemma") * (+x.locked - +y.locked || +x.disabled - +y.disabled) || x.displayName.localeCompare(y.displayName) ).filter(item => !item.hidden && ((tab ?? categories[0]) == item.category)).map((item, i) => { return {openDoc({name: item.name, type: docType})}} name={item.name} displayName={item.displayName} locked={difficulty > 0 ? item.locked : false} - disabled={item.disabled} newly={item.new} enableAll={enableAll}/> + disabled={item.disabled} newly={item.new} enableAll={enableAll} /> }) } } -function InventoryItem({name, displayName, locked, disabled, newly, showDoc, enableAll=false}) { +function InventoryItem({item, name, displayName, locked, disabled, newly, showDoc, enableAll=false}) { const icon = locked ? : - disabled ? : "" + disabled ? : item.st const className = locked ? "locked" : disabled ? "disabled" : newly ? "new" : "" + // Note: This is somewhat a hack as the statement of lemmas comes currently in the form + // `Namespace.statement_name (x y : Nat) : some type` const title = locked ? "Not unlocked yet" : - disabled ? "Not available in this level" : "" + disabled ? "Not available in this level" : item.altTitle.substring(item.altTitle.indexOf(' ') + 1) const [copied, setCopied] = useState(false) diff --git a/client/src/state/api.ts b/client/src/state/api.ts index 2bdbe8b..1a64597 100644 --- a/client/src/state/api.ts +++ b/client/src/state/api.ts @@ -35,6 +35,7 @@ export interface InventoryTile { locked: boolean, new: boolean, hidden: boolean + altTitle: string, } export interface LevelInfo { diff --git a/server/GameServer/Commands.lean b/server/GameServer/Commands.lean index 8bd5fd5..a12a94a 100644 --- a/server/GameServer/Commands.lean +++ b/server/GameServer/Commands.lean @@ -781,6 +781,7 @@ elab "MakeGame" : command => do name := item displayName := data.displayName category := data.category + altTitle := data.statement hidden := hiddenItems.contains item }) @@ -800,6 +801,7 @@ elab "MakeGame" : command => do displayName := data.displayName category := data.category locked := false + altTitle := data.statement hidden := hiddenItems.contains item } itemsInWorld := itemsInWorld.insert worldId items @@ -819,6 +821,7 @@ elab "MakeGame" : command => do displayName := data.displayName category := data.category locked := false + altTitle := data.statement hidden := hiddenItems.contains item } -- add the exercise statement from the previous level @@ -832,6 +835,7 @@ elab "MakeGame" : command => do name := name displayName := data.displayName category := data.category + altTitle := data.statement locked := false } -- add marks for `disabled` and `new` lemmas here, so that they only apply to diff --git a/server/GameServer/EnvExtensions.lean b/server/GameServer/EnvExtensions.lean index fdbd351..d2fa975 100644 --- a/server/GameServer/EnvExtensions.lean +++ b/server/GameServer/EnvExtensions.lean @@ -106,6 +106,8 @@ structure InventoryTile where new := false /-- hide the item in the inventory display -/ hidden := false + /-- hover text -/ + altTitle : String := default deriving ToJson, FromJson, Repr, Inhabited def InventoryItem.toTile (item : InventoryItem) : InventoryTile := {