-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.gd
62 lines (50 loc) · 1.82 KB
/
Menu.gd
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
extends CanvasLayer
const PokemonPartyScreen = preload("res://PokemonPartyScreen.tscn")
onready var select_arrow = $Control/NinePatchRect/TextureRect
onready var menu = $Control
enum ScreenLoaded { NOTHING, JUST_MENU, PARTY_SCREEN }
var screen_loaded = ScreenLoaded.NOTHING
var selected_option: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
menu.visible = false
select_arrow.rect_position.y = 6 + (selected_option % 6) * 14
func load_party_screen():
menu.visible = false
screen_loaded = ScreenLoaded.PARTY_SCREEN
var party_screen = PokemonPartyScreen.instance()
add_child(party_screen)
func unload_party_screen():
menu.visible = true
screen_loaded = ScreenLoaded.JUST_MENU
remove_child($PokemonPartyScreen)
func _unhandled_input(event):
match screen_loaded:
ScreenLoaded.NOTHING:
if event.is_action_pressed("menu"):
var player = Utils.get_player()
if !player.is_moving:
pass
player.set_physics_process(false)
menu.visible = true
screen_loaded = ScreenLoaded.JUST_MENU
ScreenLoaded.JUST_MENU:
if event.is_action_pressed("menu") or event.is_action_pressed("b"):
var player = Utils.get_player()
player.set_physics_process(true)
menu.visible = false
screen_loaded = ScreenLoaded.NOTHING
elif event.is_action_pressed("ui_down"):
selected_option += 1
select_arrow.rect_position.y = 6 + (selected_option % 6) * 14
elif event.is_action_pressed("ui_up"):
if selected_option == 0:
selected_option = 5
else:
selected_option -= 1
select_arrow.rect_position.y = 6 + (selected_option % 6) * 14
elif event.is_action_pressed("a"):
Utils.get_scene_manager().transition_to_party_screen()
ScreenLoaded.PARTY_SCREEN:
if event.is_action_pressed("b"):
Utils.get_scene_manager().transition_exit_party_screen()