refactoring UI

This commit was merged in pull request #26.
This commit is contained in:
2026-06-01 09:03:31 +00:00
parent 50ea1d8bbd
commit dcf5d28248
62 changed files with 2088 additions and 489 deletions

View File

@@ -1,10 +1,8 @@
@tool
extends Control
extends Button
class_name ArrowButton
signal on_pressed
@export var image: Texture:
set(value):
image = value
@@ -24,6 +22,18 @@ func _ready():
$%Texture.flip_h = flip_h
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
on_pressed.emit()
func _on_pressed() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.PUNCH_IN):
return
TweenFX.punch_in(self)
func _on_mouse_entered() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.BREATHE):
return
TweenFX.breathe(self, 1)
func _on_mouse_exited() -> void:
TweenFX.stop(self, TweenFX.Animations.BREATHE)
scale = Vector2(1, 1)

View File

@@ -2,37 +2,44 @@
[ext_resource type="Texture2D" uid="uid://cm7fok7lhrano" path="res://core/game_menu/assets/page_1/freccetta.png" id="1_vbu0v"]
[ext_resource type="Script" uid="uid://3uxuhvua1036" path="res://core/game_menu/arrow_button.gd" id="2_xq7pl"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/game_menu/hoover_tween.tscn" id="3_hu4cn"]
[node name="ArrowButton" type="Control" unique_id=1696751730]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xq7pl"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hu4cn"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_fttf3"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_05bm2"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_kc324"]
[node name="ArrowButton" type="Button" unique_id=579258112]
custom_minimum_size = Vector2(101, 124)
layout_mode = 3
anchors_preset = -1
anchor_right = 0.052604165
anchor_bottom = 0.11481482
pivot_offset_ratio = Vector2(0.5, 0.5)
theme_override_styles/normal = SubResource("StyleBoxEmpty_xq7pl")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_hu4cn")
theme_override_styles/hover = SubResource("StyleBoxEmpty_fttf3")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_05bm2")
theme_override_styles/focus = SubResource("StyleBoxEmpty_kc324")
script = ExtResource("2_xq7pl")
image = ExtResource("1_vbu0v")
metadata/_edit_use_anchors_ = true
[node name="Texture" type="TextureRect" parent="." unique_id=91599097]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
pivot_offset = Vector2(0.5, 0.5)
script = ExtResource("2_xq7pl")
image = ExtResource("1_vbu0v")
[node name="Texture" type="TextureRect" parent="." unique_id=91599097]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.47369793
anchor_top = 0.4425926
anchor_right = 0.5263021
anchor_bottom = 0.5574074
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
mouse_filter = 2
texture = ExtResource("1_vbu0v")
metadata/_edit_use_anchors_ = true
[node name="HooverTween" parent="." unique_id=2115829120 node_paths=PackedStringArray("detector_node", "visual_node") instance=ExtResource("3_hu4cn")]
detector_node = NodePath("..")
visual_node = NodePath("../Texture")
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="." to="." method="_on_pressed"]

View File

@@ -32,6 +32,7 @@ texture = ExtResource("2_vudub")
stretch_mode = 5
[node name="HSlider" type="HSlider" parent="." unique_id=1286896253]
process_mode = 3
layout_mode = 2
theme_override_icons/grabber = ExtResource("3_vf41c")
theme_override_icons/grabber_highlight = ExtResource("3_vf41c")

View File

@@ -1,5 +1,5 @@
@tool
extends Control
extends Button
@export var locked: bool = true
@export var image: Texture:
@@ -13,10 +13,16 @@ extends Control
func _ready():
if image != null and has_node("%Texture"):
$%Texture.texture = image
if has_node("%TextureRect") and has_node("%HooverTween"):
if has_node("%TextureRect"):
if locked:
$%TextureRect.show()
$%HooverTween.queue_free()
else:
$%TextureRect.hide()
TweenFX.breathe(self, 1)
func _on_pressed() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.PRESS_ROTATE):
return
TweenFX.press_rotate(self)

View File

@@ -1,51 +1,82 @@
[gd_scene format=3 uid="uid://wckwvvnk8bt4"]
[ext_resource type="Script" uid="uid://c7q3d823b1v1h" path="res://core/game_menu/biome_picker.gd" id="1_jqji0"]
[ext_resource type="Texture2D" uid="uid://dc0sl04wem136" path="res://core/game_menu/assets/page_1/color_main_biome.png" id="2_8s4h5"]
[ext_resource type="Texture2D" uid="uid://dj6pt25w5i4jq" path="res://core/game_menu/assets/page_1/lucchetto.png" id="2_jqji0"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/game_menu/hoover_tween.tscn" id="4_8s4h5"]
[node name="BiomePicker" type="Control" unique_id=52821564]
layout_mode = 3
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_jqji0"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8s4h5"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ntcky"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_aj0ly"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sqe3j"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0slqm"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_idpud"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7dp31"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_le5rt"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rs8ck"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6gubq"]
[node name="BiomePicker" type="Button" unique_id=913478047]
custom_minimum_size = Vector2(161, 343)
anchors_preset = -1
anchor_right = 0.08385417
anchor_bottom = 0.3175926
offset_right = -153.0
offset_bottom = -335.0
pivot_offset_ratio = Vector2(0.5, 0.5)
theme_override_styles/normal = SubResource("StyleBoxEmpty_jqji0")
theme_override_styles/normal_mirrored = SubResource("StyleBoxEmpty_8s4h5")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_ntcky")
theme_override_styles/pressed_mirrored = SubResource("StyleBoxEmpty_aj0ly")
theme_override_styles/hover = SubResource("StyleBoxEmpty_sqe3j")
theme_override_styles/hover_mirrored = SubResource("StyleBoxEmpty_0slqm")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_idpud")
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxEmpty_7dp31")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_le5rt")
theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_rs8ck")
theme_override_styles/focus = SubResource("StyleBoxEmpty_6gubq")
script = ExtResource("1_jqji0")
image = ExtResource("2_8s4h5")
metadata/_edit_use_anchors_ = true
[node name="Texture" type="TextureRect" parent="." unique_id=606844933]
unique_name_in_owner = true
custom_minimum_size = Vector2(161, 343)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_jqji0")
[node name="Texture" type="TextureRect" parent="." unique_id=606844933]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.47161457
anchor_top = 0.39027777
anchor_right = 0.5283854
anchor_bottom = 0.6097222
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
texture = ExtResource("2_8s4h5")
stretch_mode = 3
metadata/_edit_use_anchors_ = true
[node name="TextureRect" type="TextureRect" parent="Texture" unique_id=288045010]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
anchors_preset = -1
anchor_left = 0.36645964
anchor_top = 0.41690964
anchor_right = 0.6335404
anchor_bottom = 0.58309036
offset_left = 1.5
offset_top = 8.5
offset_right = -1.5
offset_bottom = -8.5
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
texture = ExtResource("2_jqji0")
[node name="HooverTween" parent="." unique_id=160227524 node_paths=PackedStringArray("detector_node", "visual_node") instance=ExtResource("4_8s4h5")]
unique_name_in_owner = true
detector_node = NodePath("..")
visual_node = NodePath("../Texture")
scale_amount = Vector2(1.05, 1.05)
[connection signal="pressed" from="." to="." method="_on_pressed"]

