Save custom mode (#1007)

* first step to save custom game

* localize various settings in custom game

* rename fields to lower cases

* fix many bugs

* fixes #1014
This commit is contained in:
Imple Lee
2023-10-20 01:42:04 +08:00
committed by GitHub
parent 7ac2c282f6
commit 90c428cf44
13 changed files with 240 additions and 158 deletions

View File

@@ -5,6 +5,7 @@ local floor,sin=math.floor,math.sin
local ins,rem=table.insert,table.remove
local scene={}
local MISSION=CUSTOMGAME_LOCAL.mission
local input-- Input buffer
local cur-- Cursor position
@@ -14,7 +15,7 @@ function scene.enter()
cur=#MISSION
end
function scene.leave()
saveFile(DATA.copyMission(),'conf/customMissions')
saveFile(DATA.copyMission(MISSION),'conf/customMissions')
end
local ENUM_MISSION=ENUM_MISSION
@@ -67,7 +68,7 @@ function scene.keyDown(key)
end
elseif key=='c' and kb.isDown('lctrl','rctrl') or key=='cC' then
if #MISSION>0 then
sys.setClipboardText("Techmino Target:"..DATA.copyMission())
sys.setClipboardText("Techmino Target:"..DATA.copyMission(MISSION))
MES.new('check',text.exportSuccess)
end
elseif key=='v' and kb.isDown('lctrl','rctrl') or key=='cV' then
@@ -79,7 +80,9 @@ function scene.keyDown(key)
end
str=str:sub(p+1)
end
if DATA.pasteMission(str) then
local success,mission=DATA.pasteMission(str)
if success then
CUSTOMGAME_LOCAL.mission=mission
MES.new('check',text.importSuccess)
cur=#MISSION
else
@@ -222,7 +225,7 @@ scene.widgetList={
WIDGET.newKey{name='reset', x=1000,y=640,w=90, color='lY',font=50,code=pressKey'delete', fText=CHAR.icon.trash},
WIDGET.newButton{name='copy', x=1140,y=440,w=170,h=80,color='lR',font=50,code=pressKey'cC', fText=CHAR.icon.export,hideF=function() return #MISSION==0 end},
WIDGET.newButton{name='paste', x=1140,y=540,w=170,h=80,color='lB',font=50,code=pressKey'cV', fText=CHAR.icon.import},
WIDGET.newSwitch{name='mission',x=1150,y=340,lim=280,disp=CUSval('missionKill'),code=CUSrev('missionKill')},
WIDGET.newSwitch{name='mission',x=1150,y=340,lim=280,disp=CUSTOMGAME_LOCAL:CUSval('missionKill'),code=CUSTOMGAME_LOCAL:CUSrev('missionKill')},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}