代码规范:把所有的tab换成空格
This commit is contained in:
@@ -10,234 +10,234 @@ local cur--Cursor position
|
||||
local sure
|
||||
|
||||
function scene.sceneInit()
|
||||
cur=#BAG
|
||||
sure=0
|
||||
cur=#BAG
|
||||
sure=0
|
||||
end
|
||||
function scene.sceneBack()
|
||||
FILE.save(DATA.copySequence(),'conf/customSequence')
|
||||
FILE.save(DATA.copySequence(),'conf/customSequence')
|
||||
end
|
||||
|
||||
local minoKey={
|
||||
['1']=1,['2']=2,['3']=3,['4']=4,['5']=5,['6']=6,['7']=7,
|
||||
z=1,s=2,j=3,l=4,t=5,o=6,i=7,
|
||||
p=10,q=11,f=12,e=13,u=15,
|
||||
v=16,w=17,x=18,r=21,y=22,n=23,h=24,
|
||||
['/']=26,c=27,[',']=27,['\'']=27,['-']=28,[';']=28,['.']=29,
|
||||
['1']=1,['2']=2,['3']=3,['4']=4,['5']=5,['6']=6,['7']=7,
|
||||
z=1,s=2,j=3,l=4,t=5,o=6,i=7,
|
||||
p=10,q=11,f=12,e=13,u=15,
|
||||
v=16,w=17,x=18,r=21,y=22,n=23,h=24,
|
||||
['/']=26,c=27,[',']=27,['\'']=27,['-']=28,[';']=28,['.']=29,
|
||||
}
|
||||
local minoKey2={
|
||||
['1']=8,['2']=9,['3']=19,['4']=20,['5']=14,['7']=25,
|
||||
z=8,s=9,t=14,j=19,l=20,i=25,['-']=26,o=29,
|
||||
['1']=8,['2']=9,['3']=19,['4']=20,['5']=14,['7']=25,
|
||||
z=8,s=9,t=14,j=19,l=20,i=25,['-']=26,o=29,
|
||||
}
|
||||
function scene.keyDown(key)
|
||||
if key=="left"then
|
||||
local p=cur
|
||||
if p==0 then
|
||||
cur=#BAG
|
||||
else
|
||||
repeat
|
||||
p=p-1
|
||||
until BAG[p]~=BAG[cur]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="right"then
|
||||
local p=cur
|
||||
if p==#BAG then
|
||||
cur=0
|
||||
else
|
||||
repeat
|
||||
p=p+1
|
||||
until BAG[p+1]~=BAG[cur+1]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="ten"then
|
||||
for _=1,10 do
|
||||
local p=cur
|
||||
if p==#BAG then break end
|
||||
repeat
|
||||
p=p+1
|
||||
until BAG[p+1]~=BAG[cur+1]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="backspace"then
|
||||
if cur>0 then
|
||||
rem(BAG,cur)
|
||||
cur=cur-1
|
||||
if cur>0 and BAG[cur]==BAG[cur+1]then
|
||||
scene.keyDown("right")
|
||||
end
|
||||
end
|
||||
elseif key=="delete"then
|
||||
if sure>.3 then
|
||||
TABLE.cut(BAG)
|
||||
cur=0
|
||||
sure=0
|
||||
SFX.play('finesseError',.7)
|
||||
else
|
||||
sure=1
|
||||
end
|
||||
elseif key=="="then
|
||||
local l={1,2,3,4,5,6,7}
|
||||
repeat scene.keyDown(rem(l,math.random(#l)))until not l[1]
|
||||
elseif key=="tab"then
|
||||
WIDGET.active.sequence:scroll(kb.isDown("lshift","rshift")and -1 or 1)
|
||||
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
|
||||
if #BAG>0 then
|
||||
sys.setClipboardText("Techmino SEQ:"..DATA.copySequence())
|
||||
MES.new('check',text.exportSuccess)
|
||||
end
|
||||
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
|
||||
local str=sys.getClipboardText()
|
||||
local p=str:find(":")--ptr*
|
||||
if p then
|
||||
if not str:sub(1,p-1):find("SEQ")then
|
||||
MES.new('error',text.pasteWrongPlace)
|
||||
end
|
||||
str=str:sub(p+1)
|
||||
end
|
||||
if DATA.pasteSequence(str)then
|
||||
MES.new('check',text.importSuccess)
|
||||
cur=#BAG
|
||||
else
|
||||
TABLE.cut(BAG)
|
||||
cur=0
|
||||
MES.new('error',text.dataCorrupted)
|
||||
end
|
||||
elseif key=="escape"then
|
||||
SCN.back()
|
||||
elseif type(key)=='number'then
|
||||
cur=cur+1
|
||||
ins(BAG,cur,key)
|
||||
elseif #key==1 then
|
||||
key=(kb.isDown("lshift","lalt","rshift","ralt")and minoKey2 or minoKey)[key]
|
||||
if key then
|
||||
local p=cur+1
|
||||
while BAG[p]==key do p=p+1 end
|
||||
ins(BAG,p,key)
|
||||
cur=p
|
||||
SFX.play('lock')
|
||||
end
|
||||
end
|
||||
if key=="left"then
|
||||
local p=cur
|
||||
if p==0 then
|
||||
cur=#BAG
|
||||
else
|
||||
repeat
|
||||
p=p-1
|
||||
until BAG[p]~=BAG[cur]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="right"then
|
||||
local p=cur
|
||||
if p==#BAG then
|
||||
cur=0
|
||||
else
|
||||
repeat
|
||||
p=p+1
|
||||
until BAG[p+1]~=BAG[cur+1]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="ten"then
|
||||
for _=1,10 do
|
||||
local p=cur
|
||||
if p==#BAG then break end
|
||||
repeat
|
||||
p=p+1
|
||||
until BAG[p+1]~=BAG[cur+1]
|
||||
cur=p
|
||||
end
|
||||
elseif key=="backspace"then
|
||||
if cur>0 then
|
||||
rem(BAG,cur)
|
||||
cur=cur-1
|
||||
if cur>0 and BAG[cur]==BAG[cur+1]then
|
||||
scene.keyDown("right")
|
||||
end
|
||||
end
|
||||
elseif key=="delete"then
|
||||
if sure>.3 then
|
||||
TABLE.cut(BAG)
|
||||
cur=0
|
||||
sure=0
|
||||
SFX.play('finesseError',.7)
|
||||
else
|
||||
sure=1
|
||||
end
|
||||
elseif key=="="then
|
||||
local l={1,2,3,4,5,6,7}
|
||||
repeat scene.keyDown(rem(l,math.random(#l)))until not l[1]
|
||||
elseif key=="tab"then
|
||||
WIDGET.active.sequence:scroll(kb.isDown("lshift","rshift")and -1 or 1)
|
||||
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
|
||||
if #BAG>0 then
|
||||
sys.setClipboardText("Techmino SEQ:"..DATA.copySequence())
|
||||
MES.new('check',text.exportSuccess)
|
||||
end
|
||||
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
|
||||
local str=sys.getClipboardText()
|
||||
local p=str:find(":")--ptr*
|
||||
if p then
|
||||
if not str:sub(1,p-1):find("SEQ")then
|
||||
MES.new('error',text.pasteWrongPlace)
|
||||
end
|
||||
str=str:sub(p+1)
|
||||
end
|
||||
if DATA.pasteSequence(str)then
|
||||
MES.new('check',text.importSuccess)
|
||||
cur=#BAG
|
||||
else
|
||||
TABLE.cut(BAG)
|
||||
cur=0
|
||||
MES.new('error',text.dataCorrupted)
|
||||
end
|
||||
elseif key=="escape"then
|
||||
SCN.back()
|
||||
elseif type(key)=='number'then
|
||||
cur=cur+1
|
||||
ins(BAG,cur,key)
|
||||
elseif #key==1 then
|
||||
key=(kb.isDown("lshift","lalt","rshift","ralt")and minoKey2 or minoKey)[key]
|
||||
if key then
|
||||
local p=cur+1
|
||||
while BAG[p]==key do p=p+1 end
|
||||
ins(BAG,p,key)
|
||||
cur=p
|
||||
SFX.play('lock')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function scene.update(dt)
|
||||
if sure>0 then sure=sure-dt end
|
||||
if sure>0 then sure=sure-dt end
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
--Draw frame
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.setLineWidth(2)
|
||||
gc.rectangle('line',100,110,1080,260,5)
|
||||
--Draw frame
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.setLineWidth(2)
|
||||
gc.rectangle('line',100,110,1080,260,5)
|
||||
|
||||
--Draw sequence
|
||||
local miniBlock=TEXTURE.miniBlock
|
||||
local libColor=minoColor
|
||||
local set=SETTING.skin
|
||||
local L=BAG
|
||||
local x,y=120,136--Next block pos
|
||||
local cx,cy=120,136--Cursor-center pos
|
||||
local i,j=1,#L
|
||||
local count=1
|
||||
setFont(25)
|
||||
repeat
|
||||
if L[i]==L[i-1]then
|
||||
count=count+1
|
||||
else
|
||||
if count>1 then
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print("×",x-5,y-14)
|
||||
gc.print(count,x+10,y-13)
|
||||
x=x+(count<10 and 33 or 45)
|
||||
count=1
|
||||
if i==cur+1 then
|
||||
cx,cy=x,y
|
||||
end
|
||||
end
|
||||
if x>1060 then
|
||||
x,y=120,y+50
|
||||
if y>1260 then break end
|
||||
end
|
||||
if i<=j then
|
||||
local B=miniBlock[L[i]]
|
||||
gc.setColor(libColor[set[L[i]]])
|
||||
gc.draw(B,x,y,nil,15,15,0,B:getHeight()*.5)
|
||||
x=x+B:getWidth()*15+10
|
||||
end
|
||||
end
|
||||
--Draw sequence
|
||||
local miniBlock=TEXTURE.miniBlock
|
||||
local libColor=minoColor
|
||||
local set=SETTING.skin
|
||||
local L=BAG
|
||||
local x,y=120,136--Next block pos
|
||||
local cx,cy=120,136--Cursor-center pos
|
||||
local i,j=1,#L
|
||||
local count=1
|
||||
setFont(25)
|
||||
repeat
|
||||
if L[i]==L[i-1]then
|
||||
count=count+1
|
||||
else
|
||||
if count>1 then
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print("×",x-5,y-14)
|
||||
gc.print(count,x+10,y-13)
|
||||
x=x+(count<10 and 33 or 45)
|
||||
count=1
|
||||
if i==cur+1 then
|
||||
cx,cy=x,y
|
||||
end
|
||||
end
|
||||
if x>1060 then
|
||||
x,y=120,y+50
|
||||
if y>1260 then break end
|
||||
end
|
||||
if i<=j then
|
||||
local B=miniBlock[L[i]]
|
||||
gc.setColor(libColor[set[L[i]]])
|
||||
gc.draw(B,x,y,nil,15,15,0,B:getHeight()*.5)
|
||||
x=x+B:getWidth()*15+10
|
||||
end
|
||||
end
|
||||
|
||||
if i==cur then
|
||||
cx,cy=x,y
|
||||
end
|
||||
i=i+1
|
||||
until i>j+1
|
||||
if i==cur then
|
||||
cx,cy=x,y
|
||||
end
|
||||
i=i+1
|
||||
until i>j+1
|
||||
|
||||
--Draw lenth
|
||||
setFont(40)
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print(#L,120,310)
|
||||
--Draw lenth
|
||||
setFont(40)
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print(#L,120,310)
|
||||
|
||||
--Draw cursor
|
||||
gc.setColor(.5,1,.5,.6+.4*sin(TIME()*6.26))
|
||||
gc.line(cx-5,cy-20,cx-5,cy+20)
|
||||
--Draw cursor
|
||||
gc.setColor(.5,1,.5,.6+.4*sin(TIME()*6.26))
|
||||
gc.line(cx-5,cy-20,cx-5,cy+20)
|
||||
|
||||
--Confirm reset
|
||||
if sure>0 then
|
||||
gc.setColor(1,1,1,sure)
|
||||
mDraw(TEXTURE.sure,1000,460,nil,.8)
|
||||
end
|
||||
--Confirm reset
|
||||
if sure>0 then
|
||||
gc.setColor(1,1,1,sure)
|
||||
mDraw(TEXTURE.sure,1000,460,nil,.8)
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name="title",x=520,y=5,font=70,align='R'},
|
||||
WIDGET.newText{name="subTitle",x=530,y=50,font=35,align='L',color='H'},
|
||||
WIDGET.newText{name="title",x=520,y=5,font=70,align='R'},
|
||||
WIDGET.newText{name="subTitle",x=530,y=50,font=35,align='L',color='H'},
|
||||
|
||||
WIDGET.newSelector{name="sequence",x=1080,y=60,w=200,color='Y',
|
||||
list={'bag','his','hisPool','c2','rnd','mess','reverb','loop','fixed'},
|
||||
disp=CUSval("sequence"),code=CUSsto("sequence")
|
||||
},
|
||||
WIDGET.newSelector{name="sequence",x=1080,y=60,w=200,color='Y',
|
||||
list={'bag','his','hisPool','c2','rnd','mess','reverb','loop','fixed'},
|
||||
disp=CUSval("sequence"),code=CUSsto("sequence")
|
||||
},
|
||||
|
||||
WIDGET.newKey{name="Z", x=120,y=460,w=80,font=50,code=pressKey(1)},
|
||||
WIDGET.newKey{name="S", x=200,y=460,w=80,font=50,code=pressKey(2)},
|
||||
WIDGET.newKey{name="J", x=280,y=460,w=80,font=50,code=pressKey(3)},
|
||||
WIDGET.newKey{name="L", x=360,y=460,w=80,font=50,code=pressKey(4)},
|
||||
WIDGET.newKey{name="T", x=440,y=460,w=80,font=50,code=pressKey(5)},
|
||||
WIDGET.newKey{name="O", x=520,y=460,w=80,font=50,code=pressKey(6)},
|
||||
WIDGET.newKey{name="I", x=600,y=460,w=80,font=50,code=pressKey(7)},
|
||||
WIDGET.newKey{name="left", x=680,y=460,w=80,color='lG',font=55,code=pressKey"left"},
|
||||
WIDGET.newKey{name="right", x=760,y=460,w=80,color='lG',font=55,code=pressKey"right"},
|
||||
WIDGET.newKey{name="ten", x=840,y=460,w=80,color='lG',font=40,code=pressKey"ten"},
|
||||
WIDGET.newKey{name="backsp",x=920,y=460,w=80,color='lY',font=50,code=pressKey"backspace"},
|
||||
WIDGET.newKey{name="reset", x=1000,y=460,w=80,color='lY',font=25,code=pressKey"delete"},
|
||||
WIDGET.newKey{name="Z", x=120,y=460,w=80,font=50,code=pressKey(1)},
|
||||
WIDGET.newKey{name="S", x=200,y=460,w=80,font=50,code=pressKey(2)},
|
||||
WIDGET.newKey{name="J", x=280,y=460,w=80,font=50,code=pressKey(3)},
|
||||
WIDGET.newKey{name="L", x=360,y=460,w=80,font=50,code=pressKey(4)},
|
||||
WIDGET.newKey{name="T", x=440,y=460,w=80,font=50,code=pressKey(5)},
|
||||
WIDGET.newKey{name="O", x=520,y=460,w=80,font=50,code=pressKey(6)},
|
||||
WIDGET.newKey{name="I", x=600,y=460,w=80,font=50,code=pressKey(7)},
|
||||
WIDGET.newKey{name="left", x=680,y=460,w=80,color='lG',font=55,code=pressKey"left"},
|
||||
WIDGET.newKey{name="right", x=760,y=460,w=80,color='lG',font=55,code=pressKey"right"},
|
||||
WIDGET.newKey{name="ten", x=840,y=460,w=80,color='lG',font=40,code=pressKey"ten"},
|
||||
WIDGET.newKey{name="backsp",x=920,y=460,w=80,color='lY',font=50,code=pressKey"backspace"},
|
||||
WIDGET.newKey{name="reset", x=1000,y=460,w=80,color='lY',font=25,code=pressKey"delete"},
|
||||
|
||||
WIDGET.newKey{name="Z5", x=120,y=550,w=80,color='lH',font=50,code=pressKey(8)},
|
||||
WIDGET.newKey{name="S5", x=200,y=550,w=80,color='lH',font=50,code=pressKey(9)},
|
||||
WIDGET.newKey{name="P", x=280,y=550,w=80,color='lH',font=50,code=pressKey(10)},
|
||||
WIDGET.newKey{name="Q", x=360,y=550,w=80,color='lH',font=50,code=pressKey(11)},
|
||||
WIDGET.newKey{name="F", x=440,y=550,w=80,color='lH',font=50,code=pressKey(12)},
|
||||
WIDGET.newKey{name="E", x=520,y=550,w=80,color='lH',font=50,code=pressKey(13)},
|
||||
WIDGET.newKey{name="T5", x=600,y=550,w=80,color='lH',font=50,code=pressKey(14)},
|
||||
WIDGET.newKey{name="U", x=680,y=550,w=80,color='lH',font=50,code=pressKey(15)},
|
||||
WIDGET.newKey{name="V", x=760,y=550,w=80,color='lH',font=50,code=pressKey(16)},
|
||||
WIDGET.newKey{name="I3", x=840,y=550,w=80,color='H',font=50,code=pressKey(26)},
|
||||
WIDGET.newKey{name="C", x=920,y=550,w=80,color='H',font=50,code=pressKey(27)},
|
||||
WIDGET.newKey{name="rnd", x=1000,y=550,w=80,color='R',font=25,code=pressKey"="},
|
||||
WIDGET.newKey{name="Z5", x=120,y=550,w=80,color='lH',font=50,code=pressKey(8)},
|
||||
WIDGET.newKey{name="S5", x=200,y=550,w=80,color='lH',font=50,code=pressKey(9)},
|
||||
WIDGET.newKey{name="P", x=280,y=550,w=80,color='lH',font=50,code=pressKey(10)},
|
||||
WIDGET.newKey{name="Q", x=360,y=550,w=80,color='lH',font=50,code=pressKey(11)},
|
||||
WIDGET.newKey{name="F", x=440,y=550,w=80,color='lH',font=50,code=pressKey(12)},
|
||||
WIDGET.newKey{name="E", x=520,y=550,w=80,color='lH',font=50,code=pressKey(13)},
|
||||
WIDGET.newKey{name="T5", x=600,y=550,w=80,color='lH',font=50,code=pressKey(14)},
|
||||
WIDGET.newKey{name="U", x=680,y=550,w=80,color='lH',font=50,code=pressKey(15)},
|
||||
WIDGET.newKey{name="V", x=760,y=550,w=80,color='lH',font=50,code=pressKey(16)},
|
||||
WIDGET.newKey{name="I3", x=840,y=550,w=80,color='H',font=50,code=pressKey(26)},
|
||||
WIDGET.newKey{name="C", x=920,y=550,w=80,color='H',font=50,code=pressKey(27)},
|
||||
WIDGET.newKey{name="rnd", x=1000,y=550,w=80,color='R',font=25,code=pressKey"="},
|
||||
|
||||
WIDGET.newKey{name="W", x=120,y=640,w=80,color='lH',font=50,code=pressKey(17)},
|
||||
WIDGET.newKey{name="X", x=200,y=640,w=80,color='lH',font=50,code=pressKey(18)},
|
||||
WIDGET.newKey{name="J5", x=280,y=640,w=80,color='lH',font=50,code=pressKey(19)},
|
||||
WIDGET.newKey{name="L5", x=360,y=640,w=80,color='lH',font=50,code=pressKey(20)},
|
||||
WIDGET.newKey{name="R", x=440,y=640,w=80,color='lH',font=50,code=pressKey(21)},
|
||||
WIDGET.newKey{name="Y", x=520,y=640,w=80,color='lH',font=50,code=pressKey(22)},
|
||||
WIDGET.newKey{name="N", x=600,y=640,w=80,color='lH',font=50,code=pressKey(23)},
|
||||
WIDGET.newKey{name="H", x=680,y=640,w=80,color='lH',font=50,code=pressKey(24)},
|
||||
WIDGET.newKey{name="I5", x=760,y=640,w=80,color='lH',font=50,code=pressKey(25)},
|
||||
WIDGET.newKey{name="I2", x=840,y=640,w=80,color='dH',font=50,code=pressKey(28)},
|
||||
WIDGET.newKey{name="O1", x=920,y=640,w=80,color='dH',font=50,code=pressKey(29)},
|
||||
WIDGET.newKey{name="W", x=120,y=640,w=80,color='lH',font=50,code=pressKey(17)},
|
||||
WIDGET.newKey{name="X", x=200,y=640,w=80,color='lH',font=50,code=pressKey(18)},
|
||||
WIDGET.newKey{name="J5", x=280,y=640,w=80,color='lH',font=50,code=pressKey(19)},
|
||||
WIDGET.newKey{name="L5", x=360,y=640,w=80,color='lH',font=50,code=pressKey(20)},
|
||||
WIDGET.newKey{name="R", x=440,y=640,w=80,color='lH',font=50,code=pressKey(21)},
|
||||
WIDGET.newKey{name="Y", x=520,y=640,w=80,color='lH',font=50,code=pressKey(22)},
|
||||
WIDGET.newKey{name="N", x=600,y=640,w=80,color='lH',font=50,code=pressKey(23)},
|
||||
WIDGET.newKey{name="H", x=680,y=640,w=80,color='lH',font=50,code=pressKey(24)},
|
||||
WIDGET.newKey{name="I5", x=760,y=640,w=80,color='lH',font=50,code=pressKey(25)},
|
||||
WIDGET.newKey{name="I2", x=840,y=640,w=80,color='dH',font=50,code=pressKey(28)},
|
||||
WIDGET.newKey{name="O1", x=920,y=640,w=80,color='dH',font=50,code=pressKey(29)},
|
||||
|
||||
|
||||
WIDGET.newButton{name="copy",x=1140,y=460,w=170,h=80,color='lR',font=40,code=pressKey"cC",hideF=function()return #BAG==0 end},
|
||||
WIDGET.newButton{name="paste",x=1140,y=550,w=170,h=80,color='lB',font=40,code=pressKey"cV"},
|
||||
WIDGET.newButton{name="back",x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=backScene},
|
||||
WIDGET.newButton{name="copy", x=1140,y=460,w=170,h=80,color='lR',font=40,code=pressKey"cC",hideF=function()return #BAG==0 end},
|
||||
WIDGET.newButton{name="paste",x=1140,y=550,w=170,h=80,color='lB',font=40,code=pressKey"cV"},
|
||||
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=backScene},
|
||||
}
|
||||
|
||||
return scene
|
||||
Reference in New Issue
Block a user