forked from xiangwang25/whale-town-front-v2
feat: polish personal space editor
This commit is contained in:
@@ -82,6 +82,38 @@ func open_private_chat(user_id: String, username: String) -> void:
|
||||
event_system.call("emit_event", EventNames.CHAT_PRIVATE_TARGET_SELECTED, {"userId": user_id, "username": username})
|
||||
_close_profile()
|
||||
|
||||
func visit_room(user_id: String, nickname: String = "") -> void:
|
||||
var owner_id: String = user_id.strip_edges()
|
||||
if owner_id.is_empty():
|
||||
return
|
||||
_request_get("/social/profiles/%s" % owner_id.uri_encode(), func(success: bool, response: Dictionary, error: Dictionary) -> void:
|
||||
if not success:
|
||||
_show_status("无法访问房间:%s" % str(error.get("message", "请求失败")))
|
||||
return
|
||||
var profile_variant: Variant = response.get("data", {})
|
||||
if not (profile_variant is Dictionary) or not bool((profile_variant as Dictionary).get("room_visitable", false)):
|
||||
_show_status("该玩家当前不开放个人空间访问")
|
||||
return
|
||||
var profile: Dictionary = profile_variant as Dictionary
|
||||
_begin_room_visit(owner_id, str(profile.get("nickname", nickname)))
|
||||
)
|
||||
|
||||
func _begin_room_visit(owner_id: String, nickname: String) -> void:
|
||||
var current_scene: Node = get_tree().current_scene
|
||||
var return_scene: String = SceneManager.get_current_scene_name().strip_edges()
|
||||
if return_scene.is_empty() and current_scene != null:
|
||||
return_scene = _scene_name_to_id(current_scene.name)
|
||||
if return_scene.is_empty() or return_scene == "personal_space":
|
||||
return_scene = "square"
|
||||
var return_position := Vector2.ZERO
|
||||
if current_scene != null:
|
||||
var player_node := current_scene.get_node_or_null("YSortWorld/Characters/Players/Player") as Node2D
|
||||
if player_node != null:
|
||||
return_position = player_node.global_position
|
||||
SceneManager.begin_room_visit(owner_id, nickname, return_scene, return_position)
|
||||
_close_profile()
|
||||
SceneManager.change_scene("personal_space")
|
||||
|
||||
func request_travel(destination_id: String, completion: Callable = Callable()) -> void:
|
||||
_request_post("/world/travel-destinations/%s/travel" % destination_id.uri_encode(), {}, func(success: bool, response: Dictionary, error: Dictionary) -> void:
|
||||
if not success:
|
||||
@@ -218,6 +250,8 @@ func _render_profile() -> void:
|
||||
actions.add_theme_constant_override("separation", 8)
|
||||
actions.add_child(_button("私聊", func() -> void: open_private_chat(user_id, nickname)))
|
||||
actions.add_child(_button("加好友", func() -> void: request_friend(user_id, nickname)))
|
||||
if bool(_current_profile.get("room_visitable", false)):
|
||||
actions.add_child(_button("访问房间", func() -> void: visit_room(user_id, nickname)))
|
||||
_profile_content.add_child(actions)
|
||||
var safety := HBoxContainer.new()
|
||||
safety.add_theme_constant_override("separation", 8)
|
||||
@@ -427,6 +461,14 @@ func _current_user_id() -> String:
|
||||
func _area_label(map_id: String) -> String:
|
||||
return {"whale_port": "中心广场", "work_zone": "打工区", "whale_cafe": "鲸鱼咖啡馆", "personal_space": "个人空间"}.get(map_id, map_id)
|
||||
|
||||
func _scene_name_to_id(scene_name: String) -> String:
|
||||
return {
|
||||
"Square": "square",
|
||||
"WorkZone": "work_zone",
|
||||
"CafeInterior": "cafe_interior",
|
||||
"PersonalSpace": "personal_space",
|
||||
}.get(scene_name, "")
|
||||
|
||||
func _interest_catalog() -> Array[Dictionary]:
|
||||
return [
|
||||
{"id": "ai", "label": "AI/大模型"}, {"id": "programming", "label": "编程开发"},
|
||||
|
||||
Reference in New Issue
Block a user