Skip to content
Snippets Groups Projects
Commit 2c239d20 authored by dg's avatar dg
Browse files

color item names in the log

only color objects when known


git-svn-id: http://svn.net-core.org/repos/t-engine4@401 51575b47-30f0-44d4-a5cc-537603b46e54
parent cae2d646
No related branches found
No related tags found
No related merge requests found
......@@ -117,14 +117,16 @@ function _M:resolve(t, last)
end
-- Finish resolving stuff
if t == self and last then
-- Handle ided if possible
if self.resolveIdentify then self:resolveIdentify() end
if t == self then
if last then
if self.resolveLevel then self:resolveLevel() end
if self.resolveLevel then self:resolveLevel() end
if self.unique and type(self.unique) == "boolean" then
self.unique = self.name
if self.unique and type(self.unique) == "boolean" then
self.unique = self.name
end
else
-- Handle ided if possible
if self.resolveIdentify then self:resolveIdentify() end
end
end
end
......
......@@ -95,9 +95,9 @@ function _M:pickupFloor(i, vocal)
game.level.map:removeObject(self.x, self.y, i)
o:check("on_pickup", self)
if vocal then game.logSeen(self, "%s picks up: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s picks up: %s.", self.name:capitalize(), o:getName{do_color=true}) end
elseif not prepickup then
if vocal then game.logSeen(self, "%s has no room for: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s has no room for: %s.", self.name:capitalize(), o:getName{do_color=true}) end
end
else
if vocal then game.logSeen(self, "There is nothing to pickup there.") end
......@@ -146,7 +146,7 @@ function _M:dropFloor(inven, item, vocal, all)
end
if o:check("on_drop", self) then return end
game.level.map:addObject(self.x, self.y, o)
if vocal then game.logSeen(self, "%s drops on the floor: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s drops on the floor: %s.", self.name:capitalize(), o:getName{do_color=true}) end
end
--- Show inventory dialog
......@@ -223,26 +223,26 @@ end
function _M:wearObject(o, replace, vocal)
local inven = o:wornInven()
if not inven then
if vocal then game.logSeen(self, "%s is not wearable.", o:getName()) end
if vocal then game.logSeen(self, "%s is not wearable.", o:getName{do_color=true}) end
return false
end
local ok, err = self:canWearObject(o)
if not ok then
if vocal then game.logSeen(self, "%s can not wear: %s (%s).", self.name:capitalize(), o:getName(), err) end
if vocal then game.logSeen(self, "%s can not wear: %s (%s).", self.name:capitalize(), o:getName{do_color=true}, err) end
return false
end
if self:addObject(inven, o) then
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) end
return true
elseif o.offslot and self:getInven(o.offslot) and #(self:getInven(o.offslot)) < self:getInven(o.offslot).max then
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) end
-- Warning: assume there is now space
self:addObject(self:getInven(o.offslot), o)
elseif replace then
local ro = self:removeObject(inven, 1, true)
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) end
-- Can we stack the old and new one ?
if o:stack(ro) then ro = true end
......@@ -251,7 +251,7 @@ function _M:wearObject(o, replace, vocal)
self:addObject(inven, o)
return ro
else
if vocal then game.logSeen(self, "%s can not wear: %s.", self.name:capitalize(), o:getName()) end
if vocal then game.logSeen(self, "%s can not wear: %s.", self.name:capitalize(), o:getName{do_color=true}) end
return false
end
end
......
......@@ -190,13 +190,20 @@ getmetatable(tmps).__index.drawColorString = function(s, font, str, x, y, r, g,
r = r or 255
g = g or 255
b = b or 255
local oldr, oldg, oldb = r, g, b
for i, v in ipairs(list) do
local _, _, nr, ng, nb = v:find("^#(%x%x)(%x%x)(%x%x)#")
local _, _, col = v:find("^#([A-Z_]+)#")
if nr and ng and nb then
oldr, oldg, oldb = r, g, b
r, g, b = nr:parseHex(), ng:parseHex(), nb:parseHex()
elseif col then
r, g, b = colors[col].r, colors[col].g, colors[col].b
if col == "LAST" then
r, g, b = oldr, oldg, oldb
else
oldr, oldg, oldb = r, g, b
r, g, b = colors[col].r, colors[col].g, colors[col].b
end
else
local w, h = font:size(v)
s:drawString(font, v, x, y, r, g, b)
......
......@@ -78,9 +78,10 @@ end
--- Gets the color in which to display the object in lists
function _M:getDisplayColor()
if self.egoed then return {0, 255, 128}
elseif self.unique then return {255, 255, 0}
else return {255, 255, 255}
if not self:isIdentified() then return {255, 255, 255}, "#FFFFFF#" end
if self.egoed then return {0, 255, 128}, "#00FF80#"
elseif self.unique then return {255, 255, 0}, "#FFFF00#"
else return {255, 255, 255}, "#FFFFFF#"
end
end
......@@ -103,19 +104,21 @@ function _M:getName(t)
end)
end
if qty == 1 or t.no_count then
return name
if not t.do_color then
if qty == 1 or t.no_count then return name
else return qty.." "..name
end
else
return qty.." "..name
local _, c = self:getDisplayColor()
if qty == 1 or t.no_count then return c..name.."#LAST#"
else return c..qty.." "..name.."#LAST#"
end
end
end
--- Gets the full desc of the object
function _M:getDesc()
local c = ""
if self.egoed then c = "#00FF80#"
elseif self.unique then c = "#FFFF00#"
end
local _, c = self:getDisplayColor()
local desc = { c..self:getName().."#FFFFFF#", self.desc }
local reqs = self:getRequirementDesc(game.player)
......
......@@ -70,7 +70,7 @@ function _M:move(x, y, force)
if obj and game.level.map:getObject(self.x, self.y, 2) then
game.logSeen(self, "There is more than one objects lying here.")
elseif obj then
game.logSeen(self, "There is an item here: "..obj:getName())
game.logSeen(self, "There is an item here: %s", obj:getName{do_color=true})
end
end
......@@ -275,7 +275,7 @@ function _M:playerUseItem(object, item)
o.multicharge = o.multicharge - 1
else
self:removeObject(self:getInven(self.INVEN_INVEN), item)
game.log("You have no more "..o:getName{no_count=true})
game.log("You have no more %s", o:getName{no_count=true, do_color=true})
self:sortInven()
end
end
......
......@@ -10,11 +10,11 @@ newEntity{
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
drops = resolvers.drops{chance=70, nb=1, {type="money"}, {} },
autolevel = "ghoul",
ai = "dumb_talented_simple", ai_state = { talent_in=4, },
ai = "dumb_talented_simple", ai_state = { talent_in=2, },
energy = { mod=1 },
stats = { str=14, dex=12, mag=10, con=12 },
tmasteries = resolvers.tmasteries{ ["technique/other"]=0.3, },
tmasteries = resolvers.tmasteries{ ["technique/other"]=1, },
blind_immune = 1,
see_invisible = 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment