From 30a16b4e3fbb7d945078970a221e72c56e5afe0b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 5 May 2021 12:09:30 +0200 Subject: [PATCH] improvement: put all default config in conf.lua --- sonic-radiance.love/birb/core/debug.lua | 2 +- sonic-radiance.love/birb/core/init.lua | 22 ++++++++++++++++++++++ sonic-radiance.love/birb/core/options.lua | 15 ++++++++------- sonic-radiance.love/conf.lua | 11 +++++++++-- sonic-radiance.love/game/init.lua | 2 +- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/sonic-radiance.love/birb/core/debug.lua b/sonic-radiance.love/birb/core/debug.lua index 26c797d..dda8b20 100644 --- a/sonic-radiance.love/birb/core/debug.lua +++ b/sonic-radiance.love/birb/core/debug.lua @@ -1,4 +1,4 @@ --- core/debug.lua :: Debug functions for the core system. +-- core/debug.lua :: The basic internal debug framework of the birb engine. --[[ Copyright © 2019 Kazhnuz diff --git a/sonic-radiance.love/birb/core/init.lua b/sonic-radiance.love/birb/core/init.lua index 2ecefee..dcfbcf8 100644 --- a/sonic-radiance.love/birb/core/init.lua +++ b/sonic-radiance.love/birb/core/init.lua @@ -39,6 +39,8 @@ local SceneManager = require(cwd .. "scenemanager") -- Initialize and configure the core object function CoreSystem:new(isDebug) + self:setDefaultConf() + self.debug = DebugSystem(self, isDebug) self.options = Options(self) self.input = Input(self) @@ -47,10 +49,30 @@ function CoreSystem:new(isDebug) self.lang = Lang(self) end +function CoreSystem:setDefaultConf() + self.conf = {} + self.conf.window = {} + self.conf.modules = {} + love.conf(self.conf) +end + function CoreSystem:registerGameSystem(gamesystem) self.game = gamesystem end +function CoreSystem:getDefaultConf() + return self.conf +end + +function CoreSystem:getIdentity(versionned) + local identity = self.conf.identity or "birbengine" + if (versionned) then + local version = self.conf.gameversion or 0 + identity = identity .. "-" .. version + end + return identity +end + -- MOUSE FUNCTIONS -- get directly the mouse when needed diff --git a/sonic-radiance.love/birb/core/options.lua b/sonic-radiance.love/birb/core/options.lua index 8fc2637..50f193b 100644 --- a/sonic-radiance.love/birb/core/options.lua +++ b/sonic-radiance.love/birb/core/options.lua @@ -39,13 +39,14 @@ function OptionsManager:new(controller) end function OptionsManager:reset() + local conf = self.controller:getDefaultConf() -- Reset the option to the game defaults. self.data.video = {} - self.data.video.crtfilter = false - self.data.video.resolution = 2 - self.data.video.border = true - self.data.video.vsync = true - self.data.video.fullscreen = false + self.data.video.crtfilter = (conf.window.crtfilter == true) + self.data.video.resolution = conf.window.resolution or 1 + self.data.video.border = (conf.window.borderless == false) + self.data.video.vsync = (conf.window.vsync ~= false) + self.data.video.fullscreen = (conf.window.fullscreen == true) -- We load the default files self.data.input = self:getInputDefaultData() @@ -54,8 +55,8 @@ function OptionsManager:reset() self.data.language = self:getTranslationDefaultData() self.data.audio = {} - self.data.audio.music = 100 - self.data.audio.sfx = 100 + self.data.audio.music = conf.volume.music or 100 + self.data.audio.sfx = conf.volume.sfx or 100 end -- INFO FUNCTIONS diff --git a/sonic-radiance.love/conf.lua b/sonic-radiance.love/conf.lua index fdc1472..985872b 100644 --- a/sonic-radiance.love/conf.lua +++ b/sonic-radiance.love/conf.lua @@ -4,11 +4,13 @@ function love.conf(t) t.console = false -- Attach a console (boolean, Windows only) t.accelerometerjoystick = false -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean) + t.debugLevel = 4 -- Debug level mode : 0=Error only, 3=Everything. + t.gameversion = "0.0.7" -- The game version (different than love2D version) t.window.title = "Sonic Radiance" -- The window title (string) t.window.icon = nil -- Filepath to an image to use as the window's icon (string) - t.window.width = 424 -- The window width (number) - t.window.height = 240 -- The window height (number) + t.window.width = 424 -- The window internal width (number) + t.window.height = 240 -- The window internal height (number) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) @@ -21,6 +23,11 @@ function love.conf(t) t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number) + t.window.resolution = 2 -- The default resolution + + t.volume = {} + t.volume.music = 100 -- music audio volume + t.volume.sfx = 100 -- sfx audio volume t.modules.audio = true -- Enable the audio module (boolean) t.modules.event = true -- Enable the event module (boolean) diff --git a/sonic-radiance.love/game/init.lua b/sonic-radiance.love/game/init.lua index b2742bf..8a58df5 100644 --- a/sonic-radiance.love/game/init.lua +++ b/sonic-radiance.love/game/init.lua @@ -41,7 +41,7 @@ Game.gui = require "game.modules.gui" function Game:new() self.slot = -1 self.slotNumber = 3 - self.version = "0.0.7" + self.version = core.conf.gameversion or "N/A" self:resetData() end