From 3900b4661855f9e9bc4fafb569770574a23da21d Mon Sep 17 00:00:00 2001 From: Voyager Date: Wed, 29 Jul 2026 10:53:46 -0400 Subject: [PATCH] Finalize Player Menu and UI scaling --- .../bubble_menu/bubble_confirmation_page.gd | 5 +- .../bubble_menu/cooler_fish_sprite.gd | 15 +- .../bubble_menu/cooler_water.gdshader | 215 +++++++++++-- .../bubble_menu/notepad_ink_action.gd | 24 +- .../bubble_menu/notepad_ink_choice.gd | 268 ++++++++++++---- .../bubble_menu/notepad_ink_choice.tscn | 91 +++++- ui/hotbar.gd | 29 +- ui/pause_menu.gd | 21 +- ui/pixelation_reset_overlay.gd | 33 +- ui/player_menu.gd | 298 +++++++++++++----- ui/player_menu.tscn | 206 +++++++++--- ui/settings/settings_bubble_page.gd | 5 +- ui/title_confirmation_bubble_page.gd | 2 +- ui/title_screen.gd | 21 +- ui/ui_pixelation_presenter.gd | 64 +++- ui/ui_reference_presentation.gd | 26 ++ ui/ui_reference_presentation.gd.uid | 1 + 17 files changed, 1002 insertions(+), 322 deletions(-) create mode 100644 ui/ui_reference_presentation.gd create mode 100644 ui/ui_reference_presentation.gd.uid diff --git a/ui/components/bubble_menu/bubble_confirmation_page.gd b/ui/components/bubble_menu/bubble_confirmation_page.gd index cbb0ede..fde0f34 100644 --- a/ui/components/bubble_menu/bubble_confirmation_page.gd +++ b/ui/components/bubble_menu/bubble_confirmation_page.gd @@ -158,10 +158,7 @@ func _process(delta: float) -> void: func _update_layout() -> void: if not is_node_ready() or _cluster == null: return - var compact: bool = ( - size.x < compact_width_threshold - or size.y < compact_height_threshold - ) + var compact: bool = false var layout_maximum: Vector2 = ( compact_maximum_layout_size if compact diff --git a/ui/components/bubble_menu/cooler_fish_sprite.gd b/ui/components/bubble_menu/cooler_fish_sprite.gd index 60c6578..d092dcc 100644 --- a/ui/components/bubble_menu/cooler_fish_sprite.gd +++ b/ui/components/bubble_menu/cooler_fish_sprite.gd @@ -104,6 +104,7 @@ func _update_visual_pivot() -> void: func _refresh_style() -> void: + var idle := StyleBoxEmpty.new() var normal := _make_rarity_style(_rarity_color, 2, 0.25) var hover := _make_rarity_style(_rarity_color.lightened(0.08), 4, 0.34) var selected_fill: Color = ( @@ -116,9 +117,21 @@ func _refresh_style() -> void: 6 if _batch_selected else 4, 0.46 if _batch_selected else 0.34, ) + var circle_visible: bool = ( + _batch_selected + or _hovered + or has_focus() + ) + var base_style: StyleBox = idle + if circle_visible: + base_style = ( + selected + if _batch_selected or _focused_catch + else normal + ) add_theme_stylebox_override( "normal", - selected if _batch_selected or _focused_catch else normal, + base_style, ) add_theme_stylebox_override("hover", selected if _batch_selected else hover) add_theme_stylebox_override("focus", selected) diff --git a/ui/components/bubble_menu/cooler_water.gdshader b/ui/components/bubble_menu/cooler_water.gdshader index 5418727..f5e4608 100644 --- a/ui/components/bubble_menu/cooler_water.gdshader +++ b/ui/components/bubble_menu/cooler_water.gdshader @@ -4,37 +4,204 @@ render_mode unshaded; uniform vec4 water_top : source_color = vec4(0.055, 0.38, 0.50, 1.0); uniform vec4 water_bottom : source_color = vec4(0.018, 0.16, 0.25, 1.0); uniform vec4 caustic_color : source_color = vec4(0.66, 0.91, 0.95, 1.0); -uniform float caustic_opacity : hint_range(0.0, 0.2) = 0.055; -uniform float caustic_speed : hint_range(0.0, 0.2) = 0.045; -uniform float bubble_opacity : hint_range(0.0, 0.25) = 0.11; +uniform vec2 pattern_density = vec2(38.0, 21.0); +uniform vec2 pattern_drift = vec2(0.012, 0.018); +uniform float mark_opacity_min : hint_range(0.0, 0.1) = 0.022; +uniform float mark_opacity_max : hint_range(0.0, 0.1) = 0.065; +uniform sampler2D decorative_bubble_1 : source_color, filter_nearest, repeat_disable; +uniform sampler2D decorative_bubble_2 : source_color, filter_nearest, repeat_disable; +uniform sampler2D decorative_bubble_3 : source_color, filter_nearest, repeat_disable; +uniform float decorative_bubble_opacity : hint_range(0.0, 1.0) = 0.48; +uniform vec2 rendered_size = vec2(784.0, 394.0); +uniform float corner_radius : hint_range(0.0, 96.0) = 29.0; +uniform float corner_softness : hint_range(0.0, 3.0) = 0.75; -float hash(float value) { - return fract(sin(value * 91.713) * 43758.5453); + +float cell_hash(vec2 cell) { + return fract(sin(dot(cell, vec2(127.1, 311.7))) * 43758.5453); } + +float block_mark(vec2 point, vec2 half_size) { + return ( + step(abs(point.x), half_size.x) + * step(abs(point.y), half_size.y) + ); +} + + +vec4 sample_decorative_bubble( + sampler2D artwork, + vec2 uv, + vec2 rect_size, + vec2 center, + float logical_size +) { + vec2 artwork_uv = ( + (uv - center) * rect_size / logical_size + + vec2(0.5) + ); + float inside = ( + step(0.0, artwork_uv.x) + * step(artwork_uv.x, 1.0) + * step(0.0, artwork_uv.y) + * step(artwork_uv.y, 1.0) + ); + return texture(artwork, clamp(artwork_uv, vec2(0.0), vec2(1.0))) * inside; +} + + +vec2 decorative_bubble_center( + float base_x, + float phase, + float speed, + float drift_phase +) { + float progress = fract(phase + TIME * speed); + return vec2( + base_x + sin(TIME * 0.21 + drift_phase) * 0.012, + 1.10 - progress * 1.24 + ); +} + + void fragment() { vec2 uv = UV; vec3 base = mix(water_top.rgb, water_bottom.rgb, smoothstep(0.0, 1.0, uv.y)); - float slow_time = TIME * caustic_speed; - float broad_wave = sin((uv.x * 8.0 + uv.y * 5.0 + slow_time) * 6.28318); - float crossing_wave = sin((uv.x * 5.5 - uv.y * 7.0 - slow_time * 0.73) * 6.28318); - float caustic = smoothstep(1.46, 1.88, broad_wave + crossing_wave); - base += caustic_color.rgb * caustic * caustic_opacity; + + vec2 flowing_grid = (uv + TIME * pattern_drift) * pattern_density; + float row = floor(flowing_grid.y); + flowing_grid.x += mod(row, 2.0) * 0.43; + vec2 cell = floor(flowing_grid); + vec2 local = fract(flowing_grid) - vec2(0.5); + vec2 jitter = vec2( + cell_hash(cell + vec2(3.7, 9.1)), + cell_hash(cell + vec2(7.3, 2.9)) + ) - vec2(0.5); + local -= jitter * vec2(0.52, 0.46); + vec2 stepped_local = ( + floor((local + vec2(0.5)) * 8.0) / 8.0 + - vec2(0.5) + ); + float shape_key = cell_hash(cell + vec2(13.1, 5.7)); + float size_key = cell_hash(cell + vec2(1.9, 17.3)); + vec2 mark_half_size = mix( + vec2(0.10, 0.07), + vec2(0.18, 0.12), + size_key + ); + float mark = block_mark(stepped_local, mark_half_size); + if (shape_key < 0.34) { + mark = max( + mark, + block_mark( + stepped_local - vec2(mark_half_size.x * 0.8, -0.11), + vec2(mark_half_size.x * 0.52, 0.045) + ) + ); + } else if (shape_key < 0.67) { + mark *= 1.0 - block_mark( + stepped_local - vec2(mark_half_size.x * 0.7, 0.0), + vec2(0.045, 0.045) + ); + } else { + mark = max( + mark, + block_mark( + stepped_local + vec2(mark_half_size.x * 0.75, 0.10), + vec2(0.055, 0.04) + ) + ); + } + float occupancy = step( + 0.22, + cell_hash(cell + vec2(19.7, 23.3)) + ); + float mark_opacity = mix( + mark_opacity_min, + mark_opacity_max, + cell_hash(cell + vec2(29.9, 11.5)) + ); + base += caustic_color.rgb * mark * occupancy * mark_opacity; + float sheen = (1.0 - smoothstep(0.0, 0.12, uv.y)) * 0.11; base += caustic_color.rgb * sheen; - float bubbles = 0.0; - for (int index = 0; index < 8; index++) { - float key = float(index) + 1.0; - float x = 0.08 + hash(key * 2.13) * 0.84; - float phase = hash(key * 4.71); - float y = 1.08 - mod(slow_time * (0.42 + hash(key) * 0.34) + phase, 1.18); - float radius = 0.005 + hash(key * 8.23) * 0.008; - vec2 delta = uv - vec2(x, y); - delta.x *= 0.62; - float distance_to_edge = abs(length(delta) - radius); - bubbles += 1.0 - smoothstep(0.0015, 0.004, distance_to_edge); - } - base += caustic_color.rgb * min(bubbles, 1.0) * bubble_opacity; - COLOR = vec4(base, 1.0); + vec2 rect_size = max(rendered_size, vec2(1.0)); + float desktop_bubble_slots = step(260.0, rect_size.y); + vec4 authored_bubbles = vec4(0.0); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_1, + uv, + rect_size, + decorative_bubble_center(0.12, 0.05, 0.020, 0.4), + 22.0 + ); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_2, + uv, + rect_size, + decorative_bubble_center(0.27, 0.42, 0.016, 2.1), + 28.0 + ); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_3, + uv, + rect_size, + decorative_bubble_center(0.41, 0.76, 0.018, 4.0), + 19.0 + ); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_1, + uv, + rect_size, + decorative_bubble_center(0.56, 0.22, 0.015, 5.2), + 25.0 + ); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_3, + uv, + rect_size, + decorative_bubble_center(0.69, 0.58, 0.019, 1.3), + 30.0 + ); + authored_bubbles += sample_decorative_bubble( + decorative_bubble_2, + uv, + rect_size, + decorative_bubble_center(0.82, 0.89, 0.017, 3.1), + 21.0 + ) * desktop_bubble_slots; + authored_bubbles += sample_decorative_bubble( + decorative_bubble_1, + uv, + rect_size, + decorative_bubble_center(0.92, 0.34, 0.014, 6.0), + 24.0 + ) * desktop_bubble_slots; + float authored_alpha = clamp( + authored_bubbles.a * decorative_bubble_opacity, + 0.0, + 0.72 + ); + vec3 authored_color = ( + authored_bubbles.rgb + / max(authored_bubbles.a, 0.001) + ); + base = mix(base, authored_color, authored_alpha); + + vec2 half_size = rect_size * 0.5; + float radius = min(corner_radius, min(half_size.x, half_size.y)); + vec2 rounded_offset = ( + abs(uv * rect_size - half_size) + - (half_size - vec2(radius)) + ); + float edge_distance = ( + length(max(rounded_offset, vec2(0.0))) + + min(max(rounded_offset.x, rounded_offset.y), 0.0) + - radius + ); + float softness = max(corner_softness, 0.001); + float rounded_alpha = 1.0 - smoothstep(-softness, softness, edge_distance); + COLOR = vec4(base, rounded_alpha); } diff --git a/ui/components/bubble_menu/notepad_ink_action.gd b/ui/components/bubble_menu/notepad_ink_action.gd index 0d8ba1c..85ec1b2 100644 --- a/ui/components/bubble_menu/notepad_ink_action.gd +++ b/ui/components/bubble_menu/notepad_ink_action.gd @@ -3,9 +3,14 @@ extends Button @export var ink_color := Color(0.19, 0.16, 0.12, 1.0) @export var disabled_ink_color := Color(0.31, 0.28, 0.23, 0.46) +@export var allow_persistent_mark: bool = false: + set(value): + allow_persistent_mark = value + if not allow_persistent_mark: + persistent_mark = false @export var persistent_mark: bool = false: set(value): - persistent_mark = value + persistent_mark = value and allow_persistent_mark _refresh_ink() @onready var _ink_outline: NotepadInkOutline = %InkOutline @@ -22,6 +27,7 @@ func _ready() -> void: focus_exited.connect(_set_focused.bind(false)) button_down.connect(_set_pressed.bind(true)) button_up.connect(_set_pressed.bind(false)) + gui_input.connect(_on_gui_input) _apply_paper_style() _refresh_ink() @@ -46,6 +52,22 @@ func _set_pressed(value: bool) -> void: _refresh_ink() +func _on_gui_input(event: InputEvent) -> void: + if ( + event is InputEventMouseButton + and event.button_index == MOUSE_BUTTON_LEFT + and not event.pressed + ): + call_deferred("_finish_mouse_activation") + + +func _finish_mouse_activation() -> void: + _pressed = false + if has_focus(): + release_focus() + _refresh_ink() + + func _refresh_ink() -> void: if not is_node_ready(): return diff --git a/ui/components/bubble_menu/notepad_ink_choice.gd b/ui/components/bubble_menu/notepad_ink_choice.gd index c9be830..1578587 100644 --- a/ui/components/bubble_menu/notepad_ink_choice.gd +++ b/ui/components/bubble_menu/notepad_ink_choice.gd @@ -1,37 +1,115 @@ class_name NotepadInkChoice -extends OptionButton +extends Control + +signal item_selected(index: int) @export var ink_color := Color(0.19, 0.16, 0.12, 1.0) +@export_range(0.0, 16.0, 0.25) var outline_padding: float = 3.0: + set(value): + outline_padding = value + if is_node_ready(): + _ink_outline.padding = outline_padding + _ink_outline.queue_redraw() +@export var outline_outsets := Vector4.ZERO: + set(value): + outline_outsets = value + if is_node_ready(): + _apply_outline_geometry() @onready var _ink_outline: NotepadInkOutline = %InkOutline +@onready var _displayed_value: Label = %DisplayedValue +@onready var _choice_panel: Control = %ChoicePanel +@onready var _choice_buttons: Array[Button] = [ + %CatchOrderChoice, + %NameChoice, + %RarityChoice, +] +var disabled: bool = false: + set(value): + disabled = value + if is_node_ready(): + _apply_interaction_state() +var _items: Array[String] = [] +var _item_ids: Array[int] = [] +var _selected_index: int = 0 var _hovered: bool = false var _focused: bool = false +var _opened_with_mouse: bool = false func _ready() -> void: + _ink_outline.padding = outline_padding + _apply_outline_geometry() mouse_entered.connect(_set_hovered.bind(true)) mouse_exited.connect(_set_hovered.bind(false)) focus_entered.connect(_set_focused.bind(true)) focus_exited.connect(_set_focused.bind(false)) + gui_input.connect(_on_display_gui_input) + for index: int in _choice_buttons.size(): + var button: Button = _choice_buttons[index] + button.pressed.connect(_select_index.bind(index)) + button.gui_input.connect(_on_choice_gui_input.bind(index)) + _choice_panel.hide() _apply_paper_style() - _style_popup() - queue_redraw() + _apply_interaction_state() + + +func add_item(item_text: String, item_id: int = -1) -> void: + if _items.size() >= _choice_buttons.size(): + return + var index: int = _items.size() + _items.append(item_text) + _item_ids.append(item_id if item_id >= 0 else index) + _choice_buttons[index].text = item_text + _choice_buttons[index].show() + if index == _selected_index: + _displayed_value.text = item_text + + +func select(index: int) -> void: + if index < 0 or index >= _items.size(): + return + _selected_index = index + _displayed_value.text = _items[index] + + +func get_selected_id() -> int: + if _selected_index < 0 or _selected_index >= _item_ids.size(): + return -1 + return _item_ids[_selected_index] func refresh_ink_state() -> void: _refresh_ink() +func set_choice_font_size(font_size: int) -> void: + _displayed_value.add_theme_font_size_override("font_size", font_size) + for button: Button in _choice_buttons: + button.add_theme_font_size_override("font_size", font_size) + + +func close_choices() -> void: + if not _choice_panel.visible: + return + _choice_panel.hide() + if _opened_with_mouse: + _opened_with_mouse = false + if has_focus(): + release_focus() + _refresh_ink() + + +func _apply_outline_geometry() -> void: + _ink_outline.offset_left = -outline_outsets.x + _ink_outline.offset_top = -outline_outsets.y + _ink_outline.offset_right = outline_outsets.z + _ink_outline.offset_bottom = outline_outsets.w + _ink_outline.queue_redraw() + + func _draw() -> void: - var chevron_x: float = size.x - 13.0 - var chevron_y: float = size.y * 0.5 - 1.0 - var chevron := PackedVector2Array([ - Vector2(chevron_x - 4.0, chevron_y - 2.0), - Vector2(chevron_x, chevron_y + 2.0), - Vector2(chevron_x + 4.0, chevron_y - 2.5), - ]) - draw_polyline(chevron, ink_color, 1.8, true) var underline_y: float = size.y - 5.0 var underline := PackedVector2Array([ Vector2(7.0, underline_y), @@ -44,6 +122,79 @@ func _draw() -> void: draw_polyline(underline, underline_color, 1.1, true) +func _gui_input(event: InputEvent) -> void: + if disabled: + return + if event.is_action_pressed("ui_accept"): + _open_choices(false) + accept_event() + elif event.is_action_pressed("ui_cancel") and _choice_panel.visible: + close_choices() + accept_event() + + +func _input(event: InputEvent) -> void: + if not _choice_panel.visible: + return + if event.is_action_pressed("ui_cancel"): + close_choices() + get_viewport().set_input_as_handled() + return + if ( + event is InputEventMouseButton + and event.button_index == MOUSE_BUTTON_LEFT + and event.pressed + ): + var mouse_position: Vector2 = event.position + if ( + not get_global_rect().has_point(mouse_position) + and not _choice_panel.get_global_rect().has_point(mouse_position) + ): + close_choices() + + +func _on_display_gui_input(event: InputEvent) -> void: + if ( + not disabled + and event is InputEventMouseButton + and event.button_index == MOUSE_BUTTON_LEFT + and event.pressed + ): + _open_choices(true) + accept_event() + + +func _on_choice_gui_input(event: InputEvent, index: int) -> void: + if event.is_action_pressed("ui_cancel"): + close_choices() + get_viewport().set_input_as_handled() + elif event.is_action_pressed("ui_up"): + _choice_buttons[posmod(index - 1, _choice_buttons.size())].grab_focus() + get_viewport().set_input_as_handled() + elif event.is_action_pressed("ui_down"): + _choice_buttons[(index + 1) % _choice_buttons.size()].grab_focus() + get_viewport().set_input_as_handled() + + +func _open_choices(from_mouse: bool) -> void: + if disabled or _choice_panel.visible: + return + _opened_with_mouse = from_mouse + _choice_panel.show() + _choice_panel.move_to_front() + if not from_mouse: + _choice_buttons[_selected_index].grab_focus() + _refresh_ink() + + +func _select_index(index: int) -> void: + if disabled or index < 0 or index >= _items.size(): + return + select(index) + close_choices() + item_selected.emit(get_selected_id()) + + func _set_hovered(value: bool) -> void: _hovered = value _refresh_ink() @@ -61,54 +212,51 @@ func _refresh_ink() -> void: ) +func _apply_interaction_state() -> void: + _displayed_value.modulate.a = 0.42 if disabled else 1.0 + focus_mode = Control.FOCUS_NONE if disabled else Control.FOCUS_ALL + mouse_filter = ( + Control.MOUSE_FILTER_IGNORE + if disabled + else Control.MOUSE_FILTER_STOP + ) + for button: Button in _choice_buttons: + button.disabled = disabled + if disabled: + close_choices() + _refresh_ink() + + func _apply_paper_style() -> void: var empty := StyleBoxEmpty.new() - for state: StringName in [ - &"normal", - &"hover", - &"pressed", - &"focus", - &"disabled", - ]: - add_theme_stylebox_override(state, empty) - var empty_arrow := ImageTexture.new() - add_theme_icon_override("arrow", empty_arrow) - add_theme_color_override("font_color", ink_color) - add_theme_color_override("font_hover_color", ink_color.darkened(0.08)) - add_theme_color_override("font_focus_color", ink_color.darkened(0.08)) - add_theme_color_override("font_pressed_color", ink_color.darkened(0.14)) - add_theme_color_override("font_disabled_color", Color(ink_color, 0.42)) - - -func _style_popup() -> void: - var popup: PopupMenu = get_popup() - var paper := StyleBoxFlat.new() - paper.bg_color = Color(0.93, 0.885, 0.73, 1.0) - paper.border_color = Color(0.22, 0.19, 0.15, 1.0) - paper.set_border_width_all(2) - paper.set_corner_radius_all(5) - var hover_paper := paper.duplicate() as StyleBoxFlat - hover_paper.bg_color = Color(0.82, 0.775, 0.63, 1.0) - hover_paper.border_color = Color(0.30, 0.26, 0.20, 0.62) - hover_paper.set_border_width_all(1) - popup.add_theme_stylebox_override("panel", paper) - popup.add_theme_stylebox_override("hover", hover_paper) - popup.add_theme_stylebox_override("separator", StyleBoxEmpty.new()) - popup.add_theme_color_override("font_color", ink_color) - popup.add_theme_color_override("font_hover_color", ink_color.darkened(0.08)) - popup.add_theme_color_override( - "font_separator_color", - Color(ink_color, 0.56), - ) - var empty_mark := ImageTexture.new() - for icon_name: StringName in [ - &"checked", - &"unchecked", - &"radio_checked", - &"radio_unchecked", - &"checked_disabled", - &"unchecked_disabled", - &"radio_checked_disabled", - &"radio_unchecked_disabled", - ]: - popup.add_theme_icon_override(icon_name, empty_mark) + var hover := StyleBoxFlat.new() + hover.bg_color = Color(0.82, 0.775, 0.63, 1.0) + hover.set_border_width_all(0) + hover.set_corner_radius_all(0) + hover.anti_aliasing = false + _displayed_value.add_theme_color_override("font_color", ink_color) + for button: Button in _choice_buttons: + for state: StringName in [ + &"normal", + &"disabled", + ]: + button.add_theme_stylebox_override(state, empty) + for state: StringName in [ + &"hover", + &"pressed", + &"focus", + ]: + button.add_theme_stylebox_override(state, hover) + button.add_theme_color_override("font_color", ink_color) + button.add_theme_color_override( + "font_hover_color", + ink_color.darkened(0.08), + ) + button.add_theme_color_override( + "font_focus_color", + ink_color.darkened(0.08), + ) + button.add_theme_color_override( + "font_pressed_color", + ink_color.darkened(0.14), + ) diff --git a/ui/components/bubble_menu/notepad_ink_choice.tscn b/ui/components/bubble_menu/notepad_ink_choice.tscn index bc9828f..eb8ca98 100644 --- a/ui/components/bubble_menu/notepad_ink_choice.tscn +++ b/ui/components/bubble_menu/notepad_ink_choice.tscn @@ -1,16 +1,35 @@ -[gd_scene load_steps=3 format=3] +[gd_scene load_steps=6 format=3] [ext_resource type="Script" path="res://ui/components/bubble_menu/notepad_ink_choice.gd" id="1_choice"] [ext_resource type="Script" path="res://ui/components/bubble_menu/notepad_ink_outline.gd" id="2_outline"] -[node name="NotepadInkChoice" type="OptionButton"] +[sub_resource type="StyleBoxFlat" id="StyleBox_shadow"] +bg_color = Color(0.1, 0.08, 0.06, 0.24) + +[sub_resource type="StyleBoxFlat" id="StyleBox_paper"] +bg_color = Color(0.93, 0.885, 0.73, 1) + +[sub_resource type="StyleBoxEmpty" id="StyleBox_empty"] + +[node name="NotepadInkChoice" type="Control"] custom_minimum_size = Vector2(124, 38) focus_mode = 1 mouse_default_cursor_shape = 2 -clip_text = true -fit_to_longest_item = false script = ExtResource("1_choice") +[node name="DisplayedValue" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +text = "catch order" +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="InkOutline" type="Control" parent="."] unique_name_in_owner = true visible = false @@ -22,3 +41,67 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("2_outline") + +[node name="ChoicePanel" type="Control" parent="."] +unique_name_in_owner = true +visible = false +z_index = 30 +layout_mode = 0 +offset_left = -8.0 +offset_top = 40.0 +offset_right = 132.0 +offset_bottom = 139.0 +mouse_filter = 1 + +[node name="Shadow" type="Panel" parent="ChoicePanel"] +layout_mode = 0 +offset_left = 3.0 +offset_top = 4.0 +offset_right = 143.0 +offset_bottom = 103.0 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_shadow") + +[node name="Paper" type="Panel" parent="ChoicePanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +theme_override_styles/panel = SubResource("StyleBox_paper") + +[node name="Choices" type="VBoxContainer" parent="ChoicePanel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +theme_override_constants/separation = 0 + +[node name="CatchOrderChoice" type="Button" parent="ChoicePanel/Choices"] +unique_name_in_owner = true +custom_minimum_size = Vector2(140, 33) +layout_mode = 2 +focus_mode = 1 +theme_override_styles/normal = SubResource("StyleBox_empty") +text = "catch order" + +[node name="NameChoice" type="Button" parent="ChoicePanel/Choices"] +unique_name_in_owner = true +custom_minimum_size = Vector2(140, 33) +layout_mode = 2 +focus_mode = 1 +theme_override_styles/normal = SubResource("StyleBox_empty") +text = "name" + +[node name="RarityChoice" type="Button" parent="ChoicePanel/Choices"] +unique_name_in_owner = true +custom_minimum_size = Vector2(140, 33) +layout_mode = 2 +focus_mode = 1 +theme_override_styles/normal = SubResource("StyleBox_empty") +text = "rarity" diff --git a/ui/hotbar.gd b/ui/hotbar.gd index fb2b96c..5c5ebd6 100644 --- a/ui/hotbar.gd +++ b/ui/hotbar.gd @@ -11,6 +11,8 @@ const FishingSpotType = preload("res://fishing/fishing_spot.gd") const DESKTOP_REFERENCE_SIZE := Vector2(1280.0, 720.0) const COMPACT_REFERENCE_SIZE := Vector2(640.0, 480.0) +const HOTBAR_PRESENTATION_SCALE: float = 0.60 +const HOTBAR_CANONICAL_POSITION := Vector2(256.0, 288.0) @onready var _presentation_scale_root: Control = %HotbarPresentationScaleRoot @onready var _bubble_field: Control = %BubbleField @@ -137,30 +139,13 @@ func _collect_slots() -> void: func _apply_layout() -> void: if not is_node_ready(): return - var parent_control := get_parent_control() - var available_size: Vector2 = ( - parent_control.size if parent_control != null else size - ) - _compact_layout = ( - available_size.y < PlayerSettings.COMPACT_DISPLAY_HEIGHT - ) - var reference_size := ( - COMPACT_REFERENCE_SIZE - if _compact_layout - else DESKTOP_REFERENCE_SIZE - ) - var presentation_scale: float = minf( - available_size.x / reference_size.x, - available_size.y / reference_size.y - ) - if _compact_layout: - presentation_scale = maxf(1.0, presentation_scale) + _compact_layout = false + var reference_size := DESKTOP_REFERENCE_SIZE _presentation_scale_root.size = reference_size - _presentation_scale_root.scale = Vector2.ONE * presentation_scale - _presentation_scale_root.position = Vector2( - (available_size.x - reference_size.x * presentation_scale) * 0.5, - available_size.y - reference_size.y * presentation_scale + _presentation_scale_root.scale = ( + Vector2.ONE * HOTBAR_PRESENTATION_SCALE ) + _presentation_scale_root.position = HOTBAR_CANONICAL_POSITION var field_size := ( Vector2(580.0, 82.0) if _compact_layout diff --git a/ui/pause_menu.gd b/ui/pause_menu.gd index c3101b8..ab68d67 100644 --- a/ui/pause_menu.gd +++ b/ui/pause_menu.gd @@ -484,24 +484,9 @@ func _cancel_backdrop_fade() -> void: func _update_responsive_pause_stage() -> void: if not is_node_ready(): return - var display_size := Vector2( - maxf(1.0, size.x), - maxf(1.0, size.y) - ) - var reference_size: Vector2 = ( - PAUSE_COMPACT_REFERENCE_SIZE - if display_size.y < COMPACT_HEIGHT_THRESHOLD - else PAUSE_DESKTOP_REFERENCE_SIZE - ) - var presentation_scale: float = minf( - display_size.x / reference_size.x, - display_size.y / reference_size.y - ) - _presentation_scale_root.size = reference_size - _presentation_scale_root.scale = Vector2.ONE * presentation_scale - _presentation_scale_root.position = ( - display_size - reference_size * presentation_scale - ) * 0.5 + _presentation_scale_root.size = PAUSE_DESKTOP_REFERENCE_SIZE + _presentation_scale_root.scale = Vector2.ONE + _presentation_scale_root.position = Vector2.ZERO func _restore_controls() -> void: diff --git a/ui/pixelation_reset_overlay.gd b/ui/pixelation_reset_overlay.gd index 9f67878..733a29b 100644 --- a/ui/pixelation_reset_overlay.gd +++ b/ui/pixelation_reset_overlay.gd @@ -1,12 +1,11 @@ class_name PixelationResetOverlay extends CanvasLayer -const DISPLAY_REFERENCE_SIZE: Vector2 = Vector2(1280.0, 720.0) -const MINIMUM_PRESENTATION_SCALE: float = 0.90 -const MAXIMUM_PRESENTATION_SCALE: float = 1.35 -const LARGE_DISPLAY_GROWTH: float = 0.45 const SCREEN_MARGIN: float = 16.0 const FADE_DURATION: float = 0.55 +const UIReferencePresentationType = preload( + "res://ui/ui_reference_presentation.gd" +) signal reset_requested signal return_to_settings_requested @@ -77,27 +76,17 @@ func _update_responsive_layout() -> void: var display_size: Vector2 = Vector2(get_window().size) if display_size.x <= 1.0 or display_size.y <= 1.0: return - var responsive_scale: float = minf( - display_size.x / DISPLAY_REFERENCE_SIZE.x, - display_size.y / DISPLAY_REFERENCE_SIZE.y + var presentation_scale: float = ( + UIReferencePresentationType.get_scale(display_size) ) - var presentation_scale: float - if responsive_scale < 1.0: - presentation_scale = lerpf( - MINIMUM_PRESENTATION_SCALE, - 1.0, - clampf((responsive_scale - 0.5) / 0.5, 0.0, 1.0) - ) - else: - presentation_scale = minf( - MAXIMUM_PRESENTATION_SCALE, - 1.0 + (responsive_scale - 1.0) * LARGE_DISPLAY_GROWTH - ) _presentation_root.scale = Vector2.ONE * presentation_scale _presentation_root.position = ( - display_size - - _presentation_root.size * presentation_scale - - Vector2.ONE * SCREEN_MARGIN + UIReferencePresentationType.get_offset(display_size) + + ( + UIReferencePresentationType.REFERENCE_SIZE + - _presentation_root.size + - Vector2.ONE * SCREEN_MARGIN + ) * presentation_scale ) diff --git a/ui/player_menu.gd b/ui/player_menu.gd index 5ad512a..83bfa9c 100644 --- a/ui/player_menu.gd +++ b/ui/player_menu.gd @@ -70,6 +70,9 @@ const TRANSITION_SAFE_MARGIN: float = 28.0 const DESKTOP_REFERENCE_SIZE := Vector2(1280.0, 720.0) const COMPACT_REFERENCE_SIZE := Vector2(640.0, 480.0) const COMPACT_HEIGHT_THRESHOLD: float = 560.0 +const NAVIGATION_PRESENTATION_SCALE: float = 0.60 +const NAVIGATION_CANONICAL_POSITION := Vector2(463.0, 44.0) +const NAVIGATION_SELECTED_SCALE: float = 1.02 const COOLER_RARITY_COMMON := Color("e8eef0") const COOLER_RARITY_UNCOMMON := Color("64c87c") const COOLER_RARITY_RARE := Color("6098dd") @@ -104,6 +107,7 @@ enum CloseReason { @onready var _cooler_page: Control = %CoolerPage @onready var _cooler_outer_wall: PanelContainer = %CoolerOuterWall @onready var _cooler_inner_liner: PanelContainer = %CoolerInnerLiner +@onready var _cooler_water_surface: ColorRect = %WaterSurface @onready var _fish_field: Control = %FishField @onready var _cooler_empty: Label = %CoolerEmpty @onready var _cooler_sort_controls: HBoxContainer = %CoolerSortControls @@ -114,12 +118,25 @@ enum CloseReason { @onready var _notepad_binding: Label = %BindingDecoration @onready var _notepad_title: Label = %NotepadTitle @onready var _notepad_rule: ColorRect = %NotepadRule -@onready var _notepad_wallet: Label = %NotepadWallet -@onready var _notepad_capacity: Label = %NotepadCapacity +@onready var _notepad_wallet_value: Label = %NotepadWalletValue +@onready var _notepad_capacity_value: Label = %NotepadCapacityValue @onready var _cooler_detail_texture: TextureRect = %CoolerDetailTexture @onready var _cooler_detail_name: Label = %CoolerDetailName -@onready var _cooler_detail_data: Label = %CoolerDetailData -@onready var _cooler_selection_summary: Label = %CoolerSelectionSummary +@onready var _cooler_detail_stats: Control = %CoolerDetailStats +@onready var _cooler_weight_row: HBoxContainer = %CoolerWeightRow +@onready var _cooler_weight_value: Label = %CoolerWeightValue +@onready var _cooler_weight_unit: Label = %CoolerWeightUnit +@onready var _cooler_offer_row: HBoxContainer = %CoolerOfferRow +@onready var _cooler_offer_label: Label = %CoolerOfferLabel +@onready var _cooler_offer_value: Label = %CoolerOfferValue +@onready var _cooler_selection_summary: Control = %CoolerSelectionSummary +@onready var _cooler_selection_empty: Label = %CoolerSelectionEmpty +@onready var _cooler_selected_count_row: HBoxContainer = %CoolerSelectedCountRow +@onready var _cooler_selected_count_value: Label = %CoolerSelectedCountValue +@onready var _cooler_selected_count_label: Label = %CoolerSelectedCountLabel +@onready var _cooler_combined_offer_row: HBoxContainer = %CoolerCombinedOfferRow +@onready var _cooler_combined_offer_label: Label = %CoolerCombinedOfferLabel +@onready var _cooler_combined_offer_value: Label = %CoolerCombinedOfferValue @onready var _favorite_bubble: NotepadInkActionType = %FavoriteBubble @onready var _sell_bubble: NotepadInkActionType = %SellBubble @onready var _bag_page: Control = %BagPage @@ -270,9 +287,7 @@ func _ready() -> void: _close_button.pressed.connect(close_menu) _sort_option.item_selected.connect(_on_sort_selected.bind(_sort_option)) _sort_direction.pressed.connect(_on_sort_direction_pressed) - _cooler_sort_option.item_selected.connect( - _on_sort_selected.bind(_cooler_sort_option) - ) + _cooler_sort_option.item_selected.connect(_on_cooler_sort_selected) _cooler_sort_direction.pressed.connect(_on_sort_direction_pressed) _favorite_button.pressed.connect(_on_favorite_pressed) _sell_button.pressed.connect(_on_sell_pressed) @@ -301,6 +316,7 @@ func _ready() -> void: _apply_cooler_control_styles() _apply_cooler_wall_styles() _apply_cooler_notepad_style() + _cooler_water_surface.resized.connect(_update_cooler_water_mask) _fish_field.gui_input.connect(_on_fish_field_gui_input) _apply_bag_styles() _bag_item_field.gui_input.connect(_on_bag_field_gui_input) @@ -310,9 +326,20 @@ func _ready() -> void: resized.connect(_update_shell_layout) _show_section_immediate(_current_section) call_deferred("_update_shell_layout") + call_deferred("_update_cooler_water_mask") set_process(false) +func _update_cooler_water_mask() -> void: + var shader_material := _cooler_water_surface.material as ShaderMaterial + if shader_material == null: + return + shader_material.set_shader_parameter( + "rendered_size", + _cooler_water_surface.size, + ) + + func setup( player: PlayerType, inventory: FishInventoryType, @@ -754,8 +781,7 @@ func _apply_navigation_selection_presentation() -> void: ]: if not bubble.button_pressed: continue - bubble.position.y -= 2.0 - bubble.scale *= 1.025 + bubble.scale *= NAVIGATION_SELECTED_SCALE func _apply_bag_styles() -> void: @@ -860,33 +886,23 @@ func _update_shell_layout() -> void: if not is_node_ready(): return _cancel_logbook_page_transition(true) - var display_size := Vector2(maxf(size.x, 1.0), maxf(size.y, 1.0)) - var compact: bool = display_size.y < COMPACT_HEIGHT_THRESHOLD + var compact: bool = false _compact_layout = compact - var reference_size := ( - COMPACT_REFERENCE_SIZE if compact else DESKTOP_REFERENCE_SIZE - ) - var presentation_scale: float = minf( - display_size.x / reference_size.x, - display_size.y / reference_size.y, - ) - presentation_scale = clampf(presentation_scale, 0.85, 3.0) + var reference_size := DESKTOP_REFERENCE_SIZE _presentation_scale_root.size = reference_size - _presentation_scale_root.scale = Vector2.ONE * presentation_scale - _presentation_scale_root.position = ( - display_size - reference_size * presentation_scale - ) * 0.5 + _presentation_scale_root.scale = Vector2.ONE + _presentation_scale_root.position = Vector2.ZERO _content_shell.position = Vector2(14.0, 92.0) if compact else Vector2(42.0, 104.0) _content_shell.size = Vector2(612.0, 286.0) if compact else Vector2(1196.0, 478.0) _presentation_rest_position = _content_shell.position var navigation_size := ( Vector2(620.0, 75.0) if compact else Vector2(620.0, 100.0) ) - _navigation_cluster.position = Vector2( - (reference_size.x - navigation_size.x) * 0.5, - 4.0 if compact else 8.0 - ) + _navigation_cluster.position = NAVIGATION_CANONICAL_POSITION _navigation_cluster.size = navigation_size + _navigation_cluster.scale = ( + Vector2.ONE * NAVIGATION_PRESENTATION_SCALE + ) _navigation_cluster.apply_layout(navigation_size, compact) _cooler_page.size = reference_size _cooler_page.position = Vector2.ZERO @@ -907,13 +923,13 @@ func _update_shell_layout() -> void: _notepad_binding.position = Vector2(44.0, 1.0) if compact else Vector2(28.0, 4.0) _notepad_binding.size = Vector2(218.0, 20.0) if compact else Vector2(232.0, 27.0) _notepad_binding.add_theme_font_size_override("font_size", 13 if compact else 20) - _notepad_title.position = Vector2(10.0, 16.0) if compact else Vector2(20.0, 31.0) + _notepad_title.position = Vector2(10.0, 14.0) if compact else Vector2(20.0, 31.0) _notepad_title.size = Vector2(286.0, 18.0) if compact else Vector2(248.0, 28.0) - _notepad_title.add_theme_font_size_override("font_size", 12 if compact else 19) - _notepad_rule.position = Vector2(10.0, 46.0) if compact else Vector2(18.0, 87.0) + _notepad_title.add_theme_font_size_override("font_size", 14 if compact else 20) + _notepad_rule.position = Vector2(10.0, 49.0) if compact else Vector2(18.0, 87.0) _notepad_rule.size = Vector2(286.0, 2.0) if compact else Vector2(252.0, 2.0) _cooler_sort_controls.position = ( - Vector2(10.0, 48.0) if compact else Vector2(18.0, 98.0) + Vector2(10.0, 51.0) if compact else Vector2(18.0, 98.0) ) _cooler_sort_controls.size = ( Vector2(286.0, 31.0) if compact else Vector2(252.0, 38.0) @@ -925,53 +941,60 @@ func _update_shell_layout() -> void: _cooler_sort_direction.custom_minimum_size = ( Vector2(140.0, 31.0) if compact else Vector2(123.0, 38.0) ) - for sort_control: Control in [ - _cooler_sort_option, - _cooler_sort_direction, + _cooler_sort_option.set_choice_font_size(12 if compact else 15) + _cooler_sort_direction.add_theme_font_size_override( + "font_size", + 12 if compact else 14, + ) + _notepad_wallet_value.position = ( + Vector2(10.0, 33.0) if compact else Vector2(18.0, 61.0) + ) + _notepad_wallet_value.size = ( + Vector2(138.0, 17.0) if compact else Vector2(120.0, 23.0) + ) + _notepad_capacity_value.position = ( + Vector2(154.0, 33.0) if compact else Vector2(146.0, 61.0) + ) + _notepad_capacity_value.size = ( + Vector2(142.0, 17.0) if compact else Vector2(124.0, 23.0) + ) + for status_value: Label in [ + _notepad_wallet_value, + _notepad_capacity_value, ]: - sort_control.add_theme_font_size_override( + status_value.add_theme_font_size_override( "font_size", - 9 if compact else 10, + 10 if compact else 14, ) - _notepad_wallet.position = Vector2(10.0, 31.0) if compact else Vector2(18.0, 61.0) - _notepad_wallet.size = Vector2(138.0, 17.0) if compact else Vector2(122.0, 23.0) - _notepad_capacity.position = Vector2(154.0, 31.0) if compact else Vector2(146.0, 61.0) - _notepad_capacity.size = Vector2(142.0, 17.0) if compact else Vector2(124.0, 23.0) - for status_label: Label in [_notepad_wallet, _notepad_capacity]: - status_label.add_theme_font_size_override("font_size", 10 if compact else 14) _cooler_detail_texture.position = ( - Vector2(10.0, 84.0) if compact else Vector2(88.0, 143.0) + Vector2(5.0, 84.0) if compact else Vector2(80.0, 137.0) ) _cooler_detail_texture.size = ( - Vector2(66.0, 52.0) if compact else Vector2(112.0, 92.0) + Vector2(74.0, 58.0) if compact else Vector2(128.0, 100.0) ) _cooler_detail_name.position = ( - Vector2(82.0, 82.0) if compact else Vector2(18.0, 239.0) + Vector2(82.0, 82.0) if compact else Vector2(18.0, 241.0) ) _cooler_detail_name.size = ( - Vector2(214.0, 24.0) if compact else Vector2(252.0, 30.0) + Vector2(214.0, 26.0) if compact else Vector2(252.0, 32.0) ) _cooler_detail_name.add_theme_font_size_override( - "font_size", 14 if compact else 21, + "font_size", 18 if compact else 25, ) - _cooler_detail_data.position = ( - Vector2(82.0, 105.0) if compact else Vector2(18.0, 269.0) + _cooler_detail_stats.position = ( + Vector2(82.0, 109.0) if compact else Vector2(18.0, 274.0) ) - _cooler_detail_data.size = ( - Vector2(214.0, 43.0) if compact else Vector2(252.0, 75.0) - ) - _cooler_detail_data.add_theme_font_size_override( - "font_size", 9 if compact else 16, + _cooler_detail_stats.size = ( + Vector2(214.0, 39.0) if compact else Vector2(252.0, 65.0) ) + _layout_cooler_detail_text(compact) _cooler_selection_summary.position = ( Vector2(10.0, 151.0) if compact else Vector2(18.0, 346.0) ) _cooler_selection_summary.size = ( - Vector2(130.0, 35.0) if compact else Vector2(252.0, 36.0) - ) - _cooler_selection_summary.add_theme_font_size_override( - "font_size", 9 if compact else 13, + Vector2(130.0, 35.0) if compact else Vector2(252.0, 40.0) ) + _layout_cooler_selection_text(compact) _favorite_bubble.custom_minimum_size = ( Vector2(72.0, 42.0) if compact else Vector2(108.0, 50.0) ) @@ -991,10 +1014,10 @@ func _update_shell_layout() -> void: Vector2(74.0, 42.0) if compact else Vector2(118.0, 50.0) ) _favorite_bubble.add_theme_font_size_override( - "font_size", 10 if compact else 15, + "font_size", 11 if compact else 17, ) _sell_bubble.add_theme_font_size_override( - "font_size", 10 if compact else 15, + "font_size", 11 if compact else 17, ) _update_sort_direction_text() _bag_page.size = reference_size @@ -1111,6 +1134,70 @@ func _update_shell_layout() -> void: _layout_bag_items() +func _layout_cooler_detail_text(compact: bool) -> void: + var weight_row_height: float = 17.0 if compact else 24.0 + _cooler_weight_row.position = Vector2.ZERO + _cooler_weight_row.size = Vector2( + _cooler_detail_stats.size.x, + weight_row_height, + ) + _cooler_offer_row.position = Vector2( + 0.0, + 17.0 if compact else 27.0, + ) + _cooler_offer_row.size = Vector2( + _cooler_detail_stats.size.x, + 22.0 if compact else 30.0, + ) + _cooler_weight_value.add_theme_font_size_override( + "font_size", + 9 if compact else 12, + ) + _cooler_weight_unit.add_theme_font_size_override( + "font_size", + 10 if compact else 14, + ) + _cooler_offer_label.add_theme_font_size_override( + "font_size", + 13 if compact else 18, + ) + _cooler_offer_value.add_theme_font_size_override( + "font_size", + 10 if compact else 15, + ) + + +func _layout_cooler_selection_text(compact: bool) -> void: + var row_height: float = 17.5 if compact else 20.0 + for numeric_label: Label in [ + _cooler_selected_count_value, + _cooler_combined_offer_value, + ]: + numeric_label.add_theme_font_size_override( + "font_size", + 10 if compact else 14, + ) + for word_label: Label in [ + _cooler_selection_empty, + _cooler_selected_count_label, + _cooler_combined_offer_label, + ]: + word_label.add_theme_font_size_override( + "font_size", + 12 if compact else 18, + ) + _cooler_selected_count_row.position = Vector2.ZERO + _cooler_selected_count_row.size = Vector2( + _cooler_selection_summary.size.x, + row_height, + ) + _cooler_combined_offer_row.position = Vector2(0.0, row_height) + _cooler_combined_offer_row.size = Vector2( + _cooler_selection_summary.size.x, + row_height, + ) + + func _begin_menu_entry() -> void: _transitioning = true _set_shell_interactive(false) @@ -1478,6 +1565,13 @@ func _on_sort_selected(index: int, source: OptionButton) -> void: _refresh_inventory() +func _on_cooler_sort_selected(sort_id: int) -> void: + _sort_mode = sort_id + _sort_option.select(_sort_mode) + _cooler_sort_option.select(_sort_mode) + _refresh_inventory() + + func _on_sort_direction_pressed() -> void: _sort_descending = not _sort_descending _update_sort_direction_text() @@ -1811,12 +1905,12 @@ func _refresh_economy_summary() -> void: ) _wallet_balance.text = "wallet: $%d" % balance _wallet_status.set_content("wallet", "$%d" % balance) - _notepad_wallet.text = "wallet $%d" % balance + _notepad_wallet_value.text = "$%d" % balance _capacity_status.set_content("cooler", "%d / %d" % [ _inventory.get_all_catches().size() if _inventory != null else 0, _cooler_capacity.get_capacity() if _cooler_capacity != null else 0, ]) - _notepad_capacity.text = "cooler %d / %d" % [ + _notepad_capacity_value.text = "%d / %d" % [ _inventory.get_all_catches().size() if _inventory != null else 0, _cooler_capacity.get_capacity() if _cooler_capacity != null else 0, ] @@ -1855,8 +1949,8 @@ func _refresh_inventory() -> void: if _inventory != null else null ) - _update_inventory_detail(selected) _update_sale_summary() + _update_inventory_detail(selected) _update_sort_direction_text() @@ -2086,8 +2180,8 @@ func _close_detail_constellation() -> void: _cooler_detail_texture.texture = null _cooler_detail_texture.visible = false _cooler_detail_name.text = "select a fish" - _cooler_detail_data.text = "" - _cooler_selection_summary.text = "no fish selected" + _clear_cooler_detail_stats() + _set_cooler_selection_summary_empty() _favorite_bubble.disabled = true _favorite_bubble.text = "favorite" _favorite_bubble.persistent_mark = false @@ -2103,12 +2197,57 @@ func _close_detail_constellation() -> void: _configure_cooler_fish_focus() +func _clear_cooler_detail_stats() -> void: + for label: Label in [ + _cooler_weight_value, + _cooler_weight_unit, + _cooler_offer_label, + _cooler_offer_value, + ]: + label.text = "" + + +func _set_cooler_selection_summary_empty() -> void: + _cooler_selection_empty.visible = true + _cooler_selected_count_row.visible = false + _cooler_combined_offer_row.visible = false + for label: Label in [ + _cooler_selected_count_value, + _cooler_selected_count_label, + _cooler_combined_offer_label, + _cooler_combined_offer_value, + ]: + label.visible = false + label.text = "" + + +func _set_cooler_selection_summary( + selected_count: int, + offer_value: int, +) -> void: + _cooler_selection_empty.visible = false + _cooler_selected_count_row.visible = true + _cooler_combined_offer_row.visible = true + _cooler_selected_count_value.visible = true + _cooler_selected_count_label.visible = true + _cooler_combined_offer_label.visible = true + _cooler_combined_offer_value.visible = offer_value >= 0 + _cooler_selected_count_value.text = str(selected_count) + _cooler_selected_count_label.text = "fish selected" + if offer_value >= 0: + _cooler_combined_offer_label.text = "combined offer" + _cooler_combined_offer_value.text = "$%d" % offer_value + else: + _cooler_combined_offer_label.text = "offer unavailable" + _cooler_combined_offer_value.text = "" + + func _update_inventory_detail(fish_catch: FishCatchType) -> void: if fish_catch == null: _cooler_detail_texture.texture = null _cooler_detail_texture.visible = false _cooler_detail_name.text = "select a fish" - _cooler_detail_data.text = "" + _clear_cooler_detail_stats() _favorite_button.disabled = true _favorite_button.text = "favorite" _favorite_bubble.disabled = true @@ -2136,18 +2275,14 @@ func _update_inventory_detail(fish_catch: FishCatchType) -> void: if individual_preview != null else -1 ) - var buyer_offer_text: String = "buyer unavailable" + _cooler_weight_value.text = "%.2f" % fish_catch.weight_lb + _cooler_weight_unit.text = "lb" if buyer_offer >= 0 and _default_buyer != null: - buyer_offer_text = "%s offer: $%d" % [ - _default_buyer.display_name, - buyer_offer, - ] - _cooler_detail_data.text = "%.2f lb • %s\nbase value: $%d\n%s" % [ - fish_catch.weight_lb, - fish_catch.fish.get_rarity_name(), - fish_catch.sale_value, - buyer_offer_text, - ] + _cooler_offer_label.text = "%s offer" % _default_buyer.display_name + _cooler_offer_value.text = "$%d" % buyer_offer + else: + _cooler_offer_label.text = "buyer unavailable" + _cooler_offer_value.text = "" _favorite_button.disabled = false _favorite_button.text = ( "unfavorite" if fish_catch.is_favorited else "favorite" @@ -2198,7 +2333,7 @@ func _update_sale_summary() -> void: _sell_bubble.text = "sell fish" _sell_bubble.persistent_mark = false _sell_bubble.refresh_ink_state() - _cooler_selection_summary.text = "no fish selected" + _set_cooler_selection_summary_empty() _sale_unavailable.text = "" _sale_unavailable.visible = false return @@ -2213,7 +2348,6 @@ func _update_sale_summary() -> void: else "%d fish selected" % selected_count ) _selection_summary.text = count_text - _cooler_selection_summary.text = count_text _selection_status.set_content("selected", str(selected_count)) if ( preview != null @@ -2228,12 +2362,10 @@ func _update_sale_summary() -> void: _default_buyer.display_name, preview.payout, ] - _cooler_selection_summary.text += ( - "\ncombined offer: $%d" % preview.payout - ) + _set_cooler_selection_summary(selected_count, preview.payout) _offer_status.set_content("pelican offer", "$%d" % preview.payout) else: - _cooler_selection_summary.text += "\noffer unavailable" + _set_cooler_selection_summary(selected_count, -1) _offer_status.set_content("pelican offer", "unavailable") _sell_button.disabled = preview == null or not preview.is_success() _sell_bubble.disabled = _sell_button.disabled diff --git a/ui/player_menu.tscn b/ui/player_menu.tscn index e917825..789850d 100644 --- a/ui/player_menu.tscn +++ b/ui/player_menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3] +[gd_scene load_steps=19 format=3] [ext_resource type="Script" path="res://ui/player_menu.gd" id="1_menu"] [ext_resource type="Theme" path="res://ui/game_theme.tres" id="2_theme"] @@ -14,11 +14,19 @@ [ext_resource type="PackedScene" path="res://ui/components/bubble_menu/notepad_ink_action.tscn" id="12_ink_action"] [ext_resource type="PackedScene" path="res://ui/components/bubble_menu/notepad_ink_choice.tscn" id="13_ink_choice"] [ext_resource type="Shader" path="res://ui/components/bubble_menu/cooler_water.gdshader" id="14_water"] +[ext_resource type="Texture2D" path="res://ui/assets/title/bubbles/bubble1.png" id="15_bubble1"] +[ext_resource type="Texture2D" path="res://ui/assets/title/bubbles/bubble2.png" id="16_bubble2"] +[ext_resource type="Texture2D" path="res://ui/assets/title/bubbles/bubble3.png" id="17_bubble3"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_collection"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_cooler_water"] shader = ExtResource("14_water") +shader_parameter/decorative_bubble_1 = ExtResource("15_bubble1") +shader_parameter/decorative_bubble_2 = ExtResource("16_bubble2") +shader_parameter/decorative_bubble_3 = ExtResource("17_bubble3") +shader_parameter/corner_radius = 29.0 +shader_parameter/corner_softness = 0.75 [node name="PlayerMenu" type="Control"] visible = false @@ -93,6 +101,13 @@ theme_override_constants/margin_top = 16 theme_override_constants/margin_right = 16 theme_override_constants/margin_bottom = 16 +[node name="WaterSurface" type="ColorRect" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/CoolerOuterWall/CoolerWallMargin/CoolerInnerLiner/CoolerInnerMargin"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +material = SubResource("ShaderMaterial_cooler_water") +color = Color(1, 1, 1, 1) + [node name="CoolerScroll" type="ScrollContainer" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/CoolerOuterWall/CoolerWallMargin/CoolerInnerLiner/CoolerInnerMargin"] unique_name_in_owner = true layout_mode = 2 @@ -104,17 +119,6 @@ custom_minimum_size = Vector2(784, 394) layout_mode = 2 mouse_filter = 1 -[node name="WaterSurface" type="ColorRect" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/CoolerOuterWall/CoolerWallMargin/CoolerInnerLiner/CoolerInnerMargin/CoolerScroll/CoolerHost"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -material = SubResource("ShaderMaterial_cooler_water") -color = Color(1, 1, 1, 1) - [node name="FishField" type="Control" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/CoolerOuterWall/CoolerWallMargin/CoolerInnerLiner/CoolerInnerMargin/CoolerScroll/CoolerHost"] unique_name_in_owner = true layout_mode = 1 @@ -185,19 +189,19 @@ theme_override_font_sizes/font_size = 19 text = "cooler notes" horizontal_alignment = 1 -[node name="NotepadWallet" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] +[node name="NotepadWalletValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] unique_name_in_owner = true layout_mode = 0 offset_left = 18.0 offset_top = 61.0 -offset_right = 140.0 +offset_right = 138.0 offset_bottom = 84.0 mouse_filter = 2 theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) theme_override_font_sizes/font_size = 14 -text = "wallet $0" +text = "$0" -[node name="NotepadCapacity" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] +[node name="NotepadCapacityValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] unique_name_in_owner = true layout_mode = 0 offset_left = 146.0 @@ -207,7 +211,7 @@ offset_bottom = 84.0 mouse_filter = 2 theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) theme_override_font_sizes/font_size = 14 -text = "cooler 0 / 12" +text = "0 / 12" horizontal_alignment = 2 [node name="NotepadRule" type="ColorRect" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] @@ -242,6 +246,8 @@ custom_minimum_size = Vector2(123, 38) layout_mode = 2 clip_text = true fit_to_longest_item = false +outline_padding = 1.5 +outline_outsets = Vector4(6, 2, 2, 2) [node name="CoolerSortDirection" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSortControls" instance=ExtResource("12_ink_action")] unique_name_in_owner = true @@ -252,10 +258,10 @@ clip_text = true [node name="CoolerDetailTexture" type="TextureRect" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] unique_name_in_owner = true layout_mode = 0 -offset_left = 88.0 -offset_top = 143.0 -offset_right = 200.0 -offset_bottom = 235.0 +offset_left = 80.0 +offset_top = 137.0 +offset_right = 208.0 +offset_bottom = 237.0 mouse_filter = 2 texture_filter = 1 expand_mode = 1 @@ -265,43 +271,148 @@ stretch_mode = 5 unique_name_in_owner = true layout_mode = 0 offset_left = 18.0 -offset_top = 239.0 +offset_top = 241.0 offset_right = 270.0 -offset_bottom = 269.0 +offset_bottom = 273.0 mouse_filter = 2 theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) -theme_override_font_sizes/font_size = 21 +theme_override_font_sizes/font_size = 25 text = "select a fish" horizontal_alignment = 1 text_overrun_behavior = 3 -[node name="CoolerDetailData" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] +[node name="CoolerDetailStats" type="Control" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] unique_name_in_owner = true layout_mode = 0 offset_left = 18.0 -offset_top = 269.0 +offset_top = 274.0 offset_right = 270.0 -offset_bottom = 344.0 +offset_bottom = 339.0 +mouse_filter = 2 + +[node name="CoolerWeightRow" type="HBoxContainer" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats"] +unique_name_in_owner = true +layout_mode = 0 +offset_right = 252.0 +offset_bottom = 24.0 +mouse_filter = 2 +theme_override_constants/separation = 2 +alignment = 1 + +[node name="CoolerWeightValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats/CoolerWeightRow"] +unique_name_in_owner = true +layout_mode = 2 mouse_filter = 2 theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) -theme_override_font_sizes/font_size = 16 -horizontal_alignment = 1 -vertical_alignment = 1 +theme_override_font_sizes/font_size = 12 -[node name="CoolerSelectionSummary" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] +[node name="CoolerWeightUnit" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats/CoolerWeightRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) +theme_override_font_sizes/font_size = 14 +text = "lb" + +[node name="CoolerOfferRow" type="HBoxContainer" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats"] +unique_name_in_owner = true +layout_mode = 0 +offset_top = 27.0 +offset_right = 252.0 +offset_bottom = 57.0 +mouse_filter = 2 +theme_override_constants/separation = 4 +alignment = 1 + +[node name="CoolerOfferLabel" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats/CoolerOfferRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) +theme_override_font_sizes/font_size = 18 + +[node name="CoolerOfferValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerDetailStats/CoolerOfferRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.16, 0.16, 0.14, 1) +theme_override_font_sizes/font_size = 15 + +[node name="CoolerSelectionSummary" type="Control" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation"] unique_name_in_owner = true layout_mode = 0 offset_left = 18.0 offset_top = 346.0 offset_right = 270.0 -offset_bottom = 382.0 +offset_bottom = 386.0 +mouse_filter = 2 + +[node name="CoolerSelectionEmpty" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 mouse_filter = 2 theme_override_colors/font_color = Color(0.2, 0.18, 0.15, 0.86) -theme_override_font_sizes/font_size = 13 +theme_override_font_sizes/font_size = 18 text = "no fish selected" horizontal_alignment = 1 vertical_alignment = 1 +[node name="CoolerSelectedCountRow" type="HBoxContainer" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary"] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_right = 252.0 +offset_bottom = 20.0 +mouse_filter = 2 +theme_override_constants/separation = 4 +alignment = 1 + +[node name="CoolerSelectedCountValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary/CoolerSelectedCountRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.2, 0.18, 0.15, 0.86) +theme_override_font_sizes/font_size = 14 + +[node name="CoolerSelectedCountLabel" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary/CoolerSelectedCountRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.2, 0.18, 0.15, 0.86) +theme_override_font_sizes/font_size = 18 +text = "fish selected" + +[node name="CoolerCombinedOfferRow" type="HBoxContainer" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary"] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_top = 20.0 +offset_right = 252.0 +offset_bottom = 40.0 +mouse_filter = 2 +theme_override_constants/separation = 4 +alignment = 1 + +[node name="CoolerCombinedOfferLabel" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary/CoolerCombinedOfferRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.2, 0.18, 0.15, 0.86) +theme_override_font_sizes/font_size = 18 +text = "combined offer" + +[node name="CoolerCombinedOfferValue" type="Label" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation/CoolerSelectionSummary/CoolerCombinedOfferRow"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 2 +theme_override_colors/font_color = Color(0.2, 0.18, 0.15, 0.86) +theme_override_font_sizes/font_size = 14 + [node name="FavoriteBubble" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation" instance=ExtResource("12_ink_action")] unique_name_in_owner = true custom_minimum_size = Vector2(98, 78) @@ -311,6 +422,7 @@ offset_top = 386.0 offset_right = 134.0 offset_bottom = 464.0 text = "favorite" +allow_persistent_mark = true [node name="SellBubble" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot/CoolerPage/DetailConstellation" instance=ExtResource("12_ink_action")] unique_name_in_owner = true @@ -1085,10 +1197,10 @@ custom_minimum_size = Vector2(170, 64) [node name="NavigationCluster" type="Control" parent="ResponsivePlayerMenuStage/PlayerMenuPresentationScaleRoot"] unique_name_in_owner = true layout_mode = 0 -offset_left = 260.0 -offset_top = 14.0 -offset_right = 1020.0 -offset_bottom = 110.0 +offset_left = 463.0 +offset_top = 44.0 +offset_right = 1083.0 +offset_bottom = 144.0 mouse_filter = 1 script = ExtResource("5_cluster") profile = ExtResource("4_profile") @@ -1106,8 +1218,8 @@ neutral_size = Vector2(124, 120) desktop_anchor = Vector2(116, 60) compact_anchor = Vector2(118, 73.3333) compact_minimum_size = Vector2(84, 82) -minimum_font_size = 16 -maximum_font_size = 27 +minimum_font_size = 25 +maximum_font_size = 25 horizontal_amplitude = 1.2 vertical_amplitude = 2.4 motion_period = 5.6 @@ -1123,10 +1235,10 @@ text = "bag" script = ExtResource("6_bubble") profile = ExtResource("4_profile") neutral_size = Vector2(124, 120) -desktop_anchor = Vector2(248, 60) +desktop_anchor = Vector2(244, 60) compact_anchor = Vector2(251.333, 73.3333) compact_minimum_size = Vector2(84, 82) -minimum_font_size = 16 +minimum_font_size = 25 maximum_font_size = 25 horizontal_amplitude = 1.0 vertical_amplitude = 2.0 @@ -1143,11 +1255,11 @@ text = "logbook" script = ExtResource("6_bubble") profile = ExtResource("4_profile") neutral_size = Vector2(124, 120) -desktop_anchor = Vector2(380, 60) +desktop_anchor = Vector2(372, 60) compact_anchor = Vector2(384.667, 73.3333) compact_minimum_size = Vector2(84, 82) -minimum_font_size = 16 -maximum_font_size = 27 +minimum_font_size = 25 +maximum_font_size = 25 horizontal_amplitude = 1.3 vertical_amplitude = 2.5 motion_period = 5.9 @@ -1161,11 +1273,11 @@ layout_mode = 0 text = "close" script = ExtResource("6_bubble") profile = ExtResource("4_profile") -neutral_size = Vector2(110, 106) -desktop_anchor = Vector2(504, 57) +neutral_size = Vector2(96, 94) +desktop_anchor = Vector2(489, 57) compact_anchor = Vector2(512.667, 73.3333) compact_minimum_size = Vector2(76, 74) -minimum_font_size = 15 +minimum_font_size = 23 maximum_font_size = 23 horizontal_amplitude = 1.0 vertical_amplitude = 1.9 diff --git a/ui/settings/settings_bubble_page.gd b/ui/settings/settings_bubble_page.gd index 3483f32..96b4bcb 100644 --- a/ui/settings/settings_bubble_page.gd +++ b/ui/settings/settings_bubble_page.gd @@ -150,10 +150,7 @@ func _process(delta: float) -> void: func _update_layout() -> void: if not is_node_ready() or _cluster == null: return - var compact: bool = ( - size.x < compact_width_threshold - or size.y < compact_height_threshold - ) + var compact: bool = false var layout_maximum: Vector2 = maximum_layout_size if compact and compact_maximum_layout_size != Vector2.ZERO: layout_maximum = compact_maximum_layout_size diff --git a/ui/title_confirmation_bubble_page.gd b/ui/title_confirmation_bubble_page.gd index 88ef4a1..6a0d2e4 100644 --- a/ui/title_confirmation_bubble_page.gd +++ b/ui/title_confirmation_bubble_page.gd @@ -95,7 +95,7 @@ func set_stage_rect(stage_rect: Rect2) -> void: _cluster.size = field_size _cluster.apply_layout( field_size, - field_size.y < compact_height_threshold + false ) if not _is_transitioning: _cluster.position = _resting_cluster_position diff --git a/ui/title_screen.gd b/ui/title_screen.gd index aab4921..a5d5a9f 100644 --- a/ui/title_screen.gd +++ b/ui/title_screen.gd @@ -332,24 +332,9 @@ func _update_title_layout() -> void: func _update_responsive_title_stage() -> void: if not is_node_ready(): return - var display_size := Vector2( - maxf(1.0, size.x), - maxf(1.0, size.y) - ) - var reference_size: Vector2 = ( - TITLE_COMPACT_REFERENCE_SIZE - if display_size.y < BUBBLE_COMPACT_HEIGHT_THRESHOLD - else TITLE_DESKTOP_REFERENCE_SIZE - ) - var presentation_scale: float = minf( - display_size.x / reference_size.x, - display_size.y / reference_size.y - ) - _title_presentation_scale_root.size = reference_size - _title_presentation_scale_root.scale = Vector2.ONE * presentation_scale - _title_presentation_scale_root.position = ( - display_size - reference_size * presentation_scale - ) * 0.5 + _title_presentation_scale_root.size = TITLE_DESKTOP_REFERENCE_SIZE + _title_presentation_scale_root.scale = Vector2.ONE + _title_presentation_scale_root.position = Vector2.ZERO _update_title_layout() if ( _is_confirmation_active() diff --git a/ui/ui_pixelation_presenter.gd b/ui/ui_pixelation_presenter.gd index 476f3a8..1c79d28 100644 --- a/ui/ui_pixelation_presenter.gd +++ b/ui/ui_pixelation_presenter.gd @@ -2,6 +2,9 @@ class_name UIPixelationPresenter extends SubViewportContainer const MIN_UI_VIEWPORT_SIZE: Vector2i = Vector2i(256, 180) +const UIReferencePresentationType = preload( + "res://ui/ui_reference_presentation.gd" +) signal effective_pixel_size_changed( requested_pixel_size: int, @@ -68,25 +71,35 @@ func _resize_presentation() -> void: var root_size: Vector2i = get_window().size if root_size.x <= 0 or root_size.y <= 0: return + var display_size := Vector2(root_size) + var reference_scale: float = ( + UIReferencePresentationType.get_scale(display_size) + ) var previous_effective_size: int = _effective_pixel_size - _effective_pixel_size = _resolve_effective_pixel_size(root_size) - var viewport_size: Vector2i = PlayerSettings.get_ui_render_size( + _effective_pixel_size = _resolve_effective_pixel_size(reference_scale) + var render_height: int = _get_render_height( _effective_pixel_size, - root_size + reference_scale, ) - var render_scale: float = minf( - 1.0, - float(viewport_size.y) / float(root_size.y) + var render_scale: float = ( + float(render_height) + / UIReferencePresentationType.REFERENCE_SIZE.y + ) + var viewport_size := Vector2i( + roundi( + UIReferencePresentationType.REFERENCE_SIZE.x + * render_scale + ), + render_height, ) - var presentation_size: Vector2 = Vector2(viewport_size) / render_scale set_anchors_preset(Control.PRESET_TOP_LEFT) - position = (Vector2(root_size) - presentation_size) * 0.5 + position = UIReferencePresentationType.get_offset(display_size) size = Vector2(viewport_size) - scale = Vector2.ONE / render_scale + scale = Vector2.ONE * (reference_scale / render_scale) stretch_shrink = 1 _ui_root.position = Vector2.ZERO _ui_root.scale = Vector2.ONE * render_scale - _ui_root.size = Vector2(root_size) + _ui_root.size = UIReferencePresentationType.REFERENCE_SIZE if ( previous_effective_size != _effective_pixel_size or _requested_pixel_size != _effective_pixel_size @@ -97,11 +110,36 @@ func _resize_presentation() -> void: ) -func _resolve_effective_pixel_size(root_size: Vector2i) -> int: +func _get_render_height(pixel_size: int, reference_scale: float) -> int: + var displayed_canvas_height: int = maxi( + 1, + roundi( + UIReferencePresentationType.REFERENCE_SIZE.y + * reference_scale + ), + ) + if pixel_size == PlayerSettings.MIN_UI_PIXEL_SIZE: + return displayed_canvas_height + var target_height: int = PlayerSettings.get_ui_render_height( + pixel_size, + roundi(UIReferencePresentationType.REFERENCE_SIZE.y), + ) + return mini(displayed_canvas_height, target_height) + + +func _resolve_effective_pixel_size(reference_scale: float) -> int: for candidate: int in range(_requested_pixel_size, 0, -1): - var candidate_size: Vector2i = PlayerSettings.get_ui_render_size( + var candidate_height: int = _get_render_height( candidate, - root_size + reference_scale, + ) + var candidate_size := Vector2i( + roundi( + UIReferencePresentationType.REFERENCE_SIZE.x + * float(candidate_height) + / UIReferencePresentationType.REFERENCE_SIZE.y + ), + candidate_height, ) if ( candidate_size.x >= MIN_UI_VIEWPORT_SIZE.x diff --git a/ui/ui_reference_presentation.gd b/ui/ui_reference_presentation.gd new file mode 100644 index 0000000..2b0dc5a --- /dev/null +++ b/ui/ui_reference_presentation.gd @@ -0,0 +1,26 @@ +class_name UIReferencePresentation +extends RefCounted + +const REFERENCE_SIZE: Vector2 = Vector2(1280.0, 720.0) + + +static func get_scale(display_size: Vector2) -> float: + return minf( + maxf(display_size.x, 1.0) / REFERENCE_SIZE.x, + maxf(display_size.y, 1.0) / REFERENCE_SIZE.y, + ) + + +static func get_offset(display_size: Vector2) -> Vector2: + var presentation_scale: float = get_scale(display_size) + return ( + display_size - REFERENCE_SIZE * presentation_scale + ) * 0.5 + + +static func get_rect(display_size: Vector2) -> Rect2: + var presentation_scale: float = get_scale(display_size) + return Rect2( + get_offset(display_size), + REFERENCE_SIZE * presentation_scale, + ) diff --git a/ui/ui_reference_presentation.gd.uid b/ui/ui_reference_presentation.gd.uid new file mode 100644 index 0000000..b68d727 --- /dev/null +++ b/ui/ui_reference_presentation.gd.uid @@ -0,0 +1 @@ +uid://duv2b6847fb3y