View File

@@ -1,56 +1,60 @@
[gd_scene format=3 uid="uid://bc60gon7fmvbr"]
[ext_resource type="PackedScene" uid="uid://dm3skv22c60tm" path="res://core/game_menu/arrow_button.tscn" id="1_16l2d"]
[ext_resource type="Texture2D" uid="uid://dqqnfnero7ckl" path="res://core/game_menu/assets/page_1/chooseyourbiome_text.png" id="1_wyms5"]
[ext_resource type="PackedScene" uid="uid://wckwvvnk8bt4" path="res://core/game_menu/biome_picker.tscn" id="2_q1k23"]
[ext_resource type="Texture2D" uid="uid://cin3kt42e6w3u" path="res://core/game_menu/assets/page_1/color_sx_biome.png" id="2_xjika"]
[ext_resource type="Texture2D" uid="uid://dc0sl04wem136" path="res://core/game_menu/assets/page_1/color_main_biome.png" id="3_0noye"]
[ext_resource type="Texture2D" uid="uid://c3qcivnwuisju" path="res://core/game_menu/assets/page_1/color_dx_biome.png" id="4_0noye"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="6_hjy5b"]
[node name="BiomeSelector" type="HBoxContainer" unique_id=291322067]
offset_right = 700.0
offset_bottom = 400.0
[node name="VBoxContainer" type="VBoxContainer" unique_id=1692688717]
offset_right = 685.0
offset_bottom = 418.0
[node name="ChooseYourBiomeTexture" type="TextureRect" parent="." unique_id=1769445385]
layout_mode = 2
texture = ExtResource("1_wyms5")
stretch_mode = 3
[node name="Spacer" type="Control" parent="." unique_id=1648681786]
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
[node name="BiomeSelector" type="HBoxContainer" parent="." unique_id=291322067]
layout_mode = 2
theme_override_constants/separation = 0
alignment = 1
[node name="ArrowButtonLeft" parent="." unique_id=1696751730 instance=ExtResource("1_16l2d")]
[node name="ArrowButtonLeft" parent="BiomeSelector" unique_id=1696751730 instance=ExtResource("1_16l2d")]
layout_mode = 2
size_flags_vertical = 4
flip_h = true
[node name="HBoxContainer2" type="HBoxContainer" parent="." unique_id=1117886768]
[node name="HBoxContainer2" type="HBoxContainer" parent="BiomeSelector" unique_id=1117886768]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 0
alignment = 1
[node name="BiomePicker1" parent="HBoxContainer2" unique_id=477354740 instance=ExtResource("2_q1k23")]
[node name="BiomePicker1" parent="BiomeSelector/HBoxContainer2" unique_id=477354740 instance=ExtResource("2_q1k23")]
layout_mode = 2
size_flags_horizontal = 3
image = ExtResource("2_xjika")
[node name="BiomePicker2" parent="HBoxContainer2" unique_id=52821564 instance=ExtResource("2_q1k23")]
custom_minimum_size = Vector2(200, 400)
[node name="BiomePicker2" parent="BiomeSelector/HBoxContainer2" unique_id=52821564 instance=ExtResource("2_q1k23")]
layout_mode = 2
size_flags_horizontal = 3
locked = false
image = ExtResource("3_0noye")
[node name="Texture" parent="HBoxContainer2/BiomePicker2" index="0" unique_id=606844933]
texture = ExtResource("3_0noye")
[node name="TextureRect" parent="HBoxContainer2/BiomePicker2/Texture" index="0" unique_id=288045010]
visible = false
[node name="HooverTween" parent="HBoxContainer2/BiomePicker2" index="1" unique_id=160227524]
always_active = true
[node name="BiomePicker3" parent="HBoxContainer2" unique_id=1567545303 instance=ExtResource("2_q1k23")]
[node name="BiomePicker3" parent="BiomeSelector/HBoxContainer2" unique_id=1567545303 instance=ExtResource("2_q1k23")]
layout_mode = 2
size_flags_horizontal = 3
image = ExtResource("4_0noye")
[node name="ArrowButtonRight" parent="." unique_id=1741162553 instance=ExtResource("1_16l2d")]
[node name="ArrowButtonRight" parent="BiomeSelector" unique_id=1741162553 instance=ExtResource("1_16l2d")]
layout_mode = 2
size_flags_vertical = 4
[editable path="HBoxContainer2/BiomePicker2"]
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("targets") instance=ExtResource("6_hjy5b")]
unique_name_in_owner = true
targets = [NodePath("../BiomeSelector/ArrowButtonLeft"), NodePath("../BiomeSelector/HBoxContainer2/BiomePicker1"), NodePath("../BiomeSelector/HBoxContainer2/BiomePicker2"), NodePath("../BiomeSelector/HBoxContainer2/BiomePicker3"), NodePath("../BiomeSelector/ArrowButtonRight")]

