添加小游戏面板

This commit is contained in:
2025-08-28 10:23:13 +08:00
parent 633c1cac44
commit ca5685df52
24 changed files with 4569 additions and 1250 deletions

View File

@@ -389,10 +389,23 @@ func _apply_filter_and_sort():
# 自定义排序函数
func _sort_crop_items(a, b):
# 安全地获取排序值,并进行类型转换
var value_a = a["data"].get(current_sort_key, 0)
var value_b = b["data"].get(current_sort_key, 0)
# 如果是数值类型的字段,确保转换为数值进行比较
if current_sort_key in ["花费", "生长时间", "收益", "等级", "经验", "耐候性"]:
# 转换为数值如果转换失败则使用0
if typeof(value_a) == TYPE_STRING:
value_a = int(value_a) if value_a.is_valid_int() else 0
if typeof(value_b) == TYPE_STRING:
value_b = int(value_b) if value_b.is_valid_int() else 0
# 执行排序比较
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
return value_a < value_b
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
return value_a > value_b
# 更新金钱显示
func _update_money_display():