require("util")
require("screen")
require("button")
require("animbutton")
require("image")
require("uianim")
require("spinner")
require("numericspinner")
require("screens/popupdialog")

require("screens/keyscreen")

-- TODO: clean up this entire file..

local spinner_images = {
	arrow_normal = "data/images/spin_arrow.tex",
	arrow_over = "data/images/spin_arrow_over.tex",
	arrow_disabled = "data/images/spin_arrow_disabled.tex",
	bgtexture = "data/images/spinner.tex"
}

local text_font = DEFAULTFONT

local enableDisableOptions = { { text = "关闭", data = false }, { text = "开启", data = true } }

local entityOptions = {
--{text = "Krampus 2", data = "krampus2"},
	{text = "阿比盖尔", data = "abigail"},
	{text = "小皮弗娄牛 ", data = "babybeefalo"},
	{text = "蜜蜂", data = "bee"},
	{text = "皮弗娄牛", data = "beefalo"},
	{text = "蓝色猎狗", data = "icehound"},
	{text = "蝴蝶", data = "butterfly"},
	{text = "切斯特", data = "chester"},
	{text = "发条主教", data = "bishop"},
	{text = "发条骑士", data = "knight"},
	{text = "爬行恐懼", data = "crawlinghorror"},
	{text = "乌鸦", data = "crow"},
	{text = "独眼巨鹿", data = "deerclops"},
	{text = "红色猎狗", data = "firehound"},
	{text = "青蛙", data = "frog"},
	{text = "鬼魂", data = "ghost"},
	{text = "雄火鸡", data = "perd"},
	{text = "猎犬", data = "hound"},
	{text = "杀人蜂", data = "killerbee"},
	{text = "坎普斯", data = "krampus"},
	{text = "海象", data = "walrus"},
	{text = "曼德拉草", data = "mandrake"},
	{text = "鱼人", data = "merm"},
	{text = "蚊子", data = "mosquito"},
	{text = "企鹅", data = "penguin"},
	{text = "安特米乌斯", data = "pigguard"},
	{text = "猪人国王", data = "pigking"},
	{text = "格雷汉姆", data = "pigman"},
	{text = "兔子", data = "rabbit"},
	{text = "红雀", data = "robin"},
	{text = "尖喙恐懼", data = "shadowskittish"},
	{text = "小高脚鸟", data = "smallbird"},
	{text = "蜘蛛 ", data = "spider"},
	{text = "蜘蛛女王", data = "spiderqueen"},
	{text = "蜘蛛战士 ", data = "spider_warrior"},
	{text = "红色象鼻怪", data = "koalefant_summer"},
	{text = "高脚鸟", data = "tallbird"},
	{text = "青年高脚鸟", data = "teenbird"},
	{text = "触手怪", data = "tentacle"},
	{text = "尖喙恐懼", data = "terrorbeak"},
	{text = "树精守卫", data = "leif"},
	{text = "麥斯威爾", data = "waxwell"},
	{text = "小海象", data = "little_walrus"},
	{text = "蓝色象鼻怪", data = "koalefant_winter"},
	{text = "雪雀", data = "robin_winter"},
}

