主城箭头

This commit is contained in:
chenxi 2023-04-20 18:01:39 +08:00
parent f73980c7de
commit e136291098
2 changed files with 31 additions and 2 deletions

View File

@ -17,13 +17,15 @@ function MainComp:initChapter()
self.chapterImg = self.uiMap["main_comp.chapter.img"]
self.chapterNameTx = self.uiMap["main_comp.chapter.name_tx"]
self.leftArrow = self.uiMap["main_comp.chapter.left_arrow"]
self.leftArrow:addClickListener(function()
local leftArrowBtn = self.uiMap["main_comp.chapter.left_arrow.btn"]
leftArrowBtn:addClickListener(function()
if DataManager.ChapterData:goLastChapter() then
self:refresh()
end
end)
self.rightArrow = self.uiMap["main_comp.chapter.right_arrow"]
self.rightArrow:addClickListener(function()
local rightArrowBtn = self.uiMap["main_comp.chapter.right_arrow.btn"]
rightArrowBtn:addClickListener(function()
if DataManager.ChapterData:goNextChapter() then
self:refresh()
end
@ -64,6 +66,17 @@ end
function MainComp:refreshChapter(force)
local chapterId = DataManager.ChapterData:getChapterId()
if self.currChapterId ~= chapterId or force then
if DataManager.ChapterData:getIsFirstChapter(chapterId) then
self.leftArrow:setVisible(false)
self.rightArrow:setVisible(true)
elseif DataManager.ChapterData:getIsFinalChapter(chapterId) then
self.leftArrow:setVisible(true)
self.rightArrow:setVisible(false)
else
self.leftArrow:setVisible(true)
self.rightArrow:setVisible(true)
end
self.currChapterId = chapterId
local chapterInfo = ConfigManager:getConfig("chapter")[chapterId]
local chapterI18NInfo = I18N:getConfig("chapter")[chapterId]

View File

@ -26,6 +26,22 @@ function ChapterData:init(data, notChangeChapterId)
self.data.chapterFightInfo = data and data.chapterFightInfo or {}
end
function ChapterData:getIsFirstChapter(chapterId)
return chapterId == MIN_CHAPTER_ID
end
function ChapterData:getIsFinalChapter(chapterId)
local chapterInfo = self:getChapterCfg()[chapterId]
if chapterInfo == nil then
return false
end
local chapterId = chapterInfo.next_chapter
if chapterId == nil then
return true
end
return false
end
function ChapterData:setDirty()
self.data.isDirty = not self.data.isDirty
end