View File

@@ -2,6 +2,7 @@
[ext_resource type="Script" uid="uid://dq3qtcrdnikl7" path="res://core/game_menu/collectible_gallery.gd" id="1_67tug"]
[ext_resource type="PackedScene" uid="uid://dp7dvfauh5rpx" path="res://core/game_menu/collectible_ui.tscn" id="2_or234"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="3_cvqb8"]
[node name="CollectibleGallery" type="Control" unique_id=354419843]
layout_mode = 3
@@ -46,3 +47,6 @@ layout_mode = 2
[node name="CollectibleUI6" parent="ScrollContainer/CollectibleGrid" unique_id=1566830281 instance=ExtResource("2_or234")]
layout_mode = 2
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("runtime_target_parent") instance=ExtResource("3_cvqb8")]
runtime_target_parent = NodePath("../ScrollContainer/CollectibleGrid")

View File

@@ -1,10 +1,8 @@
@tool
extends Control
extends Button
class_name TrainColorPicker
signal on_color_selected(color_picker: TrainColorPicker)
@export var image: Texture:
set(value):
image = value
@@ -23,18 +21,31 @@ func _ready():
color = img.get_pixel(0, 0)
else:
color = Color.BLACK
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
on_color_selected.emit(self)
$%Border.color.a = 0
func select() -> void:
if selected:
return
selected = true
$%Border.color.a = 1
TweenFX.press_rotate(self)
func deselect() -> void:
if !selected:
return
selected = false
$%Border.color.a = 0
func _on_mouse_entered() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.BREATHE):
return
TweenFX.breathe(self, 1)
func _on_mouse_exited() -> void:
TweenFX.stop(self, TweenFX.Animations.BREATHE)
scale = Vector2(1, 1)

View File

@@ -2,56 +2,74 @@
[ext_resource type="Texture2D" uid="uid://cdjwvwst3f10a" path="res://core/game_menu/assets/page_1/customizecolor-1.png" id="1_us0rx"]
[ext_resource type="Script" uid="uid://crfw5whcjs0du" path="res://core/game_menu/color_picker.gd" id="2_323rd"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/game_menu/hoover_tween.tscn" id="3_264kt"]
[node name="ColorPicker" type="Control" unique_id=409505029]
custom_minimum_size = Vector2(53, 53)
layout_mode = 3
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_323rd"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_264kt"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1folt"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tcqrg"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_kbu6n"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dk0pr"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_f16cj"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_s4jbd"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_2ocph"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5386i"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6pmjh"]
[node name="ColorPicker" type="Button" unique_id=1664685328]
custom_minimum_size = Vector2(60, 60)
anchors_preset = -1
anchor_right = 0.03125
anchor_bottom = 0.055555556
pivot_offset_ratio = Vector2(0.5, 0.5)
theme_override_styles/normal = SubResource("StyleBoxEmpty_323rd")
theme_override_styles/normal_mirrored = SubResource("StyleBoxEmpty_264kt")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_1folt")
theme_override_styles/pressed_mirrored = SubResource("StyleBoxEmpty_tcqrg")
theme_override_styles/hover = SubResource("StyleBoxEmpty_kbu6n")
theme_override_styles/hover_mirrored = SubResource("StyleBoxEmpty_dk0pr")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_f16cj")
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxEmpty_s4jbd")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_2ocph")
theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_5386i")
theme_override_styles/focus = SubResource("StyleBoxEmpty_6pmjh")
script = ExtResource("2_323rd")
image = ExtResource("1_us0rx")
metadata/_edit_use_anchors_ = true
[node name="Border" type="ColorRect" parent="." unique_id=1774696864]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("2_323rd")
image = ExtResource("1_us0rx")
[node name="Border" type="ColorRect" parent="." unique_id=1774696864]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -30.0
offset_top = -30.0
offset_right = 30.0
offset_bottom = 30.0
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
mouse_filter = 2
[node name="Texture" type="TextureRect" parent="Border" unique_id=329703623]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -26.5
offset_top = -26.5
offset_right = 26.5
offset_bottom = 26.5
anchors_preset = -1
anchor_left = 0.058333334
anchor_top = 0.058333334
anchor_right = 0.94166666
anchor_bottom = 0.94166666
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
mouse_filter = 2
texture = ExtResource("1_us0rx")
metadata/_edit_use_anchors_ = true
[node name="HooverTween" parent="." unique_id=160227524 node_paths=PackedStringArray("detector_node", "visual_node") instance=ExtResource("3_264kt")]
detector_node = NodePath("..")
visual_node = NodePath("../Border")
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="." to="." method="_on_pressed"]

View File

@@ -1,7 +1,8 @@
extends Control
@onready var tabs: Array[GameMenuTab] = [$%Tab1, $%Tab2, $%Tab3]
@onready var pages: Array[Control] = [$%Page1, $%Page2, $%Page3]
@onready var pages: Array[GameMenuPage] = [$%Page1, $%Page2, $%Page3]
func _ready() -> void:
for tab: GameMenuTab in tabs:
@@ -11,7 +12,7 @@ func _ready() -> void:
func on_tab_pressed(index: int, disable_animation: bool = false) -> void:
for page in pages:
page.hide()
page.hide_page()
for tab in tabs:
if tab.index == index:
@@ -25,7 +26,4 @@ func on_tab_pressed(index: int, disable_animation: bool = false) -> void:
else:
tab.deselect()
pages[index].show()
func _on_resume_button_on_button_pressed() -> void:
hide()
pages[index].show_page()

