From b82e3b873bd9a16e60dcea6bae1648863359b945 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 15 Dec 2020 14:54:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=BD=AC=E6=8D=A2=E5=AD=98?= =?UTF-8?q?=E6=A1=A3/=E5=8A=A0=E8=BD=BD=E6=96=87=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 128 +++++++++++++++++++---------------------- parts/globalTables.lua | 15 ++--- 2 files changed, 67 insertions(+), 76 deletions(-) diff --git a/main.lua b/main.lua index b28a1cf6..40353973 100644 --- a/main.lua +++ b/main.lua @@ -30,13 +30,59 @@ love.keyboard.setKeyRepeat(true) love.keyboard.setTextInput(false) love.mouse.setVisible(false) +--Create directories +for _,v in next,{"conf","record","replay"}do + local info=fs.getInfo(v) + if info then + if info.type=="directory"then goto NEXT end + fs.remove(v) + end + fs.createDirectory(v) + ::NEXT:: +end + +--Delete useless mode record file +for _,v in next,{ + "tech_ultimate.dat", + "tech_ultimate+.dat", + "sprintFix.dat", + "sprintLock.dat", + "marathon_ultimate.dat", + "infinite.dat", + "infinite_dig.dat", +}do + if fs.getInfo(v)then fs.remove(v)end +end + +--Collect files of old version +if fs.getInfo("data.dat")or fs.getInfo("key.dat")or fs.getInfo("settings.dat")then + for k,v in next,{ + ["settings.dat"]="conf/settings", + ["unlock.dat"]="conf/unlock", + ["data.dat"]="conf/data", + ["key.dat"]="conf/key", + ["virtualkey.dat"]="conf/virtualkey", + ["account.dat"]="conf/user", + }do + if fs.getInfo(k)then + fs.write(v,fs.read(k)) + fs.remove(k) + end + end + for _,name in next,fs.getDirectoryItems("")do + if name:sub(-4)==".dat"then + fs.write("record/"..name:sub(1,-4).."rec",fs.read(name)) + fs.remove(name) + end + end +end + --Load modules require"Zframework" require"parts/list" require"parts/globalTables" require"parts/gametoolfunc" - SCR.setSize(1280,720)--Initialize Screen size FIELD[1]=newBoard()--Initialize field[1] @@ -51,6 +97,18 @@ AIFUNC= require"parts/ai" MODES= require"parts/modes" TICK= require"parts/tick" +--First start for phones +if not fs.getInfo("conf/settings")and MOBILE then + SETTING.VKSwitch=true + SETTING.swap=false + SETTING.vib=2 + SETTING.powerInfo=true + SETTING.fullscreen=true + love.window.setFullscreen(true) + love.resize(love.graphics.getWidth(),love.graphics.getHeight()) +end +if SETTING.fullscreen then love.window.setFullscreen(true)end + --Initialize image libs IMG.init{ batteryImage="/mess/power.png", @@ -253,76 +311,8 @@ for _,v in next,fs.getDirectoryItems("parts/scenes")do end end ---Create directories -for _,v in next,{"conf","record","replay"}do - local info=fs.getInfo(v) - if info then - if info.type=="directory"then goto NEXT end - fs.remove(v) - end - fs.createDirectory(v) - ::NEXT:: -end - ---Collect files -if fs.getInfo("data.dat")or fs.getInfo("key.dat")or fs.getInfo("settings.dat")then - for k,v in next,{ - ["settings.dat"]="conf/settings", - ["unlock.dat"]="conf/unlock", - ["data.dat"]="conf/data", - ["key.dat"]="conf/key", - ["virtualkey.dat"]="conf/virtualkey", - ["account.dat"]="conf/user", - }do - if fs.getInfo(k)then - fs.write(v,fs.read(k)) - fs.remove(k) - end - end - for _,name in next,fs.getDirectoryItems("")do - if name:sub(-4)==".dat"then - fs.write("record/"..name:sub(1,-4).."rec",fs.read(name)) - fs.remove(name) - end - end -end - ---Load files -if fs.getInfo("conf/settings")then - addToTable(FILE.load("conf/settings"),SETTING) -else - if MOBILE then - SETTING.VKSwitch=true - SETTING.swap=false - SETTING.vib=2 - SETTING.powerInfo=true - SETTING.fullscreen=true - love.window.setFullscreen(true) - love.resize(love.graphics.getWidth(),love.graphics.getHeight()) - end -end -if SETTING.fullscreen then love.window.setFullscreen(true)end LANG.set(SETTING.lang) -if fs.getInfo("conf/unlock")then RANKS=FILE.load("conf/unlock")end -if fs.getInfo("conf/data")then STAT=FILE.load("conf/data")end -if fs.getInfo("conf/key")then keyMap=FILE.load("conf/key")end -if fs.getInfo("conf/virtualkey")then VK_org=FILE.load("conf/virtualkey")end -if fs.getInfo("conf/user")then USER=FILE.load("conf/user")end -if fs.getInfo("conf/replay")then REPLAY=FILE.load("conf/replay")end - -for _,v in next,{ - "tech_ultimate.dat", - "tech_ultimate+.dat", - "sprintFix.dat", - "sprintLock.dat", - "marathon_ultimate.dat", - "infinite.dat", - "infinite_dig.dat", -}do - if fs.getInfo(v)then fs.remove(v)end -end - --Update data do --Check Ranks diff --git a/parts/globalTables.lua b/parts/globalTables.lua index 5b08aa5a..a5ec7d29 100644 --- a/parts/globalTables.lua +++ b/parts/globalTables.lua @@ -231,8 +231,8 @@ GAME={--Global game data } --Userdata tables -RANKS={sprint_10=0}--Ranks of modes -USER={--User infomation +RANKS=FILE.load("conf/unlock")or{sprint_10=0}--Ranks of modes +USER=FILE.load("conf/user")or{--User infomation email=nil, auth_token=nil, access_token=nil, @@ -240,8 +240,9 @@ USER={--User infomation username=nil, motto=nil, avatar=nil, + xp=0,lv=1, } -SETTING={--Settings +SETTING=FILE.load("conf/settings")or{--Settings --Tuning das=10,arr=2,dascut=0, sddas=0,sdarr=2, @@ -301,7 +302,7 @@ SETTING={--Settings VKIcon=true,--If disp icon VKAlpha=.3, } -STAT={--Statistics +STAT=FILE.load("conf/data")or{--Statistics version=VERSION_CODE, run=0,game=0,time=0,frame=0, key=0,rotate=0,hold=0, @@ -315,13 +316,13 @@ STAT={--Statistics date=nil, todayTime=0, }for i=1,25 do STAT.clear[i]={0,0,0,0,0,0}STAT.spin[i]={0,0,0,0,0,0,0}end -keyMap={--Key setting +keyMap=FILE.load("conf/key")or{--Key setting {"left","right","x","z","c","up","down","space","tab","r"},{}, --Keyboard {"dpleft","dpright","a","b","y","dpup","dpdown","rightshoulder","x","leftshoulder"},{}, --Joystick }for i=1,#keyMap do for j=1,20 do if not keyMap[i][j]then keyMap[i][j]=""end end end -VK_org={--Virtualkey layout, refresh all VKs' position with this before each game +VK_org=FILE.load("conf/virtualkey")or{--Virtualkey layout, refresh all VKs' position with this before each game {ava=true, x=80, y=720-200, r=80},--moveLeft {ava=true, x=320, y=720-200, r=80},--moveRight {ava=true, x=1280-80, y=720-200, r=80},--rotRight @@ -344,4 +345,4 @@ VK_org={--Virtualkey layout, refresh all VKs' position with this before each gam {ava=false, x=1000, y=50, r=80},--addToRight } virtualkey={}for i=1,#VK_org do virtualkey[i]={}end--In-game virtualkey layout -REPLAY={} \ No newline at end of file +REPLAY=FILE.load("conf/replay")or{} \ No newline at end of file