
function DynamicWeather.CreateOverride(continent)
	local overrideBox = CreateFrame("EditBox", "overrideBox" .. continent, DynamicWeather.overridespanel, "InputBoxTemplate")
	overrideBox:SetAutoFocus(false)
	overrideBox:SetNumeric(false)
	overrideBox:SetWidth(70)
	overrideBox.text = overrideBox:CreateFontString(nil,"ARTWORK") 
	overrideBox.text:SetFont("Fonts\\ARIALN.ttf", 13, "OUTLINE")
	overrideBox.text:SetPoint("CENTER",0,30)
	overrideBox.text:SetText(continent)
	overrideBox:SetHeight(20)
	overrideBox:SetMaxLetters(12)
	overrideBox:SetScript("OnShow", function(self)
			if(DW_Overrides[continent] == nil) then
				self:SetText("Default")
			else
				self:SetText(tostring(DW_Overrides[continent]))
			end
		end)
	overrideBox:SetScript("OnHide", function(frame)
		local n = tonumber(frame:GetText())
		if not n then
			DW_Overrides[continent] = nil
			return
		else
			if(n > 100) then
				n = 100
			elseif(n < -100) then
				n = -100
			end
			DW_Overrides[continent] = n
			DynamicWeather.CalculateGlobalWeather()
		end
		
	end)
	overrideBox:Show()
	
	
	
	return overrideBox
end

Season_Selections = {
	["Summer"]="Summer",
	["Winter"]="Winter",
	["Spring"]="Spring",
	["Autumn"]="Autumn",
	["World - Default"]="World",
}

