Skip to content

Commit

Permalink
CBF v0.7 beatmap support
Browse files Browse the repository at this point in the history
Fixed early live show clear if user presses pause when there are no more notes

Fixed pause button not being invisible correctly in some cases

Fixed pause counter is affected by live opacity

Fixed MIDI beatmap loading timing non-sync

- It's caused by tempo value imprecision

Fixed crash when long note miss

Documenting LoadFont and allow loading font from embedded beatmap file (LS2)

Improved FXAA for some GPU (maybe)

2 new storyboard functions

- `GetCurrentBackgroundImage` and `GetCurrentUnitImage`

Fixed some problems in LS2 library

Recreate Weisser Schnee beatmap to Live Simulator: 2 binary beatmap v2.0
  • Loading branch information
MikuAuahDark committed Sep 3, 2017
1 parent 1687c6b commit 6ed75e4
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 66 deletions.
2 changes: 0 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ v2.0
- NoteLoader2 (metadata loading, beatmap verification) OK
- Hidden note and sudden note OK
- Individual note speed OK
- Live Show! Failed
- Pause OK
- Adjustable combo display size OK
- Adjustable SE volume OK
- Download SIF beatmaps WIP (with RayFirefist)
- Actual unit live skill Possibly aborted
- Album art for SIFTrain beatmap OK
- Decrease sensitivity for swing note accuracy OK
- LS2 v2.0 OK
Expand Down
8 changes: 8 additions & 0 deletions conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,31 @@ AquaShine.ParseCommandLineConfig(assert(arg))
------------------
-- /gles switch --
------------------
local enabledpiaware
if AquaShine.GetCommandLineConfig("gles") then
local _, ffi = pcall(require, "ffi")

if _ then
local setenv_load = assert(loadstring("local x=... return x.setenv"))
local putenv_load = assert(loadstring("local x=... return x.SetEnvironmentVariableA"))
local dpiaware = assert(loadstring("local x = ... return x.SetProcessDPIAware"))
ffi.cdef [[
int setenv(const char *envname, const char *envval, int overwrite);
int __stdcall SetEnvironmentVariableA(const char* envname, const char* envval);
int __stdcall SetProcessDPIAware();
]]

local ss, setenv = pcall(setenv_load, ffi.C)
local ps, putenv = pcall(putenv_load, ffi.C)
local dp, setdpiaware = pcall(dpiaware, ffi.C)

if ss then
setenv("LOVE_GRAPHICS_USE_OPENGLES", "1", 1)
elseif ps then
putenv("LOVE_GRAPHICS_USE_OPENGLES", "1")
end

if dp then enabledpiaware = setdpiaware end
end
end

Expand Down Expand Up @@ -104,4 +110,6 @@ function love.conf(t)
t.modules.video = true -- Enable the video module (boolean)
t.modules.window = true -- Enable the window module (boolean)
t.modules.thread = true -- Enable the thread module (boolean)

if t.window.highdpi and enabledpiaware then enabledpiaware() end
end
84 changes: 76 additions & 8 deletions docs/Storyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Lua Storyboard
Lua storyboard is simply a Lua script which controls how objects shown behind the simulator,
hence it's named Lua storyboard. Please note that Lua script running as Lua storyboard is
sandboxed, which means most of `love` functions doesn't exist in here or modified to prevent
alteration of the rendering state, and to prevent malicious Lua storyboard from running.
alteration of the rendering state, and to prevent malicious Lua script from running.

Storyboard Entry Points
=======================

Lua storyboard needs to create this function in global namespace. Although there's way to use
it without this entry points by using coroutines, but it's usage is discouraged and only
provided for legacy DEPLS storyboard lua script.
provided for legacy DEPLS storyboard Lua script.

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

Expand All @@ -30,6 +30,34 @@ Parameters:

* deltaT - The delta-time, in milliseconds

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

### `void Jump(number elapsed_time)`

Storyboard seek. This function is called when user resumes Live Show!

> This function is not available in current release.
> If this function is not implemented, the beatmap is assumed not to support resumeable live.
Parameters:

* elapsed_time - Last elapsed time when the live show state is saved

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

### `void Pause(bool pausing)`

Storyboard pause. This function is called when user pressed the pause button.

> This function is not available in current release.
> If this function is not implemented, the storyboard is assumed not to support pause, and all drawing operation will be emulated in 1136x726 canvas
Parameters:

* pausing - `true` if the game is paused, `false` if the game is unpaused.

Storyboard Functions
====================

Expand Down Expand Up @@ -104,26 +132,40 @@ Parameters:

* `path` - Video filename

Returns: love2d `Video` object or `nil` on failure
Returns: LOVE `Video` object or `AquaShineVideoObject` or `nil` on failure

> For additional sandboxing and compatibility, this is synonym of `love.graphics.newVideo`
> Unlike `love.graphics.newVideo`, this function allows loading of many video formats if system supports it (see `MultiVideoFormatSupported()`)
*************************************************

