chore: port every print to new debug mode

This commit is contained in:
Kazhnuz 2019-07-24 11:21:32 +02:00
parent 70d5fdfd8c
commit 2e3fd587c0
12 changed files with 30 additions and 22 deletions

View file

@ -51,7 +51,9 @@ function InputManager:isDown(sourceid, padkey)
local key = self.data[sourceid].keys[padkey]
isdown = love.keyboard.isDown(key)
else
print("Warning: unsupported input device")
local type = self.data[sourceid].type or "nil"
local warnstring = "unsupported input device " .. type .. " for source " .. sourceid
core.debug:warning("core/input", warnstring)
end
return isdown

View file

@ -95,7 +95,7 @@ function LanguageManager:getTranslationStringList(lang, library)
if fileinfo ~= nil then
list = require(_path)
else
print("WARNING: file " .. _path .. " do not exists")
core.debug:warning("core/lang","file " .. _path .. " do not exists")
end
return list
@ -120,7 +120,7 @@ function LanguageManager:translate(library, string)
if (translation == nil) then
translation = string
print("WARNING: no translation path found for " .. string .. " in " .. library)
core.debug:warning("core/lang", "no translation path found for " .. string .. " in " .. library)
end
return translation

View file

@ -48,7 +48,7 @@ end
function Animator:update(dt)
if (self.currentAnimation == "") then
print("warning: no current animation data")
core.debug:warning("animator", "no current animation data")
return 0
end

View file

@ -90,7 +90,7 @@ function Assets:batchImport(datafile)
elseif (asset_type == "sfx") then
self:importSFX(assets)
else
print("Unkown asset type : " .. asset_type)
core.debug:warning("assets/importer", "unkown asset type " .. asset_type)
end
end
end

View file

@ -150,7 +150,7 @@ end
function Scene:getKeys(sourceid)
if sourceid == nil then
print("WARNING", "no sourceid detected, will default to 1")
core.debug:warning("scene", "no sourceid detected, will default to 1")
end
local sourceid = sourceid or 1

View file

@ -163,7 +163,7 @@ end
function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid)
if (self.hitboxes[name] ~= nil) then
print("ERROR:", "The hitbox " .. name .. " already exists")
core.debug:warning("actor2D", "the hitbox " .. name .. " already exists")
else
local hitbox = Hitbox(self, type, ox, oy, w, h, isSolid)
self.hitboxes[name] = hitbox

View file

@ -187,7 +187,7 @@ end
function Actor3D:addHitbox(name, type, ox, oy, oz, w, h, d, isSolid)
if (self.hitboxes[name] ~= nil) then
print("ERROR:", "The hitbox " .. name .. " already exists")
core.debug:warning("actor3D", "the hitbox " .. name .. " already exists")
else
local hitbox = Hitbox(self, type, ox, oy, oz, w, h, d, isSolid)
self.hitboxes[name] = hitbox

View file

@ -36,8 +36,8 @@ function MappedBox:new(owner, x, y, z, w, h, d)
end
function MappedBox:drawTextureContent()
print(self.x, self.y, self.z)
local tx, ty = self.x, self.y - (self.z + self.d)
core.debug:print("mappedbox", "getting map layers at position " .. tx .. ";" .. ty)
love.graphics.push()
love.graphics.origin()
love.graphics.translate(math.floor(-tx), math.floor(-ty))

View file

@ -103,11 +103,16 @@ function BaseWorld:initActors( )
end
function BaseWorld:newActor(name, x, y, z)
local debugstring = " at (" .. x .. ";" .. y .. ")."
core.debug:print("world2D", "adding actor " .. name .. debugstring)
self.obj.index[name](self, x, y)
end
function BaseWorld:newCollision(name, x, y, z, w, h, d)
print("Creating collision " .. name .. " at position " .. x .. ";" .. y .. ". Size is " .. w .. ";" .. h)
local debugstringpos = "at (" .. x .. ";" .. y .. ")"
local debugstringsize = "size is (" .. w .. ";" .. h .. ")"
local debugstring = " " .. debugstringpos .. ". " .. debugstringsize .. "."
core.debug:print("world2D", "creating collision " .. name .. debugstring)
self.obj.collisions[name](self, x, y, w, h)
end

