From 5793b7ca38aa202c8e7f7896d14236ef9116f06b Mon Sep 17 00:00:00 2001 From: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:20:48 +0800 Subject: [PATCH] fix custom games (#1139) Now you can `play custom_` without going through the `customGame` scene --- parts/modes/custom_clear.lua | 2 ++ parts/modes/custom_puzzle.lua | 2 ++ parts/scenes/customGame.lua | 9 +++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/parts/modes/custom_clear.lua b/parts/modes/custom_clear.lua index 06ac187ae..951a1606b 100644 --- a/parts/modes/custom_clear.lua +++ b/parts/modes/custom_clear.lua @@ -1,3 +1,5 @@ +require'parts.scenes.customGame'.initialize() + return { env={}, load=function() diff --git a/parts/modes/custom_puzzle.lua b/parts/modes/custom_puzzle.lua index efb43f32b..6da31d4c2 100644 --- a/parts/modes/custom_puzzle.lua +++ b/parts/modes/custom_puzzle.lua @@ -1,6 +1,8 @@ local gc_setColor,gc_draw=love.graphics.setColor,love.graphics.draw local ply_applyField=PLY.draw.applyField +require'parts.scenes.customGame'.initialize() + return { env={ fkey1=function(P) P.modeData.showMark=1-P.modeData.showMark end, diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 4d6826a76..77726598c 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -23,7 +23,10 @@ local function apply_locals() TABLE.clear(CUSTOMENV) TABLE.cover(CUSTOMGAME_LOCAL.customenv,CUSTOMENV) end -do -- Initialize fields, sequence, missions, gameEnv for cutsom game + +local scene={} + +function scene.initialize() -- Initialize fields, sequence, missions, gameEnv for cutsom game local fieldData=loadFile('conf/customBoards','-string -canSkip') local fieldReinit=false if not fieldData then @@ -64,6 +67,7 @@ do -- Initialize fields, sequence, missions, gameEnv for cutsom game TABLE.complete(customData,CUSTOMGAME_LOCAL.customenv) end TABLE.complete(require"parts.customEnv0",CUSTOMGAME_LOCAL.customenv) + apply_locals() end local sList={ @@ -87,8 +91,6 @@ local sList={ } local modUsed -local scene={} - function scene.enter() destroyPlayers() BG.set(CUSTOMGAME_LOCAL.customenv.bg) @@ -143,7 +145,6 @@ local function _play(mode) end end saveFile(CUSTOMGAME_LOCAL.customenv,'conf/customEnv') - apply_locals() loadGame('custom_'..mode,true) end