### `Image|nil LoadImage(string path)`

Load image. Directory is relative to current beatmap folder
Load image. Directory is relative to current beatmap folder.

Parameters:

* `path` - Image filename

Returns: love2d `Image` object or `nil` on failure
Returns: LOVE `Image` object or `nil` on failure

> For additional sandboxing and compatibility, this is synonym of `love.graphics.newImage`
*************************************************

### `Font|nil LoadFont([string path [, number size = 14]])`

Load font. Directory is relative to current beatmap folder.

Parameters:

* `path` - Font path or nil to use default, Motoya L Maru font `MTLmr3m.ttf`

* `size` - The font size. Defaults to 14.

Returns: LOVE `Font` object or `nil` on failure

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

### `string|nil ReadFile(string path)`

Reads the contents of file. Directory is relative to current beatmap folder
Expand Down Expand Up @@ -208,6 +250,8 @@ Parameters:

Check for current rendering type.

> This function can be useful to determine quality of storyboard
Returns: `true` if currently in rendering mode (offline drawing), `false` if currently in live mode (online drawing).

*************************************************
Expand Down Expand Up @@ -245,12 +289,12 @@ drawn by default.

### `bool IsOpenGLES()`

Check if current renderer is OpenGL ES. This can be used to select shader code to be used because Desktop GL shader and GLES shader
Check if current renderer is OpenGL ES. This can be used to select shader code to use because Desktop GL shader and GLES shader code
were bit different each other

Returns: `true` if running under OpenGLES, `false` otherwise

