From 72e3ac1a1e49a75c535ddb588cf3bf685f41633d Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Sun, 14 Aug 2022 16:57:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=A8=A1=E5=BC=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=95=B4=E7=90=86=EF=BC=8C=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=8A=A0=E8=BD=BD=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/game/init.lua | 38 ++++++++++++------- .../game/mode/{gem_test.lua => gem/test.lua} | 0 .../{mino_marathon.lua => mino/marathon.lua} | 3 -- .../mode/{mino_sprint.lua => mino/sprint.lua} | 3 -- .../mode/{mino_test.lua => mino/test.lua} | 0 .../mode/{mino_ultra.lua => mino/ultra.lua} | 0 .../mode/{puyo_test.lua => puyo/test.lua} | 0 assets/scene/keyset_list.lua | 2 +- assets/scene/main_1.lua | 8 ++-- assets/scene/main_test.lua | 6 +-- assets/scene/setting_gem.lua | 2 +- assets/scene/setting_mino.lua | 2 +- assets/scene/setting_puyo.lua | 2 +- assets/skin/puyo_jelly.lua | 4 +- 14 files changed, 37 insertions(+), 33 deletions(-) rename assets/game/mode/{gem_test.lua => gem/test.lua} (100%) rename assets/game/mode/{mino_marathon.lua => mino/marathon.lua} (96%) rename assets/game/mode/{mino_sprint.lua => mino/sprint.lua} (94%) rename assets/game/mode/{mino_test.lua => mino/test.lua} (100%) rename assets/game/mode/{mino_ultra.lua => mino/ultra.lua} (100%) rename assets/game/mode/{puyo_test.lua => puyo/test.lua} (100%) diff --git a/assets/game/init.lua b/assets/game/init.lua index ab98f114..c44df955 100644 --- a/assets/game/init.lua +++ b/assets/game/init.lua @@ -117,24 +117,36 @@ do -- function layoutFuncs.default(): end local modeLib={} +local modeMeta={ + __index={ + initialize=NULL, + settings={}, + layout='default', + checkFinish=function() return true end, + result=NULL, + scorePage=NULL, + }, + __metatable=true, +} local function getMode(name) if modeLib[name] then return modeLib[name] else local path='assets/game/mode/'..name..'.lua' - if FILE.isSafe(path) then - local M=FILE.load(path,'-lua -canskip') - if not M then error("No mode called "..tostring(name)) end - if M.initialize ==nil then M.initialize= NULL else assert(type(M.initialize) =='function',"[mode].initialize must be function") end - if M.settings ==nil then M.settings= {} else assert(type(M.settings) =='table', "[mode].settings must be table (if exist)") end - if M.layout ==nil then M.layout= 'default' else assert(type(layoutFuncs[M.layout])=='funcion', "[mode].layout wrong") end - if M.checkFinish==nil then M.checkFinish=NULL else assert(type(M.checkFinish) =='function',"[mode].checkFinish must be function (if exist)") end - if M.result ==nil then M.result= NULL else assert(type(M.result) =='function',"[mode].result must be function (if exist)") end - if M.scorePage ==nil then M.scorePage= NULL else assert(type(M.scorePage) =='function',"[mode].scorePage must be function (if exist)") end - modeLib[name]=M - M.name=name - return M - end + assert(love.filesystem.getInfo(path) and FILE.isSafe(path),"No mode called "..tostring(name)) + local M=FILE.load(path,'-lua -canskip') + assert(type(M)=='table') + setmetatable(M,modeMeta) + assert(type(M.initialize) =='function',"[mode].initialize must be function") + assert(type(M.settings) =='table', "[mode].settings must be table") + assert(type(layoutFuncs[M.layout])=='function',"[mode].layout type wrong") + assert(type(M.checkFinish) =='function',"[mode].checkFinish must be function") + assert(type(M.result) =='function',"[mode].result must be function") + assert(type(M.scorePage) =='function',"[mode].scorePage must be function") + + M.name=name + modeLib[name]=M + return M end end diff --git a/assets/game/mode/gem_test.lua b/assets/game/mode/gem/test.lua similarity index 100% rename from assets/game/mode/gem_test.lua rename to assets/game/mode/gem/test.lua diff --git a/assets/game/mode/mino_marathon.lua b/assets/game/mode/mino/marathon.lua similarity index 96% rename from assets/game/mode/mino_marathon.lua rename to assets/game/mode/mino/marathon.lua index a98533f8..06131a85 100644 --- a/assets/game/mode/mino_marathon.lua +++ b/assets/game/mode/mino/marathon.lua @@ -42,7 +42,4 @@ return { end, }, }}, - checkFinish=function() - return true - end, } diff --git a/assets/game/mode/mino_sprint.lua b/assets/game/mode/mino/sprint.lua similarity index 94% rename from assets/game/mode/mino_sprint.lua rename to assets/game/mode/mino/sprint.lua index 42e95717..9d135f08 100644 --- a/assets/game/mode/mino_sprint.lua +++ b/assets/game/mode/mino/sprint.lua @@ -29,7 +29,4 @@ return { end, }, }}, - checkFinish=function() - return true - end, } diff --git a/assets/game/mode/mino_test.lua b/assets/game/mode/mino/test.lua similarity index 100% rename from assets/game/mode/mino_test.lua rename to assets/game/mode/mino/test.lua diff --git a/assets/game/mode/mino_ultra.lua b/assets/game/mode/mino/ultra.lua similarity index 100% rename from assets/game/mode/mino_ultra.lua rename to assets/game/mode/mino/ultra.lua diff --git a/assets/game/mode/puyo_test.lua b/assets/game/mode/puyo/test.lua similarity index 100% rename from assets/game/mode/puyo_test.lua rename to assets/game/mode/puyo/test.lua diff --git a/assets/scene/keyset_list.lua b/assets/scene/keyset_list.lua index d8d93dd0..73a7275b 100644 --- a/assets/scene/keyset_list.lua +++ b/assets/scene/keyset_list.lua @@ -111,7 +111,7 @@ scene.widgetList={ WIDGET.new{type='button', name='sys', x=140, y=490, w=200,h=60,text=LANG"keyset_sys_select", fontSize=20, color='lB',code=selAct('sys', 'select' )}, WIDGET.new{type='button', name='sys', x=140, y=560, w=200,h=60,text=LANG"keyset_sys_back", fontSize=20, color='lB',code=selAct('sys', 'back' )}, - WIDGET.new{type='button', name='test',pos={1,1},x=-300,y=-80, w=160,h=80,text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,keyMode..'_test') end}, + WIDGET.new{type='button', name='test',pos={1,1},x=-300,y=-80, w=160,h=80,text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,keyMode..'/test') end}, WIDGET.new{type='button',pos={1,1},x=-120,y=-80,w=160,h=80,sound='back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn}, } diff --git a/assets/scene/main_1.lua b/assets/scene/main_1.lua index 7b207819..051ad861 100644 --- a/assets/scene/main_1.lua +++ b/assets/scene/main_1.lua @@ -8,7 +8,7 @@ end function scene.keyDown(key,isRep) if isRep then return end if key=='return' then - SCN.go('game_simp',nil,'mino_sprint') + SCN.go('game_simp',nil,'mino/sprint') elseif key=='c' then SCN.go('_console') elseif key=='escape' then @@ -25,9 +25,9 @@ function scene.draw() end scene.widgetList={ - WIDGET.new{type='button_fill',pos={.5,.5},x=-400,y=-20,w=360,h=140, color='R',text='Sprint', fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino_sprint') end}, - WIDGET.new{type='button_fill',pos={.5,.5},x=0, y=-20,w=360,h=140, color='R',text='Marathon',fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino_marathon') end}, - WIDGET.new{type='button_fill',pos={.5,.5},x=400, y=-20,w=360,h=140, color='R',text='Ultra', fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino_ultra') end}, + WIDGET.new{type='button_fill',pos={.5,.5},x=-400,y=-20,w=360,h=140, color='R',text='Sprint', fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino/sprint') end}, + WIDGET.new{type='button_fill',pos={.5,.5},x=0, y=-20,w=360,h=140, color='R',text='Marathon',fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino/marathon') end}, + WIDGET.new{type='button_fill',pos={.5,.5},x=400, y=-20,w=360,h=140, color='R',text='Ultra', fontSize=40,cornerR=0,code=function() SCN.go('game_simp',nil,'mino/ultra') end}, WIDGET.new{type='button_fill',pos={.5,.5},x=-200,y=160,w=360,h=140, color='B',text='Tutorial',fontSize=40,cornerR=0,code=WIDGET.c_goScn'tutorial_1'}, WIDGET.new{type='button_fill',pos={.5,.5},x=200, y=160,w=360,h=140, color='Y',text='Sandbox', fontSize=40,cornerR=0,code=WIDGET.c_goScn'sandbox_1'}, diff --git a/assets/scene/main_test.lua b/assets/scene/main_test.lua index 2d7f67c2..cfebdb30 100644 --- a/assets/scene/main_test.lua +++ b/assets/scene/main_test.lua @@ -16,9 +16,9 @@ end scene.widgetList={ WIDGET.new{type='button',pos={.5,.75}, x=-450,w=120,fontSize=80, text=CHAR.icon.language, code=WIDGET.c_goScn'setting_lang'}, WIDGET.new{type='button',pos={.5,.75}, x=-600,w=120,fontSize=90, text=CHAR.icon.music, code=WIDGET.c_goScn'musicroom'}, - WIDGET.new{type='button',pos={.20,.2}, w=420,h=200, fontSize=50, text='MARATHON', code=function() SCN.go('game_simp',nil,'mino_marathon') end}, - WIDGET.new{type='button',pos={.50,.2}, w=420,h=200, fontSize=70, text='SPRINT', code=function() SCN.go('game_simp',nil,'mino_sprint') end}, - WIDGET.new{type='button',pos={.80,.2}, w=420,h=200, fontSize=50, text='ULTRA', code=function() SCN.go('game_simp',nil,'mino_ultra') end}, + WIDGET.new{type='button',pos={.20,.2}, w=420,h=200, fontSize=50, text='MARATHON', code=function() SCN.go('game_simp',nil,'mino/marathon') end}, + WIDGET.new{type='button',pos={.50,.2}, w=420,h=200, fontSize=70, text='SPRINT', code=function() SCN.go('game_simp',nil,'mino/sprint') end}, + WIDGET.new{type='button',pos={.80,.2}, w=420,h=200, fontSize=50, text='ULTRA', code=function() SCN.go('game_simp',nil,'mino/ultra') end}, WIDGET.new{type='button',pos={.20,.45}, w=420,h=200, fontSize=70, text='BATTLE', code=function() SCN.go('game_simp',nil,'battle') end}, WIDGET.new{type='button_fill',pos={.50,.45}, w=420,h=200, fontSize=70, text='', code=NULL}, WIDGET.new{type='button_fill',pos={.80,.45}, w=420,h=200, fontSize=60, text='', code=NULL}, diff --git a/assets/scene/setting_gem.lua b/assets/scene/setting_gem.lua index dd2357d3..a173d1f5 100644 --- a/assets/scene/setting_gem.lua +++ b/assets/scene/setting_gem.lua @@ -14,7 +14,7 @@ scene.widgetList={ WIDGET.new{type='button', pos={0,1},x=160,y=-80,w=160,h=80, text=CHAR.icon.keyboard,fontSize=60,code=function() SCN.go('keyset_list',nil,'gem') end}, WIDGET.new{type='button', pos={0,1},x=340,y=-80,w=160,h=80, text=LANG'keyset_touch',fontSize=45,code=WIDGET.c_goScn'keyset_touch'}, WIDGET.new{type='switch', pos={0,1},x=480,y=-80,h=50, text='',disp=TABLE.func_getVal(SETTINGS.system,'touchControl'),code=TABLE.func_revVal(SETTINGS.system,'touchControl')}, - WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'gem_test') end}, + WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'gem/test') end}, WIDGET.new{type='button',pos={1,1},x=-120,y=-80,w=160,h=80,sound='back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn}, } diff --git a/assets/scene/setting_mino.lua b/assets/scene/setting_mino.lua index 61761016..a51ac998 100644 --- a/assets/scene/setting_mino.lua +++ b/assets/scene/setting_mino.lua @@ -16,7 +16,7 @@ scene.widgetList={ WIDGET.new{type='button', pos={0,1},x=160,y=-80,w=160,h=80, text=CHAR.icon.keyboard,fontSize=60,code=function() SCN.go('keyset_list',nil,'mino') end}, WIDGET.new{type='button', pos={0,1},x=340,y=-80,w=160,h=80, text=LANG'keyset_touch',fontSize=45,code=WIDGET.c_goScn'keyset_touch'}, WIDGET.new{type='switch', pos={0,1},x=480,y=-80,h=50, text='',disp=TABLE.func_getVal(SETTINGS.system,'touchControl'),code=TABLE.func_revVal(SETTINGS.system,'touchControl')}, - WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'mino_test') end}, + WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'mino/test') end}, WIDGET.new{type='button',pos={1,1},x=-120,y=-80,w=160,h=80,sound='back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn}, } diff --git a/assets/scene/setting_puyo.lua b/assets/scene/setting_puyo.lua index 44318964..79eb1473 100644 --- a/assets/scene/setting_puyo.lua +++ b/assets/scene/setting_puyo.lua @@ -16,7 +16,7 @@ scene.widgetList={ WIDGET.new{type='button', pos={0,1},x=160,y=-80,w=160,h=80, text=CHAR.icon.keyboard,fontSize=60,code=function() SCN.go('keyset_list',nil,'puyo') end}, WIDGET.new{type='button', pos={0,1},x=340,y=-80,w=160,h=80, text=LANG'keyset_touch',fontSize=45,code=WIDGET.c_goScn'keyset_touch'}, WIDGET.new{type='switch', pos={0,1},x=480,y=-80,h=50, text='',disp=TABLE.func_getVal(SETTINGS.system,'touchControl'),code=TABLE.func_revVal(SETTINGS.system,'touchControl')}, - WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'puyo_test') end}, + WIDGET.new{type='button', pos={1,1},x=-300,y=-80,w=160,h=80, text=LANG'keyset_test',fontSize=45,code=function() SCN.go('game_simp',nil,'puyo/test') end}, WIDGET.new{type='button',pos={1,1},x=-120,y=-80,w=160,h=80,sound='back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn}, } diff --git a/assets/skin/puyo_jelly.lua b/assets/skin/puyo_jelly.lua index 3bd65d76..bc051cc8 100644 --- a/assets/skin/puyo_jelly.lua +++ b/assets/skin/puyo_jelly.lua @@ -1,11 +1,9 @@ local gc=love.graphics local gc_push,gc_pop=gc.push,gc.pop -local gc_translate,gc_scale=gc.translate,gc.scale +local gc_translate=gc.translate local gc_setColor=gc.setColor local gc_rectangle=gc.rectangle -local min=math.min - local S={} S.base='puyo_default'