-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVictoryMenu.adept
52 lines (41 loc) · 1.56 KB
/
VictoryMenu.adept
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
import 'main.adept'
struct VictoryMenu (
is_ok_button_hovered bool
) {
func setup {}
func enter {}
func exit {}
func __defer__ {
// Due to the compiler not yet automatically generating __defer__ functions
// via func& lookup, we have to manually ensure __defer__ is generated
}
func step {
captMouseViewPosition(undef mouseX float, undef mouseY float)
this.calculateWhetherOkButtonIsHovered(mouseX, mouseY)
}
func click(x, y float, button int){
unless button == 1, return
if this.calculateWhetherOkButtonIsHovered(x, y) {
gamedata.setScene('mainmenu')
soundtrack.fadeOutIntoNextSong()
sfx.play(sfx.button)
return
}
}
func draw {
drawButton("ok", this, func &getOkButtonPosition(*VictoryMenu, *float, *float), this.is_ok_button_hovered)
notice_message String = gamedata.gamekind != GameKind::ONLINE || gamedata.manager.getIsOnline() ? "Victory!" : "You are Offline"
unless notice_message.empty() {
drawTextCentered(notice_message)
return
}
}
func getOkButtonPosition(out x, y *float){
*x = 16.0f
*y = captViewHeight() - 16.0f - MAIN_MENU_BUTTON_HEIGHT
}
func calculateWhetherOkButtonIsHovered(mouseX, mouseY float) bool {
this.is_ok_button_hovered = isButtonHovered(this, func &getOkButtonPosition(*VictoryMenu, *float, *float), mouseX, mouseY)
return this.is_ok_button_hovered
}
}