Merge branch 'dev' of http://git.juzugame.com/b6-client/b6-lua into dev
This commit is contained in:
commit
2cf52fee2d
@ -24,7 +24,6 @@ function BountyMainUI:ctor()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BountyMainUI:onClose()
|
function BountyMainUI:onClose()
|
||||||
self:clearAdaptScrollrect()
|
|
||||||
if self.autoRotateTween then
|
if self.autoRotateTween then
|
||||||
self.autoRotateTween:Kill()
|
self.autoRotateTween:Kill()
|
||||||
end
|
end
|
||||||
@ -122,6 +121,10 @@ function BountyMainUI:initRewards()
|
|||||||
ModuleManager.BountyManager:buyBountyLevel()
|
ModuleManager.BountyManager:buyBountyLevel()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
self.progressBg = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.progress_bg"]
|
||||||
|
self.progressComp = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.progress_bg.progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
self.rewardsMaskBg = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.mask_img"]
|
||||||
|
|
||||||
self.scrollrect = self.uiMap["bounty_main_ui.mid_node.scrollrect"]
|
self.scrollrect = self.uiMap["bounty_main_ui.mid_node.scrollrect"]
|
||||||
self.scrollrectViewport = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport"]
|
self.scrollrectViewport = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport"]
|
||||||
self.rewardsContent = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content"]
|
self.rewardsContent = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content"]
|
||||||
@ -129,18 +132,12 @@ function BountyMainUI:initRewards()
|
|||||||
self.scrollrectComp:clearCells()
|
self.scrollrectComp:clearCells()
|
||||||
self.scrollrectComp:setTotalCount(0)
|
self.scrollrectComp:setTotalCount(0)
|
||||||
self.scrollrectComp:addInitCallback(function()
|
self.scrollrectComp:addInitCallback(function()
|
||||||
|
self.rewardsMaskBg:getTransform():SetAsLastSibling()
|
||||||
|
self.line:getTransform():SetAsLastSibling()
|
||||||
|
self.repeatRewardRoot:getTransform():SetAsLastSibling()
|
||||||
return "app/ui/bounty/cell/bounty_cell"
|
return "app/ui/bounty/cell/bounty_cell"
|
||||||
end)
|
end)
|
||||||
self.scrollrectComp:addRefreshCallback(function(index, cell)
|
self.scrollrectComp:addRefreshCallback(function(index, cell)
|
||||||
-- TODO 有时候顺序还是不对
|
|
||||||
if self.refreshIndex then
|
|
||||||
if index > self.refreshIndex then
|
|
||||||
cell:getBaseObject():getTransform():SetAsLastSibling()
|
|
||||||
elseif index < self.refreshIndex then
|
|
||||||
cell:getBaseObject():getTransform():SetAsFirstSibling()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.refreshIndex = index
|
|
||||||
local totalCount = self.scrollrectComp:getTotalCount()
|
local totalCount = self.scrollrectComp:getTotalCount()
|
||||||
local isFinalCell = index == totalCount
|
local isFinalCell = index == totalCount
|
||||||
if not self.disablePreviewReward then
|
if not self.disablePreviewReward then
|
||||||
@ -157,29 +154,14 @@ function BountyMainUI:initRewards()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cell:refresh(index, isFinalCell)
|
cell:refresh(index)
|
||||||
local lv = DataManager.BountyData:getLevel()
|
|
||||||
if index > lv - 1 or index < lv + 1 then
|
|
||||||
self.line:getTransform():SetAsLastSibling()
|
|
||||||
end
|
|
||||||
if not self.adjustRepeatRewardRoot then
|
|
||||||
self.adjustRepeatRewardRoot = true
|
|
||||||
local posY = -totalCount*self.cellHeight
|
|
||||||
self.repeatRewardRoot:setAnchoredPositionY(posY)
|
|
||||||
end
|
|
||||||
self.repeatRewardRoot:getTransform():SetAsLastSibling()
|
|
||||||
end)
|
end)
|
||||||
self.cellHeight = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.cell"]:getRectHeight()
|
self.cellHeight = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.cell"]:getRectHeight()
|
||||||
local scrollBottom = 106
|
local height = self.scrollrect:getRectHeight() - self.scrollrectComp:getTopRecoveryOffset() - self.scrollrectComp:getDownRecoveryOffset()
|
||||||
local scrollTop = 464
|
|
||||||
local height = self.root:getRectHeight()
|
|
||||||
height = height - scrollTop - scrollBottom
|
|
||||||
self.rewardCellNum = math.ceil(height/self.cellHeight)
|
self.rewardCellNum = math.ceil(height/self.cellHeight)
|
||||||
self:adaptScrollrect()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BountyMainUI:initRepeatReward()
|
function BountyMainUI:initRepeatReward()
|
||||||
self.adjustRepeatRewardRoot = false
|
|
||||||
self.repeatRewardRoot = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat"]
|
self.repeatRewardRoot = self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat"]
|
||||||
self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_BOX_DESC))
|
self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_BOX_DESC))
|
||||||
self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_3))
|
self.uiMap["bounty_main_ui.mid_node.scrollrect.viewport.content.repeat.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_3))
|
||||||
@ -202,26 +184,6 @@ function BountyMainUI:initRepeatReward()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BountyMainUI:adaptScrollrect()
|
|
||||||
if not self.rectDefaultSize then
|
|
||||||
self.rectDefaultSize = self.scrollrect:getSizeDelta()
|
|
||||||
end
|
|
||||||
if not self.viewDefaultSize then
|
|
||||||
self.viewDefaultSize = self.scrollrectViewport:getSizeDelta()
|
|
||||||
end
|
|
||||||
local addH = GFunc.calculateFitSizeY()
|
|
||||||
self.scrollrect:setSizeDelta(self.rectDefaultSize.x, self.rectDefaultSize.y + addH)
|
|
||||||
self.scrollrectViewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y + addH)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BountyMainUI:clearAdaptScrollrect()
|
|
||||||
if not self.rectDefaultSize then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.scrollrect:setSizeDelta(self.rectDefaultSize.x, self.rectDefaultSize.y)
|
|
||||||
self.scrollrectViewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y)
|
|
||||||
end
|
|
||||||
|
|
||||||
function BountyMainUI:bindData()
|
function BountyMainUI:bindData()
|
||||||
self:bind(DataManager.BountyData, "dirty", function()
|
self:bind(DataManager.BountyData, "dirty", function()
|
||||||
self:onRefresh()
|
self:onRefresh()
|
||||||
@ -292,14 +254,28 @@ function BountyMainUI:refreshRewards()
|
|||||||
self.scrollrectComp:updateAllCell()
|
self.scrollrectComp:updateAllCell()
|
||||||
self.disablePreviewReward = false
|
self.disablePreviewReward = false
|
||||||
end
|
end
|
||||||
|
local topRecoveryOffset = self.scrollrectComp:getTopRecoveryOffset()
|
||||||
|
local downRecoveryOffset = self.scrollrectComp:getDownRecoveryOffset()
|
||||||
|
local cellHeight = self.scrollrectComp:getCellHeight()
|
||||||
if lv >= maxLv then
|
if lv >= maxLv then
|
||||||
self.line:setVisible(false)
|
self.line:setVisible(false)
|
||||||
else
|
else
|
||||||
self.line:setVisible(true)
|
self.line:setVisible(true)
|
||||||
local posY = -lv*self.cellHeight
|
self.line:setAnchoredPositionY(-topRecoveryOffset - lv*cellHeight)
|
||||||
self.line:setAnchoredPositionY(posY)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.progressBg:setAnchoredPositionY((topRecoveryOffset + downRecoveryOffset)/2 - cellHeight/2)
|
||||||
|
self.progressBg:setSizeDeltaY(cellHeight*(maxLv - 1))
|
||||||
|
local percent = (lv - 1) / (maxLv - 1)
|
||||||
|
if percent < 0 then
|
||||||
|
percent = 0
|
||||||
|
end
|
||||||
|
self.progressComp.value = percent
|
||||||
|
|
||||||
|
self.rewardsMaskBg:setAnchoredPositionY(-topRecoveryOffset - lv*cellHeight)
|
||||||
|
self.rewardsMaskBg:setSizeDeltaY(cellHeight*maxLv + GConst.UI_SCREEN_HEIGHT)
|
||||||
|
|
||||||
|
self.repeatRewardRoot:setAnchoredPositionY(downRecoveryOffset)
|
||||||
if DataManager.BountyData:getIfCanClaimRepeatReward() then
|
if DataManager.BountyData:getIfCanClaimRepeatReward() then
|
||||||
self.repeatRewardRoot:addRedPoint(74, 15)
|
self.repeatRewardRoot:addRedPoint(74, 15)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -9,12 +9,9 @@ function BountyCell:init()
|
|||||||
self.bountyRewardCell1 = uiMap["cell.bg.bounty_reward_cell_1"]:addLuaComponent(BOUNTY_REWARD_CELL)
|
self.bountyRewardCell1 = uiMap["cell.bg.bounty_reward_cell_1"]:addLuaComponent(BOUNTY_REWARD_CELL)
|
||||||
uiMap["cell.bg.bounty_reward_cell_2"]:setAnchoredPositionX(GConst.UI_SCREEN_WIDTH/4)
|
uiMap["cell.bg.bounty_reward_cell_2"]:setAnchoredPositionX(GConst.UI_SCREEN_WIDTH/4)
|
||||||
self.bountyRewardCell2 = uiMap["cell.bg.bounty_reward_cell_2"]:addLuaComponent(BOUNTY_REWARD_CELL)
|
self.bountyRewardCell2 = uiMap["cell.bg.bounty_reward_cell_2"]:addLuaComponent(BOUNTY_REWARD_CELL)
|
||||||
self.maskImg = uiMap["cell.mask_img"]
|
|
||||||
self.lvBg = uiMap["cell.bg.lv_bg"]
|
self.lvBg = uiMap["cell.bg.lv_bg"]
|
||||||
self.lvTx = uiMap["cell.bg.lv_bg.lv_tx"]
|
self.lvTx = uiMap["cell.bg.lv_bg.lv_tx"]
|
||||||
|
|
||||||
self.progressBg = uiMap["cell.bg.progress_bg"]
|
|
||||||
self.progressComp = uiMap["cell.bg.progress_bg.progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
|
||||||
self.bountyRewardCell1:addClickListener(function()
|
self.bountyRewardCell1:addClickListener(function()
|
||||||
if self.idx == nil then
|
if self.idx == nil then
|
||||||
return
|
return
|
||||||
@ -44,7 +41,7 @@ function BountyCell:init()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BountyCell:refresh(idx, isFinalCell)
|
function BountyCell:refresh(idx)
|
||||||
self.idx = idx
|
self.idx = idx
|
||||||
local bountyInfo = DataManager.BountyData:getSeasonInfoByLevel(idx)
|
local bountyInfo = DataManager.BountyData:getSeasonInfoByLevel(idx)
|
||||||
local lv = DataManager.BountyData:getLevel()
|
local lv = DataManager.BountyData:getLevel()
|
||||||
@ -56,13 +53,7 @@ function BountyCell:refresh(idx, isFinalCell)
|
|||||||
self.bountyRewardCell1:refresh(bountyInfo.reward, false, false, state)
|
self.bountyRewardCell1:refresh(bountyInfo.reward, false, false, state)
|
||||||
self.bountyRewardCell2:refresh(bountyInfo.reward_pro, true, not isBought, proState)
|
self.bountyRewardCell2:refresh(bountyInfo.reward_pro, true, not isBought, proState)
|
||||||
if lv >= idx then
|
if lv >= idx then
|
||||||
self.maskImg:setVisible(false)
|
|
||||||
self.lvBg:setImageGray(false)
|
self.lvBg:setImageGray(false)
|
||||||
if lv == idx then
|
|
||||||
self.progressComp.value = 0
|
|
||||||
else
|
|
||||||
self.progressComp.value = 1
|
|
||||||
end
|
|
||||||
if state then -- 已经领过了
|
if state then -- 已经领过了
|
||||||
self.bountyRewardCell1:hideLight()
|
self.bountyRewardCell1:hideLight()
|
||||||
else
|
else
|
||||||
@ -75,16 +66,9 @@ function BountyCell:refresh(idx, isFinalCell)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.lvBg:setImageGray(true)
|
self.lvBg:setImageGray(true)
|
||||||
self.maskImg:setVisible(true)
|
|
||||||
self.progressComp.value = 0
|
|
||||||
self.bountyRewardCell1:hideLight()
|
self.bountyRewardCell1:hideLight()
|
||||||
self.bountyRewardCell2:hideLight()
|
self.bountyRewardCell2:hideLight()
|
||||||
end
|
end
|
||||||
if isFinalCell then
|
|
||||||
self.progressBg:setVisible(false)
|
|
||||||
else
|
|
||||||
self.progressBg:setVisible(true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BountyCell:setVisible(visible)
|
function BountyCell:setVisible(visible)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user