From e13629109810783d66fc62f8e715ef6876fe547e Mon Sep 17 00:00:00 2001 From: chenxi Date: Thu, 20 Apr 2023 18:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=9F=8E=E7=AE=AD=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/main_city/component/main_comp.lua | 17 +++++++++++++++-- lua/app/userdata/chapter/chapter_data.lua | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index d98644d9..4d26f851 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -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] diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index 3b76e461..f3ab7d93 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -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