Files
autgame/menus/scripts/screens/p3a_gym_menu_screen.gd
T

67 lines
2.1 KiB
GDScript

class_name P3AGymMenuScreen
extends Control
## P3A segue la stessa composizione mockup + hotspot trasparenti di P2A.
signal back_requested
signal game_requested
signal feedback_requested(frequency: float)
const MOCKUP := preload("res://menus/assets/p3a/p3a_menu_mockup.jpg")
var players_count := 3
var count_patch: ColorRect
var count_label: Label
func _ready() -> void:
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
_build()
func _build() -> void:
var artwork := TextureRect.new()
artwork.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
artwork.texture = MOCKUP
artwork.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
artwork.stretch_mode = TextureRect.STRETCH_SCALE
artwork.mouse_filter = Control.MOUSE_FILTER_IGNORE
artwork.material = MenuUI.submenu_lights_material()
add_child(artwork)
_add_hotspot(MenuUI.BACK_BUTTON_CENTER, MenuUI.BACK_BUTTON_SIZE, func(): back_requested.emit())
_add_hotspot(Vector2(0.775, 0.64), Vector2(0.07, 0.10), func(): _change_players(-1))
_add_hotspot(Vector2(0.895, 0.64), Vector2(0.07, 0.10), func(): _change_players(1))
_add_hotspot(Vector2(0.79, 0.88), Vector2(0.30, 0.14), _start_game)
_build_dynamic_count()
func _add_hotspot(center: Vector2, normalized_size: Vector2, action: Callable) -> void:
var hotspot := MenuUI.add_hotspot(self, center, normalized_size)
hotspot.tooltip_text = ""
hotspot.pressed.connect(func(): action.call())
func _build_dynamic_count() -> void:
count_patch = ColorRect.new()
count_patch.color = Color(1.0, 1.0, 1.0, 0.96)
count_patch.mouse_filter = Control.MOUSE_FILTER_IGNORE
count_patch.visible = false
add_child(count_patch)
MenuUI.set_normalized_rect(count_patch, Vector2(0.835, 0.64), Vector2(0.055, 0.09))
count_label = MenuUI.add_label(self, str(players_count), Vector2(0.835, 0.64), Vector2(0.055, 0.09), 32)
count_label.visible = false
func _change_players(delta: int) -> void:
players_count = clampi(players_count + delta, 1, 5)
count_patch.visible = true
count_label.visible = true
count_label.text = str(players_count)
feedback_requested.emit(440.0 + 45.0 * players_count)
func _start_game() -> void:
feedback_requested.emit(784.0)
game_requested.emit()