Exemple #1
0
func printCategory(catStr string, items []*text.Text, rowOffset *int) {
	cat := text.New(catStr, termbox.ColorCyan+termbox.AttrBold)
	ui.Print(cat, 0, *rowOffset+ui.Inventory.YOffset, ui.Whole.Width)
	*rowOffset = *rowOffset + 1

	// Items in that category.
	for _, t := range items {
		ui.Print(t, ui.Inventory.XOffset, *rowOffset+ui.Inventory.YOffset, ui.Whole.Width)
		*rowOffset = *rowOffset + 1
	}

	// Empty line.
	*rowOffset = *rowOffset + 1
}
Exemple #2
0
func PrintLong(msg []string, yoffset int) {
	for y, m := range msg {
		t := text.New(m, termbox.ColorWhite)
		ui.Print(t, 0, y+yoffset, ui.Inventory.Width)
	}
	termbox.Flush()
}
Exemple #3
0
func printEnterSign() {
	width, height := termbox.Size()

	msgPos := width/2 + len(journeyStr)/2
	t := text.New("↵", termbox.AttrBold)
	ui.Print(t, msgPos+1, height/2, 0)
	termbox.Flush()
}
Exemple #4
0
func printNameQuestion() {
	width, height := termbox.Size()

	offsetY := height/2 + 2
	msgPos := width/2 - len(journeyStr)/2

	t := text.New(nameStr, termbox.AttrBold)
	ui.Print(t, msgPos, offsetY, 0)
}
Exemple #5
0
func printJourney() {
	width, height := termbox.Size()
	msgPos := width/2 - len(journeyStr)/2

	ui.ClearLineOffset(height/2, msgPos)

	t := text.New(journeyStr, termbox.AttrBold)
	ui.Print(t, msgPos, height/2, 0)
}
Exemple #6
0
func printName() {
	width, height := termbox.Size()

	offsetX := width/2 - len(nameStr)/2
	offsetY := height/2 + 2
	ui.ClearLineOffset(offsetY, offsetX)

	t := text.New(name, termbox.AttrBold+termbox.ColorBlack)
	ui.Print(t, offsetX+1, offsetY, 0)
}
Exemple #7
0
func printLogo() {
	width, height := termbox.Size()
	logoH := 12
	logoW := 82

	for x := 0; x < logoW; x++ {
		for y := 0; y < logoH; y++ {
			t := text.New(string(logo[y*logoW+x]), termbox.ColorRed)
			ui.Print(t, width/2-logoW/2+x, height/2-15+y, 0)
		}
	}
	termbox.Flush()
}
Exemple #8
0
func ShowItemDetails(i item.Itemer, a *area.Area) bool {
	ui.Clear()

	// Print item title.
	msgs := makeDrawable(fmt.Sprintf("%c - %s", i.Hotkey(), i.Name()))
	PrintLong(msgs, 0)
	rows := len(msgs)

	// Print flavor text.
	msgs = makeDrawable(i.FlavorText())
	PrintLong(msgs, rows)
	rows += len(msgs)

	// Print flavor text.
	msgs = makeDrawable(StringEffects(i.Effects()))
	PrintLong(msgs, rows)
	rows += len(msgs)

	actionStr := dropAction
	if item.IsEquipable(i) && !creature.Hero.IsEquipped(i) {
		actionStr += " You can (e)quip this " + strings.ToLower(i.Cat()) + "."
	}
	if creature.Hero.IsEquipped(i) {
		actionStr += " You can (r)emove this " + strings.ToLower(i.Cat()) + "."
	}
	if item.IsUsable(i) {
		actionStr += " You can (u)se this " + strings.ToLower(i.Cat()) + "."
	}

	msgs = makeDrawable(actionStr)
	for y, m := range msgs {
		t := text.New(m, termbox.ColorCyan)
		ui.Print(t, ui.Inventory.XOffset, y+rows, ui.Inventory.Width)
	}

	termbox.Flush()

itemDetailLoop:
	for {
		switch detailsEvent := termbox.PollEvent(); detailsEvent.Type {
		case termbox.EventKey:
			if detailsEvent.Key == ui.CancelKey {
				break itemDetailLoop
			}

			switch string(detailsEvent.Ch) {
			case string(ui.DropItemKey):
				creature.Hero.DropItem(i.Hotkey(), a)
				return true
			case string(ui.EquipItemKey):
				NarrativeEquip(i.Hotkey())
				return true
			case string(ui.UseItemKey):
				NarrativeUse(i.Hotkey())
				return true
			case string(ui.UnEquipItemKey):
				NarrativeUnEquip(i.Hotkey())
				return true
			}
		}
	}
	return false
}
Exemple #9
0
func emptyInvMsg() {
	t := text.New(emptyInv, termbox.ColorWhite+termbox.AttrBold)
	ui.Print(t, 0, 0, ui.Whole.Width)
}
Exemple #10
0
func invTitle(title string) {
	t := text.New(title, termbox.ColorWhite+termbox.AttrBold)
	ui.Print(t, 0, 0, ui.Whole.Width)
}