|
|
|
@@ -18,6 +18,25 @@ const SETTINGS_BUTTON := preload("res://menus/assets/common/pulsante_rotellina.p
|
|
|
|
|
const CIRCUS_SIGN_PANEL := preload("res://menus/assets/p1/upendi_circus_sign_panel.png")
|
|
|
|
|
const CIRCUS_SIGN_ROPES := preload("res://menus/assets/p1/upendi_circus_sign_ropes.png")
|
|
|
|
|
|
|
|
|
|
const CURTAIN_FRAMES := [
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_00.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_01.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_02.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_03.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_04.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_05.png"),
|
|
|
|
|
preload("res://menus/assets/p1/curtain_anim/curtain_06.png"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const GARLAND_FRAMES := [
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_00.png"),
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_01.png"),
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_02.png"),
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_03.png"),
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_04.png"),
|
|
|
|
|
preload("res://menus/assets/p1/garland_anim/lights_05.png"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
|
|
@@ -29,30 +48,118 @@ func _build() -> void:
|
|
|
|
|
MenuUI.add_full_texture(self, CLOUDS, MenuUI.ambient_material(1.0, 0.16))
|
|
|
|
|
_add_sign()
|
|
|
|
|
|
|
|
|
|
var blue := _add_tent_button(BLUE_TENT, Vector2(0.29, 0.46))
|
|
|
|
|
# Solo il tendone blu di riferimento attiva lo shader delle lucine in hover.
|
|
|
|
|
var blue := _add_tent_button(BLUE_TENT, Vector2(0.29, 0.46), true)
|
|
|
|
|
blue.pressed.connect(func(): juggle_requested.emit(blue))
|
|
|
|
|
var red := _add_tent_button(RED_TENT, Vector2(0.71, 0.46))
|
|
|
|
|
var red := _add_tent_button(RED_TENT, Vector2(0.71, 0.46), false)
|
|
|
|
|
red.pressed.connect(func(): gym_requested.emit(red))
|
|
|
|
|
|
|
|
|
|
_add_bottom_bar()
|
|
|
|
|
MenuUI.add_image(self, SETTINGS_BUTTON, Vector2(0.91, 0.13), Vector2(0.09, 0.14))
|
|
|
|
|
if not OS.has_feature("web"):
|
|
|
|
|
var exit_button := MenuUI.add_image_button(self, BACK_BUTTON, Vector2(0.075, 0.13), Vector2(0.09, 0.14))
|
|
|
|
|
var exit_button := MenuUI.add_image_button(self, BACK_BUTTON, MenuUI.BACK_BUTTON_CENTER, MenuUI.BACK_BUTTON_SIZE)
|
|
|
|
|
exit_button.pressed.connect(func(): exit_requested.emit())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _add_tent_button(texture: Texture2D, center: Vector2) -> TextureButton:
|
|
|
|
|
func _add_tent_button(texture: Texture2D, center: Vector2, has_lights := false) -> TextureButton:
|
|
|
|
|
var button := MenuUI.add_image_button(self, texture, center, Vector2(0.36, 0.59))
|
|
|
|
|
var star_material := MenuUI.tent_star_material()
|
|
|
|
|
button.material = star_material
|
|
|
|
|
var star_mat := MenuUI.tent_star_material()
|
|
|
|
|
button.material = star_mat
|
|
|
|
|
button.tooltip_text = "Apri questo percorso"
|
|
|
|
|
# L'hover non altera più geometria e hitbox del tendone: mette in risalto
|
|
|
|
|
# esclusivamente la stella, tramite il parametro dello shader.
|
|
|
|
|
button.mouse_entered.connect(func(): star_material.set_shader_parameter("hover_strength", 1.0))
|
|
|
|
|
button.mouse_exited.connect(func(): star_material.set_shader_parameter("hover_strength", 0.0))
|
|
|
|
|
|
|
|
|
|
# Glow stella su entrambi i tendoni al passaggio del mouse
|
|
|
|
|
button.mouse_entered.connect(func(): star_mat.set_shader_parameter("hover_strength", 1.0))
|
|
|
|
|
button.mouse_exited.connect(func(): star_mat.set_shader_parameter("hover_strength", 0.0))
|
|
|
|
|
|
|
|
|
|
# Animazione apertura sipario e lucine in hover
|
|
|
|
|
if has_lights:
|
|
|
|
|
_setup_hover_curtain_and_garland(button, center)
|
|
|
|
|
|
|
|
|
|
return button
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _setup_hover_curtain_and_garland(parent_button: TextureButton, center: Vector2) -> void:
|
|
|
|
|
# Sipario: parte chiuso (frame 0). All'hover-in si apre (0 -> 6).
|
|
|
|
|
# All'hover-out si richiude al contrario (6 -> 0).
|
|
|
|
|
var curtain := TextureRect.new()
|
|
|
|
|
curtain.name = "Curtain"
|
|
|
|
|
curtain.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
|
|
|
curtain.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
|
|
|
curtain.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
curtain.texture = CURTAIN_FRAMES[0]
|
|
|
|
|
add_child(curtain)
|
|
|
|
|
MenuUI.set_normalized_rect(curtain, center, Vector2(0.36, 0.59))
|
|
|
|
|
|
|
|
|
|
var curtain_idx := [0]
|
|
|
|
|
var curtain_dir := [0] # 0 = fermo, 1 = apre, -1 = chiude
|
|
|
|
|
var curtain_timer := Timer.new()
|
|
|
|
|
curtain_timer.wait_time = 1.0 / 12.5
|
|
|
|
|
curtain_timer.process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
|
curtain_timer.timeout.connect(func():
|
|
|
|
|
if curtain_dir[0] == 1:
|
|
|
|
|
if curtain_idx[0] < CURTAIN_FRAMES.size() - 1:
|
|
|
|
|
curtain_idx[0] += 1
|
|
|
|
|
curtain.texture = CURTAIN_FRAMES[curtain_idx[0]]
|
|
|
|
|
curtain.visible = true
|
|
|
|
|
else:
|
|
|
|
|
# Completamente aperto: frame 06 è vuoto/trasparente
|
|
|
|
|
curtain.texture = CURTAIN_FRAMES[curtain_idx[0]]
|
|
|
|
|
curtain_dir[0] = 0
|
|
|
|
|
curtain_timer.stop()
|
|
|
|
|
elif curtain_dir[0] == -1:
|
|
|
|
|
if curtain_idx[0] > 0:
|
|
|
|
|
curtain_idx[0] -= 1
|
|
|
|
|
curtain.texture = CURTAIN_FRAMES[curtain_idx[0]]
|
|
|
|
|
curtain.visible = true
|
|
|
|
|
else:
|
|
|
|
|
# Completamente chiuso: resta fermo su frame 00
|
|
|
|
|
curtain.texture = CURTAIN_FRAMES[0]
|
|
|
|
|
curtain_dir[0] = 0
|
|
|
|
|
curtain_timer.stop()
|
|
|
|
|
)
|
|
|
|
|
add_child(curtain_timer)
|
|
|
|
|
|
|
|
|
|
# Lucine a inseguimento
|
|
|
|
|
var lights := TextureRect.new()
|
|
|
|
|
lights.name = "HoverGarland"
|
|
|
|
|
lights.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
|
|
|
lights.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
|
|
|
lights.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
lights.texture = GARLAND_FRAMES[0]
|
|
|
|
|
lights.visible = false
|
|
|
|
|
add_child(lights)
|
|
|
|
|
MenuUI.set_normalized_rect(lights, center, Vector2(0.36, 0.59))
|
|
|
|
|
|
|
|
|
|
var lights_idx := [0]
|
|
|
|
|
var lights_timer := Timer.new()
|
|
|
|
|
lights_timer.wait_time = 1.0 / 12.5
|
|
|
|
|
lights_timer.process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
|
lights_timer.timeout.connect(func():
|
|
|
|
|
lights_idx[0] = (lights_idx[0] + 1) % GARLAND_FRAMES.size()
|
|
|
|
|
if lights.visible:
|
|
|
|
|
lights.texture = GARLAND_FRAMES[lights_idx[0]]
|
|
|
|
|
)
|
|
|
|
|
add_child(lights_timer)
|
|
|
|
|
lights_timer.start()
|
|
|
|
|
|
|
|
|
|
parent_button.mouse_entered.connect(func():
|
|
|
|
|
# Avvia apertura sipario (hover in)
|
|
|
|
|
curtain_dir[0] = 1
|
|
|
|
|
curtain_timer.start()
|
|
|
|
|
# Avvia lucine
|
|
|
|
|
lights_idx[0] = 0
|
|
|
|
|
lights.texture = GARLAND_FRAMES[0]
|
|
|
|
|
lights.visible = true
|
|
|
|
|
)
|
|
|
|
|
parent_button.mouse_exited.connect(func():
|
|
|
|
|
# Avvia chiusura sipario al contrario (hover out)
|
|
|
|
|
curtain_dir[0] = -1
|
|
|
|
|
curtain_timer.start()
|
|
|
|
|
# Spegne lucine
|
|
|
|
|
lights.visible = false
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _add_bottom_bar() -> void:
|
|
|
|
|
# Il piedone entra dal basso come un unico blocco; la scritta resta
|
|
|
|
|
# invisibile fino a quando il rimbalzo della barra non è terminato.
|
|
|
|
|