删除虚拟按键颜色,恢复最早的白色

This commit is contained in:
MrZ626
2021-05-05 15:51:45 +08:00
parent 29a5556c33
commit 65a4bd3665
3 changed files with 78 additions and 95 deletions

View File

@@ -272,13 +272,7 @@ do
end
SETTING.appLock=nil
for _,v in next,VK_org do
if not v.color then
fs.remove("conf/virtualkey")
autoRestart=true
break
end
end
for _,v in next,VK_org do v.color=nil end
if STAT.version~=VERSION.code then
newVersionLaunch=true

View File

@@ -337,25 +337,25 @@ keyMap=FILE.load("conf/key")or{--Key setting
},
}
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,color=COLOR.L},--moveLeft
{ava=true, x=320, y=720-200, r=80,color=COLOR.L},--moveRight
{ava=true, x=1280-80, y=720-200, r=80,color=COLOR.R},--rotRight
{ava=true, x=1280-200, y=720-80, r=80,color=COLOR.O},--rotLeft
{ava=true, x=1280-200, y=720-320, r=80,color=COLOR.M},--rot180
{ava=true, x=200, y=720-320, r=80,color=COLOR.C},--hardDrop
{ava=true, x=200, y=720-80, r=80,color=COLOR.S},--softDrop
{ava=true, x=1280-320, y=720-200, r=80,color=COLOR.Y},--hold
{ava=true, x=1280-80, y=280, r=80,color=COLOR.lR},--func1
{ava=true, x=80, y=280, r=80,color=COLOR.lM},--func2
{ava=false, x=100, y=50, r=80,color=COLOR.A},--insLeft
{ava=false, x=200, y=50, r=80,color=COLOR.A},--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.lL},--dropLeft
{ava=false, x=800, y=50, r=80,color=COLOR.lL},--dropRight
{ava=false, x=900, y=50, r=80,color=COLOR.lA},--addToLeft
{ava=false, x=1000, y=50, r=80,color=COLOR.lA},--addToRight
{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},--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
}
REPLAY=FILE.load("conf/replay")or{}

View File

@@ -1,6 +1,7 @@
local gc=love.graphics
local SETTING=SETTING
local next=next
local SETTING,TIME=SETTING,TIME
local VK_org=VK_org
--Virtualkey icons
local VKIcon={}
@@ -17,13 +18,12 @@ local VK={keys=keys}
function VK.on(x,y)
local dist,nearest=1e10
for K=1,#keys do
local B=keys[K]
for id,B in next,keys do
if B.ava then
local d1=(x-B.x)^2+(y-B.y)^2
if d1<B.r^2 then
if d1<dist then
nearest,dist=K,d1
nearest,dist=id,d1
end
end
end
@@ -47,8 +47,7 @@ function VK.touch(id,x,y)
--Button collision (not accurate)
if SETTING.VKDodge then
for i=1,#keys do
local b=keys[i]
for _,b in next,keys do
local d=B.r+b.r-((B.x-b.x)^2+(B.y-b.y)^2)^.5--Hit depth(Neg means distance)
if d>0 then
b.x=b.x+(b.x-B.x)*d*b.r*2.6e-5
@@ -81,23 +80,21 @@ function VK.restore()
B.x=O.x
B.y=O.y
B.r=O.r
B.color=O.color
B.isDown=false
B.pressTime=0
end
for k,v in next,PLAYERS[1].keyAvailable do
for id,v in next,PLAYERS[1].keyAvailable do
if not v then
keys[k].ava=false
keys[id].ava=false
end
end
end
function VK.update()
if SETTING.VKSwitch then
for i=1,#keys do
local _=keys[i]
if _.pressTime>0 then
_.pressTime=_.pressTime-1
for _,B in next,keys do
if B.pressTime>0 then
B.pressTime=B.pressTime-1
end
end
end
@@ -105,72 +102,64 @@ end
local gc_circle,gc_draw,gc_setColor,gc_setLineWidth=gc.circle,gc.draw,gc.setColor,gc.setLineWidth
function VK.draw()
if SETTING.VKSwitch then
local a=SETTING.VKAlpha
if SETTING.VKIcon then
for i=1,#keys do
if keys[i].ava then
local B=keys[i]
if not SETTING.VKSwitch then return end
local a=SETTING.VKAlpha
if SETTING.VKIcon then
for i,B in next,keys do
if B.ava then
--Button outline
gc_setColor(1,1,1,a)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
--Button outline
gc_setColor(1,1,1,a)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
--Icon
local _=B.pressTime
gc_setColor(1,1,1,a)
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)
--Icon
local _=keys[i].pressTime
local c=B.color
gc_setColor(c[1],c[2],c[3],a)
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)
--Ripple
if _>0 then
gc_setColor(1,1,1,a*_*.08)
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
end
--Ripple
if _>0 then
gc_setColor(1,1,1,a*_*.08)
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
end
--Glow when press
if B.isDown then
gc_setColor(1,1,1,a*.4)
gc_circle('fill',B.x,B.y,B.r*.94,10)
end
--Glow when press
if B.isDown then
gc_setColor(1,1,1,a*.4)
gc_circle('fill',B.x,B.y,B.r*.94,10)
end
end
else
for i=1,#keys do
if keys[i].ava then
local B=keys[i]
gc_setColor(1,1,1,a)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
local _=keys[i].pressTime
if _>0 then
gc_setColor(1,1,1,a*_*.08)
gc_circle('fill',B.x,B.y,B.r*.94,10)
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
end
end
else
for _,B in next,keys do
if B.ava then
gc_setColor(1,1,1,a)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
local _=B.pressTime
if _>0 then
gc_setColor(1,1,1,a*_*.08)
gc_circle('fill',B.x,B.y,B.r*.94,10)
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
end
end
end
end
end
function VK.preview(selected)
if SETTING.VKSwitch then
for i=1,#VK_org do
local B=VK_org[i]
if B.ava then
if not SETTING.VKSwitch then return end
for id,B in next,VK_org do
if B.ava then
gc_setColor(1,1,1,SETTING.VKAlpha)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
if selected==id 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(1,1,1,SETTING.VKAlpha)
gc_setLineWidth(B.r*.07)
gc_circle('line',B.x,B.y,B.r,10)
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
local c=B.color
gc_setColor(c[1],c[2],c[3],SETTING.VKAlpha)
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.025,nil,18,18)
end
gc_draw(VKIcon[id],B.x,B.y,nil,B.r*.025,nil,18,18)
end
end
end