View File

@@ -17,17 +17,10 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
mouse_filter = 2
script = ExtResource("1_57vaj")
[node name="Panel" type="Panel" parent="." unique_id=992567199]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Tabs" type="HBoxContainer" parent="." unique_id=1745270897]
layout_mode = 1
offset_left = 1138.0
@@ -84,7 +77,5 @@ unique_name_in_owner = true
visible = false
layout_mode = 1
[connection signal="on_button_pressed" from="Pages/Page3/OptionMenu/VBoxContainer/ResumeButton" to="." method="_on_resume_button_on_button_pressed"]
[editable path="Pages/Page3"]
[editable path="Pages/Page3/OptionMenu"]

View File

@@ -25,6 +25,8 @@ func _ready():
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if is_selected:
return
on_tab_selected.emit(index)
func select():

View File

@@ -3,16 +3,21 @@ extends Control
@onready var photo: Photo = $%Photo
@onready var panel: Panel = $%Panel
func _ready() -> void:
GameState.on_photo_highlighted.connect(_on_photo_highlighted)
func _on_photo_highlighted(texture: Texture) -> void:
if texture != photo.texture_rect.texture:
show()
photo.scale = Vector2.ONE
TweenFX.fold_in(photo)
photo.setup(texture)
func _on_panel_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
await TweenFX.fold_out(photo).finished
photo.texture_rect.texture = null
hide()

View File

@@ -24,20 +24,14 @@ grow_vertical = 2
[node name="Photo" parent="." unique_id=201865221 instance=ExtResource("1_x7ou0")]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.3625
anchor_top = 0.14351852
anchor_right = 0.6375
anchor_bottom = 0.8564815
mouse_filter = 2
metadata/_edit_use_anchors_ = true
[node name="ColorRect" parent="Photo" index="0" unique_id=1208008621]
anchors_preset = 15
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 0.0
offset_top = 0.0
offset_right = 0.0

View File

@@ -1,44 +0,0 @@
extends Node
@export_group("Settings")
@export var always_active: bool = false
@export var detector_node: Control
@export var visual_node: Control
@export var scale_amount: Vector2 = Vector2(1.1, 1.1)
@export var duration: float = 0.5
var hover_tween: Tween
func _ready():
if not detector_node or not visual_node:
return
if always_active:
_start_tween()
return
detector_node.mouse_entered.connect(_on_mouse_entered)
detector_node.mouse_exited.connect(_on_mouse_exited)
func _on_mouse_entered():
if hover_tween: hover_tween.kill()
_start_tween()
func _on_mouse_exited():
if hover_tween: hover_tween.kill()
_stop_tween()
func _start_tween() -> void:
hover_tween = create_tween().set_loops()
hover_tween.tween_property(visual_node, "scale", scale_amount, duration).set_trans(Tween.TRANS_SINE)
hover_tween.tween_property(visual_node, "scale", Vector2.ONE, duration).set_trans(Tween.TRANS_SINE)
func _stop_tween() -> void:
var exit_tween = create_tween()
exit_tween.tween_property(visual_node, "scale", Vector2.ONE, 0.2).set_trans(Tween.TRANS_QUAD)

View File

@@ -1 +0,0 @@
uid://ryxh3nm7ayvf

View File

@@ -1,6 +0,0 @@
[gd_scene format=3 uid="uid://dxun0jk5t0n6"]
[ext_resource type="Script" uid="uid://ryxh3nm7ayvf" path="res://core/game_menu/hoover_tween.gd" id="1_gmaf4"]
[node name="HooverTween" type="Node" unique_id=160227524]
script = ExtResource("1_gmaf4")

View File

@@ -1,16 +1,23 @@
extends Control
@onready var play_button: Control = $%PlayButton
@onready var resume_button: Control = $%ResumeButton
@onready var play_button: Button = $%PlayButton
@onready var resume_button: Button = $%ResumeButton
@onready var settings_button: Button = $%SettingsButton
@onready var save_button: Button = $%SaveButton
@onready var quit_button: Button = $%QuitButton
func _on_resume_button_on_button_pressed() -> void:
GameState.resume_game()
func _ready() -> void:
play_button.pressed.connect(_on_play_button_pressed)
save_button.pressed.connect(_on_save_button_pressed)
quit_button.pressed.connect(_on_quit_button_pressed)
func _on_play_button_pressed() -> void:
SceneManager.change_scene(SceneConfig.SceneName.GAME)
func _on_save_button_on_button_pressed() -> void:
func _on_save_button_pressed() -> void:
GameState.save_game()
func _on_quit_button_on_button_pressed() -> void:
func _on_quit_button_pressed() -> void:
GameState.quit_game()

View File

