2025-10-07 18:27:59 +08:00

30 lines
1.1 KiB
Lua

local TaskCell = class("TaskCell", BaseCell)
local ICON_BG = {"daily_challenge_bg_6", "daily_challenge_bg_5"}
-- local ICON = {"daily_task_1", "daily_task_2"}
function TaskCell:refresh(idx, taskInfo, customProgress)
local complete = taskInfo.claimed
customProgress = customProgress or 0
local uiMap = self:getUIMap()
local diffChapter = DataManager.DailyChallengeData:getDiffLv()
local cfg = DataManager.DailyChallengeData:getDifficultyCfg(diffChapter)
local rewards = cfg.task_daily_reward[idx] or {}
local icon = complete and ICON_BG[2] or ICON_BG[1]
uiMap["task_cell.bg"]:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, icon)
-- icon = complete and ICON[2] or ICON[1]
-- uiMap["task_cell.task_icon"]:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, icon)
uiMap["task_cell.desc"]:setText(DataManager.DailyChallengeData:getTaskDesc(taskInfo.task_id, true, customProgress))
for i = 1, 3 do
local cell = uiMap["task_cell.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
if rewards then
cell:setActive(true)
cell:refreshByConfig(rewards[i], complete, complete)
else
cell:setActive(false)
end
end
end
return TaskCell