From 2b80f72c6b21daec7eb294895c78e58ea15604a7 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 16 Dec 2021 02:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=A1=86=E6=9E=B6=E5=86=85?= =?UTF-8?q?=E5=87=A0=E5=A4=84=E5=AF=B9SETTING=E7=9A=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 47 +++++++++++++++++++--------------- main.lua | 7 ++--- parts/scenes/load.lua | 1 + parts/scenes/setting_video.lua | 6 ++--- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index a6a45a33..e66b56ff 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -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 xOy=SCR.xOy - local ITP=xOy.inverseTransformPoint + local max,min=math.max,math.min +local devMode local mx,my,mouseShow,cursorSpd=640,360,false,0 local jsState={}--map, joystickID->axisStates: {axisName->axisVal} 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, {'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 WIDGET.press(x,y,k) lastX,lastY=x,y - if SETTING.clickFX then SYSFX.newTap(3,x,y)end + if showClickFX then SYSFX.newTap(3,x,y)end end local function mouse_update(dt) 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(x-lastX)^2+(y-lastY)^2<62 then 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 @@ -324,7 +334,7 @@ function love.keypressed(key,_,isRep) elseif key=='space'or key=='return'then mouseShow=true 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) end else @@ -452,7 +462,7 @@ function love.gamepadpressed(_,key) if W and W.arrowKey then W:arrowKey(key)end elseif key=='return'then 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) else if W and W.keypress then @@ -627,14 +637,6 @@ local wsImg={}do } 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() local love=love @@ -649,7 +651,7 @@ function love.run() local FPS,MINI=love.timer.getFPS,love.window.isMinimized 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 lastFrame=timer() @@ -698,7 +700,7 @@ function love.run() --DRAW if not MINI()then - FCT=FCT+SETTING.frameMul + FCT=FCT+frameMul if FCT>=100 then FCT=FCT-100 @@ -720,7 +722,7 @@ function love.run() MES_draw() gc_replaceTransform(SCR.origin) --Draw power info. - if showPowerInfo()then + if showPowerInfo then gc_setColor(1,1,1) gc_draw(infoCanvas,safeX,0,0,SCR.k) end @@ -794,13 +796,13 @@ function love.run() gc_present() --SPEED UPUPUP! - if SETTING.cleanCanvas then gc_discard()end + if discardCanvas then gc_discard()end end end --Fresh power info. if time-lastFreshPow>2.6 then - if showPowerInfo()then + if showPowerInfo then updatePowerInfo() lastFreshPow=time end @@ -830,7 +832,12 @@ local Z={} Z.js=jsState 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. function Z.setCursor(func)drawCursor=func end diff --git a/main.lua b/main.lua index 71e23307..e09495d9 100644 --- a/main.lua +++ b/main.lua @@ -125,9 +125,10 @@ end}) table.insert(_LOADTIMELIST_,("Load Parts: %.3fs"):format(TIME()-_LOADTIME_)) --Init Zframework -Z.setIfPowerInfo(function() - return SETTING.powerInfo and LOADED -end) +Z.setCleanCanvas(SETTING.cleanCanvas) +Z.setFrameMul(SETTING.frameMul) +Z.setClickFX(SETTING.clickFX) + do--Z.setCursor local normImg=GC.DO{16,16, {'fCirc',8,8,4}, diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index 8a1b095b..3598fe57 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -113,6 +113,7 @@ local loadingThread=coroutine.wrap(function() VOC.play('welcome') THEME.fresh() LOADED=true + Z.setPowerInfo(SETTING.powerInfo) return'finish' end) diff --git a/parts/scenes/setting_video.lua b/parts/scenes/setting_video.lua index 012595df..ea3d2414 100644 --- a/parts/scenes/setting_video.lua +++ b/parts/scenes/setting_video.lua @@ -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='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='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='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='clean', x=950,y=1160,lim=360,disp=SETval('cleanCanvas'), code=SETrev('cleanCanvas')}, + 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=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.newKey{name='bg_on', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='on'applyBG()end},