Guest User

PR_config.lua

a guest
Jul 16th, 2014
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.54 KB | None | 0 0
  1. local addonName, addon = ...
  2. local L = addon
  3.  
  4. function addon.CreateConfig()
  5.  
  6. addon.panel = CreateFrame("Frame", addonName.."panel", UIParent)
  7. addon.panel.name = "PhotoRobot"
  8. InterfaceOptions_AddCategory(addon.panel)
  9.  
  10. addon.title = addon.panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  11. addon.title:SetPoint("TOPLEFT", 16, -16)
  12. addon.title:SetText(L["PhotoRobot Config"])
  13.  
  14. addon.subtitle = addon.panel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  15. addon.subtitle:SetPoint("TOPLEFT", addon.title, "BOTTOMLEFT", 0, -8)
  16. addon.subtitle:SetNonSpaceWrap(true)
  17. addon.subtitle:SetText("v"..addon.version)
  18. addon.subtitle:SetTextColor(1, 1, 1, 0.5)
  19.  
  20. ----------------------------------
  21. -- panel 1 start
  22. ----------------------------------
  23.  
  24. addon.submenu1 = CreateFrame("Frame", addonName.."submenu1", addon.panel)
  25. addon.submenu1.name = "Display"
  26. addon.submenu1.parent = addon.panel.name
  27. InterfaceOptions_AddCategory(addon.submenu1)
  28. local p1 = addon.submenu1
  29.  
  30. p1.title = p1:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  31. p1.title:SetPoint("TOPLEFT", addon.submenu1, "TOPLEFT", 16, -16)
  32. p1.title:SetText(L["Display"])
  33.  
  34. p1.subtitle = p1:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  35. p1.subtitle:SetPoint("TOPLEFT", p1.title, "BOTTOMLEFT", 0, -8)
  36. p1.subtitle:SetNonSpaceWrap(true)
  37. p1.subtitle:SetText(L["Display Settings"])
  38.  
  39. addon.dropdown1 = CreateFrame("Frame", addonName.."dropdown1", p1, "UIDropDownMenuTemplate")
  40. addon.dropdown1:SetPoint("TOPLEFT", p1.subtitle, "BOTTOMLEFT", -10, -30)
  41. addon.dropdown1:SetWidth(40)
  42. addon.dropdown1.font = addon.dropdown1:CreateFontString(addonName.."dropdownFont", "ARTWORK", "GameFontNormalSmall")
  43. addon.dropdown1.font:SetPoint("BOTTOMLEFT", addon.dropdown1, "TOPLEFT", 20, 0)
  44. addon.dropdown1.font:SetText(L["Font Size:"])
  45. _G[addon.dropdown1:GetName().."Button"]:SetScript("OnClick", function(self, button, down)
  46. ToggleDropDownMenu(1, nil, addon.dropdown1, self:GetName(), -100 ,0)
  47. end)
  48.  
  49. local info = {}
  50.  
  51. function addon.dropdown1.initialize(self, level)
  52. if not level then return end
  53. wipe(info)
  54. if level == 1 then
  55. addon.CreateMenu(info)
  56. end
  57. end
  58.  
  59. function addon.OnClickFunc(button, arg1, arg2, checked)
  60. addon.db.fontSize = arg1
  61. local newfont, size = _G[arg2]:GetFont()
  62. addon.testFont:SetFont(newfont, size, "OUTLINE")
  63. addon.testFont2:SetFont(newfont, size/1.3, "OUTLINE")
  64. addon.arenaTextureFrame.font:SetFont(newfont, size/1.3, "OUTLINE")
  65. -- print("selected " .. arg1, arg2)
  66. UIDropDownMenu_SetText(addon.dropdown1, arg1)
  67. end
  68.  
  69. function addon.CreateMenu(info)
  70. for k, v in pairs(addon.fontsDB) do
  71. info.text = k
  72. info.isTitle = nil
  73. info.notCheckable = nil
  74. info.func = addon.OnClickFunc
  75. info.arg1 = k
  76. info.arg2 = v
  77. info.fontObject = addon[k]
  78. info.checked = addon.isCurrent(k)
  79. UIDropDownMenu_AddButton(info)
  80. end
  81. end
  82.  
  83. function addon.isCurrent(font)
  84. if addon.db.fontSize == font then
  85. return true
  86. else
  87. return false
  88. end
  89. end
  90.  
  91. addon.texture = p1:CreateTexture()
  92. addon.texture:SetTexture("Interface\\Icons\\Spell_Holy_SealOfValor")
  93. addon.texture:SetPoint("LEFT", addon.dropdown1, "RIGHT", 200, 0)
  94.  
  95. addon.testFont = p1:CreateFontString(nil, "ARTWORK")
  96. addon.testFont:SetPoint("CENTER", addon.texture, "CENTER")
  97. local newfont, size = _G[addon.fontsDB[addon.db.fontSize]]:GetFont()
  98. addon.testFont:SetFont(newfont, size, "OUTLINE")
  99. addon.testFont:SetText("8.2")
  100. addon.testFont:SetTextColor(addon.db.r, addon.db.g, addon.db.b, addon.db.a)
  101.  
  102. addon.texture2 = p1:CreateTexture()
  103. addon.texture2:SetTexture("Interface\\Icons\\Spell_Shadow_NetherCloak")
  104. addon.texture2:SetPoint("LEFT", addon.texture, "RIGHT", 0, 0)
  105. addon.texture2:SetHeight(40)
  106. addon.texture2:SetWidth(40)
  107.  
  108. addon.testFont2 = p1:CreateFontString(nil, "ARTWORK")
  109. addon.testFont2:SetPoint("CENTER", addon.texture2, "CENTER")
  110. local newfont, size = _G[addon.fontsDB[addon.db.fontSize]]:GetFont()
  111. addon.testFont2:SetFont(newfont, size/1.3, "OUTLINE")
  112. addon.testFont2:SetText("4.9")
  113. addon.testFont2:SetTextColor(addon.db.r, addon.db.g, addon.db.b, addon.db.a)
  114.  
  115. addon.colorButton = CreateFrame("Button", nil, p1, "OptionsCheckButtonTemplate")
  116. local frame = addon.colorButton
  117. frame:SetPoint("TOPLEFT", addon.dropdown1, "BOTTOMLEFT", 20, -10)
  118. frame:SetHighlightTexture("Interface\\Buttons\\CheckButtonHilight")
  119. frame:SetScript("OnClick", function(self)
  120. addon.ShowColorPicker(addon.db.r, addon.db.g, addon.db.b, addon.myColorCallback);
  121. end)
  122.  
  123. frame.texture = frame:CreateTexture(nil, "OVERLAY")
  124. frame.texture:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
  125. frame.texture:SetTexture(addon.db.r, addon.db.g, addon.db.b)
  126. frame.texture:SetPoint("CENTER", frame, "CENTER")
  127. frame.texture:SetHeight(frame:GetHeight()/2)
  128. frame.texture:SetWidth(frame:GetHeight()/2)
  129.  
  130. frame.text = frame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  131. frame.text:SetPoint("LEFT", frame, "RIGHT")
  132. frame.text:SetText(L["Font Color"])
  133. frame.text:SetTextColor(1, 1, 1)
  134.  
  135. p1.checkbox1 = CreateFrame("CheckButton", addonName.."p1_checkbox1", p1, "ChatConfigCheckButtonTemplate")
  136. p1.checkbox1:SetPoint("TOPLEFT", addon.colorButton, "BOTTOMLEFT", 0, -5)
  137. _G[p1.checkbox1:GetName().."Text"]:SetText(L["Show Decimals"])
  138. _G[p1.checkbox1:GetName().."Text"]:SetPoint("LEFT", p1.checkbox1, "RIGHT", 3, 1)
  139. p1.checkbox1.tooltip = L["Click to toggle decimal display on frames"]
  140. p1.checkbox1:Show()
  141. p1.checkbox1:SetScript("OnClick", function(self, button, down)
  142. if p1.checkbox1:GetChecked() then
  143. addon.db.showDecimals = true
  144. addon.testFont:SetText("8.2")
  145. addon.testFont2:SetText("4.9")
  146. addon.arenaTextureFrame.font:SetText("2.7")
  147. else
  148. addon.testFont:SetText("8")
  149. addon.testFont2:SetText("4")
  150. addon.arenaTextureFrame.font:SetText("2")
  151. addon.db.showDecimals = false
  152. end
  153. end)
  154.  
  155. p1.font = p1:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  156. p1.font:SetPoint("TOPLEFT", p1.checkbox1, "BOTTOMLEFT", 5, -30)
  157. p1.font:SetText(L["Font Position:"])
  158. p1.font:SetTextColor(1, 1, 1)
  159.  
  160. function addon.Text_SetPoint(self)
  161. local id, parent = self:GetID(), "CENTER"
  162. if id == 1 then
  163. parent = "CENTER"
  164. elseif id == 2 then
  165. parent = "TOP"
  166. elseif id == 3 then
  167. parent = "BOTTOM"
  168. elseif id == 4 then
  169. parent = "RIGHT"
  170. elseif id == 5 then
  171. parent = "LEFT"
  172. end
  173. addon.UpdateFontParent(parent)
  174. addon.db.fontParent = parent
  175. end
  176.  
  177. for i = 1, 5 do
  178. local button = CreateFrame("Button", "pt_btn"..i, p1, "UIPanelButtonTemplate")
  179. button:SetHeight(25)
  180. button:SetWidth(25)
  181. button:SetID(i)
  182. button:SetScript("OnClick", addon.Text_SetPoint)
  183. end
  184.  
  185. pt_btn1:SetPoint("LEFT", p1.font, "RIGHT", 50, 0)
  186. pt_btn2:SetPoint("BOTTOM", pt_btn1, "TOP")
  187. pt_btn3:SetPoint("TOP", pt_btn1, "BOTTOM")
  188. pt_btn4:SetPoint("LEFT", pt_btn1, "RIGHT")
  189. pt_btn5:SetPoint("RIGHT", pt_btn1, "LEFT")
  190.  
  191. addon.slider1 = CreateFrame("Slider", addonName.."slider1", p1, "OptionsSliderTemplate")
  192. addon.slider1:SetPoint("TOPLEFT", p1.font, "BOTTOMLEFT", 0, -70)
  193. _G[addon.slider1:GetName().."Text"]:SetText(L["Arena Frame Scale: "] .. string.format("%.0f", addon.db.arenaFrameScale*100).."%")
  194. addon.slider1.tooltipText = L["Drag to set Arena Frame Scale"]
  195. _G[addon.slider1:GetName().."Low"]:SetText("100%")
  196. _G[addon.slider1:GetName().."High"]:SetText("200%")
  197. addon.slider1:SetWidth(155)
  198. addon.slider1:SetMinMaxValues(1, 2)
  199. addon.slider1:SetValue(addon.db.arenaFrameScale)
  200. addon.slider1:SetValueStep(0.1)
  201. addon.slider1:SetScript("OnValueChanged", function(self, value)
  202. addon.db.arenaFrameScale = value
  203. _G[addon.slider1:GetName().."Text"]:SetText(L["Arena Frame Scale: "] .. string.format("%.0f", value*100).."%")
  204. addon.arenaTextureFrame:SetScale(value)
  205. end)
  206.  
  207. addon.arenaTextureFrame = CreateFrame("Frame", nil, p1)
  208. addon.arenaTextureFrame.tex = addon.arenaTextureFrame:CreateTexture(nil, "OVERLAY")
  209. addon.arenaTextureFrame.tex:SetTexture("Interface\\ArenaEnemyFrame\\UI-ArenaTargetingFrame")
  210. addon.arenaTextureFrame.tex:SetTexCoord(0, 0.796, 0, 0.5)
  211. addon.arenaTextureFrame.tex:SetPoint("TOPLEFT", addon.slider1, "BOTTOMLEFT", 20, -10)
  212. addon.arenaTextureFrame.tex:SetWidth(102)
  213. addon.arenaTextureFrame.tex:SetHeight(32)
  214. addon.arenaTextureFrame.port = addon.arenaTextureFrame:CreateTexture(nil, "ARTWORK")
  215. SetPortraitToTexture(addon.arenaTextureFrame.port, "Interface\\Icons\\Ability_Rogue_KidneyShot")
  216. addon.arenaTextureFrame.port:SetPoint("RIGHT", addon.arenaTextureFrame.tex, "RIGHT", -2, 0)
  217. addon.arenaTextureFrame.port:SetWidth(25)
  218. addon.arenaTextureFrame.port:SetHeight(25)
  219.  
  220. addon.numberFrame = CreateFrame("Frame", nil, p1)
  221. addon.numberFrame:SetFrameStrata("DIALOG")
  222. addon.arenaTextureFrame.font = addon.numberFrame:CreateFontString(nil, "OVERLAY")
  223. addon.arenaTextureFrame.font:SetPoint("CENTER", addon.arenaTextureFrame.port, "CENTER")
  224. local newfont, size = _G[addon.fontsDB[addon.db.fontSize]]:GetFont()
  225. addon.arenaTextureFrame.font:SetFont(newfont, size/1.3, "OUTLINE")
  226. addon.arenaTextureFrame.font:SetText("2.7")
  227. addon.arenaTextureFrame.font:SetTextColor(addon.db.r, addon.db.g, addon.db.b, addon.db.a)
  228.  
  229. ----------------------------------
  230. -- panel 1 end
  231. ----------------------------------
  232.  
  233. ----------------------------------
  234. -- panel 2 start
  235. ----------------------------------
  236. addon.submenu2 = CreateFrame("Frame", addonName.."submenu2", addon.panel)
  237. addon.submenu2.name = "Frames"
  238. addon.submenu2.parent = addon.panel.name
  239. InterfaceOptions_AddCategory(addon.submenu2)
  240. local p2 = addon.submenu2
  241.  
  242. p2.title = p2:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  243. p2.title:SetPoint("TOPLEFT", addon.submenu2, "TOPLEFT", 16, -16)
  244. p2.title:SetText(L["Frames"])
  245.  
  246. p2.subtitle = p2:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  247. p2.subtitle:SetPoint("TOPLEFT", p2.title, "BOTTOMLEFT", 0, -8)
  248. p2.subtitle:SetNonSpaceWrap(true)
  249. p2.subtitle:SetText(L["Frame Settings"])
  250.  
  251. addon.checkbox3 = CreateFrame("CheckButton", addonName.."checkbox3", p2, "ChatConfigCheckButtonTemplate")
  252. addon.checkbox3:SetPoint("LEFT", p2.subtitle, "LEFT", 0, -30)
  253. _G[addon.checkbox3:GetName().."Text"]:SetText(L["Enable on Player Frame"])
  254. _G[addon.checkbox3:GetName().."Text"]:SetPoint("LEFT", addon.checkbox3, "RIGHT", 3, 1)
  255. addon.checkbox3.tooltip = L["Click to toggle aura display on Player Frame"]
  256. addon.checkbox3:SetScript("OnClick", function(self, button, down)
  257. if addon.checkbox3:GetChecked() then
  258. addon.db.showPlayerAuras = true
  259. else
  260. addon.db.showPlayerAuras = false
  261. end
  262. end)
  263.  
  264. addon.checkbox1 = CreateFrame("CheckButton", addonName.."checkbox1", p2, "ChatConfigCheckButtonTemplate")
  265. addon.checkbox1:SetPoint("TOPLEFT", addon.checkbox3, "BOTTOMLEFT", 0, -5)
  266. _G[addon.checkbox1:GetName().."Text"]:SetText(L["Enable on Party Frames"])
  267. _G[addon.checkbox1:GetName().."Text"]:SetPoint("LEFT", addon.checkbox1, "RIGHT", 3, 1)
  268. addon.checkbox1.tooltip = L["Click to toggle aura display on Party Frames"]
  269. addon.checkbox1:Show()
  270. addon.checkbox1:SetScript("OnClick", function(self, button, down)
  271. if addon.checkbox1:GetChecked() then
  272. addon.db.showPartyAuras = true
  273. else
  274. addon.db.showPartyAuras = false
  275. end
  276. end)
  277.  
  278. addon.checkbox2 = CreateFrame("CheckButton", addonName.."checkbox2", p2, "ChatConfigCheckButtonTemplate")
  279. addon.checkbox2:SetPoint("TOPLEFT", addon.checkbox1, "BOTTOMLEFT", 15, -5)
  280. _G[addon.checkbox2:GetName().."Text"]:SetText(L["Always Show Blizzard Party Frames in Arena"])
  281. _G[addon.checkbox2:GetName().."Text"]:SetPoint("LEFT", addon.checkbox2, "RIGHT", 3, 1)
  282. addon.checkbox2.tooltip = L["Click to toggle Blizzard Party Frames display"]
  283. addon.checkbox2:Hide()
  284. addon.checkbox2:SetScript("OnClick", function(self, button, down)
  285. if addon.checkbox2:GetChecked() then
  286. addon.db.showPartyFrames = true
  287. else
  288. addon.db.showPartyFrames = false
  289. end
  290. end)
  291.  
  292. addon.checkbox4 = CreateFrame("CheckButton", addonName.."checkbox4", p2, "ChatConfigCheckButtonTemplate")
  293. addon.checkbox4:SetPoint("TOPLEFT", addon.checkbox1, "BOTTOMLEFT", 0, -35)
  294. _G[addon.checkbox4:GetName().."Text"]:SetText(L["Enable on Blizzard Arena Frames"])
  295. _G[addon.checkbox4:GetName().."Text"]:SetPoint("LEFT", addon.checkbox4, "RIGHT", 3, 1)
  296. addon.checkbox4.tooltip = L["Click to toggle aura display on Blizzard Arena Frames"]
  297. addon.checkbox4:SetScript("OnClick", function(self, button, down)
  298. if addon.checkbox4:GetChecked() then
  299. addon.db.showArenaAuras = true
  300. else
  301. addon.db.showArenaAuras = false
  302. end
  303. end)
  304. ----------------------------------
  305. -- panel 2 end
  306. ----------------------------------
  307. end
Advertisement
Add Comment
Please, Sign In to add comment