function DynamicWeather.CreateOptions()

	 DynamicWeather.panel = CreateFrame( "Frame", "DynamicWeatherPanel", UIParent );
	 -- Register in the Interface Addon Options GUI
	 -- Set the name for the Category for the Options Panel
	 DynamicWeather.panel.name = "DynamicWeather";
	 -- Add the panel to the Interface Options
	 InterfaceOptions_AddCategory(DynamicWeather.panel);
	 
	
	
	 
	
	 DynamicWeather.effectspanel = CreateFrame( "Frame", "DynamicWeatherChildEffectsPanel", DynamicWeather.panel);
	 DynamicWeather.effectspanel.name = "Effects";
	 -- Specify childness of this panel (this puts it under the little red [+], instead of giving it a normal AddOn category)
	 DynamicWeather.effectspanel.parent = DynamicWeather.panel.name;
	
	 -- Make a child panel
	 DynamicWeather.overridespanel = CreateFrame( "Frame", "DynamicWeatherChild", DynamicWeather.panel);
	 DynamicWeather.overridespanel.name = "Overrides";
	 -- Specify childness of this panel (this puts it under the little red [+], instead of giving it a normal AddOn category)
	 DynamicWeather.overridespanel.parent = DynamicWeather.panel.name;
	 -- Make a child panel
	
	 DynamicWeather.overridespanel.text = DynamicWeather.overridespanel:CreateFontString()
	 DynamicWeather.overridespanel.text:SetFontObject(GameFontHighlight)
	 DynamicWeather.overridespanel.text:SetPoint("TOP", 0, -30)
	 DynamicWeather.overridespanel.text:SetJustifyH("CENTER")
	 DynamicWeather.overridespanel.text:SetJustifyV("CENTER")
	 DynamicWeather.overridespanel.text:SetText("Enter a number from -100 to 100 into an option to affect the chances of weather there!\nIf your friends enter the same number they will see the same weather too!\nDelete it or enter anything non-numeric to make it use the world weather!")
	
	 DynamicWeather.overridespanel:Hide();
	 InterfaceOptions_AddCategory(DynamicWeather.effectspanel);
	 InterfaceOptions_AddCategory(DynamicWeather.overridespanel);
	 
	local effectsslider = CreateFrame("Slider","DynamicWeatherIntensitySlider", DynamicWeather.effectspanel,'OptionsSliderTemplate') 
	
	effectsslider:SetPoint("TOPLEFT", 50, -100)
	
	effectsslider.intensitytext = effectsslider:CreateFontString()
	effectsslider.intensitytext:SetFontObject(GameFontHighlight)
	effectsslider.intensitytext:SetPoint("TOP", 0, 20)
	effectsslider.intensitytext:SetJustifyH("CENTER")
	effectsslider.intensitytext:SetJustifyV("CENTER")
	effectsslider.intensitytext:SetText("Screen Effect Intensity")
	
	effectsslider:SetScript("OnValueChanged", function(self)
		local value = self:GetValue()
		DW_EffectIntensity = value
	end)
	
	effectsslider:SetMinMaxValues(0, 1)
	
	DynamicWeather.effectspanel.refresh = function()
		effectsslider:SetValue(DW_EffectIntensity)
	end
	
	
	
	 -- Add the child to the Interface Options
	local GlobalWeatherToggle_name = "EnableGlobalWeather"
	local template = "UICheckButtonTemplate"
	local GlobalWeatherButton = CreateFrame("CheckButton",GlobalWeatherToggle_name,DynamicWeather.overridespanel,template) --frameType, frameGlobalWeatherToggle_name, frameParent, frameTemplate    
	GlobalWeatherButton:SetPoint("TOPLEFT",50,-100)
	GlobalWeatherButton.text = _G[GlobalWeatherToggle_name.."Text"]
	GlobalWeatherButton.text:SetText("Enable Weather Overrides")
	GlobalWeatherButton:SetChecked(DW_UseGlobal)
	GlobalWeatherButton:SetScript("OnClick", function(self,event,arg1) 
	  if self:GetChecked() then
			DW_UseGlobal = true;
		else
			DW_UseGlobal = false;
	  end
	end)
	GlobalWeatherButton:Show()
	
	
	
	
	local overrideNorthEKBox = DynamicWeather.CreateOverride("North Eastern Kingdoms")
	overrideNorthEKBox:SetPoint("TOPLEFT", 50, -200)
	overrideNorthEKBox:Show()
	
	local overrideSouthEKBox = DynamicWeather.CreateOverride("Southern Eastern Kingdoms")
	overrideSouthEKBox:SetPoint("TOPLEFT", 200, -200)
	overrideSouthEKBox:Show()
	
	local overrideNorthKalimdorBox = DynamicWeather.CreateOverride("North Kalimdor")
	overrideNorthKalimdorBox:SetPoint("TOPLEFT", 350, -200)
	
	
	local overrideSouthKalimdorBox = DynamicWeather.CreateOverride("Southern Kalimdor")
	overrideSouthKalimdorBox:SetPoint("TOPLEFT", 50, -300)
	
	
	local overrideKulTirasBox = DynamicWeather.CreateOverride("Kul Tiras")
	overrideKulTirasBox:SetPoint("TOPLEFT", 200, -300)
	
	
	local overrideZandalarBox = DynamicWeather.CreateOverride("Zandalar")
	overrideZandalarBox:SetPoint("TOPLEFT", 350, -300)
	

	
	local overrideNorthrendBox = DynamicWeather.CreateOverride("Northrend")
	overrideNorthrendBox:SetPoint("TOPLEFT", 50, -400)
	
	
	local overridePandariaBox = DynamicWeather.CreateOverride("Pandaria")
	overridePandariaBox:SetPoint("TOPLEFT", 200, -400)
	
	
	local overrideBrokenIslesBox = DynamicWeather.CreateOverride("Broken Isles")
	overrideBrokenIslesBox:SetPoint("TOPLEFT", 350, -400)
	
	
	local overrideArgusBox = DynamicWeather.CreateOverride("Argus")
	overrideArgusBox:SetPoint("TOPLEFT", 50, -500)
	
	
	local overrideDraenorBox = DynamicWeather.CreateOverride("Draenor")
	overrideDraenorBox:SetPoint("TOPLEFT", 200, -500)
	
	
	local overrideOutlandBox = DynamicWeather.CreateOverride("Outland")
	overrideOutlandBox:SetPoint("TOPLEFT", 350, -500)
	
	local SeasonOverride_Dropdown = CreateFrame("FRAME", "SeasonOverrideDropdown", DynamicWeather.overridespanel, "UIDropDownMenuTemplate")
	SeasonOverride_Dropdown:SetPoint("TOP", 0, -600)
	UIDropDownMenu_SetWidth(SeasonOverride_Dropdown, 200)
	UIDropDownMenu_SetText(SeasonOverride_Dropdown, "Season Override")
	-- Create and bind the initialization function to the dropdown menu
	
	function SeasonOverride_Dropdown_OnClick(self, arg1, arg2, checked)
		--print("Attempting to set preset " .. arg1 .. "!")
		DW_SeasonOverride = arg1
		DynamicWeather.CalculateGlobalWeather()
	end

	
	
	UIDropDownMenu_Initialize(SeasonOverride_Dropdown, function(self, level, menuList)
		local info = UIDropDownMenu_CreateInfo()
		for index, value in pairs(Season_Selections) do
			--print(index)
			info.text, info.arg1 = index, value
			info.checked = false
			info.hasArrow = false 
			info.func = SeasonOverride_Dropdown_OnClick
			UIDropDownMenu_AddButton(info)
		end
	
	end)
	
	
end