local uncraftableItemOptions = { 
	{text = "灰烬", data = "ash"},
	{text = "胡须", data = "beardhair"},
	{text = "蜜蜂", data = "bee"},
	{text = "野牛角", data = "horn"},
	{text = "野牛毛", data = "beefalowool"},
	{text = "蓝宝石", data = "bluegem"},
	{text = "蝴蝶", data = "butterfly"},
	{text = "木炭", data = "charcoal"},
	{text = "切斯特眼骨", data = "chester_eyebone"},
	{text = "乌鸦羽毛", data = "feather_crow"},
	{text = "割下的草", data = "cutgrass"},
	{text = "割好的芦苇", data = "cutreeds"},
	{text = "鹿角怪的眼球", data = "deerclops_eyeball"},
	{text = "魔杖", data = "diviningrod"},
	{text = "浆果灌木丛", data = "dug_berrybush"},
	{text = "浆果灌木丛 2", data = "dug_berrybush2"},
	{text = "长草丛", data = "dug_grass"},
	{text = "树苗", data = "dug_sapling"},
	{text = "萤火虫", data = "fireflies"},
	{text = "燧石", data = "flint"},
	{text = "齿轮", data = "gears"},
	{text = "金块", data = "goldnugget"},
	{text = "蜂巢", data = "honeycomb"},
	{text = "犬牙", data = "houndstooth"},
	{text = "坎普斯背包", data = "krampus_sack"},
	{text = "有生命的木材", data = "livinglog"},
	{text = "木材", data = "log"},
	{text = "大理石", data = "marble"},
	{text = "便便", data = "poop"},
	{text = "噩梦燃料", data = "nightmarefuel"},
	{text = "硝石", data = "nitre"},
	{text = "猪皮", data = "pigskin"},
	{text = "松果", data = "pinecone"},
	{text = "红宝石", data = "redgem"},
	{text = "红雀羽毛", data = "feather_robin"},
	{text = "岩石", data = "rocks"},
	{text = "丝线 ", data = "silk"},
	{text = "蜘蛛卵", data = "spidereggsack"},
	{text = "蜘蛛腺体", data = "spidergland"},
	{text = "蜘蛛帽", data = "spiderhat"},
	{text = "蜂刺", data = "stinger"},
	{text = "红色象鼻", data = "trunk_summer"},
	{text = "海象帽", data = "walrushat"},
	{text = "狼牙棒", data = "tentaclespike"},
	{text = "斑点触手皮", data = "tentaclespots"},
	{text = "森林草皮", data = "turf_forest"},
	{text = "长草草皮", data = "turf_grass"},
	{text = "沼泽草皮", data = "turf_marsh"},
	{text = "岩石草皮", data = "turf_rocky"},
	{text = "热带草原草皮", data = "turf_savanna"},
	{text = "小树枝", data = "twigs"},
	{text = "海象长牙", data = "walrus_tusk"},
	{text = "蓝色象鼻", data = "trunk_winter"},
	{text = "雪雀羽毛", data = "feather_robin_winter"},
	{text = "影子钥匙", data = "maxwellkey"},
	{text = "噩梦锁头", data = "maxwelllock"},
}

local foodItemOptions = {
	{text = "鸡蛋火腿", data = "baconeggs"},
	{text = "浆果", data = "berries"},
	{text = "蓝菇头", data = "blue_cap"},
	{text = "红烧茄子", data = "eggplant_cooked"},
	{text = "奶油松饼", data = "butterflymuffin"},
	{text = "蝴蝶翅膀", data = "butterflywings"},
	{text = "蝴蝶黄油", data = "butter"},
	{text = "萝卜坑", data = "carrot"},
	{text = "精致火龙果", data = "dragonfruit_cooked"},
	{text = "超臭榴莲", data = "durian_cooked"},
	{text = "熟鱼", data = "fish_cooked"},
	{text = "熟青蛙腿", data = "froglegs_cooked"},
	{text = "熟怪兽肉", data = "cookedmonstermeat"},
	{text = "熟曼德拉草", data = "cookedmandrake"},
	{text = "熟肉", data = "cookedmeat"},
	{text = "熟肉块", data = "cookedsmallmeat"},
	{text = "玉米", data = "corn"},
	{text = "恶魔花瓣", data = "petals_evil"},
	{text = "致命盛宴", data = "deadlyfeast"},
	{text = "火龙果", data = "dragonfruit"},
	{text = "龙馅饼", data = "dragonpie"},
	{text = "鸡腿", data = "drumstick"},
	{text = "榴莲", data = "durian"},
	{text = "茄子", data = "eggplant"},
	{text = "鱼", data = "fish"},
	{text = "鱼肉条", data = "fishsticks"},
	{text = "玉米饼包炸鱼", data = "fishtacos"},
	{text = "炸鸡腿", data = "drumstick_cooked"},
	{text = "油煎高脚鸡蛋", data = "tallbirdegg_cooked"},
	{text = "青蛙腿", data = "froglegs"},
	{text = "青蛙圆面包三明治", data = "frogglebunwich"},
	{text = "水果拼盘", data = "fruitmedley"},
	{text = "绿菇头", data = "green_cap"},
	{text = "蜂蜜", data = "honey"},
	{text = "蜜汁火腿", data = "honeyham"},
	{text = "蜜汁金砖", data = "honeynuggets"},
	{text = "果酱蜜酱", data = "jammypreserves"},
	{text = "烤熟象鼻", data = "trunk_cooked"},
	{text = "肉串", data = "kabobs"},
	{text = "曼德拉草", data = "mandrake"},
	{text = "曼德拉草汤", data = "mandrakesoup"},
	{text = "肉", data = "meat"},
	{text = "肉丸", data = "meatballs"},
	{text = "肉汤", data = "bonestew"},
	{text = "怪物千层饼", data = "monsterlasagna"},
	{text = "怪物肉", data = "monstermeat"},
	{text = "小肉块", data = "smallmeat"},
	{text = "花瓣", data = "petals"},
	{text = "半圆小酥饼", data = "perogies"},
	{text = "石榴", data = "pomegranate"},
	{text = "爆米花", data = "corn_cooked"},
	{text = "南瓜", data = "pumpkin"},
	{text = "南瓜饼", data = "pumpkincookie"},
	{text = "脚的燧菜", data = "ratatouille"},
	{text = "红菇头", data = "red_cap"},
	{text = "热燧浆果", data = "berries_cooked"},
	{text = "烤胡萝卜", data = "carrot_cooked"},
	{text = "腐烂食物", data = "spoiled_food"},
	{text = "烂鸡蛋", data = "rottenegg"},
	{text = "种子", data = "seeds"},
	{text = "石榴片", data = "pomegranate_cooked"},
	{text = "香酥茄盒", data = "stuffedeggplant"},
	{text = "太糖", data = "taffy"},
	{text = "高脚鸡蛋", data = "tallbirdegg"},
	{text = "烤种子", data = "seeds_cooked"},
	{text = "火鸡正餐", data = "turkeydinner"},
	{text = "华夫饼", data = "waffles"},
	{text = "湿腻焦糊", data = "wetgoop"},
}

