/Tukui_ConfigUI/core.lua

http://github.com/Asphyxia/Tukui · Lua · 739 lines · 623 code · 85 blank · 31 comment · 424 complexity · b22fbe907e6123c5f38e0653b942340d MD5 · raw file

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