Add level selector / leaderboard browser #7
37
browser.lua
37
browser.lua
@ -395,6 +395,7 @@ local function resetKeyRepeat()
|
|||||||
repeatCount = 0
|
repeatCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ValidButtons = BT_ACCELERATE | BT_BRAKE | BT_FORWARD | BT_BACKWARD | BT_DRIFT
|
||||||
-- return value indicates we want to exit the browser
|
-- return value indicates we want to exit the browser
|
||||||
local function controller(player)
|
local function controller(player)
|
||||||
keyRepeat = max(0, $ - 1)
|
keyRepeat = max(0, $ - 1)
|
||||||
@ -405,32 +406,36 @@ local function controller(player)
|
|||||||
|
|
||||||
local cmd = player.cmd
|
local cmd = player.cmd
|
||||||
if not keyRepeat then
|
if not keyRepeat then
|
||||||
if cmd.driftturn > 0 then
|
if not (cmd.buttons & ValidButtons or cmd.driftturn) then
|
||||||
updateMapIndex(-1)
|
return
|
||||||
updateKeyRepeat()
|
end
|
||||||
elseif cmd.driftturn < 0 then
|
|
||||||
updateMapIndex(1)
|
updateKeyRepeat()
|
||||||
updateKeyRepeat()
|
|
||||||
|
if cmd.buttons & BT_BRAKE then
|
||||||
|
S_StartSound(nil, 115)
|
||||||
|
return true
|
||||||
|
elseif cmd.buttons & BT_ACCELERATE then
|
||||||
|
COM_BufInsertText(player, "changelevel "..G_BuildMapName(maps[mapIndex]))
|
||||||
|
return true
|
||||||
|
elseif cmd.driftturn then
|
||||||
|
local dir = cmd.driftturn > 0 and -1 or 1
|
||||||
|
|
||||||
|
if encoremode then
|
||||||
|
updateMapIndex(-dir)
|
||||||
|
else
|
||||||
|
updateMapIndex(dir)
|
||||||
|
end
|
||||||
elseif cmd.buttons & BT_FORWARD then
|
elseif cmd.buttons & BT_FORWARD then
|
||||||
scrollPos = $ - 1
|
scrollPos = $ - 1
|
||||||
updateKeyRepeat()
|
|
||||||
elseif cmd.buttons & BT_BACKWARD then
|
elseif cmd.buttons & BT_BACKWARD then
|
||||||
scrollPos = $ + 1
|
scrollPos = $ + 1
|
||||||
updateKeyRepeat()
|
|
||||||
elseif cmd.buttons & BT_DRIFT then
|
elseif cmd.buttons & BT_DRIFT then
|
||||||
scrollPos = 1
|
scrollPos = 1
|
||||||
if modes and #modes then
|
if modes and #modes then
|
||||||
mode = $ % #modes + 1
|
mode = $ % #modes + 1
|
||||||
prefMode = modes[mode]
|
prefMode = modes[mode]
|
||||||
end
|
end
|
||||||
updateKeyRepeat()
|
|
||||||
elseif cmd.buttons & BT_BRAKE then
|
|
||||||
S_StartSound(nil, 115)
|
|
||||||
return true
|
|
||||||
elseif cmd.buttons & BT_ACCELERATE then
|
|
||||||
S_StartSound(nil, 143)
|
|
||||||
COM_BufInsertText(player, "changelevel "..G_BuildMapName(maps[mapIndex]))
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user