@@ -6,6 +6,7 @@
[ext_resource type="Texture2D" uid="uid://cmhx3mscwrwft" path="res://core/game_menu/assets/page_3/save_button.png" id="3_vwpol"]
[ext_resource type="Texture2D" uid="uid://cu8e7pl0y4owq" path="res://core/game_menu/assets/page_3/settings_button.png" id="4_8w45m"]
[ext_resource type="Texture2D" uid="uid://v7e7467fkdec" path="res://core/game_menu/assets/page_3/quit_button.png" id="4_cd2sv"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="7_n7rb8"]
[node name="OptionMenu" type="Control" unique_id=1055457221]
layout_mode = 3
@@ -61,6 +62,5 @@ custom_minimum_size = Vector2(310, 100)
layout_mode = 2
image = ExtResource("4_cd2sv")
[connection signal="on_button_pressed" from="VBoxContainer/ResumeButton" to="." method="_on_resume_button_on_button_pressed"]
[connection signal="on_button_pressed" from="VBoxContainer/SaveButton" to="." method="_on_save_button_on_button_pressed"]
[connection signal="on_button_pressed" from="VBoxContainer/QuitButton" to="." method="_on_quit_button_on_button_pressed"]
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("targets") instance=ExtResource("7_n7rb8")]
targets = [NodePath("../VBoxContainer/PlayButton"), NodePath("../VBoxContainer/ResumeButton"), NodePath("../VBoxContainer/SettingsButton"), NodePath("../VBoxContainer/SaveButton"), NodePath("../VBoxContainer/QuitButton")]

View File

@@ -1,7 +1,5 @@
@tool
extends Control
signal on_button_pressed
extends Button
@export var image: Texture:
set(value):
@@ -13,6 +11,19 @@ func _ready():
if image != null and has_node("%Texture"):
$%Texture.texture = image
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
on_button_pressed.emit()
func _on_pressed() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.PUNCH_IN):
return
TweenFX.punch_in(self)
func _on_mouse_entered() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.BREATHE):
return
TweenFX.breathe(self, 1)
func _on_mouse_exited() -> void:
TweenFX.stop(self, TweenFX.Animations.BREATHE)
scale = Vector2(1, 1)

View File

@@ -2,17 +2,50 @@
[ext_resource type="Texture2D" uid="uid://b4nymq3n3468g" path="res://core/game_menu/assets/page_3/play_button.png" id="1_movd1"]
[ext_resource type="Script" uid="uid://bbhe65f3517m8" path="res://core/game_menu/option_menu_button.gd" id="2_nghpi"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/game_menu/hoover_tween.tscn" id="3_am666"]
[node name="OptionMenuButton" type="Control" unique_id=635721927]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_nghpi"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_am666"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_nxt2x"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_r4tfe"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1kmlt"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_51x11"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8eh6p"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_w4k7x"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_wra0p"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8dgkg"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ev2fk"]
[node name="OptionMenuButton" type="Button" unique_id=600844315]
process_mode = 3
custom_minimum_size = Vector2(302, 90)
anchors_preset = -1
anchor_right = 0.15729167
anchor_bottom = 0.083333336
pivot_offset_ratio = Vector2(0.5, 0.5)
theme_override_styles/normal = SubResource("StyleBoxEmpty_nghpi")
theme_override_styles/normal_mirrored = SubResource("StyleBoxEmpty_am666")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_nxt2x")
theme_override_styles/pressed_mirrored = SubResource("StyleBoxEmpty_r4tfe")
theme_override_styles/hover = SubResource("StyleBoxEmpty_1kmlt")
theme_override_styles/hover_mirrored = SubResource("StyleBoxEmpty_51x11")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_8eh6p")
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxEmpty_w4k7x")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_wra0p")
theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_8dgkg")
theme_override_styles/focus = SubResource("StyleBoxEmpty_ev2fk")
script = ExtResource("2_nghpi")
image = ExtResource("1_movd1")
metadata/_edit_use_anchors_ = true
[node name="Texture" type="TextureRect" parent="." unique_id=1177880405]
unique_name_in_owner = true
@@ -29,8 +62,6 @@ mouse_filter = 2
texture = ExtResource("1_movd1")
metadata/_edit_use_anchors_ = true
[node name="HooverTween" parent="." unique_id=160227524 node_paths=PackedStringArray("detector_node", "visual_node") instance=ExtResource("3_am666")]
detector_node = NodePath("..")
visual_node = NodePath("../Texture")
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="." to="." method="_on_pressed"]

14
core/game_menu/page.gd Normal file
View File

@@ -0,0 +1,14 @@
extends Control
class_name GameMenuPage
func show_page() -> void:
var tweens = find_children("*", "ContainerTween", true, false)
for tween in tweens:
tween.start_tween()
show()
func hide_page() -> void:
hide()

View File

@@ -0,0 +1 @@
uid://dup0tdvb3eghp

View File

@@ -1,5 +1,6 @@
[gd_scene format=3 uid="uid://id854u4gh12f"]
[ext_resource type="Script" uid="uid://dup0tdvb3eghp" path="res://core/game_menu/page.gd" id="1_21t5y"]
[ext_resource type="Texture2D" uid="uid://bs56pdbywm4uh" path="res://core/game_menu/assets/page_1/quad_main.png" id="1_jwl25"]
[node name="Page" type="Control" unique_id=2037261222]
@@ -7,6 +8,7 @@ layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("1_21t5y")
[node name="Background" type="TextureRect" parent="." unique_id=1203110384]
visible = false

View File

