Skip to content

Commit 1687c6b

Browse files
committed
Fix some SIF beatmap not recognized
Improved error handling of download module
1 parent 471622d commit 1687c6b

6 files changed

+65
-69
lines changed

AquaShineDownloadThread.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ end)
133133
local command = cin:demand()
134134
while command ~= "QUIT" do
135135
local headers = cin:pop()
136-
local a, b = pcall(request_http, command, headers)
136+
local a, b, c = pcall(request_http, command, headers)
137137

138-
if not(a) then
138+
if not(a) or (a and not(b)) then
139139
cout:push("ERR ")
140-
cout:push(b)
140+
cout:push(a and c or b)
141141
end
142142

143143
command = cin:demand()

beatmap_select.lua

+3-16
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,9 @@ BeatmapSelect.MainUIComposition = AquaShine.Composition.Create {
119119
end
120120
}
121121
),
122-
-- Insert beatmap
123-
BeatmapSelect._Button50ScaleTemplate(736, 8, "Insert Beatmap", function()
124-
if AquaShine.FileSelection then
125-
local list = AquaShine.FileSelection("Insert Beatmap(s)", nil, nil, true)
126-
end
127-
end),
128-
-- Download beatmap
129-
BeatmapSelect._Button50ScaleTemplate(512, 8, "Download Beatmaps", function()
130-
if love.filesystem.isFile("external/download_beatmap.lua") then
131-
AquaShine.LoadEntryPoint("external/download_beatmap.lua")
132-
end
133-
end),
134-
-- Open beatmap directory
135-
BeatmapSelect._Button50ScaleTemplate(64, 592, "Open Beatmap Directory", function()
136-
love.system.openURL("file://"..love.filesystem.getSaveDirectory().."/beatmap")
137-
end),
122+
BeatmapSelect.InsertBeatmapButton,
123+
BeatmapSelect.DownloadBeatmapButton,
124+
BeatmapSelect.OpenBeatmapButton,
138125
-- Page numbering
139126
BeatmapSelect.PageCompositionTable,
140127
{

beatmap_select2.lua

+3-16
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,9 @@ BeatmapSelect.MainUIComposition = AquaShine.Composition.Create {
9595
end
9696
}
9797
),
98-
-- Insert beatmap
99-
BeatmapSelect._Button50ScaleTemplate(736, 8, "Insert Beatmap", function()
100-
if AquaShine.FileSelection then
101-
local list = AquaShine.FileSelection("Insert Beatmap(s)", nil, nil, true)
102-
end
103-
end),
104-
-- Download beatmap
105-
BeatmapSelect._Button50ScaleTemplate(512, 8, "Download Beatmaps", function()
106-
if love.filesystem.isFile("external/download_beatmap.lua") then
107-
AquaShine.LoadEntryPoint("external/download_beatmap.lua")
108-
end
109-
end),
110-
-- Open beatmap directory
111-
BeatmapSelect._Button50ScaleTemplate(64, 592, "Open Beatmap Directory", function()
112-
love.system.openURL("file://"..love.filesystem.getSaveDirectory().."/beatmap")
113-
end),
98+
BeatmapSelect.InsertBeatmapButton,
99+
BeatmapSelect.DownloadBeatmapButton,
100+
BeatmapSelect.OpenBeatmapButton,
114101
BeatmapSelect.PageCompositionTable,
115102
{
116103
image = AquaShine.LoadImage("assets/image/ui/com_win_40.png"),

beatmap_select_common.lua

+43-24
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ local BSCommon = {
1313
CompositionList = {}
1414
}
1515

16+
local function _Button50ScaleTemplate(x, y, text, action)
17+
local select = AquaShine.LoadImage("assets/image/ui/s_button_03.png")
18+
local select_se = AquaShine.LoadImage("assets/image/ui/s_button_03se.png")
19+
local font = AquaShine.LoadFont("MTLmr3m.ttf", 18)
20+
return {
21+
x = x, y = y, w = 216, h = 40,
22+
_drawtext = function(this)
23+
love.graphics.setFont(font)
24+
love.graphics.print(text, 8, 6)
25+
end,
26+
draw = function(this)
27+
love.graphics.setColor(255, 255, 255)
28+
love.graphics.draw(select, 0, 0, 0, 0.5)
29+
return this:_drawtext()
30+
end,
31+
draw_se = function(this)
32+
love.graphics.setColor(255, 255, 255)
33+
love.graphics.draw(select_se, 0, 0, 0, 0.5)
34+
return this:_drawtext()
35+
end,
36+
click = action
37+
}
38+
end
39+
1640
BSCommon.PageCompositionTable = {
1741
x = 64, y = 560, text = "Page 1",
1842
font = BSCommon.SongNameFont,
@@ -73,6 +97,25 @@ BSCommon.RandomTick = {
7397
end
7498
}
7599

100+
-- Insert beatmap
101+
BSCommon.InsertBeatmapButton = _Button50ScaleTemplate(736, 8, "Insert Beatmap", function()
102+
if AquaShine.FileSelection then
103+
local list = AquaShine.FileSelection("Insert Beatmap(s)", nil, nil, true)
104+
end
105+
end)
106+
107+
-- Download beatmap
108+
BSCommon.DownloadBeatmapButton = _Button50ScaleTemplate(512, 8, "Download Beatmaps", function()
109+
if love.filesystem.isFile("external/download_beatmap.lua") then
110+
AquaShine.LoadEntryPoint("external/download_beatmap.lua")
111+
end
112+
end)
113+
114+
-- Open beatmap directory
115+
BSCommon.OpenBeatmapButton = _Button50ScaleTemplate(64, 592, "Open Beatmap Directory", function()
116+
love.system.openURL("file://"..love.filesystem.getSaveDirectory().."/beatmap")
117+
end)
118+
76119
function BSCommon.Update(deltaT)
77120
end
78121

@@ -126,28 +169,4 @@ function BSCommon.KeyReleased(key)
126169
end
127170
end
128171

129-
function BSCommon._Button50ScaleTemplate(x, y, text, action)
130-
local select = AquaShine.LoadImage("assets/image/ui/s_button_03.png")
131-
local select_se = AquaShine.LoadImage("assets/image/ui/s_button_03se.png")
132-
local font = AquaShine.LoadFont("MTLmr3m.ttf", 18)
133-
return {
134-
x = x, y = y, w = 216, h = 40,
135-
_drawtext = function(this)
136-
love.graphics.setFont(font)
137-
love.graphics.print(text, 8, 6)
138-
end,
139-
draw = function(this)
140-
love.graphics.setColor(255, 255, 255)
141-
love.graphics.draw(select, 0, 0, 0, 0.5)
142-
return this:_drawtext()
143-
end,
144-
draw_se = function(this)
145-
love.graphics.setColor(255, 255, 255)
146-
love.graphics.draw(select_se, 0, 0, 0, 0.5)
147-
return this:_drawtext()
148-
end,
149-
click = action
150-
}
151-
end
152-
153172
return BSCommon

livesim2_cliwrap.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
local AquaShine = ...
66
local NoteLoader = AquaShine.LoadModule("note_loader2")
7-
local DEPLS, a = assert(love.filesystem.load(":livesim_main"))(AquaShine)
7+
local DEPLS, a = assert(love.filesystem.load("livesim.lua"))(AquaShine)
88
local DEPLS_Start = DEPLS.Start
99

1010
function DEPLS.Start(arg)

noteloader/json_sif.lua

+12-9
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ return function(sif, file)
3939
local this = setmetatable({}, SIFBeatmap)
4040
assert(not(sif.song_info), "Not a valid SIF beatmap")
4141

42-
if sif.response_data and sif.response_data.live_info and sif.response_data.rank_info then
42+
if sif.response_data and sif.response_data.live_info then
4343
sif = sif.response_data
4444

45-
if sif.live_info and sif.rank_info then
45+
if sif.live_info then
4646
-- Captured version
47-
table.sort(sif.rank_info, function(a, b) return a.rank > b.rank end)
4847
table.sort(sif.live_info[1].notes_list, function(a, b)
4948
return a.timing_sec < b.timing_sec
5049
end)
5150

5251
this.notes_list = sif.live_info[1].notes_list
53-
this.score = {
54-
sif.rank_info[2].rank_min,
55-
sif.rank_info[3].rank_min,
56-
sif.rank_info[4].rank_min,
57-
sif.rank_info[5].rank_min
58-
}
52+
53+
if sif.rank_info then
54+
table.sort(sif.rank_info, function(a, b) return a.rank > b.rank end)
55+
this.score = {
56+
sif.rank_info[2].rank_min,
57+
sif.rank_info[3].rank_min,
58+
sif.rank_info[4].rank_min,
59+
sif.rank_info[5].rank_min
60+
}
61+
end
5962
end
6063
elseif #sif > 0 then
6164
this.notes_list = sif

0 commit comments

Comments
 (0)