Skip to content

Commit

Permalink
4.2 zeta
Browse files Browse the repository at this point in the history
[added] `..` directory to go up a folder
[added] small optimizations
[fixed] sometimes file list wouldn't scroll to top
[fixed] some documentation inconsistencies
[removed] scrollImg
  • Loading branch information
Nanobot567 committed May 9, 2023
1 parent 0b63f24 commit 3f9a3be
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 87 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
build.bat
build-run.bat
build.sh
build-run.sh
pdxinfobuilder.py
Games/
musik.pdx/
unused/
CHANGELOG.MD
TODO.MD
TODO.MD
4 changes: 2 additions & 2 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- B - exit to files screen
- Right/Left - seek forward / backward 5 seconds (this works best when the song is paused)
- Up/Down - skip to previous/next song
NOTE: skipping to the next song has a chance of causing your playdate to crash. See above for explanation.
NOTE: skipping to the next song has a chance of causing your playdate to crash. See README for explanation.

In the system menu, there is an options menu item titled "mode". This controls the current playing mode. The options are:
- `none` - plays the song then stops
Expand Down Expand Up @@ -51,4 +51,4 @@ To add songs to musik, follow these steps:
3. Navigate to `/Data/user.*****.musik/music/`
4. Drag and drop your MP3s / PDAs!

NOTE: Musik also supports folders, so long file names shouldn't be a problem...? (Let me know if it is and I'll see what I can do)
NOTE: Musik also supports folders, so long file names shouldn't be a problem...? (Let me know if it is and I'll see what I can do)
Binary file modified src/SystemAssets/card-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 27 additions & 20 deletions src/funcs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import "CoreLibs/ui"
import "CoreLibs/nineslice"
import "CoreLibs/timer"

local gfx <const> = playdate.graphics
local disp <const> = playdate.display
local timer <const> = playdate.timer
local fs <const> = playdate.file
local gfx <const> = pd.graphics
local disp <const> = pd.display
local timer <const> = pd.timer
local fs <const> = pd.file

function bAction()
curRow = fileList:getSelectedRow()
Expand All @@ -22,15 +22,18 @@ function bAction()
table.remove(splitted,#splitted)
end

dir = lastdirs[#lastdirs]
table.remove(lastdirs,#lastdirs)
dir = table.remove(lastdirs,#lastdirs)

files = fs.listFiles(dir, false)

table.insert(files, 1, "..")
if dir ~= "/music/" then
table.insert(files, 1, "..")
end

fileList:setSelectedRow(1)
fileList:scrollToRow(1)
local selRow = table.remove(lastDirPos)

fileList:setSelectedRow(selRow)
fileList:scrollToRow(selRow)
end

audioFiles = {}
Expand Down Expand Up @@ -123,6 +126,9 @@ function swapScreenMode()
end
end
end
if dir ~= "/music/" then
table.insert(files, 1, "..")
end
end
end

Expand Down Expand Up @@ -189,7 +195,7 @@ function handleMode(str) -- add queue mode
mode = 4
currentAudio:setFinishCallback(nil)
currentAudio:stop()
currentAudio = playdate.sound.fileplayer.new()
currentAudio = pd.sound.fileplayer.new()
currentAudio:setFinishCallback(handleSongEnd)
currentFileName = ""
currentFileDir = ""
Expand Down Expand Up @@ -232,7 +238,7 @@ end

function drawInfo()
local extension
local time = playdate.getTime()
local time = pd.getTime()
if #tostring(time["hour"]) == 1 then
time["hour"] = "0"..time["hour"]
end
Expand All @@ -247,7 +253,7 @@ function drawInfo()
time["minute"] = "0"..time["minute"]
end

local batteryPercent = playdate.getBatteryPercentage()
local batteryPercent = pd.getBatteryPercentage()

if string.find(batteryPercent,"100.") then
batteryPercent = "100"
Expand All @@ -263,6 +269,7 @@ function drawInfo()
end

function handleSongEnd() -- fix literally everything :) have fun future aiden - i did it past me! aren't you proud of me?
print(currentAudio:didUnderrun())
local justInQueue = false
audioFiles = {}
for i=1,#files do
Expand All @@ -278,7 +285,7 @@ function handleSongEnd() -- fix literally everything :) have fun future aiden -
currentPos = 1
end
if currentFileName == audioFiles[#audioFiles] then
if not playdate.buttonIsPressed("a") then
if not pd.buttonIsPressed("a") then
if fs.isdir(dir..audioFiles[1]) == false then
currentFileName = audioFiles[1]
currentAudio:load(dir..audioFiles[1])
Expand All @@ -305,7 +312,7 @@ function handleSongEnd() -- fix literally everything :) have fun future aiden -
currentFileName = audioFiles[randthing]
currentAudio:load(dir..audioFiles[randthing])
elseif mode == 0 then
currentAudio = playdate.sound.fileplayer.new()
currentAudio = pd.sound.fileplayer.new()
currentAudio:setFinishCallback(handleSongEnd)
currentFileName = ""
currentFileDir = ""
Expand Down Expand Up @@ -353,7 +360,7 @@ function handleSongEnd() -- fix literally everything :) have fun future aiden -
currentAudio:play()
else
currentFilePath = ""
playdate.setAutoLockDisabled(false)
pd.setAutoLockDisabled(false)
end
end

Expand All @@ -370,7 +377,7 @@ function formatSeconds(seconds)
end
end

function playdate.downButtonDown()
function pd.downButtonDown()
local function timerCallback()
if fileList:getSelectedRow() ~= #files then
fileList:selectNextRow(true)
Expand All @@ -381,13 +388,13 @@ function playdate.downButtonDown()
end
end

function playdate.downButtonUp()
function pd.downButtonUp()
if screenMode == 0 or screenMode == 3 then
downKeyTimer:remove()
end
end

function playdate.upButtonDown()
function pd.upButtonDown()
local function timerCallback()
if fileList:getSelectedRow() ~= 1 then
fileList:selectPreviousRow(true)
Expand All @@ -398,8 +405,8 @@ function playdate.upButtonDown()
end
end

function playdate.upButtonUp()
function pd.upButtonUp()
if screenMode == 0 or screenMode == 3 then
upKeyTimer:remove()
end
end
end
Binary file modified src/img/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/img/scrollimg.png
Binary file not shown.
Loading

0 comments on commit 3f9a3be

Please sign in to comment.