整理代码,表示键盘按键的字符串使用单引号
This commit is contained in:
@@ -218,31 +218,31 @@ end
|
||||
|
||||
local fnKey={NULL,NULL,NULL,NULL,NULL,NULL,NULL}
|
||||
local function noDevkeyPressed(key)
|
||||
if key=="f1"then fnKey[1]()
|
||||
elseif key=="f2"then fnKey[2]()
|
||||
elseif key=="f3"then fnKey[3]()
|
||||
elseif key=="f4"then fnKey[4]()
|
||||
elseif key=="f5"then fnKey[5]()
|
||||
elseif key=="f6"then fnKey[6]()
|
||||
elseif key=="f7"then fnKey[7]()
|
||||
elseif key=="f8"then devMode=nil MES.new('info',"DEBUG OFF",.2)
|
||||
elseif key=="f9"then devMode=1 MES.new('info',"DEBUG 1")
|
||||
elseif key=="f10"then devMode=2 MES.new('info',"DEBUG 2")
|
||||
elseif key=="f11"then devMode=3 MES.new('info',"DEBUG 3")
|
||||
elseif key=="f12"then devMode=4 MES.new('info',"DEBUG 4")
|
||||
if key=='f1'then fnKey[1]()
|
||||
elseif key=='f2'then fnKey[2]()
|
||||
elseif key=='f3'then fnKey[3]()
|
||||
elseif key=='f4'then fnKey[4]()
|
||||
elseif key=='f5'then fnKey[5]()
|
||||
elseif key=='f6'then fnKey[6]()
|
||||
elseif key=='f7'then fnKey[7]()
|
||||
elseif key=='f8'then devMode=nil MES.new('info',"DEBUG OFF",.2)
|
||||
elseif key=='f9'then devMode=1 MES.new('info',"DEBUG 1")
|
||||
elseif key=='f10'then devMode=2 MES.new('info',"DEBUG 2")
|
||||
elseif key=='f11'then devMode=3 MES.new('info',"DEBUG 3")
|
||||
elseif key=='f12'then devMode=4 MES.new('info',"DEBUG 4")
|
||||
elseif devMode==2 then
|
||||
local W=WIDGET.sel
|
||||
if W then
|
||||
if key=="left"then W.x=W.x-10
|
||||
elseif key=="right"then W.x=W.x+10
|
||||
elseif key=="up"then W.y=W.y-10
|
||||
elseif key=="down"then W.y=W.y+10
|
||||
elseif key==","then W.w=W.w-10
|
||||
elseif key=="."then W.w=W.w+10
|
||||
elseif key=="/"then W.h=W.h-10
|
||||
elseif key=="'"then W.h=W.h+10
|
||||
elseif key=="["then W.font=W.font-5
|
||||
elseif key=="]"then W.font=W.font+5
|
||||
if key=='left'then W.x=W.x-10
|
||||
elseif key=='right'then W.x=W.x+10
|
||||
elseif key=='up'then W.y=W.y-10
|
||||
elseif key=='down'then W.y=W.y+10
|
||||
elseif key==','then W.w=W.w-10
|
||||
elseif key=='.'then W.w=W.w+10
|
||||
elseif key=='/'then W.h=W.h-10
|
||||
elseif key=='\''then W.h=W.h+10
|
||||
elseif key=='['then W.font=W.font-5
|
||||
elseif key==']'then W.font=W.font+5
|
||||
else return true
|
||||
end
|
||||
else
|
||||
@@ -256,10 +256,10 @@ function love.keypressed(key,_,isRep)
|
||||
mouseShow=false
|
||||
if devMode and not noDevkeyPressed(key)then
|
||||
return
|
||||
elseif key=="f8"then
|
||||
elseif key=='f8'then
|
||||
devMode=1
|
||||
MES.new('info',"DEBUG ON",.2)
|
||||
elseif key=="f11"then
|
||||
elseif key=='f11'then
|
||||
SETTING.fullscreen=not SETTING.fullscreen
|
||||
applyFullscreen()
|
||||
saveSettings()
|
||||
@@ -268,7 +268,7 @@ function love.keypressed(key,_,isRep)
|
||||
if EDITING==""then
|
||||
SCN.keyDown(key,isRep)
|
||||
end
|
||||
elseif key=="escape"and not isRep then
|
||||
elseif key=='escape'and not isRep then
|
||||
SCN.back()
|
||||
else
|
||||
WIDGET.keyPressed(key,isRep)
|
||||
|
||||
@@ -9,11 +9,11 @@ return function(y,key1,key2)
|
||||
trigDist=min(trigDist,0)-(-y)^1.2
|
||||
end
|
||||
while trigDist>=1 do
|
||||
love.keypressed(key1 or"up")
|
||||
love.keypressed(key1 or'up')
|
||||
trigDist=trigDist-1
|
||||
end
|
||||
while trigDist<=-1 do
|
||||
love.keypressed(key2 or"down")
|
||||
love.keypressed(key2 or'down')
|
||||
trigDist=trigDist+1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -597,7 +597,7 @@ function slider:scroll(n)
|
||||
end
|
||||
end
|
||||
function slider:arrowKey(k)
|
||||
self:scroll((k=="left"or k=="up")and -1 or 1)
|
||||
self:scroll((k=='left'or k=='up')and -1 or 1)
|
||||
end
|
||||
function WIDGET.newSlider(D)--name,x,y,w[,lim][,fText][,color][,unit][,smooth][,font=30][,fType][,change],disp[,show],code,hide
|
||||
local _={
|
||||
@@ -773,7 +773,7 @@ function selector:scroll(n)
|
||||
end
|
||||
end
|
||||
function selector:arrowKey(k)
|
||||
self:scroll((k=="left"or k=="up")and -1 or 1)
|
||||
self:scroll((k=='left'or k=='up')and -1 or 1)
|
||||
end
|
||||
|
||||
function WIDGET.newSelector(D)--name,x,y,w[,fText][,color][,sound=true],list,disp,code,hide
|
||||
@@ -897,14 +897,14 @@ end
|
||||
function inputBox:keypress(k)
|
||||
local t=self.value
|
||||
if #t>0 and EDITING==""then
|
||||
if k=="backspace"then
|
||||
if k=='backspace'then
|
||||
local p=#t
|
||||
while t:byte(p)>=128 and t:byte(p)<192 do
|
||||
p=p-1
|
||||
end
|
||||
t=sub(t,1,p-1)
|
||||
SFX.play('lock')
|
||||
elseif k=="delete"then
|
||||
elseif k=='delete'then
|
||||
t=""
|
||||
SFX.play('hold')
|
||||
end
|
||||
@@ -1005,9 +1005,9 @@ function textBox:scroll(dir)
|
||||
self:drag(nil,nil,nil,-dir*self.lineH)
|
||||
end
|
||||
function textBox:arrowKey(k)
|
||||
if k=="up"then
|
||||
if k=='up'then
|
||||
self:scroll(-1)
|
||||
elseif k=="down"then
|
||||
elseif k=='down'then
|
||||
self:scroll(-1)
|
||||
end
|
||||
end
|
||||
@@ -1382,12 +1382,12 @@ function WIDGET.release(x,y)
|
||||
end
|
||||
function WIDGET.keyPressed(k,isRep)
|
||||
local W=WIDGET.sel
|
||||
if k=="space"or k=="return"then
|
||||
if k=='space'or k=='return'then
|
||||
if not isRep then
|
||||
WIDGET.press()
|
||||
end
|
||||
elseif k=="up"or k=="down"or k=="left"or k=="right"then
|
||||
if kb.isDown("lshift","lalt","lctrl","rshift","ralt","rctrl")then
|
||||
elseif k=='up'or k=='down'or k=='left'or k=='right'then
|
||||
if kb.isDown('lshift','lalt','lctrl','rshift','ralt','rctrl')then
|
||||
--Control some widgets with arrowkeys when hold shift/ctrl/alt
|
||||
if W and W.arrowKey then W:arrowKey(k)end
|
||||
else
|
||||
@@ -1400,10 +1400,10 @@ function WIDGET.keyPressed(k,isRep)
|
||||
end
|
||||
elseif W.getCenter then
|
||||
local WX,WY=W:getCenter()
|
||||
local dir=(k=="right"or k=="down")and 1 or -1
|
||||
local dir=(k=='right'or k=='down')and 1 or -1
|
||||
local tar
|
||||
local minDist=1e99
|
||||
local swap_xy=k=="up"or k=="down"
|
||||
local swap_xy=k=='up'or k=='down'
|
||||
if swap_xy then WX,WY=WY,WX end--note that we do not swap them back later
|
||||
for _,W1 in ipairs(WIDGET.active)do
|
||||
if W~=W1 and W1.resCtr and not W1.hide then
|
||||
@@ -1445,24 +1445,24 @@ function WIDGET.textinput(texts)
|
||||
end
|
||||
end
|
||||
local keyMirror={
|
||||
dpup="up",
|
||||
dpdown="down",
|
||||
dpleft="left",
|
||||
dpright="right",
|
||||
start="return",
|
||||
back="escape",
|
||||
dpup='up',
|
||||
dpdown='down',
|
||||
dpleft='left',
|
||||
dpright='right',
|
||||
start='return',
|
||||
back='escape',
|
||||
}
|
||||
function WIDGET.gamepadPressed(i)
|
||||
if i=="start"then
|
||||
if i=='start'then
|
||||
WIDGET.press()
|
||||
elseif i=="a"or i=="b"then
|
||||
elseif i=='a'or i=='b'then
|
||||
local W=WIDGET.sel
|
||||
if W then
|
||||
if W.type=='button'or W.type=='key'then
|
||||
WIDGET.press()
|
||||
elseif W.type=='slider'then
|
||||
local p=W.disp()
|
||||
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
|
||||
local P=i=='left'and(p>0 and p-1)or p<W.unit and p+1
|
||||
if p==P or not P then return end
|
||||
W.code(P)
|
||||
if W.change and timer()-W.lastTime>.18 then
|
||||
@@ -1471,7 +1471,7 @@ function WIDGET.gamepadPressed(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif i=="dpup"or i=="dpdown"or i=="dpleft"or i=="dpright"then
|
||||
elseif i=='dpup'or i=='dpdown'or i=='dpleft'or i=='dpright'then
|
||||
WIDGET.keyPressed(keyMirror[i])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user