-- ==================================================================================================================== --
--															--
--	File			Options.lua										--
--															--
--															--
--	Author			Zarnivoop						| Basis, thx	|		--
--															--
--										| Version	   :	 12.0.1 |	--
--										| Curse-Project-ID :	  17718 |	--
--										| Wago-ID	   :   Q6aEVa6W |	--
--										| License	   :	  MIT/X |	--
--															--
--															--
--				Baltha							| Revision	|		--
--										| Version	   :	 12.0.1 |	--
--										| Curse-Project-ID :	1188318 |	--
--										| License	   :	  MIT/X |	--
--															--
--															--
--										| Initial Version  : 2024-11-18 |	--
--										| Current Version  : 2026-05-17 |	--
--										|		   : Release	|	--
--															--
--															--
--	Path ( Revision )	"..\World of Warcraft\_retail_\Interface\AddOns\Skada\Misc\Changelog\ChangeLog.txt"	--
--															--
-- ==================================================================================================================== --


local _, Skada	     = ...


local L		     = LibStub("AceLocale-3.0"):GetLocale("Skada", true)
local media	     = LibStub("LibSharedMedia-3.0")


local emptyLines     = string.rep("\n", 2)


Skada.resetoptions   = {[1] = L["No"], [2] = L["Yes"], [3] = L["Ask"]}


   Skada.windowdefaults =

			{

					   name = "Skada"												,
				     barspacing = 0													,
				     bartexture = "BantoBar"												,
					barfont = "ABF"													,
				   barfontflags = ""													,
				    barfontsize = 13													,
				      barheight = 18													,
				       barwidth = 260													,
				 barorientation = 1													,
				       barcolor = {r = 0.3, g = 0.3, b = 0.8, a = 1}									,
				     barbgcolor = {r = 0.3, g = 0.3, b = 0.3, a = 0.6}									,
				     barslocked = false													,
				   clickthrough = false													,
				  alternaterows = false													,
				  highlightself = false													,
			     selfhighlightcolor = {r = 1, g = 1, b = 1, a = 0.15}									,
					  spark = false													,
					barfill = false													,
				      iconscale = 100													,
				       barinset = 1													,
			      spellschoolcolors = true													,
				 classcolorbars = true													,
				 classcolortext = false													,
				     classicons = true													,
				      roleicons = false													,
				       showself = true													,
					buttons = { menu = true, reset = true, report = true, mode = true, segment = true }				,
					  title =

						{

							      textcolor = { r = 1, g = 1, b = 1, a = 1 }						,
								 height = 20										,
								   font = "ABF"										,
							    barfontsize = 13										,
							       fontsize = 13										,
								texture = "BantoBar"									,
							    bordercolor = {r = 0, g = 0, b = 0, a = 0}							,
							  bordertexture = "None"									,
							borderthickness = 0										,
								  color = {r = 0.3, g = 0.3, b = 0.3, a = 1}						,
								 color2 = {r = 0.1, g = 0.3, b = 0.6, a = 0.9}						,
							      fontflags = ""										,
							      textalign = "LEFT"

						}	,

				     background =

						{

							         height = 200										,
							        texture = "Solid"									,
							    bordercolor = {r = 1, g = 1, b = 1, a = 0.1}						,
							  bordertexture = "None"									,
							borderthickness = 1										,
								  color = { r = 0, g = 0, b = 0, a = 0.4 }						,
								   tile = false										,
							       tilesize = 0										,

						}	,

					 strata = "LOW"													,
					  scale = 1													,
				  reversegrowth = false													,
				   modeincombat = ""													,
			      returnaftercombat = false													,
				       wipemode = ""													,
					 hidden = false													,
				    enabletitle = true													,
				       titleset = true													,
					    set = "current"												,
					   mode = nil													,
					display = "bar"													,
					 snapto = true													,
				      smoothing = false													,


				-- ====================
				-- | Broker exclusive |
				-- ====================
				      textcolor = {r = 0.9, g = 0.9, b = 0.9}										,
				 valuetextcolor = nil													,
				       useframe = true

			}


local windefaultscopy = {}


