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

plop

git-svn-id: http://svn.net-core.org/repos/t-engine4@1713 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1a9ae590
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,10 @@ function _M:loadMap(file)
addSpot = function(dst, type, subtype)
self.spots[#self.spots+1] = {x=dst[1], y=dst[2], type=type or "static", subtype=subtype or "static"}
end,
addZone = function(dst, type, subtype)
self.level.custom_zones = self.level.custom_zones or {}
self.level.custom_zones[#self.level.custom_zones+1] = {x1=dst[1], y1=dst[2], x2=dst[3], y2=dst[4], type=type or "static", subtype=subtype or "static"}
end,
}
setfenv(f, setmetatable(g, {__index=_G}))
local ret, err = f()
......
......@@ -453,6 +453,27 @@ function _M:getPlayer()
return self.player
end
--- Update the zone name, if needed
function _M:updateZoneName()
local name
if self.zone.display_name then
name = self.zone.display_name()
else
local lev = self.level.level
if self.level.data.reverse_level_display then lev = 1 + self.level.data.max_level - lev end
name = ("%s (%d)"):format(self.zone.name, lev)
end
if self.zone_name_s and self.old_zone_name == name then return end
self.player_display.font:setStyle("bold")
local s = core.display.drawStringBlendedNewSurface(self.player_display.font, name, unpack(colors.simple(colors.GOLD)))
self.player_display.font:setStyle("normal")
self.zone_name_w, self.zone_name_h = s:getSize()
self.zone_name_s, self.zone_name_tw, self.zone_name_th = s:glTexture()
self.old_zone_name = name
print("Updating zone name", name)
end
function _M:tick()
if self.level then
self:targetOnTick()
......@@ -521,15 +542,7 @@ function _M:display()
if self.level.data.foreground then self.level.data.foreground(self.level, self.level.map.display_x, self.level.map.display_y) end
end
if not self.zone_name_s then
self.player_display.font:setStyle("bold")
local lev = self.level.level
if self.level.data.reverse_level_display then lev = 1 + self.level.data.max_level - lev end
local s = core.display.drawStringBlendedNewSurface(self.player_display.font, ("%s (%d)"):format(self.zone.name, lev), unpack(colors.simple(colors.GOLD)))
self.player_display.font:setStyle("normal")
self.zone_name_w, self.zone_name_h = s:getSize()
self.zone_name_s, self.zone_name_tw, self.zone_name_th = s:glTexture()
end
if not self.zone_name_s then self:updateZoneName() end
self.zone_name_s:toScreenFull(
self.level.map.display_x + self.level.map.viewport.width - self.zone_name_w,
self.level.map.display_y + self.level.map.viewport.height - self.zone_name_h,
......
......@@ -184,6 +184,9 @@ function _M:move(x, y, force)
game.state:worldDirectorAI()
end
-- Update zone name
if game.zone.variable_zone_name then game:updateZoneName() end
return moved
end
......
This diff is collapsed.
......@@ -18,7 +18,9 @@
-- darkgod@te4.org
return {
name = "Eyal",
name = "World of Eyal",
display_name = function() return game.level.map.attrs(game.player.x, game.player.y, "zonename") or "Eyal" end,
variable_zone_name = true,
level_range = {1, 1},
max_level = 1,
width = 170, height = 70,
......@@ -33,5 +35,14 @@ return {
class = "engine.generator.map.Static",
map = "wilderness/maj-eyal",
},
}
},
post_process = function(level)
for _, z in ipairs(level.custom_zones) do
if z.type == "zonename" then
for x = z.x1, z.x2 do for y = z.y1, z.y2 do
game.level.map.attrs(x, y, "zonename", z.subtype)
end end
end
end
end,
}
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