Added drag and drop to backpack for quick storage.
添加拖拽到背包快速存储的功能。
This commit is contained in:
parent
221628346e
commit
4aff26d7bc
|
@ -53,3 +53,10 @@ log_patrol_to_next_point,下一个点{0},当前位置{1},偏移量{2},距
|
||||||
log_patrol_arrival_point,到达巡逻点{0}。,Arrival at patrol point {0}.,巡回ポイント{0}に到着します。
|
log_patrol_arrival_point,到达巡逻点{0}。,Arrival at patrol point {0}.,巡回ポイント{0}に到着します。
|
||||||
log_patrol_origin_position,巡逻路径的起始位置是{0}。,The starting position of the patrol path is {0}.,巡回路の開始位置は{0}です。
|
log_patrol_origin_position,巡逻路径的起始位置是{0}。,The starting position of the patrol path is {0}.,巡回路の開始位置は{0}です。
|
||||||
log_patrol_not_on_floor,不能将初始路径设置在空中。,The initial path cannot be set in the air.,初期パスを空中に設定できません。
|
log_patrol_not_on_floor,不能将初始路径设置在空中。,The initial path cannot be set in the air.,初期パスを空中に設定できません。
|
||||||
|
log_item_container_is_null,物品容器为空。,Item container is null.,アイテム・コンテナが空です。
|
||||||
|
log_can_add_item,可以添加物品{0}。,Can add item {0}.,アイテム{0}を追加できます。
|
||||||
|
log_backpack_not_allowed,不允许添加到背包。,Not allowed to add to backpack.,バックパックに追加することは許可されていません。
|
||||||
|
log_item_is_null,物品为空。,Item is null.,アイテムが空です。
|
||||||
|
log_item_id_not_same,物品ID不同。,Item ID is different.,アイテムIDが異なります。
|
||||||
|
log_max_quantity_exceeded,超过最大数量。,Exceeded maximum quantity.,最大数量を超えました。
|
||||||
|
log_item_slot_is_selected_and_not_allowed,已选择物品槽,不允许添加。,"Item slot is selected, not allowed to add.",アイテムスロットが選択されており、追加は許可されていません。
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using ColdMint.scripts.debug;
|
||||||
using ColdMint.scripts.utils;
|
using ColdMint.scripts.utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
|
@ -62,6 +63,14 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
|
|
||||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||||
{
|
{
|
||||||
|
if (_isSelect)
|
||||||
|
{
|
||||||
|
//Do not place items in the selected item slot, even if the item slot is empty.
|
||||||
|
//禁止在已选中的物品槽内放置物品,即使物品槽是空的。
|
||||||
|
LogCat.Log("item_slot_is_selected_and_not_allowed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//If the preplaced slot does not have an icon, the preplaced slot is not allowed.
|
//If the preplaced slot does not have an icon, the preplaced slot is not allowed.
|
||||||
//如果预放置的槽位没有图标,那么不允许放置。
|
//如果预放置的槽位没有图标,那么不允许放置。
|
||||||
if (_iconTextureRect == null)
|
if (_iconTextureRect == null)
|
||||||
|
@ -86,6 +95,35 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item is Packsack packsack)
|
||||||
|
{
|
||||||
|
if (_item == null)
|
||||||
|
{
|
||||||
|
//If the dragged item is a backpack and there are no items in the current slot, return whether the backpack is allowed.
|
||||||
|
//如果拖拽的物品是背包,且当前槽位没有物品,那么返回是否允许放置背包。
|
||||||
|
return BackpackAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packsack.ItemContainer == null)
|
||||||
|
{
|
||||||
|
LogCat.Log("item_container_is_null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return packsack.ItemContainer.CanAddItem(_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_item is Packsack currentPacksack)
|
||||||
|
{
|
||||||
|
if (currentPacksack.ItemContainer == null)
|
||||||
|
{
|
||||||
|
LogCat.Log("item_container_is_null");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentPacksack.ItemContainer.CanAddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
return CanAddItem(item);
|
return CanAddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,16 +232,40 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemSlotNode = data.As<ItemSlotNode>();
|
var itemSlotNode = data.As<ItemSlotNode>();
|
||||||
var item = itemSlotNode.GetItem();
|
var sourceItem = itemSlotNode.GetItem();
|
||||||
if (item == null)
|
if (sourceItem == null)
|
||||||
{
|
{
|
||||||
//Return null when trying to get the source item.
|
//Return null when trying to get the source item.
|
||||||
//尝试获取源物品时返回null。
|
//尝试获取源物品时返回null。
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sourceItem is Packsack packsack)
|
||||||
|
{
|
||||||
|
//If the source item is a backpack.
|
||||||
|
//如果源物品是背包。
|
||||||
|
if (packsack.ItemContainer != null && _item != null)
|
||||||
|
{
|
||||||
|
packsack.ItemContainer.AddItem(_item);
|
||||||
|
ClearItem(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_item is Packsack customPacksack)
|
||||||
|
{
|
||||||
|
if (customPacksack.ItemContainer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
customPacksack.ItemContainer.AddItem(sourceItem);
|
||||||
|
itemSlotNode.ClearItem(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddItem(sourceItem);
|
||||||
itemSlotNode.ClearItem(false);
|
itemSlotNode.ClearItem(false);
|
||||||
AddItem(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -337,6 +399,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
if (!BackpackAllowed && item is Packsack)
|
if (!BackpackAllowed && item is Packsack)
|
||||||
{
|
{
|
||||||
//如果禁止放置背包,且新物品是背包
|
//如果禁止放置背包,且新物品是背包
|
||||||
|
LogCat.Log("backpack_not_allowed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,6 +407,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
{
|
{
|
||||||
//If there is no item in the current item slot, it is allowed to add.
|
//If there is no item in the current item slot, it is allowed to add.
|
||||||
//如果当前物品槽内没物品,那么允许添加。
|
//如果当前物品槽内没物品,那么允许添加。
|
||||||
|
LogCat.Log("item_is_null");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +415,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
{
|
{
|
||||||
//If the item ID you want to add is different from the current item ID, disable.
|
//If the item ID you want to add is different from the current item ID, disable.
|
||||||
//如果要添加的物品ID和当前的物品ID不一样,那么禁止。
|
//如果要添加的物品ID和当前的物品ID不一样,那么禁止。
|
||||||
|
LogCat.Log("item_id_not_same");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +424,7 @@ public partial class ItemSlotNode : MarginContainer
|
||||||
{
|
{
|
||||||
//The maximum number is exceeded and items cannot be added.
|
//The maximum number is exceeded and items cannot be added.
|
||||||
//超过了最大数量,无法添加物品。
|
//超过了最大数量,无法添加物品。
|
||||||
|
LogCat.Log("max_quantity_exceeded");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
||||||
//在发行版禁用所有日志。
|
//在发行版禁用所有日志。
|
||||||
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogCat.DisableLogLabel(LogCat.LogLabel.PatrolStateProcessor);
|
||||||
ContributorDataManager.RegisterAllContributorData();
|
ContributorDataManager.RegisterAllContributorData();
|
||||||
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user