Skip to content

Commit

Permalink
Fixed unit editor
Browse files Browse the repository at this point in the history
- It's still possible to revert changes after pressing "OK"

CBF unit loading now also looks at `unit_icon` folder if none found in CBF folder

It's now possible to quit Live Simulator: 2 by pressing "Back" button in Android (or ESC in desktop)
  • Loading branch information
MikuAuahDark committed May 19, 2017
1 parent f29dff0 commit b1d11ad
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- Since AquaShine is special for Live Simulator: 2, it's not available as standalone Lua script.
-- Please see docs/AquaShine.md for more information.

DEPLS_VERSION = "1.0.1-pre1"
DEPLS_VERSION = "1.0.1"

----------------------
-- AquaShine loader --
Expand Down
6 changes: 6 additions & 0 deletions main_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ function MainMenu.MouseReleased(x, y)
end
end

function MainMenu.KeyReleased(key, scancode)
if key == "escape" then
love.event.quit()
end
end

return MainMenu, "Main Menu"
50 changes: 31 additions & 19 deletions noteloader/load_cbf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,37 +374,49 @@ function CBFBeatmap.Load(file)

if love.filesystem.isFile(charposname) then
-- Initialize units image
if not(LoadUnitStrategy1(file) or LoadUnitStrategy2(file)) then
-- If loading from "Cards" folder and "Custom Cards" folder fails,
-- Load in current beatmap directory instead
setmetatable(UnitIconCache, {
__index = function(_, var)
local name = file[1].."/"..var..".png"
if not(LoadUnitStrategy1(file)) then
LoadUnitStrategy2(file)
end

-- If loading from "Cards" folder and "Custom Cards" folder fails,
-- Load in current beatmap directory instead or in unit_icon folder
local index_name = getmetatable(UnitIconCache).__index
setmetatable(UnitIconCache, {
__index = function(_, var)
if index_name then
local ret = index_name(_, var)

if love.filesystem.isFile(name) then
local x = love.graphics.newImage(name)

UnitIconCache[var] = x
return x
if ret then
return ret
end

return nil
end
})
end

local name = file[1].."/"..var..".png"
local name2 = "unit_icon/"..var..".png"
local x = nil

if love.filesystem.isFile(name) then
x = love.graphics.newImage(name)
elseif love.filesystem.isFile(name2) then
x = love.graphics.newImage(name2)
end

UnitIconCache[var] = x
return x
end
})


local i = 10
for line in love.filesystem.lines(charposname) do
if #line > 0 then
i = i - 1

local cache_name = line:sub(line:find("/") + 1)
local pos, attr, rar, cname, r, g, b = line:match("([^/]+)/([^/]+)/([^/]+)/([^/]*)/(%d+%.?%d*),(%d+%.?%d*),(%d+%.?%d*)/")
local i = assert(position_translation[pos])

if CompositionCache[cache_name] then
units[i] = CompositionCache[cache_name]
has_custom_units = true
else
local attr, rar, cname, r, g, b = line:match("[^/]+/([^/]+)/([^/]+)/([^/]*)/(%d+%.?%d*),(%d+%.?%d*),(%d+%.?%d*)/")
local a = ComposeUnitImage(attr, rar, cname, r, g, b)

units[i] = a
Expand Down
2 changes: 1 addition & 1 deletion unit_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ local function applyChanges()

for i = 9, 1, -1 do
filelist[#filelist + 1] = (UnitEditor.State.Changed[i] or UnitEditor.State[i]).Filename
UnitEditor.State[i] = UnitEditor.State.Changed[i] or UnitEditor.State[i]
end

AquaShine.SaveConfig("IDOL_IMAGE", table.concat(filelist, "\t"))
print("Units saved")
end

function UnitEditor.Start(arg)
Expand Down

0 comments on commit b1d11ad

Please sign in to comment.