MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / buildStorageText

Function buildStorageText

modules/storage/storage.go:417–438  ·  view source on GitHub ↗

buildStorageText renders the storage listing for the player using a panel.

(itemNames []string)

Source from the content-addressed store, hash-verified

415
416// buildStorageText renders the storage listing for the player using a panel.
417func buildStorageText(itemNames []string) string {
418 layout, err := templates.LoadPanelLayout("storage/storage")
419 if err != nil {
420 layout = templates.NewPanelLayout("open", "single", 1, 1)
421 layout.AddPanelsToSlot(layout.AddSlot(), "storage")
422 layout.Panel("storage").SetTitle(` <ansi fg="black-bold">.:</ansi><ansi fg="20">In Storage</ansi> `).SetWidth(78)
423 }
424
425 panel := layout.Panel("storage")
426 if len(itemNames) == 0 {
427 panel.Add(``, ``, `Nothing`)
428 } else {
429 for i, name := range itemNames {
430 panel.Add(``, ``,
431 fmt.Sprintf(`<ansi fg="cyan">%d.</ansi> <ansi fg="itemname">%s</ansi>`, i+1, name),
432 )
433 }
434 }
435
436 return layout.Render() + term.CRLFStr +
437 ` <ansi fg="command">unstore [itemname]</ansi> or <ansi fg="command">unstore [#]</ansi> to remove items from storage.` + term.CRLFStr
438}

Callers 1

storageCommandMethod · 0.85

Calls 9

LoadPanelLayoutFunction · 0.92
NewPanelLayoutFunction · 0.92
AddPanelsToSlotMethod · 0.80
AddSlotMethod · 0.45
SetWidthMethod · 0.45
SetTitleMethod · 0.45
PanelMethod · 0.45
AddMethod · 0.45
RenderMethod · 0.45

Tested by

no test coverage detected