resolutionOptions = {
	{"800x600", {800, 600}},
	{"1024x768", {1024, 768}},
	{"1600x1200", {1600, 1200}}
}
fullscreen = {
	{"yes", true},
	{"no", false}
}
SettingState = class(Group, function(o, lastState, noScroll)
	Group.init(o)
	o.lastState = o:add(lastState)
	o.noScroll = noScroll
	o.currentResolution = player.resolution
	o:setup()
end)
function SettingState:setup()
	-- button to select resolution
	self.sky = self:add(GradientObject(0,bludG.camera.h,bludG.camera.w, bludG.camera.h, bludColor(0,0,0, 255), bludColor(0,0,0, 255)))
	self.sky:setScrollFactor(Vec2(1,1))
	self.penPosition = 20*r_scale

	self:addSelector("Windowed Resolution", resolutionOptions, "resolution", function()
		if not fullscreen[player["fullscreen"]+1][2] then
			bg:setWindowShape(resolutionOptions[player["resolution"]+1][2][1], resolutionOptions[player["resolution"]+1][2][2])
		end
		buildScreenInfo()
		-- rebuild this screen
		mainState = WrapperState(Group());
		mainState:changeState(SettingState(self.lastState, true))

	end)
	-- button to switch between fullscreen and windowed
	self:addSelector("Full Screen", fullscreen, "fullscreen", function()
		bg:setFullscreen(fullscreen[player["fullscreen"]+1][2])
		-- rebuild this screen
		-- need to do this on a coroutine so that it happens after the screen has been reset
		local fixGraphics = function()
			coroutine.yield()
			buildScreenInfo()
			mainState = WrapperState(Group());
			mainState:changeState(SettingState(self.lastState, true))		
		end
		table.insert(runningCoroutines, coroutine.create(fixGraphics))
	end)
	WorldSelectState.addBackButton(self)
	-- slider to set volume
	-- transition the camera up to view this screen
	if self.noScroll then
		bludG.camera.scroll.y = bludG.camera.h
	else
		self.camTween = Tweener:addTween(bludG.camera.scroll, {x=0, y=bludG.camera.h}, {time=.75, func='outSine', onComplete=function()
		end})
	end
	-- display all the achievement states
	currentScore = 5
end
function SettingState:addSelector(titleString, optionGroup, paramName, onchange)
	local cworld = player.currentWorld

	-- add a label
	local title = self:add(StringObject(0,self.penPosition+25*r_scale+bludG.camera.h,titleString, nil, 0.6))
	title:setColor(255,255,255)
	LevelSelectState.centerObject(self, title)
	self.penPosition = self.penPosition+30*r_scale
	
	local currentOption = self:add(StringObject(0,self.penPosition+25*r_scale+bludG.camera.h,optionGroup[player[paramName]+1][1], nil, 0.6))
	currentOption:setColor(255,255,255)
	LevelSelectState.centerObject(self, currentOption)

	-- get the distance between the border and the center of the screen (subtracting the hotel width)
	local leftSide = bludG.camera.w/4
	local pb = self:add(FancyButton(leftSide, self.penPosition+bludG.camera.h, "", "button_back"))
	pb.pos.x = pb.pos.x - pb.svg:getMaxX()/2
	pb.w = pb.svg:getMaxX()
	pb:setColor(cworld.bottom_color[1], cworld.bottom_color[2], cworld.bottom_color[3])
	pb:setScrollFactor(Vec2(1,1))

	local nb = self:add(FancyButton(bludG.camera.w/4*2.75, self.penPosition+bludG.camera.h, "", "button_back"))
	nb.svg:translate(-nb.svg:getMaxX(), 0)
	nb.svg:scale(-1, 1)
	nb.svg:storeTransform()
	nb:setColor(cworld.bottom_color[1], cworld.bottom_color[2], cworld.bottom_color[3])
	nb:setScrollFactor(Vec2(1,1))
	pb.onPress = function()
		player[paramName] = (player[paramName]-1)
		if player[paramName]<0 then
			player[paramName] = #optionGroup-1
		end
		currentOption:setValue(optionGroup[player[paramName]+1][1])
		onchange()
	end
	nb.onPress = function()
		player[paramName] = (player[paramName]+1)%#optionGroup
		currentOption:setValue(optionGroup[player[paramName]+1][1])
		onchange()
	end
	self.penPosition = self.penPosition+50*r_scale
end
function SettingState:buttonback_callback()
	self:remove(self.backButton)
	Tweener:removeTween(self.camTween)
	mainState:changeState(TitleScreenState(self))
end