-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstartmenu.go
More file actions
67 lines (56 loc) · 1.68 KB
/
startmenu.go
File metadata and controls
67 lines (56 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"github.com/bennicholls/tyumi"
"github.com/bennicholls/tyumi/event"
"github.com/bennicholls/tyumi/gfx/ui"
"github.com/bennicholls/tyumi/input"
"github.com/bennicholls/tyumi/vec"
)
type StartMenu struct {
tyumi.Scene
menu ui.List
stars StarField
}
func (sm *StartMenu) Init() {
sm.Scene.Init()
title := ui.NewTitleTextbox(vec.Dims{ui.FIT_TEXT, 1}, vec.Coord{0, 10}, 1, "SPACE SHIPPERS: The Ones Who Space Ship!")
sm.Window().AddChild(title)
title.CenterHorizontal()
sm.menu.Init(vec.Dims{16, 5}, vec.Coord{0, 0}, 1)
sm.menu.EnableBorder()
sm.Window().AddChild(&sm.menu)
sm.menu.Center()
sm.menu.InsertText(ui.JUSTIFY_CENTER, "New Game", "Load Game", "Ship Designer", "Options", "Quit")
sm.menu.EnableHighlight()
sm.menu.Focus()
sm.stars.Init(vec.Dims{96, 54}, vec.ZERO_COORD, 0, 25, 10)
sm.Window().AddChildren(&sm.stars)
sm.SetKeypressHandler(sm.HandleKeypress)
}
func (sm *StartMenu) HandleKeypress(key_event *input.KeyboardEvent) (event_handled bool) {
if key_event.Handled() {
return
}
switch key_event.Key {
case input.K_RETURN:
switch sm.menu.GetSelectionIndex() {
case 0: //New Game
tyumi.ChangeScene(NewCreateGalaxyMenu())
case 1: //Load Game
//Load Game dialog
case 2: //Ship Designer
tyumi.ChangeScene(NewShipDesignMenu())
case 3: //Options
//Options Dialog
case 4: //Quit
event.FireSimple(tyumi.EV_QUIT)
}
case input.K_SPACE: //FOR TESTING PURPOSES ONLY DAMMIT
g := NewGalaxy("Test Galaxy", GAL_MAX_RADIUS, GAL_DENSE)
s := NewShip("The Greatest Spaceship There Is", g)
temp, _ := LoadShipTemplate("raws/ship/Transport Ship.shp")
s.SetupFromTemplate(temp)
tyumi.ChangeScene(NewSpaceshipGame(g, s))
}
return
}