local objectOptions = {
	{text = "玄武岩", data = "basalt"},
	{text = "玄武岩柱子", data = "basalt_pillar"},
	{text = "蜂窝", data = "beehive"},
	{text = "蜜蜂地雷", data = "beemine"},
	{text = "捕鸟器", data = "birdtrap"},
	{text = "萤火虫", data = "fireflies"},
	{text = "鲜花", data = "flower"},
	{text = "干草", data = "grass"},
	{text = "墓碑石", data = "gravestone"},
	{text = "竖琴雕像", data = "statueharp"},
	{text = "猎狗巢", data = "houndmound"},
	{text = "杀人蜂巢", data = "wasphive"},
	{text = "松树大", data = "evergreen_sparse_normal"},
	{text = "松树中", data = "evergreen_sparse_short"},
	{text = "松树小", data = "evergreen_sparse_tall"},
	{text = "西斯", data = "lockedwes"},
	{text = "大理石柱", data = "marblepillar"},
	{text = "大理石树", data = "marbletree"},
	{text = "刺灌木", data = "marsh_bush"},
	{text = "种植", data = "marsh_plant"},
	{text = "针木", data = "marsh_tree"},
	{text = "麦克西斯", data = "maxwellendgame"},
	{text = "麦克西斯的雕像", data = "statuemaxwell"},
	{text = "坐着的麦克西斯", data = "maxwellthrone"},
	{text = "麦克西斯的牙牙陷阱", data = "trap_teeth_maxwell"},
	{text = "麦克西斯之门", data = "adventure_portal"},
	{text = "麦克西斯的头", data = "maxwellhead"},
	{text = "麦克西斯的光", data = "maxwelllight"},
	{text = "麦克西斯的留声机", data = "maxwellphonograph"},
	{text = "鱼人脑袋", data = "mermhead"},
	{text = "鱼人废墟", data = "mermhouse"},
	{text = "墓穴", data = "mound"},
	{text = "蓝蘑菇苗", data = "blue_mushroom"},
	{text = "绿蘑菇苗", data = "green_mushroom"},
	{text = "红蘑菇", data = "red_mushroom"},
	{text = "方尖塔", data = "sanityrock"},
	{text = "方尖碑", data = "insanityrock"},
	{text = "猪头", data = "pighead"},
	{text = "猪舍", data = "pighouse"},
	{text = "猪猪火炬", data = "pigtorch"},
	{text = "胡萝卜", data = "carrot_planted"},
	{text = "池塘1", data = "pond"},
	{text = "池塘2", data = "pond_mos"},
	{text = "兔子窝", data = "rabbithole"},
	{text = "芦苇", data = "reeds"},
	{text = "树苗", data = "sapling"},
	{text = "虫洞1", data = "wormhole_limited_1"},
	{text = "骨架", data = "skeleton"},
	{text = "蜘蛛巢", data = "spiderden"},
	{text = "高脚鸡巢穴", data = "tallbirdnest"},
	{text = "像木头的东西", data = "teleportato_base"},
	{text = "像盒子的东西", data = "teleportato_box"},
	{text = "像曲柄的东西", data = "teleportato_crank"},
	{text = "组装好的架子", data = "teleportato_checkmate"},
	{text = "像铁蛋子一样的东西", data = "teleportato_potato"},
	{text = "像圆环一样的东西", data = "teleportato_ring"},
	{text = "犬牙陷阱", data = "trap_teeth"},
	{text = "复活石", data = "resurrectionstone"},
	{text = "干草墙", data = "wall_hay"},
	{text = "石墙", data = "wall_stone"},
	{text = "木墙", data = "wall_wood"},
	{text = "海象营地", data = "walrus_camp"},
	{text = "虫洞2", data = "wormhole"},
}
local spinnerFont = {font = text_font, size = 30}
local spinnerHeight = 64

