if not TinyCasterStats then return end

local L = LibStub("AceLocale-3.0"):GetLocale("TinyCasterStats")
local media = LibStub:GetLibrary("LibSharedMedia-3.0")

TinyCasterStats.fonteffects = {
	["none"] = L["None"],
	["OUTLINE"] = L["OUTLINE"],
	["THICKOUTLINE"] = L["THICKOUTLINE"],
}

function TinyCasterStats:Options()
	local options = {
		name = "TinyCasterStats",
	    handler = TinyCasterStats,
	    type = 'group',
	    args = {
			reset = {
				name = L["Position zur\195\188cksetzen"],
				desc = L["Setzt die Position von TCS zur\195\188ck"],
				type = "execute",
				func = function() tcsframe:ClearAllPoints()	tcsframe:SetPoint("CENTER", UIParent, "CENTER") end,
				disabled = function() return InCombatLockdown() end,
				order = 1,
			},
			lock = {
				name = L["Textzeile sperren"],
				desc = L["Sperrt die Textzeile"],
				type = 'toggle',
				get = function() return self.db.char.FrameLocked end,
				set = function(info, value)				
					if(value) then
						self.db.char.FrameLocked = true
						tcsframe:SetMovable(false)
						fixed = L["|cffFF0000Der Text ist fixiert. Freigeben mit |c00ff00ff/tcs |c001E90FF[Textzeile sperren]|cffFF0000!|r"]
						tcsframe:SetScript("OnDragStart", function() DEFAULT_CHAT_FRAME:AddMessage(fixed) end)
					else
						self.db.char.FrameLocked = false
						tcsframe:SetMovable(true)
						tcsframe:SetScript("OnDragStart", function() tcsframe:StartMoving() end)
						tcsframe:SetScript("OnDragStop", function() tcsframe:StopMovingOrSizing() self.db.char.xPosition = tcsframe:GetLeft() self.db.char.yPosition = tcsframe:GetBottom() end)
					end
				end,
				disabled = function() return InCombatLockdown() end,
				order = 2,
			},
			record = {
				name = L["Rekordnachrichten"],
				desc = L["Schaltet Rekordnachrichten an/aus"],
				type = 'toggle',
				get = function() return self.db.char.RecordMsg end,
				set = function(info, value)				
					if(value) then
						self.db.char.RecordMsg = true
					else
						self.db.char.RecordMsg = false
					end
				end,
				disabled = function() return InCombatLockdown() end,
				order = 3,
			},
			text = {
				name = L["Text"],
				desc = L["Text Einstellungen"],
				type = 'group',
				order = 1,
				args = {			
					hader = {
						name = L["Text Einstellungen"],
						type = 'header',
						order = 1,
					},
					spaceline1 = {
						name = "\n",
						type = 'description',
						order = 2,
					},
					alpha = {
						name = L["Text Alpha"],
						desc = L["Sichtbarkeit des Textes au\195\159erhalb des Kampfes"],
						width = 'full',
						type = 'range',
						min = 0,
						max = 1,
						step = 0.01,
						isPercent = true,
						get = function() return self.db.char.Vis end,
						set = function(info, newValue)
							self.db.char.Vis = newValue
							tcsframe:SetAlpha(self.db.char.Vis)
						end,
						disabled = function() return InCombatLockdown() end,
						order = 3,
					},
					font = {
						name = L["Schriftart"],
						type = 'select',
						get = function() return self.db.char.Font end,
						set = function(info, newValue)
							self.db.char.Font = newValue
							local font = media:Fetch("font", self.db.char.Font)
							tcsstring:SetFont(font, self.db.char.Size, self.db.char.FontEffect)
						end,
						values = self.fonts,
						order = 4,
					},
					spaceline2 = {
						name = "",
						type = 'description',
						order = 5,
					},
					fonteffect = {
						name = L["Schriftartrand"],
						type = 'select',
						get = function() return self.db.char.FontEffect end,
						set = function(info, newValue)
							self.db.char.FontEffect = newValue
							local font = media:Fetch("font", self.db.char.Font)
							tcsstring:SetFont(font, self.db.char.Size, self.db.char.FontEffect)
						end,
						values = self.fonteffects,
						order = 6,
					},
					barfontsize = {
						name = L["Schriftgr\195\182\195\159e"],
						width = 'full',
						type = 'range',
						min = 6,
						max = 32,
						step = 1,
						get = function() return self.db.char.Size end,
						set = function(info, newValue)
							self.db.char.Size = newValue
							local font = media:Fetch("font", self.db.char.Font)
							tcsstring:SetFont(font, self.db.char.Size, self.db.char.FontEffect)
						end,
						order = 7,
					},
				},
			},
			style = {
				name = L["Stats"],
				desc = L["Definiert die angezeigten Stats"],
				type = 'group',
				order = 2,
				args = {
					hader = {
						name = L["Stats"],
						type = 'header',
						order = 1,
					},
					spaceline3 = {
						name = "\n",
						type = 'description',
						order = 2,
					},
					spelldmg = {
						name = L["Zaubermacht"],
						desc = L["Zaubermacht"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.Spelldmg end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.Spelldmg = true
							else
								self.db.char.Style.Spelldmg = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 3,
					},
					crit = {
						name = L["Kritischetrefferchance"],
						desc = L["Kritischetrefferchance"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.Crit end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.Crit = true
							else
								self.db.char.Style.Crit = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 4,
					},
					hit = {
						name = L["Trefferchance"],
						desc = L["Trefferchance"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.Hit end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.Hit = true
							else
								self.db.char.Style.Hit = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 5,
					},
					haste = {
						name = L["Tempowertung"],
						desc = L["Tempowertung"].." "..L["ein-/ausblenden"]..L["\n(Nur reele oder prozentuale Darstellung m\195\182glich!)"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.Haste end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.Haste = true
								self.db.char.Style.HastePerc = false
							else
								self.db.char.Style.Haste = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 6,
					},
					hasteperc = {
						name = L["Tempowertung in Prozent"],
						desc = L["Tempowertung in Prozent"].." "..L["ein-/ausblenden"]..L["\n(Nur reele oder prozentuale Darstellung m\195\182glich!)"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.HastePerc end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.HastePerc = true
								self.db.char.Style.Haste = false
							else
								self.db.char.Style.HastePerc = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 7,
					},
					mp5 = {
						name = L["Manaregeneration pro 5 Sekunden"],
						desc = L["Manaregeneration pro 5 Sekunden"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MP5 end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MP5 = true
							else
								self.db.char.Style.MP5 = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 8,
					},
					maxspelldmg = {
						name = L["H\195\182chste"].." "..L["Zaubermacht"],
						desc = L["H\195\182chste"].." "..L["Zaubermacht"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxSpelldmg end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxSpelldmg = true
							else
								self.db.char.Style.MaxSpelldmg = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 9,
					},
					maxcrit = {
						name = L["H\195\182chste"].." "..L["Kritischetrefferchance"],
						desc = L["H\195\182chste"].." "..L["Kritischetrefferchance"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxCrit end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxCrit = true
							else
								self.db.char.Style.MaxCrit = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 10,
					},
					maxhit = {
						name = L["H\195\182chste"].." "..L["Trefferchance"],
						desc = L["H\195\182chste"].." "..L["Trefferchance"].." "..L["ein-/ausblenden"]..L["\n(Nur reele oder prozentuale Darstellung m\195\182glich!)"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxHit end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxHit = true
							else
								self.db.char.Style.MaxHit = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 11,
					},
					maxhaste = {
						name = L["H\195\182chste"].." "..L["Tempowertung"],
						desc = L["H\195\182chste"].." "..L["Tempowertung"].." "..L["ein-/ausblenden"]..L["\n(Nur reele oder prozentuale Darstellung m\195\182glich!)"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxHaste end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxHaste = true
								self.db.char.Style.MaxHastePerc = false
							else
								self.db.char.Style.MaxHaste = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 12,
					},
					maxhasteperc = {
						name = L["H\195\182chste"].." "..L["Tempowertung in Prozent"],
						desc = L["H\195\182chste"].." "..L["Tempowertung in Prozent"].." "..L["ein-/ausblenden"]..L["\n(Nur reele oder prozentuale Darstellung m\195\182glich!)"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxHastePerc end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxHastePerc = true
								self.db.char.Style.MaxHaste = false
							else
								self.db.char.Style.MaxHastePerc = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 13,
					},
					maxmp5 = {
						name = L["H\195\182chste"].." "..L["Manaregeneration pro 5 Sekunden"],
						desc = L["H\195\182chste"].." "..L["Manaregeneration pro 5 Sekunden"].." "..L["ein-/ausblenden"],
						width = 'full',
						type = 'toggle',
						get = function() return self.db.char.Style.MaxMP5 end,
						set = function(info, value)				
							if(value) then
								self.db.char.Style.MaxMP5 = true
							else
								self.db.char.Style.MaxMP5 = false
							end
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 14,
					},
					spaceline4 = {
						name = "\n",
						type = 'description',
						order = 15,
					},
					resetrecords = {
						name = L["Rekorde zur\195\188cksetzen"],
						desc = L["Setzt die Rekorde deiner Stats zur\195\188ck"],
						type = 'execute',
						func = function()
							self.db.char.HighestSpelldmg = 0
							self.db.char.HighestCrit = "0"
							self.db.char.HighestHaste = "0"
							self.db.char.HighestHastePerc = "0"
							self.db.char.HighestHit = "0"
							self.db.char.HighestMP5if = "0"
							self.db.char.HighestMP5 = "0"
							self:Stats()
						end,
						disabled = function() return InCombatLockdown() end,
						order = 16,
					},
				},
			},
		},
	}
	return options
end