涉及框架的设置项统一应用,不再细分时机
修改errData的获得方式 WIDGET新增setOnChange方法,不再依赖THEME
This commit is contained in:
@@ -319,7 +319,7 @@ function love.keypressed(key,_,isRep)
|
||||
MES.new('info',"DEBUG ON",.2)
|
||||
elseif key=='f11'then
|
||||
SETTING.fullscreen=not SETTING.fullscreen
|
||||
applyFullscreen()
|
||||
applySettings()
|
||||
saveSettings()
|
||||
elseif not SCN.swapping then
|
||||
if EDITING==""and(not SCN.keyDown or SCN.keyDown(key,isRep))then
|
||||
@@ -492,6 +492,7 @@ function love.lowmemory()
|
||||
end
|
||||
end
|
||||
function love.resize(w,h)
|
||||
if SCR.w==w and SCR.h==h then return end
|
||||
SCR.resize(w,h)
|
||||
if BG.resize then BG.resize(w,h)end
|
||||
if SCN.resize then SCN.resize(w,h)end
|
||||
@@ -829,13 +830,19 @@ end
|
||||
|
||||
local Z={}
|
||||
|
||||
Z.js=jsState
|
||||
Z.errData=errData
|
||||
function Z.getJsState()return jsState end
|
||||
function Z.getErr(i)
|
||||
if i=='#'then
|
||||
return errData[#errData]
|
||||
elseif i then
|
||||
return errData[i]
|
||||
else
|
||||
return errData
|
||||
end
|
||||
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
|
||||
|
||||
@@ -844,12 +851,12 @@ function Z.setCursor(func)drawCursor=func end
|
||||
|
||||
--Change F1~F7 events of devmode (F8 mode)
|
||||
function Z.setOnFnKeys(list)
|
||||
assert(type(list)=='table')
|
||||
assert(type(list)=='table',"Z.setOnFnKeys(list): list must be a table.")
|
||||
for i=1,7 do fnKey[i]=type(list[i])=='function'and list[i]or NULL end
|
||||
end
|
||||
|
||||
function Z.setOnFocus(func)onFocus=type(func)=='function'and func or NULL end
|
||||
function Z.setOnFocus(func)onFocus=assert(type(func)=='function'and func,"Z.setOnFocus(func): func must be a function")end
|
||||
|
||||
function Z.setOnQuit(func)onQuit=type(func)=='function'and func or NULL end
|
||||
function Z.setOnQuit(func)onQuit=assert(type(func)=='function'and func,"Z.setOnQuit(func): func must be a function")end
|
||||
|
||||
return Z
|
||||
|
||||
@@ -45,7 +45,12 @@ local function _rectangleStencil()
|
||||
gc.rectangle('fill',1,1,STW-2,STH-2)
|
||||
end
|
||||
|
||||
local onChange=NULL
|
||||
|
||||
local WIDGET={}
|
||||
|
||||
function WIDGET.setOnChange(func)onChange=assert(type(func)=='function'and func,"WIDGET.setOnChange(func): func must be a function")end
|
||||
|
||||
local widgetMetatable={
|
||||
__tostring=function(self)
|
||||
return self:getInfo()
|
||||
@@ -1263,7 +1268,7 @@ end
|
||||
function listBox:getInfo()
|
||||
return("x=%d,y=%d,w=%d,h=%d"):format(self.x+self.w*.5,self.y+self.h*.5,self.w,self.h)
|
||||
end
|
||||
function WIDGET.newListBox(D)--name,x,y,w,h,lineH[,hideF][,hide][,drawF]
|
||||
function WIDGET.newListBox(D)--name,x,y,w,h,lineH,drawF[,hideF][,hide]
|
||||
local _={
|
||||
name= D.name or"_",
|
||||
|
||||
@@ -1320,16 +1325,7 @@ function WIDGET.setWidgetList(list)
|
||||
for i=1,#list do
|
||||
list[i]:reset()
|
||||
end
|
||||
if SCN.cur~='custom_field'then
|
||||
local colorList=THEME.getThemeColor()
|
||||
if not colorList then return end
|
||||
local rnd=math.random
|
||||
for _,W in next,list do
|
||||
if W.color and not W.fText then
|
||||
W.color=colorList[rnd(#colorList)]
|
||||
end
|
||||
end
|
||||
end
|
||||
onChange()
|
||||
end
|
||||
end
|
||||
function WIDGET.setScrollHeight(height)
|
||||
|
||||
23
main.lua
23
main.lua
@@ -62,6 +62,19 @@ BGM.setMaxSources(5)
|
||||
BGM.setChange(function(name)MES.new('music',text.nowPlaying..name,5)end)
|
||||
VOC.setDiversion(.62)
|
||||
|
||||
WIDGET.setOnChange(function()
|
||||
if SCN.cur~='custom_field'then
|
||||
local colorList=THEME.getThemeColor()
|
||||
if not colorList then return end
|
||||
local rnd=math.random
|
||||
for _,W in next,SCN.scenes[SCN.cur].widgetList do
|
||||
if W.color then
|
||||
W.color=colorList[rnd(#colorList)]
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
table.insert(_LOADTIMELIST_,("Load Zframework: %.3fs"):format(TIME()-_LOADTIME_))
|
||||
|
||||
--Create shortcuts
|
||||
@@ -125,10 +138,6 @@ end})
|
||||
table.insert(_LOADTIMELIST_,("Load Parts: %.3fs"):format(TIME()-_LOADTIME_))
|
||||
|
||||
--Init Zframework
|
||||
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},
|
||||
@@ -575,7 +584,7 @@ if FIRSTLAUNCH and MOBILE then
|
||||
end
|
||||
|
||||
--Apply system setting
|
||||
applyAllSettings()
|
||||
applySettings()
|
||||
|
||||
--Load replays
|
||||
for _,fileName in next,fs.getDirectoryItems('replay')do
|
||||
@@ -653,9 +662,9 @@ if TABLE.find(arg,'--test')then
|
||||
TASK.new(function()
|
||||
while true do
|
||||
YIELD()
|
||||
if Z.errData[1]then break end
|
||||
if Z.getErr(1)then break end
|
||||
end
|
||||
LOG("\27[91m\27[1mAutomatic Test Failed :(\27[0m\nThe error message is:\n"..table.concat(Z.errData[1].mes,"\n").."\27[91m\nAborting\27[0m")
|
||||
LOG("\27[91m\27[1mAutomatic Test Failed :(\27[0m\nThe error message is:\n"..table.concat(Z.getErr(1).mes,"\n").."\27[91m\nAborting\27[0m")
|
||||
TEST.yieldN(60)
|
||||
love.event.quit(1)
|
||||
end)
|
||||
|
||||
@@ -109,23 +109,7 @@ end
|
||||
function saveSettings()
|
||||
return saveFile(SETTING,'conf/settings')
|
||||
end
|
||||
function applyLanguage()
|
||||
text=LANG.get(SETTING.locale)
|
||||
WIDGET.setLang(text.WidgetText)
|
||||
for k,v in next,TEXTOBJ do
|
||||
if rawget(text,k)then
|
||||
v:set(text[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
function applyCursor()
|
||||
love.mouse.setVisible(SETTING.sysCursor)
|
||||
end
|
||||
function applyFullscreen()
|
||||
love.window.setFullscreen(SETTING.fullscreen)
|
||||
love.resize(gc.getWidth(),gc.getHeight())
|
||||
end
|
||||
do--function applyBlockSatur,applyFieldSatur(mode)
|
||||
do--function applySettings()
|
||||
local saturateValues={
|
||||
normal={0,1},
|
||||
soft={.2,.7},
|
||||
@@ -133,58 +117,79 @@ do--function applyBlockSatur,applyFieldSatur(mode)
|
||||
light={.2,.8},
|
||||
color={-.2,1.2},
|
||||
}
|
||||
function applyBlockSatur(mode)
|
||||
local m=saturateValues[mode]or saturateValues.normal
|
||||
function applySettings()
|
||||
--Apply fullscreen
|
||||
love.window.setFullscreen(SETTING.fullscreen)
|
||||
love.resize(gc.getWidth(),gc.getHeight())
|
||||
|
||||
--Apply Zframework setting
|
||||
Z.setClickFX(SETTING.clickFX)
|
||||
Z.setFrameMul(SETTING.frameMul)
|
||||
Z.setPowerInfo(SETTING.powerInfo)
|
||||
Z.setCleanCanvas(SETTING.cleanCanvas)
|
||||
|
||||
--Apply VK shape
|
||||
VK.setShape(SETTING.VKSkin)
|
||||
|
||||
--Apply sound
|
||||
love.audio.setVolume(SETTING.mainVol)
|
||||
BGM.setVol(SETTING.bgm)
|
||||
SFX.setVol(SETTING.sfx)
|
||||
VOC.setVol(SETTING.voc)
|
||||
|
||||
--Apply saturs
|
||||
local m
|
||||
m=saturateValues[SETTING.blockSatur]or saturateValues.normal
|
||||
SHADER.blockSatur:send('b',m[1])
|
||||
SHADER.blockSatur:send('k',m[2])
|
||||
end
|
||||
function applyFieldSatur(mode)
|
||||
local m=saturateValues[mode]or saturateValues.normal
|
||||
m=saturateValues[SETTING.fieldSatur]or saturateValues.normal
|
||||
SHADER.fieldSatur:send('b',m[1])
|
||||
SHADER.fieldSatur:send('k',m[2])
|
||||
end
|
||||
end
|
||||
function applyBG()
|
||||
if SETTING.bg=='on'then
|
||||
BG.unlock()
|
||||
BG.set()
|
||||
elseif SETTING.bg=='off'then
|
||||
BG.unlock()
|
||||
BG.set('gray')
|
||||
BG.send(SETTING.bgAlpha)
|
||||
BG.lock()
|
||||
elseif SETTING.bg=='custom'then
|
||||
if love.filesystem.getInfo('conf/customBG')then
|
||||
local res,image=pcall(gc.newImage,love.filesystem.newFile('conf/customBG'))
|
||||
if res then
|
||||
BG.unlock()
|
||||
BG.set('custom')
|
||||
gc.setDefaultFilter('linear','linear')
|
||||
BG.send(SETTING.bgAlpha,image)
|
||||
gc.setDefaultFilter('nearest','nearest')
|
||||
BG.lock()
|
||||
else
|
||||
MES.new('error',text.customBGloadFailed)
|
||||
|
||||
--Apply language
|
||||
text=LANG.get(SETTING.locale)
|
||||
WIDGET.setLang(text.WidgetText)
|
||||
for k,v in next,TEXTOBJ do
|
||||
if rawget(text,k)then
|
||||
v:set(text[k])
|
||||
end
|
||||
end
|
||||
|
||||
--Apply cursor
|
||||
love.mouse.setVisible(SETTING.sysCursor)
|
||||
|
||||
--Apply BG
|
||||
if SETTING.bg=='on'then
|
||||
BG.unlock()
|
||||
BG.set()
|
||||
elseif SETTING.bg=='off'then
|
||||
BG.unlock()
|
||||
BG.set('gray')
|
||||
BG.send(SETTING.bgAlpha)
|
||||
BG.lock()
|
||||
elseif SETTING.bg=='custom'then
|
||||
if love.filesystem.getInfo('conf/customBG')then
|
||||
local res,image=pcall(gc.newImage,love.filesystem.newFile('conf/customBG'))
|
||||
if res then
|
||||
BG.unlock()
|
||||
BG.set('custom')
|
||||
gc.setDefaultFilter('linear','linear')
|
||||
BG.send(SETTING.bgAlpha,image)
|
||||
gc.setDefaultFilter('nearest','nearest')
|
||||
BG.lock()
|
||||
else
|
||||
MES.new('error',text.customBGloadFailed)
|
||||
end
|
||||
else--Switch off when custom BG not found
|
||||
SETTING.bg='off'
|
||||
BG.unlock()
|
||||
BG.set('gray')
|
||||
BG.send(SETTING.bgAlpha)
|
||||
BG.lock()
|
||||
end
|
||||
else
|
||||
SETTING.bg='off'
|
||||
applyBG()
|
||||
end
|
||||
end
|
||||
end
|
||||
function applyAllSettings()
|
||||
applyFullscreen()
|
||||
love.audio.setVolume(SETTING.mainVol)
|
||||
VK.setShape(SETTING.VKSkin)
|
||||
BGM.setVol(SETTING.bgm)
|
||||
SFX.setVol(SETTING.sfx)
|
||||
VOC.setVol(SETTING.voc)
|
||||
applyBlockSatur(SETTING.blockSatur)
|
||||
applyFieldSatur(SETTING.fieldSatur)
|
||||
applyLanguage()
|
||||
applyCursor()
|
||||
applyBG()
|
||||
end
|
||||
|
||||
--Royale mode
|
||||
function randomTarget(P)--Return a random opponent for P
|
||||
|
||||
@@ -279,7 +279,7 @@ function NET.loadSavedData(sections)
|
||||
|
||||
TABLE.cover(NET.cloudData.SETTING,SETTING)
|
||||
success=success and saveSettings()
|
||||
applyAllSettings()
|
||||
applySettings()
|
||||
|
||||
TABLE.cover(NET.cloudData.keyMap,KEY_MAP)
|
||||
success=success and saveFile(KEY_MAP,'conf/key')
|
||||
|
||||
@@ -9,9 +9,9 @@ local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BGcolor=rnd()>.026 and{.3,.5,.9}or{.62,.3,.926}
|
||||
sysAndScn=SYSTEM.."-"..VERSION.string.." scene:"..Z.errData[#Z.errData].scene
|
||||
sysAndScn=SYSTEM.."-"..VERSION.string.." scene:"..Z.getErrData('#').scene
|
||||
errorText=LOADED and text.errorMsg or"An error has occurred while the game was loading.\nAn error log has been created so you can send it to the author."
|
||||
errorShot,errorInfo=Z.errData[#Z.errData].shot,Z.errData[#Z.errData].mes
|
||||
errorShot,errorInfo=Z.getErrData('#').shot,Z.getErrData('#').mes
|
||||
NET.wsclose_app()
|
||||
NET.wsclose_user()
|
||||
NET.wsclose_play()
|
||||
|
||||
@@ -42,7 +42,7 @@ end
|
||||
|
||||
local function _setLang(lid)
|
||||
SETTING.locale=lid
|
||||
applyLanguage()
|
||||
applySettings()
|
||||
TEXT.clear()
|
||||
TEXT.show(langList[lid],640,360,100,'appear',.626)
|
||||
collectgarbage()
|
||||
|
||||
@@ -59,7 +59,7 @@ scene.widgetList={
|
||||
local D=_parseCB()
|
||||
if D then
|
||||
TABLE.update(D,SETTING)
|
||||
applyAllSettings()
|
||||
applySettings()
|
||||
saveSettings()
|
||||
MES.new('check',text.importSuccess)
|
||||
else
|
||||
|
||||
@@ -45,7 +45,7 @@ scene.widgetList={
|
||||
WIDGET.newSlider{name='reTime', x=330, y=320, w=300,lim=180,unit=10,disp=SETval('reTime'), code=SETsto('reTime'),show=function(S)return(.5+S.disp()*.25).."s"end},
|
||||
WIDGET.newSelector{name='RS', x=300, y=420, w=300,color='S', disp=SETval('RS'), code=SETsto('RS'),list={'TRS','SRS','SRS_plus','SRS_X','BiRS','ARS_Z','DRS_weak','ASC','ASC_plus','C2','C2_sym','Classic','Classic_plus','None','None_plus'}},
|
||||
WIDGET.newSelector{name='menuPos',x=980, y=320, w=300,color='O', disp=SETval('menuPos'), code=SETsto('menuPos'),list={'left','middle','right'}},
|
||||
WIDGET.newSwitch{name='sysCursor',x=1060, y=390, lim=580, disp=SETval('sysCursor'),code=function()SETTING.sysCursor=not SETTING.sysCursor applyCursor()end},
|
||||
WIDGET.newSwitch{name='sysCursor',x=1060, y=390, lim=580, disp=SETval('sysCursor'),code=function()SETTING.sysCursor=not SETTING.sysCursor applySettings()end},
|
||||
WIDGET.newSwitch{name='autoPause',x=1060, y=450, lim=580, disp=SETval('autoPause'),code=SETrev('autoPause')},
|
||||
WIDGET.newSwitch{name='autoSave', x=1060, y=500, lim=580, disp=SETval('autoSave'), code=SETrev('autoSave')},
|
||||
WIDGET.newSwitch{name='autoLogin',x=960, y=580, lim=480, disp=SETval('autoLogin'),code=SETrev('autoLogin')},
|
||||
|
||||
@@ -11,7 +11,7 @@ function scene.fileDropped(file)
|
||||
if pcall(gc.newImage,file)then
|
||||
love.filesystem.write('conf/customBG',file:read('data'))
|
||||
SETTING.bg='custom'
|
||||
applyBG()
|
||||
applySettings()
|
||||
else
|
||||
MES.new('error',text.customBGloadFailed)
|
||||
end
|
||||
@@ -79,18 +79,18 @@ scene.widgetList={
|
||||
WIDGET.newSwitch{name='highCam', x=450,y=1270,lim=360,disp=SETval('highCam'), code=SETrev('highCam')},
|
||||
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=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.newSwitch{name='clickFX', x=950,y=980,lim=360,disp=SETval('clickFX'), code=function()SETTING.clickFX=not SETTING.clickFX applySettings()end},
|
||||
WIDGET.newSwitch{name='power', x=950,y=1070,lim=360,disp=SETval('powerInfo'), code=function()SETTING.powerInfo=not SETTING.powerInfo applySettings()end},
|
||||
WIDGET.newSwitch{name='clean', x=950,y=1160,lim=360,disp=SETval('cleanCanvas'), code=function()SETTING.cleanCanvas=not SETTING.cleanCanvas applySettings()end},
|
||||
WIDGET.newSwitch{name='fullscreen', x=950,y=1250,lim=360,disp=SETval('fullscreen'), code=function()SETTING.fullscreen=not SETTING.fullscreen applySettings()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_off', x=900,y=1340,w=200,h=80,code=function()SETTING.bg='off'applyBG()end},
|
||||
WIDGET.newKey{name='bg_on', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='on'applySettings()end},
|
||||
WIDGET.newKey{name='bg_off', x=900,y=1340,w=200,h=80,code=function()SETTING.bg='off'applySettings()end},
|
||||
WIDGET.newKey{name='bg_custom', x=1120,y=1340,w=200,h=80,
|
||||
code=function()
|
||||
if love.filesystem.getInfo('conf/customBG')then
|
||||
SETTING.bg='custom'
|
||||
applyBG()
|
||||
applySettings()
|
||||
else
|
||||
MES.new('info',text.customBGhelp)
|
||||
end
|
||||
@@ -105,12 +105,12 @@ scene.widgetList={
|
||||
WIDGET.newSelector{name='blockSatur', x=800,y=1440,w=300,color='lN',
|
||||
list={'normal','soft','gray','light','color'},
|
||||
disp=SETval('blockSatur'),
|
||||
code=function(v)SETTING.blockSatur=v;applyBlockSatur(SETTING.blockSatur)end
|
||||
code=function(v)SETTING.blockSatur=v;applySettings(SETTING.blockSatur)end
|
||||
},
|
||||
WIDGET.newSelector{name='fieldSatur', x=800,y=1540,w=300,color='lN',
|
||||
list={'normal','soft','gray','light','color'},
|
||||
disp=SETval('fieldSatur'),
|
||||
code=function(v)SETTING.fieldSatur=v;applyFieldSatur(SETTING.fieldSatur)end
|
||||
code=function(v)SETTING.fieldSatur=v;applySettings(SETTING.fieldSatur)end
|
||||
},
|
||||
|
||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||
|
||||
Reference in New Issue
Block a user