mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Replace `table.getn with # and scene with SCENE`
This commit is contained in:
42
main.lua
42
main.lua
@@ -30,7 +30,7 @@ function love.load()
|
|||||||
require "scene"
|
require "scene"
|
||||||
require "game.vctrl" -- VCTRL
|
require "game.vctrl" -- VCTRL
|
||||||
|
|
||||||
scene = config.firstTime and InputConfigScene() or TitleScene()
|
SCENE = config.firstTime and InputConfigScene() or TitleScene()
|
||||||
|
|
||||||
love.mouse.setVisible(false)
|
love.mouse.setVisible(false)
|
||||||
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
||||||
@@ -77,7 +77,7 @@ function love.draw()
|
|||||||
love.graphics.clear()
|
love.graphics.clear()
|
||||||
love.graphics.push()
|
love.graphics.push()
|
||||||
|
|
||||||
scene:render()
|
SCENE:render()
|
||||||
VCTRL.draw()
|
VCTRL.draw()
|
||||||
|
|
||||||
-- -- Grid system
|
-- -- Grid system
|
||||||
@@ -129,20 +129,20 @@ 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"])
|
||||||
elseif scancode == "f2" and scene.title ~= "Input Config" and scene.title ~= "Game" then
|
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||||
scene = InputConfigScene()
|
SCENE = InputConfigScene()
|
||||||
-- function keys are reserved
|
-- function keys are reserved
|
||||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||||
return
|
return
|
||||||
-- escape is reserved for menu_back
|
-- escape is reserved for menu_back
|
||||||
elseif scancode == "escape" or scancode == "acback" then
|
elseif scancode == "escape" or scancode == "acback" then
|
||||||
scene:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
|
SCENE:onInputPress({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
-- pass any other key to the scene, with its configured mapping
|
-- pass any other key to the scene, with its configured mapping
|
||||||
else
|
else
|
||||||
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
|
||||||
|
|
||||||
LastPressedKey = input_pressed or scancode
|
LastPressedKey = input_pressed or scancode
|
||||||
@@ -153,7 +153,7 @@ function love.keyreleased(key, scancode)
|
|||||||
|
|
||||||
-- escape is reserved for menu_back
|
-- escape is reserved for menu_back
|
||||||
if scancode == "escape" or scancode == 'acback' then
|
if scancode == "escape" or scancode == 'acback' then
|
||||||
scene:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
SCENE:onInputRelease({input="menu_back", type="key", key=key, scancode=scancode})
|
||||||
-- function keys are reserved
|
-- function keys are reserved
|
||||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||||
return
|
return
|
||||||
@@ -162,7 +162,7 @@ function love.keyreleased(key, scancode)
|
|||||||
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
|
||||||
|
|
||||||
LastReleasedKey = input_released or scancode
|
LastReleasedKey = input_released or scancode
|
||||||
@@ -178,7 +178,7 @@ function love.joystickpressed(joystick, button)
|
|||||||
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)
|
||||||
@@ -191,7 +191,7 @@ function love.joystickreleased(joystick, button)
|
|||||||
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)
|
||||||
@@ -212,10 +212,10 @@ function love.joystickaxis(joystick, axis, value)
|
|||||||
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) >= 1 then
|
if math.abs(value) >= 1 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
|
||||||
|
|
||||||
@@ -247,20 +247,20 @@ function love.joystickhat(joystick, hat, direction)
|
|||||||
local char = direction:sub(i, i)
|
local char = direction:sub(i, i)
|
||||||
local _, count = last_hat_direction:gsub(char, char)
|
local _, count = last_hat_direction:gsub(char, char)
|
||||||
if count == 0 then
|
if count == 0 then
|
||||||
scene:onInputPress({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
SCENE:onInputPress({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1, #last_hat_direction do
|
for i = 1, #last_hat_direction do
|
||||||
local char = last_hat_direction:sub(i, i)
|
local char = last_hat_direction:sub(i, i)
|
||||||
local _, count = direction:gsub(char, char)
|
local _, count = direction:gsub(char, char)
|
||||||
if count == 0 then
|
if count == 0 then
|
||||||
scene:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
SCENE:onInputRelease({input=config.input.joysticks[joystick:getName()].hats[hat][char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
last_hat_direction = direction
|
last_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
|
||||||
last_hat_direction = ""
|
last_hat_direction = ""
|
||||||
elseif direction ~= "c" then
|
elseif direction ~= "c" then
|
||||||
@@ -268,20 +268,20 @@ function love.joystickhat(joystick, hat, direction)
|
|||||||
local char = direction:sub(i, i)
|
local char = direction:sub(i, i)
|
||||||
local _, count = last_hat_direction:gsub(char, char)
|
local _, count = last_hat_direction:gsub(char, char)
|
||||||
if count == 0 then
|
if count == 0 then
|
||||||
scene:onInputPress({input=directions[char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
SCENE:onInputPress({input=directions[char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1, #last_hat_direction do
|
for i = 1, #last_hat_direction do
|
||||||
local char = last_hat_direction:sub(i, i)
|
local char = last_hat_direction:sub(i, i)
|
||||||
local _, count = direction:gsub(char, char)
|
local _, count = direction:gsub(char, char)
|
||||||
if count == 0 then
|
if count == 0 then
|
||||||
scene:onInputRelease({input=directions[char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
SCENE:onInputRelease({input=directions[char], type="joyhat", name=joystick:getName(), hat=hat, direction=char})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
last_hat_direction = direction
|
last_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
|
||||||
last_hat_direction = ""
|
last_hat_direction = ""
|
||||||
end
|
end
|
||||||
@@ -315,8 +315,8 @@ function love.run()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if scene and scene.update and love.timer then
|
if SCENE and SCENE.update and love.timer then
|
||||||
scene:update()
|
SCENE:update()
|
||||||
|
|
||||||
local frame_duration = 1.0 / TARGET_FPS
|
local frame_duration = 1.0 / TARGET_FPS
|
||||||
if time_accumulator < frame_duration then
|
if time_accumulator < frame_duration then
|
||||||
|
|||||||
12
scene.lua
12
scene.lua
@@ -1,12 +1,12 @@
|
|||||||
local Object = require "libs.classic"
|
local Object = require "libs.classic"
|
||||||
|
|
||||||
Scene = Object:extend()
|
SCENE = Object:extend()
|
||||||
|
|
||||||
function Scene:new() end
|
function SCENE:new() end
|
||||||
function Scene:update() end
|
function SCENE:update() end
|
||||||
function Scene:render() end
|
function SCENE:render() end
|
||||||
function Scene:onInputPress() end
|
function SCENE:onInputPress() end
|
||||||
function Scene:onInputRelease() end
|
function SCENE:onInputRelease() end
|
||||||
|
|
||||||
ExitScene = require "scene.exit"
|
ExitScene = require "scene.exit"
|
||||||
GameScene = require "scene.game"
|
GameScene = require "scene.game"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local ExitScene = Scene:extend()
|
local ExitScene = SCENE:extend()
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
ExitScene.title = "Exit Game"
|
ExitScene.title = "Exit Game"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local FullscreenScene = Scene:extend()
|
local FullscreenScene = SCENE:extend()
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
FullscreenScene.title = "Fullscreen"
|
FullscreenScene.title = "Fullscreen"
|
||||||
@@ -10,7 +10,7 @@ function FullscreenScene:update()
|
|||||||
config["fullscreen"] = not config["fullscreen"]
|
config["fullscreen"] = not config["fullscreen"]
|
||||||
saveConfig()
|
saveConfig()
|
||||||
love.window.setFullscreen(config["fullscreen"])
|
love.window.setFullscreen(config["fullscreen"])
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
end
|
end
|
||||||
|
|
||||||
function FullscreenScene:render()
|
function FullscreenScene:render()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local GameScene = Scene:extend()
|
local GameScene = SCENE:extend()
|
||||||
|
|
||||||
GameScene.title = "Game"
|
GameScene.title = "Game"
|
||||||
local tas = false
|
local tas = false
|
||||||
@@ -68,11 +68,11 @@ end
|
|||||||
|
|
||||||
function GameScene:onInputPress(e)
|
function GameScene:onInputPress(e)
|
||||||
if (self.game.game_over or self.game.completed) and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "rotate_right") and self.game.game_over_frames > 50 then
|
if (self.game.game_over or self.game.completed) and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "rotate_right") and self.game.game_over_frames > 50 then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
elseif tas and e.input == "menu_decide" then
|
elseif tas and e.input == "menu_decide" then
|
||||||
self:update(false, true)
|
self:update(false, true)
|
||||||
elseif self.game.input_playback and (e.input == "menu_back") then
|
elseif self.game.input_playback and (e.input == "menu_back") then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
elseif self.game.input_playback and e.input == "rotate_left" then
|
elseif self.game.input_playback and e.input == "rotate_left" then
|
||||||
self.paused = false
|
self.paused = false
|
||||||
self:update()
|
self:update()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local ConfigScene = Scene:extend()
|
local ConfigScene = SCENE:extend()
|
||||||
|
|
||||||
ConfigScene.title = "Input Config"
|
ConfigScene.title = "Input Config"
|
||||||
|
|
||||||
@@ -39,13 +39,13 @@ function ConfigScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:changeOption(rel)
|
function ConfigScene:changeOption(rel)
|
||||||
local len = table.getn(menu_screens)
|
local len = #menu_screens
|
||||||
self.menu_state = (self.menu_state + len + rel - 1) % len + 1
|
self.menu_state = (self.menu_state + len + rel - 1) % len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function ConfigScene:onInputPress(e)
|
function ConfigScene:onInputPress(e)
|
||||||
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||||
scene = menu_screens[self.menu_state]()
|
SCENE = menu_screens[self.menu_state]()
|
||||||
elseif e.input == "up" or e.scancode == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
elseif e.input == "down" or e.scancode == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
@@ -53,7 +53,7 @@ function ConfigScene:onInputPress(e)
|
|||||||
elseif config.input and (
|
elseif config.input and (
|
||||||
e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete"
|
e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete"
|
||||||
) then
|
) then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local KeyConfigScene = Scene:extend()
|
local KeyConfigScene = SCENE:extend()
|
||||||
|
|
||||||
KeyConfigScene.title = "Key Config"
|
KeyConfigScene.title = "Key Config"
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ function KeyConfigScene:render()
|
|||||||
drawText(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
|
drawText(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 > #configurable_inputs then
|
||||||
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""),0,0,1000)
|
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""),0,0,1000)
|
||||||
else
|
else
|
||||||
drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000)
|
drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel",0,0,1000)
|
||||||
@@ -70,12 +70,12 @@ function KeyConfigScene:onInputPress(e)
|
|||||||
if e.type == "key" then
|
if e.type == "key" then
|
||||||
-- function keys, escape, and tab are reserved and can't be remapped
|
-- function keys, escape, and tab are reserved and can't be remapped
|
||||||
if e.scancode == "escape" then
|
if e.scancode == "escape" then
|
||||||
scene = InputConfigScene()
|
SCENE = InputConfigScene()
|
||||||
elseif self.input_state > table.getn(configurable_inputs) then
|
elseif self.input_state > #configurable_inputs then
|
||||||
if e.scancode == "return" then
|
if e.scancode == "return" then
|
||||||
config.input.keys = self.new_input
|
config.input.keys = self.new_input
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = config.firstTime and TitleScene() or InputConfigScene()
|
SCENE = config.firstTime and TitleScene() or InputConfigScene()
|
||||||
config.firstTime = false
|
config.firstTime = false
|
||||||
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
-- retry
|
-- retry
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local MusicToggleScene = Scene:extend()
|
local MusicToggleScene = SCENE:extend()
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
MusicToggleScene.title = "Play music during game:"
|
MusicToggleScene.title = "Play music during game:"
|
||||||
@@ -9,7 +9,7 @@ end
|
|||||||
function MusicToggleScene:update()
|
function MusicToggleScene:update()
|
||||||
config["music"] = not config["music"]
|
config["music"] = not config["music"]
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
end
|
end
|
||||||
|
|
||||||
function MusicToggleScene:render()
|
function MusicToggleScene:render()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local NameEntryScene = Scene:extend()
|
local NameEntryScene = SCENE:extend()
|
||||||
local Grid = require 'game.grid'
|
local Grid = require 'game.grid'
|
||||||
local bitser = require 'libs.bitser'
|
local bitser = require 'libs.bitser'
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
@@ -117,7 +117,7 @@ function NameEntryScene:onInputPress(e)
|
|||||||
if self.entry_pos == 4 then
|
if self.entry_pos == 4 then
|
||||||
config['last_entry'] = name:upper()
|
config['last_entry'] = name:upper()
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = GameScene(name:lower())
|
SCENE = GameScene(name:lower())
|
||||||
else
|
else
|
||||||
if self.entry_pos == 3 then
|
if self.entry_pos == 3 then
|
||||||
name = string.lower(self.name_entry[1]..self.name_entry[2]..self.name_entry[3])
|
name = string.lower(self.name_entry[1]..self.name_entry[2]..self.name_entry[3])
|
||||||
@@ -146,7 +146,7 @@ function NameEntryScene:onInputPress(e)
|
|||||||
self.delete_confirm = false
|
self.delete_confirm = false
|
||||||
self.delete_input_count = 0
|
self.delete_input_count = 0
|
||||||
if self.entry_pos == 1 then
|
if self.entry_pos == 1 then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
else
|
else
|
||||||
self.name_entry[self.entry_pos] = 'A'
|
self.name_entry[self.entry_pos] = 'A'
|
||||||
self.name_entry[self.entry_pos-1] = 'A'
|
self.name_entry[self.entry_pos-1] = 'A'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
require 'funcs'
|
require 'funcs'
|
||||||
local ReplaySelectScene = Scene:extend()
|
local ReplaySelectScene = SCENE:extend()
|
||||||
|
|
||||||
ReplaySelectScene.title = "Replay"
|
ReplaySelectScene.title = "Replay"
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ function ReplaySelectScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ReplaySelectScene:changeOption(rel)
|
function ReplaySelectScene:changeOption(rel)
|
||||||
local len = table.getn(self.replays)
|
local len = #self.replays
|
||||||
self.replay_select = self.replay_select + rel
|
self.replay_select = self.replay_select + rel
|
||||||
if self.replay_select + ((self.page-1) * self.page_flip) > len then
|
if self.replay_select + ((self.page-1) * self.page_flip) > len then
|
||||||
self.page = 1
|
self.page = 1
|
||||||
@@ -107,7 +107,7 @@ function ReplaySelectScene:onInputPress(e)
|
|||||||
selected_replay_text = self.replay_text[self.replay_select + ((self.page-1) * self.page_flip)]
|
selected_replay_text = self.replay_text[self.replay_select + ((self.page-1) * self.page_flip)]
|
||||||
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||||
if self.replays[1] == nil then
|
if self.replays[1] == nil then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
--if not self.dialog then
|
--if not self.dialog then
|
||||||
-- self.dialog_select = 1
|
-- self.dialog_select = 1
|
||||||
-- self.dialog = true
|
-- self.dialog = true
|
||||||
@@ -130,19 +130,19 @@ function ReplaySelectScene:onInputPress(e)
|
|||||||
end
|
end
|
||||||
player_name = line_components[1]
|
player_name = line_components[1]
|
||||||
player_grade = string.gsub(line_components[2], " ", "")
|
player_grade = string.gsub(line_components[2], " ", "")
|
||||||
scene = GameScene(player_name, selected_replay, player_grade)
|
SCENE = GameScene(player_name, selected_replay, player_grade)
|
||||||
end
|
end
|
||||||
elseif e.input == "up" or e.scancode == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
if self.replays[1] == nil then scene = TitleScene() end
|
if self.replays[1] == nil then SCENE = TitleScene() end
|
||||||
if not self.dialog then self:changeOption(-1)
|
if not self.dialog then self:changeOption(-1)
|
||||||
else self:changeDialog(-1) end
|
else self:changeDialog(-1) end
|
||||||
elseif e.input == "down" or e.scancode == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
if self.replays[1] == nil then scene = TitleScene() end
|
if self.replays[1] == nil then SCENE = TitleScene() end
|
||||||
if not self.dialog then self:changeOption(1)
|
if not self.dialog then self:changeOption(1)
|
||||||
else self:changeDialog(1) end
|
else self:changeDialog(1) end
|
||||||
elseif e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete" then
|
elseif e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete" then
|
||||||
if self.replays[1] == nil then scene = TitleScene() end
|
if self.replays[1] == nil then SCENE = TitleScene() end
|
||||||
if not self.dialog then scene = TitleScene()
|
if not self.dialog then SCENE = TitleScene()
|
||||||
else self.dialog = false end
|
else self.dialog = false end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local StickConfigScene = Scene:extend()
|
local StickConfigScene = SCENE:extend()
|
||||||
|
|
||||||
StickConfigScene.title = "Controller Config"
|
StickConfigScene.title = "Controller Config"
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ function StickConfigScene:render()
|
|||||||
drawText(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
|
drawText(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 > #configurable_inputs then
|
||||||
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""), 0, 0, 1000)
|
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""), 0, 0, 1000)
|
||||||
else
|
else
|
||||||
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
|
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
|
||||||
@@ -77,15 +77,15 @@ function StickConfigScene:onInputPress(e)
|
|||||||
if e.type == "key" then
|
if e.type == "key" then
|
||||||
-- function keys, escape, and tab are reserved and can't be remapped
|
-- function keys, escape, and tab are reserved and can't be remapped
|
||||||
if e.scancode == "escape" then
|
if e.scancode == "escape" then
|
||||||
scene = InputConfigScene()
|
SCENE = InputConfigScene()
|
||||||
elseif self.input_state > table.getn(configurable_inputs) then
|
elseif self.input_state > #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
|
||||||
local had_config = config.input ~= nil
|
local had_config = config.input ~= nil
|
||||||
if not config.input then config.input = {} end
|
if not config.input then config.input = {} end
|
||||||
config.input.joysticks = self.new_input
|
config.input.joysticks = self.new_input
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = had_config and InputConfigScene() or TitleScene()
|
SCENE = had_config and InputConfigScene() or 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
|
||||||
@@ -97,7 +97,7 @@ function StickConfigScene:onInputPress(e)
|
|||||||
self.input_state = self.input_state + 1
|
self.input_state = self.input_state + 1
|
||||||
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 <= #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[e.name].buttons then
|
if not self.new_input[e.name].buttons then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local TitleScene = Scene:extend()
|
local TitleScene = SCENE:extend()
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
require 'funcs'
|
require 'funcs'
|
||||||
|
|
||||||
@@ -83,13 +83,13 @@ function TitleScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TitleScene:changeOption(rel)
|
function TitleScene:changeOption(rel)
|
||||||
local len = table.getn(main_menu_screens)
|
local len = #main_menu_screens
|
||||||
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
self.main_menu_state = (self.main_menu_state + len + rel - 1) % len + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function TitleScene:onInputPress(e)
|
function TitleScene:onInputPress(e)
|
||||||
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||||
scene = main_menu_screens[self.main_menu_state]()
|
SCENE = main_menu_screens[self.main_menu_state]()
|
||||||
elseif e.input == "up" or e.scancode == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
elseif e.input == "down" or e.scancode == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local TrainingScene = Scene:extend()
|
local TrainingScene = SCENE:extend()
|
||||||
|
|
||||||
TrainingScene.title = "Max Gravity Training"
|
TrainingScene.title = "Max Gravity Training"
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ end
|
|||||||
|
|
||||||
function TrainingScene:onInputPress(e)
|
function TrainingScene:onInputPress(e)
|
||||||
if (self.game.game_over or self.game.completed) and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "rotate_right") and self.game.game_over_frames > 50 then
|
if (self.game.game_over or self.game.completed) and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "rotate_right") and self.game.game_over_frames > 50 then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
elseif (e.input == "menu_back") then
|
elseif (e.input == "menu_back") then
|
||||||
scene = TitleScene()
|
SCENE = TitleScene()
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user