@@ -2,8 +2,6 @@
[ext_resource type="PackedScene" uid="uid://id854u4gh12f" path="res://core/game_menu/page.tscn" id="1_uxih6"]
[ext_resource type="PackedScene" uid="uid://bh1kxsp5jyxfx" path="res://core/game_menu/train_selector.tscn" id="3_ijm38"]
[ext_resource type="Texture2D" uid="uid://bjqp8kmb5y7px" path="res://core/game_menu/assets/page_1/chooseyourtrain_text.png" id="3_t5hmd"]
[ext_resource type="Texture2D" uid="uid://dqqnfnero7ckl" path="res://core/game_menu/assets/page_1/chooseyourbiome_text.png" id="11_3chbu"]
[ext_resource type="PackedScene" uid="uid://bc60gon7fmvbr" path="res://core/game_menu/biome_selector.tscn" id="12_7yi8x"]
[node name="Page1" unique_id=2037261222 instance=ExtResource("1_uxih6")]
@@ -16,33 +14,16 @@ grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="ChooseyourtrainText" type="TextureRect" parent="." index="1" unique_id=1883940124]
layout_mode = 0
offset_left = 350.0
offset_top = 365.0
offset_right = 758.0
offset_bottom = 445.0
texture = ExtResource("3_t5hmd")
[node name="TrainSelector" parent="." index="2" unique_id=1039769375 instance=ExtResource("3_ijm38")]
[node name="TrainSelector" parent="." index="1" unique_id=1039769375 instance=ExtResource("3_ijm38")]
layout_mode = 0
offset_left = 211.0
offset_top = 469.0
offset_right = 871.0
offset_bottom = 778.0
[node name="ChooseyourbiomeText" type="TextureRect" parent="." index="3" unique_id=1133714914]
layout_mode = 0
offset_left = 1184.0
offset_top = 365.0
offset_right = 1579.0
offset_bottom = 436.0
texture = ExtResource("11_3chbu")
stretch_mode = 3
offset_right = 871.0
offset_bottom = 758.0
[node name="BiomeSelector" parent="." index="4" unique_id=1957954960 instance=ExtResource("12_7yi8x")]
[node name="BiomeSelector" parent="." index="2" unique_id=1957954960 instance=ExtResource("12_7yi8x")]
layout_mode = 0
offset_left = 1038.0
offset_top = 437.0
offset_top = 365.0
offset_right = 1738.0
offset_bottom = 837.0
offset_bottom = 783.0

View File

@@ -17,9 +17,6 @@ grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="Background" parent="." index="0" unique_id=1203110384]
mouse_filter = 2
[node name="PhotoCollectionText" type="TextureRect" parent="." index="1" unique_id=240014191]
layout_mode = 0
offset_left = 350.0
@@ -43,7 +40,7 @@ layout_mode = 1
offset_left = 244.0
offset_top = 410.0
offset_right = 844.0
offset_bottom = 810.0
offset_bottom = 850.0
[node name="CollectibleGallery" parent="." index="4" unique_id=708445500 instance=ExtResource("5_w0bcg")]
layout_mode = 1

View File

@@ -1,4 +1,4 @@
extends Control
extends Button
class_name Photo
@@ -11,6 +11,20 @@ func setup(texture: Texture) -> void:
texture_rect.texture = texture
func _on_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
GameState.on_photo_highlighted.emit(texture_rect.texture)
func _on_pressed() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.PUNCH_IN):
return
TweenFX.punch_in(self)
GameState.on_photo_highlighted.emit(texture_rect.texture)
func _on_mouse_entered() -> void:
if TweenFX.is_playing(self, TweenFX.Animations.BREATHE):
return
TweenFX.breathe(self, 1)
func _on_mouse_exited() -> void:
TweenFX.stop(self, TweenFX.Animations.BREATHE)
scale = Vector2(1, 1)

View File

@@ -1,29 +1,26 @@
[gd_scene format=3 uid="uid://cvus62qkop3qi"]
[ext_resource type="Script" uid="uid://dsey5dvc11vpq" path="res://core/game_menu/photo.gd" id="1_u0arp"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/game_menu/hoover_tween.tscn" id="2_62vvn"]
[node name="Photo" type="Control" unique_id=201865221]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Photo" type="Button" unique_id=1451980505]
custom_minimum_size = Vector2(132, 154)
anchors_preset = -1
anchor_right = 0.06875
anchor_bottom = 0.1425926
pivot_offset_ratio = Vector2(0.5, 0.5)
script = ExtResource("1_u0arp")
metadata/_edit_use_anchors_ = true
[node name="ColorRect" type="ColorRect" parent="." unique_id=1208008621]
custom_minimum_size = Vector2(132, 154)
layout_mode = 1
anchors_preset = -1
anchor_left = 0.465625
anchor_top = 0.4287037
anchor_right = 0.534375
anchor_bottom = 0.5712963
offset_left = 66.0
offset_top = 77.0
offset_right = -66.0
offset_bottom = -77.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 127.462494
offset_top = 143.02037
offset_right = -127.4625
offset_bottom = -143.02037
grow_horizontal = 2
grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5)
@@ -50,8 +47,6 @@ mouse_filter = 2
expand_mode = 1
stretch_mode = 6
[node name="HooverTween" parent="." unique_id=160227524 node_paths=PackedStringArray("detector_node", "visual_node") instance=ExtResource("2_62vvn")]
detector_node = NodePath("..")
visual_node = NodePath("../ColorRect")
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="." to="." method="_on_pressed"]

View File

