+ timing bars to result screen

This commit is contained in:
FajsiEx 2021-07-27 23:54:17 +02:00
parent cce79649e1
commit b252d801ed
1 changed files with 85 additions and 77 deletions

View File

@ -28,26 +28,16 @@ local RIGHT_PANEL_TRANSTION_ENTER_OFFSET = 128;
local BOTTOM_PANEL_TRANSTION_ENTER_OFFSET = 128; local BOTTOM_PANEL_TRANSTION_ENTER_OFFSET = 128;
local earlyLateBarsStats = { local earlyLateBarsStats = {
earlyErrors = 0; earlyErrors = 0,
earlyNears = 0; earlyNears = 0,
criticals = 0; criticals = 0,
lateNears = 0; lateNears = 0,
lateErrors = 0; lateErrors = 0
}; };
local objectTypeTimingStats = { local objectTypeTimingStats = {
chip = { chip = {criticals = 0, nears = 0, errors = 0},
criticals = 0, long = {criticals = 0, errors = 0},
nears = 0, vol = {criticals = 0, errors = 0}
errors = 0,
},
long = {
criticals = 0,
errors = 0,
},
vol = {
criticals = 0,
errors = 0,
},
} }
game.LoadSkinSample("result") game.LoadSkinSample("result")
@ -68,6 +58,22 @@ local handleSfx = function()
if game.GetButton(game.BUTTON_BCK) then game.StopSample("result") end if game.GetButton(game.BUTTON_BCK) then game.StopSample("result") end
end end
function drawTimingBar(y, value, max, type)
gfx.BeginPath();
if type == 'crit' then
gfx.FillColor(253,243,24,255);
elseif type == 'early' then
gfx.FillColor(215,48,182,255);
elseif type == 'late' then
gfx.FillColor(46,211,241,255);
end
gfx.Rect(rightPanelX+695,rightPanelY+y,256*(value/max), 8);
gfx.Fill();
gfx.ClosePath();
end
local drawTopBar = function() local drawTopBar = function()
gfx.BeginPath(); gfx.BeginPath();
local tw, th = gfx.ImageSize(topBarImage); local tw, th = gfx.ImageSize(topBarImage);
@ -75,23 +81,15 @@ local drawTopBar = function()
topBarImage, 1, 0); topBarImage, 1, 0);
end end
local drawRightPanel = function() local drawRightPanel = function()
gfx.BeginPath(); gfx.BeginPath();
local tw, th = gfx.ImageSize(rightPanelImage); local tw, th = gfx.ImageSize(rightPanelImage);
gfx.ImageRect( gfx.ImageRect(rightPanelX, rightPanelY, tw, th, rightPanelImage,
rightPanelX, Easing.outQuad(transitionEnterScale), 0);
rightPanelY,
tw,
th,
rightPanelImage,
Easing.outQuad(transitionEnterScale),
0
);
end end
local drawRightPanelContent = function () local drawRightPanelContent = function()
-- Draw song name and artist -- Draw song name and artist
gfx.FontSize(28) gfx.FontSize(28)
@ -104,17 +102,35 @@ local drawRightPanelContent = function ()
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE) gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)
gfx.LoadSkinFont('Digital-Serial-Bold.ttf') gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.Text(earlyLateBarsStats.earlyErrors, rightPanelX + 683, rightPanelY + 370); gfx.Text(earlyLateBarsStats.earlyErrors, rightPanelX + 683,
rightPanelY + 370);
gfx.Text(earlyLateBarsStats.earlyNears, rightPanelX + 683, rightPanelY + 401); gfx.Text(earlyLateBarsStats.earlyNears, rightPanelX + 683, rightPanelY + 401);
gfx.Text(earlyLateBarsStats.criticals, rightPanelX + 683, rightPanelY + 432); gfx.Text(earlyLateBarsStats.criticals, rightPanelX + 683, rightPanelY + 432);
gfx.Text(earlyLateBarsStats.lateNears, rightPanelX + 683, rightPanelY + 463); gfx.Text(earlyLateBarsStats.lateNears, rightPanelX + 683, rightPanelY + 463);
gfx.Text(earlyLateBarsStats.lateErrors, rightPanelX + 683, rightPanelY + 494); gfx.Text(earlyLateBarsStats.lateErrors, rightPanelX + 683, rightPanelY + 494);
-- Draw hit timing bars
local totalHits = earlyLateBarsStats.earlyErrors +
earlyLateBarsStats.earlyNears +
earlyLateBarsStats.criticals +
earlyLateBarsStats.lateNears +
earlyLateBarsStats.lateErrors
gfx.Save()
drawTimingBar(365, earlyLateBarsStats.earlyErrors, totalHits, 'early')
drawTimingBar(396, earlyLateBarsStats.earlyNears, totalHits, 'early')
drawTimingBar(427, earlyLateBarsStats.criticals, totalHits, 'crit')
drawTimingBar(458, earlyLateBarsStats.lateNears, totalHits, 'late')
drawTimingBar(489, earlyLateBarsStats.lateErrors, totalHits, 'late')
gfx.Restore()
-- Draw hit stats based on objects -- Draw hit stats based on objects
-- CHIP -- CHIP
gfx.Text(objectTypeTimingStats.chip.criticals, rightPanelX + 255, rightPanelY + 365); gfx.Text(objectTypeTimingStats.chip.criticals, rightPanelX + 255,
gfx.Text(objectTypeTimingStats.chip.nears, rightPanelX + 255, rightPanelY + 395); rightPanelY + 365);
gfx.Text(objectTypeTimingStats.chip.errors, rightPanelX + 255, rightPanelY + 425); gfx.Text(objectTypeTimingStats.chip.nears, rightPanelX + 255,
rightPanelY + 395);
gfx.Text(objectTypeTimingStats.chip.errors, rightPanelX + 255,
rightPanelY + 425);
-- LONG -- LONG
gfx.Text('???', rightPanelX + 333, rightPanelY + 365); gfx.Text('???', rightPanelX + 333, rightPanelY + 365);
gfx.Text('-', rightPanelX + 333, rightPanelY + 395); gfx.Text('-', rightPanelX + 333, rightPanelY + 395);
@ -128,47 +144,27 @@ local drawRightPanelContent = function ()
gfx.Text(result.maxCombo, rightPanelX + 371, rightPanelY + 466); gfx.Text(result.maxCombo, rightPanelX + 371, rightPanelY + 466);
end end
local drawBottomPanel = function () local drawBottomPanel = function()
gfx.BeginPath(); gfx.BeginPath();
local tw, th = gfx.ImageSize(bottomPanelImage); local tw, th = gfx.ImageSize(bottomPanelImage);
gfx.ImageRect( gfx.ImageRect(0, 1110 + (BOTTOM_PANEL_TRANSTION_ENTER_OFFSET *
0, (1 - Easing.outQuad(transitionEnterScale))), tw, th,
1110+(BOTTOM_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))), bottomPanelImage, Easing.outQuad(transitionEnterScale), 0);
tw,
th,
bottomPanelImage,
Easing.outQuad(transitionEnterScale),
0
);
end end
local drawJacketPanel = function() local drawJacketPanel = function()
gfx.BeginPath(); gfx.BeginPath();
local tw, th = gfx.ImageSize(jacketPanelImage); local tw, th = gfx.ImageSize(jacketPanelImage);
gfx.ImageRect( gfx.ImageRect(jacketPanelX, jacketPanelY, tw, th, jacketPanelImage,
jacketPanelX, Easing.outQuad(transitionEnterScale), 0);
jacketPanelY,
tw,
th,
jacketPanelImage,
Easing.outQuad(transitionEnterScale),
0
);
end end
local drawJacketPanelContent = function () local drawJacketPanelContent = function()
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect( gfx.ImageRect(jacketPanelX + 12, jacketPanelY + 26, 273, 273, jacketImage,
jacketPanelX+12, Easing.outQuad(transitionEnterScale), 0);
jacketPanelY+26,
273,
273,
jacketImage,
Easing.outQuad(transitionEnterScale),
0
);
end end
local tickTransitions = function(deltaTime) local tickTransitions = function(deltaTime)
@ -179,11 +175,14 @@ local tickTransitions = function(deltaTime)
transitionEnterScale = 1 transitionEnterScale = 1
end end
rightPanelX = 0+(RIGHT_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))) rightPanelX = 0 +
jacketPanelX = 40 + (JACKET_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))) (RIGHT_PANEL_TRANSTION_ENTER_OFFSET *
(1 - Easing.outQuad(transitionEnterScale)))
jacketPanelX = 40 + (JACKET_PANEL_TRANSTION_ENTER_OFFSET *
(1 - Easing.outQuad(transitionEnterScale)))
end end
result_set = function () result_set = function()
if result.jacketPath ~= nil and result.jacketPath ~= "" then if result.jacketPath ~= nil and result.jacketPath ~= "" then
jacketImage = gfx.CreateImage(result.jacketPath, 0) jacketImage = gfx.CreateImage(result.jacketPath, 0)
end end
@ -193,29 +192,38 @@ result_set = function ()
local hitStat = result.noteHitStats[hitStatIndex]; local hitStat = result.noteHitStats[hitStatIndex];
if (hitStat.rating == 0) then -- Miss if (hitStat.rating == 0) then -- Miss
objectTypeTimingStats.chip.errors = objectTypeTimingStats.chip.errors + 1; objectTypeTimingStats.chip.errors =
objectTypeTimingStats.chip.errors + 1;
if hitStat.delta < 0 then if hitStat.delta < 0 then
earlyLateBarsStats.earlyErrors = earlyLateBarsStats.earlyErrors + 1; earlyLateBarsStats.earlyErrors =
earlyLateBarsStats.earlyErrors + 1;
else else
earlyLateBarsStats.lateErrors = earlyLateBarsStats.lateErrors + 1; earlyLateBarsStats.lateErrors =
earlyLateBarsStats.lateErrors + 1;
end end
elseif hitStat.rating == 1 then elseif hitStat.rating == 1 then
objectTypeTimingStats.chip.nears = objectTypeTimingStats.chip.nears + 1; objectTypeTimingStats.chip.nears =
objectTypeTimingStats.chip.nears + 1;
if hitStat.delta < 0 then if hitStat.delta < 0 then
earlyLateBarsStats.earlyNears = earlyLateBarsStats.earlyNears + 1; earlyLateBarsStats.earlyNears =
earlyLateBarsStats.earlyNears + 1;
else else
earlyLateBarsStats.lateNears = earlyLateBarsStats.lateNears + 1; earlyLateBarsStats.lateNears = earlyLateBarsStats.lateNears + 1;
end end
else else
objectTypeTimingStats.chip.criticals = objectTypeTimingStats.chip.criticals + 1; objectTypeTimingStats.chip.criticals =
objectTypeTimingStats.chip.criticals + 1;
end end
end end
-- misses on LONGs or LAZERs are automatically late errors -- misses on LONGs or LAZERs are automatically late errors
-- so we add errors that are not ealy or late to late errors -- so we add errors that are not ealy or late to late errors
earlyLateBarsStats.lateErrors = earlyLateBarsStats.lateErrors + (result.misses - earlyLateBarsStats.lateErrors - earlyLateBarsStats.earlyErrors) earlyLateBarsStats.lateErrors = earlyLateBarsStats.lateErrors +
(result.misses -
earlyLateBarsStats.lateErrors -
earlyLateBarsStats.earlyErrors)
-- criticals are same for all objects so we just copy them from results -- criticals are same for all objects so we just copy them from results
earlyLateBarsStats.criticals = result.perfects earlyLateBarsStats.criticals = result.perfects