-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_menu.go
50 lines (39 loc) · 1.29 KB
/
game_menu.go
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
package main
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
)
type GameMenu struct {
GenericWidgetContainerScreen
gameplayScreen *GameplayScreen
}
func (s *GameMenu) ProcessKeyEvents() bool {
if s.GenericWidgetContainerScreen.ProcessKeyEvents() {
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
s.gameplayScreen.overlayStack.Pop()
}
}
return false
}
func CreateGameMenu(s *GameplayScreen) *GameMenu {
gm := new(GameMenu)
gm.gameplayScreen = s
g := s.game
gm.game = g
gm.title = "Paused"
gm.widgets = append(gm.widgets, CreateCommonButton(g, I18n("string_resume_game", "Resume Game"), func(g *Game) {
s.overlayStack.Pop()
}))
gm.widgets = append(gm.widgets, CreateCommonButton(g, I18n("string_save_level", "Save Level"), func(g *Game) {
s.overlayStack.Push(CreateSaveLevelScreen(s))
}))
gm.widgets = append(gm.widgets, CreateCommonButton(g, I18n("string_settings", "Settings"), func(g *Game) {
s.overlayStack.Push(CreateSettingsScreen(s))
}))
gm.widgets = append(gm.widgets, CreateCommonButton(g, I18n("string_main_menu", "Main Menu"), func(g *Game) {
s.game.SetScreen(CreateMainMenu(s.game))
}))
gm.widgets[0].SetSelection(true)
gm.focusedWidget = gm.widgets[0]
return gm
}