local LevelDot = Object:extend()

function LevelDot:new(scene, levelname)
  self.scene = scene
  self.name  = levelname
  self.data = require("datas.levels." .. levelname)
  self.isActive = self.data.isActive or true

  self:register()
end

function LevelDot:register()
  self.scene:registerDot(self)
end

function LevelDot:draw()
  if (self.isActive) then
    local x, y =  16 + self.data.x * 16 + 4,
                  48 + self.data.y * 16 + 4
    self.scene.assets:drawImage("leveldot", x, y)
  end
end

function LevelDot:action()
  scenes.Levels(self.name, 0)
end

function LevelDot:drawName()
  local _, w, h = 0, core.screen:getDimensions()
  self.scene.assets.fonts["small"]:set()
  love.graphics.setColor(0, 0, 0, .6)
  love.graphics.rectangle("fill", 0, h-16, w, 13)
  utils.graphics.resetColor()
  love.graphics.printf(self.data.name, 0, h-18, w, "center")
end

return LevelDot
