v.1.1.2
This commit is contained in:
parent
f0703eaafd
commit
9cfb1689b3
@ -6,6 +6,9 @@ local timeFinished = 0
|
|||||||
local disable = true
|
local disable = true
|
||||||
local prevLap = 0
|
local prevLap = 0
|
||||||
local splits = {}
|
local splits = {}
|
||||||
|
local PATCH = {
|
||||||
|
["FACERANK"]={}
|
||||||
|
}
|
||||||
|
|
||||||
-- Read the leaderboard
|
-- Read the leaderboard
|
||||||
local f = io.open(FILENAME, "r")
|
local f = io.open(FILENAME, "r")
|
||||||
@ -90,14 +93,31 @@ local function ticsToTime(tics)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local bodium = {V_YELLOWMAP, V_GRAYMAP, V_BROWNMAP, 0, 0}
|
local bodium = {V_YELLOWMAP, V_GRAYMAP, V_BROWNMAP, 0}
|
||||||
local splitColor = {[true]=V_SKYMAP, [false]=V_REDMAP}
|
local splitColor = {[true]=V_SKYMAP, [false]=V_REDMAP}
|
||||||
local splitSymbol = {[true]="-", [false]="+"}
|
local splitSymbol = {[true]="-", [false]="+"}
|
||||||
|
|
||||||
local showSplit = 0
|
local showSplit = 0
|
||||||
local function drawScoreboard(v)
|
local function drawScoreboard(v, player)
|
||||||
if disable then return end
|
if disable then return end
|
||||||
|
|
||||||
|
if player != displayplayers[0] then return end
|
||||||
|
|
||||||
|
-- PATCH CACHE
|
||||||
|
if not PATCH["CHILI"] then
|
||||||
|
PATCH["CHILI"] = {}
|
||||||
|
for i = 1, 8 do
|
||||||
|
PATCH["CHILI"][i-1] = v.cachePatch("K_CHILI" + i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for skin in skins.iterate do
|
||||||
|
if PATCH["FACERANK"][skin.name] then
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
PATCH["FACERANK"][skin.name] = v.cachePatch(skin.facerank)
|
||||||
|
end
|
||||||
|
|
||||||
local m = lb[tostring(gamemap)]
|
local m = lb[tostring(gamemap)]
|
||||||
if m == nil then
|
if m == nil then
|
||||||
return
|
return
|
||||||
@ -105,23 +125,45 @@ local function drawScoreboard(v)
|
|||||||
|
|
||||||
for i = 1, #m do
|
for i = 1, #m do
|
||||||
local score = m[i]
|
local score = m[i]
|
||||||
|
local name = score[1]
|
||||||
local skin = skins[score[2]]
|
local skin = skins[score[2]]
|
||||||
if skin == nil then
|
if skin == nil then
|
||||||
skin = skins["sonic"]
|
skin = skins["sonic"]
|
||||||
end
|
end
|
||||||
|
local skinPatch = PATCH["FACERANK"][skin.name]
|
||||||
|
|
||||||
local patch = v.cachePatch(skin.facerank)
|
|
||||||
-- | OFFSET | + | PADDING | * |INDEX|
|
-- | OFFSET | + | PADDING | * |INDEX|
|
||||||
local h = ((200 / 4) + 4) + (patch.height + 4) * (i - 1)
|
local h = ((200 / 4) + 4) + (skinPatch.height + 4) * (i - 1)
|
||||||
v.draw(4, h, patch, V_HUDTRANS | bodium[i], v.getColormap("sonic", score[3]))
|
v.draw(4, h, skinPatch, V_HUDTRANS, v.getColormap("sonic", score[3]))
|
||||||
v.drawString(8 + patch.width, h, score[1], V_HUDTRANSHALF | V_ALLOWLOWERCASE)
|
if player.name == name then
|
||||||
|
v.draw(4, h, PATCH["CHILI"][(leveltime / 4) % 8], V_HUDTRANS)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Shorten long names
|
||||||
|
local stralign = "left"
|
||||||
|
local MAXWIDTH = 70
|
||||||
|
local px = 6
|
||||||
|
local py = 0
|
||||||
|
if v.stringWidth(name) > MAXWIDTH then
|
||||||
|
stralign = "thin"
|
||||||
|
py = -1
|
||||||
|
if v.stringWidth(name, 0, "thin") > MAXWIDTH then
|
||||||
|
stralign = "small"
|
||||||
|
py = 2
|
||||||
|
if v.stringWidth(name, 0, "small") > MAXWIDTH then
|
||||||
|
name = name:sub(0, 15) + "..."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
v.drawString(px + skinPatch.width, h + py, name, V_HUDTRANSHALF | V_ALLOWLOWERCASE, stralign)
|
||||||
|
|
||||||
-- Draw splits
|
-- Draw splits
|
||||||
if showSplit > 0 and score[5][prevLap] != nil then
|
if showSplit > 0 and score[5][prevLap] != nil then
|
||||||
local split = splits[prevLap] - score[5][prevLap]
|
local split = splits[prevLap] - score[5][prevLap]
|
||||||
v.drawString(8 + patch.width, h + 8, splitSymbol[split < 0] + ticsToTime(abs(split)), V_HUDTRANSHALF | splitColor[split < 0])
|
v.drawString(px + skinPatch.width, h + 8, splitSymbol[split < 0] + ticsToTime(abs(split)), V_HUDTRANSHALF | splitColor[split < 0])
|
||||||
else
|
else
|
||||||
v.drawString(8 + patch.width, h + 8, ticsToTime(score[4]), V_HUDTRANSHALF | bodium[i])
|
v.drawString(px + skinPatch.width, h + 8, ticsToTime(score[4]), V_HUDTRANSHALF | bodium[min(i, 4)])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user