Some code organization
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
extends Control
|
||||
|
||||
|
||||
signal back
|
||||
|
||||
|
||||
@export var scroll_speed: float = 25.0
|
||||
|
||||
|
||||
@onready var main_menu_button := $BackButton
|
||||
@onready var text := $Text
|
||||
@onready var tween: Tween
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
main_menu_button.grab_focus()
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if not is_node_ready(): return
|
||||
if not visible: return
|
||||
|
||||
main_menu_button.grab_focus()
|
||||
|
||||
_start_scrolling()
|
||||
|
||||
|
||||
func _start_scrolling() -> void:
|
||||
var start_pos := Vector2(0, get_viewport_rect().size.y)
|
||||
var end_pos := Vector2(0, -text.size.y)
|
||||
var duration := (start_pos.y - end_pos.y) / scroll_speed
|
||||
|
||||
text.position = start_pos
|
||||
|
||||
tween = create_tween()
|
||||
tween.tween_property(text, "position:y", end_pos.y, duration)
|
||||
tween.finished.connect(_on_scroll_finished)
|
||||
|
||||
|
||||
func _on_back_button_pressed() -> void:
|
||||
if tween:
|
||||
tween.kill()
|
||||
|
||||
SoundManager.play_ui_stream(SoundManager.ui_stream_decline)
|
||||
back.emit()
|
||||
|
||||
|
||||
func _on_scroll_finished() -> void:
|
||||
back.emit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://dclkpithyykju
|
||||
@@ -0,0 +1,81 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://c3q3g2647qc27"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dclkpithyykju" path="res://game/menu/main/credits.gd" id="1_wp78b"]
|
||||
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://styles/menu_theme.tres" id="2_nidem"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_wp78b"]
|
||||
action = &"ui_cancel"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_nidem"]
|
||||
events = [SubResource("InputEventAction_wp78b")]
|
||||
|
||||
[node name="Credits" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_right = 304.0
|
||||
offset_bottom = 444.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_wp78b")
|
||||
|
||||
[node name="BackButton" type="Button" parent="."]
|
||||
z_index = 100
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -42.0
|
||||
offset_top = -44.0
|
||||
offset_right = 42.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("2_nidem")
|
||||
shortcut = SubResource("Shortcut_nidem")
|
||||
text = "Back"
|
||||
|
||||
[node name="Text" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -152.0
|
||||
offset_top = -222.0
|
||||
offset_right = 152.0
|
||||
offset_bottom = 174.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_nidem")
|
||||
text = "PROGRAMMING
|
||||
|
||||
|
||||
Ruslan Ignatov
|
||||
|
||||
|
||||
|
||||
DEGIGN AND GRAPHICS
|
||||
|
||||
|
||||
Ruslan Ignatov
|
||||
|
||||
|
||||
|
||||
PLAY TESTING
|
||||
|
||||
|
||||
Daniil Ivashchenko
|
||||
|
||||
Fedor Daragan
|
||||
"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="BackButton" to="." method="_on_back_button_pressed"]
|
||||
@@ -3,8 +3,8 @@
|
||||
[ext_resource type="Script" uid="uid://bqnepsuk13qo8" path="res://game/menu/main/title_screen.gd" id="1_lxdol"]
|
||||
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://styles/menu_theme.tres" id="2_4xt7k"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxlccevt52y70" path="res://game/menu/main/main_menu.tscn" id="2_o0rbc"]
|
||||
[ext_resource type="PackedScene" uid="uid://btr60idiit4y7" path="res://game/menu/common/options.tscn" id="3_88gnj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3q3g2647qc27" path="res://game/menu/common/credits.tscn" id="4_w1y3c"]
|
||||
[ext_resource type="PackedScene" uid="uid://btr60idiit4y7" path="res://game/menu/options/options.tscn" id="3_88gnj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3q3g2647qc27" path="res://game/menu/main/credits.tscn" id="4_w1y3c"]
|
||||
[ext_resource type="PackedScene" uid="uid://chdrjc7c6bdpb" path="res://game/entities/world/background.tscn" id="5_88gnj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c36n317rhv8k7" path="res://game/menu/main/seed_selection_menu.tscn" id="5_w1y3c"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user