lb_common.lua
This commit is contained in:
parent
d7dc3336dd
commit
e453290419
11
browser.lua
11
browser.lua
@ -6,9 +6,11 @@ local modes = nil
|
||||
local mode = 1
|
||||
local prefMode = nil
|
||||
|
||||
-- imported funcs
|
||||
local ZoneAct
|
||||
local TicsToTime
|
||||
-- Imported functions -------
|
||||
-- lb_common.lua
|
||||
local ZoneAct = lb_ZoneAct
|
||||
local TicsToTime = lb_TicsToTime
|
||||
-----------------------------
|
||||
|
||||
local function mapIndexOffset(n)
|
||||
return (mapIndex + n + #maps - 1) % #maps + 1
|
||||
@ -293,9 +295,6 @@ end
|
||||
local function drawBrowser(v)
|
||||
if not leaderboard then return end
|
||||
|
||||
TicsToTime = $ or rawget(_G, "TicsToTime")
|
||||
ZoneAct = $ or rawget(_G, "ZoneAct")
|
||||
|
||||
v.fadeScreen(0xFF00, 16)
|
||||
|
||||
-- previous, next maps
|
||||
|
26
lb_common.lua
Normal file
26
lb_common.lua
Normal file
@ -0,0 +1,26 @@
|
||||
rawset(_G, "lb_TicsToTime", function(tics, pure)
|
||||
if tics == 0 and pure then
|
||||
return "-:--:--"
|
||||
end
|
||||
|
||||
return string.format(
|
||||
"%d:%02d:%02d",
|
||||
G_TicsToMinutes(tics, true),
|
||||
G_TicsToSeconds(tics),
|
||||
G_TicsToCentiseconds(tics)
|
||||
)
|
||||
end)
|
||||
|
||||
rawset(_G, "lb_ZoneAct", function(map)
|
||||
local z = ""
|
||||
if map.zonttl != "" then
|
||||
z = " " + map.zonttl
|
||||
elseif not(map.levelflags & LF_NOZONE) then
|
||||
z = " Zone"
|
||||
end
|
||||
if map.actnum != "" then
|
||||
z = $ + " " + map.actnum
|
||||
end
|
||||
|
||||
return z
|
||||
end)
|
@ -87,9 +87,18 @@ local clamp
|
||||
|
||||
local scroll_to
|
||||
|
||||
local ticsToTime
|
||||
|
||||
local allowJoin
|
||||
|
||||
-- Imported functions --
|
||||
|
||||
-- lb_common.lua
|
||||
local ticsToTime = lb_TicsToTime
|
||||
local zoneAct = lb_ZoneAct
|
||||
|
||||
-- browser.lua
|
||||
local InitBrowser = InitBrowser
|
||||
local DrawBrowser = DrawBrowser
|
||||
local BrowserController = BrowserController
|
||||
---------------
|
||||
|
||||
-- cvars
|
||||
@ -398,8 +407,6 @@ local function exitlevel(player, ...)
|
||||
end
|
||||
COM_AddCommand("exit", exitlevel)
|
||||
|
||||
local DrawBrowser
|
||||
local BrowserController
|
||||
local function initBrowser(player)
|
||||
if not doyoudare(player) then return end
|
||||
|
||||
@ -409,33 +416,18 @@ local function initBrowser(player)
|
||||
return
|
||||
end
|
||||
|
||||
if not rawget(_G, "DrawBrowser") then
|
||||
if not InitBrowser then
|
||||
print("Browser is not loaded")
|
||||
return
|
||||
end
|
||||
|
||||
rawget(_G, "InitBrowser")(lb)
|
||||
InitBrowser(lb)
|
||||
drawState = DS_BROWSER
|
||||
|
||||
player.afkTime = leveltime
|
||||
end
|
||||
COM_AddCommand("levelselect", initBrowser)
|
||||
|
||||
local function zoneAct(map)
|
||||
local z = ""
|
||||
if map.zonttl != "" then
|
||||
z = " " + map.zonttl
|
||||
elseif not(map.levelflags & LF_NOZONE) then
|
||||
z = " Zone"
|
||||
end
|
||||
if map.actnum != "" then
|
||||
z = $ + " " + map.actnum
|
||||
end
|
||||
|
||||
return z
|
||||
end
|
||||
rawset(_G, "ZoneAct", zoneAct)
|
||||
|
||||
local function findMap(player, ...)
|
||||
local search = ...
|
||||
|
||||
@ -849,20 +841,6 @@ addHook("MapLoad", function()
|
||||
end
|
||||
)
|
||||
|
||||
function ticsToTime(tics, pure)
|
||||
if tics == 0 and pure then
|
||||
return "-:--:--"
|
||||
end
|
||||
|
||||
return string.format(
|
||||
"%d:%02d:%02d",
|
||||
G_TicsToMinutes(tics, true),
|
||||
G_TicsToSeconds(tics),
|
||||
G_TicsToCentiseconds(tics)
|
||||
)
|
||||
end
|
||||
rawset(_G, "TicsToTime", ticsToTime)
|
||||
|
||||
-- Item patches have the amazing property of being displaced 12x 13y pixels
|
||||
local iXoffset = 13 * FRACUNIT
|
||||
local iYoffset = 12 * FRACUNIT
|
||||
@ -1144,9 +1122,6 @@ local function drawScrollTo(v, player, scoreTable, gui)
|
||||
end
|
||||
|
||||
local function drawBrowser(v, player)
|
||||
if not DrawBrowser then
|
||||
DrawBrowser = rawget(_G, "DrawBrowser")
|
||||
end
|
||||
DrawBrowser(v, lb)
|
||||
end
|
||||
|
||||
@ -1493,9 +1468,6 @@ local function think()
|
||||
end
|
||||
end
|
||||
elseif drawState == DS_BROWSER then
|
||||
if not BrowserController then
|
||||
BrowserController = rawget(_G, "BrowserController")
|
||||
end
|
||||
if BrowserController(p) then
|
||||
drawState = DS_DEFAULT
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user