优化猪头怪追击参数;增加 disable_prop_item_temp
This commit is contained in:
parent
715658c199
commit
784d6937ed
@ -22,7 +22,9 @@ var archive: AssembledArchive:
|
|||||||
# emit signal
|
# emit signal
|
||||||
archive_loaded.emit()
|
archive_loaded.emit()
|
||||||
GlobalConfigManager.print_global_info()
|
GlobalConfigManager.print_global_info()
|
||||||
print("use archive ", archive.resource_path)
|
print("[Archive] use archive ", archive.resource_path)
|
||||||
|
else:
|
||||||
|
print("[Archive] unload archive")
|
||||||
|
|
||||||
var archives_dict: Dictionary[int, AssembledArchive] = {}
|
var archives_dict: Dictionary[int, AssembledArchive] = {}
|
||||||
var archives_notes_dict: Dictionary[int, String] = {}
|
var archives_notes_dict: Dictionary[int, String] = {}
|
||||||
|
@ -238,6 +238,16 @@ func disable_prop_item(prop_key: String) -> void:
|
|||||||
printerr("disable_prop_item PropHud node not found")
|
printerr("disable_prop_item PropHud node not found")
|
||||||
|
|
||||||
|
|
||||||
|
# 临时禁用 prop, 延迟写入(真正 disable_prop_item 的时候写入)
|
||||||
|
func disable_prop_item_temp(prop_key: String) -> void:
|
||||||
|
var prop_hud = get_prop_hud()
|
||||||
|
if prop_hud:
|
||||||
|
print("[prop] disable_prop_item_temp prop:", prop_key)
|
||||||
|
prop_hud.disable_prop_item_temp(prop_key)
|
||||||
|
else:
|
||||||
|
printerr("disable_prop_item_temp PropHud node not found")
|
||||||
|
|
||||||
|
|
||||||
func pop_os_with_str(translation_key: String) -> void:
|
func pop_os_with_str(translation_key: String) -> void:
|
||||||
var player = get_player() as MainPlayer
|
var player = get_player() as MainPlayer
|
||||||
if player:
|
if player:
|
||||||
@ -319,6 +329,8 @@ func pop_chapter_notification(id: int) -> void:
|
|||||||
func checkout_index_page(transition := true) -> void:
|
func checkout_index_page(transition := true) -> void:
|
||||||
# 保存后,渐隐切换场景
|
# 保存后,渐隐切换场景
|
||||||
ArchiveManager.save_all()
|
ArchiveManager.save_all()
|
||||||
|
# 移除 archive
|
||||||
|
ArchiveManager.archive = null
|
||||||
if transition:
|
if transition:
|
||||||
var ground_loader = get_ground_loader() as GroundLoader
|
var ground_loader = get_ground_loader() as GroundLoader
|
||||||
if ground_loader:
|
if ground_loader:
|
||||||
|
@ -53,6 +53,7 @@ debug_note = "出来就不能回来了"
|
|||||||
portal_name = "1"
|
portal_name = "1"
|
||||||
target_scene = "c02_s12"
|
target_scene = "c02_s12"
|
||||||
target_portal = "left"
|
target_portal = "left"
|
||||||
|
status = "opened"
|
||||||
|
|
||||||
[node name="Ambush猫咪敲门互动2" parent="Ground/DeployLayer" index="3" instance=ExtResource("8_m6dyn")]
|
[node name="Ambush猫咪敲门互动2" parent="Ground/DeployLayer" index="3" instance=ExtResource("8_m6dyn")]
|
||||||
position = Vector2(106, 6)
|
position = Vector2(106, 6)
|
||||||
|
@ -10,10 +10,10 @@ extends Node2D
|
|||||||
@export var trun_back_detect_x := 150
|
@export var trun_back_detect_x := 150
|
||||||
# 抓取范围,优先 catch_front 播放 猪头怪抓盒子猫
|
# 抓取范围,优先 catch_front 播放 猪头怪抓盒子猫
|
||||||
# 其次 catch_nearby 播放 猪头怪抓盒子猫后段
|
# 其次 catch_nearby 播放 猪头怪抓盒子猫后段
|
||||||
@export var catch_front_x_range := Vector2(55 - 3, 55 + 3)
|
var catch_front_x_range := Vector2(55 - 3, 55 + 3)
|
||||||
@export var catch_nearby_x_range := Vector2(-10, 55)
|
var catch_nearby_x_range := Vector2(-10, 55)
|
||||||
# 观测范围,在观测范围内进入盒子仍旧会被抓
|
# 观测范围,在观测范围内进入盒子仍旧会被抓
|
||||||
@export var watching_x := 180
|
var watching_x := 80
|
||||||
|
|
||||||
# 允许被抓后重开游戏
|
# 允许被抓后重开游戏
|
||||||
var allow_restart_game := true
|
var allow_restart_game := true
|
||||||
@ -50,6 +50,7 @@ func _on_ground_ready():
|
|||||||
var archive = ArchiveManager.archive as AssembledArchive
|
var archive = ArchiveManager.archive as AssembledArchive
|
||||||
var portal = archive.entrance_portal
|
var portal = archive.entrance_portal
|
||||||
var chasing_started = ArchiveManager.get_global_value(&"c02_boxcat_chasing_started", false)
|
var chasing_started = ArchiveManager.get_global_value(&"c02_boxcat_chasing_started", false)
|
||||||
|
# 盒子猫二楼 c02_s13
|
||||||
if archive.current_scene == "c02_s13":
|
if archive.current_scene == "c02_s13":
|
||||||
# 开始追逐后,禁用二楼两只
|
# 开始追逐后,禁用二楼两只
|
||||||
if chasing_started and not transfer_mode:
|
if chasing_started and not transfer_mode:
|
||||||
@ -89,8 +90,8 @@ func _on_ground_ready():
|
|||||||
global_position.x = portal_node.global_position.x
|
global_position.x = portal_node.global_position.x
|
||||||
# 禁用传送过来的 portal 3s
|
# 禁用传送过来的 portal 3s
|
||||||
_disable_portal_a_few_seconds(portal_node)
|
_disable_portal_a_few_seconds(portal_node)
|
||||||
# 3 秒后传送
|
# 2.5 秒后传送
|
||||||
Util.timer(1.0, _do_transfer)
|
Util.timer(2.5, _do_transfer)
|
||||||
if GlobalConfig.DEBUG:
|
if GlobalConfig.DEBUG:
|
||||||
print("猪头怪 Transfer to: " + portal)
|
print("猪头怪 Transfer to: " + portal)
|
||||||
else:
|
else:
|
||||||
@ -126,10 +127,10 @@ func toggle_footstep_sfx(play := true):
|
|||||||
footstep_timer.stop()
|
footstep_timer.stop()
|
||||||
|
|
||||||
|
|
||||||
# 禁用传送过来的 portal 3s
|
# 禁用传送过来的 portal 4s
|
||||||
func _disable_portal_a_few_seconds(portal_node: Portal2D):
|
func _disable_portal_a_few_seconds(portal_node: Portal2D):
|
||||||
portal_node.enabled = false
|
portal_node.enabled = false
|
||||||
await create_tween().tween_interval(3.0).finished
|
await create_tween().tween_interval(4.0).finished
|
||||||
portal_node.enabled = true
|
portal_node.enabled = true
|
||||||
|
|
||||||
|
|
||||||
@ -183,6 +184,8 @@ func do_catch(front: bool):
|
|||||||
SceneManager.unlock_player()
|
SceneManager.unlock_player()
|
||||||
# 等待动画播放后秒,再检查是否允许重开游戏
|
# 等待动画播放后秒,再检查是否允许重开游戏
|
||||||
if allow_restart_game:
|
if allow_restart_game:
|
||||||
|
# 重置追击状态
|
||||||
|
ArchiveManager.set_global_entry(&"c02_boxcat_chasing_started", false)
|
||||||
SceneManager.get_ground_loader().transition_to_scene("c02_s12", "left")
|
SceneManager.get_ground_loader().transition_to_scene("c02_s12", "left")
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,12 +51,11 @@ func intro():
|
|||||||
|
|
||||||
|
|
||||||
func intro_finished():
|
func intro_finished():
|
||||||
SceneManager.disable_prop_item("prop_弹珠")
|
SceneManager.disable_prop_item_temp("prop_弹珠")
|
||||||
# 老虎钳 - 弹珠交换功能结束
|
# SceneManager.disable_prop_item("prop_弹珠")
|
||||||
EventManager.set_stage_if_greater(&"handnote_c02_hand_exchange", 2)
|
|
||||||
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
|
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
|
||||||
# 放入弹珠,开始游戏
|
# 放入弹珠,开始游戏
|
||||||
EventManager.set_stage(&"c02_ball_game_stage", 2)
|
# EventManager.set_stage(&"c02_ball_game_stage", 2)
|
||||||
var ball = pivot.get_child(0) as RigidBody2D
|
var ball = pivot.get_child(0) as RigidBody2D
|
||||||
ball.angular_velocity = 20
|
ball.angular_velocity = 20
|
||||||
animation_player.play("give_ball")
|
animation_player.play("give_ball")
|
||||||
@ -255,6 +254,8 @@ func game_win() -> void:
|
|||||||
animation_player.stop()
|
animation_player.stop()
|
||||||
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
|
# 0:默认 1:寻找弹珠(老虎钳可以换弹珠) 2:给出弹珠 3:游戏结束(小猫纸片) 4:游戏结束(小猫离开)
|
||||||
EventManager.set_stage(&"c02_ball_game_stage", 3)
|
EventManager.set_stage(&"c02_ball_game_stage", 3)
|
||||||
|
# 老虎钳 - 弹珠交换功能结束
|
||||||
|
EventManager.set_stage_if_greater(&"handnote_c02_hand_exchange", 2)
|
||||||
$"Sfx结尾小孩跑_耳鸣".global_play()
|
$"Sfx结尾小孩跑_耳鸣".global_play()
|
||||||
Util.shake_layer(self, 2.0)
|
Util.shake_layer(self, 2.0)
|
||||||
# 弹珠雨
|
# 弹珠雨
|
||||||
|
@ -33,17 +33,7 @@ const HUD_FADE_DURATION = 0.3
|
|||||||
|
|
||||||
@export_group("UI-UX")
|
@export_group("UI-UX")
|
||||||
@export var display_time := 2.5 # 不包含渐入渐出(约 0.6s)的时长
|
@export var display_time := 2.5 # 不包含渐入渐出(约 0.6s)的时长
|
||||||
@export var locked := false:
|
@export var locked := false
|
||||||
set(value):
|
|
||||||
locked = value
|
|
||||||
if value:
|
|
||||||
selected = false
|
|
||||||
@export var selected := true:
|
|
||||||
set(value):
|
|
||||||
if selected != value:
|
|
||||||
selected = value
|
|
||||||
_emit_changed()
|
|
||||||
|
|
||||||
@onready var sfx_click = %SfxClick as Sfx
|
@onready var sfx_click = %SfxClick as Sfx
|
||||||
@onready var sfx_inspect = %SfxInspect as Sfx
|
@onready var sfx_inspect = %SfxInspect as Sfx
|
||||||
@onready var sfx_new_prop = %SfxNewProp as Sfx
|
@onready var sfx_new_prop = %SfxNewProp as Sfx
|
||||||
@ -64,7 +54,7 @@ const HUD_FADE_DURATION = 0.3
|
|||||||
var prop_containers: Array[CenterContainer] = []
|
var prop_containers: Array[CenterContainer] = []
|
||||||
var items_dict := {}
|
var items_dict := {}
|
||||||
# 从配置文件加载 prop items
|
# 从配置文件加载 prop items
|
||||||
var item_config_res = preload("res://asset/dialogue/item_description.dialogue")
|
var item_config_res = preload("uid://b1vwhxctfhl5d") #item_description.dialogue
|
||||||
var path_prefix = "res://asset/art/prop/"
|
var path_prefix = "res://asset/art/prop/"
|
||||||
var cached_inventory_textures := {}
|
var cached_inventory_textures := {}
|
||||||
|
|
||||||
@ -87,9 +77,6 @@ var placeholder_texture: Texture2D
|
|||||||
|
|
||||||
|
|
||||||
func _emit_changed(prop_key := ""):
|
func _emit_changed(prop_key := ""):
|
||||||
if not selected:
|
|
||||||
current_item_changed.emit("")
|
|
||||||
else:
|
|
||||||
current_item_changed.emit(prop_key)
|
current_item_changed.emit(prop_key)
|
||||||
|
|
||||||
|
|
||||||
@ -97,8 +84,8 @@ func _ready() -> void:
|
|||||||
if Engine.is_editor_hint():
|
if Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
|
|
||||||
# 初始化占位符纹理
|
# 初始化占位符纹理 placeholder.png
|
||||||
placeholder_texture = preload("res://asset/art/ui/hud/placeholder.png")
|
placeholder_texture = preload("uid://djrfdhywg7uu2")
|
||||||
|
|
||||||
# read prop containers
|
# read prop containers
|
||||||
for id in range(props_bag.get_child_count()):
|
for id in range(props_bag.get_child_count()):
|
||||||
@ -110,18 +97,15 @@ func _ready() -> void:
|
|||||||
|
|
||||||
display_prop.gui_input.connect(_on_prop_gui_input.bind(-1))
|
display_prop.gui_input.connect(_on_prop_gui_input.bind(-1))
|
||||||
|
|
||||||
_load_items_config_to_dict("ImportantPropItems")
|
_reload_all()
|
||||||
_load_items_config_to_dict("PropItems")
|
# 存档更新时,从存档加载 prop
|
||||||
_reload_cache_and_realign_display()
|
ArchiveManager.archive_loaded.connect(_reload_all)
|
||||||
|
|
||||||
selecting_bg.modulate.a = 0.0
|
selecting_bg.modulate.a = 0.0
|
||||||
prop_scroll.scroll_horizontal = PROP_CONTAINER_X
|
prop_scroll.scroll_horizontal = PROP_CONTAINER_X
|
||||||
props_bag_scroll.scroll_horizontal = 0.0
|
props_bag_scroll.scroll_horizontal = 0.0
|
||||||
props_bag_scroll.custom_minimum_size.x = 0.0
|
props_bag_scroll.custom_minimum_size.x = 0.0
|
||||||
|
|
||||||
# 存档更新时,从存档加载 prop
|
|
||||||
ArchiveManager.archive_loaded.connect(_reload_cache_and_realign_display)
|
|
||||||
|
|
||||||
# tween timer
|
# tween timer
|
||||||
timer.wait_time = display_time
|
timer.wait_time = display_time
|
||||||
timer.one_shot = true
|
timer.one_shot = true
|
||||||
@ -139,6 +123,21 @@ func _ready() -> void:
|
|||||||
mouse_exited.connect(_on_mouse_exited)
|
mouse_exited.connect(_on_mouse_exited)
|
||||||
|
|
||||||
|
|
||||||
|
func _notification(what: int) -> void:
|
||||||
|
if what == NOTIFICATION_TRANSLATION_CHANGED and is_node_ready():
|
||||||
|
_reload_all()
|
||||||
|
|
||||||
|
|
||||||
|
func _reload_all() -> void:
|
||||||
|
inventory = ArchiveManager.archive.prop_inventory
|
||||||
|
if inventory:
|
||||||
|
# 刷新 inventory 的 virtual(回到 index 再进游戏时,inventory 的 virtual 应该刷新)
|
||||||
|
inventory.virtual_enabled_items(true, true)
|
||||||
|
_load_items_config_to_dict("ImportantPropItems")
|
||||||
|
_load_items_config_to_dict("PropItems")
|
||||||
|
_reload_cache_and_realign_display()
|
||||||
|
|
||||||
|
|
||||||
func _load_items_config_to_dict(title: String):
|
func _load_items_config_to_dict(title: String):
|
||||||
if not item_config_res or not item_config_res.titles.has(title):
|
if not item_config_res or not item_config_res.titles.has(title):
|
||||||
return
|
return
|
||||||
@ -224,22 +223,24 @@ func _load_texture_cache() -> void:
|
|||||||
if not inventory:
|
if not inventory:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var virtual_items = inventory.virtual_enabled_items()
|
||||||
# 移除无效纹理
|
# 移除无效纹理
|
||||||
var keys_to_remove = []
|
var keys_to_remove = []
|
||||||
for k in cached_inventory_textures:
|
for k in cached_inventory_textures:
|
||||||
if not k in inventory.enabled_items:
|
if not k in virtual_items:
|
||||||
keys_to_remove.append(k)
|
keys_to_remove.append(k)
|
||||||
|
|
||||||
for k in keys_to_remove:
|
for k in keys_to_remove:
|
||||||
cached_inventory_textures.erase(k)
|
cached_inventory_textures.erase(k)
|
||||||
|
|
||||||
# 加载新纹理
|
# 加载新纹理
|
||||||
for key in inventory.enabled_items:
|
for key in virtual_items:
|
||||||
if cached_inventory_textures.has(key):
|
if cached_inventory_textures.has(key):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not items_dict.has(key):
|
if not items_dict.has(key):
|
||||||
inventory.disable_item(key)
|
inventory.disable_item_tmp(key)
|
||||||
|
virtual_items = inventory.virtual_enabled_items()
|
||||||
printerr(
|
printerr(
|
||||||
"PropHud _load_texture_cache: key not found in items_dict:", key, ". remove item."
|
"PropHud _load_texture_cache: key not found in items_dict:", key, ". remove item."
|
||||||
)
|
)
|
||||||
@ -257,18 +258,15 @@ func _load_texture_cache() -> void:
|
|||||||
print("Cache load prop texture key=", key)
|
print("Cache load prop texture key=", key)
|
||||||
cached_inventory_textures[key] = texture
|
cached_inventory_textures[key] = texture
|
||||||
|
|
||||||
# wrap index
|
|
||||||
if inventory.enabled_items.size() > 0:
|
|
||||||
inventory.current_index = wrapi(inventory.current_index, 0, inventory.enabled_items.size())
|
|
||||||
|
|
||||||
|
|
||||||
func _update_prop_display_with_texture():
|
func _update_prop_display_with_texture():
|
||||||
if not inventory:
|
if not inventory:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var virtual_items = inventory.virtual_enabled_items()
|
||||||
var key = ""
|
var key = ""
|
||||||
# 在没有道具时,展示空手 placeholder
|
# 在没有道具时,展示空手 placeholder
|
||||||
if inventory.enabled_items.is_empty():
|
if virtual_items.is_empty():
|
||||||
display_prop.texture_normal = placeholder_texture
|
display_prop.texture_normal = placeholder_texture
|
||||||
display_prop.size = Vector2(PROP_CONTROL_X, PROP_CONTROL_X)
|
display_prop.size = Vector2(PROP_CONTROL_X, PROP_CONTROL_X)
|
||||||
display_prop.scale = Vector2(1.0, 1.0)
|
display_prop.scale = Vector2(1.0, 1.0)
|
||||||
@ -290,9 +288,9 @@ func _update_prop_display_with_texture():
|
|||||||
_update_select_mark()
|
_update_select_mark()
|
||||||
|
|
||||||
# bag更新
|
# bag更新
|
||||||
for i in range(inventory.enabled_items.size()):
|
for i in range(virtual_items.size()):
|
||||||
var id = wrapi(i, 0, inventory.enabled_items.size())
|
var id = wrapi(i, 0, virtual_items.size())
|
||||||
var k = inventory.enabled_items[id]
|
var k = virtual_items[id]
|
||||||
var container = prop_containers[i]
|
var container = prop_containers[i]
|
||||||
var button = container.get_child(0).get_child(0) as TextureButton
|
var button = container.get_child(0).get_child(0) as TextureButton
|
||||||
_display_texture_by_key(button, k)
|
_display_texture_by_key(button, k)
|
||||||
@ -306,7 +304,8 @@ func _update_select_mark():
|
|||||||
if not is_instance_valid(select_mark):
|
if not is_instance_valid(select_mark):
|
||||||
select_mark = TextureRect.new()
|
select_mark = TextureRect.new()
|
||||||
select_mark.custom_minimum_size = Vector2(PROP_CONTAINER_X, PROP_CONTAINER_X)
|
select_mark.custom_minimum_size = Vector2(PROP_CONTAINER_X, PROP_CONTAINER_X)
|
||||||
select_mark.texture = preload("res://asset/art/ui/hud/select_mark.png")
|
# res://asset/art/ui/hud/select_mark.png
|
||||||
|
select_mark.texture = preload("uid://c0gjes4a8ou3b")
|
||||||
else:
|
else:
|
||||||
var parent = select_mark.get_parent()
|
var parent = select_mark.get_parent()
|
||||||
if parent:
|
if parent:
|
||||||
@ -342,8 +341,7 @@ func on_left_pressed() -> void:
|
|||||||
if locked:
|
if locked:
|
||||||
return
|
return
|
||||||
sfx_click.play()
|
sfx_click.play()
|
||||||
if inventory.index_wrap_add(-1):
|
inventory.index_wrap_add(-1)
|
||||||
selected = true
|
|
||||||
_update_prop_display_with_texture()
|
_update_prop_display_with_texture()
|
||||||
_tween_container(true)
|
_tween_container(true)
|
||||||
_mouse_moved_on_listening()
|
_mouse_moved_on_listening()
|
||||||
@ -353,8 +351,7 @@ func on_right_pressed() -> void:
|
|||||||
if locked:
|
if locked:
|
||||||
return
|
return
|
||||||
sfx_click.play()
|
sfx_click.play()
|
||||||
if inventory.index_wrap_add(1):
|
inventory.index_wrap_add(1)
|
||||||
selected = true
|
|
||||||
_update_prop_display_with_texture()
|
_update_prop_display_with_texture()
|
||||||
_tween_container(false)
|
_tween_container(false)
|
||||||
_mouse_moved_on_listening()
|
_mouse_moved_on_listening()
|
||||||
@ -387,10 +384,10 @@ func _on_prop_gui_input(event: InputEvent, id: int) -> void:
|
|||||||
func _on_prop_inspected(id := 0) -> void:
|
func _on_prop_inspected(id := 0) -> void:
|
||||||
if locked:
|
if locked:
|
||||||
return
|
return
|
||||||
|
var virtual_items = inventory.virtual_enabled_items()
|
||||||
var prop_key = ""
|
var prop_key = ""
|
||||||
if id >= 0 and id < inventory.enabled_items.size():
|
if id >= 0 and id < virtual_items.size():
|
||||||
prop_key = inventory.enabled_items[id]
|
prop_key = virtual_items[id]
|
||||||
else:
|
else:
|
||||||
prop_key = inventory.current_item_key()
|
prop_key = inventory.current_item_key()
|
||||||
|
|
||||||
@ -410,9 +407,9 @@ func _on_prop_pressed(id := 0) -> void:
|
|||||||
|
|
||||||
focus_mode = FOCUS_ALL
|
focus_mode = FOCUS_ALL
|
||||||
grab_focus()
|
grab_focus()
|
||||||
selected = true
|
|
||||||
|
|
||||||
if id >= 0 and id < inventory.enabled_items.size():
|
var virtual_items = inventory.virtual_enabled_items()
|
||||||
|
if id >= 0 and id < virtual_items.size():
|
||||||
inventory.current_index = id
|
inventory.current_index = id
|
||||||
|
|
||||||
_update_prop_display_with_texture()
|
_update_prop_display_with_texture()
|
||||||
@ -476,11 +473,9 @@ func _on_mouse_exited() -> void:
|
|||||||
func _mouse_moved_on_listening(unfold_scroll := false) -> void:
|
func _mouse_moved_on_listening(unfold_scroll := false) -> void:
|
||||||
if unfold_scroll:
|
if unfold_scroll:
|
||||||
_toggle_scroll(false)
|
_toggle_scroll(false)
|
||||||
|
|
||||||
if not displaying:
|
if not displaying:
|
||||||
_toggle_details(true)
|
_toggle_details(true)
|
||||||
return
|
return
|
||||||
|
|
||||||
timer.start(display_time)
|
timer.start(display_time)
|
||||||
|
|
||||||
|
|
||||||
@ -492,7 +487,6 @@ func _on_timer_timeout() -> void:
|
|||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if locked or not listening_hotkey:
|
if locked or not listening_hotkey:
|
||||||
return
|
return
|
||||||
|
|
||||||
if event.is_action_pressed("prop_left"):
|
if event.is_action_pressed("prop_left"):
|
||||||
on_left_pressed()
|
on_left_pressed()
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
@ -514,7 +508,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if locked:
|
if locked:
|
||||||
return
|
return
|
||||||
|
|
||||||
if listen_mouse and (event is InputEventMouseMotion or event is InputEventScreenTouch):
|
if listen_mouse and (event is InputEventMouseMotion or event is InputEventScreenTouch):
|
||||||
_mouse_moved_on_listening()
|
_mouse_moved_on_listening()
|
||||||
|
|
||||||
@ -580,10 +573,9 @@ func enable_prop_item(prop_key: String, inspect := true) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func inspect_item(prop_key: String, display_obtained := true, as_important_item := false):
|
func inspect_item(prop_key: String, display_obtained := true, as_important_item := false):
|
||||||
var inspector = SceneManager.get_inspector()
|
var inspector = SceneManager.get_inspector() as PropInspector
|
||||||
if not inspector or not items_dict.has(prop_key):
|
if not inspector or not items_dict.has(prop_key):
|
||||||
return
|
return
|
||||||
|
|
||||||
var item = items_dict[prop_key]
|
var item = items_dict[prop_key]
|
||||||
var texture: Texture2D = null
|
var texture: Texture2D = null
|
||||||
|
|
||||||
@ -596,20 +588,15 @@ func inspect_item(prop_key: String, display_obtained := true, as_important_item
|
|||||||
texture = load(item.texture_path) as Texture2D
|
texture = load(item.texture_path) as Texture2D
|
||||||
if texture:
|
if texture:
|
||||||
cached_inventory_textures[prop_key] = texture
|
cached_inventory_textures[prop_key] = texture
|
||||||
|
|
||||||
if not texture:
|
if not texture:
|
||||||
printerr("prophud inspect_item invalid texture for key:", prop_key)
|
printerr("prophud inspect_item invalid texture for key:", prop_key)
|
||||||
return
|
return
|
||||||
if as_important_item:
|
if as_important_item:
|
||||||
var content = get_item_description(prop_key)
|
var content = get_item_description(prop_key)
|
||||||
var wide = len(content) > 150
|
var wide = len(content) > 150
|
||||||
inspector.pop_standard_inspection(
|
inspector.pop_standard_inspection(texture, null, content, false, wide)
|
||||||
texture, null, content, false, wide
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
inspector.pop_prop_inspection(
|
inspector.pop_prop_inspection(prop_key, texture, display_obtained)
|
||||||
prop_key, texture, display_obtained
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
func disable_prop_item(prop_key: String) -> void:
|
func disable_prop_item(prop_key: String) -> void:
|
||||||
@ -619,16 +606,25 @@ func disable_prop_item(prop_key: String) -> void:
|
|||||||
_reload_cache_and_realign_display()
|
_reload_cache_and_realign_display()
|
||||||
|
|
||||||
|
|
||||||
|
# 临时禁用 prop, 延迟写入(真正 disable_prop_item 的时候写入)
|
||||||
|
func disable_prop_item_temp(prop_key: String) -> void:
|
||||||
|
if not inventory or not prop_key:
|
||||||
|
return
|
||||||
|
inventory.disable_item_temp(prop_key)
|
||||||
|
_reload_cache_and_realign_display()
|
||||||
|
|
||||||
|
|
||||||
func _align_container_size() -> void:
|
func _align_container_size() -> void:
|
||||||
if not inventory:
|
if not inventory:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
var virtual_items = inventory.virtual_enabled_items()
|
||||||
# 添加新容器
|
# 添加新容器
|
||||||
while inventory.enabled_items.size() > prop_containers.size():
|
while virtual_items.size() > prop_containers.size():
|
||||||
append_prop_container()
|
append_prop_container()
|
||||||
|
|
||||||
# 删除多余容器
|
# 删除多余容器
|
||||||
while inventory.enabled_items.size() < prop_containers.size():
|
while virtual_items.size() < prop_containers.size():
|
||||||
remove_prop_container()
|
remove_prop_container()
|
||||||
|
|
||||||
if displaying:
|
if displaying:
|
||||||
|
@ -120,6 +120,7 @@ func pop_standard_inspection(
|
|||||||
content_label.text = inspection_note.replace("{br}", "\n").strip_edges()
|
content_label.text = inspection_note.replace("{br}", "\n").strip_edges()
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(full_texture, "modulate:a", 1.0, 0.15)
|
tween.tween_property(full_texture, "modulate:a", 1.0, 0.15)
|
||||||
|
tween.parallel().tween_property(prop_bg, "modulate:a", 1.0, 0.15)
|
||||||
tip_label.text = tip_cover
|
tip_label.text = tip_cover
|
||||||
_blink_label()
|
_blink_label()
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ signal current_item_changed(prop_key: String)
|
|||||||
@export var current_index := 0:
|
@export var current_index := 0:
|
||||||
set(val):
|
set(val):
|
||||||
if current_index != val:
|
if current_index != val:
|
||||||
val = wrapi(val, 0, enabled_items.size())
|
# virtual id
|
||||||
|
val = wrapi(val, 0, virtual_items.size())
|
||||||
current_index = val
|
current_index = val
|
||||||
if enabled_items.size() > 0:
|
if virtual_items.size() > 0:
|
||||||
current_item_changed.emit(enabled_items[current_index])
|
current_item_changed.emit(virtual_items[current_index])
|
||||||
else:
|
else:
|
||||||
current_item_changed.emit("")
|
current_item_changed.emit("")
|
||||||
# 重要物品,不可丢弃,在背包可见
|
# 重要物品,不可丢弃,在背包可见
|
||||||
@ -22,8 +23,11 @@ signal current_item_changed(prop_key: String)
|
|||||||
@export var xdie_enabled_items := [] as Array[String]
|
@export var xdie_enabled_items := [] as Array[String]
|
||||||
@export var xxdie_enabled_items := [] as Array[String]
|
@export var xxdie_enabled_items := [] as Array[String]
|
||||||
@export var xxxdie_enabled_items := [] as Array[String]
|
@export var xxxdie_enabled_items := [] as Array[String]
|
||||||
var enabled_items := [] as Array[String]
|
var enabled_items: Array[String]
|
||||||
|
var virtual_items: Array[String]
|
||||||
|
|
||||||
|
# virtual
|
||||||
|
var disabled_tmp_props := [] as Array[String]
|
||||||
|
|
||||||
func checkout(character: String):
|
func checkout(character: String):
|
||||||
# @export_enum("吕萍", "吕萍爬行", "吕萍带小猫", "吕萍推柜子", "小小蝶", "盒子猫", "小小小蝶") var character := "吕萍":
|
# @export_enum("吕萍", "吕萍爬行", "吕萍带小猫", "吕萍推柜子", "小小蝶", "盒子猫", "小小小蝶") var character := "吕萍":
|
||||||
@ -35,6 +39,7 @@ func checkout(character: String):
|
|||||||
enabled_items = xdie_enabled_items
|
enabled_items = xdie_enabled_items
|
||||||
else:
|
else:
|
||||||
enabled_items = default_enabled_items
|
enabled_items = default_enabled_items
|
||||||
|
virtual_items = virtual_enabled_items(true)
|
||||||
|
|
||||||
|
|
||||||
func enable_important_item(prop_key: String) -> void:
|
func enable_important_item(prop_key: String) -> void:
|
||||||
@ -44,34 +49,56 @@ func enable_important_item(prop_key: String) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func has_prop(prop_key: String) -> bool:
|
func has_prop(prop_key: String) -> bool:
|
||||||
return enabled_items.has(prop_key)
|
if not virtual_items.has(prop_key):
|
||||||
|
return false
|
||||||
|
return not disabled_tmp_props.has(prop_key)
|
||||||
|
|
||||||
|
|
||||||
|
# return current virtual item key
|
||||||
func current_item_key() -> String:
|
func current_item_key() -> String:
|
||||||
if enabled_items.size() == 0:
|
if virtual_items.is_empty():
|
||||||
return ""
|
return ""
|
||||||
return enabled_items[current_index]
|
current_index = wrapi(current_index, 0, virtual_items.size())
|
||||||
|
return virtual_items[current_index]
|
||||||
|
|
||||||
|
|
||||||
func enable_item(prop_key: String, inspect := true) -> void:
|
func enable_item(prop_key: String, inspect := true) -> void:
|
||||||
# 重复 enable 无负面影响
|
# 重复 enable 无负面影响
|
||||||
if not enabled_items.has(prop_key):
|
if not enabled_items.has(prop_key):
|
||||||
enabled_items.append(prop_key)
|
enabled_items.append(prop_key)
|
||||||
|
|
||||||
# 如果 inspect, 则直接选中为当前条目
|
# 如果 inspect, 则直接选中为当前条目
|
||||||
if inspect:
|
if inspect:
|
||||||
current_index = enabled_items.find(prop_key)
|
current_index = virtual_items.find(prop_key)
|
||||||
|
# 消除临时禁用
|
||||||
|
disabled_tmp_props.erase(prop_key)
|
||||||
|
virtual_items = virtual_enabled_items(true)
|
||||||
|
|
||||||
|
|
||||||
func disable_item(prop_key: String) -> void:
|
func disable_item(prop_key: String) -> void:
|
||||||
|
disabled_tmp_props.erase(prop_key)
|
||||||
|
virtual_items = virtual_enabled_items(true)
|
||||||
# if enabled_items.has(prop_key):
|
# if enabled_items.has(prop_key):
|
||||||
enabled_items.erase(prop_key)
|
enabled_items.erase(prop_key)
|
||||||
# wrap index
|
# wrap index
|
||||||
current_index = clampi(current_index, 0, enabled_items.size())
|
current_index = clampi(current_index, 0, virtual_items.size())
|
||||||
|
|
||||||
|
|
||||||
|
func disable_item_temp(prop_key: String) -> void:
|
||||||
|
disabled_tmp_props.append(prop_key)
|
||||||
|
virtual_items = virtual_enabled_items(true)
|
||||||
|
|
||||||
|
|
||||||
# return true if the index changed
|
# return true if the index changed
|
||||||
func index_wrap_add(delta: int) -> bool:
|
func index_wrap_add(delta: int) -> void:
|
||||||
# auto wrapped in setter
|
# auto wrapped in setter
|
||||||
current_index += delta
|
current_index = wrapi(current_index + delta, 0, virtual_items.size())
|
||||||
return not enabled_items.is_empty()
|
|
||||||
|
|
||||||
|
func virtual_enabled_items(refresh := false, clear_tmps := false) -> Array[String]:
|
||||||
|
if clear_tmps:
|
||||||
|
disabled_tmp_props.clear()
|
||||||
|
if refresh:
|
||||||
|
virtual_items = enabled_items.duplicate()
|
||||||
|
for k in disabled_tmp_props:
|
||||||
|
virtual_items.erase(k)
|
||||||
|
return virtual_items
|
||||||
|
Loading…
Reference in New Issue
Block a user