131 lines
3.7 KiB
GDScript
131 lines
3.7 KiB
GDScript
extends Control
|
|
|
|
var display_text = """
|
|
STARTING Infiltrate.exe ...
|
|
MADE FOR GMTK GAME JAM 2024
|
|
---------------------------------------
|
|
|
|
>> SECURITY PROTOCOLS: ACTIVE
|
|
>> SCANNING FOR THREATS...
|
|
|
|
>> WARNING: UNAUTHORIZED ACCESS DETECTED
|
|
>> INITIALIZING COUNTERMEASURES...
|
|
|
|
PRESS START TO GET ACCESS.
|
|
|
|
"""
|
|
|
|
var current_text = ""
|
|
var char_index = 0
|
|
var typing_speed = 0.05
|
|
var fast_typing_speed = 0.0001
|
|
var last_click_time = 0.0
|
|
var double_click_time = 0.3
|
|
var is_typing = true
|
|
var current_button_index = 0
|
|
var buttons = []
|
|
|
|
func _ready():
|
|
for hbox in $VBoxContainer/Buttons.get_children():
|
|
hbox.visible = false
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
|
_initialize_menu()
|
|
_start_typing()
|
|
|
|
func _initialize_menu():
|
|
buttons = $VBoxContainer/Buttons.get_children()
|
|
_update_button_visibility()
|
|
_blink_current_button()
|
|
|
|
func _update_button_visibility():
|
|
for i in range(len(buttons)):
|
|
var hbox_container = buttons[i]
|
|
var label_node = hbox_container.get_child(0)
|
|
if label_node != null:
|
|
label_node.visible = (i == current_button_index)
|
|
|
|
func _blink_current_button() -> void:
|
|
while true:
|
|
var hbox_container = buttons[current_button_index]
|
|
var label_node = hbox_container.get_child(0)
|
|
if label_node != null:
|
|
label_node.visible = true
|
|
await get_tree().create_timer(0.5).timeout
|
|
if label_node != null:
|
|
label_node.visible = false
|
|
await get_tree().create_timer(0.5).timeout
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if is_typing:
|
|
if event is InputEventKey and event.is_pressed():
|
|
if get_time_since_last_click() <= double_click_time:
|
|
_show_full_text()
|
|
else:
|
|
typing_speed = fast_typing_speed
|
|
elif event is InputEventKey and not event.is_pressed():
|
|
typing_speed = 0.05
|
|
else:
|
|
if event.is_action_pressed("ui_down") or event.is_action_pressed("down"):
|
|
current_button_index = (current_button_index + 1) % buttons.size()
|
|
_update_button_visibility()
|
|
elif event.is_action_pressed("ui_up") or event.is_action_pressed("up"):
|
|
current_button_index = (current_button_index - 1 + buttons.size()) % buttons.size()
|
|
_update_button_visibility()
|
|
elif event.is_action_pressed("ui_accept"):
|
|
buttons[current_button_index].get_child(1).emit_signal("pressed")
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
if not is_typing:
|
|
if Input.is_action_pressed("ui_accept"):
|
|
typing_speed = fast_typing_speed
|
|
|
|
func _start_typing() -> void:
|
|
current_text = ""
|
|
char_index = 0
|
|
is_typing = true
|
|
_update_text()
|
|
|
|
func _update_text() -> void:
|
|
if char_index < display_text.length():
|
|
current_text += display_text[char_index]
|
|
$VBoxContainer/VBoxContainer2/Label.text = current_text
|
|
char_index += 1
|
|
await get_tree().create_timer(typing_speed).timeout
|
|
_update_text()
|
|
else:
|
|
is_typing = false
|
|
_show_menu_options()
|
|
|
|
func _show_menu_options() -> void:
|
|
for hbox in $VBoxContainer/Buttons.get_children():
|
|
hbox.visible = true
|
|
|
|
func _show_full_text() -> void:
|
|
current_text = display_text
|
|
$VBoxContainer/VBoxContainer2/Label.text = current_text
|
|
char_index = display_text.length()
|
|
is_typing = false
|
|
_show_menu_options()
|
|
|
|
func get_time_since_last_click() -> float:
|
|
var current_time = Time.get_ticks_msec() / 1000.0 # Zeit in Sekunden
|
|
var time_since_last_click = current_time - last_click_time
|
|
last_click_time = current_time
|
|
return time_since_last_click
|
|
|
|
func _on_start_button_pressed() -> void:
|
|
get_tree().change_scene_to_file("res://levels/level_1.tscn")
|
|
|
|
func _on_level_select_pressed():
|
|
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn")
|
|
|
|
func _on_credits_button_pressed() -> void:
|
|
get_tree().change_scene_to_file("res://menu/main_menu/CreditsScene.tscn")
|
|
|
|
func _on_quit_button_pressed() -> void:
|
|
$VBoxContainer/VBoxContainer2/Label.text += "Logging out!"
|
|
await get_tree().create_timer(0.5).timeout
|
|
get_tree().quit()
|