generate new main menu screen
This commit is contained in:
@@ -126,15 +126,22 @@ func _apply_initial_train_start() -> void:
|
||||
if total_length <= 0.0:
|
||||
return
|
||||
|
||||
#start from a random position
|
||||
if environment_config != null and environment_config.train_start_from_random_position:
|
||||
if environment_config != null:
|
||||
match environment_config.train_start_from_random_position:
|
||||
EnvironmentConfig.TrainStartMode.RANDOM_POSITION:
|
||||
train_progress = randf() * total_length
|
||||
_update_next_stop_index_from_progress()
|
||||
elif environment_config != null and not stop_offset.is_empty():
|
||||
#start from a specific stop
|
||||
EnvironmentConfig.TrainStartMode.SPECIFIED_STATION:
|
||||
if stop_offset.is_empty():
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
else:
|
||||
var stop_index: int = clampi(environment_config.train_start_stop_index, 0, stop_offset.size() - 1)
|
||||
train_progress = stop_offset[stop_index]
|
||||
_set_next_stop_index_from_current(stop_index)
|
||||
EnvironmentConfig.TrainStartMode.SPECIFIED_POSITION:
|
||||
train_progress = wrapf(environment_config.train_start_position, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
else:
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
@@ -145,16 +152,22 @@ func _apply_train_start_delay() -> void:
|
||||
if not _initial_is_inmotion:
|
||||
return
|
||||
|
||||
var should_start_after_delay: bool = true
|
||||
var start_delay_seconds: float = 0.0
|
||||
if environment_config != null:
|
||||
should_start_after_delay = environment_config.train_start_after_delay
|
||||
start_delay_seconds = maxf(environment_config.train_start_delay_seconds, 0.0)
|
||||
if start_delay_seconds <= 0.0:
|
||||
if not should_start_after_delay:
|
||||
is_inmotion = false
|
||||
return
|
||||
|
||||
is_inmotion = false
|
||||
await get_tree().create_timer(start_delay_seconds).timeout
|
||||
if not is_inside_tree():
|
||||
return
|
||||
if not should_start_after_delay:
|
||||
return
|
||||
|
||||
is_inmotion = _initial_is_inmotion
|
||||
|
||||
@@ -285,6 +298,9 @@ func _plan_stops() -> void:
|
||||
stops_position.append(data["position"])
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if EnvironmentManagerRoot.is_keyboard_input_blocked(get_tree()):
|
||||
return
|
||||
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.keycode == KEY_T:
|
||||
_goto_next_stop()
|
||||
@@ -323,6 +339,7 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
func input_controls_management(delta: float) -> void:
|
||||
if not is_inmotion: return
|
||||
if EnvironmentManagerRoot.is_keyboard_input_blocked(get_tree()): return
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
train_speed += manual_acceleration * delta
|
||||
elif Input.is_action_pressed("ui_down"):
|
||||
|
||||
@@ -30,6 +30,7 @@ func _ready() -> void:
|
||||
UIEvents.toggle_pause_daytime.connect(_on_toggle_pause_daytime)
|
||||
UIEvents.time_option_item_changed.connect(_time_option_changed)
|
||||
|
||||
paused = environment_config.start_day_time_paused
|
||||
current_time = environment_config.start_time
|
||||
update_time(current_time)
|
||||
|
||||
|
||||
@@ -7,6 +7,14 @@ const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 32 #how many update of the en
|
||||
|
||||
@export var environment_config: EnvironmentConfig
|
||||
|
||||
@export_group("Input")
|
||||
@export var block_keyboard_input: bool = false:
|
||||
set(value):
|
||||
if block_keyboard_input == value:
|
||||
return
|
||||
block_keyboard_input = value
|
||||
_apply_keyboard_input_block()
|
||||
|
||||
@export_group("Camera")
|
||||
@export var camera: Camera3D
|
||||
@export var camera_pivot: Node3D
|
||||
@@ -40,8 +48,24 @@ var day_tween: Tween
|
||||
var day_time: float = 0.0
|
||||
var pending_environment_nodes: Dictionary = {}
|
||||
var weather_shader_no_noise: Material
|
||||
var _blocked_keyboard_events_by_action: Dictionary = {}
|
||||
|
||||
static func is_keyboard_input_blocked(tree: SceneTree) -> bool:
|
||||
if tree == null:
|
||||
return false
|
||||
|
||||
for node in tree.get_nodes_in_group("keyboard_input_blocker"):
|
||||
var environment_manager := node as EnvironmentManagerRoot
|
||||
if environment_manager != null and environment_manager.block_keyboard_input:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _enter_tree() -> void:
|
||||
add_to_group("keyboard_input_blocker")
|
||||
|
||||
func _ready() -> void:
|
||||
_apply_keyboard_input_block()
|
||||
|
||||
#connect shader when new node is added
|
||||
get_tree().node_added.connect(_on_tree_node_added)
|
||||
@@ -87,9 +111,51 @@ func _ready() -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
_process_pending_environment_nodes()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if block_keyboard_input and event is InputEventKey:
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
_restore_keyboard_action_events()
|
||||
remove_from_group("keyboard_input_blocker")
|
||||
|
||||
func flush_pending_environment_nodes() -> void:
|
||||
_process_pending_environment_nodes(-1)
|
||||
|
||||
func _apply_keyboard_input_block() -> void:
|
||||
if block_keyboard_input:
|
||||
_remove_keyboard_action_events()
|
||||
else:
|
||||
_restore_keyboard_action_events()
|
||||
|
||||
func _remove_keyboard_action_events() -> void:
|
||||
if not _blocked_keyboard_events_by_action.is_empty():
|
||||
return
|
||||
|
||||
for action in InputMap.get_actions():
|
||||
var keyboard_events: Array[InputEvent] = []
|
||||
for event in InputMap.action_get_events(action):
|
||||
if event is InputEventKey:
|
||||
keyboard_events.append(event)
|
||||
|
||||
if keyboard_events.is_empty():
|
||||
continue
|
||||
|
||||
_blocked_keyboard_events_by_action[action] = keyboard_events
|
||||
Input.action_release(action)
|
||||
for keyboard_event in keyboard_events:
|
||||
InputMap.action_erase_event(action, keyboard_event)
|
||||
|
||||
func _restore_keyboard_action_events() -> void:
|
||||
for action in _blocked_keyboard_events_by_action.keys():
|
||||
if not InputMap.has_action(action):
|
||||
continue
|
||||
|
||||
for keyboard_event in _blocked_keyboard_events_by_action[action]:
|
||||
InputMap.action_add_event(action, keyboard_event)
|
||||
|
||||
_blocked_keyboard_events_by_action.clear()
|
||||
|
||||
func _on_tree_node_added(node: Node) -> void:
|
||||
if node.is_in_group("wind_node") or node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
|
||||
_queue_dynamic_environment_node(node)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
class_name EnvironmentConfig
|
||||
extends Resource
|
||||
|
||||
enum TrainStartMode { RANDOM_POSITION, SPECIFIED_STATION, SPECIFIED_POSITION }
|
||||
|
||||
@export_group("Day")
|
||||
@export var start_time: float = 0.0 #start time of the day
|
||||
@export var day_duration: float = 300.0 #Duration of a full day cycle in seconds
|
||||
@export var start_day_time_paused: bool = false #Start with day time paused, without advancing the day cycle
|
||||
@export var sunrise: float = 0.25 #day_time 1.0→2.0 (night colors → morning colors)
|
||||
@export var day: float = 0.45 #day_time 2.0→2.0 (stays morning/afternoon)
|
||||
@export var sunset: float = 0.80 #day_time 2.0→3.0 (afternoon colors → night colors)
|
||||
@@ -156,9 +159,11 @@ extends Resource
|
||||
|
||||
#Train start settings
|
||||
@export_group("Train Start")
|
||||
@export var train_start_from_random_position: bool = true #When enabled the train starts from a random offset on the rail curve instead of a stop
|
||||
@export_enum("random_position", "specified_station", "specified_position") var train_start_from_random_position: int = TrainStartMode.RANDOM_POSITION #Train start mode
|
||||
@export_range(0, 64, 1, "or_greater") var train_start_stop_index: int = 1 #Stop index used for the train start when random start is disabled
|
||||
@export var train_start_delay_seconds: float = 3.0 #Seconds the train waits before starting at game launch
|
||||
@export var train_start_position: float = 0.0 #Offset on the rail curve used when train_start_from_random_position is specified_position
|
||||
@export var train_start_delay_seconds: float = 0.0 #Seconds the train waits before starting at game launch
|
||||
@export var train_start_after_delay: bool = true #When enabled the train starts after train_start_delay_seconds, otherwise it stays stopped
|
||||
@export var train_start_acceleration_seconds: float = 4.0 #Seconds used to progressively reach normal train speed after launch
|
||||
|
||||
#Snow settings
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_resource type="Resource" script_class="SceneConfig" format=3 uid="uid://dr612tmciq8pg"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://btcpge7cj2041" path="res://core/main_menu/main_menu.tscn" id="1_72aup"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgkqj51u6p8dn" path="res://tgcc/main menu/main_menu_test.tscn" id="1_ayiwx"]
|
||||
[ext_resource type="Script" uid="uid://bbgyhmb8a17i7" path="res://core/scene_manager/scene_config.gd" id="1_km45g"]
|
||||
[ext_resource type="PackedScene" uid="uid://vjf4bdxd8saj" path="res://tgcc/main_scene.tscn" id="2_prsyo"]
|
||||
[ext_resource type="PackedScene" uid="uid://ri5kxx4mipo" path="res://core/splash_screen/splash_screen.tscn" id="3_aasbo"]
|
||||
@@ -8,7 +8,7 @@
|
||||
[resource]
|
||||
script = ExtResource("1_km45g")
|
||||
scenes = Dictionary[int, PackedScene]({
|
||||
0: ExtResource("1_72aup"),
|
||||
0: ExtResource("1_ayiwx"),
|
||||
1: ExtResource("2_prsyo"),
|
||||
2: ExtResource("3_aasbo")
|
||||
})
|
||||
|
||||
@@ -26,4 +26,4 @@ func _ready() -> void:
|
||||
# Aspetta lo schermo nero prima di caricare il menu principale
|
||||
await get_tree().create_timer(black_screen_delay).timeout
|
||||
|
||||
get_tree().change_scene_to_packed(main_menu_scene)
|
||||
SceneManager.change_scene_with_standard_fade(SceneConfig.SceneName.MAIN_MENU, true)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://ckj2pcoxi5j3" path="res://core/splash_screen/splash_screen.gd" id="1_elsnp"]
|
||||
[ext_resource type="Texture2D" uid="uid://dp3qxncy8u184" path="res://core/splash_screen/jmp_logo.png" id="1_jkpgl"]
|
||||
[ext_resource type="PackedScene" uid="uid://btcpge7cj2041" path="res://core/main_menu/main_menu.tscn" id="2_qmlqp"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgkqj51u6p8dn" path="res://tgcc/main menu/main_menu_test.tscn" id="2_qmlqp"]
|
||||
|
||||
[node name="Control" type="Control" unique_id=163470013]
|
||||
layout_mode = 3
|
||||
@@ -13,7 +13,11 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_elsnp")
|
||||
main_menu_scene = ExtResource("2_qmlqp")
|
||||
initial_delay = null
|
||||
logo_fade_in_time = null
|
||||
logo_display_time = 1.25
|
||||
logo_fade_out_time = null
|
||||
black_screen_delay = null
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1599828641]
|
||||
layout_mode = 1
|
||||
|
||||
4
tgcc/main menu/main_menu_test.gd
Normal file
4
tgcc/main menu/main_menu_test.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
extends Node3D
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
1
tgcc/main menu/main_menu_test.gd.uid
Normal file
1
tgcc/main menu/main_menu_test.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cna45gowlxaqj
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://cgkqj51u6p8dn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmuvmmp7xam4o" path="res://core/daynight/environment_management.tscn" id="1_2o8pc"]
|
||||
[ext_resource type="Script" uid="uid://cna45gowlxaqj" path="res://tgcc/main menu/main_menu_test.gd" id="1_4j5xl"]
|
||||
[ext_resource type="Resource" uid="uid://dufa43jysup7" path="res://tgcc/main menu/menu.tres" id="2_vvb5q"]
|
||||
[ext_resource type="PackedScene" uid="uid://bmwmdsdyfxfc1" path="res://tgcc/map/map_1/map_menu.tscn" id="2_wbrya"]
|
||||
[ext_resource type="Shader" uid="uid://cpgtj8mhjklb8" path="res://tgcc/chunk/prop/cloud/cloud3d.gdshader" id="2_wcae3"]
|
||||
@@ -268,10 +269,12 @@ size = Vector2(600, 300)
|
||||
|
||||
[node name="MainMenu" type="Node3D" unique_id=448381304]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||
script = ExtResource("1_4j5xl")
|
||||
|
||||
[node name="EnvironmentManager" parent="." unique_id=1611939731 instance=ExtResource("1_2o8pc")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.822516, 0, 1.9254212)
|
||||
environment_config = ExtResource("2_vvb5q")
|
||||
block_keyboard_input = true
|
||||
cloud_material = SubResource("ShaderMaterial_00nq7")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=759297292]
|
||||
@@ -280,6 +283,7 @@ fov = 80.0
|
||||
size = 11.429
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=199803985]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -584,14 +588,14 @@ transform = Transform3D(-0.09359112, 0, 0.9713834, 0, 0.56225973, 0, -0.38276488
|
||||
[node name="Fuji4" parent="." unique_id=930179001 instance=ExtResource("99_61psf")]
|
||||
transform = Transform3D(-0.09359112, 0, 0.9713834, 0, 0.56225973, 0, -0.38276488, 0, -0.23751618, 239.46135, 1.7057877, 224.6928)
|
||||
|
||||
[node name="Landscape" parent="Fuji4" index="0" unique_id=244602034]
|
||||
[node name="Landscape" parent="Fuji4" index="0" unique_id=581950846]
|
||||
transform = Transform3D(28.638817, 1.7053026e-13, -7.6293945e-06, 0, 13.6219845, 2.1621709e-06, 0, -1.0284306e-06, 28.638834, -10.786804, 5.0069, 17.382736)
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_g1vc5")
|
||||
|
||||
[node name="Fuji5" parent="." unique_id=1070037082 instance=ExtResource("99_61psf")]
|
||||
transform = Transform3D(0.0935979, 0, 0.9713791, 0, 0.56225973, 0, -0.38276324, 0, 0.23753339, -275.95566, -3.4616928, 232.02234)
|
||||
|
||||
[node name="Landscape" parent="Fuji5" index="0" unique_id=244602034]
|
||||
[node name="Landscape" parent="Fuji5" index="0" unique_id=581950846]
|
||||
transform = Transform3D(28.638819, 1.7053026e-13, -7.6293945e-06, 0, 13.6219845, 2.1621709e-06, 0, -1.0284306e-06, 28.638836, -10.786743, 6.703195, 17.382767)
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_g1vc5")
|
||||
|
||||
@@ -601,7 +605,7 @@ transform = Transform3D(-4.88843, -0.020050459, 0.86837775, -0.010355438, 4.9646
|
||||
[node name="Fuji6" parent="." unique_id=150126281 instance=ExtResource("100_0aqpp")]
|
||||
transform = Transform3D(-5.287449, -0.020231497, 0.22351237, -0.011200703, 5.009496, 0.014500697, -0.9394429, 0.05414178, -1.2581636, 32.446022, 15.848213, 525.54346)
|
||||
|
||||
[node name="Mt Fuji_simplified_3d_mesh" parent="Fuji6" index="0" unique_id=1389340781]
|
||||
[node name="Mt Fuji_simplified_3d_mesh" parent="Fuji6" index="0" unique_id=65404928]
|
||||
transform = Transform3D(0.5151193, -0.011206273, -0.07264297, 0.077138014, 0.07483422, 0.48510167, 3.5762787e-07, -0.4938935, 0.07515043, 6.299696, 12.244916, 3.004303)
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_vvb5q")
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ shader_parameter/sun_color = Color(0.2841828, 0.2023238, 0.27953526, 1)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("3_vg0pk")
|
||||
start_time = 0.5
|
||||
start_day_time_paused = true
|
||||
morning_color = Color(0.93333334, 0.78039217, 0.6039216, 1)
|
||||
afternoon_color = Color(0.9490196, 0.62352943, 0.38039216, 1)
|
||||
night_color = Color(0.18431373, 0.18431373, 0.4862745, 1)
|
||||
@@ -83,6 +85,9 @@ godray_spawn_radius = 100.0
|
||||
godray_spawn_offset = Vector3(20, 80, 20)
|
||||
godray_rotation_degrees = Vector3(50, 30, 0)
|
||||
godray_scale = Vector3(2, 25, 50)
|
||||
train_start_from_random_position = 2
|
||||
train_start_position = 100.5
|
||||
train_start_after_delay = false
|
||||
snow_amount = 2000.0
|
||||
wind_amount = 50
|
||||
cloud_speed = 0.01
|
||||
|
||||
Reference in New Issue
Block a user