mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Add a debug connector
This commit is contained in:
45
main.lua
45
main.lua
@@ -1,3 +1,11 @@
|
|||||||
|
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE")=="1" then
|
||||||
|
lldebugger=require('lldebugger')
|
||||||
|
lldebugger.start()
|
||||||
|
REQUEST_BREAK=lldebugger.requestBreak
|
||||||
|
else
|
||||||
|
REQUEST_BREAK=function()end
|
||||||
|
end
|
||||||
|
|
||||||
require 'funcs'
|
require 'funcs'
|
||||||
DEBUG_showKey=true
|
DEBUG_showKey=true
|
||||||
|
|
||||||
@@ -25,8 +33,8 @@ function love.load()
|
|||||||
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});
|
||||||
|
|
||||||
-- used for screenshots
|
GLOBAL_TRANSFORM = love.math.newTransform()
|
||||||
GLOBAL_CANVAS = love.graphics.newCanvas()
|
love.resize(love.graphics.getWidth(), love.graphics.getHeight())
|
||||||
|
|
||||||
-- init config
|
-- init config
|
||||||
initConfig()
|
initConfig()
|
||||||
@@ -35,20 +43,22 @@ function love.load()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function love.resize(w, h)
|
||||||
|
local scale_factor = math.min(w / 640, h / 480)
|
||||||
|
GLOBAL_TRANSFORM:setTransformation(
|
||||||
|
(w - scale_factor * 640) / 2, -- x
|
||||||
|
(h - scale_factor * 480) / 2, -- y
|
||||||
|
0, -- orientation
|
||||||
|
scale_factor
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.setCanvas(GLOBAL_CANVAS)
|
love.graphics.replaceTransform(GLOBAL_TRANSFORM)
|
||||||
love.graphics.clear()
|
love.graphics.clear()
|
||||||
love.graphics.push()
|
love.graphics.push()
|
||||||
|
|
||||||
-- get offset matrix
|
-- get offset matrix
|
||||||
local width = love.graphics.getWidth()
|
|
||||||
local height = love.graphics.getHeight()
|
|
||||||
local scale_factor = math.min(width / 640, height / 480)
|
|
||||||
love.graphics.translate(
|
|
||||||
(width - scale_factor * 640) / 2,
|
|
||||||
(height - scale_factor * 480) / 2
|
|
||||||
)
|
|
||||||
love.graphics.scale(scale_factor)
|
|
||||||
|
|
||||||
scene:render()
|
scene:render()
|
||||||
love.graphics.pop()
|
love.graphics.pop()
|
||||||
@@ -56,10 +66,6 @@ function love.draw()
|
|||||||
if DEBUG_showKey then
|
if DEBUG_showKey then
|
||||||
drawText("Pressed: "..(LastPressedKey or '[NONE]').." | Released: "..(LastReleasedKey or '[NONE]'),0,0,1000,"left")
|
drawText("Pressed: "..(LastPressedKey or '[NONE]').." | Released: "..(LastReleasedKey or '[NONE]'),0,0,1000,"left")
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setCanvas()
|
|
||||||
love.graphics.setColor(1,1,1,1)
|
|
||||||
love.graphics.draw(GLOBAL_CANVAS)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key, scancode)
|
function love.keypressed(key, scancode)
|
||||||
@@ -76,7 +82,7 @@ function love.keypressed(key, scancode)
|
|||||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||||
return
|
return
|
||||||
-- escape is reserved for menu_back
|
-- escape is reserved for menu_back
|
||||||
elseif scancode == "escape" 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
|
||||||
@@ -93,7 +99,7 @@ function love.keyreleased(key, scancode)
|
|||||||
local input_released = nil
|
local input_released = nil
|
||||||
|
|
||||||
-- 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, "^f[1-9][0-9]+$") then
|
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f[1-9][0-9]+$") then
|
||||||
@@ -238,11 +244,6 @@ function love.focus(f)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.resize(w, h)
|
|
||||||
GLOBAL_CANVAS:release()
|
|
||||||
GLOBAL_CANVAS = love.graphics.newCanvas(w, h)
|
|
||||||
end
|
|
||||||
|
|
||||||
local TARGET_FPS = 60
|
local TARGET_FPS = 60
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user