@@ -2,12 +2,13 @@
[ext_resource type="Script" uid="uid://k4iqrlkbjppl" path="res://core/game_menu/photo_gallery.gd" id="1_bp5uf"]
[ext_resource type="PackedScene" uid="uid://cvus62qkop3qi" path="res://core/game_menu/photo.tscn" id="2_45wok"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="3_ht2y6"]
[node name="PhotoGallery" type="Control" unique_id=354419843]
layout_mode = 3
anchors_preset = 0
offset_right = 600.0
offset_bottom = 420.0
offset_bottom = 440.0
mouse_filter = 2
script = ExtResource("1_bp5uf")
photo_scene = ExtResource("2_45wok")
@@ -21,35 +22,40 @@ grow_horizontal = 2
grow_vertical = 2
draw_focus_border = true
[node name="PhotoGrid" type="GridContainer" parent="ScrollContainer" unique_id=1187865988]
unique_name_in_owner = true
[node name="MarginContainer" type="MarginContainer" parent="ScrollContainer" unique_id=934979837]
layout_mode = 2
size_flags_horizontal = 6
size_flags_vertical = 6
theme_override_constants/margin_left = 32
theme_override_constants/margin_top = 32
theme_override_constants/margin_right = 32
theme_override_constants/margin_bottom = 33
[node name="PhotoGrid" type="GridContainer" parent="ScrollContainer/MarginContainer" unique_id=1187865988]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 44
theme_override_constants/v_separation = 54
columns = 3
[node name="Photo" parent="ScrollContainer/PhotoGrid" unique_id=201865221 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=201865221 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="Photo2" parent="ScrollContainer/PhotoGrid" unique_id=427039285 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo2" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=427039285 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="Photo3" parent="ScrollContainer/PhotoGrid" unique_id=800591401 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo3" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=800591401 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="Photo4" parent="ScrollContainer/PhotoGrid" unique_id=1895298585 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo4" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=1895298585 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="Photo5" parent="ScrollContainer/PhotoGrid" unique_id=2093353381 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo5" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=2093353381 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="Photo6" parent="ScrollContainer/PhotoGrid" unique_id=316021755 instance=ExtResource("2_45wok")]
custom_minimum_size = Vector2(132, 154)
[node name="Photo6" parent="ScrollContainer/MarginContainer/PhotoGrid" unique_id=316021755 instance=ExtResource("2_45wok")]
layout_mode = 2
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("runtime_target_parent") instance=ExtResource("3_ht2y6")]
unique_name_in_owner = true
runtime_target_parent = NodePath("../ScrollContainer/MarginContainer/PhotoGrid")

View File

@@ -4,20 +4,30 @@
[ext_resource type="PackedScene" uid="uid://cescrovsjlwke" path="res://core/game_menu/audio_option.tscn" id="1_hwcco"]
[ext_resource type="Texture2D" uid="uid://0t00kjvrw206" path="res://core/game_menu/assets/page_3/music_volume_button.png" id="3_kgdba"]
[ext_resource type="Texture2D" uid="uid://dvergpy6qgggn" path="res://core/game_menu/assets/page_3/sfx_volume_button.png" id="4_ugk4n"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="5_p0gqk"]
[node name="SettingsMenu" type="Control" unique_id=1639777294]
custom_minimum_size = Vector2(327, 512)
layout_mode = 3
anchors_preset = 0
offset_right = 600.0
offset_bottom = 420.0
anchor_right = 0.1703125
anchor_bottom = 0.47407407
offset_right = -327.0
offset_bottom = -512.0
pivot_offset_ratio = Vector2(0.5, 0.5)
script = ExtResource("1_4lekq")
metadata/_edit_use_anchors_ = true
[node name="AudioOptionsContainer" type="VBoxContainer" parent="." unique_id=743642398]
unique_name_in_owner = true
layout_mode = 0
offset_right = 327.0
offset_bottom = 512.0
custom_minimum_size = Vector2(327, 512)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 12
alignment = 1
[node name="MasterVolume_AudioOption" parent="AudioOptionsContainer" unique_id=1509773712 instance=ExtResource("1_hwcco")]
layout_mode = 2
@@ -31,3 +41,6 @@ bus_name = &"Music"
layout_mode = 2
image = ExtResource("4_ugk4n")
bus_name = &"SFX"
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("targets") instance=ExtResource("5_p0gqk")]
targets = [NodePath("../AudioOptionsContainer/MasterVolume_AudioOption"), NodePath("../AudioOptionsContainer/MusicVolume_AudioOption"), NodePath("../AudioOptionsContainer/SFXVolume_AudioOption")]

View File

