+ infinite scroll to songwheel
This commit is contained in:
parent
fdff69f762
commit
a2520877dd
|
@ -74,6 +74,23 @@ function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
|
|||
end
|
||||
end
|
||||
|
||||
function getCorrectedIndex(from, offset)
|
||||
total = #songwheel.songs;
|
||||
|
||||
index = from + offset;
|
||||
|
||||
if index < 1 then
|
||||
index = total + (from+offset) -- this only happens if the offset is negative
|
||||
end;
|
||||
|
||||
if index > total then
|
||||
indexesUntilEnd = total - from;
|
||||
index = offset - indexesUntilEnd -- this only happens if the offset is positive
|
||||
end;
|
||||
|
||||
return index;
|
||||
end;
|
||||
|
||||
function getJacketImage(song)
|
||||
if not jacketCache[song.id] then
|
||||
jacketCache[song.id] = gfx.CreateImage(song.difficulties[1].jacketPath, 0)
|
||||
|
@ -129,7 +146,8 @@ function drawSongList()
|
|||
|
||||
local i=1;
|
||||
while (i <= numOfSongsAround) do
|
||||
drawSong(songwheel.songs[selectedIndex-i], desh/2-172/2-172*i)
|
||||
local songIndex = getCorrectedIndex(selectedIndex, -i)
|
||||
drawSong(songwheel.songs[songIndex], desh/2-172/2-172*i)
|
||||
i=i+1;
|
||||
end;
|
||||
|
||||
|
@ -138,7 +156,8 @@ function drawSongList()
|
|||
|
||||
i=1;
|
||||
while (i <= numOfSongsAround) do
|
||||
drawSong(songwheel.songs[selectedIndex+i], desh/2-172/2+172*i)
|
||||
local songIndex = getCorrectedIndex(selectedIndex, i)
|
||||
drawSong(songwheel.songs[songIndex], desh/2-172/2+172*i)
|
||||
i=i+1;
|
||||
end;
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue