No theme and default BG and patch BG bug when hitting F11 (#1070)

* Add setting slot for no theme & default BG

* Whitelist 4 seasons theme + blocking console's theme command if theme disabled

* Small update theme.lua

* Expose the WIDGET.setOnChange() to use in setting_video.lua

* Shorten "Use custom B.G." to "Custom B.G."

* Shorten theme code, and edit the UI

* Add lock BG

* Add VI translation

* Fullscreen patch

* Modify UI

* Small change

* Undo a mistake
This commit is contained in:
C6H12O6 + NaCl + H2O
2023-12-31 20:35:48 +07:00
committed by GitHub
parent 42942d1ac4
commit 19ea76dc4c
8 changed files with 150 additions and 87 deletions

View File

@@ -49,7 +49,7 @@ SCR.setSize(1280,720) -- Initialize Screen size
BGM.setMaxSources(5) BGM.setMaxSources(5)
VOC.setDiversion(.62) VOC.setDiversion(.62)
WIDGET.setOnChange(function() ChangeButtonColorIfThemeUsed=function()
if SCN.cur~='net_game' and SCN.cur~='custom_field' then if SCN.cur~='net_game' and SCN.cur~='custom_field' then
local colorList=THEME.getThemeColor() local colorList=THEME.getThemeColor()
if colorList then if colorList then
@@ -60,7 +60,8 @@ WIDGET.setOnChange(function()
end end
end end
end end
end) end
WIDGET.setOnChange(ChangeButtonColorIfThemeUsed)
-- Create shortcuts -- Create shortcuts
setFont=FONT.set setFont=FONT.set
@@ -191,7 +192,7 @@ Z.setOnFnKeys({
Z.setOnGlobalKey('f11',function() Z.setOnGlobalKey('f11',function()
if not MOBILE then if not MOBILE then
SETTING.fullscreen=not SETTING.fullscreen SETTING.fullscreen=not SETTING.fullscreen
applySettings() applySettings('fullscreen')
saveSettings() saveSettings()
end end
end) end)

View File

@@ -115,7 +115,7 @@ do-- function applySettings()
light={.2,.8}, light={.2,.8},
color={-.2,1.2}, color={-.2,1.2},
} }
function applySettings() function applySettings(arg)
-- Apply language -- Apply language
text=LANG.get(SETTING.locale) text=LANG.get(SETTING.locale)
WIDGET.setLang(text.WidgetText) WIDGET.setLang(text.WidgetText)
@@ -157,30 +157,34 @@ do-- function applySettings()
SHADER.fieldSatur:send('k',m[2]) SHADER.fieldSatur:send('k',m[2])
-- Apply BG -- Apply BG
if SETTING.bg=='on' then if not (arg and arg=='fullscreen') then
BG.unlock() if SETTING.bg=='on' then
BG.set() BG.unlock()
elseif SETTING.bg=='off' then BG.setDefault(SETTING.defaultBG)
BG.unlock() BG.set()
BG.set('fixColor',SETTING.bgAlpha,SETTING.bgAlpha,SETTING.bgAlpha) if SETTING.lockBG then BG.lock() end
BG.lock() elseif SETTING.bg=='off' then
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()
GC.setDefaultFilter('linear','linear')
BG.set('custom',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.unlock()
BG.set('fixColor',SETTING.bgAlpha,SETTING.bgAlpha,SETTING.bgAlpha) BG.set('fixColor',SETTING.bgAlpha,SETTING.bgAlpha,SETTING.bgAlpha)
BG.lock() 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()
GC.setDefaultFilter('linear','linear')
BG.set('custom',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('fixColor',SETTING.bgAlpha,SETTING.bgAlpha,SETTING.bgAlpha)
BG.lock()
end
end end
end end
end end

View File

@@ -659,6 +659,9 @@ do-- Userdata tables
msaa=0, msaa=0,
bg='on', bg='on',
bgAlpha=.26, bgAlpha=.26,
defaultBG='space',
lockBG=false,
noTheme=false,
powerInfo=false, powerInfo=false,
clickFX=true, clickFX=true,
warn=true, warn=true,

View File

@@ -587,7 +587,11 @@ C. Gamepad
bg_on="Normal B.G.", bg_on="Normal B.G.",
bg_off="No B.G.", bg_off="No B.G.",
bg_custom="Use Custom B.G.", bg_custom="Custom B.G.",
defaultBG="Default B.G.",
resetDbg="Reset default B.G.",
lockBG="Lock B.G.",
noTheme="Disable theme",
blockSatur="Block Saturation", blockSatur="Block Saturation",
fieldSatur="Field Saturation", fieldSatur="Field Saturation",

View File

@@ -599,6 +599,11 @@ C. Tay cầm chơi game (Gamepad):
bg_on="Ảnh nền thường", bg_on="Ảnh nền thường",
bg_off="Không ảnh nền", bg_off="Không ảnh nền",
bg_custom="Ảnh nền tự chọn", bg_custom="Ảnh nền tự chọn",
defaultBG="Nền mặc định",
-- resetDbg='Đặt lại →',
resetDbg="Đặt lại ảnh nền mặc định",
lockBG="Khóa ảnh nền",
noTheme="Tắt theme",
blockSatur="Độ đậm gạch", blockSatur="Độ đậm gạch",
fieldSatur="Độ đậm bảng", fieldSatur="Độ đậm bảng",

View File

@@ -501,10 +501,14 @@ local commands={} do
commands.theme={ commands.theme={
code=function(name) code=function(name)
if name~="" then if name~="" then
if THEME.set(name) then if SETTING.noTheme then
log("Theme set to: "..name) log{"Theme is ",C.R,"disabled",C.Z,"! Please re-enable it before trying this command again"}
else else
log("No theme called "..name) if THEME.set(name) then
log("Theme set to: "..name)
else
log("No theme called "..name)
end
end end
else else
log{C.A,"Usage: theme <xmas|halloween|sprfes|zday1/2/3|season1/2/3/4|fool|birth>"} log{C.A,"Usage: theme <xmas|halloween|sprfes|zday1/2/3|season1/2/3/4|fool|birth>"}

View File

@@ -30,7 +30,7 @@ function scene.draw()
gc.push('transform') gc.push('transform')
gc.setColor(1,1,1) gc.setColor(1,1,1)
local T=skinLib[1] local T=skinLib[1]
gc.translate(0,1410-WIDGET.scrollPos) gc.translate(-200,1410-WIDGET.scrollPos) -- -200
gc.setShader(SHADER.blockSatur) gc.setShader(SHADER.blockSatur)
gc.draw(T,435,0)gc.draw(T,465,0)gc.draw(T,465,30)gc.draw(T,495,30) gc.draw(T,435,0)gc.draw(T,465,0)gc.draw(T,465,30)gc.draw(T,495,30)
gc.setShader(SHADER.fieldSatur) gc.setShader(SHADER.fieldSatur)
@@ -84,15 +84,15 @@ 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=function() SETTING.clickFX=not SETTING.clickFX; applySettings() 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=1050,lim=360,disp=SETval('powerInfo'), code=function() SETTING.powerInfo=not SETTING.powerInfo; applySettings() end}, WIDGET.newSwitch{name='power', x=950,y=1030,lim=360,disp=SETval('powerInfo'), code=function() SETTING.powerInfo=not SETTING.powerInfo; applySettings() end},
WIDGET.newSwitch{name='clean', x=950,y=1120,lim=360,disp=SETval('cleanCanvas'), code=function() SETTING.cleanCanvas=not SETTING.cleanCanvas; applySettings() end}, WIDGET.newSwitch{name='clean', x=950,y=1100,lim=360,disp=SETval('cleanCanvas'), code=function() SETTING.cleanCanvas=not SETTING.cleanCanvas; applySettings() end},
WIDGET.newSwitch{name='fullscreen', x=950,y=1190,lim=360,disp=SETval('fullscreen'), code=function() SETTING.fullscreen=not SETTING.fullscreen; applySettings() end,hideF=function() return MOBILE end}, WIDGET.newSwitch{name='fullscreen', x=950,y=1150,lim=360,disp=SETval('fullscreen'), code=function() SETTING.fullscreen=not SETTING.fullscreen; applySettings() end,hideF=function() return MOBILE end},
WIDGET.newSwitch{name='portrait', x=950,y=1190,lim=360,disp=SETval('portrait'), code=function() SETTING.portrait=not SETTING.portrait; saveSettings(); MES.new('warn',text.settingWarn2,6.26) end,hideF=function() return not MOBILE end}, WIDGET.newSwitch{name='portrait', x=950,y=1150,lim=360,disp=SETval('portrait'), code=function() SETTING.portrait=not SETTING.portrait; saveSettings(); MES.new('warn',text.settingWarn2,6.26) end,hideF=function() return not MOBILE end},
WIDGET.newSlider{name='msaa', x=950,y=1250,lim=360,w=200,axis={0,4,1},show=_msaaShow,disp=function() return SETTING.msaa==0 and 0 or math.log(SETTING.msaa,2) end,code=function(v) SETTING.msaa=v==0 and 0 or 2^v; saveSettings(); if TASK.lock('warnMessage',6.26) then MES.new('warn',text.settingWarn2,6.26) end end}, WIDGET.newSlider{name='msaa', x=950,y=1220,lim=360,w=200,axis={0,4,1},show=_msaaShow,disp=function() return SETTING.msaa==0 and 0 or math.log(SETTING.msaa,2) end,code=function(v) SETTING.msaa=v==0 and 0 or 2^v; saveSettings(); if TASK.lock('warnMessage',6.26) then MES.new('warn',text.settingWarn2,6.26) end 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=680,y=1290,w=200,h=60,code=function() SETTING.bg='off'; 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_on', x=900,y=1290,w=200,h=60,code=function() SETTING.bg='on' ; applySettings() end},
WIDGET.newKey{name='bg_custom', x=1120,y=1340,w=200,h=80, WIDGET.newKey{name='bg_custom', x=1120,y=1290,w=200,h=60,
code=function() code=function()
if love.filesystem.getInfo('conf/customBG') then if love.filesystem.getInfo('conf/customBG') then
SETTING.bg='custom' SETTING.bg='custom'
@@ -101,8 +101,8 @@ scene.widgetList={
MES.new('info',text.customBGhelp) MES.new('info',text.customBGhelp)
end end
end end
}, },
WIDGET.newSlider{name='bgAlpha', x=1020,y=1430,w=200, WIDGET.newSlider{name='bgAlpha', x=1020,y=1365,w=200,
axis={0,.8},disp=SETval('bgAlpha'), axis={0,.8},disp=SETval('bgAlpha'),
code=function(v) code=function(v)
SETTING.bgAlpha=v SETTING.bgAlpha=v
@@ -113,18 +113,60 @@ scene.widgetList={
end end
end, end,
hideF=function() return SETTING.bg=='on' end hideF=function() return SETTING.bg=='on' end
}, },
WIDGET.newSelector{name='defaultBG', x=1120,y=1365,w=200,color='G',
limit=370,
list=BG.getList(),
disp=SETval('defaultBG'),
code=function(v)
SETTING.defaultBG=v
applySettings()
end,
hideF=function() return SETTING.bg~='on' end
},
WIDGET.newKey{name='resetDbg',x=900,y=1365,w=200,h=60,font=25,
code=function()
SETTING.defaultBG='space'
scene.widgetList.defaultBG:reset()
applySettings()
end,
hideF=function() return SETTING.bg~='on' or SETTING.defaultBG=='space' end
},
WIDGET.newSwitch{name='lockBG',x=1170,y=1485,
disp=SETval('lockBG'),
code=function()
SETTING.lockBG=not SETTING.lockBG
applySettings()
end,
hideF=function() return SETTING.bg~='on' end
},
WIDGET.newSelector{name='blockSatur', x=800,y=1440,w=300,color='lN', WIDGET.newSwitch{name='noTheme',x=1170,y=1545,
disp=SETval('noTheme'),
code=function()
SETTING.noTheme=not SETTING.noTheme
local ct=THEME.calculate()
if SETTING.noTheme and type(ct)=='string' and string.sub(ct,1,6)~='season' then
if TASK.lock('warnMessage',6.26) then
MES.new('warn',text.settingWarn2,6.26)
end
else
THEME.set(THEME.calculate())
ChangeButtonColorIfThemeUsed()
end
end
},
WIDGET.newSelector{name='blockSatur', x=600,y=1440,w=300,color='lN',
list={'normal','soft','gray','light','color'}, list={'normal','soft','gray','light','color'},
disp=SETval('blockSatur'), disp=SETval('blockSatur'),
code=function(v) SETTING.blockSatur=v; applySettings() end code=function(v) SETTING.blockSatur=v; applySettings() end
}, },
WIDGET.newSelector{name='fieldSatur', x=800,y=1540,w=300,color='lN', WIDGET.newSelector{name='fieldSatur', x=600,y=1540,w=300,color='lN',
list={'normal','soft','gray','light','color'}, list={'normal','soft','gray','light','color'},
disp=SETval('fieldSatur'), disp=SETval('fieldSatur'),
code=function(v) SETTING.fieldSatur=v; applySettings() end code=function(v) SETTING.fieldSatur=v; applySettings() end
}, },
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
} }

View File

@@ -59,48 +59,48 @@ function THEME.calculate(Y,M,D)
end end
function THEME.set(theme) function THEME.set(theme)
if theme=='xmas' then local seasonT={'null','nil','vaccum','space'}
BG.setDefault('snow') -- Note: by default, the background will be 'space' unless user changed
BGM.setDefault('xmas') -- Because 4 seasonal themes are basically the normal theme, not special like others
MES.new('info',"==Merry Christmas==") if type(theme)=='string' and string.sub(theme,1,6)=='season' then
elseif theme=='birth' then local n=tonumber(string.sub(theme,7))
BG.setDefault('firework') if 0<n and n<5 then
BGM.setDefault('magicblock') BG. setDefault(SETTING.defaultBG)
elseif theme=='sprfes' then BGM.setDefault(seasonT[n])
BG.setDefault('firework') end
BGM.setDefault('spring festival') elseif not SETTING.noTheme then
MES.new('info',"★☆新年快乐☆★") if theme=='xmas' then
elseif theme=='halloween' then BG.setDefault('snow')
BG.setDefault('glow') BGM.setDefault('xmas')
BGM.setDefault('antispace') MES.new('info',"==Merry Christmas==")
MES.new('info',">>Happy halloween<<") elseif theme=='birth' then
elseif theme=='zday1' then BG.setDefault('firework')
BG.setDefault('lanterns') BGM.setDefault('magicblock')
BGM.setDefault('overzero') elseif theme=='sprfes' then
elseif theme=='zday2' then BG.setDefault('firework')
BG.setDefault('lanterns') BGM.setDefault('spring festival')
BGM.setDefault('jazz nihilism') MES.new('info',"★☆新年快乐☆★")
elseif theme=='zday3' then elseif theme=='halloween' then
BG.setDefault('lanterns') BG.setDefault('glow')
BGM.setDefault('empty') BGM.setDefault('antispace')
elseif theme=='season1' then MES.new('info',">>Happy halloween<<")
BG.setDefault('space') elseif theme=='zday1' then
BGM.setDefault('null') BG.setDefault('lanterns')
elseif theme=='season2' then BGM.setDefault('overzero')
BG.setDefault('space') elseif theme=='zday2' then
BGM.setDefault('nil') BG.setDefault('lanterns')
elseif theme=='season3' then BGM.setDefault('jazz nihilism')
BG.setDefault('space') elseif theme=='zday3' then
BGM.setDefault('vacuum') BG.setDefault('lanterns')
elseif theme=='season4' then BGM.setDefault('empty')
BG.setDefault('space') elseif theme=='fool' then
BGM.setDefault('space') BG.setDefault('blockrain')
elseif theme=='fool' then BGM.setDefault('how feeling')
BG.setDefault('blockrain') else
BGM.setDefault('how feeling') return
else end
return else THEME.set(THEME.calculate('0',os.date('%m'),'0')) return end
end
THEME.cur=theme THEME.cur=theme
BG.set() BG.set()
BGM.play() BGM.play()