Menu de inicio, nuevo nivel y ajustes en objetos
This commit is contained in:
1 parent
cd9f31c8c1
commit
827e16cf50
61 files changed
+2685
-3553
No files matched your search
@@ -0,0 +1,90 @@
|
||||
extends Control
|
||||
|
||||
## Intro provisional. Los diez segundos son una presentacion, no progreso ficticio.
|
||||
## Se carga el menu en paralelo y nunca se salta una carga real pendiente.
|
||||
## Sustituir IntroContent por un video/animacion no obliga a cambiar el menu.
|
||||
const MENU_PATH: String = "res://ui/menu/main_menu.tscn"
|
||||
|
||||
@export_category("Intro")
|
||||
## La intro es saltable desde el primer arranque; no necesita un archivo de guardado.
|
||||
@export_range(0.0, 60.0, 0.5) var intro_duration_seconds: float = 10.0
|
||||
|
||||
@onready var status_label: Label = $Margin/IntroContent/Status
|
||||
@onready var skip_button: Button = $Margin/IntroContent/Skip
|
||||
|
||||
var _elapsed: float = 0.0
|
||||
var _skip_requested: bool = false
|
||||
var _leaving: bool = false
|
||||
var _load_failed: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$Margin/IntroContent/Hint.text = "Intro provisional de %g segundos" % intro_duration_seconds
|
||||
skip_button.pressed.connect(_on_skip_pressed)
|
||||
skip_button.grab_focus()
|
||||
_request_menu()
|
||||
|
||||
|
||||
## Inicia o reintenta la carga, sin bloquear el hilo que dibuja la intro.
|
||||
func _request_menu() -> void:
|
||||
_load_failed = false
|
||||
status_label.text = "Cargando..."
|
||||
skip_button.text = "SALTAR INTRO"
|
||||
skip_button.disabled = false
|
||||
var error: Error = ResourceLoader.load_threaded_request(MENU_PATH, "PackedScene")
|
||||
if error != OK:
|
||||
_show_error(error_string(error))
|
||||
else:
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _leaving or _load_failed:
|
||||
return
|
||||
_elapsed += delta
|
||||
var status: ResourceLoader.ThreadLoadStatus = ResourceLoader.load_threaded_get_status(MENU_PATH)
|
||||
if status == ResourceLoader.THREAD_LOAD_FAILED or status == ResourceLoader.THREAD_LOAD_INVALID_RESOURCE:
|
||||
_show_error("No se pudo cargar el menu.")
|
||||
return
|
||||
if not _skip_requested and _elapsed < intro_duration_seconds:
|
||||
return
|
||||
if status != ResourceLoader.THREAD_LOAD_LOADED:
|
||||
status_label.text = "Cargando el menu..."
|
||||
return
|
||||
var menu: PackedScene = ResourceLoader.load_threaded_get(MENU_PATH) as PackedScene
|
||||
if menu == null:
|
||||
_show_error("El recurso del menu no es una escena.")
|
||||
return
|
||||
_leaving = true
|
||||
var error: Error = get_tree().change_scene_to_packed(menu)
|
||||
if error != OK:
|
||||
_leaving = false
|
||||
_show_error(error_string(error))
|
||||
|
||||
|
||||
func _on_skip_pressed() -> void:
|
||||
_skip_requested = true
|
||||
if _load_failed:
|
||||
_request_menu()
|
||||
else:
|
||||
skip_button.disabled = true
|
||||
|
||||
|
||||
## Escape/atras hace lo mismo que el boton, pero no abandona una carga pendiente.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
_on_skip_pressed()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_WM_GO_BACK_REQUEST and is_node_ready():
|
||||
_on_skip_pressed()
|
||||
|
||||
|
||||
func _show_error(message: String) -> void:
|
||||
_load_failed = true
|
||||
set_process(false)
|
||||
status_label.text = "No se pudo abrir el menu.\n" + message
|
||||
skip_button.text = "REINTENTAR"
|
||||
skip_button.disabled = false
|
||||
+52
-4
@@ -1,7 +1,55 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://levels/test/combat_test.tscn" id="1_test"]
|
||||
[ext_resource type="Script" path="res://game/boot.gd" id="script"]
|
||||
[ext_resource type="Theme" path="res://ui/menu/menu_theme.tres" id="theme"]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
[node name="Boot" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("theme")
|
||||
script = ExtResource("script")
|
||||
|
||||
[node name="CombatTest" parent="." instance=ExtResource("1_test")]
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
color = Color(0.035, 0.045, 0.055, 1)
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme_override_constants/margin_left = 32
|
||||
theme_override_constants/margin_top = 24
|
||||
theme_override_constants/margin_right = 32
|
||||
theme_override_constants/margin_bottom = 24
|
||||
|
||||
[node name="IntroContent" type="VBoxContainer" parent="Margin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 24
|
||||
alignment = 1
|
||||
|
||||
[node name="Status" type="Label" parent="Margin/IntroContent"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 30
|
||||
text = "Cargando..."
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Hint" type="Label" parent="Margin/IntroContent"]
|
||||
layout_mode = 2
|
||||
text = "Intro provisional de 10 segundos"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Skip" type="Button" parent="Margin/IntroContent"]
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
layout_mode = 2
|
||||
text = "SALTAR INTRO"
|
||||
Reference in new issue
Block a user