KLUICostMatItem.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ---@class KLUICostMatItem:UIKmlLuaPanelBase
  2. ---@field view KLUICostMatItemView
  3. local KLUICostMatItem = class(UIKmlLuaPanelBase)
  4. local this =KLUICostMatItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. ---@param id number @物品id
  10. ---@param needCount number @需求数量
  11. function this:Refresh(id,needCount)
  12. if id then
  13. ---@type cfg_item_column
  14. local cfgData = SL:GetConfig("cfg_item",id)
  15. local bagCount = SL:GetBagItemCount(id)
  16. GUI:Text_setString(self.view.TextName,cfgData.name)
  17. if needCount then
  18. local countTextColor = bagCount >= needCount and "#1add1f" or "#ff2323"
  19. GUI:Text_setString(self.view.TextCount,"<color="..countTextColor..">"..bagCount.."</color>/"..needCount)
  20. else
  21. GUI:Text_setString(self.view.TextCount,bagCount)
  22. end
  23. local data = {
  24. width = "30",
  25. height = "30",
  26. itemid = id,
  27. z = -3001,
  28. mfixsize = "80,80",
  29. bgtype = "0",
  30. itemcount = nil,
  31. }
  32. if self.item then
  33. GUI:Item_UpdataData(self.item, data)
  34. else
  35. self.item = GUI:Item_Create(self.view.Model, data)
  36. end
  37. end
  38. end
  39. ---注册UI事件和服务器消息
  40. function this:RegistEvents()
  41. end
  42. function this:Close()
  43. end
  44. return this