add tooltips and fix stuff

This commit is contained in:
2026-07-02 21:19:56 +02:00
parent 3512145a66
commit 922c771185
69 changed files with 1452 additions and 5 deletions

View File

@@ -12,6 +12,9 @@ class_name IconButton
@export var images: Array[Texture]
@export var apply_texture_on_selection: bool = true
@export var enable_tooltip: bool = false
@export var tooltip_scene: PackedScene
@export var tooltip_image: Texture
func _ready():
if image != null and has_node("%Texture"):
@@ -36,3 +39,15 @@ func _on_pressed() -> void:
rotation = 0.0
modulate.a = 1.0
TweenFX.press_rotate(self)
func _make_custom_tooltip(for_text: String) -> Object:
if !enable_tooltip:
return null
var tooltip = tooltip_scene.instantiate()
tooltip.text = for_text
if tooltip_image != null:
tooltip.image = tooltip_image
return tooltip

View File

@@ -2,6 +2,8 @@
[ext_resource type="Script" uid="uid://bpbgecvan0a5k" path="res://core/main_scene_ui/icon_button.gd" id="1_r8gxt"]
[ext_resource type="Texture2D" uid="uid://bkos5j6dwqcxw" path="res://core/main_scene_ui/assets/button_chrono_night.png" id="3_6q6an"]
[ext_resource type="PackedScene" uid="uid://blh7egp5ge16m" path="res://core/tooltips/tooltip.tscn" id="3_60w2f"]
[ext_resource type="Texture2D" uid="uid://cbk8ufxb7wdgx" path="res://core/tooltips/assets/tooltip_DX.png" id="4_60w2f"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_r8gxt"]
@@ -44,6 +46,8 @@ theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_4beq1")
theme_override_styles/focus = SubResource("StyleBoxEmpty_cxhgx")
script = ExtResource("1_r8gxt")
image = ExtResource("3_6q6an")
tooltip_scene = ExtResource("3_60w2f")
tooltip_image = ExtResource("4_60w2f")
metadata/_edit_use_anchors_ = true
[node name="Texture" type="TextureRect" parent="." unique_id=1071359322]

View File

@@ -10,18 +10,21 @@ extends Control
@onready var collectible_icon_button: Button = $%CollectibleIconButton
@onready var weather_row: HBoxContainer = $%WeatherRow
@onready var time_of_day_row: HBoxContainer = $%TimeOfDayRow
@onready var cameras_row: HBoxContainer = $%CamerasRow
@onready var photo_mode_texture_panel: Panel = $%PhotoModeTexturePanel
@onready var photo_mode_texture_mask: TextureRect = $%PhotoModeTextureMask
@onready var photo_mode_black_screen: ColorRect = $%PhotoModeBlackScreen
@onready var audio_player: Control = $%AudioPlayer
@onready var time_label: Label = $%TimeLabel
@onready var dist_label: Label = $%DistLabel
@onready var tooltips: HBoxContainer = $%Tooltips
var _cycle = false
var _rain = false
var _snow = false
var _storm = false
var _wind = false
var _ui_hidden = false
var _photo_mode_mat_tween: Tween
var _photo_mode_alpha_tween: Tween
var _photo_mode_fold_tween: Tween
@@ -53,6 +56,7 @@ func _process(_delta: float) -> void:
dist_label.text = "Distance Traveled: %d km" % int(GameState.save_data.total_distance_km)
func _on_hide_ui_button_pressed() -> void:
UIEvents.on_hide_ui_requested.emit()
hide_ui()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
await get_tree().create_timer(0.3).timeout
@@ -66,7 +70,7 @@ func _input(event: InputEvent) -> void:
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_options"):
if photo_mode_texture_panel.visible:
if photo_mode_texture_panel.visible or _ui_hidden:
return
if game_menu_panel.visible:
_on_resume_button_pressed()
@@ -219,20 +223,41 @@ func _set_buttons_mouse_filter(ignore: bool) -> void:
buttons.append_array(weather_row.options_icon_buttons)
if time_of_day_row and "options_icon_buttons" in time_of_day_row:
buttons.append_array(time_of_day_row.options_icon_buttons)
if cameras_row and "options_icon_buttons" in cameras_row:
buttons.append_array(cameras_row.options_icon_buttons)
for btn in buttons:
if btn is Control:
btn.mouse_filter = filter
func hide_ui() -> void:
_ui_hidden = true
_set_buttons_mouse_filter(true)
var hud_elements = [hide_ui_button, weather_row, time_of_day_row, customize_train_button, collectible_icon_button, menu_icon_button, photo_icon_button, audio_player, choo_choo_button, time_label, dist_label]
var hud_elements = [hide_ui_button, weather_row, time_of_day_row, cameras_row, customize_train_button, collectible_icon_button, menu_icon_button, photo_icon_button, audio_player, choo_choo_button, time_label, dist_label]
for element in hud_elements:
element.visible = false
element.visible = true
TweenFX.fade_out(element, 0.25)
func show_ui() -> void:
_ui_hidden = false
_set_buttons_mouse_filter(false)
var hud_elements = [hide_ui_button, weather_row, time_of_day_row, customize_train_button, collectible_icon_button, menu_icon_button, photo_icon_button, audio_player, choo_choo_button, time_label, dist_label]
var hud_elements = [hide_ui_button, weather_row, time_of_day_row, cameras_row, customize_train_button, collectible_icon_button, menu_icon_button, photo_icon_button, audio_player, choo_choo_button, time_label, dist_label, tooltips]
for element in hud_elements:
element.show()
TweenFX.fade_in(element, 0.25)
func _on_cameras_row_on_option_changed(data: String) -> void:
match data:
"1":
UIEvents.change_camera_request.emit(0)
"2":
UIEvents.change_camera_request.emit(1)
"3":
UIEvents.change_camera_request.emit(2)
"4":
UIEvents.change_camera_request.emit(3)
"5":
UIEvents.change_camera_request.emit(4)
_:
pass

View File

@@ -27,10 +27,26 @@
[ext_resource type="Texture2D" uid="uid://tex06svipyg4" path="res://core/main_scene_ui/assets/button_random.png" id="14_gcgq4"]
[ext_resource type="Texture2D" uid="uid://1n3paucfsovj" path="res://core/main_scene_ui/assets/button_photomode.png" id="15_th1nj"]
[ext_resource type="Texture2D" uid="uid://qq84r14df2ix" path="res://core/main_scene_ui/assets/button_visibility_on.png" id="19_dyo0w"]
[ext_resource type="Texture2D" uid="uid://dijxloxgmn3ws" path="res://core/tooltips/assets/tooltip_ESC.png" id="19_mlhrv"]
[ext_resource type="Texture2D" uid="uid://c31yut8p24t8g" path="res://core/main_scene_ui/assets/button_customize.png" id="19_vywaj"]
[ext_resource type="Texture2D" uid="uid://b03si5ir3ypp7" path="res://core/main_scene_ui/assets/button_collection03.png" id="19_yggu7"]
[ext_resource type="Texture2D" uid="uid://c8io1gdqo45kw" path="res://core/tooltips/assets/tooltip_H.png" id="21_7mx2q"]
[ext_resource type="Texture2D" uid="uid://clmbvd7ilhra2" path="res://core/main_scene_ui/assets/button_choochoo_on.png" id="22_x1iix"]
[ext_resource type="Texture2D" uid="uid://oc0aqajt2yxr" path="res://core/tooltips/assets/tooltip_p.png" id="25_1n7cf"]
[ext_resource type="PackedScene" uid="uid://dx66qveii1lml" path="res://core/tooltips/tooltips.tscn" id="25_kh0c7"]
[ext_resource type="Texture2D" uid="uid://1hbcebf3mf1l" path="res://core/tooltips/assets/tooltip_Q.png" id="27_binfm"]
[ext_resource type="Texture2D" uid="uid://dsytn6pedo8i" path="res://core/tooltips/assets/camera_none.png" id="28_mukbp"]
[ext_resource type="Texture2D" uid="uid://cavfu38w67kv1" path="res://core/tooltips/assets/camera_1.png" id="29_ej62u"]
[ext_resource type="FontFile" uid="uid://bclja5no1qteh" path="res://core/font/Kestila.ttf" id="29_jn6vt"]
[ext_resource type="Texture2D" uid="uid://c4nsxmoh3itat" path="res://core/tooltips/assets/camera_2.png" id="30_b6lng"]
[ext_resource type="Texture2D" uid="uid://d12w3tr36spe8" path="res://core/tooltips/assets/tooltip_1.png" id="30_jpo3t"]
[ext_resource type="Texture2D" uid="uid://bbsohagx2646w" path="res://core/tooltips/assets/camera_3.png" id="31_xe82o"]
[ext_resource type="Texture2D" uid="uid://bi2tblkgtqnf6" path="res://core/tooltips/assets/tooltip_2.png" id="32_4h51y"]
[ext_resource type="Texture2D" uid="uid://dry1k7w03167e" path="res://core/tooltips/assets/camera_4.png" id="32_nqdet"]
[ext_resource type="Texture2D" uid="uid://1fsufkfkyti" path="res://core/tooltips/assets/camera_5.png" id="33_l4tct"]
[ext_resource type="Texture2D" uid="uid://d160748lbh8j5" path="res://core/tooltips/assets/tooltip_3.png" id="34_o8vr4"]
[ext_resource type="Texture2D" uid="uid://b4hb1i0p6fg1b" path="res://core/tooltips/assets/tooltip_4.png" id="36_yts6a"]
[ext_resource type="Texture2D" uid="uid://dtq561kbf31gw" path="res://core/tooltips/assets/tooltip_5.png" id="38_vv0oj"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hole"]
shader = ExtResource("10_shader")
@@ -64,23 +80,28 @@ layout_mode = 2
[node name="IconButton" parent="Rows/TimeOfDayRow" index="0" unique_id=1750448019]
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton2" parent="Rows/TimeOfDayRow" index="1" unique_id=638856991]
data = "Sunrise"
image = ExtResource("3_kd244")
enable_tooltip = null
[node name="IconButton3" parent="Rows/TimeOfDayRow" index="2" unique_id=1662483962]
data = "Day"
image = ExtResource("4_lapqe")
enable_tooltip = null
[node name="IconButton4" parent="Rows/TimeOfDayRow" index="3" unique_id=1375190490]
data = "Night"
enable_tooltip = null
[node name="IconButton5" parent="Rows/TimeOfDayRow" index="4" unique_id=315412403]
data = "Cycle"
image = ExtResource("5_fjfwt")
images = Array[Texture]([ExtResource("5_fjfwt"), ExtResource("6_luj56")])
apply_texture_on_selection = false
enable_tooltip = null
[node name="ShowContainerTween" parent="Rows/TimeOfDayRow" index="5" unique_id=160227524]
tween_types = Array[String](["impact_land", "fade_in"])
@@ -95,30 +116,35 @@ layout_mode = 2
[node name="IconButton" parent="Rows/WeatherRow" index="0" unique_id=1750448019]
image = ExtResource("6_yggu7")
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton2" parent="Rows/WeatherRow" index="1" unique_id=638856991]
data = "Snow"
image = ExtResource("6_xykej")
images = Array[Texture]([ExtResource("6_xykej"), ExtResource("6_167gj")])
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton3" parent="Rows/WeatherRow" index="2" unique_id=1662483962]
data = "Rain"
image = ExtResource("7_jpmw5")
images = Array[Texture]([ExtResource("7_jpmw5"), ExtResource("8_c5e3i")])
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton4" parent="Rows/WeatherRow" index="3" unique_id=1375190490]
data = "Storm"
image = ExtResource("8_i1mwp")
images = Array[Texture]([ExtResource("8_i1mwp"), ExtResource("10_th1nj")])
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton5" parent="Rows/WeatherRow" index="4" unique_id=315412403]
data = "Wind"
image = ExtResource("11_gcgq4")
images = Array[Texture]([ExtResource("11_gcgq4"), ExtResource("12_fjfwt")])
apply_texture_on_selection = false
enable_tooltip = null
[node name="ShowContainerTween" parent="Rows/WeatherRow" index="5" unique_id=160227524 node_paths=PackedStringArray("targets")]
targets = [NodePath("../IconButton2"), NodePath("../IconButton3"), NodePath("../IconButton4"), NodePath("../IconButton5"), NodePath("../IconButton6")]
@@ -137,6 +163,7 @@ size_flags_vertical = 3
data = "Random"
image = ExtResource("14_gcgq4")
apply_texture_on_selection = false
enable_tooltip = null
[node name="TopButtons" type="VBoxContainer" parent="." unique_id=1644086668]
layout_mode = 1
@@ -153,12 +180,18 @@ theme_override_constants/separation = 8
[node name="MenuIconButton" parent="TopButtons" unique_id=707872474 instance=ExtResource("3_t1xop")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "option"
image = ExtResource("10_6016m")
enable_tooltip = true
tooltip_image = ExtResource("19_mlhrv")
[node name="HideUIButton" parent="TopButtons" unique_id=1621140689 instance=ExtResource("3_t1xop")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "hide UI"
image = ExtResource("19_dyo0w")
enable_tooltip = true
tooltip_image = ExtResource("21_7mx2q")
[node name="MiddleButtons" type="VBoxContainer" parent="." unique_id=542153805]
layout_mode = 1
@@ -168,9 +201,9 @@ anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = -100.0
offset_top = -124.0
offset_top = -172.0
offset_right = -20.0
offset_bottom = 124.0
offset_bottom = 172.0
grow_horizontal = 0
grow_vertical = 2
theme_override_constants/separation = 8
@@ -179,21 +212,29 @@ theme_override_constants/separation = 8
unique_name_in_owner = true
layout_mode = 2
image = ExtResource("19_vywaj")
enable_tooltip = null
[node name="CollectibleIconButton" parent="MiddleButtons" unique_id=520235552 instance=ExtResource("3_t1xop")]
unique_name_in_owner = true
layout_mode = 2
image = ExtResource("19_yggu7")
enable_tooltip = null
[node name="PhotoIconButton" parent="MiddleButtons" unique_id=1863476241 instance=ExtResource("3_t1xop")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "photo mode"
image = ExtResource("15_th1nj")
enable_tooltip = true
tooltip_image = ExtResource("25_1n7cf")
[node name="ChooChooButton" parent="MiddleButtons" unique_id=774819903 instance=ExtResource("3_t1xop")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "horn"
image = ExtResource("22_x1iix")
enable_tooltip = true
tooltip_image = ExtResource("27_binfm")
[node name="InfoLabels" type="VBoxContainer" parent="." unique_id=234435566]
custom_minimum_size = Vector2(400, 0)
@@ -203,6 +244,58 @@ offset_top = 20.0
offset_right = 420.0
offset_bottom = 220.0
[node name="CamerasRow" parent="InfoLabels" unique_id=1233961141 instance=ExtResource("2_4cc8f")]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 1
[node name="IconButton" parent="InfoLabels/CamerasRow" index="0" unique_id=1750448019]
image = ExtResource("28_mukbp")
apply_texture_on_selection = false
enable_tooltip = null
[node name="IconButton2" parent="InfoLabels/CamerasRow" index="1" unique_id=638856991]
data = "1"
image = ExtResource("29_ej62u")
enable_tooltip = true
tooltip_image = ExtResource("30_jpo3t")
[node name="IconButton3" parent="InfoLabels/CamerasRow" index="2" unique_id=1662483962]
data = "2"
image = ExtResource("30_b6lng")
enable_tooltip = true
tooltip_image = ExtResource("32_4h51y")
[node name="IconButton4" parent="InfoLabels/CamerasRow" index="3" unique_id=1375190490]
data = "3"
image = ExtResource("31_xe82o")
enable_tooltip = true
tooltip_image = ExtResource("34_o8vr4")
[node name="IconButton5" parent="InfoLabels/CamerasRow" index="4" unique_id=315412403]
data = "4"
image = ExtResource("32_nqdet")
enable_tooltip = true
tooltip_image = ExtResource("36_yts6a")
[node name="IconButton6" parent="InfoLabels/CamerasRow" unique_id=1017773972 instance=ExtResource("3_t1xop")]
visible = false
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 3
data = "5"
image = ExtResource("33_l4tct")
enable_tooltip = true
tooltip_image = ExtResource("38_vv0oj")
[node name="ShowContainerTween" parent="InfoLabels/CamerasRow" index="6" unique_id=160227524 node_paths=PackedStringArray("targets")]
targets = [NodePath("../IconButton2"), NodePath("../IconButton3"), NodePath("../IconButton4"), NodePath("../IconButton5"), NodePath("../IconButton6")]
tween_types = Array[String](["impact_land", "fade_in"])
[node name="HideContainerTween" parent="InfoLabels/CamerasRow" index="7" unique_id=1169748375 node_paths=PackedStringArray("targets")]
targets = [NodePath("../IconButton6"), NodePath("../IconButton5"), NodePath("../IconButton4"), NodePath("../IconButton3"), NodePath("../IconButton2")]
tween_types = Array[String](["impact_land", "fade_out"])
[node name="TimeLabel" type="Label" parent="InfoLabels" unique_id=18932607]
unique_name_in_owner = true
layout_mode = 2
@@ -213,6 +306,17 @@ unique_name_in_owner = true
layout_mode = 2
theme_override_fonts/font = ExtResource("29_jn6vt")
[node name="Tooltips" parent="." unique_id=1388346317 instance=ExtResource("25_kh0c7")]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_right = 0.5
offset_left = -297.5
offset_top = -68.0
offset_right = 297.5
offset_bottom = -20.0
[node name="AudioPlayer" parent="." unique_id=425192018 node_paths=PackedStringArray("radio") instance=ExtResource("7_lapqe")]
unique_name_in_owner = true
layout_mode = 1
@@ -300,8 +404,10 @@ playlist = Array[AudioStream]([ExtResource("6_kd244")])
[connection signal="on_option_changed" from="Rows/TimeOfDayRow" to="." method="_on_time_of_day_row_on_option_changed"]
[connection signal="on_option_changed" from="Rows/WeatherRow" to="." method="_on_weather_row_on_option_changed"]
[connection signal="on_option_changed" from="InfoLabels/CamerasRow" to="." method="_on_cameras_row_on_option_changed"]
[editable path="Rows/TimeOfDayRow"]
[editable path="Rows/WeatherRow"]
[editable path="InfoLabels/CamerasRow"]
[editable path="GameMenuPanel/GameMenu"]
[editable path="GameMenuPanel/GameMenu/Pages/Page3"]