TestScreen = Class(Screen, function(self, displayed)
	Screen._ctor(self, "TestScreen")

	--TheFrontEnd:DoFadeIn(2)

	local graphicsOptions = TheFrontEnd:GetGraphicsOptions()

	self.options = {
		entityPrefab = nil,
		itemPrefab = nil,
		foodPrefab = nil,
		objectPrefab = nil,
	}

	local indexTable = {}

	indexTable = self:RetrieveIndices()

	self.entityIndex = indexTable[1] or 1
	self.itemIndex = indexTable[2] or 1
	self.foodIndex = indexTable[3] or 1
	self.speedIndex = indexTable[4] or 1
	self.objectIndex = indexTable[5] or 1

	self.displayed = displayed
	self.working = deepcopy(self.options)

	self:DoInit()
	self:InitializeSpinners()
end)

-- relocate
function string.starts(String,Start)
	Start = string.upper(Start)
	return string.sub(String,1,string.len(Start)) == Start
end

function TestScreen:OnTextInput(text)
	local spinner = self:GetActiveFocusWidget()
	
	local index = 1

	for k,v in pairs(spinner.options) do
		if string.starts(v.text, text) then
			spinner:SetSelectedIndex(index)
			break
		end	
		
		index = index + 1
	end
end

function TestScreen:OnKeyUp(key)
	if key == KEY_ESCAPE then
		self:Close()
	end
end

function TestScreen:OnKeyDown(key)
	if (key == KEY_TAB) and not TheInput:IsKeyDown(KEY_ALT) then
		self:AdvanceFocus( not TheInput:IsKeyDown(KEY_SHIFT) )
	end
end

function TestScreen:Accept()
	self:Save(function()
	self:Close()
	end)
end

function TestScreen:Save(cb)
	self.options = deepcopy(self.working)
	Profile:Save(function()
	if cb then
	  cb()
	end
	end)
end

function TestScreen:Close()
	TheSim:SetSetting("TEST_TOOLS", "entityIndex", self.entitySpinner:GetSelectedIndex())
	TheSim:SetSetting("TEST_TOOLS", "itemIndex", self.itemSpinner:GetSelectedIndex())
	TheSim:SetSetting("TEST_TOOLS", "foodIndex", self.foodSpinner:GetSelectedIndex())
	TheSim:SetSetting("TEST_TOOLS", "speedIndex", self.speedSpinner:GetSelectedIndex())
	TheSim:SetSetting("TEST_TOOLS", "objectIndex", self.objectSpinner:GetSelectedIndex())

	TheFrontEnd:PopScreen(self)
	self.displayed = false
	SetHUDPause(false)
end

function TestScreen:RetrieveIndices()
	local values = {}

	table.insert(values, TheSim:GetSetting("TEST_TOOLS", "entityIndex") or 1)
	table.insert(values, TheSim:GetSetting("TEST_TOOLS", "itemIndex") or 1)
	table.insert(values, TheSim:GetSetting("TEST_TOOLS", "foodIndex") or 1)
	table.insert(values, TheSim:GetSetting("TEST_TOOLS", "speedIndex") or 1)
	table.insert(values, TheSim:GetSetting("TEST_TOOLS", "objectIndex") or 1)

	return values
end

