Skip to content

Commit f622a5f

Browse files
committed
添加复制粘贴功能(手机不能复制,画P或V粘贴)
框架跟进
1 parent 04a739a commit f622a5f

File tree

5 files changed

+144
-7
lines changed

5 files changed

+144
-7
lines changed

Zenitha

copy.ogg

7 KB
Binary file not shown.

error.ogg

19 KB
Binary file not shown.

main.lua

Lines changed: 143 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ TASK.new(function()
4444
end)
4545

4646
SFX.load({
47-
untick='untick.ogg',
48-
solve='solve.ogg',
49-
copy='copy.ogg',
50-
paste='paste.ogg',
47+
tick = 'tick.ogg',
48+
untick = 'untick.ogg',
49+
solve = 'solve.ogg',
50+
copy = 'copy.ogg',
51+
paste = 'paste.ogg',
52+
error = 'error.ogg',
5153
})
5254

5355
FONT.load('unifont', 'unifont.otf')
@@ -379,6 +381,92 @@ local gridConst = {
379381
{ 0, 0, 1, 0, 0 },
380382
{ 0, 0, 1, 0, 0 },
381383
},
384+
paste = {
385+
dumpGrid {
386+
{ 1, 1, 1, 1, 0 },
387+
{ 1, 0, 0, 0, 1 },
388+
{ 1, 1, 1, 1, 0 },
389+
{ 1, 0, 0, 0, 0 },
390+
{ 1, 0, 0, 0, 0 },
391+
},
392+
dumpGrid {
393+
{ 1, 1, 1, 1, 0 },
394+
{ 1, 0, 0, 0, 1 },
395+
{ 1, 1, 1, 1, 0 },
396+
{ 1, 0, 0, 0, 0 },
397+
{ 1, 0, 0, 0, 0 },
398+
},
399+
dumpGrid {
400+
{ 1, 1, 1, 1, 1 },
401+
{ 1, 0, 0, 0, 1 },
402+
{ 1, 1, 1, 1, 1 },
403+
{ 1, 0, 0, 0, 0 },
404+
{ 1, 0, 0, 0, 0 },
405+
},
406+
dumpGrid {
407+
{ 1, 1, 1, 0, 0 },
408+
{ 1, 0, 0, 1, 0 },
409+
{ 1, 1, 1, 0, 0 },
410+
{ 1, 0, 0, 0, 0 },
411+
{ 1, 0, 0, 0, 0 },
412+
},
413+
dumpGrid {
414+
{ 0, 1, 1, 1, 0 },
415+
{ 0, 1, 0, 0, 1 },
416+
{ 0, 1, 1, 1, 0 },
417+
{ 0, 1, 0, 0, 0 },
418+
{ 0, 1, 0, 0, 0 },
419+
},
420+
dumpGrid {
421+
{ 1, 1, 1, 1, 0 },
422+
{ 1, 0, 0, 1, 0 },
423+
{ 1, 1, 1, 1, 0 },
424+
{ 1, 0, 0, 0, 0 },
425+
{ 1, 0, 0, 0, 0 },
426+
},
427+
dumpGrid {
428+
{ 0, 1, 1, 1, 1 },
429+
{ 0, 1, 0, 0, 1 },
430+
{ 0, 1, 1, 1, 1 },
431+
{ 0, 1, 0, 0, 0 },
432+
{ 0, 1, 0, 0, 0 },
433+
},
434+
dumpGrid {
435+
{ 1, 1, 1, 0, 0 },
436+
{ 1, 0, 1, 0, 0 },
437+
{ 1, 1, 1, 0, 0 },
438+
{ 1, 0, 0, 0, 0 },
439+
{ 1, 0, 0, 0, 0 },
440+
},
441+
dumpGrid {
442+
{ 0, 1, 1, 1, 0 },
443+
{ 0, 1, 0, 1, 0 },
444+
{ 0, 1, 1, 1, 0 },
445+
{ 0, 1, 0, 0, 0 },
446+
{ 0, 1, 0, 0, 0 },
447+
},
448+
dumpGrid {
449+
{ 0, 0, 1, 1, 1 },
450+
{ 0, 0, 1, 0, 1 },
451+
{ 0, 0, 1, 1, 1 },
452+
{ 0, 0, 1, 0, 0 },
453+
{ 0, 0, 1, 0, 0 },
454+
},
455+
dumpGrid { -- V
456+
{ 1, 0, 0, 0, 1 },
457+
{ 1, 0, 0, 0, 1 },
458+
{ 1, 0, 0, 0, 1 },
459+
{ 0, 1, 0, 1, 0 },
460+
{ 0, 0, 1, 0, 0 },
461+
},
462+
dumpGrid { -- V
463+
{ 1, 0, 0, 0, 1 },
464+
{ 1, 0, 0, 0, 1 },
465+
{ 0, 1, 0, 1, 0 },
466+
{ 0, 1, 0, 1, 0 },
467+
{ 0, 0, 1, 0, 0 },
468+
},
469+
},
382470
}
383471
local function selectDate(option)
384472
if option == 'prev' then
@@ -679,6 +767,53 @@ function scene.keyDown(k, rep)
679767
end
680768
elseif k == 'h' then
681769
triggerHint()
770+
elseif k == 'c' then
771+
local output = ""
772+
for i = 1, 5 do
773+
output = output .. table.concat(DATA.tickMat[i]) .. "\n"
774+
end
775+
love.system.setClipboardText(output)
776+
SFX.play('copy')
777+
if TASK.lock('copy') then
778+
MSG.new('check', "Wow you can even copy", 4.2)
779+
end
780+
elseif k == 'v' then
781+
local input = love.system.getClipboardText()
782+
if input and type(input) == 'string' then
783+
input = input:gsub('%s', '')
784+
if input:find('%D') then
785+
MSG.new('warn', "Can only paste numbers", 4.2)
786+
SFX.play('error')
787+
else
788+
local lastEdit = 0
789+
local pos = 1
790+
for c in input:gmatch("%d") do
791+
if pos > 25 then
792+
lastEdit = 26
793+
break
794+
end
795+
c = tonumber(c)
796+
if c <= 2 then
797+
DATA.tickMat[math.ceil(pos / 5)][(pos - 1) % 5 + 1] = c
798+
lastEdit = pos
799+
else
800+
if TASK.lock('count2+') then MSG.new('warn', "Cannot count over 2", 4.2) end
801+
break
802+
end
803+
pos = pos + 1
804+
end
805+
if lastEdit == 25 then
806+
SFX.play('paste')
807+
else
808+
if lastEdit > 25 then
809+
if TASK.lock('stackoverflow') then MSG.new('warn', "Stack Overflow", 4.2) end
810+
else
811+
if TASK.lock('stackunderflow') then MSG.new('warn', "Stack Underflow", 4.2) end
812+
end
813+
SFX.play('error')
814+
end
815+
end
816+
end
682817
end
683818
return true
684819
end
@@ -714,6 +849,8 @@ function scene.mouseDown(x, y, k)
714849
selectDate('now')
715850
elseif TABLE.find(gridConst.R, pattern) then
716851
selectDate('random')
852+
elseif TABLE.find(gridConst.paste, pattern) then
853+
scene.keyDown('v')
717854
elseif pattern == gridConst.up then
718855
local y0 = board.Y
719856
TWEEN.new(function(t)
@@ -841,7 +978,7 @@ function scene.update(dt)
841978
end
842979
end
843980

844-
local tick = GC.load { w=62, h=62,
981+
local tick = GC.load { w = 62, h = 62,
845982
{ 'move', 4, 4 },
846983
{ 'setLW', 10 },
847984
{ 'setCL', 0, 0, 0 },
@@ -850,7 +987,7 @@ local tick = GC.load { w=62, h=62,
850987
{ 'setCL', COLOR.L },
851988
{ 'line', 2, 28, 26, 48, 50, 3 },
852989
}
853-
local cross = GC.load { w=62, h=62,
990+
local cross = GC.load { w = 62, h = 62,
854991
{ 'move', 4, 4 },
855992
{ 'setLW', 8 },
856993
{ 'setCL', 0, 0, 0 },

paste.ogg

6.08 KB
Binary file not shown.

0 commit comments

Comments
 (0)