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