feat: enhance choice layout parameters for ground finish chooser
This commit is contained in:
@@ -159,9 +159,13 @@
|
||||
"choice_font_size": 18,
|
||||
"choice_min_width": 104,
|
||||
"choice_corner_radius": 12,
|
||||
"choice_content_inset_x": 8,
|
||||
"choice_content_inset_y": 6,
|
||||
"compact_choice_height": 50,
|
||||
"compact_choice_preview_height": 22,
|
||||
"compact_choice_font_size": 16,
|
||||
"compact_choice_content_inset": 4,
|
||||
"compact_choice_content_separation": 2,
|
||||
"compact_grid_gap": 6,
|
||||
"compact_layout_max_width": 600,
|
||||
"compact_layout_max_height": 460,
|
||||
|
||||
@@ -33,6 +33,10 @@ var _grid_gap: int = 8
|
||||
var _compact_choice_height: int = 54
|
||||
var _compact_choice_preview_height: int = 22
|
||||
var _compact_choice_font_size: int = 16
|
||||
var _choice_content_inset_x: int = 8
|
||||
var _choice_content_inset_y: int = 6
|
||||
var _compact_choice_content_inset: int = 4
|
||||
var _compact_choice_content_separation: int = 2
|
||||
var _compact_grid_gap: int = 6
|
||||
var _compact_layout_max_width: int = 600
|
||||
var _compact_layout_max_height: int = 460
|
||||
@@ -107,6 +111,10 @@ func _configure_theme_values() -> void:
|
||||
_compact_choice_height = _theme_int("compact_choice_height", 50, 48, 72)
|
||||
_compact_choice_preview_height = _theme_int("compact_choice_preview_height", 22, 16, 36)
|
||||
_compact_choice_font_size = _theme_int("compact_choice_font_size", 16, 14, 20)
|
||||
_choice_content_inset_x = _theme_int("choice_content_inset_x", 8, 4, 20)
|
||||
_choice_content_inset_y = _theme_int("choice_content_inset_y", 6, 3, 16)
|
||||
_compact_choice_content_inset = _theme_int("compact_choice_content_inset", 4, 3, 12)
|
||||
_compact_choice_content_separation = _theme_int("compact_choice_content_separation", 2, 0, 8)
|
||||
_compact_grid_gap = _theme_int("compact_grid_gap", 6, 4, 12)
|
||||
_compact_layout_max_width = _theme_int("compact_layout_max_width", 600, 440, 760)
|
||||
_compact_layout_max_height = _theme_int("compact_layout_max_height", 460, 360, 640)
|
||||
@@ -158,7 +166,9 @@ func _build_choice_buttons() -> void:
|
||||
button.focus_mode = Control.FOCUS_ALL
|
||||
_apply_choice_style(button)
|
||||
var contents := VBoxContainer.new()
|
||||
contents.name = "ChoiceContent"
|
||||
contents.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
contents.clip_contents = true
|
||||
contents.add_theme_constant_override("separation", 4)
|
||||
contents.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
var sample := GROUND_PREVIEW.new() as StageGroundFinishPreview
|
||||
@@ -327,13 +337,28 @@ func _apply_choice_density(compact: bool) -> void:
|
||||
var button: Button = _choice_buttons[finish_id] as Button
|
||||
button.custom_minimum_size.y = target_height
|
||||
_apply_choice_style(button)
|
||||
var inset_y: float = float(_compact_choice_content_inset if compact else _choice_content_inset_y)
|
||||
var content_separation: int = _compact_choice_content_separation if compact else 4
|
||||
var label_height: float = 18.0 if compact else 20.0
|
||||
var available_preview_height: float = maxf(
|
||||
16.0,
|
||||
target_height - inset_y * 2.0 - label_height - float(content_separation)
|
||||
)
|
||||
var preview_height: float = minf(target_preview_height, available_preview_height)
|
||||
var contents: VBoxContainer = button.get_node_or_null("ChoiceContent") as VBoxContainer
|
||||
if contents != null:
|
||||
contents.offset_left = float(_choice_content_inset_x)
|
||||
contents.offset_top = inset_y
|
||||
contents.offset_right = -float(_choice_content_inset_x)
|
||||
contents.offset_bottom = -inset_y
|
||||
contents.add_theme_constant_override("separation", content_separation)
|
||||
var sample: StageGroundFinishPreview = _choice_previews[finish_id] as StageGroundFinishPreview
|
||||
if sample != null:
|
||||
sample.custom_minimum_size.y = target_preview_height
|
||||
sample.custom_minimum_size.y = preview_height
|
||||
var label: Label = _choice_labels[finish_id] as Label
|
||||
if label != null:
|
||||
label.add_theme_font_size_override("font_size", target_font_size)
|
||||
label.custom_minimum_size.y = 18.0 if compact else 20.0
|
||||
label.custom_minimum_size.y = label_height
|
||||
|
||||
|
||||
func _focus_selected_choice() -> void:
|
||||
@@ -363,9 +388,9 @@ func _choice_box(background: Color, border: Color, border_width: int) -> StyleBo
|
||||
style.border_color = border
|
||||
style.set_border_width_all(border_width)
|
||||
style.set_corner_radius_all(_theme_int("choice_corner_radius", 12, 8, 24))
|
||||
style.content_margin_left = 8.0
|
||||
style.content_margin_right = 8.0
|
||||
var vertical_padding: float = 2.0 if _is_compact_layout else 6.0
|
||||
style.content_margin_left = float(_choice_content_inset_x)
|
||||
style.content_margin_right = float(_choice_content_inset_x)
|
||||
var vertical_padding: float = float(_compact_choice_content_inset) if _is_compact_layout else float(_choice_content_inset_y)
|
||||
style.content_margin_top = vertical_padding
|
||||
style.content_margin_bottom = vertical_padding
|
||||
return style
|
||||
|
||||
@@ -134,9 +134,13 @@ func _apply_phase19_defaults() -> void:
|
||||
"choice_font_size": 18,
|
||||
"choice_min_width": 104,
|
||||
"choice_corner_radius": 12,
|
||||
"choice_content_inset_x": 8,
|
||||
"choice_content_inset_y": 6,
|
||||
"compact_choice_height": 50,
|
||||
"compact_choice_preview_height": 22,
|
||||
"compact_choice_font_size": 16,
|
||||
"compact_choice_content_inset": 4,
|
||||
"compact_choice_content_separation": 2,
|
||||
"compact_grid_gap": 6,
|
||||
"compact_layout_max_width": 600,
|
||||
"compact_layout_max_height": 460,
|
||||
|
||||
Reference in New Issue
Block a user