Implemented credits scene
This commit is contained in:
35
GUI/Credits.gd
Normal file
35
GUI/Credits.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends CanvasLayer
|
||||
|
||||
export var credits_path: String = 'res://credits.txt'
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load_credits()
|
||||
return
|
||||
|
||||
|
||||
func _load_credits() -> void:
|
||||
var credits_file: File = File.new()
|
||||
assert(credits_file.file_exists(credits_path), 'Credits file does not exist')
|
||||
assert(credits_file.open(credits_path, File.READ) == OK, 'Credits file failed to open')
|
||||
|
||||
while not credits_file.eof_reached():
|
||||
var line: String = credits_file.get_line()
|
||||
if line == '':
|
||||
continue
|
||||
|
||||
var label: Label = Label.new()
|
||||
label.set_custom_minimum_size(Vector2(3200, 0))
|
||||
label.set_align(Label.ALIGN_CENTER)
|
||||
label.set_valign(Label.VALIGN_CENTER)
|
||||
label.set_autowrap(true)
|
||||
label.set_text(line)
|
||||
$'Credits/Credits Items'.add_child(label)
|
||||
credits_file.close()
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('ui_cancel'):
|
||||
queue_free()
|
||||
return
|
43
GUI/Credits.tscn
Normal file
43
GUI/Credits.tscn
Normal file
@@ -0,0 +1,43 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/Assets/Black_Background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://GUI/Credits.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Fonts/TheLittleBonjour.ttf" type="DynamicFontData" id=3]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 60
|
||||
extra_spacing_top = 30
|
||||
extra_spacing_bottom = 30
|
||||
extra_spacing_char = 2
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="Theme" id=2]
|
||||
default_font = SubResource( 1 )
|
||||
|
||||
[node name="Credits" type="CanvasLayer"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
light_mask = 0
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
rect_min_size = Vector2( 320, 180 )
|
||||
texture = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Credits" type="ScrollContainer" parent="."]
|
||||
rect_min_size = Vector2( 3200, 1800 )
|
||||
rect_scale = Vector2( 0.1, 0.1 )
|
||||
scroll_horizontal_enabled = false
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Credits Items" type="VBoxContainer" parent="Credits"]
|
||||
light_mask = 0
|
||||
margin_right = 3200.0
|
||||
margin_bottom = 1800.0
|
||||
rect_min_size = Vector2( 3200, 1800 )
|
||||
theme = SubResource( 2 )
|
@@ -2,12 +2,20 @@ extends CanvasLayer
|
||||
|
||||
signal complete(option)
|
||||
|
||||
export var credits_scene_path: String = 'res://GUI/Credits.tscn'
|
||||
|
||||
|
||||
func _on_new_game_button_pressed() -> void:
|
||||
emit_signal('complete', 'new game')
|
||||
return
|
||||
|
||||
|
||||
func _on_credits_button_pressed() -> void:
|
||||
var credits_scene: Node = load(credits_scene_path).instance()
|
||||
add_child(credits_scene)
|
||||
return
|
||||
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
return
|
||||
|
@@ -139,5 +139,6 @@ volume_db = -16.0
|
||||
[connection signal="pressed" from="Menu/Menu Elements/Menu Options/New Game/New Game Button" to="." method="_on_new_game_button_pressed"]
|
||||
[connection signal="mouse_entered" from="Menu/Menu Elements/Menu Options/Settings/Settings Button" to="." method="_on_settings_button_mouse_entered"]
|
||||
[connection signal="mouse_entered" from="Menu/Menu Elements/Menu Options/Credits/Credits Button" to="." method="_on_credits_button_mouse_entered"]
|
||||
[connection signal="pressed" from="Menu/Menu Elements/Menu Options/Credits/Credits Button" to="." method="_on_credits_button_pressed"]
|
||||
[connection signal="mouse_entered" from="Menu/Menu Elements/Menu Options/Quit/Quit Button" to="." method="_on_quit_button_mouse_entered"]
|
||||
[connection signal="pressed" from="Menu/Menu Elements/Menu Options/Quit/Quit Button" to="." method="_on_quit_button_pressed"]
|
||||
|
Reference in New Issue
Block a user