为消耗品图标增加显示数量

This commit is contained in:
Lenheart 2025-01-20 18:02:26 +08:00
parent da0e76a02c
commit dc1214f83c
3 changed files with 27 additions and 5 deletions

View File

@ -7,7 +7,7 @@
//消耗品图标窗口
class GameItem.StackableIcon extends CL_CanvasObject {
constructor(Stackable) {
constructor(Stackable, RenderCount = true) {
base.constructor();
ResizeAndClear(32, 32);
BeginDraw();
@ -20,6 +20,12 @@ class GameItem.StackableIcon extends CL_CanvasObject {
//边框
local IconFrame = CL_SpriteFrameObject("sprite/item/iconmark.img", 62 + GameItem.EquipmentInfoTag.rarityframe_color_idx[Stackable.Rarity]);
DrawSpriteFrame(IconFrame, 0, 0);
//数量
if (RenderCount && Stackable.Count > 0) {
local CountText = Yosin_Mininumber(Stackable.Count);
DrawActor(CountText, 28 - CountText.GetSize().w, 0);
}
}
EndDraw();
}
@ -54,7 +60,7 @@ class GameItem.StackableInfo extends Yosin_Window {
//构造图标 及图标边框
if (Stackable.Icon) {
local Icon = GameItem.StackableIcon(Stackable);
local Icon = GameItem.StackableIcon(Stackable, false);
Canvas.DrawActor(Icon, 7, 7);
}
@ -144,6 +150,8 @@ class GameItem.Stackable extends GameItem.Item {
Idx = -1;
//物品名称
Name = "";
//数量
Count = 0;
//物品类型
Type = null;
@ -187,10 +195,16 @@ class GameItem.Stackable extends GameItem.Item {
local StkInfo;
//通过ID构造
if (typeof vargv[0] == "integer") {
StkInfo = AssetManager.GetStackable(vargv[0]);
Idx = vargv[0];
ConstructStackableFromScript(StkInfo);
ConstructStackableFromScript(AssetManager.GetStackable(Idx));
}
//通过脚本信息构造
else if (typeof vargv[0] == "table") {
Idx = vargv[0].ItemId;
ConstructStackableFromScript(AssetManager.GetStackable(Idx));
IterateStackableBasedOnActualStackableInformation(vargv[0]);
}
}
}
@ -228,6 +242,12 @@ class GameItem.Stackable extends GameItem.Item {
if (StkInfo.rawin("trade_type")) TradeType = StkInfo["trade_type"];
}
}
//根据实际的消耗品信息迭代消耗品
function IterateStackableBasedOnActualStackableInformation(Info) {
Count = Info.ItemCount;
TradeType = Info.ItemTradeType;
}
}

View File

@ -152,7 +152,7 @@ function RegisterFunctionalPack() {
//道具数量
ItemCount = Pack.Get_Int(),
}
ItemList[ItemInfo.Pos] <- GameItem.Stackable(ItemInfo.ItemId);
ItemList[ItemInfo.Pos] <- GameItem.Stackable(ItemInfo);
ClientCharacterInventory.PageList[0].SetItemCollectionList(InventoryType - 2, ItemList);

View File

@ -12,11 +12,13 @@ function TestStage() {
local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
// local BackGround = CL_SpriteObject("sprite/loding.img", 0);
// T.Addchild(BackGround);
// local Stk = GameItem.Stackable(3037);
// Stk.Count = 10;
// local Window = Stk.GetInfoWindow();
// Window.SetPosition(300, 80);
// Window.ResetFocus();