ExperimentalGear/scripts/gameplay/banner.lua

237 lines
7.7 KiB
Lua

local Charting = require('common.charting');
local volforceWindow = require("components.volforceWindow")
local DiffRectangle = require('components.diff_rectangle');
local bannerBaseImage = gfx.CreateSkinImage("gameplay/banner/base.png", 0)
--portrait version images
local multi_bottom = gfx.CreateSkinImage("gameplay/banner/scoreboard/base.png", 0)
local multi_top = gfx.CreateSkinImage("result/banner/scoreboard/top.png", 0)
local pos = {
gfx.CreateSkinImage("result/multi_4p/pos/1.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/2.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/3.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/4.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/5.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/6.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/7.png", 0),
gfx.CreateSkinImage("result/multi_4p/pos/8.png", 0),
}
local desw = 1080
local desh = 1920
local BANNER_W = 1080;
local BANNER_H = 368;
local draw_landscape_board = function(users, currentUserId, diff, level)
if (users == nil) then
return
end
adjustedDiff = Charting.GetDisplayDifficulty(gameplay.jacketPath, diff)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(32)
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
for i, u in ipairs(users) do
local x = (desw/2)+325;
local basey = 120;
local y = basey + i * 10;
gfx.FontSize(13);
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE);
gfx.Text(string.format("%04d", math.floor(u.score / 10000)), x + 20, y);
local lastFourDigits = ((u.score / 10000) - math.floor(u.score / 10000)) * 10000
gfx.FontSize(11);
gfx.Text(string.format("%04d", math.floor(lastFourDigits)), x + 20 + (58 / 2), y + 0.5);
gfx.FontSize(13);
gfx.Scissor(x + 90, y - 10, 49, 20);
gfx.Text(string.upper(u.name), x + 90, y);
gfx.ResetScissor();
--DiffRectangle.render(deltaTime, x + 145, y - 7.5, 0.84 / 2, adjustedDiff, level);
-- lined out until tcp thing
end
end
local draw_portrait_board = function(users, currentUserId, diff, level)
if (users == nil) then
return
end
adjustedDiff = Charting.GetDisplayDifficulty(gameplay.jacketPath, diff)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(32)
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
for i, u in ipairs(users) do
go_away = 0
local make_room_x, make_room_y = gfx.ImageSize(multi_bottom)
if (u.id == user_id) then
return
elseif i == 2 then
go_away = make_room_x
elseif i == 3 then
go_away = 16
elseif i == 4 then
go_away = make_room_x + make_room_x
elseif i >= 5 then
go_away = -500
end
local posUPWidth ,posUPHeight = gfx.ImageSize(multi_bottom)
numberx = posUPWidth;
number_y = -posUPHeight + 35;
local offset_y = 2;
local base_x = 19;
local offset_x = base_x + i * 2;
local number_pos_x = 185
-- Get Bottom Layer Image for Multi Mode
gfx.BeginPath()
gfx.ImageRect(offset_x + go_away, offset_y, posUPWidth, posUPHeight, multi_bottom, 1, 0)
-- Get Player Portrait
-- gfx.BeginPath();
-- gfx.ImageRect(offset_x - 5 + go_away, offset_y, posUPWidth, posUPWidth / 1.825, img_string, 1, 0);
-- Get Top Layer Image for Multi Mode
-- local posDWWidth, posDWHeight = gfx.ImageSize(UsTop)
-- gfx.BeginPath()
-- gfx.ImageRect(offset_x + go_away, offset_y,posDWWidth/1.75,posDWHeight/1.75,UsTop,1,0)
-- Get AppealCard
-- gfx.BeginPath();
-- gfx.ImageRect(offset_x + 20 + go_away, offset_y + 32, 103 / 1.17, 132 / 1.17, appeal_string, 1, 0);
-- Get Dan Badge
-- gfx.BeginPath();
-- gfx.ImageRect(offset_x + 132 + go_away, offset_y + 118, 107 / 1.17, 29 / 1.17, badge_string, 1, 0);
-- 1st,2nd,3rd... Placements
local posWidth, posHeight = gfx.ImageSize(pos[i])
gfx.BeginPath()
gfx.ImageRect(offset_x + 220 + go_away, offset_y + 40, posWidth / 1.17, posHeight / 1.17, pos[i], 1, 0)
-- Get The Name
gfx.BeginPath()
gfx.FontSize(26)
gfx.Text(string.upper(u.name), offset_x + 52 + go_away, offset_y + 173)
-- Volforce
-- volforceWindow.render(0, offset_x + 230 + go_away, offset_y + 108, 42, force_string, true, false, false)
-- gfx.BeginPath()
-- gfx.ImageRect(offset_x + go_away + 244.5, offset_y + 145, 42 * 1.4, 42 * 1.4, force_img_string, 1, 0)
-- and stars
-- vf_star = gfx.CreateSkinImage("volforce/stars/" .. star_type .. ".png", 1)
--[[
for i = 1, star_count do
divider = 0
if star_count == 1 then
divider = 18
gfx.BeginPath();
gfx.ImageRect(offset_x + go_away + 250.5 + divider + (i - 1) * divider, offset_y + 190, 42 / 4, 42 / 4,
vf_star, 1
, 0);
elseif star_count == 2 then
divider = 13
gfx.BeginPath();
gfx.ImageRect(offset_x + go_away + 250 + divider + (i - 1) * (divider - 2), offset_y + 190, 42 / 4, 42 / 4
,
vf_star, 1, 0);
elseif star_count == 3 then
divider = 8.25
gfx.BeginPath();
gfx.ImageRect(offset_x + go_away + 250 + divider + (i - 1) * (divider + 2), offset_y + 190, 42 / 4, 42 / 4
,
vf_star, 1, 0);
elseif star_count == 4 then
divider = 5
gfx.BeginPath();
gfx.ImageRect(offset_x + go_away + 250 + (divider - 1) + (i - 1) * (divider + 5), offset_y + 190, 42 / 4,
42 / 4,
vf_star, 1, 0);
end
end
]]
-- Getting Difficulty Box and Score
DiffRectangle.render(deltaTime, offset_x + 75 + go_away, offset_y - number_y - 24.5, 0.84 / 1.05, adjustedDiff, level);
gfx.FontSize(26);
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE);
gfx.FillColor(100, 100, 100)
gfx.Text("00000000", offset_x + number_pos_x + go_away, offset_y - number_y - 11);
gfx.FillColor(255, 255, 255)
gfx.Text(string.format("%04d", math.floor(u.score / 10000)), offset_x + number_pos_x + go_away,
offset_y - number_y - 11);
local lastFourDigits = ((u.score / 10000) - math.floor(u.score / 10000)) * 10000
gfx.Text(string.format("%04d", math.floor(lastFourDigits)), offset_x + number_pos_x + 56 + go_away,
offset_y - number_y - 11);
end
end
local render = function(deltaTime, users, currentUserId, current_dif, current_level)
local resx, resy = game.GetResolution();
local scale = resx / desw
gfx.Scale(scale, scale)
draw_landscape_board(users, currentUserId, current_dif, current_level); -- TODO: for now
-- hide if landscape
if (resx > resy) then
return
end
-- Get the banner downscaled in whatever resolution it is, while maintaining the aspect ratio
local tw, th = gfx.ImageSize(bannerBaseImage);
BANNER_H = th * (1080 / tw);
gfx.BeginPath();
gfx.ImageRect(
0,
0,
BANNER_W,
BANNER_H,
bannerBaseImage,
1,
0
);
-- draw_portrait_board(users, currentUserId, current_dif, current_level); -- TODO: for now
gfx.ResetTransform()
end
return {
render = render
}