View file

@ -47,7 +47,7 @@ end
function CameraSystem:setMode(mode)
self.mode = mode
print("Camera system mode set to " .. mode)
core.debug:print("camera", "mode is now set to " .. mode)
return mode
end

View file

@ -33,7 +33,8 @@ end
function StiMap:loadCollisions()
for k, objectlayer in pairs(self.sti.layers) do
if self.world:isCollisionIndexed(objectlayer.name) then
print("DEBUG: loading actors in " .. objectlayer.name .. " collision layer")
local debugstring = "loading " .. #objectlayer.objects .. " objects in " .. objectlayer.name .. " collision layer"
core.debug:print("map/sti", debugstring)
for k, object in pairs(objectlayer.objects) do
self:newCollision(objectlayer, object)
end
@ -45,7 +46,8 @@ end
function StiMap:loadActors()
for k, objectlayer in pairs(self.sti.layers) do
if self.world:isActorIndexed(objectlayer.name) then
print("DEBUG: loading actors in " .. objectlayer.name .. " actor layer")
local debugstring = "loading " .. #objectlayer.objects .. " objects in " .. objectlayer.name .. " actor layer"
core.debug:print("map/sti", debugstring)
for k, object in pairs(objectlayer.objects) do
if (object.properties.batchActor) then
self:batchActor(objectlayer, object)
@ -61,7 +63,8 @@ end
function StiMap:loadPlayers()
for k, objectlayer in pairs(self.sti.layers) do
if (objectlayer.name == "player") then
print("DEBUG: loading actors in player layer")
local debugstring = "loading at most " .. #objectlayer.objects .. " actors in " .. objectlayer.name .. " actor layer"
core.debug:print("map/sti", debugstring)
local i = 1
for k, object in pairs(objectlayer.objects) do
self:newPlayer(object, i)
@ -87,7 +90,6 @@ function StiMap:batchActor(objectlayer, object)
for i=1, cellHor do
for j=1, cellVert do
print("DEBUG:", "Setting the world to create actor " .. name)
self.world:newActor(name, x + (i-1)*gwidth, y + (j-1)*gheight, z)
end
end
@ -102,7 +104,6 @@ function StiMap:newActor(objectlayer, object)
y = y + z
end
print("DEBUG:", "Setting the world to create actor " .. objectlayer.name)
self.world:newActor(objectlayer.name, object.x, y, z)
end
@ -113,12 +114,12 @@ function StiMap:newCollision(objectlayer, object)
local y = object.y
if (fromTop) then
print("create from top, set z and y:", z, y, "=>", z-d, y+z)
local poschange = z .. ";" .. y .. " => " .. z-d .. ";" .. y+z
core.debug:print("map/sti", "create from top, set z and y: " .. poschange)
y = y + z
z = z - d
end
print("DEBUG:", "Setting the world to create collision " .. objectlayer.name)
self.world:newCollision(objectlayer.name, object.x, y, z, object.width, object.height, d)
end
@ -128,10 +129,10 @@ function StiMap:newPlayer(object, i)
local y = object.y
if (adaptPosition) then
core.debug:print("map/sti", "adapting position, set y: " .. y .. " => ", y+z)
y = y + z
end
print("DEBUG:", "Setting the world to create player " .. i)
self.world:addPlayer(object.x, y, z, i)
end

View file

@ -33,10 +33,10 @@ local TRANSLATION_PATH = "datas/languages/"
-- Initialize and configure the game options
function OptionsManager:new(controller)
self.controller = controller
-- We begin by creating an empty data table before reading the data.
self.data = {}
self:read()
self.controller = controller
end
function OptionsManager:reset()
@ -152,11 +152,11 @@ function OptionsManager:read()
filepath = self:getFile(true)
if utils.filesystem.exists("options.data") then
local loadedDatas = binser.readFile(filepath)
print("data file found, loading it")
self.controller.debug:print("core/options", "data file found, loading it")
self:setData(loadedDatas[1])
else
self:reset()
print("no data file found, reseting data")
self.controller.debug:print("core/options", "no data file found, reseting data")
end
end