-
Notifications
You must be signed in to change notification settings - Fork 1
/
CreditsModal.gd
47 lines (38 loc) · 1.64 KB
/
CreditsModal.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
extends Node2D
class_name CreditsModal
onready var gamelogic = get_tree().get_root().find_node("LevelScene", true, false).gamelogic;
onready var holder : Label = get_node("Holder");
onready var pointer : Sprite = get_node("Holder/Pointer");
onready var okbutton : Button = get_node("Holder/OkButton");
onready var linklabel : RichTextLabel = get_node("Holder/LinkLabel");
func _ready() -> void:
okbutton.connect("pressed", self, "destroy");
okbutton.grab_focus();
linklabel.connect("meta_clicked", self, "_meta_clicked");
func _meta_clicked(meta):
OS.shell_open(meta);
func destroy() -> void:
self.queue_free();
gamelogic.ui_stack.erase(self);
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if (gamelogic.ui_stack.size() > 0 and gamelogic.ui_stack[gamelogic.ui_stack.size() - 1] != self):
return;
if (Input.is_action_just_pressed("escape")):
destroy();
return;
var focus = holder.get_focus_owner();
if (focus == null):
okbutton.grab_focus();
focus = okbutton;
var focus_middle_x = round(focus.rect_position.x + focus.rect_size.x / 2);
pointer.position.y = round(focus.rect_position.y + focus.rect_size.y / 2);
if (focus_middle_x > holder.rect_size.x / 2):
pointer.texture = preload("res://assets/tutorial_arrows/LeftArrow.tres");
pointer.position.x = round(focus.rect_position.x + focus.rect_size.x + 12);
else:
pointer.texture = preload("res://assets/tutorial_arrows/RightArrow.tres");
pointer.position.x = round(focus.rect_position.x - 12);
func _draw() -> void:
draw_rect(Rect2(0, 0,
gamelogic.pixel_width, gamelogic.pixel_height), Color(0, 0, 0, 0.5), true);