示例#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
}
示例#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()
}
示例#3
0
文件: intro.go 项目: karlek/reason
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()
}
示例#4
0
文件: intro.go 项目: karlek/reason
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)
}
示例#5
0
文件: intro.go 项目: karlek/reason
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)
}
示例#6
0
文件: intro.go 项目: karlek/reason
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)
}
示例#7
0
文件: intro.go 项目: karlek/reason
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()
}
示例#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
}
示例#9
0
func emptyInvMsg() {
	t := text.New(emptyInv, termbox.ColorWhite+termbox.AttrBold)
	ui.Print(t, 0, 0, ui.Whole.Width)
}
示例#10
0
func invTitle(title string) {
	t := text.New(title, termbox.ColorWhite+termbox.AttrBold)
	ui.Print(t, 0, 0, ui.Whole.Width)
}