mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 13:09:02 -06:00
Changed indentation to hard tabs.
This commit is contained in:
parent
3479374686
commit
6834e92674
192
main.lua
192
main.lua
@ -46,10 +46,10 @@ function love.load()
|
|||||||
end
|
end
|
||||||
--sort mode/rule lists
|
--sort mode/rule lists
|
||||||
local function padnum(d) return ("%03d%s"):format(#d, d) end
|
local function padnum(d) return ("%03d%s"):format(#d, d) end
|
||||||
table.sort(game_modes, function(a,b)
|
table.sort(game_modes, function(a,b)
|
||||||
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
table.sort(rulesets, function(a,b)
|
table.sort(rulesets, function(a,b)
|
||||||
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
return tostring(a.name):gsub("%d+",padnum) < tostring(b.name):gsub("%d+",padnum) end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,120 +114,120 @@ function love.keypressed(key, scancode)
|
|||||||
if scancode == "f4" then
|
if scancode == "f4" then
|
||||||
config["fullscreen"] = not config["fullscreen"]
|
config["fullscreen"] = not config["fullscreen"]
|
||||||
love.window.setFullscreen(config["fullscreen"])
|
love.window.setFullscreen(config["fullscreen"])
|
||||||
-- reserved keys, so the user can always get back to configure input
|
-- reserved keys, so the user can always get back to configure input
|
||||||
elseif scancode == "return" then
|
elseif scancode == "return" then
|
||||||
scene:onInputPress({input="menu_decide", type="key", key=key, scancode=scancode})
|
scene:onInputPress({input="menu_decide", type="key", key=key, scancode=scancode})
|
||||||
elseif scancode == "escape" then
|
elseif scancode == "escape" then
|
||||||
scene:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
|
scene:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
elseif scancode == "left" or scancode == "right" or scancode == "up" or scancode == "down" then
|
elseif scancode == "left" or scancode == "right" or scancode == "up" or scancode == "down" then
|
||||||
scene:onInputPress({input=scancode, type="key", key=key, scancode=scancode})
|
scene:onInputPress({input=scancode, type="key", key=key, scancode=scancode})
|
||||||
-- other keys can be configured
|
-- other keys can be configured
|
||||||
else
|
else
|
||||||
local input_pressed = nil
|
local input_pressed = nil
|
||||||
if config.input and config.input.keys then
|
if config.input and config.input.keys then
|
||||||
input_pressed = config.input.keys[scancode]
|
input_pressed = config.input.keys[scancode]
|
||||||
end
|
end
|
||||||
scene:onInputPress({input=input_pressed, type="key", key=key, scancode=scancode})
|
scene:onInputPress({input=input_pressed, type="key", key=key, scancode=scancode})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keyreleased(key, scancode)
|
function love.keyreleased(key, scancode)
|
||||||
-- reserved keys, so the user can always get back to configure input
|
-- reserved keys, so the user can always get back to configure input
|
||||||
if scancode == "return" then
|
if scancode == "return" then
|
||||||
scene:onInputRelease({input="menu_decide", type="key", key=key, scancode=scancode})
|
scene:onInputRelease({input="menu_decide", type="key", key=key, scancode=scancode})
|
||||||
elseif scancode == "escape" then
|
elseif scancode == "escape" then
|
||||||
scene:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
scene:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
elseif scancode == "left" or scancode == "right" or scancode == "up" or scancode == "down" then
|
elseif scancode == "left" or scancode == "right" or scancode == "up" or scancode == "down" then
|
||||||
scene:onInputRelease({input=scancode, type="key", key=key, scancode=scancode})
|
scene:onInputRelease({input=scancode, type="key", key=key, scancode=scancode})
|
||||||
-- other keys can be configured
|
-- other keys can be configured
|
||||||
else
|
else
|
||||||
local input_released = nil
|
local input_released = nil
|
||||||
if config.input and config.input.keys then
|
if config.input and config.input.keys then
|
||||||
input_released = config.input.keys[scancode]
|
input_released = config.input.keys[scancode]
|
||||||
end
|
end
|
||||||
scene:onInputRelease({input=input_released, type="key", key=key, scancode=scancode})
|
scene:onInputRelease({input=input_released, type="key", key=key, scancode=scancode})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickpressed(joystick, button)
|
function love.joystickpressed(joystick, button)
|
||||||
local input_pressed = nil
|
local input_pressed = nil
|
||||||
if
|
if
|
||||||
config.input and
|
config.input and
|
||||||
config.input.joysticks and
|
config.input.joysticks and
|
||||||
config.input.joysticks[joystick:getName()] and
|
config.input.joysticks[joystick:getName()] and
|
||||||
config.input.joysticks[joystick:getName()].buttons
|
config.input.joysticks[joystick:getName()].buttons
|
||||||
then
|
then
|
||||||
input_pressed = config.input.joysticks[joystick:getName()].buttons[button]
|
input_pressed = config.input.joysticks[joystick:getName()].buttons[button]
|
||||||
end
|
end
|
||||||
scene:onInputPress({input=input_pressed, type="joybutton", name=joystick:getName(), button=button})
|
scene:onInputPress({input=input_pressed, type="joybutton", name=joystick:getName(), button=button})
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickreleased(joystick, button)
|
function love.joystickreleased(joystick, button)
|
||||||
local input_released = nil
|
local input_released = nil
|
||||||
if
|
if
|
||||||
config.input and
|
config.input and
|
||||||
config.input.joysticks and
|
config.input.joysticks and
|
||||||
config.input.joysticks[joystick:getName()] and
|
config.input.joysticks[joystick:getName()] and
|
||||||
config.input.joysticks[joystick:getName()].buttons
|
config.input.joysticks[joystick:getName()].buttons
|
||||||
then
|
then
|
||||||
input_released = config.input.joysticks[joystick:getName()].buttons[button]
|
input_released = config.input.joysticks[joystick:getName()].buttons[button]
|
||||||
end
|
end
|
||||||
scene:onInputRelease({input=input_released, type="joybutton", name=joystick:getName(), button=button})
|
scene:onInputRelease({input=input_released, type="joybutton", name=joystick:getName(), button=button})
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickaxis(joystick, axis, value)
|
function love.joystickaxis(joystick, axis, value)
|
||||||
local input_pressed = nil
|
local input_pressed = nil
|
||||||
local positive_released = nil
|
local positive_released = nil
|
||||||
local negative_released = nil
|
local negative_released = nil
|
||||||
if
|
if
|
||||||
config.input and
|
config.input and
|
||||||
config.input.joysticks and
|
config.input.joysticks and
|
||||||
config.input.joysticks[joystick:getName()] and
|
config.input.joysticks[joystick:getName()] and
|
||||||
config.input.joysticks[joystick:getName()].axes and
|
config.input.joysticks[joystick:getName()].axes and
|
||||||
config.input.joysticks[joystick:getName()].axes[axis]
|
config.input.joysticks[joystick:getName()].axes[axis]
|
||||||
then
|
then
|
||||||
if math.abs(value) >= 0.5 then
|
if math.abs(value) >= 0.5 then
|
||||||
input_pressed = config.input.joysticks[joystick:getName()].axes[axis][value >= 0.5 and "positive" or "negative"]
|
input_pressed = config.input.joysticks[joystick:getName()].axes[axis][value >= 0.5 and "positive" or "negative"]
|
||||||
end
|
end
|
||||||
positive_released = config.input.joysticks[joystick:getName()].axes[axis].positive
|
positive_released = config.input.joysticks[joystick:getName()].axes[axis].positive
|
||||||
negative_released = config.input.joysticks[joystick:getName()].axes[axis].negative
|
negative_released = config.input.joysticks[joystick:getName()].axes[axis].negative
|
||||||
end
|
end
|
||||||
if math.abs(value) >= 0.5 then
|
if math.abs(value) >= 0.5 then
|
||||||
scene:onInputPress({input=input_pressed, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
scene:onInputPress({input=input_pressed, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
else
|
else
|
||||||
scene:onInputRelease({input=positive_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
scene:onInputRelease({input=positive_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
scene:onInputRelease({input=negative_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
scene:onInputRelease({input=negative_released, type="joyaxis", name=joystick:getName(), axis=axis, value=value})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickhat(joystick, hat, direction)
|
function love.joystickhat(joystick, hat, direction)
|
||||||
local input_pressed = nil
|
local input_pressed = nil
|
||||||
local has_hat = false
|
local has_hat = false
|
||||||
if
|
if
|
||||||
config.input and
|
config.input and
|
||||||
config.input.joysticks and
|
config.input.joysticks and
|
||||||
config.input.joysticks[joystick:getName()] and
|
config.input.joysticks[joystick:getName()] and
|
||||||
config.input.joysticks[joystick:getName()].hats and
|
config.input.joysticks[joystick:getName()].hats and
|
||||||
config.input.joysticks[joystick:getName()].hats[hat]
|
config.input.joysticks[joystick:getName()].hats[hat]
|
||||||
then
|
then
|
||||||
if direction ~= "c" then
|
if direction ~= "c" then
|
||||||
input_pressed = config.input.joysticks[joystick:getName()].hats[hat][direction]
|
input_pressed = config.input.joysticks[joystick:getName()].hats[hat][direction]
|
||||||
end
|
end
|
||||||
has_hat = true
|
has_hat = true
|
||||||
end
|
end
|
||||||
if input_pressed then
|
if input_pressed then
|
||||||
scene:onInputPress({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
scene:onInputPress({input=input_pressed, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
elseif has_hat then
|
elseif has_hat then
|
||||||
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
||||||
scene:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
scene:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][direction], type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
end
|
end
|
||||||
elseif direction ~= "c" then
|
elseif direction ~= "c" then
|
||||||
scene:onInputPress({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
scene:onInputPress({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
else
|
else
|
||||||
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
for i, direction in ipairs{"d", "l", "ld", "lu", "r", "rd", "ru", "u"} do
|
||||||
scene:onInputRelease({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
scene:onInputRelease({input=nil, type="joyhat", name=joystick:getName(), hat=hat, direction=direction})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.focus(f)
|
function love.focus(f)
|
||||||
|
@ -2,23 +2,23 @@ local GameScene = Scene:extend()
|
|||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
function GameScene:new(game_mode, ruleset)
|
function GameScene:new(game_mode, ruleset)
|
||||||
self.retry_mode = game_mode
|
self.retry_mode = game_mode
|
||||||
self.retry_ruleset = ruleset
|
self.retry_ruleset = ruleset
|
||||||
self.game = game_mode()
|
self.game = game_mode()
|
||||||
self.ruleset = ruleset()
|
self.ruleset = ruleset()
|
||||||
self.game:initialize(self.ruleset)
|
self.game:initialize(self.ruleset)
|
||||||
self.inputs = {
|
self.inputs = {
|
||||||
left=false,
|
left=false,
|
||||||
right=false,
|
right=false,
|
||||||
up=false,
|
up=false,
|
||||||
down=false,
|
down=false,
|
||||||
rotate_left=false,
|
rotate_left=false,
|
||||||
rotate_left2=false,
|
rotate_left2=false,
|
||||||
rotate_right=false,
|
rotate_right=false,
|
||||||
rotate_right2=false,
|
rotate_right2=false,
|
||||||
rotate_180=false,
|
rotate_180=false,
|
||||||
hold=false,
|
hold=false,
|
||||||
}
|
}
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = self.game.rpc_details,
|
details = self.game.rpc_details,
|
||||||
state = self.game.name,
|
state = self.game.name,
|
||||||
@ -27,10 +27,10 @@ end
|
|||||||
|
|
||||||
function GameScene:update()
|
function GameScene:update()
|
||||||
if love.window.hasFocus() then
|
if love.window.hasFocus() then
|
||||||
local inputs = {}
|
local inputs = {}
|
||||||
for input, value in pairs(self.inputs) do
|
for input, value in pairs(self.inputs) do
|
||||||
inputs[input] = value
|
inputs[input] = value
|
||||||
end
|
end
|
||||||
self.game:update(inputs, self.ruleset)
|
self.game:update(inputs, self.ruleset)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,24 +67,24 @@ function GameScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:onInputPress(e)
|
function GameScene:onInputPress(e)
|
||||||
if self.game.completed and (e.input == "menu_decide" or e.input == "menu_back") then
|
if self.game.completed and (e.input == "menu_decide" or e.input == "menu_back") then
|
||||||
highscore_entry = self.game:getHighscoreData()
|
highscore_entry = self.game:getHighscoreData()
|
||||||
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
||||||
submitHighscore(highscore_hash, highscore_entry)
|
submitHighscore(highscore_hash, highscore_entry)
|
||||||
scene = ModeSelectScene()
|
scene = ModeSelectScene()
|
||||||
elseif e.input == "retry" then
|
elseif e.input == "retry" then
|
||||||
scene = GameScene(self.retry_mode, self.retry_ruleset)
|
scene = GameScene(self.retry_mode, self.retry_ruleset)
|
||||||
elseif e.input == "menu_back" then
|
elseif e.input == "menu_back" then
|
||||||
scene = ModeSelectScene()
|
scene = ModeSelectScene()
|
||||||
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
||||||
self.inputs[e.input] = true
|
self.inputs[e.input] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:onInputRelease(e)
|
function GameScene:onInputRelease(e)
|
||||||
if e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
if e.input and string.sub(e.input, 1, 5) ~= "menu_" then
|
||||||
self.inputs[e.input] = false
|
self.inputs[e.input] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function submitHighscore(hash, data)
|
function submitHighscore(hash, data)
|
||||||
|
@ -5,10 +5,10 @@ ConfigScene.title = "Game Settings"
|
|||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
ConfigScene.options = {
|
ConfigScene.options = {
|
||||||
-- this serves as reference to what the options' values mean i guess?
|
-- this serves as reference to what the options' values mean i guess?
|
||||||
{"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
|
{"manlock", "Manual locking",{"Per ruleset","Per gamemode","Harddrop", "Softdrop"}},
|
||||||
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
|
{"piece_colour", "Piece Colours", {"Per ruleset","Arika" ,"TTC"}},
|
||||||
{"world_reverse","World Reverse", {"No" ,"SRS only" ,"Always"}},
|
{"world_reverse","World Reverse", {"No" ,"SRS only" ,"Always"}},
|
||||||
}
|
}
|
||||||
local optioncount = #ConfigScene.options
|
local optioncount = #ConfigScene.options
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ ConfigScene.title = "Input Config"
|
|||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
local configurable_inputs = {
|
local configurable_inputs = {
|
||||||
"menu_decide",
|
"menu_decide",
|
||||||
"menu_back",
|
"menu_back",
|
||||||
"left",
|
"left",
|
||||||
"right",
|
"right",
|
||||||
"up",
|
"up",
|
||||||
@ -21,17 +21,17 @@ local configurable_inputs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local function newSetInputs()
|
local function newSetInputs()
|
||||||
local set_inputs = {}
|
local set_inputs = {}
|
||||||
for i, input in ipairs(configurable_inputs) do
|
for i, input in ipairs(configurable_inputs) do
|
||||||
set_inputs[input] = false
|
set_inputs[input] = false
|
||||||
end
|
end
|
||||||
return set_inputs
|
return set_inputs
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:new()
|
function ConfigScene:new()
|
||||||
self.input_state = 1
|
self.input_state = 1
|
||||||
self.set_inputs = newSetInputs()
|
self.set_inputs = newSetInputs()
|
||||||
self.new_input = {}
|
self.new_input = {}
|
||||||
|
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In menus",
|
details = "In menus",
|
||||||
@ -53,116 +53,116 @@ function ConfigScene:render()
|
|||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
for i, input in ipairs(configurable_inputs) do
|
for i, input in ipairs(configurable_inputs) do
|
||||||
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
|
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
|
||||||
if self.set_inputs[input] then
|
if self.set_inputs[input] then
|
||||||
love.graphics.printf(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
|
love.graphics.printf(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.input_state > table.getn(configurable_inputs) then
|
if self.input_state > table.getn(configurable_inputs) then
|
||||||
love.graphics.print("press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""))
|
love.graphics.print("press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""))
|
||||||
else
|
else
|
||||||
love.graphics.print("press key or joystick input for " .. configurable_inputs[self.input_state] .. ", tab to skip" .. (config.input and ", escape to cancel" or ""), 0, 0)
|
love.graphics.print("press key or joystick input for " .. configurable_inputs[self.input_state] .. ", tab to skip" .. (config.input and ", escape to cancel" or ""), 0, 0)
|
||||||
love.graphics.print("enter, delete, backspace, tab, arrows, and escape can't be changed", 0, 20)
|
love.graphics.print("enter, delete, backspace, tab, arrows, and escape can't be changed", 0, 20)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function addJoystick(input, name)
|
local function addJoystick(input, name)
|
||||||
if not input.joysticks then
|
if not input.joysticks then
|
||||||
input.joysticks = {}
|
input.joysticks = {}
|
||||||
end
|
end
|
||||||
if not input.joysticks[name] then
|
if not input.joysticks[name] then
|
||||||
input.joysticks[name] = {}
|
input.joysticks[name] = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:onInputPress(e)
|
function ConfigScene:onInputPress(e)
|
||||||
if e.type == "key" then
|
if e.type == "key" then
|
||||||
-- enter, delete, backspace, tab, arrows, and escape are reserved and can't be remapped
|
-- enter, delete, backspace, tab, arrows, and escape are reserved and can't be remapped
|
||||||
if e.scancode == "escape" and config.input then
|
if e.scancode == "escape" and config.input then
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
elseif self.input_state > table.getn(configurable_inputs) then
|
elseif self.input_state > table.getn(configurable_inputs) then
|
||||||
if e.scancode == "return" then
|
if e.scancode == "return" then
|
||||||
-- save new input, then load next scene
|
-- save new input, then load next scene
|
||||||
config.input = self.new_input
|
config.input = self.new_input
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
-- retry
|
-- retry
|
||||||
self.input_state = 1
|
self.input_state = 1
|
||||||
self.set_inputs = newSetInputs()
|
self.set_inputs = newSetInputs()
|
||||||
self.new_input = {}
|
self.new_input = {}
|
||||||
elseif e.scancode == "escape" and config.input then
|
elseif e.scancode == "escape" and config.input then
|
||||||
-- cancel only if there was an input config already
|
-- cancel only if there was an input config already
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
end
|
end
|
||||||
elseif
|
elseif
|
||||||
e.scancode ~= "delete" and
|
e.scancode ~= "delete" and
|
||||||
e.scancode ~= "backspace" and
|
e.scancode ~= "backspace" and
|
||||||
e.scancode ~= "return" and
|
e.scancode ~= "return" and
|
||||||
e.scancode ~= "left" and
|
e.scancode ~= "left" and
|
||||||
e.scancode ~= "right" and
|
e.scancode ~= "right" and
|
||||||
e.scancode ~= "up" and
|
e.scancode ~= "up" and
|
||||||
e.scancode ~= "down"
|
e.scancode ~= "down"
|
||||||
then
|
then
|
||||||
if e.scancode == "tab" then
|
if e.scancode == "tab" then
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
else
|
else
|
||||||
if not self.new_input.keys then
|
if not self.new_input.keys then
|
||||||
self.new_input.keys = {}
|
self.new_input.keys = {}
|
||||||
end
|
end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
|
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
|
||||||
self.new_input.keys[e.scancode] = configurable_inputs[self.input_state]
|
self.new_input.keys[e.scancode] = configurable_inputs[self.input_state]
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif string.sub(e.type, 1, 3) == "joy" then
|
elseif string.sub(e.type, 1, 3) == "joy" then
|
||||||
if self.input_state <= table.getn(configurable_inputs) then
|
if self.input_state <= table.getn(configurable_inputs) then
|
||||||
if e.type == "joybutton" then
|
if e.type == "joybutton" then
|
||||||
addJoystick(self.new_input, e.name)
|
addJoystick(self.new_input, e.name)
|
||||||
if not self.new_input.joysticks[e.name].buttons then
|
if not self.new_input.joysticks[e.name].buttons then
|
||||||
self.new_input.joysticks[e.name].buttons = {}
|
self.new_input.joysticks[e.name].buttons = {}
|
||||||
end
|
end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jbtn " ..
|
"jbtn " ..
|
||||||
e.button ..
|
e.button ..
|
||||||
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
self.new_input.joysticks[e.name].buttons[e.button] = configurable_inputs[self.input_state]
|
self.new_input.joysticks[e.name].buttons[e.button] = configurable_inputs[self.input_state]
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
elseif e.type == "joyaxis" then
|
elseif e.type == "joyaxis" then
|
||||||
if math.abs(e.value) >= 0.5 then
|
if math.abs(e.value) >= 0.5 then
|
||||||
addJoystick(self.new_input, e.name)
|
addJoystick(self.new_input, e.name)
|
||||||
if not self.new_input.joysticks[e.name].axes then
|
if not self.new_input.joysticks[e.name].axes then
|
||||||
self.new_input.joysticks[e.name].axes = {}
|
self.new_input.joysticks[e.name].axes = {}
|
||||||
end
|
end
|
||||||
if not self.new_input.joysticks[e.name].axes[e.axis] then
|
if not self.new_input.joysticks[e.name].axes[e.axis] then
|
||||||
self.new_input.joysticks[e.name].axes[e.axis] = {}
|
self.new_input.joysticks[e.name].axes[e.axis] = {}
|
||||||
end
|
end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jaxis " ..
|
"jaxis " ..
|
||||||
(e.value >= 0.5 and "+" or "-") .. e.axis ..
|
(e.value >= 0.5 and "+" or "-") .. e.axis ..
|
||||||
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
self.new_input.joysticks[e.name].axes[e.axis][e.value >= 0.5 and "positive" or "negative"] = configurable_inputs[self.input_state]
|
self.new_input.joysticks[e.name].axes[e.axis][e.value >= 0.5 and "positive" or "negative"] = configurable_inputs[self.input_state]
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
end
|
end
|
||||||
elseif e.type == "joyhat" then
|
elseif e.type == "joyhat" then
|
||||||
if e.direction ~= "c" then
|
if e.direction ~= "c" then
|
||||||
addJoystick(self.new_input, e.name)
|
addJoystick(self.new_input, e.name)
|
||||||
if not self.new_input.joysticks[e.name].hats then
|
if not self.new_input.joysticks[e.name].hats then
|
||||||
self.new_input.joysticks[e.name].hats = {}
|
self.new_input.joysticks[e.name].hats = {}
|
||||||
end
|
end
|
||||||
if not self.new_input.joysticks[e.name].hats[e.hat] then
|
if not self.new_input.joysticks[e.name].hats[e.hat] then
|
||||||
self.new_input.joysticks[e.name].hats[e.hat] = {}
|
self.new_input.joysticks[e.name].hats[e.hat] = {}
|
||||||
end
|
end
|
||||||
self.set_inputs[configurable_inputs[self.input_state]] =
|
self.set_inputs[configurable_inputs[self.input_state]] =
|
||||||
"jhat " ..
|
"jhat " ..
|
||||||
e.hat .. " " .. e.direction ..
|
e.hat .. " " .. e.direction ..
|
||||||
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
" " .. string.sub(e.name, 1, 10) .. (string.len(e.name) > 10 and "..." or "")
|
||||||
self.new_input.joysticks[e.name].hats[e.hat][e.direction] = configurable_inputs[self.input_state]
|
self.new_input.joysticks[e.name].hats[e.hat][e.direction] = configurable_inputs[self.input_state]
|
||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return ConfigScene
|
return ConfigScene
|
||||||
|
@ -26,7 +26,7 @@ function TitleScene:new()
|
|||||||
self.main_menu_state = 1
|
self.main_menu_state = 1
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In menus",
|
details = "In menus",
|
||||||
state = mainmenuidle[math.random(#mainmenuidle)],
|
state = mainmenuidle[math.random(#mainmenuidle)],
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user