> This function returns `true` when running LOVE2D under desktop with [ANGLE](http://angleproject.org) renderer.
> This function also returns `true` when running LOVE under desktop with [ANGLE](http://angleproject.org) renderer.
*************************************************

Expand All @@ -260,6 +304,30 @@ Check if FFmpeg extension is available.

Returns: `true` if FFmpeg extension is available (allow loading video other than Theora .ogg/.ogv), `false` otherwise.

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

### `table|Image|nil GetCurrentBackgroundImage([number index = 0])`

Get the current beatmap background.

Parameters:

* `idx` - The index to retrieve it's background image or nil for all index

Returns: LOVE `Image` object of specificed index, or nil, or table containing all of background image in LOVE `Image` object (index 0-4)

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

### `Image GetCurrentUnitImage(number index)`

Get the current unit image.

Parameters:

* `idx` - The unit index to retrieve it's image. 1 is rightmost, 9 is leftmost.

Returns: LOVE `Image` object

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

Expand Down
2 changes: 2 additions & 0 deletions docs/draft_depls2_beatmap_format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ Sections:
For Every amount of notes above:
dwordu - Timing milliseconds
dwordu - Attribute. Some possible values:
* bit layout: rrrrrrrr rggggggg ggbbbbbb bbbscccc
* bit 0-3: Note images following Sukufesu simulator note colors in order. Ask yuyu for it, lol.
* If it's 15 - CBF extension colored note
* bit 23-31 - R color (9 bits, unsigned)
* bit 14-22 - G color (9 bits, unsigned)
* bit 5-13 - B color (9 bits, unsigned)
* bit 4: Is swing note?
dwordu - Note effect
* bit layout: ssssssss llllllll llllllll llffpppp
* bit 0-3 - Note position. 9 is leftmost, 1 is rightmost
* bit 4-5: Note effect.
0 = Normal note
Expand Down
70 changes: 52 additions & 18 deletions livesim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,29 @@ function DEPLS.StoryboardFunctions.MultiVideoFormatSupported()
return not(not(AquaShine.FFmpegExt))
end

--! @brief Get the current beatmap background
--! @param idx The index to retrieve it's background image or nil for all index
--! @returns LOVE `Image` object of specificed index, or nil, or table containing
--! all of background image in LOVE `Image` object (index 0-4)
function DEPLS.StoryboardFunctions.GetCurrentBackgroundImage(idx)
if idx then
assert(idx >= 0 and idx < 5, "Invalid index")
return DEPLS.BackgroundImage[idx][1]
else
local a = {}
for i = 0, 4 do
a[i] = DEPLS.BackgroundImage[i][1]
end

return a
end
end

function DEPLS.StoryboardFunctions.GetCurrentUnitImage(idx)
assert(idx > 0 and idx < 10, "Invalid index")
return DEPLS.IdolImageData[idx][1]
end

-----------------------------
-- The Live simuator logic --
-----------------------------
Expand Down Expand Up @@ -532,7 +555,8 @@ function DEPLS.Resume()
end

function DEPLS.IsLiveEnded()
return (not(DEPLS.Sound.LiveAudio) or
return not(DEPLS.Routines.PauseScreen.IsPaused()) and
(not(DEPLS.Sound.LiveAudio) or
DEPLS.Sound.LiveAudio:isPlaying() == false) and
DEPLS.NoteManager.NoteRemaining == 0
end
Expand Down Expand Up @@ -602,7 +626,6 @@ function DEPLS.Start(argv)
local noteloader_data = argv.Beatmap
local notes_list = noteloader_data:GetNotesList()
local custom_background = false
DEPLS.StoryboardHandle = noteloader_data:GetStoryboard()
DEPLS.Sound.BeatmapAudio = noteloader_data:GetBeatmapAudio()
DEPLS.Sound.LiveClear = noteloader_data:GetLiveClearSound()

Expand Down Expand Up @@ -649,9 +672,27 @@ function DEPLS.Start(argv)
custom_background = true
end

-- Load unit icons
local noteloader_units = noteloader_data:GetCustomUnitInformation()
local IdolImagePath = {}
do
local idol_img = AquaShine.LoadConfig("IDOL_IMAGE", "dummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy")

for w in idol_img:gmatch("[^\t]+") do
IdolImagePath[#IdolImagePath + 1] = w
end
end
for i = 1, 9 do
DEPLS.IdolImageData[i][1] = noteloader_units[i] or DEPLS.LoadUnitIcon(IdolImagePath[10 - i])
end

-- Load storyboard
DEPLS.StoryboardHandle = noteloader_data:GetStoryboard()

DEPLS.ScoreBase = noteloader_data.scoretap or DEPLS.ScoreBase
DEPLS.Stamina = noteloader_data.staminadisp or DEPLS.Stamina

-- Load cover art
local noteloader_coverdata = noteloader_data:GetCoverArt()
if noteloader_coverdata then
local new_coverdata = {}
Expand Down Expand Up @@ -746,20 +787,6 @@ function DEPLS.Start(argv)
DEPLS.Images.ScoreGauge = AquaShine.LoadImage("assets/image/live/live_gauge_03_02.png")
DEPLS.Images.Pause = AquaShine.LoadImage("assets/image/live/live_pause.png")

-- Load unit icons
local noteloader_units = noteloader_data:GetCustomUnitInformation()
local IdolImagePath = {}
do
local idol_img = AquaShine.LoadConfig("IDOL_IMAGE", "dummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy\tdummy")

for w in idol_img:gmatch("[^\t]+") do
IdolImagePath[#IdolImagePath + 1] = w
end
end
for i = 1, 9 do
DEPLS.IdolImageData[i][1] = noteloader_units[i] or DEPLS.LoadUnitIcon(IdolImagePath[10 - i])
end

-- Load stamina image (bar and number)
DEPLS.Images.StaminaRelated = {
Bar = AquaShine.LoadImage("assets/image/live/live_gauge_02_02.png")
Expand Down Expand Up @@ -999,6 +1026,7 @@ function DEPLS.Draw(deltaT)
if DEPLS.IsLiveEnded() then
Routines.LiveClearAnim.Draw()
else
setColor(255, 255, 255, DEPLS.LiveOpacity)
draw(Images.Pause, 916, 5, 0, 0.6)
end

Expand Down Expand Up @@ -1110,7 +1138,7 @@ function DEPLS.KeyPressed(key, scancode, repeat_bit)
elseif key == "f5" then
DEPLS.BeatmapAudioVolume = math.max(DEPLS.BeatmapAudioVolume - 0.05, 0)
update_audio_volume()
elseif key == "pause" and DEPLS.ElapsedTime > 0 then
elseif key == "pause" and DEPLS.ElapsedTime > 0 and not(DEPLS.IsLiveEnded()) then
DEPLS.Pause()
elseif DEPLS.ElapsedTime >= 0 then
for i = 1, 9 do
Expand Down Expand Up @@ -1177,7 +1205,13 @@ function DEPLS.Exit()
end

function DEPLS.Focus(focus)
if not(AquaShine.IsDesktopSystem()) and focus and DEPLS.Sound.LiveAudio and DEPLS.ElapsedTime >= 0 then
if
not(AquaShine.IsDesktopSystem()) and
not(DEPLS.Routines.PauseScreen.IsPaused()) and
focus and
DEPLS.Sound.LiveAudio and
DEPLS.ElapsedTime >= 0
then
DEPLS.Sound.LiveAudio:seek(DEPLS.ElapsedTime * 0.001)
end
end
Expand Down
1 change: 1 addition & 0 deletions livesim/pause.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function PauseScreen.Draw()

if PauseScreen.Paused <= 3000 then
-- Draw pause counter
love.graphics.setColor(255, 255, 255)
love.graphics.draw(
PauseScreen.Counter[math.max(math.ceil(PauseScreen.Paused * 0.001), 1)],
480, 320, 0, 1.5, 1.5, 18, 19.5
Expand Down
Loading

0 comments on commit 6ed75e4

Please sign in to comment.