local MakeMenu = function(offset, menuitems)
	local menu = Widget("OptionsMenu")
	local pos = Vector3(0, 0, 0)
	
	for k, v in ipairs(menuitems) do
		local button = menu:AddChild(AnimButton("button"))
		button:SetPosition(pos)
		button:SetText(v.text)
		button.text:SetColour(0, 0, 0, 1)
		button:SetOnClick(v.cb)
		button:SetFont(BUTTONFONT)
		button:SetTextSize(40)
		pos = pos + offset
	end
	
	return menu
end


function TestScreen:AddSpinners(data, user_offset, bg_size)
	local master_group = self:AddChild(Widget("SpinnerGroup"))
	master_group:SetVAnchor(ANCHOR_TOP)
	
	local offset = {0, 0, 0}
	if user_offset then
		offset[1] = offset[1] + user_offset[1]
		offset[2] = offset[2] + user_offset[2]
		offset[3] = offset[3] + user_offset[3]
	end
	
	master_group:SetPosition(offset[1] + 360, offset[2] + -230, offset[2] + 0)
	
	local label_width = 200
	
	for idx, entry in ipairs(data) do
		local text = entry[1]
		local spinner = entry[2]
		local group = master_group:AddChild(Widget("SpinnerGroup"))
		group:SetPosition(0, (idx - 1) * -75 + 25, 0)
		local label = group:AddChild(Text(DEFAULTFONT, 30, text))
		label:SetPosition(0.5 * label_width, 0, 0)
		label:SetRegionSize(label_width, 50)
		label:SetHAlign(ANCHOR_RIGHT)
		group:AddChild(spinner)
		spinner:SetPosition(label_width + 32, 0, 0)
		spinner:SetWrapEnabled(true)
		spinner:SetLeftMouseDown(function() self:SetFocus(spinner) end)
	end
	
	return master_group
end

function TestScreen:DoInit()
    self.bg = self:AddChild(Image("data/images/bg_red.tex"))
    self.bg:SetVRegPoint(ANCHOR_MIDDLE)
    self.bg:SetHRegPoint(ANCHOR_MIDDLE)
    self.bg:SetVAnchor(ANCHOR_MIDDLE)
    self.bg:SetHAnchor(ANCHOR_MIDDLE)
    self.bg:SetScaleMode(SCALEMODE_FILLSCREEN)
    
	self.root = self:AddChild(Widget("ROOT"))
    self.root:SetVAnchor(ANCHOR_MIDDLE)
    self.root:SetHAnchor(ANCHOR_MIDDLE)
    self.root:SetPosition(0,0,0)
    self.root:SetScaleMode(SCALEMODE_PROPORTIONAL)
    
	local shield = self.root:AddChild( Image( "data/images/panel.tex" ) )
	shield:SetPosition( 0,0,0 )
	shield:SetSize( 1000, 700 )	
	
	local menu_items = {
		{ text = "使用说明", cb = function() TheFrontEnd:PushScreen(KeyScreen({ {text="上一页", cb = function() end}})) end },	
		{ text = "返回游戏", cb = function() self:Accept() end }
	}
	
	if self.menu then
		self.menu:Kill()
	end
	
	local menu_spacing = 60
	local bottom_offset = 70
	local this = self

	self.entitySpinner = Spinner(entityOptions, 180, spinnerHeight, spinnerFont, spinner_images)
	  function self.entitySpinner:OnChanged(data)
			this.working.entityPrefab = data
			this:UpdateSelectedEntity()
	  end

	self.itemSpinner = Spinner(uncraftableItemOptions, 180, spinnerHeight, spinnerFont, spinner_images)
	  function self.itemSpinner:OnChanged(data)
			this.working.itemPrefab = data
			this:UpdateSelectedItem()
	  end

	self.foodSpinner = Spinner(foodItemOptions, 180, spinnerHeight, spinnerFont, spinner_images)
		function self.foodSpinner:OnChanged(data)
			this.working.foodPrefab = data
			this:UpdateSelectedFood()
		end
		
	self.objectSpinner = Spinner(objectOptions, 180, spinnerHeight, spinnerFont, spinner_images)
		function self.objectSpinner:OnChanged(data)
			this.working.objectPrefab = data
			this:UpdateSelectedObject()
		end

	self.speedSpinner = NumericSpinner( 2, 10, 50, spinnerHeight, spinnerFont, spinner_images )
	self.speedSpinner.OnChanged =
		function( self, data )
			this:UpdateSpeedMultiplier()
		end 
		
	self.godmodeSpinner = Spinner(enableDisableOptions, 100, spinnerHeight, spinnerFont, spinner_images)
		function self.godmodeSpinner:OnChanged(data)
			this:UpdateGodMode()
		end

	local spawning_spinners = {}
	local option_spinners = {}
	local toggle_spinners = {}

	local spawn_pos, option_pos, toggle_pos, bg_pos, bg_size

	table.insert(spawning_spinners, { "怪物:", self.entitySpinner })
	table.insert(spawning_spinners, { "道具:", self.itemSpinner })
	table.insert(spawning_spinners, { "食物:", self.foodSpinner })
	table.insert(spawning_spinners, { "物品:", self.objectSpinner })

	table.insert(toggle_spinners, { "上帝模式:", self.godmodeSpinner })

	table.insert(option_spinners, { "速度提升:", self.speedSpinner })

	spawn_pos = { -225, 0, 0}
	option_pos = { 300, -75, 0}
	toggle_pos = {225,0,0}
	bg_pos = {640, 360,0}
	bg_size = {1000, 700}

