mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
V0 version
Add ``.gitignore``
Update ``.vscode\settings.json``
Main file changed a bit
Replace every single ``io.open`` into ``fs.read()``
Add ``input.waiting2trigger`` as buffer for too quick inputs
Replace ``binser`` with ``bitser``
Add the missing buffer logical code in training mode
Add a debug connector
Not a big update
Update VirtualControl.lua
Update in vctrl system
Trimming some unnecessary empty lines in classic library
Update virtual control stuff
Replace ``table.getn`` with ``#`` and ``scene`` with ``SCENE``
Renaming and moving some modules
Removing unnecessary ``local mino = {...}``
Add loading screen
Update loading screen
Apply replay patch
Not showing virtual control on computer
Adding touch screen configuration scene (placeholder)
Fix loading screen
update virtual control texture
Do some preparation for touch config screen
Quick patch
Compress background
Not important uodates
Small changes on how virtual key call action
Add ``SCENE:onInputMove``
Apply V2.2 patch
Clean up unnecessary imports
Test
.
Remove a redudant global variable
Small change
Split up alpha number
Sorting code
Update storeInput function
Optimize replay storing, saving and reading
Add VCTRL.export (for saving feature)
Remove unnecessary imports
Redesign loading screen
Replace loading screen
Make a simple BUTTON module
Update BUTTON module
Update button module
Add new callback
Add new callback
TEST
Update simple-button module
Update simple button module
Set default draw function for button
Add scene type notation
TEST
Not important updates
Design a error screen
Small update
Remove error key
Update
TEST
TEST
Test
TEST
TEST
Update button module
TEST
TEST
TEST
TEST
TEST
TEST
TEST
TEST
test
TEST
TEST
TEST
test
TEST
test
Fix a bug in VCTRL module that affect to SCENE:onInputRelease
Moving VCTRL related calls and adding buttons for name entry screen
Add type notation
Update modules
Final update for touch configuration scene
Fix 2 buttons can be highlighted at the same time in simple-button module
Narrow the safe border
Remove id = b (it was there for test)
Update of touch configuration scene
Add touch gesture for replay and input configuration scene
Add buttons for Replay, add MENU to go out after finishing game or in 20G Training mode
TEST
Fix some bugs (TEST)
Fix lỗi giữa đêm
Fix bug again
It should work imo
TEST
Fix SCENE:onInputMove{type="touch"} is not working
Fix bug once again (DONE!)
Temproraily allowing save
Fix settings module
Fix VCTRL.exportAll()
Fix VCTRL.exportAll returns userdata
Reverse a change
Fix forgetting to import virtual control settings
Fix grid drawing
Fix bugs related to the first time launching game
Add README file
Add README file
Update README and add LICENSE files
Update README
Add TV remote code
Disable debug code
Fix Android code
Small fix
Rename LICENSE to COPYING
Moving scene.lua to modules folder
Add new libraries
Make a new FILE API and add a simple error screen in case most thing went down
Change special code, add a way to skip keys
Update icon + README file
Rename screenshot file
Update README
Updating README file
Replace loading screen
Update README
Update virtual control texture
Fix virtual button method
Update README
Add icon font
Add importing and exporting replays
Update touch control
Update conf.lua
Replacing font, to avoid license issue
convert indents to spaces
Update font related stuff
Replace font
Updating README file
Update virtual control texture
This commit is contained in:
280
scene/touch_config.lua
Normal file
280
scene/touch_config.lua
Normal file
@@ -0,0 +1,280 @@
|
||||
---@diagnostic disable: cast-local-type
|
||||
local TouchConfigScene = SCENE:extend()
|
||||
TouchConfigScene.title = "Touchscreen config"
|
||||
|
||||
local Grid = require 'game.grid'
|
||||
|
||||
local buttonList
|
||||
local sliderList
|
||||
---@class VCTRL.data
|
||||
local focusingButton
|
||||
---@type number
|
||||
local snapUnit = 1
|
||||
---@type boolean
|
||||
local hasChanged
|
||||
|
||||
---@type function
|
||||
local function exitSceneFunc(saved)
|
||||
VCTRL.release()
|
||||
BUTTON.release(buttonList)
|
||||
if SETTINGS.firstTime and not saved then
|
||||
SCENE = InputConfigScene(true)
|
||||
else
|
||||
SCENE = TitleScene()
|
||||
SETTINGS.firstTime = false
|
||||
end
|
||||
end
|
||||
|
||||
buttonList = {
|
||||
showToggle = BUTTON.new{
|
||||
text = function()
|
||||
if focusingButton then
|
||||
return focusingButton.show and "[SHOW]\nHide" or "Show\n[HIDE]"
|
||||
else
|
||||
return "Show\nHide"
|
||||
end
|
||||
end,
|
||||
x = 275, y = 5, w = 50, h = 75,
|
||||
codeWhenReleased = function ()
|
||||
if focusingButton then
|
||||
focusingButton.show = not focusingButton.show
|
||||
hasChanged = true
|
||||
end
|
||||
end,
|
||||
update = function(self) self.textColor = focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5} end
|
||||
},
|
||||
previewToggle = BUTTON.new{
|
||||
text = "Preview\nON",
|
||||
x = 570, y = 35, w = 60, h = 40,
|
||||
codeWhenReleased = function()
|
||||
VCTRL.release()
|
||||
BUTTON.release(buttonList)
|
||||
SCENE = TouchConfigPreviewScene()
|
||||
end
|
||||
},
|
||||
resetAll = BUTTON.new{
|
||||
text = "RESET\nALL",
|
||||
x = 570, y = 80, w = 60, h = 40,
|
||||
codeWhenReleased = function()
|
||||
local selection = love.window.showMessageBox(
|
||||
"Save config?", "Are you really sure about RESETTING ALL touchscreen configuration?",
|
||||
{"Yes", "No", escapebutton = 2, enterbutton = 1},
|
||||
"info", true
|
||||
)
|
||||
if selection == 1 then
|
||||
VCTRL.focus = nil; focusingButton = nil
|
||||
hasChanged = false
|
||||
VCTRL.clearAll()
|
||||
VCTRL.new(SETTINGS.__default__.input.virtual)
|
||||
SETTINGS.input.virtual = SETTINGS.__default__.input.virtual
|
||||
end
|
||||
end
|
||||
},
|
||||
menuScreen = BUTTON.new{
|
||||
text = "MENU",
|
||||
x = 570, y = 5, w = 60, h = 25,
|
||||
codeWhenReleased = function()
|
||||
if hasChanged or SETTINGS.firstTime then
|
||||
local selection = love.window.showMessageBox(
|
||||
"Save config?", "Do you want to save your changes before exiting?",
|
||||
{"Save", "Discard", "Keep editing", escapebutton = 3, enterbutton = 1},
|
||||
"info", true
|
||||
)
|
||||
if selection == 1 then
|
||||
SETTINGS.input.virtual = VCTRL.exportAll()
|
||||
-- love.window.showMessageBox("Saved!", "Your changes was saved!")
|
||||
|
||||
exitSceneFunc(true)
|
||||
elseif selection == 2 then
|
||||
VCTRL.clearAll()
|
||||
VCTRL.new(SETTINGS.input.virtual)
|
||||
-- love.window.showMessageBox("Discarded!", "Your changes was discarded!")
|
||||
|
||||
exitSceneFunc()
|
||||
end
|
||||
else
|
||||
exitSceneFunc()
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
sliderList = {}
|
||||
sliderList.opacity = newSlider(
|
||||
155, 20+5, 120, 100, 0, 100,
|
||||
function()
|
||||
local v
|
||||
if focusingButton then
|
||||
v = math.roundUnit(sliderList.opacity.value, 0.01)
|
||||
if focusingButton.alpha~=v then
|
||||
focusingButton.alpha = v
|
||||
hasChanged = true
|
||||
end
|
||||
sliderList.opacity.value = v
|
||||
end
|
||||
end,
|
||||
{width = 30}
|
||||
)
|
||||
sliderList.size = newSlider(
|
||||
155, 60+2.5, 120, 45, 0, 120,
|
||||
function(v)
|
||||
if focusingButton then
|
||||
local v = math.roundUnit(v, 5)
|
||||
if focusingButton.r ~= v then
|
||||
focusingButton.r = v
|
||||
hasChanged = true
|
||||
end
|
||||
sliderList.size.value = v / 120
|
||||
end
|
||||
end,
|
||||
{width = 30}
|
||||
)
|
||||
local gridSizeTable = {1, 2, 5, 10, 20, 50, 100}
|
||||
sliderList.gridSize = newSlider(
|
||||
405, 50, 100, 1, 1, #gridSizeTable - 1,
|
||||
function()
|
||||
local v = math.roundUnit(sliderList.gridSize.value, 1 / 6)
|
||||
sliderList.gridSize.value = v
|
||||
snapUnit = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1)]
|
||||
end,
|
||||
{width = 30}
|
||||
); sliderList.gridSize.forceLight = true
|
||||
|
||||
local function sliderList_draw()
|
||||
for _, s in pairs(sliderList) do
|
||||
if s.forceLight then
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
else
|
||||
love.graphics.setColor(focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5})
|
||||
end
|
||||
love.graphics.setLineWidth(1)
|
||||
s:draw()
|
||||
end
|
||||
end
|
||||
|
||||
local function sliderList_update()
|
||||
local x, y
|
||||
if #love.touch.getTouches() == 1 then
|
||||
x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.touch.getPosition(love.touch.getTouches()[1]))
|
||||
else
|
||||
x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||
end
|
||||
for _, s in pairs(sliderList) do
|
||||
s:update(x, y, #love.touch.getTouches() == 1 or love.mouse.isDown(1))
|
||||
end
|
||||
end
|
||||
|
||||
function TouchConfigScene:new()
|
||||
VCTRL.toggle(true)
|
||||
|
||||
VCTRL.focus = nil
|
||||
focusingButton = nil
|
||||
|
||||
Grid:new(10, 20)
|
||||
-- TODO
|
||||
end
|
||||
function TouchConfigScene:update()
|
||||
-- TODO
|
||||
if VCTRL.focus~=focusingButton then
|
||||
focusingButton = VCTRL.focus
|
||||
sliderList.opacity.value = focusingButton.alpha
|
||||
sliderList.size.value = focusingButton.r / 120
|
||||
end
|
||||
|
||||
BUTTON.update(buttonList)
|
||||
sliderList_update()
|
||||
end
|
||||
|
||||
function TouchConfigScene:render()
|
||||
MainBackground()
|
||||
|
||||
if snapUnit >= 5 then
|
||||
local x1, y1 = GLOBAL_TRANSFORM:inverseTransformPoint(0, 0)
|
||||
local x2, y2 = GLOBAL_TRANSFORM:inverseTransformPoint(love.graphics.getDimensions())
|
||||
|
||||
love.graphics.setColor(1,1,1,math.sin(love.timer.getTime()*4)*.1+.25)
|
||||
love.graphics.setLineWidth(1)
|
||||
-- From 0 to X
|
||||
for i=x1, x2+snapUnit, snapUnit do
|
||||
local x = i - i % snapUnit
|
||||
love.graphics.line(x, y1, x, y2)
|
||||
end
|
||||
-- From 0 to Y
|
||||
for i=y1,y2+snapUnit,snapUnit do
|
||||
local y= i - i % snapUnit
|
||||
love.graphics.line(x1, y, x2, y)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setColor(0, 0, 0, 0.7)
|
||||
-- Opacity and Size
|
||||
love.graphics.rectangle("fill", 10, 5, 267, 75)
|
||||
-- Snap to grid
|
||||
love.graphics.rectangle("fill", 330, 5, 150, 75)
|
||||
|
||||
-- Opacity
|
||||
drawText("Opacity", 20, 15, 100, "left")
|
||||
drawText(string.format("%3.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 225, 15, 40, "left")
|
||||
-- Size
|
||||
drawText("Size", 20, 55, 100, "left")
|
||||
drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 225, 55, 40, "left")
|
||||
-- Snap to grid
|
||||
drawText(string.format("Snap to grid: %3s", snapUnit), 345, 15, 140, "left")
|
||||
|
||||
for _, v in ipairs(VCTRL) do
|
||||
if v ~= focusingButton then
|
||||
v:draw(
|
||||
focusingButton and
|
||||
(v.show and 0.5 or 0.1) or
|
||||
(v.show and 1 or 0.5)
|
||||
)
|
||||
end
|
||||
end
|
||||
if focusingButton then
|
||||
focusingButton:draw(
|
||||
math.clamp(
|
||||
math.sin(love.timer.getTime()*4)*.5+0.1,
|
||||
focusingButton.show and 1 or 0.1, 1
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
sliderList_draw()
|
||||
BUTTON.draw(buttonList)
|
||||
end
|
||||
|
||||
---@param e SCENE_onInput
|
||||
function TouchConfigScene:onInputMove(e)
|
||||
if e.type == "touch" or (e.type == "mouse" and love.mouse.isDown(1)) then
|
||||
if VCTRL.drag(e.dx, e.dy, e.id or 1) then hasChanged = true end
|
||||
end
|
||||
|
||||
if e.type == "mouse" then
|
||||
BUTTON.checkHovering(buttonList, e.x, e.y)
|
||||
end
|
||||
end
|
||||
---@param e SCENE_onInput
|
||||
function TouchConfigScene:onInputPress(e)
|
||||
if e.type == "mouse" or e.type == "touch" then
|
||||
if not (
|
||||
VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or
|
||||
BUTTON.press(buttonList, e.x, e.y, e.id) or
|
||||
(e.x >= 80 and e.x <= 230 and e.y >= 10 and e.y <= 77)
|
||||
) then
|
||||
VCTRL.focus = nil
|
||||
focusingButton = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
---@param e SCENE_onInput
|
||||
function TouchConfigScene:onInputRelease(e)
|
||||
if e.type == "mouse" or e.type == "touch" then
|
||||
if not BUTTON.release(buttonList, e.x, e.y, e.id) then
|
||||
if focusingButton and VCTRL.release(e.id or 1) then
|
||||
focusingButton.x = math.roundUnit(focusingButton.x, snapUnit)
|
||||
focusingButton.y = math.roundUnit(focusingButton.y, snapUnit)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return TouchConfigScene
|
||||
Reference in New Issue
Block a user