Skip to content

Commit

Permalink
LLP beatmap converter
Browse files Browse the repository at this point in the history
- Invoke via `love livesim2 llpbeatmap <beatmapname>`
  • Loading branch information
MikuAuahDark committed Jan 5, 2018
1 parent 0b8323c commit 1629588
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 15 deletions.
1 change: 1 addition & 0 deletions AquaShineConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return {
about = {0, "about_screen.lua"},
render = {3, "render_livesim.lua"},
noteloader = {1, "invoke_noteloader.lua"},
llpbeatmap = {1, "tollp.lua"},
unit_create = {0, "unit_create.lua"},
},
-- Default entry point to be used if there's none specificed in command-line
Expand Down
20 changes: 20 additions & 0 deletions docs/Storyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,26 @@ Check whenever the notes is randomized.

Returns: `false` if the notes is not randomized, `true` otherwise.

*************************************************

### `Shader ... SetPostProcessingShader(Shader ...)`

Set post-processing shader chain

Parameters:

* `...` - New shaders to be used as post-processing (in order). Pass empty value to unset.

Returns: Previous `Shader` objects (or `nil` if no shader is used)

*************************************************

### `number, number GetScreenDimensions()`

Get the screen dimensions

Returns: Screen dimensions (width and height)

Storyboard Callback Functions
=============================

Expand Down
58 changes: 43 additions & 15 deletions livesim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,27 @@ function DEPLS.StoryboardFunctions._SetColorRange(r)
DEPLS.DefaultColorMode = r
end

--! @brief Set post-processing shader
--! @param shader New shader to be used as post-processing
--! @returns Previous shader
function DEPLS.StoryboardFunctions.SetPostProcessingShader(shader)
if type(shader) == nil or (type(shader) == "userdata" and shader:typeOf("Shader")) then
local sh = DEPLS.PostShader
DELS.PostShader = shader
return sh
--! @brief Set post-processing shaders
--! @param ... New shaders to be used as post-processing
--! @returns Previous shaders
function DEPLS.StoryboardFunctions.SetPostProcessingShader(...)
local arg = {...}
local prev = DEPLS.PostShader

if #arg == 0 then
DEPLS.PostShader = nil
else
for i = 1, #arg do
assert(type(arg[i]) == "userdata" and arg[i]:typeOf("Shader"), "Invalid value passed")
end

DEPLS.PostShader = arg
end

if prev then
return unpack(prev)
else
error("bad argument #2 to 'SetPostProcessingShader' (Invalid shader)", 2)
return nil
end
end

Expand Down Expand Up @@ -1158,12 +1169,28 @@ function DEPLS.Draw(deltaT)
end

graphics.pop()
graphics.push()
graphics.origin()
graphics.setShader(DEPLS.PostShader)
graphics.draw(DEPLS.MainCanvas)
graphics.setShader()
graphics.pop()
return DEPLS.PostProcessingDraw()
end

-- Post-processing draw. Shaders can be chained here
function DEPLS.PostProcessingDraw()
love.graphics.push()
love.graphics.origin()

if DEPLS.PostShader then
for i = 1, #DEPLS.PostShader do
love.graphics.setCanvas(DEPLS.SecondaryCanvas)
love.graphics.clear()
love.graphics.setShader(DEPLS.PostShader[i])
love.graphics.draw(DEPLS.MainCanvas)
DEPLS.MainCanvas, DEPLS.SecondaryCanvas = DEPLS.SecondaryCanvas, DEPLS.MainCanvas
end
love.graphics.setShader()
love.graphics.setCanvas(AquaShine.MainCanvas)
end

love.graphics.draw(DEPLS.MainCanvas)
love.graphics.pop()
end

-- LOVE2D mouse/touch pressed
Expand Down Expand Up @@ -1309,6 +1336,7 @@ end

function DEPLS.Resize(w, h)
DEPLS.MainCanvas = love.graphics.newCanvas()
DEPLS.SecondaryCanvas = love.graphics.newCanvas()
end

function DEPLS.Exit()
Expand Down
60 changes: 60 additions & 0 deletions tollp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- Beatmap converter: To LLPractice
-- Part of Live Simulator: 2
-- See copyright notice in main.lua

local AquaShine = ...
local JSON = require("JSON")
local NoteLoader = AquaShine.LoadModule("note_loader2")
local ToLLP = {}
local epsilon = 0.001

function ToLLP.CheckSimulNote(lane, timing)
for i = 1, 9 do
if lane[i] then
local n = lane[i]

for j = 1, #n do
if math.abs(n[j].starttime - timing) <= epsilon then
return true
end
end
end
end

return false
end

function ToLLP.Start(arg)
local noteloader_data = NoteLoader.NoteLoader(assert("beatmap/"..arg[1]))
local llpdata = {}
--llpdata.speed = tonumber(arg[2]) or 160
--llpdata.audiofile = arg[1]
llpdata.lane = {}

for i, v in ipairs(noteloader_data:GetNotesList()) do
local laneidx = 10 - v.position
local lane = llpdata.lane[laneidx]

if not(lane) then
lane = {}
llpdata.lane[laneidx] = lane
end

local note = table.new(0, 6)
local long = v.effect % 10 == 3
-- time units is in ms for LLP
note.starttime = v.timing_sec * 1000
note.endtime = note.starttime + (long and v.effect_value or 0) * 1000
note.longnote = long
note.parallel = ToLLP.CheckSimulNote(llpdata.lane, note.starttime)
note.lane = laneidx - 1
note.hold = false

lane[#lane + 1] = note
end

io.write(JSON:encode(llpdata), "\n")
love.event.quit()
end

return ToLLP

0 comments on commit 1629588

Please sign in to comment.