fix ui, add labels for distance and time, add choo choo button and hide button
This commit is contained in:
@@ -392,7 +392,14 @@ func train_move(delta: float) -> void:
|
||||
|
||||
#Calculate train distance for steam stats
|
||||
func _track_steam_distance(distance_units: float) -> void:
|
||||
if distance_units <= 0.0 or not SteamManager.is_on_steam:
|
||||
if distance_units <= 0.0:
|
||||
return
|
||||
|
||||
# Always track the global distance in our save file (for UI and persistency)
|
||||
GameState.save_data.total_distance_km += distance_units * STEAM_DISTANCE_KM_PER_UNIT
|
||||
|
||||
# Steam specific logic
|
||||
if not SteamManager.is_on_steam:
|
||||
return
|
||||
|
||||
_pending_steam_distance_km += distance_units * STEAM_DISTANCE_KM_PER_UNIT
|
||||
|
||||
@@ -31,6 +31,10 @@ func _ready() -> void:
|
||||
apply_video_settings()
|
||||
apply_train_colors()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not get_tree().paused and is_loaded:
|
||||
save_data.total_time_played_seconds += delta
|
||||
|
||||
func apply_video_settings() -> void:
|
||||
get_viewport().use_taa = save_data.anti_aliasing
|
||||
var msaa_mode = Viewport.MSAA_2X if save_data.anti_aliasing else Viewport.MSAA_DISABLED
|
||||
|
||||
@@ -14,6 +14,9 @@ var train_color_2: String = ""
|
||||
var train_color_1_index: int = 0
|
||||
var train_color_2_index: int = 0
|
||||
|
||||
var total_distance_km: float = 0.0
|
||||
var total_time_played_seconds: float = 0.0
|
||||
|
||||
func to_dictionary() -> Dictionary:
|
||||
var serialized_collectible_ids: Array[String] = []
|
||||
for collectible_id in unlocked_collectibles_ids:
|
||||
@@ -31,6 +34,8 @@ func to_dictionary() -> Dictionary:
|
||||
"train_color_2": train_color_2,
|
||||
"train_color_1_index": train_color_1_index,
|
||||
"train_color_2_index": train_color_2_index,
|
||||
"total_distance_km": total_distance_km,
|
||||
"total_time_played_seconds": total_time_played_seconds,
|
||||
}
|
||||
|
||||
static func from_dictionary(data: Dictionary) -> SaveGameData:
|
||||
@@ -72,4 +77,10 @@ static func from_dictionary(data: Dictionary) -> SaveGameData:
|
||||
if data.has("train_color_2_index"):
|
||||
save_game_data.train_color_2_index = int(data["train_color_2_index"])
|
||||
|
||||
if data.has("total_distance_km"):
|
||||
save_game_data.total_distance_km = float(data["total_distance_km"])
|
||||
|
||||
if data.has("total_time_played_seconds"):
|
||||
save_game_data.total_time_played_seconds = float(data["total_time_played_seconds"])
|
||||
|
||||
return save_game_data
|
||||
|
||||
@@ -4,8 +4,10 @@ extends Control
|
||||
@onready var game_menu: Control = $%GameMenu
|
||||
@onready var game_menu_panel: Control = $%GameMenuPanel
|
||||
@onready var menu_icon_button: Button = $%MenuIconButton
|
||||
@onready var hide_ui_button: Button = $%HideUIButton
|
||||
@onready var customize_train_button: Button = $%CustomizeTrainButton
|
||||
@onready var photo_icon_button: Button = $%PhotoIconButton
|
||||
@onready var choo_choo_button: Button = $%ChooChooButton
|
||||
@onready var collectible_icon_button: Button = $%CollectibleIconButton
|
||||
@onready var resume_button: Button = $GameMenuPanel/GameMenu/Pages/Page3/OptionMenu/VBoxContainer/ResumeButton
|
||||
@onready var weather_row: HBoxContainer = $%WeatherRow
|
||||
@@ -14,6 +16,8 @@ extends Control
|
||||
@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
|
||||
|
||||
var _cycle = false
|
||||
var _rain = false
|
||||
@@ -25,17 +29,41 @@ var _photo_mode_alpha_tween: Tween
|
||||
var _photo_mode_fold_tween: Tween
|
||||
|
||||
func _ready() -> void:
|
||||
set_process_input(false)
|
||||
GameState.on_enable_photo_mode_request.connect(_on_enable_photo_mode)
|
||||
GameState.on_disable_photo_mode_request.connect(_on_disable_photo_mode)
|
||||
GameState.on_photo_taken_started.connect(_on_photo_taken_started)
|
||||
GameState.on_photo_taken_finished.connect(_on_photo_taken_finished)
|
||||
GameState.on_photo_taken_prepare.connect(_on_photo_capture_prepare)
|
||||
hide_ui_button.pressed.connect(_on_hide_ui_button_pressed)
|
||||
customize_train_button.pressed.connect(_open_game_menu_on_page.bind(0))
|
||||
collectible_icon_button.pressed.connect(_open_game_menu_on_page.bind(1))
|
||||
menu_icon_button.pressed.connect(_open_game_menu_on_page.bind(2))
|
||||
photo_icon_button.pressed.connect(_on_photo_icon_button_pressed)
|
||||
choo_choo_button.pressed.connect(_on_choo_choo_button_pressed)
|
||||
resume_button.pressed.connect(_on_resume_button_pressed)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if time_label and dist_label and GameState.is_loaded:
|
||||
var time = GameState.save_data.total_time_played_seconds
|
||||
var hours = int(time) / 3600
|
||||
var minutes = (int(time) % 3600) / 60
|
||||
var seconds = int(time) % 60
|
||||
time_label.text = "Travel Time: %02d:%02d:%02d" % [hours, minutes, seconds]
|
||||
dist_label.text = "Distance Traveled: %d km" % int(GameState.save_data.total_distance_km)
|
||||
|
||||
func _on_hide_ui_button_pressed() -> void:
|
||||
hide_ui()
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
await get_tree().create_timer(0.3).timeout
|
||||
set_process_input(true)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
set_process_input(false)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
show_ui()
|
||||
|
||||
func _on_photo_icon_button_pressed() -> void:
|
||||
GameState.on_enable_photo_mode_request.emit()
|
||||
|
||||
@@ -96,7 +124,7 @@ func pick_random_weather() -> void:
|
||||
weather_row.on_icon_pressed_changed(random_button)
|
||||
|
||||
func _on_enable_photo_mode() -> void:
|
||||
hide_ui_for_photo_mode()
|
||||
hide_ui()
|
||||
photo_mode_texture_mask.scale = Vector2(1,1)
|
||||
photo_mode_texture_mask.modulate.a = 0.0
|
||||
photo_mode_texture_panel.show()
|
||||
@@ -119,7 +147,7 @@ func _on_enable_photo_mode() -> void:
|
||||
_photo_mode_fold_tween = TweenFX.fold_in(photo_mode_texture_mask)
|
||||
|
||||
func _on_disable_photo_mode() -> void:
|
||||
show_ui_for_photo_mode()
|
||||
show_ui()
|
||||
var mat = photo_mode_texture_panel.material as ShaderMaterial
|
||||
if mat:
|
||||
if _photo_mode_mat_tween:
|
||||
@@ -162,27 +190,35 @@ func _on_photo_taken_finished() -> void:
|
||||
photo_mode_black_screen.hide()
|
||||
GameState.on_photo_mode_black_screen_disappeared.emit()
|
||||
|
||||
func hide_ui_for_photo_mode() -> void:
|
||||
TweenFX.fade_out(weather_row, 0.25)
|
||||
TweenFX.fade_out(time_of_day_row, 0.25)
|
||||
TweenFX.fade_out(customize_train_button, 0.25)
|
||||
TweenFX.fade_out(collectible_icon_button, 0.25)
|
||||
TweenFX.fade_out(menu_icon_button, 0.25)
|
||||
TweenFX.fade_out(photo_icon_button, 0.25)
|
||||
TweenFX.fade_out(audio_player, 0.25)
|
||||
func _on_choo_choo_button_pressed() -> void:
|
||||
#play sfx
|
||||
pass
|
||||
|
||||
func show_ui_for_photo_mode() -> void:
|
||||
weather_row.show()
|
||||
time_of_day_row.show()
|
||||
menu_icon_button.show()
|
||||
customize_train_button.show()
|
||||
photo_icon_button.show()
|
||||
collectible_icon_button.show()
|
||||
audio_player.show()
|
||||
TweenFX.fade_in(weather_row, 0.25)
|
||||
TweenFX.fade_in(time_of_day_row, 0.25)
|
||||
TweenFX.fade_in(customize_train_button, 0.25)
|
||||
TweenFX.fade_in(collectible_icon_button, 0.25)
|
||||
TweenFX.fade_in(menu_icon_button, 0.25)
|
||||
TweenFX.fade_in(photo_icon_button, 0.25)
|
||||
TweenFX.fade_in(audio_player, 0.25)
|
||||
func _set_buttons_mouse_filter(ignore: bool) -> void:
|
||||
var filter = Control.MOUSE_FILTER_IGNORE if ignore else Control.MOUSE_FILTER_STOP
|
||||
var buttons = [hide_ui_button, customize_train_button, collectible_icon_button, menu_icon_button, photo_icon_button, choo_choo_button]
|
||||
if weather_row and "options_icon_buttons" in weather_row:
|
||||
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)
|
||||
|
||||
for btn in buttons:
|
||||
if btn is Control:
|
||||
btn.mouse_filter = filter
|
||||
|
||||
func hide_ui() -> void:
|
||||
_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]
|
||||
if time_label: hud_elements.append(time_label)
|
||||
if dist_label: hud_elements.append(dist_label)
|
||||
for element in hud_elements:
|
||||
TweenFX.fade_out(element, 0.25)
|
||||
|
||||
func show_ui() -> void:
|
||||
_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]
|
||||
if time_label: hud_elements.append(time_label)
|
||||
if dist_label: hud_elements.append(dist_label)
|
||||
for element in hud_elements:
|
||||
element.show()
|
||||
TweenFX.fade_in(element, 0.25)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
[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://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="FontFile" uid="uid://bclja5no1qteh" path="res://core/font/Kestila.ttf" id="29_jn6vt"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hole"]
|
||||
shader = ExtResource("10_shader")
|
||||
@@ -49,8 +50,10 @@ layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -164.0
|
||||
offset_right = 80.0
|
||||
offset_left = 20.0
|
||||
offset_top = -184.0
|
||||
offset_right = 100.0
|
||||
offset_bottom = -20.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="TimeOfDayRow" parent="Rows" unique_id=1734127019 instance=ExtResource("2_4cc8f")]
|
||||
@@ -133,46 +136,81 @@ data = "Random"
|
||||
image = ExtResource("14_gcgq4")
|
||||
apply_texture_on_selection = false
|
||||
|
||||
[node name="MenuIconButton" parent="." unique_id=707872474 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
[node name="TopButtons" type="VBoxContainer" parent="." unique_id=1644086668]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = -80.0
|
||||
offset_bottom = 80.0
|
||||
offset_left = -100.0
|
||||
offset_top = 20.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = 100.0
|
||||
grow_horizontal = 0
|
||||
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
|
||||
image = ExtResource("10_6016m")
|
||||
|
||||
[node name="CollectionOptions" type="VBoxContainer" parent="." unique_id=542153805]
|
||||
[node name="HideUIButton" parent="TopButtons" unique_id=1621140689 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
image = ExtResource("10_6016m")
|
||||
|
||||
[node name="MiddleButtons" type="VBoxContainer" parent="." unique_id=542153805]
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -40.0
|
||||
offset_top = -20.0
|
||||
offset_bottom = 20.0
|
||||
offset_left = -100.0
|
||||
offset_top = -124.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = 124.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="CustomizeTrainButton" parent="CollectionOptions" unique_id=1621140689 instance=ExtResource("3_t1xop")]
|
||||
[node name="CustomizeTrainButton" parent="MiddleButtons" unique_id=27430111 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
image = ExtResource("19_vywaj")
|
||||
|
||||
[node name="CollectibleIconButton" parent="CollectionOptions" unique_id=520235552 instance=ExtResource("3_t1xop")]
|
||||
[node name="CollectibleIconButton" parent="MiddleButtons" unique_id=520235552 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
image = ExtResource("19_yggu7")
|
||||
|
||||
[node name="PhotoIconButton" parent="CollectionOptions" unique_id=1863476241 instance=ExtResource("3_t1xop")]
|
||||
[node name="PhotoIconButton" parent="MiddleButtons" unique_id=1863476241 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
image = ExtResource("15_th1nj")
|
||||
|
||||
[node name="ChooChooButton" parent="MiddleButtons" unique_id=774819903 instance=ExtResource("3_t1xop")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
image = ExtResource("15_th1nj")
|
||||
|
||||
[node name="InfoLabels" type="VBoxContainer" parent="." unique_id=234435566]
|
||||
custom_minimum_size = Vector2(400, 0)
|
||||
layout_mode = 1
|
||||
offset_left = 20.0
|
||||
offset_top = 20.0
|
||||
offset_right = 420.0
|
||||
offset_bottom = 220.0
|
||||
|
||||
[node name="TimeLabel" type="Label" parent="InfoLabels" unique_id=18932607]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("29_jn6vt")
|
||||
|
||||
[node name="DistLabel" type="Label" parent="InfoLabels" unique_id=1743894966]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("29_jn6vt")
|
||||
|
||||
[node name="AudioPlayer" parent="." unique_id=425192018 node_paths=PackedStringArray("radio") instance=ExtResource("7_lapqe")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
@@ -180,10 +218,10 @@ anchor_left = 1.0
|
||||
anchor_top = 0.99814814
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.99814814
|
||||
offset_left = -146.0
|
||||
offset_top = -57.0
|
||||
offset_right = -146.0
|
||||
offset_bottom = -57.0
|
||||
offset_left = -166.0
|
||||
offset_top = -74.0
|
||||
offset_right = -166.0
|
||||
offset_bottom = -74.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
radio = NodePath("../Radio")
|
||||
|
||||
Reference in New Issue
Block a user