204 lines
6.5 KiB
Lua
204 lines
6.5 KiB
Lua
|
|
local logging = require("modules.logging")
|
|
local files = require("modules.files")
|
|
local json = require("modules.json")
|
|
|
|
local text = {}
|
|
text.__index = text
|
|
|
|
function text:Move(position)
|
|
for index, tex in next, self.text do
|
|
tex.position = Vector2(position.x + 30 * (index - 1), position.y)
|
|
end
|
|
self.position = position
|
|
end
|
|
|
|
local function createFunkinNumbers(number, position, layer)
|
|
local list = setmetatable({
|
|
text = {},
|
|
position = position
|
|
}, text)
|
|
local str = tostring(number)
|
|
|
|
for i = 1, #str do
|
|
local l = str:sub(i, i)
|
|
|
|
local newText = Rect("sprites/resultScreen/tallieNumber.png", "sprites/resultScreen/tallieNumber.json")
|
|
newText:Frame(string.format("%s small", l), 0)
|
|
newText.position = Vector2(position.x + 30 * (i - 1), position.y)
|
|
newText.layer = layer - (i / 200)
|
|
newText.modifier = 0
|
|
|
|
list.text[i] = newText
|
|
end
|
|
|
|
return list
|
|
end
|
|
|
|
local evilText
|
|
|
|
return function(score, accuracy, ratings, combo)
|
|
local soundSystem
|
|
local rantingPopin
|
|
|
|
local rankingWindows = {
|
|
{
|
|
name = "GOOD",
|
|
window = 40,
|
|
animation = ""
|
|
},
|
|
{
|
|
name = "GREAT",
|
|
window = 50,
|
|
animation = ""
|
|
},
|
|
{
|
|
name = "EXCELLENT",
|
|
window = 70,
|
|
animation = ""
|
|
},
|
|
{
|
|
name = "PERFECT",
|
|
window = 90,
|
|
animation = ""
|
|
},
|
|
{
|
|
name = "PERFECTGOLD",
|
|
window = 100,
|
|
animation = ""
|
|
},
|
|
}
|
|
|
|
local state = {}
|
|
|
|
function state.update(dt)
|
|
render.updateSprites(dt)
|
|
end
|
|
|
|
function state.keypressed(key, un, is)
|
|
if key == "return" then
|
|
state.changeState("freeplaystate")
|
|
end
|
|
end
|
|
|
|
function state.load()
|
|
if love.graphics.getWidth() ~= 1280 then
|
|
love.window.setMode(1280, 720, { fullscreen = false, resizable = false, centered = true, borderless = false })
|
|
end
|
|
|
|
local rank = "LOSS"
|
|
local animation = "LOSS animation"
|
|
|
|
for index, newRank in next, rankingWindows do
|
|
if accuracy >= newRank.window then
|
|
rank = newRank.name
|
|
end
|
|
end
|
|
|
|
soundSystem = Sprite("sprites/resultScreen/soundSystem.png", "sprites/resultScreen/soundSystem.json")
|
|
soundSystem:PlayAnimation("sound system", 24, false)
|
|
soundSystem.position = Vector2(0, -200)
|
|
soundSystem.layer = 10
|
|
soundSystem.modifier = 0
|
|
|
|
rantingPopin = Sprite("sprites/resultScreen/ratingsPopin.png", "sprites/resultScreen/ratingsPopin.json")
|
|
rantingPopin.position = Vector2(-120, 140)
|
|
rantingPopin.layer = 11
|
|
rantingPopin:PlayAnimation("Categories", 24, false)
|
|
rantingPopin.modifier = 0
|
|
|
|
local scorePopin = Sprite("sprites/resultScreen/scorePopin.png", "sprites/resultScreen/scorePopin.json")
|
|
scorePopin.position = Vector2(-200, 500)
|
|
scorePopin.layer = 12
|
|
scorePopin:PlayAnimation("tally score", 24, false)
|
|
scorePopin.modifier = 0
|
|
|
|
local top = Image("sprites/resultScreen/topBarBlack.png", 0)
|
|
top.layer = 6
|
|
|
|
local resultsLabel = Sprite("sprites/resultScreen/results.png", "sprites/resultScreen/results.json")
|
|
resultsLabel.position = Vector2(-200)
|
|
resultsLabel.layer = 12
|
|
resultsLabel:PlayAnimation("results instance 1", 24, false)
|
|
resultsLabel.modifier = 0
|
|
|
|
|
|
local total = 0
|
|
|
|
for index, notes in next, ratings do
|
|
total = total + notes
|
|
end
|
|
|
|
local totalText = createFunkinNumbers(total, Vector2(330, 150), 30)
|
|
local comboText = createFunkinNumbers(combo, Vector2(330, 210), 30)
|
|
|
|
local sick = createFunkinNumbers(ratings.sick, Vector2(210, 270), 30)
|
|
local good = createFunkinNumbers(ratings.good, Vector2(190, 330), 30)
|
|
local bad = createFunkinNumbers(ratings.bad, Vector2(160, 390), 30)
|
|
local shit = createFunkinNumbers(ratings.shit, Vector2(170, 440), 30)
|
|
local miss = createFunkinNumbers(ratings.miss, Vector2(230, 500), 30)
|
|
|
|
local info = json.parse(files.read_file(string.format("resultScreens/%s.json", curChar)))
|
|
|
|
for index, evil in next, info.results[string.lower(rank)] do
|
|
if evil.renderType == "animateatlas" then
|
|
local atlas = Atlas(evil.assetPath)
|
|
atlas.layer = evil.zIndex - 900
|
|
atlas.position = Vector2(evil.offsets.x, evil.offsets.y)
|
|
atlas:PlayAnimation()
|
|
atlas.modifier = 0
|
|
elseif evil.renderType == "sparrow" then
|
|
local sprite = Sprite(evil.assetPath .. ".png", evil.assetPath .. ".json")
|
|
sprite.layer = evil.zIndex - 900
|
|
sprite.position = Vector2(evil.offsets.x, evil.offsets.y)
|
|
sprite.modifier = 0
|
|
local anim
|
|
for name, quad in next, sprite.quads do
|
|
print(name)
|
|
anim = name
|
|
break
|
|
end
|
|
---@diagnostic disable-next-line: param-type-mismatch
|
|
sprite:PlayAnimation(anim, 24, true)
|
|
end
|
|
end
|
|
|
|
score = tostring(score)
|
|
|
|
local numbers = {
|
|
"ZERO",
|
|
"ONE",
|
|
"TWO",
|
|
"THREE",
|
|
"FOUR",
|
|
"FIVE",
|
|
"SIX",
|
|
"SEVEN",
|
|
"EIGHT",
|
|
"NINE",
|
|
}
|
|
|
|
for i = 0, 9 do
|
|
local letter = i <= score:len() and tonumber(score:sub(score:len() - i, score:len() - i)) or 0
|
|
|
|
local resultsLabel = Sprite("sprites/resultScreen/score-digital-numbers.png", "sprites/resultScreen/score-digital-numbers.json")
|
|
resultsLabel.position = Vector2(-200)
|
|
resultsLabel.layer = 15
|
|
resultsLabel:PlayAnimation(string.format("%s DIGITAL", numbers[letter + 1]), 24, false)
|
|
resultsLabel.modifier = 0
|
|
resultsLabel.position = Vector2(600 - (60 * i), 600)
|
|
resultsLabel.frame = 1
|
|
end
|
|
|
|
render.cameraPosition = Vector2()
|
|
end
|
|
|
|
function state.draw()
|
|
love.graphics.clear({ 1, 0.96470588235, 0.60784313725 })
|
|
render.drawSprites()
|
|
render.drawUI()
|
|
end
|
|
|
|
return state
|
|
end
|