@@ -3,36 +3,50 @@ extends VBoxContainer
@onready var color_pickers: Array[TrainColorPicker] = [$%ColorPicker1, $%ColorPicker2, $%ColorPicker3, $%ColorPicker4, $%ColorPicker5, $%ColorPicker6]
@onready var left_arrow: ArrowButton = $%ArrowButtonLeft
@onready var right_arrow: ArrowButton = $%ArrowButtonRight
@onready var treno: Node3D = $TrainViewportContainer/SubViewport/Treno
var selected_color: Color
var selected_color_index: int = 0
func _ready() -> void:
for color_picker in color_pickers:
color_picker.on_color_selected.connect(_on_color_selected)
color_picker.pressed.connect(_on_color_selected.bind(color_picker))
color_picker.deselect()
selected_color = color_pickers[0].color
color_pickers[0].select()
_set_selected_color(0)
left_arrow.on_pressed.connect(_select_prev_color)
right_arrow.on_pressed.connect(_select_next_color)
left_arrow.pressed.connect(_select_prev_color)
right_arrow.pressed.connect(_select_next_color)
func _on_color_selected(selected_color_picker: TrainColorPicker) -> void:
func _process(delta: float) -> void:
if treno:
treno.rotation_degrees.y += 30.0 * delta
func _set_selected_color(index: int) -> void:
for i in range(color_pickers.size()):
if color_pickers[i].color == selected_color_picker.color:
selected_color_picker.select()
if i == index:
color_pickers[i].select()
selected_color_index = i
selected_color = color_pickers[i].color
_apply_train_color(selected_color)
else:
color_pickers[i].deselect()
func _on_color_selected(selected_color_picker: TrainColorPicker) -> void:
for i in range(color_pickers.size()):
if color_pickers[i] == selected_color_picker:
_set_selected_color(i)
break
func _select_prev_color() -> void:
for color_picker in color_pickers:
color_picker.deselect()
selected_color_index = (selected_color_index - 1 + color_pickers.size()) % color_pickers.size()
color_pickers[selected_color_index].select()
var next_index = (selected_color_index - 1 + color_pickers.size()) % color_pickers.size()
_set_selected_color(next_index)
func _select_next_color() -> void:
for color_picker in color_pickers:
color_picker.deselect()
selected_color_index = (selected_color_index + 1) % color_pickers.size()
color_pickers[selected_color_index].select()
var next_index = (selected_color_index + 1) % color_pickers.size()
_set_selected_color(next_index)
func _apply_train_color(color: Color) -> void:
var mat: ShaderMaterial = load("res://tgcc/train/Color1_train.tres")
if mat:
mat.set_shader_parameter("albedo_color", color)

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://bh1kxsp5jyxfx"]
[ext_resource type="Script" uid="uid://8k1msabobhks" path="res://core/game_menu/train_selector.gd" id="1_puip6"]
[ext_resource type="Texture2D" uid="uid://cqvani6n2h3fw" path="res://core/game_menu/assets/page_1/train_texture.png" id="1_wfiis"]
[ext_resource type="Texture2D" uid="uid://bjqp8kmb5y7px" path="res://core/game_menu/assets/page_1/chooseyourtrain_text.png" id="2_cfvtr"]
[ext_resource type="PackedScene" uid="uid://dm3skv22c60tm" path="res://core/game_menu/arrow_button.tscn" id="2_puip6"]
[ext_resource type="PackedScene" uid="uid://ch1st1oryjoio" path="res://core/game_menu/color_picker.tscn" id="3_i2rs1"]
[ext_resource type="Texture2D" uid="uid://b5arobd7gl4u4" path="res://core/game_menu/assets/page_1/customizecolor-3.png" id="4_cfvtr"]
@@ -9,19 +9,47 @@
[ext_resource type="Texture2D" uid="uid://bv07xhpe3kh0r" path="res://core/game_menu/assets/page_1/customizecolor-5.png" id="6_dxnpq"]
[ext_resource type="Texture2D" uid="uid://cryqbi1av2x1c" path="res://core/game_menu/assets/page_1/customizecolor.png" id="7_d1sdr"]
[ext_resource type="Texture2D" uid="uid://d4l5ih723j3md" path="res://core/game_menu/assets/page_1/customizecolor-2.png" id="8_tuh6m"]
[ext_resource type="PackedScene" uid="uid://dxun0jk5t0n6" path="res://core/tween/container_tween.tscn" id="10_i2rs1"]
[ext_resource type="PackedScene" uid="uid://otptvwer4par" path="res://tgcc/train/train.tscn" id="11_train"]
[node name="TrainSelector" type="VBoxContainer" unique_id=1039769375]
offset_right = 625.0
offset_bottom = 309.0
alignment = 1
script = ExtResource("1_puip6")
[node name="TrainTexture" type="TextureRect" parent="." unique_id=2095010706]
[node name="ChooseYourTrainTexture" type="TextureRect" parent="." unique_id=2095010706]
layout_mode = 2
texture = ExtResource("1_wfiis")
texture = ExtResource("2_cfvtr")
stretch_mode = 3
[node name="Spacer" type="Control" parent="." unique_id=685700140]
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
[node name="TrainViewportContainer" type="SubViewportContainer" parent="." unique_id=1674220600]
custom_minimum_size = Vector2(0, 180)
layout_mode = 2
stretch = true
[node name="SubViewport" type="SubViewport" parent="TrainViewportContainer" unique_id=1674220601]
transparent_bg = true
handle_input_locally = false
size = Vector2i(660, 180)
render_target_update_mode = 4
[node name="Camera3D" type="Camera3D" parent="TrainViewportContainer/SubViewport" unique_id=1674220602]
transform = Transform3D(0.707107, -0.353553, 0.612372, 0, 0.866025, 0.5, -0.707107, -0.353553, 0.612372, 6, 4, 6)
current = true
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="TrainViewportContainer/SubViewport" unique_id=1674220604]
transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 5, 0)
[node name="Treno" parent="TrainViewportContainer/SubViewport" unique_id=1674220603 instance=ExtResource("11_train")]
[node name="HBoxContainer2" type="HBoxContainer" parent="." unique_id=607833319]
layout_mode = 2
alignment = 1
[node name="ArrowButtonLeft" parent="HBoxContainer2" unique_id=103192648 instance=ExtResource("2_puip6")]
unique_name_in_owner = true
@@ -31,44 +59,39 @@ flip_h = true
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer2" unique_id=1364417494]
layout_mode = 2
theme_override_constants/separation = 18
alignment = 1
[node name="ColorPicker1" parent="HBoxContainer2/HBoxContainer" unique_id=59169767 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
image = ExtResource("4_cfvtr")
[node name="ColorPicker2" parent="HBoxContainer2/HBoxContainer" unique_id=584054476 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
image = ExtResource("5_jnto8")
[node name="ColorPicker3" parent="HBoxContainer2/HBoxContainer" unique_id=889429149 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
image = ExtResource("6_dxnpq")
[node name="ColorPicker4" parent="HBoxContainer2/HBoxContainer" unique_id=466686411 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
image = ExtResource("7_d1sdr")
[node name="ColorPicker5" parent="HBoxContainer2/HBoxContainer" unique_id=675841518 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
[node name="ColorPicker6" parent="HBoxContainer2/HBoxContainer" unique_id=1698412911 instance=ExtResource("3_i2rs1")]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
size_flags_vertical = 4
image = ExtResource("8_tuh6m")
@@ -76,3 +99,7 @@ image = ExtResource("8_tuh6m")
[node name="ArrowButtonRight" parent="HBoxContainer2" unique_id=68298624 instance=ExtResource("2_puip6")]
unique_name_in_owner = true
layout_mode = 2
[node name="ContainerTween" parent="." unique_id=160227524 node_paths=PackedStringArray("targets") instance=ExtResource("10_i2rs1")]
unique_name_in_owner = true
targets = [NodePath("../HBoxContainer2/ArrowButtonLeft"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker1"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker2"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker3"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker4"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker5"), NodePath("../HBoxContainer2/HBoxContainer/ColorPicker6"), NodePath("../HBoxContainer2/ArrowButtonRight")]