-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfileMenu.adept
48 lines (37 loc) · 1.48 KB
/
ProfileMenu.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
import 'main.adept'
struct ProfileMenu (
is_back_button_hovered bool
) {
func setup {
this.is_back_button_hovered = false
}
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.is_back_button_hovered = isButtonHovered(this, func &getBackButtonPosition(*ProfileMenu, *float, *float), mouseX, mouseY)
}
func click(mouseX, mouseY float, button int){
unless button == 1, return
this.is_back_button_hovered = isButtonHovered(this, func &getBackButtonPosition(*ProfileMenu, *float, *float), mouseX, mouseY)
if this.is_back_button_hovered {
gamedata.setScene('optionsmenu')
sfx.play(sfx.back)
return
}
}
func draw {
captMouseViewPosition(undef mouseX float, undef mouseY float)
drawTextCentered("Name: " + gamedata.player_name, captViewWidth() / 2.0f, captViewHeight() / 2.0f)
this.getBackButtonPosition(undef back_x float, undef back_y float)
drawButton("back", back_x, back_y, this.is_back_button_hovered)
}
func getBackButtonPosition(out x, y *float){
*x = 16.0f
*y = captViewHeight() - 16.0f - MAIN_MENU_BUTTON_HEIGHT
}
}