Intro
This commit is contained in:
parent
ffb63bfbdf
commit
f4db104fc8
BIN
assets/sounds/intro.mp4
Normal file
BIN
assets/sounds/intro.mp4
Normal file
Binary file not shown.
BIN
assets/sounds/intro.ogv
Normal file
BIN
assets/sounds/intro.ogv
Normal file
Binary file not shown.
1
assets/sounds/intro.ogv.uid
Normal file
1
assets/sounds/intro.ogv.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dlnyxbrvfejbi
|
||||
@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Randoloot"
|
||||
run/main_scene="res://scenes/ui/main_menu.tscn"
|
||||
run/main_scene="res://scenes/ui/intro.tscn"
|
||||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
|
||||
52
scenes/ui/intro.tscn
Normal file
52
scenes/ui/intro.tscn
Normal file
@ -0,0 +1,52 @@
|
||||
[gd_scene load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/ui/intro.gd" id="1"]
|
||||
[ext_resource type="VideoStream" path="res://assets/sounds/intro.ogv" id="2"]
|
||||
|
||||
[node name="Intro" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
|
||||
[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, 0, 0, 1)
|
||||
|
||||
[node name="VideoAspect" type="AspectRatioContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
ratio = 1.7777778
|
||||
stretch_mode = 2
|
||||
|
||||
[node name="Video" type="VideoStreamPlayer" parent="VideoAspect"]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
stream = ExtResource("2")
|
||||
expand = true
|
||||
|
||||
[node name="SkipHint" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -42.0
|
||||
offset_bottom = -12.0
|
||||
mouse_filter = 2
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 0.8)
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 4
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "SPACJA — pomiń intro"
|
||||
horizontal_alignment = 1
|
||||
26
scripts/ui/intro.gd
Normal file
26
scripts/ui/intro.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends Control
|
||||
|
||||
const MENU := "res://scenes/ui/main_menu.tscn"
|
||||
@onready var video: VideoStreamPlayer = $VideoAspect/Video
|
||||
var _finished := false
|
||||
|
||||
func _ready() -> void:
|
||||
video.finished.connect(_finish_intro)
|
||||
video.play()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.echo and (event.physical_keycode == KEY_SPACE or event.keycode == KEY_SPACE):
|
||||
get_viewport().set_input_as_handled()
|
||||
_finish_intro()
|
||||
|
||||
func _finish_intro() -> void:
|
||||
if _finished:
|
||||
return
|
||||
_finished = true
|
||||
video.stop()
|
||||
_open_menu.call_deferred()
|
||||
|
||||
func _open_menu() -> void:
|
||||
var error := get_tree().change_scene_to_file(MENU)
|
||||
if error != OK:
|
||||
push_error("Nie udało się otworzyć menu: %s" % error_string(error))
|
||||
1
scripts/ui/intro.gd.uid
Normal file
1
scripts/ui/intro.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bsnbx40kgxhct
|
||||
28
tests/ships/intro_test.gd
Normal file
28
tests/ships/intro_test.gd
Normal file
@ -0,0 +1,28 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
for skip in [true, false]:
|
||||
var intro := preload("res://scenes/ui/intro.tscn").instantiate() as Control
|
||||
get_tree().root.add_child.call_deferred(intro)
|
||||
await get_tree().process_frame
|
||||
get_tree().current_scene = intro
|
||||
await get_tree().create_timer(0.3).timeout
|
||||
var video := intro.get_node("VideoAspect/Video") as VideoStreamPlayer
|
||||
assert(video.is_playing())
|
||||
assert(video.stream is VideoStreamTheora)
|
||||
assert(video.get_video_texture().get_width() == 1920)
|
||||
if skip:
|
||||
var event := InputEventKey.new()
|
||||
event.physical_keycode = KEY_SPACE
|
||||
event.pressed = true
|
||||
Input.parse_input_event(event)
|
||||
else:
|
||||
video.finished.emit()
|
||||
for frame in 5:
|
||||
await get_tree().process_frame
|
||||
assert(get_tree().current_scene.scene_file_path == "res://scenes/ui/main_menu.tscn")
|
||||
assert(get_tree().current_scene.get_node("ShipSelectionPanel").visible == false)
|
||||
get_tree().current_scene.queue_free()
|
||||
await get_tree().process_frame
|
||||
print("INTRO_TEST: PASS Theora playback and decoded frame, Space skip, finished signal -> menu")
|
||||
get_tree().quit()
|
||||
1
tests/ships/intro_test.gd.uid
Normal file
1
tests/ships/intro_test.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c0u13w0bfs5ry
|
||||
4
tests/ships/intro_test.tscn
Normal file
4
tests/ships/intro_test.tscn
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[ext_resource type="Script" path="res://tests/ships/intro_test.gd" id="1"]
|
||||
[node name="IntroTest" type="Node"]
|
||||
script = ExtResource("1")
|
||||
Loading…
x
Reference in New Issue
Block a user