buildStorageText renders the storage listing for the player using a panel.
(itemNames []string)
| 415 | |
| 416 | // buildStorageText renders the storage listing for the player using a panel. |
| 417 | func 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 | } |
no test coverage detected