152 lines
6.5 KiB
GDScript
152 lines
6.5 KiB
GDScript
class_name ModeSelectView
|
|
extends RefCounted
|
|
## Costruzione visuale del dialog modalità; la logica resta nel controller.
|
|
|
|
|
|
static func build(owner: CanvasLayer) -> Dictionary:
|
|
var dim := ColorRect.new()
|
|
dim.color = Color(0.045, 0.018, 0.012, 0.77)
|
|
dim.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
dim.mouse_filter = Control.MOUSE_FILTER_STOP
|
|
owner.add_child(dim)
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
owner.add_child(center)
|
|
|
|
var card := PanelContainer.new()
|
|
card.custom_minimum_size = Vector2(750, 550)
|
|
var frame := CircusTheme.flat_style(Color("#70411f"), Color("#edca69"), 6, 31)
|
|
frame.shadow_color = Color(0, 0, 0, 0.58)
|
|
frame.shadow_size = 22
|
|
frame.shadow_offset = Vector2(0, 9)
|
|
for side in [SIDE_LEFT, SIDE_RIGHT, SIDE_TOP, SIDE_BOTTOM]:
|
|
frame.set_content_margin(side, 10.0)
|
|
card.add_theme_stylebox_override("panel", frame)
|
|
center.add_child(card)
|
|
|
|
var wood := PanelContainer.new()
|
|
wood.add_theme_stylebox_override("panel", CircusTheme.wood_style())
|
|
card.add_child(wood)
|
|
var studs := BrassStuds.new()
|
|
studs.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
wood.add_child(studs)
|
|
var margin := MarginContainer.new()
|
|
margin.add_theme_constant_override("margin_left", 50)
|
|
margin.add_theme_constant_override("margin_right", 50)
|
|
margin.add_theme_constant_override("margin_top", 28)
|
|
margin.add_theme_constant_override("margin_bottom", 32)
|
|
wood.add_child(margin)
|
|
var content := VBoxContainer.new()
|
|
content.add_theme_constant_override("separation", 12)
|
|
content.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
margin.add_child(content)
|
|
_add_header(content)
|
|
var buttons := _add_mode_buttons(content)
|
|
var zen := _add_zen(content)
|
|
var play := _add_play(content)
|
|
var back := _add_back(content)
|
|
return {"card": card, "target": buttons.target, "infinite": buttons.infinite, "group": buttons.group, "zen": zen, "play": play, "back": back}
|
|
|
|
|
|
static func _add_header(parent: VBoxContainer) -> void:
|
|
var bunting := CircusTrim.new()
|
|
bunting.custom_minimum_size = Vector2(0, 34)
|
|
parent.add_child(bunting)
|
|
var title := Label.new()
|
|
title.text = "Scegli la modalità"
|
|
title.add_theme_font_override("font", CircusTheme.FONT)
|
|
title.add_theme_font_size_override("font_size", 45)
|
|
title.add_theme_color_override("font_color", Color("#6d3419"))
|
|
title.add_theme_color_override("font_outline_color", Color("#f5d985"))
|
|
title.add_theme_constant_override("outline_size", 3)
|
|
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
parent.add_child(title)
|
|
var subtitle := Label.new()
|
|
subtitle.text = "Come vuoi giocare?"
|
|
subtitle.add_theme_font_size_override("font_size", 18)
|
|
subtitle.add_theme_color_override("font_color", CircusTheme.INK)
|
|
subtitle.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
parent.add_child(subtitle)
|
|
|
|
|
|
static func _add_mode_buttons(parent: VBoxContainer) -> Dictionary:
|
|
var row := HBoxContainer.new()
|
|
row.add_theme_constant_override("separation", 18)
|
|
row.alignment = BoxContainer.ALIGNMENT_CENTER
|
|
parent.add_child(row)
|
|
var group := ButtonGroup.new()
|
|
var target := _mode_button("🎯 TARGET", "Raggiungi il punteggio stabilito")
|
|
var infinite := _mode_button("♾ INFINITA", "A vite, senza limite di punteggio")
|
|
target.button_group = group
|
|
infinite.button_group = group
|
|
row.add_child(target)
|
|
row.add_child(infinite)
|
|
return {"target": target, "infinite": infinite, "group": group}
|
|
|
|
|
|
static func _mode_button(title: String, hint: String) -> Button:
|
|
var button := Button.new()
|
|
button.text = title + "\n" + hint
|
|
button.custom_minimum_size = Vector2(305, 100)
|
|
button.add_theme_font_override("font", CircusTheme.FONT)
|
|
button.add_theme_font_size_override("font_size", 20)
|
|
button.add_theme_color_override("font_color", CircusTheme.INK)
|
|
button.add_theme_color_override("font_pressed_color", Color("#fff5d6"))
|
|
button.toggle_mode = true
|
|
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
|
button.add_theme_stylebox_override("normal", CircusTheme.button_style(Color("#ead7ac"), Color("#9b6b30"), 3))
|
|
button.add_theme_stylebox_override("hover", CircusTheme.button_style(Color("#f3dfad"), CircusTheme.BRASS_LIGHT, 4))
|
|
var selected := CircusTheme.button_style(Color("#a85b2c"), Color("#f4cf67"), 5)
|
|
button.add_theme_stylebox_override("pressed", selected)
|
|
button.add_theme_stylebox_override("hover_pressed", selected)
|
|
button.add_theme_stylebox_override("focus", selected)
|
|
return button
|
|
|
|
|
|
static func _add_zen(parent: VBoxContainer) -> CheckButton:
|
|
var center := CenterContainer.new()
|
|
center.custom_minimum_size = Vector2(0, 52)
|
|
parent.add_child(center)
|
|
var zen := CheckButton.new()
|
|
zen.text = " ZEN · senza countdown né decadimento"
|
|
zen.custom_minimum_size = Vector2(420, 46)
|
|
zen.add_theme_font_size_override("font_size", 17)
|
|
zen.add_theme_color_override("font_color", CircusTheme.INK)
|
|
zen.add_theme_stylebox_override("normal", CircusTheme.flat_style(Color("#ead6a8"), Color("#a77835"), 2, 12))
|
|
zen.add_theme_stylebox_override("hover", CircusTheme.flat_style(Color("#f2dfb2"), CircusTheme.BRASS, 3, 12))
|
|
zen.alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
center.add_child(zen)
|
|
return zen
|
|
|
|
|
|
static func _add_play(parent: VBoxContainer) -> Button:
|
|
var center := CenterContainer.new()
|
|
parent.add_child(center)
|
|
var button := Button.new()
|
|
button.text = "◆ GIOCA ◆"
|
|
button.custom_minimum_size = Vector2(380, 66)
|
|
button.add_theme_font_override("font", CircusTheme.FONT)
|
|
button.add_theme_font_size_override("font_size", 29)
|
|
button.add_theme_color_override("font_color", Color("#fff1c7"))
|
|
button.add_theme_stylebox_override("normal", CircusTheme.button_style(Color("#824720"), Color("#d9a947"), 5))
|
|
button.add_theme_stylebox_override("hover", CircusTheme.button_style(Color("#98562a"), CircusTheme.BRASS_LIGHT, 5))
|
|
button.add_theme_stylebox_override("pressed", CircusTheme.button_style(Color("#653318"), Color("#b7832e"), 4))
|
|
center.add_child(button)
|
|
return button
|
|
|
|
|
|
static func _add_back(parent: VBoxContainer) -> Button:
|
|
var center := CenterContainer.new()
|
|
center.custom_minimum_size = Vector2(0, 42)
|
|
parent.add_child(center)
|
|
var button := Button.new()
|
|
button.text = "← Indietro"
|
|
button.custom_minimum_size = Vector2(220, 42)
|
|
button.add_theme_font_override("font", CircusTheme.FONT)
|
|
button.add_theme_font_size_override("font_size", 18)
|
|
button.add_theme_color_override("font_color", CircusTheme.INK)
|
|
button.add_theme_stylebox_override("normal", CircusTheme.flat_style(Color("#ead7ac"), Color("#9b6b30"), 2, 10))
|
|
button.add_theme_stylebox_override("hover", CircusTheme.flat_style(Color("#f3dfad"), CircusTheme.BRASS_LIGHT, 3, 10))
|
|
center.add_child(button)
|
|
return button
|