Add collaborative surface drawing

This commit is contained in:
Alexander Sellite 2026-08-01 22:55:39 -04:00
parent 6b7ef4c11b
commit b92c55562d
28 changed files with 3504 additions and 2 deletions

View file

@ -65,6 +65,10 @@ signal shop_backdrop_visibility_changed(is_visible: bool)
@onready var _effect_status: Label = %EffectStatus
@onready var _chat_ui: ChatUIType = %ChatUI
@onready var _emote_radial_menu: EmoteRadialMenuType = %EmoteRadialMenu
@onready var _marker_hud: PanelContainer = %MarkerHUD
@onready var _marker_swatch: ColorRect = %MarkerSwatch
@onready var _marker_summary: Label = %MarkerSummary
@onready var _marker_help: Label = %MarkerHelp
@onready var _title_settings_panel: SettingsPanelType = (
$UIRoot/TitleScreen/ResponsiveTitleStage/TitlePresentationScaleRoot/SettingsPanel
)
@ -84,6 +88,7 @@ var _player_menu_hotbar_visible: bool = false
var _item_effects: PlayerItemEffectsType
var _main_shop_buyer: FishBuyerProfileType
var _shop_interaction: ShopInteractionType
var _surface_drawing: NetworkSurfaceDrawingService
func _ready() -> void:
@ -136,6 +141,7 @@ func setup(
network_profile_service: NetworkProfileService,
network_player_list: NetworkPlayerListService,
settings_manager: PlayerSettingsManagerType,
surface_drawing: NetworkSurfaceDrawingService,
) -> void:
_player = player
_fishing_spot = fishing_spot
@ -206,9 +212,30 @@ func setup(
)
_main_shop_buyer = main_shop_buyer
_shop_interaction = shop_interaction
_surface_drawing = surface_drawing
if _surface_drawing != null:
_surface_drawing.hud_state_changed.connect(
_on_surface_drawing_hud_state_changed
)
func _input(event: InputEvent) -> void:
var drawing_can_open: bool = (
_gameplay_ui_enabled
and not _system_menu_open
and not _player_menu_open
and not _shop_open
and not _chat_input_open
and not _showcase_active
and _fishing_spot != null
and _fishing_spot.can_use_surface_drawing()
)
if (
_surface_drawing != null
and _surface_drawing.handle_input(event, drawing_can_open)
):
get_viewport().set_input_as_handled()
return
if _emote_radial_menu == null:
return
var can_open: bool = (
@ -306,6 +333,8 @@ func set_gameplay_ui_enabled(enabled: bool) -> void:
_gameplay_transient_hud.visible = enabled and not _player_menu_open
_refresh_chat_availability()
if not enabled:
if _surface_drawing != null:
_surface_drawing.deactivate()
close_player_menu_for_session_end()
_fishing_shop.close_for_session_end()
_fishing_panel.visible = false
@ -320,6 +349,8 @@ func set_gameplay_ui_enabled(enabled: bool) -> void:
func set_system_menu_open(is_open: bool) -> void:
_system_menu_open = is_open
if is_open and _surface_drawing != null:
_surface_drawing.deactivate()
_refresh_chat_availability()
_refresh_hotbar_visibility()
_hotbar_ui.set_gameplay_input_enabled(
@ -532,6 +563,8 @@ func _on_showcase_changed(
func _on_player_menu_visibility_changed(is_open: bool) -> void:
_player_menu_open = is_open
if is_open and _surface_drawing != null:
_surface_drawing.deactivate()
_gameplay_transient_hud.visible = _gameplay_ui_enabled and not is_open
if is_open:
_hotbar_ui.set_drag_enabled(false)
@ -577,6 +610,8 @@ func _on_player_menu_exit_started() -> void:
func _on_shop_visibility_changed(is_open: bool) -> void:
_shop_open = is_open
if is_open and _surface_drawing != null:
_surface_drawing.deactivate()
shop_backdrop_visibility_changed.emit(is_open)
if not is_open and _player_menu.is_shop_cooler_mounted():
_player_menu.unmount_shop_cooler()
@ -679,9 +714,40 @@ func _emit_interactive_pointer_ui_changed() -> void:
func _on_chat_text_entry_ownership_changed(active: bool) -> void:
_chat_input_open = active
if active and _surface_drawing != null:
_surface_drawing.deactivate()
_emit_interactive_pointer_ui_changed()
func _on_surface_drawing_hud_state_changed(
is_active: bool,
mode_name: String,
color_name: String,
color_value: Color,
brush_size: int,
status: String,
) -> void:
_marker_hud.visible = is_active and _gameplay_ui_enabled
_marker_swatch.visible = mode_name != "place grid"
_marker_swatch.color = color_value
_marker_summary.text = (
"place shared grid"
if mode_name == "place grid"
else "marker • %s • brush %d" % [
color_name.to_lower(), brush_size,
]
)
_marker_help.text = (
status
if not status.is_empty()
else (
"click place/restore • shift hide • ctrl shift finish • shift scroll zoom"
if mode_name == "place grid"
else "click draw • shift click erase • ctrl z undo • shift scroll zoom"
)
)
func _refresh_chat_availability() -> void:
if _chat_ui == null:
return

View file

@ -34,6 +34,17 @@ corner_radius_bottom_left = 12
[sub_resource type="StyleBoxFlat" id="StyleBox_transparent"]
bg_color = Color(0, 0, 0, 0)
[sub_resource type="StyleBoxFlat" id="StyleBox_marker_panel"]
bg_color = Color(0.051, 0.173, 0.227, 0.96)
corner_radius_top_left = 12
corner_radius_top_right = 12
corner_radius_bottom_right = 12
corner_radius_bottom_left = 12
content_margin_left = 14.0
content_margin_top = 9.0
content_margin_right = 14.0
content_margin_bottom = 9.0
[node name="GameUI" type="CanvasLayer"]
script = ExtResource("1_ui")
@ -254,6 +265,51 @@ theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.9)
theme_override_constants/shadow_offset_x = 2
theme_override_constants/shadow_offset_y = 2
[node name="MarkerHUD" type="PanelContainer" parent="UIRoot/CanonicalStage/GameplayTransientHUD"]
unique_name_in_owner = true
visible = false
z_index = 58
anchors_preset = 10
anchor_left = 1.0
anchor_right = 1.0
offset_left = -510.0
offset_top = 18.0
offset_right = -18.0
offset_bottom = 92.0
grow_horizontal = 0
mouse_filter = 2
theme = ExtResource("3_theme")
theme_override_styles/panel = SubResource("StyleBox_marker_panel")
[node name="Layout" type="HBoxContainer" parent="UIRoot/CanonicalStage/GameplayTransientHUD/MarkerHUD"]
layout_mode = 2
theme_override_constants/separation = 12
[node name="MarkerSwatch" type="ColorRect" parent="UIRoot/CanonicalStage/GameplayTransientHUD/MarkerHUD/Layout"]
unique_name_in_owner = true
custom_minimum_size = Vector2(42, 42)
layout_mode = 2
mouse_filter = 2
color = Color(0.960784, 0.933333, 0.85098, 1)
[node name="Text" type="VBoxContainer" parent="UIRoot/CanonicalStage/GameplayTransientHUD/MarkerHUD/Layout"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 0
[node name="MarkerSummary" type="Label" parent="UIRoot/CanonicalStage/GameplayTransientHUD/MarkerHUD/Layout/Text"]
unique_name_in_owner = true
layout_mode = 2
text = "marker • chalk white • brush 1"
theme_override_font_sizes/font_size = 18
[node name="MarkerHelp" type="Label" parent="UIRoot/CanonicalStage/GameplayTransientHUD/MarkerHUD/Layout/Text"]
unique_name_in_owner = true
layout_mode = 2
text = "click draw • shift erase • ctrl z undo • shift scroll zoom"
theme_override_colors/font_color = Color(0.623529, 0.811765, 0.823529, 1)
theme_override_font_sizes/font_size = 13
[node name="ChatUI" type="Control" parent="UIRoot"]
unique_name_in_owner = true
layout_mode = 1

View file

@ -105,6 +105,8 @@ func _refresh() -> void:
func _build_active_rows() -> void:
if _service.is_local_host():
_build_session_artwork_controls()
var entries := _service.get_entries()
if entries.is_empty():
_add_empty("No authenticated players.")
@ -169,6 +171,33 @@ func _build_active_rows() -> void:
_list.add_child(row)
func _build_session_artwork_controls() -> void:
var counts: Vector2i = _service.get_session_artwork_counts()
var row := _make_row()
var label := Label.new()
label.custom_minimum_size.x = 830
label.text = "session artwork · %d layers · %d painted pixels" % [
counts.x, counts.y,
]
label.add_theme_color_override(
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
)
row.add_child(label)
var reset := Button.new()
reset.text = "reset paint"
reset.disabled = counts.x == 0
reset.tooltip_text = "Clears all shared artwork from this session."
reset.pressed.connect(func() -> void:
_confirm(
"Clear all shared paint from this session?\nThis cannot be undone.",
_service.reset_session_artwork,
)
)
UtilityPageStyle.apply_ocean_button(reset)
row.add_child(reset)
_list.add_child(row)
func _build_relationship_rows() -> void:
var records := _service.get_relationships()
if records.is_empty():