93 lines
3.1 KiB
Lua
93 lines
3.1 KiB
Lua
local ItemGetUI = class("ItemGetUI", BaseUI)
|
|
|
|
function ItemGetUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function ItemGetUI:getPrefabPath()
|
|
return "assets/prefabs/ui/dungeon/item_get_ui.prefab"
|
|
end
|
|
|
|
function ItemGetUI:onPressBackspace()
|
|
self:closeUI()
|
|
end
|
|
|
|
function ItemGetUI:onClose()
|
|
end
|
|
|
|
function ItemGetUI:ctor(parmas)
|
|
self.target = parmas
|
|
end
|
|
|
|
function ItemGetUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
|
|
self.txTitle = uiMap["item_get_ui.content.title.tx_title"]
|
|
self.btnClose = uiMap["item_get_ui.content.btn_close"]
|
|
self.rewardCell = uiMap["item_get_ui.content.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
self.txDesc = uiMap["item_get_ui.content.tx_desc"]
|
|
self.txGet = uiMap["item_get_ui.content.tx_get"]
|
|
self.scrollRectComp = uiMap["item_get_ui.content.scroll_view"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
|
|
self.txTitle:setText(I18N:getText("item", self.target.id, "name"))
|
|
self.txDesc:setText(I18N:getText("item", self.target.id, "desc"))
|
|
self.txGet:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_23))
|
|
-- self.rewardCell:refreshItemById(self.target.id)
|
|
|
|
local itemCfg = ConfigManager:getConfig("item")[self.target.id]
|
|
if itemCfg == nil or itemCfg.get_way_type == nil or itemCfg.get_way == nil or #itemCfg.get_way == 0 then
|
|
self:closeUI()
|
|
return
|
|
end
|
|
|
|
self.wayType = itemCfg.get_way_type
|
|
self.wayList = {}
|
|
|
|
if self.wayType == GConst.DungeonConst.TYPE.WEAPON then
|
|
local weaponData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_WEAPON)
|
|
local unlock = {}
|
|
local lock = {}
|
|
for index, id in ipairs(itemCfg.get_way) do
|
|
if weaponData:canFightChapter(id) then
|
|
table.insert(unlock, id)
|
|
else
|
|
table.insert(lock, id)
|
|
end
|
|
end
|
|
table.sort(unlock, function(a, b) return a > b end)
|
|
table.sort(lock, function(a, b) return a > b end)
|
|
self.wayList = table.addArray(unlock, lock)
|
|
elseif self.wayType == GConst.DungeonConst.TYPE.ARMOR then
|
|
local weaponData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_ARMOR)
|
|
local unlock = {}
|
|
local lock = {}
|
|
for index, id in ipairs(itemCfg.get_way) do
|
|
if weaponData:canFightChapter(id) then
|
|
table.insert(unlock, id)
|
|
else
|
|
table.insert(lock, id)
|
|
end
|
|
end
|
|
table.sort(unlock, function(a, b) return a > b end)
|
|
table.sort(lock, function(a, b) return a > b end)
|
|
self.wayList = table.addArray(unlock, lock)
|
|
end
|
|
|
|
self.scrollRectComp:addInitCallback(function()
|
|
return "app/ui/dungeon/cell/dungeon_target_cell"
|
|
end)
|
|
self.scrollRectComp:addRefreshCallback(function(index, cell)
|
|
cell:refresh(self.target, self.wayType, self.wayList[index])
|
|
end)
|
|
|
|
self.btnClose:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
end
|
|
|
|
function ItemGetUI:onRefresh()
|
|
self.scrollRectComp:clearCells()
|
|
self.scrollRectComp:refillCells(#self.wayList)
|
|
end
|
|
|
|
return ItemGetUI |