CameraTextButton = class(CameraButton, function(o, x, y, w, h, text)
  CameraButton.init(o, x, y, w, h)
  o.text = StringObject(x, y, text)
  o.text:setScrollFactor(Vec2(1,1))
end)
function CameraTextButton:draw()
	CameraButton.draw(self)
	self.text:draw()
end
function CameraTextButton:setTextColor(r, g, b, a)
	self.text:setColor(r, g, b, a)
end
function CameraTextButton:setLayer(layer)
	CameraButton.setLayer(self, layer)
	self.text:setLayer(layer)
end
LockButton = class(Object, function(o, x, y)
	o.svg = SvgLoader(svg_root .. "interface/level_lock.svg", true)
	Object.init(o, x, y, 10, 10)
	o.drawType = 'svg'
end)
LevelButton = class(CameraButton, function(o,x,y,t)
	local w,h,p = 40*r_scale, 80*r_scale, 6*r_scale
	o.p = p
	CameraButton.init(o, x, y, w, h)
	o:setLayer(0)
	o:setColor(234,226,78,0)
	o.sprite = sprites['tiles']['white.png']
	o.drawType = 'stretched'
	
	o.completionBg = Object(x+p, y+w+p, w-p*2, h/2-p*2)
	o.completionBg:setColor(0,0,0)
	o.completionBg.drawType = 'stretched'
	o.completionBg.sprite = sprites['tiles']['white.png']
	
	o.lText = StringObject(0,y+p,t)
	o.lText:setColor(0,0,0)
	LevelSelectState.centerObject(o, o.lText, o)
end)
function LevelButton:setComplete()
	local p = 8*r_scale
	local size = self.completionBg.w-p*2
	self.completeObject = Object(self.completionBg.pos.x+p, self.completionBg.pos.y+self.completionBg.h-p-size, size, size)
	self.completeObject:setColor(234,226,78,255)
	self.completeObject.drawType = 'stretched'
	self.completeObject.sprite = sprites['tiles']['white.png']
end
function LevelButton:setAlpha(a)
	if self.colorTween then Tweener:removeTween(self.colorTween) end
	self.colorTween = Tweener:addTween(self.tint, {a=a}, {time=2})
end
function LevelButton:draw()
	Object.draw(self)
	self.completionBg:draw()
	if self.completeObject then self.completeObject:draw() end
	self.lText:draw()
end
function LevelButton:setPosition(x, y)
	Object.setPosition(self, x, y)
	if self.completionBg then
		self.completionBg:setPosition(self.pos.x+self.p, self.pos.y+self.p+self.h/2)
	end
	if self.completeObject then
		local p = 8*r_scale
		local size = self.completionBg.w-p*2
		self.completeObject:setPosition(self.completionBg.pos.x+p, self.completionBg.pos.y+self.completionBg.h-p-size)
	end
	if self.lText then
		self.lText:setPosition(self.pos.x+self.p, self.pos.y+self.p)
		LevelSelectState.centerObject(self, self.lText, self)
	end
end

