Add artwork export and stamping

This commit is contained in:
Alexander Sellite 2026-08-21 21:01:21 -04:00
parent ba35db1015
commit 8107e2d89c
21 changed files with 1727 additions and 105 deletions

View file

@ -1118,6 +1118,10 @@ func _refresh_supplies() -> void:
var canvas_grid := _add_stock_icon_grid()
for product_id: StringName in ArtShopStockType.GRID_PRODUCTS:
_add_art_upgrade_button(product_id, canvas_grid)
_add_stock_section("stamps")
var stamp_grid := _add_stock_icon_grid()
for product_id: StringName in ArtShopStockType.STAMP_PRODUCTS:
_add_art_upgrade_button(product_id, stamp_grid)
call_deferred("_configure_controller_focus")
@ -1361,7 +1365,9 @@ func _add_art_upgrade_button(
var marker_color_id: StringName = (
PlayerArtUnlocksType.color_id_for_product(product_id)
)
if marker_color_id.is_empty():
if product_id == PlayerArtUnlocksType.STAMP_PRODUCT_ID:
_configure_art_text_tile(button, "stamp")
elif marker_color_id.is_empty():
var upgrade_icon: Texture2D = ART_UPGRADE_ICONS.get(
product_id,
FALLBACK_SUPPLY_ICON,
@ -1390,6 +1396,16 @@ func _add_art_upgrade_button(
button.pressed.connect(_purchase_art_upgrade.bind(product_id))
func _configure_art_text_tile(button: Button, label_text: String) -> void:
button.custom_minimum_size = SUPPLY_ICON_TILE_SIZE
button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
button.icon = null
button.expand_icon = false
button.alignment = HORIZONTAL_ALIGNMENT_CENTER
button.text = label_text
button.add_theme_font_size_override("font_size", 17)
func _make_stock_button(
button_text: String,
tooltip: String,

View file

@ -522,6 +522,15 @@ func _build_active_rows() -> void:
operator.pressed.connect(_confirm_operator.bind(entry))
UtilityPageStyle.apply_compact_ocean_button(operator)
row.add_child(operator)
var clear_art := Button.new()
clear_art.text = "clear art"
clear_art.disabled = not entry.can_clear_art
clear_art.tooltip_text = (
"Remove every shared artwork this player participated in."
)
clear_art.pressed.connect(_confirm_clear_art.bind(entry))
UtilityPageStyle.apply_compact_ocean_button(clear_art)
row.add_child(clear_art)
var kick := Button.new()
kick.disabled = not entry.can_kick
kick.pressed.connect(_confirm_kick.bind(entry))
@ -704,8 +713,21 @@ func _confirm_kick(entry: PlayerListEntry) -> void:
)
func _confirm_clear_art(entry: PlayerListEntry) -> void:
_confirm(
(
"Clear every shared artwork %s participated in?\n"
+ "This removes it for everyone and cannot be undone."
) % entry.display_name,
func() -> void:
_service.clear_art(
entry.peer_id, entry.full_fingerprint, entry.revision
)
)
func _confirm_ban(entry: PlayerListEntry) -> void:
_confirm("Ban %s · %s from this server?" % [
_confirm("Ban %s · %s from this server?\nTheir shared artwork will also be removed." % [
entry.display_name, entry.compact_fingerprint,
], func() -> void:
_service.ban(

View file

@ -29,7 +29,7 @@ const GRID_SIZE_ICONS: Dictionary[int, Texture2D] = {
64: preload("res://items/icons/art/art_kit_grid_large_light.png"),
128: preload("res://items/icons/art/art_kit_grid_xl_light.png"),
}
const TOOLBAR_WIDTH: float = 510.0
const TOOLBAR_WIDTH: float = 634.0
const TOOLBAR_HEIGHT: float = 373.0
const COLOR_RAIL_WIDTH: float = 46.0
const POPUP_LOCK_ICON_SIZE: int = 24
@ -48,6 +48,13 @@ const COLOR_LOCK_ICON_ALPHA: float = 0.34
@onready var _hide_guide_button: Button = %HideGuideButton
@onready var _restore_guide_button: Button = %RestoreGuideButton
@onready var _finalize_guide_button: Button = %FinalizeGuideButton
@onready var _export_button: Button = %ExportButton
@onready var _stamp_button: Button = %StampButton
@onready var _stamp_library_panel: PanelContainer = %StampLibraryPanel
@onready var _stamp_library_close: Button = %StampLibraryClose
@onready var _empty_stamp_library: Label = %EmptyStampLibrary
@onready var _stamp_scroll: ScrollContainer = %StampScroll
@onready var _stamp_grid: GridContainer = %StampGrid
var _service: NetworkSurfaceDrawingService
var _unlocks: PlayerArtUnlocks
@ -65,6 +72,7 @@ func _ready() -> void:
UtilityPageStyleType.apply_page(self)
_apply_toolbar_panel(_top_panel)
_apply_toolbar_panel(_color_panel)
_apply_toolbar_panel(_stamp_library_panel)
UtilityPageStyleType.apply_ocean_button(_mode_button)
UtilityPageStyleType.apply_ocean_button(_brush_option)
UtilityPageStyleType.apply_ocean_button(_grid_option)
@ -102,6 +110,9 @@ func _ready() -> void:
_finalize_guide_button.pressed.connect(
_arm_guide_action.bind(NetworkSurfaceDrawingService.GuideAction.FINALIZE)
)
_export_button.pressed.connect(_export_aimed_artwork)
_stamp_button.pressed.connect(_toggle_stamp_library)
_stamp_library_close.pressed.connect(_close_stamp_library)
_brush_option.item_selected.connect(_select_brush)
_grid_option.item_selected.connect(_select_grid)
_configure_pointer_only_controls()
@ -136,6 +147,8 @@ func _action_buttons() -> Array[Button]:
_hide_guide_button,
_restore_guide_button,
_finalize_guide_button,
_export_button,
_stamp_button,
]
@ -224,6 +237,12 @@ func owns_pointer_event(event: InputEvent) -> bool:
return (
_top_panel.get_global_rect().has_point(pointer_position)
or _color_panel.get_global_rect().has_point(pointer_position)
or (
_stamp_library_panel.visible
and _stamp_library_panel.get_global_rect().has_point(
pointer_position
)
)
)
return false
@ -264,6 +283,9 @@ func _configure_pointer_only_controls() -> void:
_hide_guide_button,
_restore_guide_button,
_finalize_guide_button,
_export_button,
_stamp_button,
_stamp_library_close,
]:
control.focus_mode = Control.FOCUS_NONE
control.focus_neighbor_left = NodePath()
@ -443,6 +465,14 @@ func _refresh_unlocks() -> void:
and _service.get_color_id() == color_id
),
)
_stamp_button.disabled = not _unlocks.is_stamp_unlocked()
_stamp_button.tooltip_text = (
"Place saved artwork stamps"
if not _stamp_button.disabled
else "Unlock the stamp tool in Art Supplies"
)
if _stamp_button.disabled:
_close_stamp_library()
func _apply_popup_unlock_state(
@ -524,6 +554,65 @@ func _arm_guide_action(action: int) -> void:
_service.arm_guide_action(action)
func _export_aimed_artwork() -> void:
if _service != null:
var export_path: String = _service.export_aimed_canvas()
if not export_path.is_empty() and _stamp_library_panel.visible:
_rebuild_stamp_library()
func _toggle_stamp_library() -> void:
if _stamp_button.disabled or _service == null:
return
if _stamp_library_panel.visible:
_close_stamp_library()
return
_rebuild_stamp_library()
_stamp_library_panel.show()
func _close_stamp_library() -> void:
_stamp_library_panel.hide()
func _rebuild_stamp_library() -> void:
for child: Node in _stamp_grid.get_children():
child.queue_free()
var entries: Array[Dictionary] = (
_service.get_saved_stamp_entries() if _service != null else []
)
_empty_stamp_library.visible = entries.is_empty()
_stamp_scroll.visible = not entries.is_empty()
for entry: Dictionary in entries:
var button := Button.new()
button.custom_minimum_size = Vector2(110.0, 108.0)
button.focus_mode = Control.FOCUS_NONE
button.expand_icon = true
button.icon_alignment = HORIZONTAL_ALIGNMENT_CENTER
button.vertical_icon_alignment = VERTICAL_ALIGNMENT_TOP
button.add_theme_constant_override("icon_max_width", 74)
button.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
button.icon = ImageTexture.create_from_image(entry["image"])
button.text = "%d×%d" % [entry["grid_size"], entry["grid_size"]]
button.tooltip_text = str(entry["file_name"])
button.accessibility_name = "saved artwork %s" % str(
entry["file_name"]
)
button.disabled = not bool(entry.get("available", false))
if button.disabled:
button.tooltip_text += "\nrequires its grid, colors, and stamp unlock"
UtilityPageStyleType.apply_ocean_button(button)
button.pressed.connect(
_select_saved_stamp.bind(str(entry["path"]))
)
_stamp_grid.add_child(button)
func _select_saved_stamp(path: String) -> void:
if _service != null and _service.select_saved_stamp(path):
_close_stamp_library()
func _on_unlocks_changed(_unlock_mask: int) -> void:
_refresh_unlocks()
@ -539,6 +628,7 @@ func _on_service_state_changed(
) -> void:
visible = is_active
if not is_active:
_close_stamp_library()
hide_virtual_pointer_overlay()
return
_mode_button.icon = (

View file

@ -20,7 +20,7 @@ layout_mode = 0
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -510.0
offset_left = -634.0
offset_bottom = 373.0
grow_horizontal = 0
mouse_filter = 2
@ -30,7 +30,7 @@ script = ExtResource("1_script")
[node name="TopPanel" type="PanelContainer" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_right = 510.0
offset_right = 634.0
offset_bottom = 60.0
[node name="Top" type="HBoxContainer" parent="TopPanel"]
@ -109,6 +109,22 @@ accessibility_name = "toggle finalize grid mode"
icon = ExtResource("9_grid_finish")
expand_icon = true
[node name="ExportButton" type="Button" parent="TopPanel/Top"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "export aimed artwork as PNG"
focus_mode = 0
accessibility_name = "export aimed artwork as PNG"
text = "png"
[node name="StampButton" type="Button" parent="TopPanel/Top"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "place saved artwork stamps"
focus_mode = 0
accessibility_name = "place saved artwork stamps"
text = "stamp"
[node name="ModeButton" type="Button" parent="TopPanel/Top"]
unique_name_in_owner = true
layout_mode = 2
@ -121,12 +137,74 @@ expand_icon = true
[node name="ColorPanel" type="PanelContainer" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_left = 464.0
offset_left = 588.0
offset_top = 54.0
offset_right = 510.0
offset_right = 634.0
offset_bottom = 373.0
[node name="ColorList" type="VBoxContainer" parent="ColorPanel"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 5
[node name="StampLibraryPanel" type="PanelContainer" parent="."]
unique_name_in_owner = true
visible = false
z_index = 10
layout_mode = 0
offset_left = 57.0
offset_top = 64.0
offset_right = 577.0
offset_bottom = 366.0
[node name="Margin" type="MarginContainer" parent="StampLibraryPanel"]
layout_mode = 2
theme_override_constants/margin_left = 12
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 12
theme_override_constants/margin_bottom = 10
[node name="Layout" type="VBoxContainer" parent="StampLibraryPanel/Margin"]
layout_mode = 2
theme_override_constants/separation = 8
[node name="Header" type="HBoxContainer" parent="StampLibraryPanel/Margin/Layout"]
layout_mode = 2
[node name="Title" type="Label" parent="StampLibraryPanel/Margin/Layout/Header"]
layout_mode = 2
size_flags_horizontal = 3
text = "saved artwork"
theme_override_font_sizes/font_size = 22
[node name="StampLibraryClose" type="Button" parent="StampLibraryPanel/Margin/Layout/Header"]
unique_name_in_owner = true
custom_minimum_size = Vector2(42, 36)
layout_mode = 2
focus_mode = 0
tooltip_text = "close saved artwork"
accessibility_name = "close saved artwork"
text = "×"
[node name="EmptyStampLibrary" type="Label" parent="StampLibraryPanel/Margin/Layout"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
text = "export artwork to add stamps"
horizontal_alignment = 1
vertical_alignment = 1
[node name="StampScroll" type="ScrollContainer" parent="StampLibraryPanel/Margin/Layout"]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
[node name="StampGrid" type="GridContainer" parent="StampLibraryPanel/Margin/Layout/StampScroll"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/h_separation = 12
theme_override_constants/v_separation = 12
columns = 4