--	local bg = self:AddChild(Image("data/images/panel.tex"))
--	bg:SetPosition(bg_pos[1], bg_pos[2], bg_pos[3])
--	bg:SetSize(bg_size[1], bg_size[2])

	local spawn_group = self:AddSpinners(spawning_spinners, spawn_pos)
	local option_group = self:AddSpinners(option_spinners, option_pos)
	local toggle_group = self:AddSpinners(toggle_spinners, toggle_pos)
	
	self:PushFocusWidget(self.entitySpinner)
	self:PushFocusWidget(self.itemSpinner)
	self:PushFocusWidget(self.foodSpinner)
	self:PushFocusWidget(self.objectSpinner)

	self.soundmenu = self:AddChild(MakeMenu(Vector3(0, -menu_spacing, 0), menu_items))
	self.soundmenu:SetHAnchor(ANCHOR_MIDDLE)
	self.soundmenu:SetPosition(400, bottom_offset + menu_spacing * (#menu_items - 1), 0)
end

local EnabledOptionsIndex = function(enabled)
	if enabled then
		return 2
	else
		return 1
	end
end

local function GodModeIndex()
	if GetPlayer().components.health:IsInvincible() then
		return 2
	else
		return 1
	end
end

function TestScreen:UpdateSelectedEntity()
	if self.entitySpinner:GetSelected().data then
		GetPlayer().components.testtoolcontroller.entityPrefab = self.entitySpinner:GetSelectedData()
	end
end

function TestScreen:UpdateSelectedItem()
	if self.itemSpinner:GetSelected().data then
		GetPlayer().components.testtoolcontroller.itemPrefab = self.itemSpinner:GetSelectedData()
	end
end

function TestScreen:UpdateSelectedFood()
	if self.foodSpinner:GetSelected().data then
		GetPlayer().components.testtoolcontroller.foodPrefab = self.foodSpinner:GetSelectedData()
	end
end

function TestScreen:UpdateSelectedObject()
	if self.objectSpinner:GetSelected().data then
		GetPlayer().components.testtoolcontroller.objectPrefab = self.objectSpinner:GetSelectedData()
	end
end

function TestScreen:UpdateSpeedMultiplier()
	if self.speedSpinner:GetSelected() then
		GetPlayer().components.testtoolcontroller.speed_multiplier = self.speedSpinner:GetSelectedData()
	end
end

function TestScreen:UpdateGodMode()
	if self.godmodeSpinner:GetSelected() then
		local value = self.godmodeSpinner:GetSelectedData()
		GetPlayer().components.health:SetInvincible(value)
	end
end

function TestScreen:InitializeSpinners()
	self.entitySpinner:SetSelectedIndex(self.entityIndex)
	self:UpdateSelectedEntity()

	self.itemSpinner:SetSelectedIndex(self.itemIndex)
	self:UpdateSelectedItem()

	self.foodSpinner:SetSelectedIndex(self.foodIndex)
	self:UpdateSelectedFood()

	self.objectSpinner:SetSelectedIndex(self.objectIndex)
	self:UpdateSelectedObject()

	self.speedSpinner:SetSelectedIndex(self.speedIndex)
	self:UpdateSpeedMultiplier()

	self.godmodeSpinner:SetSelectedIndex(GodModeIndex())
	self:UpdateGodMode()
end
