tooltips and ui #42

Merged
m.cirafisi merged 7 commits from tooltip into main 2026-07-02 20:57:07 +00:00
4 changed files with 140 additions and 119 deletions
Showing only changes of commit 238dd4a124 - Show all commits

View File

@@ -84,9 +84,12 @@ var wagon_instances: Array[Node3D] = []
var wagon_progress_offsets: Array[float] = []
var _pending_steam_distance_km: float = 0.0
var _initial_is_inmotion: bool = true
var _is_photo_mode_active: bool = false
func _ready() -> void:
randomize()
GameState.on_enable_photo_mode_request.connect(func(): _is_photo_mode_active = true)
GameState.on_disable_photo_mode_request.connect(func(): _is_photo_mode_active = false)
_cache_environment_config()
_initial_is_inmotion = is_inmotion
@@ -285,9 +288,12 @@ func _plan_stops() -> void:
stops_position.append(data["position"])
func _input(event: InputEvent) -> void:
if _is_photo_mode_active: return
if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_T:
_goto_next_stop()
if event.is_action_pressed("train_horn"):
UIEvents.toot_toot.emit(true)
#elif event.keycode == KEY_F:
#_test_manual_fireworks()
@@ -322,12 +328,12 @@ func _physics_process(delta: float) -> void:
train_move(delta)
func input_controls_management(delta: float) -> void:
if not is_inmotion: return
if Input.is_action_pressed("ui_up"):
if not is_inmotion or _is_photo_mode_active: return
if Input.is_action_pressed("train_speed_up"):
train_speed += manual_acceleration * delta
elif Input.is_action_pressed("ui_down"):
elif Input.is_action_pressed("train_speed_down"):
train_speed -= manual_acceleration * delta
elif Input.is_action_pressed("ui_text_backspace"):
elif Input.is_action_pressed("train_stop"):
train_speed = 0
train_speed = clamp(train_speed, speed_min, speed_max)

View File

@@ -46,111 +46,81 @@ func _ready():
if camera_iso:
set_camera(camera_iso)
func sync_zoom(new_size: float, new_fov: float) -> void:
if camera_iso:
camera_iso.size = new_size
camera_iso.fov = new_fov
if abs(new_size - zoom_size) < abs(new_size - normal_size):
is_zoomed = true
else:
is_zoomed = false
func set_camera(camera: Camera3D):
camera.make_current()
emit_signal("camera_changed", camera)
func _input(event):
if event is InputEventKey and event.pressed and not event.echo:
#R-> Reset isometric camera
if event.keycode == KEY_R and is_moving_enabled and pivot:
pivot.transform = initial_pivot_transformation
print("Isometric camera resetted!")
return
#C-> Toggle cinematic mode
if event.keycode == KEY_C:
is_cinematic_mode = !is_cinematic_mode
if is_cinematic_mode:
cinematic_timer = 0.0
for i in range(array_camera.size()):
if array_camera[i].current:
cinematic_index = i
break
print("Cinematic Mode: enabled")
else:
print("Cinematic Mode: disabled")
return
#Z-> soft zoom
if event.keycode == KEY_Z and camera_iso:
is_zoomed = !is_zoomed
var target_size = zoom_size if is_zoomed else normal_size
if zoom_tween and zoom_tween.is_valid():
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera_iso, "size", target_size, zoom_time)
return
#manual controls (1-5)
var manual_action = false
if event.keycode == KEY_1 and camera_iso:
set_camera(camera_iso)
is_moving_enabled = true
manual_action = true
elif event.keycode == KEY_2 and camera_front:
set_camera(camera_front)
is_moving_enabled = false
manual_action = true
elif event.keycode == KEY_3 and camera_side1:
set_camera(camera_side1)
is_moving_enabled = false
manual_action = true
elif event.keycode == KEY_4 and camera_side2:
set_camera(camera_side2)
is_moving_enabled = false
manual_action = true
elif event.keycode == KEY_5 and camera_top:
set_camera(camera_top)
is_moving_enabled = false
manual_action = true
if manual_action and is_cinematic_mode:
is_cinematic_mode = false
print("Cinematic Mode: Disabled")
if is_moving_enabled and pivot:
if event is InputEventMouseMotion and Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
pivot.rotate_y(deg_to_rad(-event.relative.x * rotation_speed))
func _process(delta):
if is_cinematic_mode and array_camera.size() > 0:
cinematic_timer += delta
if cinematic_timer >= change_camera_time:
cinematic_timer = 0.0
cinematic_index = (cinematic_index + 1) % array_camera.size()
var next_cam = array_camera[cinematic_index]
set_camera(next_cam)
is_moving_enabled = (next_cam == camera_iso)
if not is_moving_enabled or pivot == null:
func _process(delta: float) -> void:
if camera_iso == null or get_viewport().get_camera_3d() != camera_iso:
return
var input_dir = Vector3.ZERO
if Input.is_key_pressed(KEY_W): input_dir.z -= 1
if Input.is_key_pressed(KEY_S): input_dir.z += 1
if Input.is_key_pressed(KEY_A): input_dir.x -= 1
if Input.is_key_pressed(KEY_D): input_dir.x += 1
if input_dir != Vector3.ZERO:
input_dir = input_dir.normalized()
if Input.is_action_just_pressed("photo_zoom_in"):
if is_zoomed == false:
return
is_zoomed = false
var target_size = normal_size
var forward = pivot.transform.basis.z
var right = pivot.transform.basis.x
forward.y = 0
right.y = 0
if zoom_tween and zoom_tween.is_valid():
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera_iso, "size", target_size, zoom_time)
zoom_tween.parallel().tween_property(camera_iso, "fov", target_size, zoom_time)
elif Input.is_action_just_pressed("photo_zoom_out"):
if is_zoomed == true:
return
is_zoomed = true
var target_size = zoom_size
forward = forward.normalized()
right = right.normalized()
var motion = (forward * input_dir.z + right * input_dir.x)
pivot.position += motion * move_speed * delta
if zoom_tween and zoom_tween.is_valid():
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera_iso, "size", target_size, zoom_time)
zoom_tween.parallel().tween_property(camera_iso, "fov", target_size, zoom_time)
#func _process_movement(delta):
#if is_cinematic_mode and array_camera.size() > 0:
#cinematic_timer += delta
#if cinematic_timer >= change_camera_time:
#cinematic_timer = 0.0
#cinematic_index = (cinematic_index + 1) % array_camera.size()
#var next_cam = array_camera[cinematic_index]
#set_camera(next_cam)
#is_moving_enabled = (next_cam == camera_iso)
#
#if not is_moving_enabled or pivot == null:
#return
#
#var input_dir = Vector3.ZERO
#if Input.is_key_pressed(KEY_W): input_dir.z -= 1
#if Input.is_key_pressed(KEY_S): input_dir.z += 1
#if Input.is_key_pressed(KEY_A): input_dir.x -= 1
#if Input.is_key_pressed(KEY_D): input_dir.x += 1
#
#if input_dir != Vector3.ZERO:
#input_dir = input_dir.normalized()
#
#var forward = pivot.transform.basis.z
#var right = pivot.transform.basis.x
#forward.y = 0
#right.y = 0
#
#forward = forward.normalized()
#right = right.normalized()
#
#var motion = (forward * input_dir.z + right * input_dir.x)
#pivot.position += motion * move_speed * delta

