improvement: put all default config in conf.lua

This commit is contained in:
Kazhnuz 2021-05-05 12:09:30 +02:00
parent 61a3206a95
commit 30a16b4e3f
5 changed files with 41 additions and 11 deletions

View file

@ -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 Copyright © 2019 Kazhnuz

View file

@ -39,6 +39,8 @@ local SceneManager = require(cwd .. "scenemanager")
-- Initialize and configure the core object -- Initialize and configure the core object
function CoreSystem:new(isDebug) function CoreSystem:new(isDebug)
self:setDefaultConf()
self.debug = DebugSystem(self, isDebug) self.debug = DebugSystem(self, isDebug)
self.options = Options(self) self.options = Options(self)
self.input = Input(self) self.input = Input(self)
@ -47,10 +49,30 @@ function CoreSystem:new(isDebug)
self.lang = Lang(self) self.lang = Lang(self)
end end
function CoreSystem:setDefaultConf()
self.conf = {}
self.conf.window = {}
self.conf.modules = {}
love.conf(self.conf)
end
function CoreSystem:registerGameSystem(gamesystem) function CoreSystem:registerGameSystem(gamesystem)
self.game = gamesystem self.game = gamesystem
end 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 -- MOUSE FUNCTIONS
-- get directly the mouse when needed -- get directly the mouse when needed

View file

@ -39,13 +39,14 @@ function OptionsManager:new(controller)
end end
function OptionsManager:reset() function OptionsManager:reset()
local conf = self.controller:getDefaultConf()
-- Reset the option to the game defaults. -- Reset the option to the game defaults.
self.data.video = {} self.data.video = {}
self.data.video.crtfilter = false self.data.video.crtfilter = (conf.window.crtfilter == true)
self.data.video.resolution = 2 self.data.video.resolution = conf.window.resolution or 1
self.data.video.border = true self.data.video.border = (conf.window.borderless == false)
self.data.video.vsync = true self.data.video.vsync = (conf.window.vsync ~= false)
self.data.video.fullscreen = false self.data.video.fullscreen = (conf.window.fullscreen == true)
-- We load the default files -- We load the default files
self.data.input = self:getInputDefaultData() self.data.input = self:getInputDefaultData()
@ -54,8 +55,8 @@ function OptionsManager:reset()
self.data.language = self:getTranslationDefaultData() self.data.language = self:getTranslationDefaultData()
self.data.audio = {} self.data.audio = {}
self.data.audio.music = 100 self.data.audio.music = conf.volume.music or 100
self.data.audio.sfx = 100 self.data.audio.sfx = conf.volume.sfx or 100
end end
-- INFO FUNCTIONS -- INFO FUNCTIONS

View file

@ -4,11 +4,13 @@ function love.conf(t)
t.console = false -- Attach a console (boolean, Windows only) 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.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.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.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.icon = nil -- Filepath to an image to use as the window's icon (string)
t.window.width = 424 -- The window width (number) t.window.width = 424 -- The window internal width (number)
t.window.height = 240 -- The window height (number) t.window.height = 240 -- The window internal height (number)
t.window.borderless = false -- Remove all border visuals from the window (boolean) 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.resizable = false -- Let the window be user-resizable (boolean)
t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) 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.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.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.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.audio = true -- Enable the audio module (boolean)
t.modules.event = true -- Enable the event module (boolean) t.modules.event = true -- Enable the event module (boolean)

View file

@ -41,7 +41,7 @@ Game.gui = require "game.modules.gui"
function Game:new() function Game:new()
self.slot = -1 self.slot = -1
self.slotNumber = 3 self.slotNumber = 3
self.version = "0.0.7" self.version = core.conf.gameversion or "N/A"
self:resetData() self:resetData()
end end