From 7f22fb6ad11886910f65f0faa871337dbc1fb474 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 6 Jun 2021 13:41:54 +0200 Subject: [PATCH] feat: get debugLevel from commandline --- sonic-radiance.love/birb/core/debug.lua | 4 ++-- sonic-radiance.love/birb/core/init.lua | 19 +++++++++++++++++-- sonic-radiance.love/conf.lua | 1 - 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sonic-radiance.love/birb/core/debug.lua b/sonic-radiance.love/birb/core/debug.lua index ddd423b..6e2531f 100644 --- a/sonic-radiance.love/birb/core/debug.lua +++ b/sonic-radiance.love/birb/core/debug.lua @@ -32,10 +32,10 @@ local Levels = enum { "DEBUG" } -function DebugSystem:new(controller) +function DebugSystem:new(controller, debugLevel) self.controller = controller - self.debugLevel = self.controller.conf.debugLevel or Levels.INFO + self.debugLevel = debugLevel or Levels.WARNING self.active = (self.debugLevel == Levels.DEBUG) if (self.active) then lovebird = require "birb.libs.lovebird" diff --git a/sonic-radiance.love/birb/core/init.lua b/sonic-radiance.love/birb/core/init.lua index 50eb89e..0e4f132 100644 --- a/sonic-radiance.love/birb/core/init.lua +++ b/sonic-radiance.love/birb/core/init.lua @@ -40,10 +40,11 @@ local DataManager = require(cwd .. "datas") -- INIT FUNCTIONS -- Initialize and configure the core object -function CoreSystem:new() +function CoreSystem:new(args) + self.args = args self:setDefaultConf() - self.debug = DebugSystem(self) + self.debug = DebugSystem(self, self:getArg("DEBUGLEVEL", true)) self.options = Options(self) self.input = Input(self) self.screen = Screen(self) @@ -77,6 +78,20 @@ function CoreSystem:getIdentity(versionned) return identity end +function CoreSystem:getArg(name, isNumber) + for _, arg in ipairs(self.args) do + print(arg) + local argData = utils.string.split(arg, "=") + if (argData[1] == name) then + if (isNumber == true) then + return tonumber(argData[2]) + else + return argData[2] + end + end + end +end + -- MOUSE FUNCTIONS -- get directly the mouse when needed diff --git a/sonic-radiance.love/conf.lua b/sonic-radiance.love/conf.lua index 985872b..b729630 100644 --- a/sonic-radiance.love/conf.lua +++ b/sonic-radiance.love/conf.lua @@ -4,7 +4,6 @@ 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)