mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Update virtual control scene
This commit is contained in:
@@ -64,7 +64,7 @@ function control_type.button:new(data)
|
|||||||
r=data.r or 80, -- size
|
r=data.r or 80, -- size
|
||||||
shape=data.shape or 'circle',
|
shape=data.shape or 'circle',
|
||||||
key=data.key or 'X',
|
key=data.key or 'X',
|
||||||
iconSize=data.iconSize or 80,
|
iconSize=data.iconSize or 60,
|
||||||
alpha=data.alpha or 0.75,
|
alpha=data.alpha or 0.75,
|
||||||
quad=virtual_quad[data.key]
|
quad=virtual_quad[data.key]
|
||||||
},self)
|
},self)
|
||||||
@@ -148,6 +148,7 @@ local touches={}
|
|||||||
local global_toggle=false
|
local global_toggle=false
|
||||||
VCTRL={}
|
VCTRL={}
|
||||||
VCTRL.focus=nil -- Focusing buttons
|
VCTRL.focus=nil -- Focusing buttons
|
||||||
|
VCTRL.hasChanged = false
|
||||||
|
|
||||||
---@class VCTRL.data
|
---@class VCTRL.data
|
||||||
---@field type 'button'
|
---@field type 'button'
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ TouchConfigScene.title = "Touchscreen config"
|
|||||||
local Grid = require 'game.grid'
|
local Grid = require 'game.grid'
|
||||||
|
|
||||||
local buttonList
|
local buttonList
|
||||||
local sliderList
|
local sliderList = {}
|
||||||
---@class VCTRL.data
|
---@class VCTRL.data
|
||||||
local focusingButton
|
local focusingButton
|
||||||
---@type number
|
---@type number
|
||||||
local snapUnit = 1
|
local snapUnit = 1
|
||||||
---@type boolean
|
|
||||||
local hasChanged
|
|
||||||
|
|
||||||
---@type function
|
---@type function
|
||||||
local function exitSceneFunc(saved)
|
local function exitSceneFunc(saved)
|
||||||
@@ -29,23 +27,23 @@ buttonList = {
|
|||||||
showToggle = BUTTON.new{
|
showToggle = BUTTON.new{
|
||||||
text = function()
|
text = function()
|
||||||
if focusingButton then
|
if focusingButton then
|
||||||
return focusingButton.show and "[SHOW]\nHide" or "Show\n[HIDE]"
|
return focusingButton.show and ">SHOW<\nhide" or "show\n>HIDE<"
|
||||||
else
|
else
|
||||||
return "Show\nHide"
|
return "show\nhide"
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
x = 275, y = 5, w = 50, h = 75,
|
x = 400, y = 110, w = 60, h = 40,
|
||||||
codeWhenReleased = function ()
|
codeWhenReleased = function()
|
||||||
if focusingButton then
|
if focusingButton then
|
||||||
focusingButton.show = not focusingButton.show
|
focusingButton.show = not focusingButton.show
|
||||||
hasChanged = true
|
VCTRL.hasChanged = true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
update = function(self) self.textColor = focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5} end
|
update = function(self) self.textColor = focusingButton and {1, 1, 1} or {0.5, 0.5, 0.5} end
|
||||||
},
|
},
|
||||||
previewToggle = BUTTON.new{
|
previewToggle = BUTTON.new{
|
||||||
text = "Preview\nON",
|
text = "Preview\nON",
|
||||||
x = 570, y = 35, w = 60, h = 40,
|
x = 570, y = 60, w = 60, h = 40,
|
||||||
codeWhenReleased = function()
|
codeWhenReleased = function()
|
||||||
VCTRL.release()
|
VCTRL.release()
|
||||||
BUTTON.release(buttonList)
|
BUTTON.release(buttonList)
|
||||||
@@ -54,7 +52,7 @@ buttonList = {
|
|||||||
},
|
},
|
||||||
resetAll = BUTTON.new{
|
resetAll = BUTTON.new{
|
||||||
text = "RESET\nALL",
|
text = "RESET\nALL",
|
||||||
x = 570, y = 80, w = 60, h = 40,
|
x = 500, y = 110, w = 60, h = 40,
|
||||||
codeWhenReleased = function()
|
codeWhenReleased = function()
|
||||||
local selection = love.window.showMessageBox(
|
local selection = love.window.showMessageBox(
|
||||||
"Save config?", "Are you really sure about RESETTING ALL touchscreen configuration?",
|
"Save config?", "Are you really sure about RESETTING ALL touchscreen configuration?",
|
||||||
@@ -63,7 +61,7 @@ buttonList = {
|
|||||||
)
|
)
|
||||||
if selection == 1 then
|
if selection == 1 then
|
||||||
VCTRL.focus = nil; focusingButton = nil
|
VCTRL.focus = nil; focusingButton = nil
|
||||||
hasChanged = false
|
VCTRL.hasChanged = false
|
||||||
VCTRL.clearAll()
|
VCTRL.clearAll()
|
||||||
VCTRL.new(SETTINGS.__default__.input.virtual)
|
VCTRL.new(SETTINGS.__default__.input.virtual)
|
||||||
SETTINGS.input.virtual = SETTINGS.__default__.input.virtual
|
SETTINGS.input.virtual = SETTINGS.__default__.input.virtual
|
||||||
@@ -72,9 +70,9 @@ buttonList = {
|
|||||||
},
|
},
|
||||||
menuScreen = BUTTON.new{
|
menuScreen = BUTTON.new{
|
||||||
text = "MENU",
|
text = "MENU",
|
||||||
x = 570, y = 5, w = 60, h = 25,
|
x = 570, y = 10, w = 60, h = 40,
|
||||||
codeWhenReleased = function()
|
codeWhenReleased = function()
|
||||||
if hasChanged or SETTINGS.firstTime then
|
if VCTRL.hasChanged or SETTINGS.firstTime then
|
||||||
local selection = love.window.showMessageBox(
|
local selection = love.window.showMessageBox(
|
||||||
"Save config?", "Do you want to save your changes before exiting?",
|
"Save config?", "Do you want to save your changes before exiting?",
|
||||||
{"Save", "Discard", "Keep editing", escapebutton = 3, enterbutton = 1},
|
{"Save", "Discard", "Keep editing", escapebutton = 3, enterbutton = 1},
|
||||||
@@ -98,45 +96,59 @@ buttonList = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sliderList = {}
|
sliderList.buttonSize = newSlider(
|
||||||
|
200, 30, 120, 0, 0, 120,
|
||||||
|
function(v)
|
||||||
|
if focusingButton then
|
||||||
|
v = math.roundUnit(v, 5)
|
||||||
|
if focusingButton.r ~= v then
|
||||||
|
focusingButton.r = v
|
||||||
|
VCTRL.hasChanged = true
|
||||||
|
end
|
||||||
|
sliderList.buttonSize.value = v / 120
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{width = 40}
|
||||||
|
)
|
||||||
|
sliderList.iconSize = newSlider(
|
||||||
|
480, 30, 120, 0, 0, 100,
|
||||||
|
function(v)
|
||||||
|
if focusingButton then
|
||||||
|
v = math.roundUnit(v, 5)
|
||||||
|
if focusingButton.iconSize ~= v then
|
||||||
|
focusingButton.iconSize = v
|
||||||
|
VCTRL.hasChanged = true
|
||||||
|
end
|
||||||
|
sliderList.iconSize.value = v / 100
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{width = 40}
|
||||||
|
)
|
||||||
sliderList.opacity = newSlider(
|
sliderList.opacity = newSlider(
|
||||||
155, 20+5, 120, 100, 0, 100,
|
200, 80, 120, 0, 0, 1,
|
||||||
function()
|
function()
|
||||||
local v
|
local v
|
||||||
if focusingButton then
|
if focusingButton then
|
||||||
v = math.roundUnit(sliderList.opacity.value, 0.01)
|
v = math.roundUnit(sliderList.opacity.value, 0.01)
|
||||||
if focusingButton.alpha~=v then
|
if focusingButton.alpha~=v then
|
||||||
focusingButton.alpha = v
|
focusingButton.alpha = v
|
||||||
hasChanged = true
|
VCTRL.hasChanged = true
|
||||||
end
|
end
|
||||||
sliderList.opacity.value = v
|
sliderList.opacity.value = v
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{width = 30}
|
{width = 40}
|
||||||
)
|
|
||||||
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}
|
local gridSizeTable = {1, 2, 5, 10, 20, 50, 100}
|
||||||
sliderList.gridSize = newSlider(
|
sliderList.gridSize = newSlider(
|
||||||
405, 50, 100, 1, 1, #gridSizeTable - 1,
|
480, 80, 120, 1, 1, #gridSizeTable - 1,
|
||||||
function()
|
function()
|
||||||
local v = math.roundUnit(sliderList.gridSize.value, 1 / 6)
|
local f = #gridSizeTable - 1
|
||||||
|
local v = math.roundUnit(sliderList.gridSize.value, 1 / f)
|
||||||
sliderList.gridSize.value = v
|
sliderList.gridSize.value = v
|
||||||
snapUnit = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1)]
|
snapUnit = gridSizeTable[math.roundUnit(v * f + 1)]
|
||||||
end,
|
end,
|
||||||
{width = 30}
|
{width = 40}
|
||||||
); sliderList.gridSize.forceLight = true
|
); sliderList.gridSize.forceLight = true
|
||||||
|
|
||||||
local function sliderList_draw()
|
local function sliderList_draw()
|
||||||
@@ -177,13 +189,15 @@ function TouchConfigScene:update()
|
|||||||
if VCTRL.focus~=focusingButton then
|
if VCTRL.focus~=focusingButton then
|
||||||
focusingButton = VCTRL.focus
|
focusingButton = VCTRL.focus
|
||||||
sliderList.opacity.value = focusingButton.alpha
|
sliderList.opacity.value = focusingButton.alpha
|
||||||
sliderList.size.value = focusingButton.r / 120
|
sliderList.buttonSize.value = focusingButton.r / 120
|
||||||
|
sliderList.iconSize.value = focusingButton.iconSize / 100
|
||||||
end
|
end
|
||||||
|
|
||||||
BUTTON.update(buttonList)
|
BUTTON.update(buttonList)
|
||||||
sliderList_update()
|
sliderList_update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local string_format = string.format
|
||||||
function TouchConfigScene:render()
|
function TouchConfigScene:render()
|
||||||
MainBackground()
|
MainBackground()
|
||||||
|
|
||||||
@@ -206,19 +220,16 @@ function TouchConfigScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, 0.7)
|
love.graphics.setColor(0, 0, 0, 0.7)
|
||||||
-- Opacity and Size
|
love.graphics.rectangle("fill", 5, 5, 560, 100)
|
||||||
love.graphics.rectangle("fill", 10, 5, 267, 75)
|
|
||||||
-- Snap to grid
|
|
||||||
love.graphics.rectangle("fill", 330, 5, 150, 75)
|
|
||||||
|
|
||||||
|
-- Button Size
|
||||||
|
drawText(string_format("Size (buttons)\n%14.1d", focusingButton and focusingButton.r or 0), 10, 13, 100, "left")
|
||||||
|
-- Icon size
|
||||||
|
drawText(string_format("Size (icons)\n%13.1d%%", focusingButton and focusingButton.iconSize or 0), 290, 13, 100, "left")
|
||||||
-- Opacity
|
-- Opacity
|
||||||
drawText("Opacity", 20, 15, 100, "left")
|
drawText(string_format("Opacity\n%13.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 10, 63, 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
|
-- Snap to grid
|
||||||
drawText(string.format("Snap to grid: %3s", snapUnit), 345, 15, 140, "left")
|
drawText(string_format("Snap to grid\n%14.1d", snapUnit), 290, 63, 100, "left")
|
||||||
|
|
||||||
for _, v in ipairs(VCTRL) do
|
for _, v in ipairs(VCTRL) do
|
||||||
if v ~= focusingButton then
|
if v ~= focusingButton then
|
||||||
@@ -245,10 +256,8 @@ end
|
|||||||
---@param e SCENE_onInput
|
---@param e SCENE_onInput
|
||||||
function TouchConfigScene:onInputMove(e)
|
function TouchConfigScene:onInputMove(e)
|
||||||
if e.type == "touch" or (e.type == "mouse" and love.mouse.isDown(1)) then
|
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
|
if VCTRL.drag(e.dx, e.dy, e.id or 1) then VCTRL.hasChanged = true end
|
||||||
end
|
elseif e.type == "mouse" then
|
||||||
|
|
||||||
if e.type == "mouse" then
|
|
||||||
BUTTON.checkHovering(buttonList, e.x, e.y)
|
BUTTON.checkHovering(buttonList, e.x, e.y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -258,7 +267,8 @@ function TouchConfigScene:onInputPress(e)
|
|||||||
if not (
|
if not (
|
||||||
VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or
|
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
|
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)
|
(e.x >= 120 and e.x <= 280 and e.y >= 10 and e.y <= 100) or
|
||||||
|
(e.x >= 400 and e.x <= 560 and e.y >= 10 and e.y <= 100)
|
||||||
) then
|
) then
|
||||||
VCTRL.focus = nil
|
VCTRL.focus = nil
|
||||||
focusingButton = nil
|
focusingButton = nil
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local buttonList
|
|||||||
buttonList = {
|
buttonList = {
|
||||||
previewToggle = BUTTON.new{
|
previewToggle = BUTTON.new{
|
||||||
text = "Preview\nOFF",
|
text = "Preview\nOFF",
|
||||||
x = 570, y = 35, w = 60, h = 40,
|
x = 570, y = 60, w = 60, h = 40,
|
||||||
codeWhenReleased = function()
|
codeWhenReleased = function()
|
||||||
VCTRL.release()
|
VCTRL.release()
|
||||||
BUTTON.release(buttonList)
|
BUTTON.release(buttonList)
|
||||||
@@ -16,8 +16,6 @@ buttonList = {
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
local sliderList = {}
|
|
||||||
|
|
||||||
local secret_grade_grid = {}
|
local secret_grade_grid = {}
|
||||||
do
|
do
|
||||||
local colour_names = {'R', 'O', 'Y', 'G', 'C', 'B', 'M'}
|
local colour_names = {'R', 'O', 'Y', 'G', 'C', 'B', 'M'}
|
||||||
@@ -80,13 +78,17 @@ end
|
|||||||
function TouchConfigPreviewScene:onInputPress(e)
|
function TouchConfigPreviewScene:onInputPress(e)
|
||||||
if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end
|
if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end
|
||||||
if e.type == "mouse" or e.type == "touch" then
|
if e.type == "mouse" or e.type == "touch" then
|
||||||
BUTTON.press(buttonList, e.x, e.y, e.id)
|
if not BUTTON.press(buttonList, e.x, e.y, e.id) then
|
||||||
|
VCTRL.press(e.x, e.y, e.id or 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
---@param e SCENE_onInput
|
---@param e SCENE_onInput
|
||||||
function TouchConfigPreviewScene:onInputRelease(e)
|
function TouchConfigPreviewScene:onInputRelease(e)
|
||||||
if e.type == "mouse" or e.type == "touch" then
|
if e.type == "mouse" or e.type == "touch" then
|
||||||
BUTTON.release(buttonList, e.x, e.y, e.id)
|
if not BUTTON.release(buttonList, e.x, e.y, e.id) then
|
||||||
|
VCTRL.release(e.id or 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ local _defaultSettings = {
|
|||||||
{type='button',x=320, y=420,key= 'restart',r=35,iconSize=60,alpha=0.4},
|
{type='button',x=320, y=420,key= 'restart',r=35,iconSize=60,alpha=0.4},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tvMode = false -- 79338732
|
tvMode = false
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTINGS = setmetatable(
|
SETTINGS = setmetatable(
|
||||||
|
|||||||
Reference in New Issue
Block a user