Skada:tcopy(windefaultscopy, Skada.windowdefaults)


	 Skada.defaults =

			{

			profile =

				{

						  reset = { instance = 1, join = 1, leave = 1 }								,
						   icon = { hide = false, radius = 80, minimapPos = 195 }						,
					   numberformat = 1												,
					      setformat = 3												,
					      showranks = true												,
					       tooltips = true												,
					     tooltippos = "smart"											,
					    tooltiprows = 3												,
				    informativetooltips = true												,
					       hidesolo = false												,
						hidepvp = false												,
					     hidecombat = false												,
						   feed = ""												,
					     showtotals = false												,
				       sortmodesbyusage = true												,
					updatefrequency = 0.25												,
						modules = {}												,
						 report = {mode = "Damage", set = "current", channel = "Say", chantype = "preset", number = 10}		,
					 modulesBlocked = {}												,
						windows = {windefaultscopy}

				}
			}




function Skada:AddLoadableModuleCheckbox(mod, name, description)

      local new =

		{

			type = "toggle"		,
			name = name		,
			desc = description	,
		       order = 1

		}


	Skada.options.args.modules.args[mod] = new
end


local deletewindow = nil
local newdisplay   = "bar"


			-- ==================
			-- | options: Skada |
			-- ==================
	  Skada.options =
																								
			{

			   	   type = "group"																					,
			   	   name = "Skada"																					,
				plugins = {}																						,

				   args =

					{

						      d =

							{

								   type = "description"																	,
								   name = "\124cFF00FF00" .. L["Options: menu"]														,
								  order = 0

							}	,


							-- ====================
							-- | options: windows |
							-- ====================
						windows =

							{

								   type = "group"																	,
								   name = L["Windows"]																	,
								  order = 1																		,
	
								   args = {

									  windowoptions =

											{

												   type = "description"													,
												   name = "\124cnNORMAL_FONT_COLOR:" .. L["Options: window"] .. emptyLines						,
												  order = 1

											}	,

										 create =

											{

												   type = "input"													,
												   name = "\124cFF00FF00" .. L["Create window"]										,
												   desc = L["Enter the name for the new window."]									,
												    set = function(self, val)


														  local cwnHasName, cwnIsAllowedName = Skada:CheckWindowNames(val)


														  if cwnIsAllowedName == true then

															  local cwdHasName, cwdIsAllowedName = Skada:CheckWindowDuplicates(cwnHasName, "INS")


															  if cwdIsAllowedName == true then

																  Skada:CreateWindow(cwdHasName, nil, newdisplay)
																  Skada:CurrentTooltip("INS", "NEW", cwdHasName, "")
															  else

																  Skada:CurrentTooltip("INS", "DUP", cwnHasName, "")
														 	  end
													  	  end
												  	  end														,
												  order = 2

											}	,

										display =

											{

												   type = "select"													,
												   name = "\124cFF00FF00" .. L["Display system"]									,
												   desc = L["Choose the system to be used for displaying data in this window."]						,
												 values = function()

														  local list = {}


												  		  for name, display in pairs(Skada.displays) do

															  if display.name == L["Bar display"] then

																  list[name] = "\124cnBLUE_FONT_COLOR:" .. display.name
															  end


															  if display.name == L["Data text"] then

																  list[name] = "\124cnORANGE_FONT_COLOR:" .. display.name
															  end
														  end


														  return list
													  end														,
												    get = function()

														  return newdisplay
													  end														,
												    set = function(i, display)

														  newdisplay = display
													  end														,
												  order = 3
											}	,
									}	,
							}	,


							-- ==================
							-- | options: reset |
							-- ==================
					   resetoptions =

							{

								   type = "group"																	,
								   name = L["Data resets"]																,
								  order = function()

										  if GetLocale() == "deDE" then return 2 end
										  if GetLocale() == "enUS" then return 4 end	  	
									  end																		,

								   args =	

									{

									   optionsreset =

											{

												   type = "description"													,
												   name = "\124cnNORMAL_FONT_COLOR:" .. L["Options: reset data"] .. emptyLines						,
												  order = 0

											}	,

									  resetinstance =

											{

												   type = "select"													,
												   name = "\124cFFFFFFFF" .. L["Reset on entering instance"]								,
												   desc = L["Controls if data is reset when you enter an instance."]							,
												 values = function()

														  return Skada.resetoptions
													  end														,
												    get = function()

														  return Skada.db.profile.reset.instance
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.reset.instance = opt
													  end														,
												  order = 1

											}	,

									      resetjoin =

											{

												   type = "select"													,
												   name = "\124cFFFFFFFF" .. L["Reset on joining a group"]								,
												   desc = L["Controls if data is reset when you join a group."]								,
												 values = function()

														  return Skada.resetoptions
													  end														,
												    get = function()

														  return Skada.db.profile.reset.join
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.reset.join = opt
													  end														,
												  order = 2

											}	,

									     resetleave =

											{

												   type = "select"													,
												   name = "\124cFFFFFFFF" .. L["Reset on leaving a group"]								,
												   desc = L["Controls if data is reset when you leave a group."]							,
												 values = function()

														  return Skada.resetoptions
													  end														,
												    get = function()

														  return Skada.db.profile.reset.leave
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.reset.leave = opt
													  end														,
												  order = 3

											}	,
									}
							}	,


							-- =====================
							-- | options: tooltips |
							-- =====================
					       tooltips =

							{

							   type = "group"																		,
							   name = L["Tooltips"]																		,
							  order = 4																			,

							   args =

								{			

								optionstooltips =

										{

											   type = "description"														,
											   name = "\124cnNORMAL_FONT_COLOR:" .. L["Options: tooltips"] .. emptyLines							,
											  order = 0

										}	,

								       tooltips =

										{

											   type = "toggle"														,
											   name = L["Show tooltips"]													,
											   desc = L["Shows tooltips with extra information in some modes."]								,
											    get = function()

													  return Skada.db.profile.tooltips
												  end															,														    set = function()

													  Skada.db.profile.tooltips = not Skada.db.profile.tooltips
												  end															,
											  order = 1

										}	,

								    informative =

										{

											   type = "toggle"														,
											   name = L["Informative tooltips"]												,
											   desc = L["Shows subview summaries in the tooltips."]										,
											    get = function()	

													  return Skada.db.profile.informativetooltips
												  end															,
											    set = function()

													  Skada.db.profile.informativetooltips = not Skada.db.profile.informativetooltips
												  end															,
											  order = 2

										}	,

									   rows =

										{

											   type = "range"														,
											   name = L["Subview rows"]													,
											   desc = L["The number of rows from each subview to show  when using informative tooltips."]					,
											    min = 1															,
											    max = 10															,
											   step = 1															,
											    get = function()

													  return Skada.db.profile.tooltiprows
												  end															,
											    set = function(self, val)

													  Skada.db.profile.tooltiprows = val
												  end															,
											  order = 3															,

										}	,

								     tooltippos =

										{

											   type = "select"														,
											   name = L["Tooltip position"]													,
											   desc = L["Position of the tooltips."]											,
											 values =

												{

													 ["default"] = L["Default"]											,
													["topright"] = L["Top right"]											,
													 ["topleft"] = L["Top left"]											,
													   ["smart"] = L["Smart"]

												}	,

											    get = function()

													  return Skada.db.profile.tooltippos
												  end															,
											    set = function(self, opt)

													  Skada.db.profile.tooltippos = opt
												  end															,
											  order = 4

										}	,
								}
							}	,


							-- ====================
							-- | options: general |
							-- ====================
					 generaloptions =

							{

								   type = "group"																	,
								   name = L["General options"]																,
								  order = function()

										  if GetLocale() == "deDE" then return 2 end
										  if GetLocale() == "enUS" then return 5 end	  	
									  end																		,

								   args = {


								  generaloptionsettings =

											{

												   type = "description"													,
												   name = "\124cnNORMAL_FONT_COLOR:" .. L["Options: general settings"] .. emptyLines					,
												  order = 0

											}	,

									       mmbutton =

											{

												   type = "toggle"													,
												   name = L["Show minimap button"]											,
												   desc = L["Toggles showing the minimap button."]									,
												    get = function()

														  return not Skada.db.profile.icon.hide
													  end														,
												    set = function()

														  Skada.db.profile.icon.hide = not Skada.db.profile.icon.hide


														  Skada:RefreshMMButton()
													  end														,
												  order = 1

											}	,

									     showtotals =

											{

												   type = "toggle"													,
												   name = L["Show totals"]												,
												   desc = L["Shows a extra row with a summary in certain modes."]							,
												    get = function()

														  return Skada.db.profile.showtotals
													  end														,
												    set = function()

														  Skada.db.profile.showtotals = not Skada.db.profile.showtotals
													  end														,
												  order = 2


											}	,

									       hidesolo =

											{

												   type = "toggle"													,
												   name = L["Hide when solo"]												,
												   desc = L["Hides Skada's window when not in a party or raid."]							,
												    get = function()

														  return Skada.db.profile.hidesolo
													  end														,
												    set = function()

														  Skada.db.profile.hidesolo = not Skada.db.profile.hidesolo


														  Skada:ApplySettings()
													  end														,
												  order = 3

											}	,

										hidepvp =

											{

												   type = "toggle"													,
												   name = L["Hide in PvP"]												,
												   desc = L["Hides Skada's window when in Battlegrounds/Arenas."]							,
												    get = function()

														  return Skada.db.profile.hidepvp
													  end														,
												    set = function()

														  Skada.db.profile.hidepvp = not Skada.db.profile.hidepvp


														  Skada:ApplySettings()
													  end														,
												  order = 4

											}	,

									     hidecombat =

											{

												   type = "toggle"													,
												   name = L["Hide in combat"]												,
												   desc = L["Hides Skada's window when in combat."]									,
												    get = function()

														  return Skada.db.profile.hidecombat
													  end														,
												    set = function()

														  Skada.db.profile.hidecombat = not Skada.db.profile.hidecombat


														  Skada:ApplySettings()
													  end														,
										 		  order = 5

											}	,

								       sortmodesbyusage =

											{

												   type = "toggle"													,
												   name = L["Sort modes by usage"]											,
												   desc = L["The mode list will be sorted to reflect usage instead of alphabetically."]					,
												  width = "full"													,
												    get = function()

														  return Skada.db.profile.sortmodesbyusage
													  end														,
												    set = function()

														  Skada.db.profile.sortmodesbyusage = not Skada.db.profile.sortmodesbyusage


														  Skada:ApplySettings()
													  end														,
												  order = 6

											}	,



									      showranks =

											{

												   type = "toggle"													,
												   name = L["Show rank numbers"]											,
												   desc = L["Shows numbers for relative ranks for modes where it is applicable."]					,
												    get = function()

														  return Skada.db.profile.showranks
													  end														,
												    set = function()

														  Skada.db.profile.showranks = not Skada.db.profile.showranks


														  Skada:ApplySettings()
													  end														,
												  order = 7

											}	,

									       showself =

											{

												   type = "toggle"													,
												   name = L["Always show self"]												,
												   desc = L["Keeps the player shown last even if there is not enough space."]						,
												    get = function()

														  return Skada.db.profile.showself
													  end														,
												    set = function()

														  Skada.db.profile.showself = not Skada.db.profile.showself


														  Skada:ApplySettings()
													  end														,
												  order = 8

											}	,

									   numberformat =

											{

												   type = "select"													,
												   name = L["Number format"]												,
												   desc = L["Controls the way large numbers are displayed."]								,
												 values = function()

														  return {[1] = L["Condensed"], [2] = L["Detailed"]}
												 	  end														,
												    get = function()

														  return Skada.db.profile.numberformat
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.numberformat = opt
												  end															,
												  order = 9
																								
											}	,

									       datafeed =

											{

												   type = "select"													,
												   name = L["Data feed"]												,
												   desc = L["Choose which data feed to show in the DataBroker view." ..
													    " This requires an LDB display addon, such as Titan Panel."]						,
												 values = function()

														  local feeds = {}


														  feeds[""] = L["None"]


														  for name, func in pairs(Skada:GetFeeds()) do feeds[name] = name end


														  return feeds
													  end														,
												    get = function()

														  return Skada.db.profile.feed
													  end														,
												    set = function(self, feed)

														  Skada.db.profile.feed = feed


														  if feed ~= "" then Skada:SetFeed(Skada:GetFeeds()[feed]) end
													  end														,
												  order = 10														,

											}	,

									      setformat =

											{

												   type = "select"													,
												   name = L["Set format"]												,
												   desc = L["Controls the way set names are displayed."]								,
												 values = Skada:SetLabelFormats()											,
												    get = function()

														  return Skada.db.profile.setformat
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.setformat = opt


														  Skada:ApplySettings()
													  end														,
												  width = "double"													,
												  order = 11

											}	,

									updatefrequency =

											{

												   type = "range"													,
												   name = L["Update frequency"]												,
												   desc = L["How often windows are updated. Shorter for faster updates. Increases CPU usage."]				,
												    min = 0.10														,
												    max = 1														,
												   step = 0.05														,
												  width = "double"													,
												    get = function()

														  return Skada.db.profile.updatefrequency
													  end														,
												    set = function(self, opt)

														  Skada.db.profile.updatefrequency = opt
													  end														,
												  order = 12

											}	,

									     simulation =

											{

												   type = "group"													,
												   name = L["Debug & Simulation"]											,
												  order = 13														,
												 inline = true														,

												   args =

													{

													        simulation_mode =

																{

																	   type = "toggle"								,
																	   name = L["Modus"]								,
																	   desc = L["Enables simulation mode for performance testing." .. 
																		    " Auto-disables in real combat."]					,
																	    get = function()

																			  return Skada.Simulation and Skada.Simulation.active
																		  end									,
																	    set = function(self, val)

																			  if Skada.Simulation then

																				  Skada.Simulation:SetEnabled(val)
																			  end
																		  end									,
																	  order = 1

																}	,

														simulation_size =

																{

																	   type = "range"								,
																	   name = L["Group Size"]							,
																	   desc = L["Controls the number of simulated participants."]			,
																	    min = 1									,
																	    max = 40									,
																	   step = 1									,
																       disabled = function()

																			  return not (Skada.Simulation and Skada.Simulation.active)
																		  end									,
																	    get = function()

																			  return Skada.Simulation and Skada.Simulation.groupSize or 40
																		  end									,
																	   set = function(self, val)

																			 if Skada.Simulation then

																				 Skada.Simulation:SetGroupSize(val)
																			 end
																		 end									,
																	order = 2
																}	,
													}
											}

									}
							},

							-- ====================
							-- | options: modules |
							-- ====================
						modules =

							{
								   type = "group"																	,
								   name = L["Disabled Modules"]																,
								    get = function(i)

										  return Skada.db.profile.modulesBlocked[i[#i]]
									  end																		,
								    set = function(i, value)

										  Skada.db.profile.modulesBlocked[i[#i]]	 = value


										  Skada.options.args.modules.args.apply.disabled = false
									  end																		,
								  order = function()

										  if GetLocale() == "deDE" then return 3 end
										  if GetLocale() == "enUS" then return 3 end	  	
									  end																		,

								   args =

									{

										   desc =

											{

												   type = "description"													,
												   name = "\124cnNORMAL_FONT_COLOR:" .. L["Options: modules (de)activate"] .. "|cffffffff" .. emptyLines		,
												  order = 0

											}	,

										  apply =

											{

												   type = "execute"													,
												   name = APPLY														,
												  width = "full"													,
												   func = ReloadUI													,
											        confirm = function()

														  return L["This change requires a UI reload. Are you sure?"]
													  end														,
											       disabled = true														,
												  order = 1

											}	,
									}	,
							}	,
					}
			}




local function create_window_button(display_key)

end




local function update_create_windows()

end




local original_add_display = Skada.AddDisplaySystem




Skada.AddDisplaySystem = function(self, key, mod)

	original_add_display(self, key, mod)


	update_create_windows()
end




local original_setup = Skada.OptionsSetup




Skada.OptionsSetup = function()

		     	     original_setup()


			     update_create_windows()
		     end