Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadin committed May 13, 2022
2 parents 03923e0 + 9f513b4 commit c5804d7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
14 changes: 8 additions & 6 deletions Panels.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ local function setUpPanels(seq)
local pos = 0
local j = 1

if seq.panels == nil then
printError(seq.title or "Untitled sequence", "No panel data found in sequence:")
end

local list = table.shallowcopy(seq.panels)
if seq.scrollingIsReversed then
reverseTable(list)
Expand Down Expand Up @@ -174,7 +178,7 @@ local function drawButtonIndicator()
buttonIndicator:hide()
end
end
if sequence.showAdvanceControl then
if sequence.showAdvanceControl and sequenceDidStart then
buttonIndicator:draw()
end
end
Expand Down Expand Up @@ -346,7 +350,7 @@ local function startTransitionIn(direction, delay)

scrollPos = start

-- make a dummy animator to hold scoll pos until delayed transition starts
-- make a dummy animator to hold scroll pos until delayed transition starts
transitionInAnimator = playdate.graphics.animator.new(math.max(delay * 2, 2000), start, start)

if previousBGColor then
Expand Down Expand Up @@ -494,6 +498,7 @@ local function loadSequence(num)
end

startTransitionIn(sequence.direction, sequence.delay or 0)

end

local function unloadSequence()
Expand Down Expand Up @@ -666,7 +671,6 @@ end

local function updateComic(offset)


if transitionInAnimator or transitionOutAnimator then
updateSequenceTransition()
else
Expand All @@ -688,8 +692,6 @@ local function updateComic(offset)
checkInputs()
end
end


end

local function drawComic(offset)
Expand Down Expand Up @@ -952,6 +954,6 @@ end

function playdate.keyPressed(key)
if key == "0" then
unlockAll()
if Panels.Settings.debugControlsEnabled then unlockAll() end
end
end
21 changes: 15 additions & 6 deletions modules/Audio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Panels.Audio = {
}

function Panels.Audio.createTypingSound()
local path = Panels.Settings.path .. "assets/audio/typingBeep.wav"
local path = Panels.Settings.path .. "assets/audio/typingBeep"
if Panels.Settings.typingSound ~= Panels.Audio.TypingSound.NONE then
if Panels.Settings.typingSound ~= Panels.Audio.TypingSound.DEFAULT then
path = Panels.Settings.audioFolder .. Panels.Settings.typingSound
Expand All @@ -23,6 +23,10 @@ function Panels.Audio.createTypingSound()
end
end

function onBGFinished(player)
printError("", "Background audio fileplayer stopped due to buffer underrun")
end

function Panels.Audio.startBGAudio(path, loop, volume)
if string.sub(path, -4) == ".wav" then
path = string.sub(path, 0, -5)
Expand All @@ -31,17 +35,22 @@ function Panels.Audio.startBGAudio(path, loop, volume)
if bgAudioPlayer then
Panels.Audio.fadeOut(bgAudioPlayer)
end
bgAudioPlayer, error = playdate.sound.fileplayer.new(path)
bgAudioPlayer, error = playdate.sound.fileplayer.new(path, 2)
bgAudioPlayer:setFinishCallback(onBGFinished, bgAudioPlayer)
if bgAudioPlayer then
if loop then repeatCount = 0 else repeatCount = 1 end
bgAudioPlayer:play(repeatCount)

if volume then
bgAudioPlayer:setVolume(volume)
if loop then repeatCount = 0 else repeatCount = 1 end
success, e = bgAudioPlayer:play(repeatCount)
if e then
printError(e, "Error playing bg audio:")
else
bgAudioPlayer:setVolume(volume or 1)
end

else
printError(error, "Error loading background audio:")
end

end

function Panels.Audio.stopBGAudio()
Expand Down
14 changes: 13 additions & 1 deletion modules/Panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local AxisHorizontal = Panels.ScrollAxis.HORIZONTAL


local function createFrameFromPartialFrame(frame)
if frame.margin == nil then frame.margin = 0 end
if frame.margin == nil then frame.margin = Panels.Settings.defaultFrame.margin end

if frame.width == nil then
frame.width = ScreenWidth - frame.margin * 2
Expand All @@ -25,6 +25,10 @@ local function createFrameFromPartialFrame(frame)
if frame.y == nil then
frame.y = frame.margin
end

if frame.gap == nil then
frame.gap = Panels.Settings.defaultFrame.gap
end

return frame
end
Expand Down Expand Up @@ -152,6 +156,14 @@ function Panels.Panel.new(data)
if layer.effect.type == Panels.Effect.BLINK and layer.effect.audio then
layer.sfxPlayer = playdate.sound.sampleplayer.new(Panels.Settings.audioFolder .. layer.effect.audio.file)
end

if playdate.getReduceFlashing()
and layer.effect.type == Panels.Effect.BLINK
and layer.effect.reduceFlashingDurations ~= nil
then
layer.effect.durations.on = layer.effect.reduceFlashingDurations.on
layer.effect.durations.off = layer.effect.reduceFlashingDurations.off
end
end

if layer.animate then
Expand Down
5 changes: 4 additions & 1 deletion modules/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Panels.Settings = {

-- menu settings
menuImage = "menuImage.png",
listUnnamedSequences = false,
listLockedSequences = true,
chapterMenuHeaderImage = nil,
useChapterMenu = true,
Expand All @@ -25,6 +24,10 @@ Panels.Settings = {

-- credits
showCreditsOnGameOver = false,

-- debug
debugControlsEnabled = false,
listUnnamedSequences = false,
}

local function addSlashToFolderName(f)
Expand Down

0 comments on commit c5804d7

Please sign in to comment.