移除框架内几处对SETTING的依赖
This commit is contained in:
@@ -70,15 +70,25 @@ local gc_draw,gc_line,gc_circle,gc_print=gc.draw,gc.line,gc.circle,gc.print
|
|||||||
|
|
||||||
local WIDGET,SCR,SCN=WIDGET,SCR,SCN
|
local WIDGET,SCR,SCN=WIDGET,SCR,SCN
|
||||||
local xOy=SCR.xOy
|
local xOy=SCR.xOy
|
||||||
|
|
||||||
local ITP=xOy.inverseTransformPoint
|
local ITP=xOy.inverseTransformPoint
|
||||||
|
|
||||||
local max,min=math.max,math.min
|
local max,min=math.max,math.min
|
||||||
|
|
||||||
|
local devMode
|
||||||
local mx,my,mouseShow,cursorSpd=640,360,false,0
|
local mx,my,mouseShow,cursorSpd=640,360,false,0
|
||||||
local jsState={}--map, joystickID->axisStates: {axisName->axisVal}
|
local jsState={}--map, joystickID->axisStates: {axisName->axisVal}
|
||||||
local errData={}--list, each error create {mes={errMes strings},scene=sceneNameStr}
|
local errData={}--list, each error create {mes={errMes strings},scene=sceneNameStr}
|
||||||
|
|
||||||
local devMode
|
local function drawCursor(_,x,y)
|
||||||
|
gc_setColor(1,1,1)
|
||||||
|
gc_setLineWidth(2)
|
||||||
|
gc_circle(ms.isDown(1)and'fill'or'line',x,y,6)
|
||||||
|
end
|
||||||
|
local showPowerInfo=true
|
||||||
|
local showClickFX=true
|
||||||
|
local discardCanvas=false
|
||||||
|
local frameMul=100
|
||||||
|
local onQuit=NULL
|
||||||
|
|
||||||
local batteryImg=GC.DO{31,20,
|
local batteryImg=GC.DO{31,20,
|
||||||
{'fRect',1,0,26,2},
|
{'fRect',1,0,26,2},
|
||||||
@@ -152,7 +162,7 @@ local function _triggerMouseDown(x,y,k)
|
|||||||
if SCN.mouseDown then SCN.mouseDown(x,y,k)end
|
if SCN.mouseDown then SCN.mouseDown(x,y,k)end
|
||||||
WIDGET.press(x,y,k)
|
WIDGET.press(x,y,k)
|
||||||
lastX,lastY=x,y
|
lastX,lastY=x,y
|
||||||
if SETTING.clickFX then SYSFX.newTap(3,x,y)end
|
if showClickFX then SYSFX.newTap(3,x,y)end
|
||||||
end
|
end
|
||||||
local function mouse_update(dt)
|
local function mouse_update(dt)
|
||||||
if not KBisDown('lctrl','rctrl')and KBisDown('up','down','left','right')then
|
if not KBisDown('lctrl','rctrl')and KBisDown('up','down','left','right')then
|
||||||
@@ -260,7 +270,7 @@ function love.touchreleased(id,x,y)
|
|||||||
if SCN.touchUp then SCN.touchUp(x,y)end
|
if SCN.touchUp then SCN.touchUp(x,y)end
|
||||||
if(x-lastX)^2+(y-lastY)^2<62 then
|
if(x-lastX)^2+(y-lastY)^2<62 then
|
||||||
if SCN.touchClick then SCN.touchClick(x,y)end
|
if SCN.touchClick then SCN.touchClick(x,y)end
|
||||||
if SETTING.clickFX then SYSFX.newTap(3,x,y)end
|
if showClickFX then SYSFX.newTap(3,x,y)end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -324,7 +334,7 @@ function love.keypressed(key,_,isRep)
|
|||||||
elseif key=='space'or key=='return'then
|
elseif key=='space'or key=='return'then
|
||||||
mouseShow=true
|
mouseShow=true
|
||||||
if not isRep then
|
if not isRep then
|
||||||
if SETTING.clickFX then SYSFX.newTap(3,mx,my)end
|
if showClickFX then SYSFX.newTap(3,mx,my)end
|
||||||
_triggerMouseDown(mx,my,1)
|
_triggerMouseDown(mx,my,1)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -452,7 +462,7 @@ function love.gamepadpressed(_,key)
|
|||||||
if W and W.arrowKey then W:arrowKey(key)end
|
if W and W.arrowKey then W:arrowKey(key)end
|
||||||
elseif key=='return'then
|
elseif key=='return'then
|
||||||
mouseShow=true
|
mouseShow=true
|
||||||
if SETTING.clickFX then SYSFX.newTap(3,mx,my)end
|
if showClickFX then SYSFX.newTap(3,mx,my)end
|
||||||
_triggerMouseDown(mx,my,1)
|
_triggerMouseDown(mx,my,1)
|
||||||
else
|
else
|
||||||
if W and W.keypress then
|
if W and W.keypress then
|
||||||
@@ -627,14 +637,6 @@ local wsImg={}do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drawCursor(_,x,y)
|
|
||||||
gc_setColor(1,1,1)
|
|
||||||
gc_setLineWidth(2)
|
|
||||||
gc_circle(ms.isDown(1)and'fill'or'line',x,y,6)
|
|
||||||
end
|
|
||||||
local function showPowerInfo()return true end
|
|
||||||
local onQuit=NULL
|
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
local love=love
|
local love=love
|
||||||
|
|
||||||
@@ -649,7 +651,7 @@ function love.run()
|
|||||||
local FPS,MINI=love.timer.getFPS,love.window.isMinimized
|
local FPS,MINI=love.timer.getFPS,love.window.isMinimized
|
||||||
local PUMP,POLL=love.event.pump,love.event.poll
|
local PUMP,POLL=love.event.pump,love.event.poll
|
||||||
|
|
||||||
local timer,SETTING,VERSION=love.timer.getTime,SETTING,VERSION
|
local timer,VERSION=love.timer.getTime,VERSION
|
||||||
|
|
||||||
local frameTimeList={}
|
local frameTimeList={}
|
||||||
local lastFrame=timer()
|
local lastFrame=timer()
|
||||||
@@ -698,7 +700,7 @@ function love.run()
|
|||||||
|
|
||||||
--DRAW
|
--DRAW
|
||||||
if not MINI()then
|
if not MINI()then
|
||||||
FCT=FCT+SETTING.frameMul
|
FCT=FCT+frameMul
|
||||||
if FCT>=100 then
|
if FCT>=100 then
|
||||||
FCT=FCT-100
|
FCT=FCT-100
|
||||||
|
|
||||||
@@ -720,7 +722,7 @@ function love.run()
|
|||||||
MES_draw()
|
MES_draw()
|
||||||
gc_replaceTransform(SCR.origin)
|
gc_replaceTransform(SCR.origin)
|
||||||
--Draw power info.
|
--Draw power info.
|
||||||
if showPowerInfo()then
|
if showPowerInfo then
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
gc_draw(infoCanvas,safeX,0,0,SCR.k)
|
gc_draw(infoCanvas,safeX,0,0,SCR.k)
|
||||||
end
|
end
|
||||||
@@ -794,13 +796,13 @@ function love.run()
|
|||||||
gc_present()
|
gc_present()
|
||||||
|
|
||||||
--SPEED UPUPUP!
|
--SPEED UPUPUP!
|
||||||
if SETTING.cleanCanvas then gc_discard()end
|
if discardCanvas then gc_discard()end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Fresh power info.
|
--Fresh power info.
|
||||||
if time-lastFreshPow>2.6 then
|
if time-lastFreshPow>2.6 then
|
||||||
if showPowerInfo()then
|
if showPowerInfo then
|
||||||
updatePowerInfo()
|
updatePowerInfo()
|
||||||
lastFreshPow=time
|
lastFreshPow=time
|
||||||
end
|
end
|
||||||
@@ -830,7 +832,12 @@ local Z={}
|
|||||||
Z.js=jsState
|
Z.js=jsState
|
||||||
Z.errData=errData
|
Z.errData=errData
|
||||||
|
|
||||||
function Z.setIfPowerInfo(func)showPowerInfo=func end
|
function Z.setPowerInfo(bool)showPowerInfo=bool end
|
||||||
|
|
||||||
|
function Z.setCleanCanvas(bool)discardCanvas=bool end
|
||||||
|
|
||||||
|
function Z.setFrameMul(n)frameMul=n end
|
||||||
|
function Z.setClickFX(bool)showClickFX=bool end
|
||||||
|
|
||||||
--[Warning] Color and line width is uncertain value, set it in the function.
|
--[Warning] Color and line width is uncertain value, set it in the function.
|
||||||
function Z.setCursor(func)drawCursor=func end
|
function Z.setCursor(func)drawCursor=func end
|
||||||
|
|||||||
7
main.lua
7
main.lua
@@ -125,9 +125,10 @@ end})
|
|||||||
table.insert(_LOADTIMELIST_,("Load Parts: %.3fs"):format(TIME()-_LOADTIME_))
|
table.insert(_LOADTIMELIST_,("Load Parts: %.3fs"):format(TIME()-_LOADTIME_))
|
||||||
|
|
||||||
--Init Zframework
|
--Init Zframework
|
||||||
Z.setIfPowerInfo(function()
|
Z.setCleanCanvas(SETTING.cleanCanvas)
|
||||||
return SETTING.powerInfo and LOADED
|
Z.setFrameMul(SETTING.frameMul)
|
||||||
end)
|
Z.setClickFX(SETTING.clickFX)
|
||||||
|
|
||||||
do--Z.setCursor
|
do--Z.setCursor
|
||||||
local normImg=GC.DO{16,16,
|
local normImg=GC.DO{16,16,
|
||||||
{'fCirc',8,8,4},
|
{'fCirc',8,8,4},
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ local loadingThread=coroutine.wrap(function()
|
|||||||
VOC.play('welcome')
|
VOC.play('welcome')
|
||||||
THEME.fresh()
|
THEME.fresh()
|
||||||
LOADED=true
|
LOADED=true
|
||||||
|
Z.setPowerInfo(SETTING.powerInfo)
|
||||||
return'finish'
|
return'finish'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ scene.widgetList={
|
|||||||
WIDGET.newSlider{name='shakeFX', x=330,y=760,lim=280,w=540,unit=5,disp=SETval('shakeFX'), code=SETsto('shakeFX')},
|
WIDGET.newSlider{name='shakeFX', x=330,y=760,lim=280,w=540,unit=5,disp=SETval('shakeFX'), code=SETsto('shakeFX')},
|
||||||
WIDGET.newSlider{name='atkFX', x=330,y=820,lim=280,w=540,unit=5,disp=SETval('atkFX'), code=SETsto('atkFX')},
|
WIDGET.newSlider{name='atkFX', x=330,y=820,lim=280,w=540,unit=5,disp=SETval('atkFX'), code=SETsto('atkFX')},
|
||||||
|
|
||||||
WIDGET.newSelector{name='frame', x=400,y=890,lim=280,w=460,list={8,10,13,17,22,29,37,47,62,80,100},disp=SETval('frameMul'),code=SETsto('frameMul')},
|
WIDGET.newSelector{name='frame', x=400,y=890,lim=280,w=460,list={8,10,13,17,22,29,37,47,62,80,100},disp=SETval('frameMul'),code=function(v)SETTING.frameMul=v;Z.setFrameMul(SETTING.frameMul)end},
|
||||||
WIDGET.newSwitch{name='FTlock', x=950,y=890,lim=290,disp=SETval('FTLock'), code=SETrev('FTLock')},
|
WIDGET.newSwitch{name='FTlock', x=950,y=890,lim=290,disp=SETval('FTLock'), code=SETrev('FTLock')},
|
||||||
|
|
||||||
WIDGET.newSwitch{name='text', x=450,y=980,lim=360,disp=SETval('text'), code=SETrev('text')},
|
WIDGET.newSwitch{name='text', x=450,y=980,lim=360,disp=SETval('text'), code=SETrev('text')},
|
||||||
@@ -80,8 +80,8 @@ scene.widgetList={
|
|||||||
WIDGET.newSwitch{name='warn', x=450,y=1340,lim=360,disp=SETval('warn'), code=SETrev('warn')},
|
WIDGET.newSwitch{name='warn', x=450,y=1340,lim=360,disp=SETval('warn'), code=SETrev('warn')},
|
||||||
|
|
||||||
WIDGET.newSwitch{name='clickFX', x=950,y=980,lim=360,disp=SETval('clickFX'), code=SETrev('clickFX')},
|
WIDGET.newSwitch{name='clickFX', x=950,y=980,lim=360,disp=SETval('clickFX'), code=SETrev('clickFX')},
|
||||||
WIDGET.newSwitch{name='power', x=950,y=1070,lim=360,disp=SETval('powerInfo'), code=SETrev('powerInfo')},
|
WIDGET.newSwitch{name='power', x=950,y=1070,lim=360,disp=SETval('powerInfo'), code=function()SETTING.powerInfo=not SETTING.powerInfo Z.setPowerInfo(SETTING.powerInfo)end},
|
||||||
WIDGET.newSwitch{name='clean', x=950,y=1160,lim=360,disp=SETval('cleanCanvas'), code=SETrev('cleanCanvas')},
|
WIDGET.newSwitch{name='clean', x=950,y=1160,lim=360,disp=SETval('cleanCanvas'), code=function()SETTING.cleanCanvas=not SETTING.cleanCanvas Z.setCleanCanvas(SETTING.cleanCanvas)end},
|
||||||
WIDGET.newSwitch{name='fullscreen', x=950,y=1250,lim=360,disp=SETval('fullscreen'), code=function()SETTING.fullscreen=not SETTING.fullscreen applyFullscreen()end},
|
WIDGET.newSwitch{name='fullscreen', x=950,y=1250,lim=360,disp=SETval('fullscreen'), code=function()SETTING.fullscreen=not SETTING.fullscreen applyFullscreen()end},
|
||||||
|
|
||||||
WIDGET.newKey{name='bg_on', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='on'applyBG()end},
|
WIDGET.newKey{name='bg_on', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='on'applyBG()end},
|
||||||
|
|||||||
Reference in New Issue
Block a user