涉及框架的设置项统一应用,不再细分时机

修改errData的获得方式
WIDGET新增setOnChange方法,不再依赖THEME
This commit is contained in:
MrZ626
2021-12-16 12:39:42 +08:00
parent 8e075adf8f
commit 9c8c9f2106
10 changed files with 120 additions and 103 deletions

View File

@@ -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