Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadin committed Sep 30, 2023
2 parents 93564d5 + 68ca0b1 commit ea67299
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
3 changes: 3 additions & 0 deletions Panels.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
-- Panels version 1.5.1
-- https://cadin.github.io/panels/

import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
Expand Down
32 changes: 15 additions & 17 deletions modules/Menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ end

local function isLastUnlockedSequence(index)
for i = index + 1, #Panels.unlockedSequences, 1 do
if Panels.unlockedSequences[i] == true then
if i > #sections then return true end
local sectionIndex = sections[i].index
if Panels.unlockedSequences[sectionIndex] == true then
return false
end
end
Expand All @@ -288,7 +290,8 @@ end

local function isFirstUnlockedSequence(index)
for i = index - 1, 1, -1 do
if Panels.unlockedSequences[i] == true then
local sectionIndex = sections[i].index
if Panels.unlockedSequences[sectionIndex] == true then
return false
end
end
Expand All @@ -297,7 +300,8 @@ end

local function getNextUnlockedSequence(index)
for i = index + 1, #Panels.unlockedSequences, 1 do
if Panels.unlockedSequences[i] == true then
local sectionIndex = sections[i].index
if Panels.unlockedSequences[sectionIndex] == true then
return i
end
end
Expand All @@ -306,7 +310,8 @@ end

local function getPreviousUnlockedSequence(index)
for i = index - 1, 1, -1 do
if Panels.unlockedSequences[i] == true then
local sectionIndex = sections[i].index
if Panels.unlockedSequences[sectionIndex] == true then
return i
end
end
Expand Down Expand Up @@ -339,11 +344,9 @@ local function createChapterMenu(data)
downButtonUp = function()
chapterOffset = 4
local selectedRow = chapterList:getSelectedRow()
local item = sections[selectedRow]
if not isLastUnlockedSequence(item.index) then
local next = getNextUnlockedSequence(item.index)
local row = getRowForSequenceIndex(next)
chapterList:setSelectedRow(row)
if not isLastUnlockedSequence(selectedRow) then
local next = getNextUnlockedSequence(selectedRow)
chapterList:setSelectedRow(next)
if Panels.Settings.playMenuSounds then
selectionSound:play()
end
Expand All @@ -356,14 +359,10 @@ local function createChapterMenu(data)

upButtonUp = function()
chapterOffset = -4

local selectedRow = chapterList:getSelectedRow()
local item = sections[selectedRow]

if not isFirstUnlockedSequence(item.index) then
local prev = getPreviousUnlockedSequence(item.index)
local row = getRowForSequenceIndex(prev)
chapterList:setSelectedRow(row)
if not isFirstUnlockedSequence(selectedRow) then
local prev = getPreviousUnlockedSequence(selectedRow)
chapterList:setSelectedRow(prev)
if Panels.Settings.playMenuSounds then
selectionRevSound:play()
end
Expand Down Expand Up @@ -399,7 +398,6 @@ function chapterList:drawCell(section, row, column, selected, x, y, width, heigh
if selected then
gfx.setColor(gfx.kColorBlack)
gfx.fillRoundRect(x, y + chapterOffset, width, height, 4)
-- gfx.drawRoundRect(x + 1, y, width - 2, height, 4)
gfx.setImageDrawMode(gfx.kDrawModeFillWhite)
chapterOffset = 0
else
Expand Down

0 comments on commit ea67299

Please sign in to comment.