feat: polish personal space editor

This commit is contained in:
ANG-Server
2026-07-22 13:41:28 +08:00
parent e3accf6b71
commit d60444d2eb
10 changed files with 858 additions and 42 deletions

View File

@@ -371,6 +371,19 @@ func _create_friend_row(friend: Dictionary) -> Control:
dot.add_theme_stylebox_override("panel", _create_dot_style(ONLINE_COLOR if online else OFFLINE_COLOR))
row.add_child(dot)
if bool(friend.get("room_visitable", false)):
var visit_button := _create_small_button("房间", ACCENT_COLOR)
visit_button.name = "VisitRoomButton"
visit_button.custom_minimum_size = Vector2(56, 30)
visit_button.set_anchors_preset(Control.PRESET_CENTER_RIGHT)
visit_button.offset_left = -68
visit_button.offset_top = -15
visit_button.offset_right = -12
visit_button.offset_bottom = 15
visit_button.z_index = 2
visit_button.pressed.connect(func() -> void: _visit_friend_room(userId, username))
button.add_child(visit_button)
return button
func _create_request_row(request: Dictionary) -> Control:
@@ -417,6 +430,13 @@ func _select_friend(userId: String, username: String, _online: bool) -> void:
"username": username
})
func _visit_friend_room(userId: String, username: String) -> void:
if userId.strip_edges().is_empty():
return
var social_manager := get_node_or_null("/root/SocialManager")
if social_manager != null and social_manager.has_method("visit_room"):
social_manager.call("visit_room", userId, username)
func _respond_request(userId: String, username: String, accepted: bool) -> void:
if userId.strip_edges().is_empty():
return

View File

@@ -436,6 +436,8 @@ func _on_travel_authorized(success: bool, destination: Dictionary) -> void:
_render_markers()
return
set_panel_open(false)
if sceneName == "personal_space":
SceneManager.clear_room_visit_context()
SceneManager.set_next_destination_id(str(destination.get("id", "")))
SceneManager.set_next_scene_position(position)
SceneManager.change_scene(sceneName)

View File

@@ -47,6 +47,7 @@ const DEFAULT_SETTINGS: Dictionary = {
"allow_nearby_private": true,
"allow_nearby_friend_requests": true,
"allow_nearby_profile": true,
"room_visit_policy": "friends",
"mute_ui_sfx": false,
}
@@ -388,6 +389,9 @@ func _render_chat_content() -> void:
_create_toggle_row("chat", "允许附近私聊", "allow_nearby_private", "附近玩家按 E 可以发起悄悄话"),
_create_toggle_row("account", "允许好友申请", "allow_nearby_friend_requests", "附近玩家可通过互动列表发送好友申请"),
]))
_content.add_child(_create_section("个人空间访问", [
_create_room_visit_policy_row(),
]))
func _render_controls_content() -> void:
_content.add_child(_create_section("操作说明", [
@@ -526,6 +530,58 @@ func _create_toggle_row(iconName: String, labelText: String, key: String, detail
return row
func _create_room_visit_policy_row() -> Control:
var row := HBoxContainer.new()
row.custom_minimum_size = Vector2(0, 54)
row.add_theme_constant_override("separation", 16)
row.alignment = BoxContainer.ALIGNMENT_CENTER
var icon := ICON_SCRIPT.new() as Control
icon.set("iconName", "account")
icon.set("active", true)
icon.custom_minimum_size = Vector2(34, 34)
row.add_child(icon)
var text_box := VBoxContainer.new()
text_box.size_flags_horizontal = Control.SIZE_EXPAND_FILL
text_box.alignment = BoxContainer.ALIGNMENT_CENTER
text_box.add_theme_constant_override("separation", 2)
row.add_child(text_box)
var label := Label.new()
label.text = "谁可以参观我的房间"
label.add_theme_color_override("font_color", TEXT_COLOR)
label.add_theme_font_size_override("font_size", 17)
text_box.add_child(label)
var detail := Label.new()
detail.text = "拉黑关系始终无法访问;房主始终可编辑。"
detail.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
detail.add_theme_color_override("font_color", MUTED_COLOR)
detail.add_theme_font_size_override("font_size", 13)
text_box.add_child(detail)
var selector := OptionButton.new()
selector.custom_minimum_size = Vector2(126, 38)
selector.focus_mode = Control.FOCUS_NONE
selector.add_item("仅好友")
selector.set_item_metadata(0, "friends")
selector.add_item("公开")
selector.set_item_metadata(1, "public")
selector.add_item("关闭访问")
selector.set_item_metadata(2, "closed")
var current_policy: String = str(_settings.get("room_visit_policy", "friends"))
for index in range(selector.item_count):
if str(selector.get_item_metadata(index)) == current_policy:
selector.select(index)
break
selector.item_selected.connect(func(index: int) -> void:
_settings["room_visit_policy"] = str(selector.get_item_metadata(index))
_apply_preview_settings()
)
row.add_child(selector)
return row
func _create_scale_row() -> Control:
var row := HBoxContainer.new()
row.custom_minimum_size = Vector2(0, 48)