Unify action-button states across the UI
- Add UiStyles with explicit normal, hover, pressed, focus and disabled styles and apply it to every action button. - Disable timeline Previous/Next at the first/last event and keep Close always available. - Style settings reset-dialog buttons and cover the button-state audit in docs/ui-copy.md. - Add shared-state and timeline-boundary regression tests.
This commit is contained in:
1 parent
98c31fe44c
commit
9692f262f1
15 files changed
+172
-75
No files matched your search
@@ -11,6 +11,7 @@ signal settings_requested()
|
||||
signal quit_requested()
|
||||
|
||||
const UiArt := preload("res://src/game/ui/art.gd")
|
||||
const UiStyles := preload("res://src/game/ui/ui_styles.gd")
|
||||
const Strings := preload("res://src/core/strings.gd")
|
||||
|
||||
const VENUES := [
|
||||
@@ -108,7 +109,7 @@ func _build() -> void:
|
||||
_continue_button.name = "ContinueButton"
|
||||
_continue_button.custom_minimum_size = Vector2(460, 52)
|
||||
_continue_button.pressed.connect(_on_continue_pressed)
|
||||
_style_venue_button(_continue_button)
|
||||
UiStyles.apply_button(_continue_button, 18)
|
||||
column.add_child(_continue_button)
|
||||
|
||||
for i in VENUES.size():
|
||||
@@ -119,7 +120,7 @@ func _build() -> void:
|
||||
button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
button.custom_minimum_size = Vector2(460, 62)
|
||||
button.pressed.connect(_on_venue_pressed.bind(i))
|
||||
_style_venue_button(button)
|
||||
UiStyles.apply_button(button, 18)
|
||||
column.add_child(button)
|
||||
_buttons.append(button)
|
||||
|
||||
@@ -136,18 +137,21 @@ func _build() -> void:
|
||||
help_button.name = "HelpButton"
|
||||
help_button.text = Strings.lookup("ui.start_help")
|
||||
help_button.pressed.connect(func(): help_requested.emit())
|
||||
UiStyles.apply_button(help_button, 16)
|
||||
row.add_child(help_button)
|
||||
|
||||
var settings_button := Button.new()
|
||||
settings_button.name = "SettingsButton"
|
||||
settings_button.text = Strings.lookup("ui.start_settings")
|
||||
settings_button.pressed.connect(func(): settings_requested.emit())
|
||||
UiStyles.apply_button(settings_button, 16)
|
||||
row.add_child(settings_button)
|
||||
|
||||
var quit_button := Button.new()
|
||||
quit_button.name = "QuitButton"
|
||||
quit_button.text = Strings.lookup("ui.quit_game")
|
||||
quit_button.pressed.connect(func(): quit_requested.emit())
|
||||
UiStyles.apply_button(quit_button, 16)
|
||||
row.add_child(quit_button)
|
||||
|
||||
var hint := Label.new()
|
||||
@@ -158,35 +162,6 @@ func _build() -> void:
|
||||
|
||||
_focus_index(0)
|
||||
|
||||
## Match the dark, rounded rows in the `start_menu` mockup.
|
||||
func _style_venue_button(button: Button) -> void:
|
||||
button.add_theme_font_size_override("font_size", 18)
|
||||
button.add_theme_color_override("font_color", Color(0.94, 0.94, 0.92))
|
||||
button.add_theme_color_override("font_hover_color", Color.WHITE)
|
||||
var normal := StyleBoxFlat.new()
|
||||
normal.bg_color = Color(0.115, 0.125, 0.15, 0.96)
|
||||
normal.corner_radius_top_left = 12
|
||||
normal.corner_radius_top_right = 12
|
||||
normal.corner_radius_bottom_left = 12
|
||||
normal.corner_radius_bottom_right = 12
|
||||
normal.content_margin_left = 22
|
||||
normal.content_margin_right = 22
|
||||
normal.content_margin_top = 10
|
||||
normal.content_margin_bottom = 10
|
||||
var hover := normal.duplicate() as StyleBoxFlat
|
||||
hover.bg_color = Color(0.16, 0.175, 0.21, 0.98)
|
||||
var focus := normal.duplicate() as StyleBoxFlat
|
||||
focus.bg_color = Color(0.14, 0.155, 0.19, 0.98)
|
||||
focus.border_color = Color(0.85, 0.86, 0.88)
|
||||
focus.border_width_left = 2
|
||||
focus.border_width_top = 2
|
||||
focus.border_width_right = 2
|
||||
focus.border_width_bottom = 2
|
||||
button.add_theme_stylebox_override("normal", normal)
|
||||
button.add_theme_stylebox_override("hover", hover)
|
||||
button.add_theme_stylebox_override("focus", focus)
|
||||
button.add_theme_stylebox_override("pressed", hover)
|
||||
|
||||
func _focus_index(i: int) -> void:
|
||||
if _buttons.is_empty():
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user