给虚拟按键添加颜色

This commit is contained in:
MrZ626
2021-01-17 01:12:11 +08:00
parent ba8a39465f
commit 667c3c240b
5 changed files with 32 additions and 25 deletions

View File

@@ -425,6 +425,7 @@ function restoreVirtualKey()
B.x=O.x
B.y=O.y
B.r=O.r
B.color=O.color
B.isDown=false
B.pressTime=0
end

View File

@@ -340,26 +340,26 @@ keyMap=FILE.load("conf/key")or{--Key setting
--Joystick
}for i=1,#keyMap do for j=1,20 do if not keyMap[i][j]then keyMap[i][j]=""end end end
VK_org=FILE.load("conf/virtualkey")or{--Virtualkey layout, refresh all VKs' position with this before each game
{ava=true, x=80, y=720-200, r=80},--moveLeft
{ava=true, x=320, y=720-200, r=80},--moveRight
{ava=true, x=1280-80, y=720-200, r=80},--rotRight
{ava=true, x=1280-200, y=720-80, r=80},--rotLeft
{ava=true, x=1280-200, y=720-320, r=80},--rot180
{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},--func
{ava=true, x=80, y=280, r=80},--restart
{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=720-200, r=80,color=COLOR.lame},--moveLeft
{ava=true, x=320, y=720-200, r=80,color=COLOR.lame},--moveRight
{ava=true, x=1280-80, y=720-200, r=80,color=COLOR.red},--rotRight
{ava=true, x=1280-200, y=720-80, r=80,color=COLOR.orange},--rotLeft
{ava=true, x=1280-200, y=720-320, r=80,color=COLOR.magenta},--rot180
{ava=true, x=200, y=720-320, r=80,color=COLOR.cyan},--hardDrop
{ava=true, x=200, y=720-80, r=80,color=COLOR.sea},--softDrop
{ava=true, x=1280-320, y=720-200, r=80,color=COLOR.yellow},--hold
{ava=true, x=1280-80, y=280, r=80,color=COLOR.lRed},--func
{ava=true, x=80, y=280, r=80,color=COLOR.lMagenta},--restart
{ava=false, x=100, y=50, r=80,color=COLOR.water},--insLeft
{ava=false, x=200, y=50, r=80,color=COLOR.water},--insRight
{ava=false, x=300, y=50, r=80,color={COLOR.rainbow(3.5)}},--insDown
{ava=false, x=400, y=50, r=80,color={COLOR.rainbow(3.3)}},--down1
{ava=false, x=500, y=50, r=80,color={COLOR.rainbow(3.1)}},--down4
{ava=false, x=600, y=50, r=80,color={COLOR.rainbow(2.9)}},--down10
{ava=false, x=700, y=50, r=80,color=COLOR.lLame},--dropLeft
{ava=false, x=800, y=50, r=80,color=COLOR.lLame},--dropRight
{ava=false, x=900, y=50, r=80,color=COLOR.lWater},--addToLeft
{ava=false, x=1000, y=50, r=80,color=COLOR.lWater},--addToRight
}
virtualkey={}for i=1,#VK_org do virtualkey[i]={}end--In-game virtualkey layout
REPLAY=FILE.load("conf/replay")or{}

View File

@@ -258,7 +258,6 @@ function scene.draw()
end
--Virtual keys
gc_setColor(1,1,1)
if SETTING.VKSwitch then
local a=SETTING.VKAlpha
local _
@@ -271,6 +270,7 @@ function scene.draw()
gc.setLineWidth(B.r*.07)
gc_circle("line",B.x,B.y,B.r,10)--Button outline
_=VK[i].pressTime
gc_setColor(B.color[1],B.color[2],B.color[3],a)
gc.draw(icons[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)--Icon
if _>0 then
gc_setColor(1,1,1,a*_*.08)

View File

@@ -284,7 +284,6 @@ function scene.draw()
end
--Virtual keys
gc_setColor(1,1,1)
if SETTING.VKSwitch then
local a=SETTING.VKAlpha
local _
@@ -297,6 +296,7 @@ function scene.draw()
gc.setLineWidth(B.r*.07)
gc_circle("line",B.x,B.y,B.r,10)--Button outline
_=VK[i].pressTime
gc_setColor(B.color[1],B.color[2],B.color[3],a)
gc.draw(icons[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)--Icon
if _>0 then
gc_setColor(1,1,1,a*_*.08)

View File

@@ -73,11 +73,17 @@ local function VirtualkeyPreview()
for i=1,#VK_org do
local B=VK_org[i]
if B.ava then
local c=selected==i and .6 or 1
gc.setColor(c,1,c,SETTING.VKAlpha)
gc.setColor(1,1,1,SETTING.VKAlpha)
gc.setLineWidth(B.r*.07)
gc.circle("line",B.x,B.y,B.r,10)
if SETTING.VKIcon then gc.draw(TEXTURE.VKIcon[i],B.x,B.y,nil,B.r*.025,nil,18,18)end
if selected==i and TIME()%.26<.13 then
gc.setColor(1,1,1,SETTING.VKAlpha*.62)
gc.circle("fill",B.x,B.y,B.r,10)
end
if SETTING.VKIcon then
gc.setColor(B.color[1],B.color[2],B.color[3],SETTING.VKAlpha)
gc.draw(TEXTURE.VKIcon[i],B.x,B.y,nil,B.r*.025,nil,18,18)
end
end
end
end