View File

@@ -64,6 +64,18 @@ func _input(event: InputEvent) -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
show_ui()
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_options"):
if photo_mode_texture_panel.visible:
return
if game_menu_panel.visible:
_on_resume_button_pressed()
else:
_open_game_menu_on_page(2)
elif event.is_action_pressed("hide_ui"):
if not game_menu_panel.visible:
_on_hide_ui_button_pressed()
func _on_photo_icon_button_pressed() -> void:
GameState.on_enable_photo_mode_request.emit()

View File

@@ -49,18 +49,35 @@ func enable_photo_mode() -> void:
current_pan = Vector2.ZERO
if camera:
if previous_camera:
camera.size = previous_camera.size
camera.fov = previous_camera.fov
if abs(camera.size - zoom_size) < abs(camera.size - normal_size):
is_zoomed = true
else:
is_zoomed = false
camera.make_current()
func disable_photo_mode() -> void:
is_active = false
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if previous_camera:
previous_camera.size = camera.size
previous_camera.fov = camera.fov
var parent = previous_camera.get_parent()
if parent and parent.has_method("sync_zoom"):
parent.sync_zoom(camera.size, camera.fov)
previous_camera.make_current()
func _input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_Z and camera:
is_zoomed = !is_zoomed
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_WHEEL_UP and camera:
if is_zoomed == false:
return
is_zoomed = false
var target_size = zoom_size if is_zoomed else normal_size
if zoom_tween and zoom_tween.is_valid():
@@ -70,6 +87,34 @@ func _input(event: InputEvent) -> void:
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera, "size", target_size, zoom_time)
zoom_tween.parallel().tween_property(camera, "fov", target_size, zoom_time)
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and camera:
if is_zoomed == true:
return
is_zoomed = true
var target_size = zoom_size if is_zoomed else normal_size
if zoom_tween and zoom_tween.is_valid():
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera, "size", target_size, zoom_time)
zoom_tween.parallel().tween_property(camera, "fov", target_size, zoom_time)
if is_active:
if event.is_action_pressed("exit_photo_mode") and not is_making_photo:
GameState.on_disable_photo_mode_request.emit()
elif event.is_action_pressed("take_photo"):
if not is_making_photo:
is_making_photo = true
GameState.on_photo_taken_prepare.emit()
await RenderingServer.frame_post_draw
captured_image = get_viewport().get_texture().get_image()
GameState.on_photo_taken_started.emit()
if event.is_action_pressed("toggle_photo_mode"):
if get_tree().paused:
@@ -82,18 +127,6 @@ func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion and is_active:
total_yaw -= event.relative.x * rotation_speed
if event.is_action_pressed("take_photo"):
if !is_active or is_making_photo:
return
is_making_photo = true
GameState.on_photo_taken_prepare.emit()
await RenderingServer.frame_post_draw
captured_image = get_viewport().get_texture().get_image()
GameState.on_photo_taken_started.emit()
func _process(delta: float) -> void:
if not is_active: