fix new main menu
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
|
||||
signal settings_requested
|
||||
|
||||
const TRAIN_WHISTLE_STREAM: AudioStream = preload("res://tgcc/train/sounds/train_whistle2.mp3")
|
||||
|
||||
@onready var play_button: Button = $%PlayButton
|
||||
@@ -18,6 +20,7 @@ func _ready() -> void:
|
||||
save_button.pressed.connect(_on_save_button_pressed)
|
||||
quit_button.pressed.connect(_on_quit_button_pressed)
|
||||
resume_button.pressed.connect(func(): UIEvents.resume_game_requested.emit())
|
||||
settings_button.pressed.connect(func(): settings_requested.emit())
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
_play_train_horn()
|
||||
|
||||
@@ -4,7 +4,7 @@ extends Control
|
||||
@onready var option_menu: Control = $%OptionMenu
|
||||
|
||||
func _ready() -> void:
|
||||
option_menu.settings_button.pressed.connect(_on_settings_button_pressed)
|
||||
option_menu.settings_requested.connect(_on_settings_button_pressed)
|
||||
|
||||
|
||||
func _on_settings_button_pressed() -> void:
|
||||
|
||||
47
core/main_menu/sign.gd
Normal file
47
core/main_menu/sign.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Node3D
|
||||
|
||||
@export var sub_viewport: SubViewport
|
||||
@onready var quad_cartello = $%QuadSign
|
||||
@onready var coll_shape = $%CollisionShape3D
|
||||
|
||||
func _ready() -> void:
|
||||
sub_viewport.transparent_bg = true
|
||||
|
||||
var mat = StandardMaterial3D.new()
|
||||
mat.albedo_texture = sub_viewport.get_texture()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
|
||||
#fix color
|
||||
sub_viewport.use_hdr_2d = false
|
||||
mat.albedo_texture_force_srgb = true
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.albedo_color = Color(0.85, 0.85, 0.85, 1.0)
|
||||
|
||||
quad_cartello.material_override = mat
|
||||
|
||||
coll_shape.shape.size = Vector3(2.0, 2.0, 2.0)
|
||||
coll_shape.position.z = 0.0
|
||||
|
||||
|
||||
func _on_area_3d_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
|
||||
if event is InputEventMouse:
|
||||
var local_cam = quad_cartello.to_local(camera.global_position)
|
||||
var local_hit = quad_cartello.to_local(event_position)
|
||||
var ray_dir = (local_hit - local_cam).normalized()
|
||||
|
||||
if abs(ray_dir.z) < 0.0001: return
|
||||
|
||||
var t = -local_cam.z / ray_dir.z
|
||||
var exact_pos = local_cam + ray_dir * t
|
||||
|
||||
var uv_x = exact_pos.x + 0.5
|
||||
var uv_y = 0.5 - exact_pos.y
|
||||
if uv_x < 0 or uv_x > 1 or uv_y < 0 or uv_y > 1:
|
||||
return
|
||||
|
||||
var viewport_pos = Vector2(uv_x * sub_viewport.size.x, uv_y * sub_viewport.size.y)
|
||||
var ev2d = event.duplicate()
|
||||
ev2d.position = viewport_pos
|
||||
ev2d.global_position = viewport_pos
|
||||
|
||||
sub_viewport.push_input(ev2d)
|
||||
1
core/main_menu/sign.gd.uid
Normal file
1
core/main_menu/sign.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://duiqgeista384
|
||||
Reference in New Issue
Block a user