diff options
Diffstat (limited to 'go/ui/choice.go')
| -rw-r--r-- | go/ui/choice.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/go/ui/choice.go b/go/ui/choice.go index 003c2a6a..bacc6657 100644 --- a/go/ui/choice.go +++ b/go/ui/choice.go @@ -1,8 +1,11 @@ package ui import ( + "fmt" + "github.com/hajimehoshi/ebiten/v2" "muhq.space/muhqs-game/go/game" + "muhq.space/muhqs-game/go/utils" ) type Choice struct { @@ -59,14 +62,21 @@ func (c *Choice) Render() *ebiten.Image { return nil } -func NewActionChoice(x, y int, actions []game.Action, onClick func(*Choice, int, int)) *Choice { +func NewObjectChoice(x, y int, objs []interface{}, onClick func(*Choice, int, int)) *Choice { // TODO: use dynamic with width and height width := 200 choiceHeight := 40 - labels := make([]string, 0, len(actions)) - for _, action := range actions { - labels = append(labels, action.String()) + labels := make([]string, 0, len(objs)) + for _, obj := range objs { + labels = append(labels, fmt.Sprintf("%v", obj)) } - return NewChoice(x, y, width, choiceHeight, labels, onClick) } + +func NewActionChoice(x, y int, actions []game.Action, onClick func(*Choice, int, int)) *Choice { + return NewObjectChoice(x, y, utils.TypedSliceToInterfaceSlice(actions), onClick) +} + +func NewPermChoice(x, y int, perms []game.Permanent, onClick func(*Choice, int, int)) *Choice { + return NewObjectChoice(x, y, utils.TypedSliceToInterfaceSlice(perms), onClick) +} |
