PageRenderTime 291ms CodeModel.GetById 111ms app.highlight 104ms RepoModel.GetById 67ms app.codeStats 0ms

/Tukui_ConfigUI/core.lua

http://github.com/Asphyxia/Tukui
Lua | 739 lines | 623 code | 85 blank | 31 comment | 403 complexity | b22fbe907e6123c5f38e0653b942340d MD5 | raw file
  1-- This will filter everythin NON user config data out of TukuiDB
  2
  3local myPlayerRealm = GetCVar("realmName")
  4local myPlayerName  = UnitName("player")
  5
  6local ALLOWED_GROUPS = {
  7	["general"]=1,
  8	["unitframes"]=1,
  9	["arena"]=1,
 10	["actionbar"]=1,
 11	["nameplate"]=1,
 12	["bags"]=1,
 13	["loot"]=1,
 14	["cooldown"]=1,
 15	["datatext"]=1,
 16	["chat"]=1,
 17	["tooltip"]=1,
 18	["merchant"]=1,
 19	["error"]=1,
 20	["invite"]=1,
 21	["buffreminder"]=1,
 22	["auras"]=1,
 23}
 24
 25--List of "Table Names" that we do not want to show in the config
 26local TableFilter = {
 27	["filter"]=1,
 28}
 29
 30local function Local(o)
 31	local T, C, L = unpack(Tukui)
 32	
 33	-- general
 34	if o == "TukuiConfigUIgeneral" then o = TukuiL.option_general end
 35	if o == "TukuiConfigUIgeneralautoscale" then o = TukuiL.option_general_uiscale end
 36	if o == "TukuiConfigUIgeneraloverridelowtohigh" then o = TukuiL.option_general_override end
 37	if o == "TukuiConfigUIgeneralmultisampleprotect" then o = TukuiL.option_general_multisample end
 38	if o == "TukuiConfigUIgeneraluiscale" then o = TukuiL.option_general_customuiscale end
 39	if o == "TukuiConfigUIgeneralbackdropcolor" then o = TukuiL.option_general_backdropcolor end
 40	if o == "TukuiConfigUIgeneralbordercolor" then o = TukuiL.option_general_bordercolor end
 41	if o == "TukuiConfigUIgeneralblizzardreskin" then o = TukuiL.option_general_blizzardreskin end
 42
 43	-- nameplate
 44	if o == "TukuiConfigUInameplate" then o = TukuiL.option_nameplates end
 45	if o == "TukuiConfigUInameplateenable" then o = TukuiL.option_nameplates_enable end
 46	if o == "TukuiConfigUInameplateshowhealth" then o = TukuiL.option_nameplates_showhealth end
 47	if o == "TukuiConfigUInameplateenhancethreat" then o = TukuiL.option_nameplates_enhancethreat end
 48	if o == "TukuiConfigUInameplateoverlap" then o = UNIT_NAMEPLATES_ALLOW_OVERLAP end
 49	if o == "TukuiConfigUInameplatecombat" then o = TukuiL.option_nameplates_combat end
 50	if o == "TukuiConfigUInameplategoodcolor" then o = TukuiL.option_nameplates_goodcolor end
 51	if o == "TukuiConfigUInameplatebadcolor" then o = TukuiL.option_nameplates_badcolor end
 52	if o == "TukuiConfigUInameplatetransitioncolor" then o = TukuiL.option_nameplates_transitioncolor end
 53	if o =="TukuiConfigUInameplatetrackcc" then o = TukuiL.option_nameplates_trackcc end
 54	if o =="TukuiConfigUInameplatetrackdebuffs" then o = TukuiL.option_nameplates_trackdebuffs end
 55	
 56	-- merchant
 57	if o == "TukuiConfigUImerchant" then o = TukuiL.option_merchant end
 58	if o == "TukuiConfigUImerchantsellgrays" then o = TukuiL.option_merchant_autosell end
 59	if o == "TukuiConfigUImerchantautorepair" then o = TukuiL.option_merchant_autorepair end
 60	if o == "TukuiConfigUImerchantsellmisc" then o = TukuiL.option_merchant_sellmisc end
 61	if o == "TukuiConfigUImerchantguildrepair" then o = TukuiL.option_merchant_guildrepair end
 62	
 63	-- bags
 64	if o == "TukuiConfigUIbags" then o = TukuiL.option_bags end
 65	if o == "TukuiConfigUIbagsenable" then o = TukuiL.option_bags_enable end
 66	
 67	-- datatext
 68	if o == "TukuiConfigUIdatatext" then o = TukuiL.option_datatext end
 69	if o == "TukuiConfigUIdatatexttime24" then o = TukuiL.option_datatext_24h end
 70	if o == "TukuiConfigUIdatatextlocaltime" then o = TukuiL.option_datatext_localtime end
 71	if o == "TukuiConfigUIdatatextbattleground" then o = TukuiL.option_datatext_bg end
 72	if o == "TukuiConfigUIdatatexthps_text" then o = TukuiL.option_datatext_hps end
 73	if o == "TukuiConfigUIdatatextguild" then o = TukuiL.option_datatext_guild end
 74	if o == "TukuiConfigUIdatatextarp" then o = TukuiL.option_datatext_arp end
 75	if o == "TukuiConfigUIdatatextsystem" then o = TukuiL.option_datatext_mem end
 76	if o == "TukuiConfigUIdatatextbags" then o = TukuiL.option_datatext_bags end
 77	if o == "TukuiConfigUIdatatextfontsize" then o = TukuiL.option_datatext_fontsize end
 78	if o == "TukuiConfigUIdatatextfps_ms" then o = TukuiL.option_datatext_fps_ms end
 79	if o == "TukuiConfigUIdatatextarmor" then o = TukuiL.option_datatext_armor end
 80	if o == "TukuiConfigUIdatatextavd" then o = TukuiL.option_datatext_avd end
 81	if o == "TukuiConfigUIdatatextpower" then o = TukuiL.option_datatext_power end
 82	if o == "TukuiConfigUIdatatexthaste" then o = TukuiL.option_datatext_haste end
 83	if o == "TukuiConfigUIdatatextfriends" then o = TukuiL.option_datatext_friend end
 84	if o == "TukuiConfigUIdatatextwowtime" then o = TukuiL.option_datatext_time end
 85	if o == "TukuiConfigUIdatatextgold" then o = TukuiL.option_datatext_gold end
 86	if o == "TukuiConfigUIdatatextdps_text" then o = TukuiL.option_datatext_dps end
 87	if o == "TukuiConfigUIdatatextcrit" then o = TukuiL.option_datatext_crit end	
 88	if o == "TukuiConfigUIdatatextdur" then o = TukuiL.option_datatext_dur end
 89	if o == "TukuiConfigUIdatatextcurrency" then o = TukuiL.option_datatext_currency end
 90	if o == "TukuiConfigUIdatatextmicromenu" then o = TukuiL.option_datatext_micromenu end
 91	if o == "TukuiConfigUIdatatexthit" then o = TukuiL.option_datatext_hit end	
 92	if o == "TukuiConfigUIdatatextmastery" then o = TukuiL.option_datatext_mastery end	
 93	if o == "TukuiConfigUIdatatextregen" then o = MANA_REGEN end
 94	if o == "TukuiConfigUIdatatextbgannouncer" then o = TukuiL.option_datatext_BG_Announcer end
 95	if o == "TukuiConfigUIdatatextcolor" then o = TukuiL.option_datatext_color end
 96	if o == "TukuiConfigUIdatatextclasscolored" then  o = TukuiL.option_datatext_classcolored end
 97	if o == "TukuiConfigUIdatatextprofession" then o = TukuiL.option_datatext_profession end
 98	if o == "TukuiConfigUIdatatextenable_specswitcher" then o = TukuiL.option_datatext_enable_specswitcher end
 99	if o == "TukuiConfigUIdatatextcalltoarms" then o = TukuiL.option_datatext_calltoarms end
