Skip to content

Commit

Permalink
Fixed stamina and score per tap config ignored
Browse files Browse the repository at this point in the history
- Result in 0 stamina and 0 score per tap if there's no per-beatmap stamina and score per tap

Make `UseZeroToOneColorRange` affects other functions

- `SetUnitOpacity`, `SetLiveOpacity`, and `SetBackgroundDimOpacity`

Storyboard: Make aliased functions

- `DrawObject` = `love.graphics.draw`

- `PrintText` = `love.graphics.print`

- `SetColor` = `love.graphics.setColor`

- `LoadShader` = `love.graphics.newShader`

- `LoadFont` = `love.graphics.newFont`

Fixed again background detection
  • Loading branch information
MikuAuahDark committed Dec 2, 2017
1 parent b9f99f3 commit f4a5958
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions docs/Storyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ take LOVE 0.11.x color range changes into account.

> This function can only be called inside, or before `Initialize` function.
> This function also affects `SetUnitOpacity`, `SetLiveOpacity`, and `SetBackgroundDimOpacity` color range to be 0..1
*************************************************

### `void AddScore(number score)`
Expand Down
37 changes: 22 additions & 15 deletions livesim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ local DEPLS = {
CoverShown = 0, -- Cover shown if this value starts at 3167
CoverData = {},

BackgroundOpacity = 1, -- User background opacity set from storyboard
DefaultColorMode = 255, -- Color range
BackgroundOpacity = 1, -- User background opacity set from storyboard
BackgroundImage = { -- Index 0 is the main background
-- {handle, logical x, logical y, x size, y size}
{nil, -88, 0},
Expand Down Expand Up @@ -214,16 +215,16 @@ end
--! @brief Sets foreground live opacity
--! @param opacity Transparency. 255 = opaque, 0 = invisible
function DEPLS.StoryboardFunctions.SetLiveOpacity(opacity)
opacity = math.max(math.min(opacity or 255, 255), 0)
DEPLS.LiveOpacity = opacity / 255
opacity = math.max(math.min(opacity or DEPLS.DefaultColorMode, DEPLS.DefaultColorMode), 0)
DEPLS.LiveOpacity = opacity / DEPLS.DefaultColorMode
end

--! @brief Sets background blackness
--! @param opacity Transparency. 0 = full black, 255 = full light
function DEPLS.StoryboardFunctions.SetBackgroundDimOpacity(opacity)
opacity = math.max(math.min(opacity or 255, 255), 0)
opacity = math.max(math.min(opacity or DEPLS.DefaultColorMode, DEPLS.DefaultColorMode), 0)

DEPLS.BackgroundOpacity = 1 - opacity / 255
DEPLS.BackgroundOpacity = 1 - opacity / DEPLS.DefaultColorMode
end

--! @brief Gets current elapsed time
Expand Down Expand Up @@ -277,13 +278,8 @@ end
--! @param pos The unit position (9 is leftmost)
--! @param opacity The desired opacity. 0 is fully transparent, 255 is fully opaque (255 default)
function DEPLS.StoryboardFunctions.SetUnitOpacity(pos, opacity)
local data = DEPLS.IdolImageData[pos]

if data == nil then
error("Invalid pos specificed")
end

data[2] = math.min(math.max(opacity or 255, 0), 255)
local data = assert(DEPLS.IdolImageData[pos], "Invalid pos specificed")
data[2] = math.min(math.max(opacity or DEPLS.DefaultColorMode, 0), DEPLS.DefaultColorMode)
end

do
Expand Down Expand Up @@ -511,6 +507,11 @@ function DEPLS.StoryboardFunctions.IsRandomMode()
return not(not(DEPLS.NoteRandomized))
end

--! Internal function
function DEPLS.StoryboardFunctions._SetColorRange(r)
DEPLS.DefaultColorMode = r
end

-----------------------------
-- The Live simuator logic --
-----------------------------
Expand Down Expand Up @@ -618,7 +619,7 @@ function DEPLS.Start(argv)
-- Load tap sound. High priority
local se_volume = AquaShine.LoadConfig("SE_VOLUME", 80) * 0.008
DEPLS.Sound.PerfectTap = AquaShine.GetCachedData("sound/SE_306.ogg", love.audio.newSource, "sound/SE_306.ogg", "static")
DEPLS.Sound.PerfectTap:setVolume(se_volume)
DEPLS.Sound.PerfectTap:setVolume(se_volume * (DEPLS.RenderingMode and 0.5 or 1))
DEPLS.Sound.GreatTap = AquaShine.GetCachedData("sound/SE_307.ogg", love.audio.newSource, "sound/SE_307.ogg", "static")
DEPLS.Sound.GreatTap:setVolume(se_volume)
DEPLS.Sound.GoodTap = AquaShine.GetCachedData("sound/SE_308.ogg", love.audio.newSource, "sound/SE_308.ogg", "static")
Expand Down Expand Up @@ -671,8 +672,14 @@ function DEPLS.Start(argv)
local custom_background = false
DEPLS.Sound.BeatmapAudio = noteloader_data:GetBeatmapAudio()
DEPLS.Sound.LiveClear = noteloader_data:GetLiveClearSound()
DEPLS.ScoreBase = noteloader_data:GetScorePerTap() or DEPLS.ScoreBase
DEPLS.Stamina = noteloader_data:GetStamina() or DEPLS.Stamina

if noteloader_data:GetScorePerTap() > 0 then
DEPLS.ScoreBase = noteloader_data:GetScorePerTap()
end

if noteloader_data:GetStamina() > 0 then
DEPLS.Stamina = noteloader_data:GetStamina()
end

-- Load modules
DEPLS.NoteManager = assert(love.filesystem.load("note.lua"))(DEPLS, AquaShine)
Expand Down
7 changes: 7 additions & 0 deletions luastoryboard2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ local function setup_env(story, lua)
return nil
end,
DrawObject = love.graphics.draw,
DrawRectangle = love.graphics.rectangle,
PrintText = love.graphics.print,
SetColor = love.graphics.setColor,
SetFont = love.graphics.setFont,
LoadShader = love.graphics.newShader,
LoadFont = function(path, size)
if not(path) then
Expand Down Expand Up @@ -218,8 +222,11 @@ local function setup_env(story, lua)
AquaShine.Log("storyboard", table.concat(a, "\t"))
end
env.UseZeroToOneColorRange = function()
story.AdditionalFunctions._SetColorRange(1)
env.love.graphics.setColor = love.graphics.setColor
env.SetColor = love.graphics.setColor
end
env._SetColorRange = nil -- Internal function @ livesim.lua

setfenv(lua, env)

Expand Down
7 changes: 4 additions & 3 deletions noteloader/load_depls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,19 @@ function DEPLSBeatmap.GetCustomBackground(this)

for i = 1, 4 do
bgname = this.project_dir.."/background-"..i..ext
local bginfo = love.filesystem.getInfo(bgname)

if love.filesystem.isFile(bgname) then
if bginfo and bginfo.type == "file" then
this.background[i] = love.graphics.newImage(bgname)
end
end

if not(this.background[1]) or not(this.background[2]) then
if not(this.background[1]) ~= not(this.background[2]) then
AquaShine.Log("NoteLoader2/load_depls", "Non-balanced background (only contain left or right part). Removed")
this.background[1], this.background[2] = nil, nil
end

if not(this.background[3]) or not(this.background[4]) then
if not(this.background[3]) ~= not(this.background[4]) then
AquaShine.Log("NoteLoader2/load_depls", "Non-balanced background (only contain top or bottom part). Removed")
this.background[3], this.background[4] = nil, nil
end
Expand Down
1 change: 1 addition & 0 deletions render_livesim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ function RenderMode.Start(arg)
RenderMode.DEPLS.MinimalEffect = false
RenderMode.DEPLS.Start({arg[3], arg[4]})
RenderMode.DEPLS.AutoPlay = true
RenderMode.DEPLS.Sound.LiveAudio:setVolume(1.6)

-- Image formats
if AquaShine.GetCommandLineConfig("tga") then
Expand Down

0 comments on commit f4a5958

Please sign in to comment.