Tooltip = class(Object, function(o, x, y, text, confirm)
	-- placeholder in the width and height
	Object.init(o, x, y, bludG.camera.w*.75, bludG.camera.h/6)
	
	o.text = text

	-- determine the positioning of the main box
	o.arrow = sprites["tool_tip_arrow.png"]
	local margin = 25*r_scale
	o.padding = 20*r_scale
	o:calculateBox()
	o.confirm = confirm
	if o.confirm then
		o.okButton = Button(o.pos.x, o.pos.y,sprites["button_ok.png"]:getWidth(), sprites["button_ok.png"]:getHeight())
		o.okButton.layer = 4
	end
end)
function Tooltip:calculateBox()
	local camera = bludG.camera
	local cam = Camera(camera.pos.x*self.scrollFactor.x, camera.pos.y*self.scrollFactor.y, camera.w, camera.h)
    x, y = self:getCameraOffset(camera)
    self.above = false
	if x <= bludG.camera.w/2 then
		if y <= bludG.camera.h/2 then
			self.box = Object(cam.pos.x+self.padding, self.pos.y+self.arrow:getHeight(), self.w, self.h)
			self.above = true
		else
			self.box = Object(cam.pos.x+self.padding, self.pos.y-self.arrow:getHeight()-self.h, self.w, self.h)
		end
	else
		if y <= bludG.camera.h/2 then
			self.box = Object(cam.pos.x+cam.w-self.padding-self.w, self.pos.y+self.arrow:getHeight(), self.w, self.h)
			self.above = true
		else
			self.box = Object(self.pos.x+self.padding-self.w, self.pos.y-self.arrow:getHeight()-self.h, self.w, self.h)
		end
	end
	
	local lh = 25*r_scale

	-- change the height of the box based on the text contained within it
	-- tb:getHeight(self.bodyText, width-padding, sfontSize*2, true)
	self.h = tb:getHeight(self.text, self.box.w-self.padding*2, sfontSize*2) + self.padding
	if self.confirm then
		self.h = self.h + sprites["button_ok.png"]:getHeight()
	end
end
function Tooltip:update()
	self:calculateBox()
end
function Tooltip:draw()
	-- Tooltip.draw(self)
	local op = Vec2(self.pos.x, self.pos.y)

	local camera = bludG.camera
	-- set the position for the box based on the current camera
	local cam = Camera(camera.pos.x*self.scrollFactor.x, camera.pos.y*self.scrollFactor.y, camera.w, camera.h)
    _x, _y = self.box:getCameraOffset(cam)

	-- draw the main rectangle
	local tl = {_x, _y}
	local tr = {_x+self.box.w, _y}
	local bl = {_x, _y+self.box.h}
	local br = {_x+self.box.w, _y+self.box.h}
	sheet:addCornerTile(sprites["white.png"], tl[1],tl[2], tr[1],tr[2], br[1],br[2], bl[1],bl[2], 4, 239,238,233,255)
-- draw the drop shadow
	local h = 4*r_scale
	tl = {bl[1], bl[2]}
	tr = {br[1], br[2]}
	bl = {bl[1]+h/2, bl[2]+h}
	br = {br[1]-h/2, br[2]+h}
	sheet:addCornerTile(sprites["white.png"], tl[1],tl[2], tr[1],tr[2], br[1],br[2], bl[1],bl[2], 4, 188, 184, 172,255)

	-- draw the text
	local lh = 25*r_scale
	tb:addText(self.text, _x+self.padding, _y+self.padding*2, true, self.box.w-self.padding*2, lh);

	-- if we are on a confirmation style
	if self.confirm then
		self.pos.y = self.box.pos.y + self.box.h - sprites["button_ok.png"]:getHeight()-self.padding
		self.pos.x = self.box.pos.x + self.box.w/2 - sprites["button_ok.png"]:getWidth()/2
		
		self.okButton:setPosition(self.pos.x, self.pos.y)

		self.okButton.scrollFactor = self.scrollFactor
		self.sprite = sprites["button_ok.png"]
		self.layer = 4
		Object.draw(self)
	end

	-- reset the position back
	self:setPosition(op.x, op.y)

	-- draw the point
	self.sprite = self.arrow
	self.pos.y = self.pos.y + self.arrow:getHeight()/2
	self.rot = 0
	if not self.above then
		self.pos.y = self.pos.y - self.arrow:getHeight()
		self.rot = 180
	end

	local camera = bludG.camera
	-- set the position for the box based on the current camera
	local cam = Camera(camera.pos.x*self.scrollFactor.x, camera.pos.y*self.scrollFactor.y, camera.w, camera.h)
    local _x, _y = self:getCameraOffset(camera)

	sheet:addCenterRotatedTile(self.sprite, _x, _y, 4, flip, self.scale, self.rot, self.tint.r, self.tint.g, self.tint.b, self.tint.a)

	-- reset the position back
	self:setPosition(op.x, op.y)

end