100	if o == "TukuiConfigUIdatatextexpertise" then o = TukuiL.option_datatext_expertise end
101
102	-- unit frames
103	if o == "TukuiConfigUIunitframes" then o = TukuiL.option_unitframes_unitframes end
104	if o == "TukuiConfigUIunitframescombatfeedback" then o = TukuiL.option_unitframes_combatfeedback end
105	if o == "TukuiConfigUIunitframesrunebar" then o = TukuiL.option_unitframes_runebar end
106	if o == "TukuiConfigUIunitframesauratimer" then o = TukuiL.option_unitframes_auratimer end
107	if o == "TukuiConfigUIunitframestotemtimer" then o = TukuiL.option_unitframes_totembar end
108	if o == "TukuiConfigUIunitframesshowtotalhpmp" then o = TukuiL.option_unitframes_totalhpmp end
109	if o == "TukuiConfigUIunitframesshowplayerinparty" then o = TukuiL.option_unitframes_playerparty end
110	if o == "TukuiConfigUIunitframesraidunitdebuffwatch" then o = TukuiL.option_unitframes_aurawatch end
111	if o == "TukuiConfigUIunitframesunitcastbar" then o = TukuiL.option_unitframes_castbar end
112	if o == "TukuiConfigUIunitframestargetauras" then o = TukuiL.option_unitframes_targetaura end
113	if o == "TukuiConfigUIunitframespositionbychar" then o = TukuiL.option_unitframes_saveperchar end
114	if o == "TukuiConfigUIunitframesws_show_time" then o = TukuiL.option_unitframes_wstimer end
115	if o == "TukuiConfigUIunitframesplayeraggro" then o = TukuiL.option_unitframes_playeraggro end
116	if o == "TukuiConfigUIunitframesshowsmooth" then o = TukuiL.option_unitframes_smooth end
117	if o == "TukuiConfigUIunitframescharportrait" then o = TukuiL.option_unitframes_portrait end
118	if o == "TukuiConfigUIunitframesenable" then o = TukuiL.option_unitframes_enable end
119	if o == "TukuiConfigUIunitframesws_show_target" then o = TukuiL.option_unitframes_wstarget end
120	if o == "TukuiConfigUIunitframestargetpowerpvponly" then o = TukuiL.option_unitframes_enemypower end
121	if o == "TukuiConfigUIunitframesgridonly" then o = TukuiL.option_unitframes_gridonly end
122	if o == "TukuiConfigUIunitframeshealcomm" then o = TukuiL.option_unitframes_healcomm end
123	if o == "TukuiConfigUIunitframesfocusdebuffs" then o = TukuiL.option_unitframes_focusdebuff end
124	if o == "TukuiConfigUIunitframesws_show_player" then o = TukuiL.option_unitframes_wsplayer end
125	if o == "TukuiConfigUIunitframesaggro" then o = TukuiL.option_unitframes_raidaggro end
126	if o == "TukuiConfigUIunitframesshowboss" then o = TukuiL.option_unitframes_boss end
127	if o == "TukuiConfigUIunitframesenemyhcolor" then o = TukuiL.option_unitframes_enemyhostilitycolor end
128	if o == "TukuiConfigUIunitframesgridhealthvertical" then o = TukuiL.option_unitframes_hpvertical end
129	if o == "TukuiConfigUIunitframesshowsymbols" then o = TukuiL.option_unitframes_symbol end
130	if o == "TukuiConfigUIunitframesshowthreat" then o = TukuiL.option_unitframes_threatbar end
131	if o == "TukuiConfigUIunitframesshowrange" then o = TukuiL.option_unitframes_enablerange end
132	if o == "TukuiConfigUIunitframesshowfocustarget" then o = TukuiL.option_unitframes_focus end
133	if o == "TukuiConfigUIunitframescblatency" then o = TukuiL.option_unitframes_latency end
134	if o == "TukuiConfigUIunitframescbicons" then o = TukuiL.option_unitframes_icon end
135	if o == "TukuiConfigUIunitframesplayerauras" then o = TukuiL.option_unitframes_playeraura end
136	if o == "TukuiConfigUIunitframesauratextscale" then o = TukuiL.option_unitframes_aurascale end
137	if o == "TukuiConfigUIunitframesgridscale" then o = TukuiL.option_unitframes_gridscale end
138	if o == "TukuiConfigUIunitframeshighThreshold" then o = TukuiL.option_unitframes_manahigh end
139	if o == "TukuiConfigUIunitframeslowThreshold" then o = TukuiL.option_unitframes_manalow end
140	if o == "TukuiConfigUIunitframesraidalphaoor" then o = TukuiL.option_unitframes_range end
141	if o == "TukuiConfigUIunitframesmaintank" then o = TukuiL.option_unitframes_maintank end
142	if o == "TukuiConfigUIunitframesmainassist" then o = TukuiL.option_unitframes_mainassist end
143	if o == "TukuiConfigUIunitframesunicolor" then o = TukuiL.option_unitframes_unicolor end
144	if o == "TukuiConfigUIunitframestotdebuffs" then o = TukuiL.option_unitframes_totdebuffs end
145	if o == "TukuiConfigUIunitframesclassbar" then o = TukuiL.option_unitframes_classbar end
146	if o == "TukuiConfigUIunitframesweakenedsoulbar" then o = TukuiL.option_unitframes_weakenedsoulbar end
147	if o == "TukuiConfigUIunitframesonlyselfdebuffs" then o = TukuiL.option_unitframes_onlyselfdebuffs end
148	if o == "TukuiConfigUIunitframesshowfocustarget" then o = TukuiL.option_unitframes_focus end
149	if o == "TukuiConfigUIunitframesbordercolor" then o = TukuiL.option_unitframes_bordercolor end
150	if o == "TukuiConfigUIunitframeshideunitframes" then o = TukuiL.option_unitframes_hide_unitframes end
151	if o == "TukuiConfigUIunitframesshowsolo" then o = TukuiL.option_unitframes_show_solo end
152	if o == "TukuiConfigUIunitframesgradient" then o = TukuiL.option_unitframes_gradient end
153	if o == "TukuiConfigUIunitframesextendedpet" then o = TukuiL.option_unitframes_extended_pet end
154	if o == "TukuiConfigUIunitframespettarget" then o = TukuiL.option_unitframes_pet_target end
155	if o == "TukuiConfigUIunitframesgradienthealth" then o = TukuiL.option_unitframes_gradient_health end
156	if o == "TukuiConfigUIunitframescbspark" then o = TukuiL.option_unitframes_cbspark end
157	if o == "TukuiConfigUIunitframesclassicon" then o = TukuiL.option_unitframes_classicon end
158	if o == "TukuiConfigUIunitframesstyle" then o = TukuiL.option_unitframes_style end
159
160	-- loot
161	if o == "TukuiConfigUIloot" then o = TukuiL.option_loot end
162	if o == "TukuiConfigUIlootlootframe" then o = TukuiL.option_loot_enableloot end
163	if o == "TukuiConfigUIlootautogreed" then o = TukuiL.option_loot_autogreed end
164	if o == "TukuiConfigUIlootrolllootframe" then o = TukuiL.option_loot_enableroll end
165	
166	-- map
167	if o == "TukuiConfigUImap" then o = TukuiL.option_map end
168	if o == "TukuiConfigUImapenable" then o = TukuiL.option_map_enable end
169	
170	-- invite
171	if o == "TukuiConfigUIinvite" then o = TukuiL.option_invite end
172	if o == "TukuiConfigUIinviteautoaccept" then o = TukuiL.option_invite_autoinvite end
173
174	-- tooltip
175	if o == "TukuiConfigUItooltip" then o = TukuiL.option_tooltip end
176	if o == "TukuiConfigUItooltipenable" then o = TukuiL.option_tooltip_enable end
177	if o == "TukuiConfigUItooltiphidecombat" then o = TukuiL.option_tooltip_hidecombat end
178	if o == "TukuiConfigUItooltiphidebuttons" then o = TukuiL.option_tooltip_hidebutton end
179	if o == "TukuiConfigUItooltiphideuf" then o = TukuiL.option_tooltip_hideuf end
180	if o == "TukuiConfigUItooltipcursor" then o = TukuiL.option_tooltip_cursor end
181	
182	-- others
183	if o == "TukuiConfigUIothers" then o = TukuiL.option_others end
184	if o == "TukuiConfigUIotherspvpautorelease" then o = TukuiL.option_others_bg end
185	
186	-- reminder
187	if o == "TukuiConfigUIbuffreminder" then o = TukuiL.option_reminder end
188	if o == "TukuiConfigUIbuffreminderenable" then o = TukuiL.option_reminder_enable end
189	if o == "TukuiConfigUIbuffremindersound" then o = TukuiL.option_reminder_sound end
190	if o == "TukuiConfigUIbuffreminderraidbuffreminder" then o = TukuiL.option_reminder_raidbuff_reminder end
191	
192	-- error
193	if o == "TukuiConfigUIerror" then o = TukuiL.option_error end
194	if o == "TukuiConfigUIerrorenable" then o = TukuiL.option_error_hide end
195	
196	-- action bar
197	if o == "TukuiConfigUIactionbar" then o = TukuiL.option_actionbar end
198	if o == "TukuiConfigUIactionbarhideshapeshift" then o = TukuiL.option_actionbar_hidess end
199	if o == "TukuiConfigUIactionbarshowgrid" then o = TukuiL.option_actionbar_showgrid end
200	if o == "TukuiConfigUIactionbarenable" then o = TukuiL.option_actionbar_enable end
201	if o == "TukuiConfigUIactionbarrightbarmouseover" then o = TukuiL.option_actionbar_rb end
202	if o == "TukuiConfigUIactionbarhotkey" then o = TukuiL.option_actionbar_hk end
203	if o == "TukuiConfigUIactionbarshapeshiftmouseover" then o = TukuiL.option_actionbar_ssmo end
204	if o == "TukuiConfigUIactionbarbottomrows" then o = TukuiL.option_actionbar_rbn end
205	if o == "TukuiConfigUIactionbarrightbars" then o = TukuiL.option_actionbar_rn end
206	if o == "TukuiConfigUIactionbarbuttonsize" then o = TukuiL.option_actionbar_buttonsize end
207	if o == "TukuiConfigUIactionbarbuttonspacing" then o = TukuiL.option_actionbar_buttonspacing end
208	if o == "TukuiConfigUIactionbarpetbuttonsize" then o = TukuiL.option_actionbar_petbuttonsize end
209	if o == "TukuiConfigUIactionbarvertical_rightbars" then o = TukuiL.option_actionbar_vertical_rightbars end
210	if o == "TukuiConfigUIactionbarstancebuttonsize" then o = TukuiL.option_actionbar_stancebuttonsize end
211	if o == "TukuiConfigUIactionbarvertical_shapeshift" then o = TukuiL.option_actionbar_vertical_shapeshift end
212	if o == "TukuiConfigUIactionbarmainswap" then o = TukuiL.option_actionbar_mainswap end
213	if o == "TukuiConfigUIactionbarmacrotext" then o = TukuiL.option_actionbar_macrotext end
214	
215	-- quest watch frame
216	if o == "TukuiConfigUIwatchframe" then o = TukuiL.option_quest end
217	if o == "TukuiConfigUIwatchframemovable" then o = TukuiL.option_quest_movable end
218	
219	-- arena
220	if o == "TukuiConfigUIarena" then o = TukuiL.option_arena end
221	if o == "TukuiConfigUIarenaspelltracker" then o = TukuiL.option_arena_st end
222	if o == "TukuiConfigUIarenaunitframes" then o = TukuiL.option_arena_uf end
223	
224	-- pvp
225	if o == "TukuiConfigUIpvp" then o = TukuiL.option_pvp end
226	if o == "TukuiConfigUIpvpinterrupt" then o = TukuiL.option_pvp_ii end
227	
228	-- cooldowns
229	if o == "TukuiConfigUIcooldown" then o = TukuiL.option_cooldown end
230	if o == "TukuiConfigUIcooldownenable" then o = TukuiL.option_cooldown_enable end
231	if o == "TukuiConfigUIcooldowntreshold" then o = TukuiL.option_cooldown_th end
232	
233	-- chat
234	if o == "TukuiConfigUIchat" then o = TukuiL.option_chat end
235	if o == "TukuiConfigUIchatenable" then o = TukuiL.option_chat_enable end
236	if o == "TukuiConfigUIchatwidth" then o = TukuiL.option_chat_width end
237	if o == "TukuiConfigUIchatheight" then o = TukuiL.option_chat_height end
238	if o == "TukuiConfigUIchatwhispersound" then o = TukuiL.option_chat_whispersound end
239	if o == "TukuiConfigUIchatjustifyRight" then o = TukuiL.option_chat_justify_Right end
240	if o == "TukuiConfigUIchatbackground" then o = TukuiL.option_chat_background end
241	if o == "TukuiConfigUIchatrightchat" then o = TukuiL.option_chat_rightchat end
242	if o == "TukuiConfigUIchatrightchatnumber" then o = TukuiL.option_chat_rightchat_number end
243
244	
245	-- aura
246	if o == "TukuiConfigUIauras" then o = TukuiL.option_auras end
247	if o == "TukuiConfigUIaurasplayer" then o = TukuiL.option_auras_player end
248
249	T.option = o
250end
251
252local NewButton = function(text,parent)
253	local T, C, L = unpack(Tukui)
254	
255	local result = CreateFrame("Button", nil, parent)
256	local label = result:CreateFontString(nil,"OVERLAY",nil)
257	label:SetFont(C.media.font,12)
258	label:SetText(text)
259	result:SetWidth(label:GetWidth())
260	result:SetHeight(label:GetHeight())
261	result:SetFontString(label)
262
263	return result
264end
265
266StaticPopupDialogs["PERCHAR"] = {
267	text = TukuiL.option_perchar,
268	OnAccept = function() 
269		if TukuiConfigAllCharacters:GetChecked() then 
270			TukuiConfigAll[myPlayerRealm][myPlayerName] = true
271		else 
272			TukuiConfigAll[myPlayerRealm][myPlayerName] = false
273		end 	
274		ReloadUI() 
275	end,
276	OnCancel = function() 
277		TukuiConfigCover:Hide()
278		if TukuiConfigAllCharacters:GetChecked() then 
279			TukuiConfigAllCharacters:SetChecked(false)
280		else 
281			TukuiConfigAllCharacters:SetChecked(true)
282		end 		
283	end,
284	button1 = ACCEPT,
285	button2 = CANCEL,
286	timeout = 0,
287	whileDead = 1,
288	preferredIndex = 3,
289}
290
291StaticPopupDialogs["RESET_PERCHAR"] = {
292	text = TukuiL.option_resetchar,
293	OnAccept = function() 
294		TukuiConfig = TukuiConfigSettings
295		ReloadUI() 
296	end,
297	OnCancel = function() if TukuiConfigUI and TukuiConfigUI:IsShown() then TukuiConfigCover:Hide() end end,
298	button1 = ACCEPT,
299	button2 = CANCEL,
300	timeout = 0,
301	whileDead = 1,
302	preferredIndex = 3,
303}
304
305StaticPopupDialogs["RESET_ALL"] = {
306	text = TukuiL.option_resetall,
307	OnAccept = function() 
308		TukuiConfigSettings = nil
309		TukuiConfig = nil
310		ReloadUI() 
311	end,
312	OnCancel = function() TukuiConfigCover:Hide() end,
313	button1 = ACCEPT,
314	button2 = CANCEL,
315	timeout = 0,
316	whileDead = 1,
317	preferredIndex = 3,
318}
319
320-- We wanna make sure we have all needed tables when we try add values
321local function SetValue(group,option,value)		
322	--Determine if we should be copying our default settings to our player settings, this only happens if we're not using player settings by default
323	local mergesettings
324	if TukuiConfig == TukuiConfigSettings then
325		mergesettings = true
326	else
327		mergesettings = false
328	end
329
330	if TukuiConfigAll[myPlayerRealm][myPlayerName] == true then
331		if not TukuiConfig then TukuiConfig = {} end	
332		if not TukuiConfig[group] then TukuiConfig[group] = {} end
333		TukuiConfig[group][option] = value
334	else
335		--Set PerChar settings to the same as our settings if theres no per char settings
336		if mergesettings == true then
337			if not TukuiConfig then TukuiConfig = {} end	
338			if not TukuiConfig[group] then TukuiConfig[group] = {} end
339			TukuiConfig[group][option] = value
340		end
341		
342		if not TukuiConfigSettings then TukuiConfigSettings = {} end
343		if not TukuiConfigSettings[group] then TukuiConfigSettings[group] = {} end
344		TukuiConfigSettings[group][option] = value
345	end
346end
347
348local VISIBLE_GROUP = nil
349local function ShowGroup(group)
350	local T, C, L = unpack(Tukui)
351	if(VISIBLE_GROUP) then
352		_G["TukuiConfigUI"..VISIBLE_GROUP]:Hide()
353	end
354	if _G["TukuiConfigUI"..group] then
355		local o = "TukuiConfigUI"..group
356		Local(o)
357		_G["TukuiConfigUITitle"]:SetText(T.option)
358		local height = _G["TukuiConfigUI"..group]:GetHeight()
359		_G["TukuiConfigUI"..group]:Show()
360		local scrollamntmax = 305
361		local scrollamntmin = scrollamntmax - 10
362		local max = height > scrollamntmax and height-scrollamntmin or 1
363		
364		if max == 1 then
365			_G["TukuiConfigUIGroupSlider"]:SetValue(1)
366			_G["TukuiConfigUIGroupSlider"]:Hide()
367		else
368			_G["TukuiConfigUIGroupSlider"]:SetMinMaxValues(0, max)
369			_G["TukuiConfigUIGroupSlider"]:Show()
370			_G["TukuiConfigUIGroupSlider"]:SetValue(1)
371		end
372		_G["TukuiConfigUIGroup"]:SetScrollChild(_G["TukuiConfigUI"..group])
373		
374		local x
375		if TukuiConfigUIGroupSlider:IsShown() then 
376			_G["TukuiConfigUIGroup"]:EnableMouseWheel(true)
377			_G["TukuiConfigUIGroup"]:SetScript("OnMouseWheel", function(self, delta)
378				if TukuiConfigUIGroupSlider:IsShown() then
379					if delta == -1 then
380						x = _G["TukuiConfigUIGroupSlider"]:GetValue()
381						_G["TukuiConfigUIGroupSlider"]:SetValue(x + 10)
382					elseif delta == 1 then
383						x = _G["TukuiConfigUIGroupSlider"]:GetValue()			
384						_G["TukuiConfigUIGroupSlider"]:SetValue(x - 30)	
385					end
386				end
387			end)
388		else
389			_G["TukuiConfigUIGroup"]:EnableMouseWheel(false)
390		end		
391		VISIBLE_GROUP = group
392	end
393end
394
395function CreateTukuiConfigUI()
396	local T, C, L = unpack(Tukui)
397	
398	if TukuiConfigUI then
399		ShowGroup("general")
400		TukuiConfigUI:Show()
401		return
402	end
403	
404	local version = tonumber(T.version)
405	if version < 12.59 then
406		print(TukuiL.option_update)
407	end
408	
409	-- MAIN FRAME
410	local TukuiConfigUI = CreateFrame("Frame","TukuiConfigUI",UIParent)
411	TukuiConfigUI:SetPoint("CENTER", UIParent, "CENTER", 90, 0)
412	TukuiConfigUI:SetWidth(550)
413	TukuiConfigUI:SetHeight(300)
414	TukuiConfigUI:SetFrameStrata("DIALOG")
415	TukuiConfigUI:SetFrameLevel(20)
416	
417	-- TITLE 2
418	local TukuiConfigUITitleBox = CreateFrame("Frame","TukuiConfigUI",TukuiConfigUI)
419	TukuiConfigUITitleBox:SetWidth(570)
420	TukuiConfigUITitleBox:SetHeight(24)
421	TukuiConfigUITitleBox:SetPoint("TOPLEFT", -10, 42)
422	TukuiConfigUITitleBox:SetTemplate("Default")
423	TukuiConfigUITitleBox:CreateShadow("Default")
424	
425	local title = TukuiConfigUITitleBox:CreateFontString("TukuiConfigUITitle", "OVERLAY")
426	title:SetFont(C.media.font, 12)
427	title:SetPoint("LEFT", TukuiConfigUITitleBox, "LEFT", 4, 0)
428		
429	local TukuiConfigUIBG = CreateFrame("Frame","TukuiConfigUI",TukuiConfigUI)
430	TukuiConfigUIBG:SetPoint("TOPLEFT", -10, 10)
431	TukuiConfigUIBG:SetPoint("BOTTOMRIGHT", 10, -10)
432	TukuiConfigUIBG:SetTemplate("Default")
433	TukuiConfigUIBG:CreateShadow("Default")
434	
435	-- GROUP SELECTION ( LEFT SIDE )
436	local groups = CreateFrame("ScrollFrame", "TukuiCatagoryGroup", TukuiConfigUI)
437	groups:SetPoint("TOPLEFT",-180,0)
438	groups:SetWidth(150)
439	groups:SetHeight(300)
440
441	local groupsBG = CreateFrame("Frame","TukuiConfigUI",TukuiConfigUI)
442	groupsBG:SetPoint("TOPLEFT", groups, -10, 10)
443	groupsBG:SetPoint("BOTTOMRIGHT", groups, 10, -10)
444	groupsBG:SetTemplate("Default")
445	groupsBG:CreateShadow("Default")
446	
447	--This is our frame we will use to prevent clicking on the config, before you choose a popup window
448	local TukuiConfigCover = CreateFrame("Frame", "TukuiConfigCover", TukuiConfigUI)
449	TukuiConfigCover:SetPoint("TOPLEFT", TukuiCatagoryGroup, "TOPLEFT")
450	TukuiConfigCover:SetPoint("BOTTOMRIGHT", TukuiConfigUI, "BOTTOMRIGHT")
451	TukuiConfigCover:SetFrameLevel(TukuiConfigUI:GetFrameLevel() + 20)
452	TukuiConfigCover:EnableMouse(true)
453	TukuiConfigCover:SetScript("OnMouseDown", function(self) print(TukuiL.option_makeselection) end)
454	TukuiConfigCover:Hide()	
455		
456	local slider = CreateFrame("Slider", "TukuiConfigUICatagorySlider", groups)
457	slider:SetPoint("TOPRIGHT", 0, 0)
458	slider:SetWidth(20)
459	slider:SetHeight(300)
460	slider:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
461	slider:SetOrientation("VERTICAL")
462	slider:SetValueStep(20)
463	slider:SetScript("OnValueChanged", function(self,value) groups:SetVerticalScroll(value) end)
464	slider:SetTemplate("Default")
465	local r,g,b,a = unpack(C["media"].bordercolor)
466	slider:SetBackdropColor(r,g,b,0.2)
467	local child = CreateFrame("Frame",nil,groups)
468	child:SetPoint("TOPLEFT")
469	local offset=5
470	for group in pairs(ALLOWED_GROUPS) do
471		local o = "TukuiConfigUI"..group
472		Local(o)
473		local button = NewButton(T.option, child)
474		button:SetHeight(16)
475		button:SetWidth(125)
476		button:SetPoint("TOPLEFT", 5,-(offset))
477		button:SetScript("OnClick", function(self) ShowGroup(group) end)		
478		offset=offset+20
479	end
480	child:SetWidth(125)
481	child:SetHeight(offset)
482	slider:SetMinMaxValues(0, (offset == 0 and 1 or offset-12*25))
483	slider:SetValue(1)
484	groups:SetScrollChild(child)
485	
486	local x
487	_G["TukuiCatagoryGroup"]:EnableMouseWheel(true)
488	_G["TukuiCatagoryGroup"]:SetScript("OnMouseWheel", function(self, delta)
489		if _G["TukuiConfigUICatagorySlider"]:IsShown() then
490			if delta == -1 then
491				x = _G["TukuiConfigUICatagorySlider"]:GetValue()
492				_G["TukuiConfigUICatagorySlider"]:SetValue(x + 10)
493			elseif delta == 1 then
494				x = _G["TukuiConfigUICatagorySlider"]:GetValue()			
495				_G["TukuiConfigUICatagorySlider"]:SetValue(x - 20)	
496			end
497		end
498	end)
499	
500	-- GROUP SCROLLFRAME ( RIGHT SIDE)
501	local group = CreateFrame("ScrollFrame", "TukuiConfigUIGroup", TukuiConfigUI)
502	group:SetPoint("TOPLEFT",0,5)
503	group:SetWidth(550)
504	group:SetHeight(300)
505	local slider = CreateFrame("Slider", "TukuiConfigUIGroupSlider", group)
506	slider:SetPoint("TOPRIGHT",0,0)
507	slider:SetWidth(20)
508	slider:SetHeight(300)
509	slider:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
510	slider:SetOrientation("VERTICAL")
511	slider:SetValueStep(20)
512	slider:SetTemplate("Default")
513	local r,g,b,a = unpack(C["media"].bordercolor)
514	slider:SetBackdropColor(r,g,b,0.2)
515	slider:SetScript("OnValueChanged", function(self,value) group:SetVerticalScroll(value) end)
516	
517	for group in pairs(ALLOWED_GROUPS) do
518		local frame = CreateFrame("Frame","TukuiConfigUI"..group,TukuiConfigUIGroup)
519		frame:SetPoint("TOPLEFT")
520		frame:SetWidth(325)
521	
522		local offset=5
523
524		if type(C[group]) ~= "table" then error(group.." GroupName not found in config table.") return end
525		for option,value in pairs(C[group]) do
526
527			if type(value) == "boolean" then
528				local button = CreateFrame("CheckButton", "TukuiConfigUI"..group..option, frame, "InterfaceOptionsCheckButtonTemplate")
529				local o = "TukuiConfigUI"..group..option
530				Local(o)
531				_G["TukuiConfigUI"..group..option.."Text"]:SetText(T.option)
532				_G["TukuiConfigUI"..group..option.."Text"]:SetFont(C.media.font, 12)
533				button:SetChecked(value)
534				button:SetScript("OnClick", function(self) SetValue(group,option,(self:GetChecked() and true or false)) end)
535				button:SetPoint("TOPLEFT", 5, -(offset))
536				offset = offset+25
537			elseif type(value) == "number" or type(value) == "string" then
538				local label = frame:CreateFontString(nil,"OVERLAY",nil)
539				label:SetFont(C.media.font,12)
540				local o = "TukuiConfigUI"..group..option
541				Local(o)
542				label:SetText(T.option)
543				label:SetWidth(420)
544				label:SetHeight(20)
545				label:SetJustifyH("LEFT")
546				label:SetPoint("TOPLEFT", 5, -(offset))
547				
548				local editbox = CreateFrame("EditBox", nil, frame)
549				editbox:SetAutoFocus(false)
550				editbox:SetMultiLine(false)
551				editbox:SetWidth(280)
552				editbox:SetHeight(20)
553				editbox:SetMaxLetters(255)
554				editbox:SetTextInsets(3,0,0,0)
555				editbox:SetBackdrop({
556					bgFile = [=[Interface\Addons\Tukui\media\textures\blank]=], 
557					tiled = false,
558				})
559				editbox:SetBackdropColor(0,0,0,0.5)
560				editbox:SetBackdropBorderColor(0,0,0,1)
561				editbox:SetFontObject(GameFontHighlight)
562				editbox:SetPoint("TOPLEFT", 5, -(offset+20))
563				editbox:SetText(value)
564				
565				editbox:SetTemplate("Default")
566				
567				local okbutton = CreateFrame("Button", nil, frame)
568				okbutton:SetHeight(editbox:GetHeight())
569				okbutton:SetWidth(editbox:GetHeight())
570				okbutton:SetTemplate("Default")
571				okbutton:SetPoint("LEFT", editbox, "RIGHT", 2, 0)
572				
573				local oktext = okbutton:CreateFontString(nil,"OVERLAY",nil)
574				oktext:SetFont(C.media.font,12)
575				oktext:SetText("OK")
576				oktext:SetPoint("CENTER", T.Scale(1), 0)
577				oktext:SetJustifyH("CENTER")
578				okbutton:Hide()
579 
580				if type(value) == "number" then
581					editbox:SetScript("OnEscapePressed", function(self) okbutton:Hide() self:ClearFocus() self:SetText(value) end)
582					editbox:SetScript("OnChar", function(self) okbutton:Show() end)
583					editbox:SetScript("OnEnterPressed", function(self) okbutton:Hide() self:ClearFocus() SetValue(group,option,tonumber(self:GetText())) end)
584					okbutton:SetScript("OnMouseDown", function(self) editbox:ClearFocus() self:Hide() SetValue(group,option,tonumber(editbox:GetText())) end)
585				else
586					editbox:SetScript("OnEscapePressed", function(self) okbutton:Hide() self:ClearFocus() self:SetText(value) end)
587					editbox:SetScript("OnChar", function(self) okbutton:Show() end)
588					editbox:SetScript("OnEnterPressed", function(self) okbutton:Hide() self:ClearFocus() SetValue(group,option,tostring(self:GetText())) end)
589					okbutton:SetScript("OnMouseDown", function(self) editbox:ClearFocus() self:Hide() SetValue(group,option,tostring(editbox:GetText())) end)
590				end
591				offset = offset+45
592			elseif type(value) == "table" and not TableFilter[option] then
593				local label = frame:CreateFontString(nil,"OVERLAY",nil)
594				label:SetFont(C.media.font,12)
595				local o = "TukuiConfigUI"..group..option
596				Local(o)
597				label:SetText(T.option)
598				label:SetWidth(420)
599				label:SetHeight(20)
600				label:SetJustifyH("LEFT")
601				label:SetPoint("TOPLEFT", 5, -(offset))
602				
603				colorbuttonname = (label:GetText().."ColorPicker")
604				local colorbutton = CreateFrame("Button", colorbuttonname, frame)
605				colorbutton:SetHeight(20)
606				colorbutton:SetWidth(50)
607				colorbutton:SetTemplate("Default")
608				colorbutton:SetBackdropBorderColor(unpack(value))
609				colorbutton:SetPoint("LEFT", label, "RIGHT", 2, 0)
610				local colortext = colorbutton:CreateFontString(nil,"OVERLAY",nil)
611				colortext:SetFont(C.media.font,12)
612				colortext:SetText("Set Color")
613				colortext:SetPoint("CENTER")
614				colortext:SetJustifyH("CENTER")
615				
616				
617				local function round(number, decimal)
618					return (("%%.%df"):format(decimal)):format(number)
619				end	
620				
621				colorbutton:SetScript("OnMouseDown", function(button) 
622					if ColorPickerFrame:IsShown() then return end
623					local oldr, oldg, oldb, olda = unpack(value)
624
625					local function ShowColorPicker(r, g, b, a, changedCallback, sameCallback)
626						HideUIPanel(ColorPickerFrame)
627						ColorPickerFrame.button = button
628						ColorPickerFrame:SetColorRGB(r,g,b)
629						ColorPickerFrame.hasOpacity = (a ~= nil and a < 1)
630						ColorPickerFrame.opacity = a
631						ColorPickerFrame.previousValues = {oldr, oldg, oldb, olda}
632						ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = changedCallback, changedCallback, sameCallback;
633						ShowUIPanel(ColorPickerFrame)
634					end
635										
636					local function ColorCallback(restore)
637						-- Something change
638						if restore ~= nil or button ~= ColorPickerFrame.button then return end
639
640						local newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB()
641						
642						value = { newR, newG, newB, newA }
643						SetValue(group,option,(value)) 
644						button:SetBackdropBorderColor(newR, newG, newB, newA)	
645					end
646					
647					local function SameColorCallback()
648						value = { oldr, oldg, oldb, olda }
649						SetValue(group,option,(value))
650						button:SetBackdropBorderColor(oldr, oldg, oldb, olda)
651					end
652										
653					ShowColorPicker(oldr, oldg, oldb, olda, ColorCallback, SameColorCallback)
654				end)
655				
656				offset = offset+25
657			end
658		end
659				
660		frame:SetHeight(offset)
661		frame:Hide()
662	end
663
664	local reset = NewButton(TukuiL.option_button_reset, TukuiConfigUI)
665	reset:SetWidth(100)
666	reset:SetHeight(20)
667	reset:SetPoint("BOTTOMLEFT",-10, -38)
668	reset:SetScript("OnClick", function(self) 
669		TukuiConfigCover:Show()
670		if TukuiConfigAll[myPlayerRealm][myPlayerName] == true then
671			StaticPopup_Show("RESET_PERCHAR")
672		else
673			StaticPopup_Show("RESET_ALL")
674		end
675	end)
676	reset:SetTemplate("Default")
677	reset:CreateShadow("Default")
678	
679	local close = NewButton(TukuiL.option_button_close, TukuiConfigUI)
680	close:SetWidth(100)
681	close:SetHeight(20)
682	close:SetPoint("BOTTOMRIGHT", 10, -38)
683	close:SetScript("OnClick", function(self) TukuiConfigUI:Hide() end)
684	close:SetTemplate("Default")
685	close:CreateShadow("Default")
686	
687	local load = NewButton(TukuiL.option_button_load, TukuiConfigUI)
688	load:SetHeight(20)
689	load:SetPoint("LEFT", reset, "RIGHT", 15, 0)
690	load:SetPoint("RIGHT", close, "LEFT", -15, 0)
691	load:SetScript("OnClick", function(self) ReloadUI() end)
692	load:SetTemplate("Default")
693	load:CreateShadow("Default")
694	
695	if TukuiConfigAll then
696		local button = CreateFrame("CheckButton", "TukuiConfigAllCharacters", TukuiConfigUITitleBox, "InterfaceOptionsCheckButtonTemplate")
697		
698		button:SetScript("OnClick", function(self) StaticPopup_Show("PERCHAR") TukuiConfigCover:Show() end)
699		
700		button:SetPoint("RIGHT", TukuiConfigUITitleBox, "RIGHT",-3, 0)	
701		
702		local label = TukuiConfigAllCharacters:CreateFontString(nil,"OVERLAY",nil)
703		label:SetFont(C.media.font,12)
704		
705		label:SetText(TukuiL.option_setsavedsetttings)
706		label:SetPoint("RIGHT", button, "LEFT")
707		
708		if TukuiConfigAll[myPlayerRealm][myPlayerName] == true then
709			button:SetChecked(true)
710		else
711			button:SetChecked(false)
712		end
713	end	
714	
715	ShowGroup("general")
716end
717
718do
719	SLASH_CONFIG1 = '/tc'
720	SLASH_CONFIG2 = '/tukui'
721	function SlashCmdList.CONFIG(msg, editbox)
722		if not TukuiConfigUI or not TukuiConfigUI:IsShown() then
723			CreateTukuiConfigUI()
724		else
725			TukuiConfigUI:Hide()
726		end
727	end
728	
729	SLASH_RESETCONFIG1 = '/resetconfig'
730	function SlashCmdList.RESETCONFIG()
731		if TukuiConfigUI and TukuiConfigUI:IsShown() then TukuiConfigCover:Show() end
732		
733		if TukuiConfigAll[myPlayerRealm][myPlayerName] == true then
734			StaticPopup_Show("RESET_PERCHAR")
735		else
736			StaticPopup_Show("RESET_ALL")
737		end	
738	end
739end