Refactor help menu
This commit is contained in:
parent
e1f3488c4c
commit
2cd92e147e
|
@ -45,7 +45,11 @@ func NewHelpMenu() *HelpMenu {
|
|||
}
|
||||
|
||||
func (self *HelpMenu) Resize(termWidth, termHeight int) {
|
||||
textWidth := 53
|
||||
var textWidth = 0
|
||||
for _, line := range strings.Split(KEYBINDS, "\n") {
|
||||
textWidth = maxInt(len(line), textWidth)
|
||||
}
|
||||
textWidth += 2
|
||||
textHeight := 22
|
||||
x := (termWidth - textWidth) / 2
|
||||
y := (termHeight - textHeight) / 2
|
||||
|
@ -65,3 +69,10 @@ func (self *HelpMenu) Draw(buf *ui.Buffer) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func maxInt(a int, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user