自定义序列/任务连续同种方块使用缩略显示

This commit is contained in:
MrZ626
2020-09-20 15:37:39 +08:00
parent 6f90b85da5
commit f0d4c7ae7d
2 changed files with 129 additions and 41 deletions

View File

@@ -169,7 +169,7 @@ function pasteSequence(str)
return true return true
end end
function copyTarget() function copyMission()
local str="" local str=""
local preMission=preMission local preMission=preMission
for i=1,#preMission do for i=1,#preMission do
@@ -178,7 +178,7 @@ function copyTarget()
return data.encode("string","base64",data.compress("string","deflate",str)) return data.encode("string","base64",data.compress("string","deflate",str))
end end
function pasteTarget(str) function pasteMission(str)
local _ local _
--Decode --Decode
@@ -197,6 +197,7 @@ function pasteTarget(str)
end end
end end
preMission=mission preMission=mission
sceneTemp.cur=#preMission
return true return true
end end

View File

@@ -1290,18 +1290,34 @@ do--custom_seq
} }
function keyDown.custom_seq(key) function keyDown.custom_seq(key)
local S=sceneTemp local S=sceneTemp
local preBag=preBag
if key=="left"then if key=="left"then
S.cur=S.cur-1 local p=S.cur
if S.cur==-1 then if p==0 then
S.cur=#preBag S.cur=#preBag
else
repeat
p=p-1
until preBag[p]~=preBag[S.cur]
S.cur=p
end end
elseif key=="right"then elseif key=="right"then
S.cur=S.cur+1 local p=S.cur
if S.cur>#preBag then if p==#preBag then
S.cur=0 S.cur=0
else
repeat
p=p+1
until preBag[p+1]~=preBag[S.cur+1]
S.cur=p
end end
elseif key=="ten"then elseif key=="ten"then
S.cur=min(S.cur+10,#preBag) S.cur=min(S.cur+9,#preBag)
local p=S.cur
repeat
p=p+1
until preBag[p+1]~=preBag[S.cur+1]
S.cur=p
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
if #preBag>0 then if #preBag>0 then
sys.setClipboardText("Techmino SEQ:"..copySequence()) sys.setClipboardText("Techmino SEQ:"..copySequence())
@@ -1321,7 +1337,9 @@ do--custom_seq
end end
elseif key=="delete"then elseif key=="delete"then
if S.sure>20 then if S.sure>20 then
preBag={} for i=1,#preBag do
rem(preBag)
end
S.cur=0 S.cur=0
S.sure=0 S.sure=0
SFX.play("finesseError",.7) SFX.play("finesseError",.7)
@@ -1361,31 +1379,52 @@ do--custom_seq
--Draw frame --Draw frame
gc.setLineWidth(4) gc.setLineWidth(4)
gc.rectangle("line",100,110,1080,260) gc.rectangle("line",100,110,1080,260)
local bag=preBag
--Draw lenth
setFont(40)
gc.print(#bag,120,310)
--Draw sequence --Draw sequence
local L=TEXTURE.miniBlock local miniBlock=TEXTURE.miniBlock
local lib=SKIN.libColor local libColor=SKIN.libColor
local set=setting.skin local set=setting.skin
local L=preBag
local x,y=120,136--Next block pos local x,y=120,136--Next block pos
local cx,cy=120,136--Cursor-center pos local cx,cy=120,136--Cursor-center pos
for i=1,#bag do local i,j=1,#L
local B=L[bag[i]] local count=1
gc.setColor(lib[set[bag[i]]]) setFont(25)
gc.draw(B,x,y,nil,15,15,0,B:getHeight()*.5) repeat
x=x+B:getWidth()*15+10 if L[i]==L[i-1]then
if x>1100 then count=count+1
x,y=120,y+50 else
if count>1 then
gc.setColor(1,1,1)
gc.print("x",x-5,y-15)
gc.print(count,x+10,y-13)
x=x+(count<10 and 33 or 45)
count=1
if i==S.cur+1 then
cx,cy=x,y
end
end
if x>1060 then
x,y=120,y+50
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 end
if i==S.cur then if i==S.cur then
cx,cy=x,y cx,cy=x,y
end end
end i=i+1
until i>j+1
--Draw lenth
setFont(40)
gc.setColor(1,1,1)
gc.print(#L,120,310)
--Draw cursor --Draw cursor
gc.setColor(.5,1,.5,.6+.4*sin(Timer()*6.26)) gc.setColor(.5,1,.5,.6+.4*sin(Timer()*6.26))
@@ -1596,28 +1635,44 @@ do--custom_mission
local legalInput={Z=true,S=true,J=true,L=true,T=true,O=true,I=true,A=true,_=true,P=true} local legalInput={Z=true,S=true,J=true,L=true,T=true,O=true,I=true,A=true,_=true,P=true}
function keyDown.custom_mission(key) function keyDown.custom_mission(key)
local S=sceneTemp local S=sceneTemp
local preMission=preMission
if key=="left"then if key=="left"then
S.cur=S.cur-1 local p=S.cur
if S.cur==-1 then if p==0 then
S.cur=#preMission S.cur=#preMission
else
repeat
p=p-1
until preMission[p]~=preMission[S.cur]
S.cur=p
end end
elseif key=="right"then elseif key=="right"then
S.cur=S.cur+1 local p=S.cur
if S.cur>#preMission then if p==#preMission then
S.cur=0 S.cur=0
else
repeat
p=p+1
until preMission[p+1]~=preMission[S.cur+1]
S.cur=p
end end
elseif key=="ten"then elseif key=="ten"then
S.cur=min(S.cur+10,#preMission) S.cur=min(S.cur+9,#preMission)
local p=S.cur
repeat
p=p+1
until preMission[p+1]~=preMission[S.cur+1]
S.cur=p
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
if #preMission>0 then if #preMission>0 then
sys.setClipboardText("Techmino Target:"..copyTarget()) sys.setClipboardText("Techmino Target:"..copyMission())
LOG.print(text.copySuccess,color.green) LOG.print(text.copySuccess,color.green)
end end
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
local str=sys.getClipboardText() local str=sys.getClipboardText()
local p=string.find(str,":")--ptr* local p=string.find(str,":")--ptr*
if p then str=string.sub(str,p+1)end if p then str=string.sub(str,p+1)end
if not pasteTarget(str)then if not pasteMission(str)then
LOG.print(text.dataCorrupted,color.red) LOG.print(text.dataCorrupted,color.red)
end end
elseif key=="backspace"then elseif key=="backspace"then
@@ -1627,7 +1682,9 @@ do--custom_mission
end end
elseif key=="delete"then elseif key=="delete"then
if S.sure>20 then if S.sure>20 then
preMission={} for i=1,#preMission do
rem(preMission)
end
S.cur=0 S.cur=0
S.sure=0 S.sure=0
SFX.play("finesseError",.7) SFX.play("finesseError",.7)
@@ -1686,20 +1743,50 @@ do--custom_mission
gc.print(S.input,1200,270) gc.print(S.input,1200,270)
--Draw targets --Draw targets
gc.setColor(1,1,1) local libColor=SKIN.libColor
setFont(35) local set=setting.skin
local L=preMission
local x,y=100,136--Next block pos local x,y=100,136--Next block pos
local cx,cy=100,136--Cursor-center pos local cx,cy=100,136--Cursor-center pos
for i=1,#preMission do local i,j=1,#L
gc.print(missionEnum[preMission[i]],x,y-25) local count=1
x=x+55 repeat
if x>1160 then if L[i]==L[i-1]then
x,y=100,y+50 count=count+1
else
if count>1 then
setFont(25)
gc.setColor(1,1,1)
gc.print("x",x-10,y-15)
gc.print(count,x+5,y-13)
x=x+(count<10 and 33 or 45)
count=1
if i==S.cur+1 then
cx,cy=x,y
end
end
if x>1140 then
x,y=100,y+36
end
if i<=j then
setFont(35)
local N=int(L[i]*.1)
if N==9 then
gc.setColor(color.rainbow(i+Timer()*6.26))
elseif N>0 then
gc.setColor(libColor[set[N]])
else
gc.setColor(color.grey)
end
gc.print(missionEnum[L[i]],x,y-25)
x=x+56
end
end end
if i==S.cur then if i==S.cur then
cx,cy=x,y cx,cy=x,y
end end
end i=i+1
until i>j+1
--Draw cursor --Draw cursor
gc.setColor(1,1,.4,.6+.4*sin(Timer()*6.26)) gc.setColor(1,1,.4,.6+.4*sin(Timer()*6.26))