整理代码
预设虚拟按键的键位移入virtualkey模块
This commit is contained in:
17
main.lua
17
main.lua
@@ -117,15 +117,6 @@ if customData and customData.version==VERSION.code then TABLE.complete(customDat
|
||||
TABLE.complete(require"parts.customEnv0",CUSTOMENV)
|
||||
|
||||
|
||||
--First start for phones
|
||||
if not fs.getInfo('conf/settings')and MOBILE then
|
||||
SETTING.VKSwitch=true
|
||||
SETTING.swap=false
|
||||
SETTING.powerInfo=true
|
||||
SETTING.cleanCanvas=true
|
||||
end
|
||||
if SETTING.fullscreen then love.window.setFullscreen(true)end
|
||||
|
||||
--Initialize image libs
|
||||
IMG.init{
|
||||
lock='media/image/mess/lock.png',
|
||||
@@ -359,6 +350,14 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
--First start for phones
|
||||
if FIRSTLAUNCH and MOBILE then
|
||||
SETTING.VKSwitch=true
|
||||
SETTING.swap=false
|
||||
SETTING.powerInfo=true
|
||||
SETTING.cleanCanvas=true
|
||||
end
|
||||
|
||||
--Apply system setting
|
||||
applySettings()
|
||||
|
||||
|
||||
@@ -338,18 +338,18 @@ VK_org={--Virtualkey layout, refresh all VKs' position with this before each gam
|
||||
{ava=true, x=200, y=720-320, r=80},--hardDrop
|
||||
{ava=true, x=200, y=720-80, r=80},--softDrop
|
||||
{ava=true, x=1280-320, y=720-200, r=80},--hold
|
||||
{ava=true, x=1280-80, y=280, r=80},--func1
|
||||
{ava=true, x=80, y=280, r=80},--func2
|
||||
{ava=false, x=100, y=50, r=80},--insLeft
|
||||
{ava=false, x=200, y=50, r=80},--insRight
|
||||
{ava=false, x=300, y=50, r=80},--insDown
|
||||
{ava=false, x=400, y=50, r=80},--down1
|
||||
{ava=false, x=500, y=50, r=80},--down4
|
||||
{ava=false, x=600, y=50, r=80},--down10
|
||||
{ava=false, x=700, y=50, r=80},--dropLeft
|
||||
{ava=false, x=800, y=50, r=80},--dropRight
|
||||
{ava=false, x=900, y=50, r=80},--addToLeft
|
||||
{ava=false, x=1000, y=50, r=80},--addToRight
|
||||
{ava=true, x=80, y=280, r=80},--func1
|
||||
{ava=true, x=1280-80, y=280, r=80},--func2
|
||||
{ava=false, x=670, y=50, r=30},--insLeft
|
||||
{ava=false, x=730, y=50, r=30},--insRight
|
||||
{ava=false, x=790, y=50, r=30},--insDown
|
||||
{ava=false, x=850, y=50, r=30},--down1
|
||||
{ava=false, x=910, y=50, r=30},--down4
|
||||
{ava=false, x=970, y=50, r=30},--down10
|
||||
{ava=false, x=1030, y=50, r=30},--dropLeft
|
||||
{ava=false, x=1090, y=50, r=30},--dropRight
|
||||
{ava=false, x=1150, y=50, r=30},--zangiLeft
|
||||
{ava=false, x=1210, y=50, r=30},--zangiRight
|
||||
}
|
||||
RANKS={sprint_10l=0}--Ranks of modes
|
||||
STAT={
|
||||
|
||||
@@ -103,96 +103,11 @@ function scene.draw()
|
||||
end
|
||||
end
|
||||
|
||||
local virtualkeySet={
|
||||
{
|
||||
{1, 80, 720-200, 80},--moveLeft
|
||||
{2, 320, 720-200, 80},--moveRight
|
||||
{3, 1280-80, 720-200, 80},--rotRight
|
||||
{4, 1280-200, 720-80, 80},--rotLeft
|
||||
{5, 1280-200, 720-320, 80},--rot180
|
||||
{6, 200, 720-320, 80},--hardDrop
|
||||
{7, 200, 720-80, 80},--softDrop
|
||||
{8, 1280-320, 720-200, 80},--hold
|
||||
{9, 80, 280, 80},--func1
|
||||
{10,1280-80, 280, 80},--func2
|
||||
},--Farter's tetr.js set
|
||||
{
|
||||
{1, 1280-320, 720-200, 80},--moveLeft
|
||||
{2, 1280-80, 720-200, 80},--moveRight
|
||||
{3, 200, 720-80, 80},--rotRight
|
||||
{4, 80, 720-200, 80},--rotLeft
|
||||
{5, 200, 720-320, 80},--rot180
|
||||
{6, 1280-200, 720-320, 80},--hardDrop
|
||||
{7, 1280-200, 720-80, 80},--softDrop
|
||||
{8, 320, 720-200, 80},--hold
|
||||
{9, 1280-80, 280, 80},--func1
|
||||
{10,80, 280, 80},--func2
|
||||
},--Mirrored tetr.js set
|
||||
{
|
||||
{1, 80, 720-80, 80},--moveLeft
|
||||
{2, 240, 720-80, 80},--moveRight
|
||||
{3, 1280-240, 720-80, 80},--rotRight
|
||||
{4, 1280-400, 720-80, 80},--rotLeft
|
||||
{5, 1280-240, 720-240, 80},--rot180
|
||||
{6, 1280-80, 720-80, 80},--hardDrop
|
||||
{7, 1280-80, 720-240, 80},--softDrop
|
||||
{8, 1280-80, 720-400, 80},--hold
|
||||
{9, 80, 720-240, 80},--func1
|
||||
{10,240, 720-240, 80},--func2
|
||||
},--Author's set, not recommend
|
||||
{
|
||||
{1, 1280-400, 720-80, 80},--moveLeft
|
||||
{2, 1280-80, 720-80, 80},--moveRight
|
||||
{3, 240, 720-80, 80},--rotRight
|
||||
{4, 80, 720-80, 80},--rotLeft
|
||||
{5, 240, 720-240, 80},--rot180
|
||||
{6, 1280-240, 720-240, 80},--hardDrop
|
||||
{7, 1280-240, 720-80, 80},--softDrop
|
||||
{8, 400, 720-80, 80},--hold
|
||||
{9, 80, 720-240, 80},--func1
|
||||
{10,80, 720-400, 80},--func2
|
||||
},--Keyboard set
|
||||
{
|
||||
{9, 70, 50,30},--func1
|
||||
{10,130, 50,30},--func2
|
||||
{4, 190, 50,30},--rotLeft
|
||||
{3, 250, 50,30},--rotRight
|
||||
{5, 310, 50,30},--rot180
|
||||
{1, 370, 50,30},--moveLeft
|
||||
{2, 430, 50,30},--moveRight
|
||||
{8, 490, 50,30},--hold
|
||||
{7, 550, 50,30},--softDrop1
|
||||
{6, 610, 50,30},--hardDrop
|
||||
{11,670, 50,30},--insLeft
|
||||
{12,730, 50,30},--insRight
|
||||
{13,790, 50,30},--insDown
|
||||
{14,850, 50,30},--down1
|
||||
{15,910, 50,30},--down4
|
||||
{16,970, 50,30},--down10
|
||||
{17,1030, 50,30},--dropLeft
|
||||
{18,1090, 50,30},--dropRight
|
||||
{19,1150, 50,30},--zangiLeft
|
||||
{20,1210, 50,30},--zangiRight
|
||||
},--PC key feedback(top&in a row)
|
||||
}
|
||||
scene.widgetList={
|
||||
WIDGET.newButton{name="default",x=530,y=90,w=200,h=80,font=35,
|
||||
code=function()
|
||||
local D=virtualkeySet[defaultSetSelect]
|
||||
for i=1,#VK_org do
|
||||
VK_org[i].ava=false
|
||||
end
|
||||
|
||||
--Replace keys
|
||||
for n=1,#D do
|
||||
local T=D[n]
|
||||
if T[1]then
|
||||
local B=VK_org[n]
|
||||
B.ava=true
|
||||
B.x,B.y,B.r=T[2],T[3],T[4]
|
||||
end
|
||||
end
|
||||
MES.new('check',("==[ %d ]=="):format(defaultSetSelect))
|
||||
VK.changeSet(defaultSetSelect)
|
||||
MES.new('check',"==[ "..defaultSetSelect.." ]==")
|
||||
defaultSetSelect=defaultSetSelect%5+1
|
||||
selected=false
|
||||
end},
|
||||
|
||||
@@ -28,6 +28,80 @@ local holdImages={
|
||||
GC.DO{200,200,{'fCirc',100,100,83,4}},
|
||||
GC.DO{200,200,{'fRect',43,43,114,114}},
|
||||
}
|
||||
|
||||
local virtualkeySet={
|
||||
{
|
||||
{id=1, x=80, y=720-200, r=80},--moveLeft
|
||||
{id=2, x=320, y=720-200, r=80},--moveRight
|
||||
{id=3, x=1280-80, y=720-200, r=80},--rotRight
|
||||
{id=4, x=1280-200, y=720-80, r=80},--rotLeft
|
||||
{id=5, x=1280-200, y=720-320, r=80},--rot180
|
||||
{id=6, x=200, y=720-320, r=80},--hardDrop
|
||||
{id=7, x=200, y=720-80, r=80},--softDrop
|
||||
{id=8, x=1280-320, y=720-200, r=80},--hold
|
||||
{id=9, x=80, y=280, r=80},--func1
|
||||
{id=10, x=1280-80, y=280, r=80},--func2
|
||||
},--Farter's tetr.js set
|
||||
{
|
||||
{id=1, x=1280-320, y=720-200, r=80},--moveLeft
|
||||
{id=2, x=1280-80, y=720-200, r=80},--moveRight
|
||||
{id=3, x=200, y=720-80, r=80},--rotRight
|
||||
{id=4, x=80, y=720-200, r=80},--rotLeft
|
||||
{id=5, x=200, y=720-320, r=80},--rot180
|
||||
{id=6, x=1280-200, y=720-320, r=80},--hardDrop
|
||||
{id=7, x=1280-200, y=720-80, r=80},--softDrop
|
||||
{id=8, x=320, y=720-200, r=80},--hold
|
||||
{id=9, x=1280-80, y=280, r=80},--func1
|
||||
{id=10, x=80, y=280, r=80},--func2
|
||||
},--Mirrored tetr.js set
|
||||
{
|
||||
{id=1, x=80, y=720-80, r=80},--moveLeft
|
||||
{id=2, x=240, y=720-80, r=80},--moveRight
|
||||
{id=3, x=1280-240, y=720-80, r=80},--rotRight
|
||||
{id=4, x=1280-400, y=720-80, r=80},--rotLeft
|
||||
{id=5, x=1280-240, y=720-240, r=80},--rot180
|
||||
{id=6, x=1280-80, y=720-80, r=80},--hardDrop
|
||||
{id=7, x=1280-80, y=720-240, r=80},--softDrop
|
||||
{id=8, x=1280-80, y=720-400, r=80},--hold
|
||||
{id=9, x=80, y=720-240, r=80},--func1
|
||||
{id=10, x=240, y=720-240, r=80},--func2
|
||||
},--Author's set, not recommend
|
||||
{
|
||||
{id=1, x=1280-400, y=720-80, r=80},--moveLeft
|
||||
{id=2, x=1280-80, y=720-80, r=80},--moveRight
|
||||
{id=3, x=240, y=720-80, r=80},--rotRight
|
||||
{id=4, x=80, y=720-80, r=80},--rotLeft
|
||||
{id=5, x=240, y=720-240, r=80},--rot180
|
||||
{id=6, x=1280-240, y=720-240, r=80},--hardDrop
|
||||
{id=7, x=1280-240, y=720-80, r=80},--softDrop
|
||||
{id=8, x=400, y=720-80, r=80},--hold
|
||||
{id=9, x=80, y=720-240, r=80},--func1
|
||||
{id=10, x=80, y=720-400, r=80},--func2
|
||||
},--Keyboard set
|
||||
{
|
||||
{id=9, x=70, y=50,r=30},--func1
|
||||
{id=10, x=130, y=50,r=30},--func2
|
||||
{id=4, x=190, y=50,r=30},--rotLeft
|
||||
{id=3, x=250, y=50,r=30},--rotRight
|
||||
{id=5, x=310, y=50,r=30},--rot180
|
||||
{id=1, x=370, y=50,r=30},--moveLeft
|
||||
{id=2, x=430, y=50,r=30},--moveRight
|
||||
{id=8, x=490, y=50,r=30},--hold
|
||||
{id=7, x=550, y=50,r=30},--softDrop
|
||||
{id=6, x=610, y=50,r=30},--hardDrop
|
||||
{id=11, x=670, y=50,r=30},--insLeft
|
||||
{id=12, x=730, y=50,r=30},--insRight
|
||||
{id=13, x=790, y=50,r=30},--insDown
|
||||
{id=14, x=850, y=50,r=30},--down1
|
||||
{id=15, x=910, y=50,r=30},--down4
|
||||
{id=16, x=970, y=50,r=30},--down10
|
||||
{id=17, x=1030, y=50,r=30},--dropLeft
|
||||
{id=18, x=1090, y=50,r=30},--dropRight
|
||||
{id=19, x=1150, y=50,r=30},--zangiLeft
|
||||
{id=20, x=1210, y=50,r=30},--zangiRight
|
||||
},--PC key feedback(top&in a row)
|
||||
}
|
||||
|
||||
--Virtualkey icons
|
||||
local VKIcon={}
|
||||
gc.setDefaultFilter('nearest','nearest')
|
||||
@@ -123,6 +197,16 @@ function VK.restore()
|
||||
end
|
||||
end
|
||||
|
||||
function VK.changeSet(id)
|
||||
local set=virtualkeySet[id]
|
||||
for i=1,#VK_org do VK_org[i].ava=false end
|
||||
for n=1,#set do
|
||||
local vk=set[n]
|
||||
local B=VK_org[vk.id]
|
||||
B.ava,B.x,B.y,B.r=true,vk.x,vk.y,vk.r
|
||||
end
|
||||
end
|
||||
|
||||
function VK.update()
|
||||
if SETTING.VKSwitch then
|
||||
for _,B in next,keys do
|
||||
|
||||
Reference in New Issue
Block a user