Keep utility pages within menu bounds

This commit is contained in:
Alexander Sellite 2026-08-22 22:56:55 -04:00
parent 3dbfd74b6c
commit 1f3308d83b
3 changed files with 200 additions and 85 deletions

View file

@ -470,77 +470,94 @@ func _build_active_rows() -> void:
_add_empty("No authenticated players.")
return
for entry: PlayerListEntry in entries:
var row := _make_row()
var identity := Label.new()
identity.custom_minimum_size.x = 250
identity.size_flags_horizontal = Control.SIZE_EXPAND_FILL
var markers: Array[String] = []
if entry.is_host:
markers.append("host")
if entry.is_operator:
markers.append("operator")
if entry.is_local_player:
markers.append("You")
identity.text = "%s%s · %s\n%s" % [
entry.display_name,
" [%s]" % ", ".join(markers) if not markers.is_empty() else "",
entry.compact_fingerprint,
entry.continuity_state,
]
identity.tooltip_text = "Full identity fingerprint:\n%s" % (
entry.full_fingerprint
)
identity.add_theme_color_override(
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
)
row.add_child(identity)
var ping := Label.new()
ping.custom_minimum_size.x = 60
ping.text = (
"Local" if entry.is_host
else "%d ms" % entry.ping_to_host_ms
if entry.ping_to_host_ms >= 0 else ""
)
ping.add_theme_color_override(
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
)
row.add_child(ping)
var mute := Button.new()
var mute_action: String = "unmute" if entry.muted else "mute"
mute.disabled = entry.is_local_player
mute.pressed.connect(_toggle_mute.bind(entry))
_configure_moderation_button(mute, MODERATION_MUTE_ICON, mute_action)
row.add_child(mute)
var block := Button.new()
block.disabled = entry.is_local_player
block.pressed.connect(_confirm_block.bind(entry))
_configure_moderation_button(block, MODERATION_BLOCK_ICON, "block")
row.add_child(block)
if entry.can_manage_operator:
var operator := Button.new()
operator.text = "deop" if entry.is_operator else "op"
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))
_configure_moderation_button(kick, MODERATION_KICK_ICON, "kick")
row.add_child(kick)
var ban := Button.new()
ban.disabled = not entry.can_ban
ban.pressed.connect(_confirm_ban.bind(entry))
_configure_moderation_button(ban, MODERATION_BAN_ICON, "ban")
row.add_child(ban)
_build_active_player_row(entry)
func _build_active_player_row(entry: PlayerListEntry) -> void:
var row := _make_active_player_row()
var identity_row := HBoxContainer.new()
identity_row.add_theme_constant_override("separation", 8)
row.add_child(identity_row)
var identity := Label.new()
identity.clip_text = true
identity.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
identity.size_flags_horizontal = Control.SIZE_EXPAND_FILL
var markers: Array[String] = []
if entry.is_host:
markers.append("host")
if entry.is_operator:
markers.append("operator")
if entry.is_local_player:
markers.append("You")
identity.text = "%s%s · %s\n%s" % [
entry.display_name,
" [%s]" % ", ".join(markers) if not markers.is_empty() else "",
entry.compact_fingerprint,
entry.continuity_state,
]
identity.tooltip_text = "Full identity fingerprint:\n%s" % (
entry.full_fingerprint
)
identity.add_theme_color_override(
"font_color", UtilityPageStyle.OCEAN_TEXT_PRIMARY
)
identity_row.add_child(identity)
var ping := Label.new()
ping.custom_minimum_size.x = 72
ping.text = (
"Local" if entry.is_host
else "%d ms" % entry.ping_to_host_ms
if entry.ping_to_host_ms >= 0 else ""
)
ping.add_theme_color_override(
"font_color", UtilityPageStyle.OCEAN_TEXT_SECONDARY
)
ping.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
identity_row.add_child(ping)
var actions := HBoxContainer.new()
actions.alignment = BoxContainer.ALIGNMENT_END
actions.add_theme_constant_override("separation", 6)
row.add_child(actions)
var mute := Button.new()
var mute_action: String = "unmute" if entry.muted else "mute"
mute.disabled = entry.is_local_player
mute.pressed.connect(_toggle_mute.bind(entry))
_configure_moderation_button(mute, MODERATION_MUTE_ICON, mute_action)
actions.add_child(mute)
var block := Button.new()
block.disabled = entry.is_local_player
block.pressed.connect(_confirm_block.bind(entry))
_configure_moderation_button(block, MODERATION_BLOCK_ICON, "block")
actions.add_child(block)
if entry.can_manage_operator:
var operator := Button.new()
operator.text = "deop" if entry.is_operator else "op"
operator.pressed.connect(_confirm_operator.bind(entry))
UtilityPageStyle.apply_compact_ocean_button(operator)
operator.custom_minimum_size = MODERATION_BUTTON_SIZE
actions.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)
clear_art.custom_minimum_size = Vector2(84.0, 40.0)
actions.add_child(clear_art)
var kick := Button.new()
kick.disabled = not entry.can_kick
kick.pressed.connect(_confirm_kick.bind(entry))
_configure_moderation_button(kick, MODERATION_KICK_ICON, "kick")
actions.add_child(kick)
var ban := Button.new()
ban.disabled = not entry.can_ban
ban.pressed.connect(_confirm_ban.bind(entry))
_configure_moderation_button(ban, MODERATION_BAN_ICON, "ban")
actions.add_child(ban)
func _configure_moderation_button(
@ -580,8 +597,9 @@ 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 = 600
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.text = "session artwork · %d layers · %d painted pixels" % [
counts.x, counts.y,
]
@ -611,8 +629,9 @@ func _build_relationship_rows() -> void:
for record: Dictionary in records:
var row := _make_row()
var label := Label.new()
label.custom_minimum_size.x = 560
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
var fingerprint := str(record["fingerprint"])
label.text = "%s · %s %s" % [
str(record.get("last_known_display_name", "Player")),
@ -651,8 +670,9 @@ func _build_ban_rows() -> void:
var row := _make_row()
var fingerprint := str(record["target_fingerprint"])
var label := Label.new()
label.custom_minimum_size.x = 600
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.clip_text = true
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
label.text = "%s · %s banned %s" % [
str(record.get("last_known_display_name", "Player")),
NetworkIdentityCrypto.compact_suffix(fingerprint),
@ -683,6 +703,20 @@ func _make_row() -> HBoxContainer:
return row
func _make_active_player_row() -> VBoxContainer:
var panel := PanelContainer.new()
panel.clip_contents = true
panel.add_theme_stylebox_override(
"panel", UtilityPageStyle.row_style(false)
)
_list.add_child(panel)
var row := VBoxContainer.new()
row.custom_minimum_size.y = 88
row.add_theme_constant_override("separation", 4)
panel.add_child(row)
return row
func _add_empty(text: String) -> void:
var label := Label.new()
label.text = text