整理代码
This commit is contained in:
6
main.lua
6
main.lua
@@ -319,9 +319,9 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if needSave then
|
if needSave then
|
||||||
FILE.save(SETTING,"conf/settings",'q')
|
FILE.save(SETTING,'conf/settings','q')
|
||||||
FILE.save(RANKS,"conf/unlock",'q')
|
FILE.save(RANKS,'conf/unlock','q')
|
||||||
FILE.save(STAT,"conf/data",'q')
|
FILE.save(STAT,'conf/data','q')
|
||||||
end
|
end
|
||||||
if autoRestart then
|
if autoRestart then
|
||||||
love.event.quit('restart')
|
love.event.quit('restart')
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ do--function DATA.saveRecording()
|
|||||||
|
|
||||||
love.filesystem.write(fileName,fileHead.."\n"..data.compress('string','zlib',fileBody))
|
love.filesystem.write(fileName,fileHead.."\n"..data.compress('string','zlib',fileBody))
|
||||||
ins(REPLAY,fileName)
|
ins(REPLAY,fileName)
|
||||||
FILE.save(REPLAY,"conf/replay")
|
FILE.save(REPLAY,'conf/replay')
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
LOG.print("Save failed: File already exists")
|
LOG.print("Save failed: File already exists")
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ function NET.updateWS_user()
|
|||||||
if res.uid then
|
if res.uid then
|
||||||
USER.uid=res.uid
|
USER.uid=res.uid
|
||||||
USER.authToken=res.authToken
|
USER.authToken=res.authToken
|
||||||
FILE.save(USER,"conf/user",'q')
|
FILE.save(USER,'conf/user','q')
|
||||||
if SCN.cur=='login'then SCN.back()end
|
if SCN.cur=='login'then SCN.back()end
|
||||||
end
|
end
|
||||||
LOG.print(text.loginSuccessed)
|
LOG.print(text.loginSuccessed)
|
||||||
@@ -350,7 +350,7 @@ function NET.updateWS_play()
|
|||||||
--?
|
--?
|
||||||
elseif res.action==2 then--Player join
|
elseif res.action==2 then--Player join
|
||||||
if res.type=='Self'then
|
if res.type=='Self'then
|
||||||
--Create room
|
--Enter new room
|
||||||
TABLE.cut(PLY_NET)
|
TABLE.cut(PLY_NET)
|
||||||
if d.players then
|
if d.players then
|
||||||
for _,p in next,d.players do
|
for _,p in next,d.players do
|
||||||
@@ -373,7 +373,7 @@ function NET.updateWS_play()
|
|||||||
ready=d.ready,
|
ready=d.ready,
|
||||||
config=d.config,
|
config=d.config,
|
||||||
})
|
})
|
||||||
if SCN.socketRead then SCN.socketRead("Join",d)end
|
if SCN.socketRead then SCN.socketRead('Join',d)end
|
||||||
end
|
end
|
||||||
elseif res.action==3 then--Player leave
|
elseif res.action==3 then--Player leave
|
||||||
if not d.uid then
|
if not d.uid then
|
||||||
@@ -399,10 +399,10 @@ function NET.updateWS_play()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if SCN.socketRead then SCN.socketRead("Leave",d)end
|
if SCN.socketRead then SCN.socketRead('Leave',d)end
|
||||||
end
|
end
|
||||||
elseif res.action==4 then--Player talk
|
elseif res.action==4 then--Player talk
|
||||||
if SCN.socketRead then SCN.socketRead("Talk",d)end
|
if SCN.socketRead then SCN.socketRead('Talk',d)end
|
||||||
elseif res.action==5 then--Player change settings
|
elseif res.action==5 then--Player change settings
|
||||||
if tostring(USER.uid)~=d.uid then
|
if tostring(USER.uid)~=d.uid then
|
||||||
for i=1,#PLY_NET do
|
for i=1,#PLY_NET do
|
||||||
@@ -443,7 +443,7 @@ function NET.updateWS_play()
|
|||||||
elseif res.action==9 then--Game finished
|
elseif res.action==9 then--Game finished
|
||||||
NET.allReady=false
|
NET.allReady=false
|
||||||
NET.wsclose_stream()
|
NET.wsclose_stream()
|
||||||
if SCN.socketRead then SCN.socketRead("Finish",d)end
|
if SCN.socketRead then SCN.socketRead('Finish',d)end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
WS.alert('play')
|
WS.alert('play')
|
||||||
@@ -472,7 +472,7 @@ function NET.updateWS_stream()
|
|||||||
if res.type=='Connect'then
|
if res.type=='Connect'then
|
||||||
NET.unlock('wsc_stream')
|
NET.unlock('wsc_stream')
|
||||||
elseif res.action==0 then--Game start
|
elseif res.action==0 then--Game start
|
||||||
SCN.socketRead("Go",d)
|
SCN.socketRead('Go',d)
|
||||||
elseif res.action==1 then--Game finished
|
elseif res.action==1 then--Game finished
|
||||||
--?
|
--?
|
||||||
elseif res.action==2 then--Player join
|
elseif res.action==2 then--Player join
|
||||||
@@ -487,7 +487,7 @@ function NET.updateWS_stream()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif res.action==5 then--Receive stream
|
elseif res.action==5 then--Receive stream
|
||||||
SCN.socketRead("Stream",d)
|
SCN.socketRead('Stream',d)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
WS.alert('stream')
|
WS.alert('stream')
|
||||||
|
|||||||
@@ -1609,7 +1609,7 @@ end
|
|||||||
--------------------------<Events>--------------------------
|
--------------------------<Events>--------------------------
|
||||||
local function gameOver()--Save record
|
local function gameOver()--Save record
|
||||||
if GAME.replaying then return end
|
if GAME.replaying then return end
|
||||||
FILE.save(STAT,"conf/data")
|
FILE.save(STAT,'conf/data')
|
||||||
local M=GAME.curMode
|
local M=GAME.curMode
|
||||||
local R=M.getRank
|
local R=M.getRank
|
||||||
if R then
|
if R then
|
||||||
@@ -1639,7 +1639,7 @@ local function gameOver()--Save record
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if needSave then
|
if needSave then
|
||||||
FILE.save(RANKS,"conf/unlock",'q')
|
FILE.save(RANKS,'conf/unlock','q')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local D=M.score(P)
|
local D=M.score(P)
|
||||||
@@ -1658,7 +1658,7 @@ local function gameOver()--Save record
|
|||||||
D.date=os.date("%Y/%m/%d %H:%M")
|
D.date=os.date("%Y/%m/%d %H:%M")
|
||||||
ins(L,p+1,D)
|
ins(L,p+1,D)
|
||||||
if L[11]then L[11]=nil end
|
if L[11]then L[11]=nil end
|
||||||
FILE.save(L,"record/"..M.name..".rec",'lq')
|
FILE.save(L,('record/%s.rec'):format(M.name),'lq')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ function commands.unlockall(bool)
|
|||||||
RANKS[name]=M.score and 0 or 6
|
RANKS[name]=M.score and 0 or 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
FILE.save(RANKS,"conf/unlock")
|
FILE.save(RANKS,'conf/unlock')
|
||||||
log{C.lC,"\85\78\76\79\67\75\65\76\76"}
|
log{C.lC,"\85\78\76\79\67\75\65\76\76"}
|
||||||
SFX.play('clear_2')
|
SFX.play('clear_2')
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ function scene.keyDown(key)
|
|||||||
end
|
end
|
||||||
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
|
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
|
||||||
if initField then
|
if initField then
|
||||||
FILE.save(CUSTOMENV,"conf/customEnv",'q')
|
FILE.save(CUSTOMENV,'conf/customEnv','q')
|
||||||
loadGame('custom_puzzle',true)
|
loadGame('custom_puzzle',true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
FILE.save(CUSTOMENV,"conf/customEnv",'q')
|
FILE.save(CUSTOMENV,'conf/customEnv','q')
|
||||||
loadGame('custom_clear',true)
|
loadGame('custom_clear',true)
|
||||||
end
|
end
|
||||||
elseif key=="f"then
|
elseif key=="f"then
|
||||||
@@ -102,7 +102,7 @@ function scene.keyDown(key)
|
|||||||
do return end
|
do return end
|
||||||
::THROW_fail::LOG.print(text.dataCorrupted,COLOR.R)
|
::THROW_fail::LOG.print(text.dataCorrupted,COLOR.R)
|
||||||
elseif key=="escape"then
|
elseif key=="escape"then
|
||||||
FILE.save(CUSTOMENV,"conf/customEnv",'q')
|
FILE.save(CUSTOMENV,'conf/customEnv','q')
|
||||||
SCN.back()
|
SCN.back()
|
||||||
else
|
else
|
||||||
WIDGET.keyPressed(key)
|
WIDGET.keyPressed(key)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,'conf/settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setLang(n)return function()SETTING.lang=n LANG.set(n)end end
|
local function setLang(n)return function()SETTING.lang=n LANG.set(n)end end
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ local loadingThread=coroutine.wrap(function()
|
|||||||
RANKS[name]=nil
|
RANKS[name]=nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
FILE.save(RANKS,"conf/unlock",'q')
|
FILE.save(RANKS,'conf/unlock','q')
|
||||||
end
|
end
|
||||||
|
|
||||||
DAILYLAUNCH=freshDate'q'
|
DAILYLAUNCH=freshDate'q'
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ scene.widgetList={
|
|||||||
USER.uid=false
|
USER.uid=false
|
||||||
USER.username=false
|
USER.username=false
|
||||||
USER.authToken=false
|
USER.authToken=false
|
||||||
FILE.save(USER,"conf/user",'q')
|
FILE.save(USER,'conf/user','q')
|
||||||
SCN.back()
|
SCN.back()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ function scene.sceneBack()
|
|||||||
STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time
|
STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time
|
||||||
if not GAME.replaying and(PLAYERS[1].frameRun>400 or GAME.result)and not GAME.result then
|
if not GAME.replaying and(PLAYERS[1].frameRun>400 or GAME.result)and not GAME.result then
|
||||||
mergeStat(STAT,PLAYERS[1].stat)
|
mergeStat(STAT,PLAYERS[1].stat)
|
||||||
FILE.save(STAT,"conf/data")
|
FILE.save(STAT,'conf/data')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ scene.widgetList={
|
|||||||
local D=parseCB()
|
local D=parseCB()
|
||||||
if D then
|
if D then
|
||||||
TABLE.update(D,RANKS)
|
TABLE.update(D,RANKS)
|
||||||
FILE.save(RANKS,"conf/unlock")
|
FILE.save(RANKS,'conf/unlock')
|
||||||
LOG.print(text.importSuccess,'message')
|
LOG.print(text.importSuccess,'message')
|
||||||
else
|
else
|
||||||
LOG.print(text.dataCorrupted,'warn')
|
LOG.print(text.dataCorrupted,'warn')
|
||||||
@@ -50,7 +50,7 @@ scene.widgetList={
|
|||||||
local D=parseCB()
|
local D=parseCB()
|
||||||
if D and D.version==STAT.version then
|
if D and D.version==STAT.version then
|
||||||
TABLE.update(D,STAT)
|
TABLE.update(D,STAT)
|
||||||
FILE.save(STAT,"conf/data")
|
FILE.save(STAT,'conf/data')
|
||||||
LOG.print(text.importSuccess,'message')
|
LOG.print(text.importSuccess,'message')
|
||||||
else
|
else
|
||||||
LOG.print(text.dataCorrupted,'warn')
|
LOG.print(text.dataCorrupted,'warn')
|
||||||
@@ -61,7 +61,7 @@ scene.widgetList={
|
|||||||
local D=parseCB()
|
local D=parseCB()
|
||||||
if D then
|
if D then
|
||||||
TABLE.update(D,SETTING)
|
TABLE.update(D,SETTING)
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,'conf/settings')
|
||||||
LOG.print(text.importSuccess,'message')
|
LOG.print(text.importSuccess,'message')
|
||||||
else
|
else
|
||||||
LOG.print(text.dataCorrupted,'warn')
|
LOG.print(text.dataCorrupted,'warn')
|
||||||
@@ -72,7 +72,7 @@ scene.widgetList={
|
|||||||
local D=parseCB()
|
local D=parseCB()
|
||||||
if D then
|
if D then
|
||||||
TABLE.update(D,VK_org)
|
TABLE.update(D,VK_org)
|
||||||
FILE.save(VK_org,"conf/virtualkey")
|
FILE.save(VK_org,'conf/virtualkey')
|
||||||
LOG.print(text.importSuccess,'message')
|
LOG.print(text.importSuccess,'message')
|
||||||
else
|
else
|
||||||
LOG.print(text.dataCorrupted,'warn')
|
LOG.print(text.dataCorrupted,'warn')
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function scene.sceneInit()
|
|||||||
BG.set()
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,'conf/settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function scene.sceneInit()
|
|||||||
BG.set('none')
|
BG.set('none')
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(keyMap,"conf/key")
|
FILE.save(keyMap,'conf/key')
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.keyDown(key)
|
function scene.keyDown(key)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function scene.sceneInit()
|
|||||||
BG.set()
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,'conf/settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.mouseDown(x,y)
|
function scene.mouseDown(x,y)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function scene.sceneInit()
|
|||||||
selected=false
|
selected=false
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(VK_org,"conf/virtualkey")
|
FILE.save(VK_org,'conf/virtualkey')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onVK_org(x,y)
|
local function onVK_org(x,y)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ function scene.sceneInit()
|
|||||||
BG.set()
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,'conf/settings')
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
|
|||||||
Reference in New Issue
Block a user