Advertisement
Guest User

BasicUI_Datapanel,lua

a guest
Apr 17th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.19 KB | None | 0 0
  1. --[[
  2. All Credit for Datapanel.lua goes to Tuks.
  3. Tukui = http://www.tukui.org/download.php.
  4. Edited by Cokedriver.
  5. ]]
  6.  
  7. local Core = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  8. local Module = Core:NewModule("Datapanel", "AceEvent-3.0")
  9.  
  10. -- Constants (variables whose values are never altered):
  11. local PLAYER_CLASS = UnitClass("player")
  12. local PLAYER_NAME = UnitName("player")
  13. local PLAYER_REALM = GetRealmName()
  14. local SCREEN_WIDTH = tonumber(string.match(({GetScreenResolutions()})[GetCurrentResolution()], "(%d+)x+%d"))
  15. local TOC_VERSION = select(4, GetBuildInfo())
  16. local GAME_LOCALE = GetLocale()
  17.  
  18. -- Variables:
  19. local db, currentFightDPS, playerRole
  20. local hexa = "|cffffffff" -- not very descriptive names :(
  21.  
  22. -- Variables that point to frames or other objects:
  23. local MainPanel, LeftPanel, CenterPanel, RightPanel, BGPanel
  24.  
  25. ------------------------------------------------------------------------
  26. -- Local functions
  27.  
  28. local function RGBToHex(r, g, b)
  29. if r > 1 then r = 1 elseif r < 0 then r = 0 end
  30. if g > 1 then g = 1 elseif g < 0 then g = 0 end
  31. if b > 1 then b = 1 elseif b < 0 then b = 0 end
  32. return format("|cff%02x%02x%02x", r*255, g*255, b*255)
  33. end
  34.  
  35. local function HexToRGB(hex)
  36. local rhex, ghex, bhex = strsub(hex, 1, 2), strsub(hex, 3, 4), strsub(hex, 5, 6)
  37. return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
  38. end
  39.  
  40. local function ShortValue(v)
  41. if v >= 1e6 then
  42. return format("%.1fm", v / 1e6):gsub("%.?0+([km])$", "%1")
  43. elseif v >= 1e3 or v <= -1e3 then
  44. return format("%.1fk", v / 1e3):gsub("%.?0+([km])$", "%1")
  45. else
  46. return v
  47. end
  48. end
  49.  
  50. local function GetTooltipAnchor()
  51. local _, y = GetCursorPosition()
  52. if (y * 2) > UIParent:GetHeight() then
  53. return "ANCHOR_BOTTOM", 1, 3
  54. else
  55. return "ANCHOR_TOP", 1, -3
  56. end
  57. end
  58.  
  59. local function SetMainPanel()
  60. local db = Core.db.profile
  61.  
  62. if db.datapanel.location ~= "top" then
  63. MainPanel:SetPoint("BOTTOM", UIParent, 0, 0)
  64. MainPanel:SetWidth(1200)
  65. MainPanel:SetFrameLevel(1)
  66. MainMenuBar:ClearAllPoints()
  67. MainMenuBar:SetPoint("BOTTOM", MainPanel, "TOP", 0, -3)
  68.  
  69.  
  70. -- Hide Panels When in a Vehicle or Pet Battle
  71. MainPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
  72. MainPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")
  73. MainPanel:RegisterUnitEvent("PET_BATTLE_OPENING_START")
  74. MainPanel:RegisterUnitEvent("PET_BATTLE_CLOSE")
  75. MainPanel:RegisterUnitEvent("PLAYER_ENTERING_WORLD")
  76.  
  77. MainPanel:SetScript("OnEvent", function(self, event, ...)
  78. if event == "UNIT_ENTERING_VEHICLE" or event == "PET_BATTLE_OPENING_START" then
  79. self:Hide()
  80. elseif event == "UNIT_EXITED_VEHICLE" or event == "PET_BATTLE_CLOSE" or event == "PLAYER_ENTERING_WORLD" then
  81. SetMainPanel()
  82. self:Show()
  83. end
  84. end)
  85. else
  86. MainPanel:SetPoint("TOP", UIParent, 0, 0)
  87. MainPanel:SetWidth(SCREEN_WIDTH)
  88. end
  89. end
  90.  
  91. local function SetPanelLeft()
  92. local db = Core.db.profile
  93.  
  94. if db.datapanel.location ~= "top" then
  95. PanelLeft:SetPoint("LEFT", MainPanel, 5, 0)
  96. PanelLeft:SetHeight(35)
  97. PanelLeft:SetWidth(1200 / 3)
  98. PanelLeft:SetFrameStrata("MEDIUM")
  99. PanelLeft:SetFrameLevel(2)
  100. else
  101. PanelLeft:SetPoint("LEFT", MainPanel, 5, 0)
  102. PanelLeft:SetHeight(35)
  103. PanelLeft:SetWidth(SCREEN_WIDTH / 3)
  104. PanelLeft:SetFrameStrata("LOW")
  105. PanelLeft:SetFrameLevel(1)
  106. end
  107. end
  108.  
  109. local function SetPanelCenter()
  110. local db = Core.db.profile
  111.  
  112. if db.datapanel.location ~= "top" then
  113. PanelCenter:SetPoint("CENTER", MainPanel, 0, 0)
  114. PanelCenter:SetHeight(35)
  115. PanelCenter:SetWidth(1200 / 3)
  116. --PanelCenter:SetFrameStrata("MEDIUM")
  117. --PanelCenter:SetFrameLevel(1)
  118. else
  119. PanelCenter:SetPoint("CENTER", MainPanel, 0, 0)
  120. PanelCenter:SetHeight(35)
  121. PanelCenter:SetWidth(SCREEN_WIDTH / 3)
  122. PanelCenter:SetFrameStrata("LOW")
  123. PanelCenter:SetFrameLevel(1)
  124. end
  125. end
  126.  
  127. local function SetPanelRight()
  128. local db = Core.db.profile
  129.  
  130. if db.datapanel.location ~= "top" then
  131. PanelRight:SetPoint("RIGHT", MainPanel, -5, 0)
  132. PanelRight:SetHeight(35)
  133. PanelRight:SetWidth(1200 / 3)
  134. --PanelRight:SetFrameStrata("MEDIUM")
  135. --PanelRight:SetFrameLevel(1)
  136. else
  137. PanelRight:SetPoint("RIGHT", MainPanel, -5, 0)
  138. PanelRight:SetHeight(35)
  139. PanelRight:SetWidth(SCREEN_WIDTH / 3)
  140. PanelRight:SetFrameStrata("LOW")
  141. PanelRight:SetFrameLevel(1)
  142. end
  143. end
  144.  
  145. local function MoveObjects()
  146. local db = Core.db.profile
  147.  
  148. if db.datapanel.location ~= "top" then
  149. -- World Status
  150. WorldStateAlwaysUpFrame:ClearAllPoints()
  151. WorldStateAlwaysUpFrame:SetPoint('TOP', -20, -40)
  152.  
  153. -- Move the tooltip above the Actionbar
  154. hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self)
  155. self:SetPoint('BOTTOMRIGHT', UIParent, -95, 135)
  156. end)
  157.  
  158. -- Move the Bags above the Actionbar
  159. CONTAINER_WIDTH = 192;
  160. CONTAINER_SPACING = 5;
  161. VISIBLE_CONTAINER_SPACING = 3;
  162. CONTAINER_OFFSET_Y = 70;
  163. CONTAINER_OFFSET_X = 0;
  164.  
  165.  
  166. function UpdateContainerFrameAnchors()
  167. local _, xOffset, yOffset, _, _, _, _;
  168. local containerScale = 1;
  169. screenHeight = GetScreenHeight() / containerScale;
  170. -- Adjust the start anchor for bags depending on the multibars
  171. xOffset = CONTAINER_OFFSET_X / containerScale;
  172. yOffset = CONTAINER_OFFSET_Y / containerScale + 25;
  173. -- freeScreenHeight determines when to start a new column of bags
  174. freeScreenHeight = screenHeight - yOffset;
  175. column = 0;
  176. for index, frameName in ipairs(ContainerFrame1.bags) do
  177. frame = _G[frameName];
  178. frame:SetScale(containerScale);
  179. if ( index == 1 ) then
  180. -- First bag
  181. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -xOffset, yOffset );
  182. elseif ( freeScreenHeight < frame:GetHeight() ) then
  183. -- Start a new column
  184. column = column + 1;
  185. freeScreenHeight = screenHeight - yOffset;
  186. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -(column * CONTAINER_WIDTH) - xOffset, yOffset );
  187. else
  188. -- Anchor to the previous bag
  189. frame:SetPoint('BOTTOMRIGHT', ContainerFrame1.bags[index - 1], 'TOPRIGHT', 0, CONTAINER_SPACING);
  190. end
  191. freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
  192. end
  193. end
  194. else
  195. -- Player Frame
  196. PlayerFrame:ClearAllPoints()
  197. PlayerFrame:SetPoint("TOPLEFT", -19, -20)
  198.  
  199. -- Target Frame
  200. TargetFrame:ClearAllPoints()
  201. TargetFrame:SetPoint("TOPLEFT", 250, -20)
  202.  
  203. -- Minimap Frame
  204. MinimapCluster:ClearAllPoints()
  205. MinimapCluster:SetPoint('TOPRIGHT', 0, -32)
  206.  
  207. -- Buff Frame
  208. BuffFrame:ClearAllPoints()
  209. BuffFrame:SetPoint('TOP', MinimapCluster, -110, -2)
  210.  
  211. -- PvP Frame
  212. WorldStateAlwaysUpFrame:ClearAllPoints()
  213. WorldStateAlwaysUpFrame:SetPoint('TOP', 0, -32)
  214. end
  215. end
  216.  
  217. ------------------------------------------------------------------------
  218. -- Module functions
  219.  
  220. function Module:OnEnable()
  221. -- You should fix your DB to use module namespaces properly:
  222. local db = Core.db.profile
  223.  
  224. -- This line should not be needed if you're using modules correctly:
  225. --if not db.datapanel.enable then return end
  226.  
  227. if db.datapanel.enable then -- How is this different than "enable" ? If the panel is not enabled, what's the point of doing anything else?
  228. self:CreatePanel() -- factor this giant blob out into its own function to keep things clean
  229. end
  230.  
  231. if db.misc.classcolor then
  232. --local _, class = UnitClass("player")
  233. local color = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  234. hexa = RGBToHex(color.r, color.g, color.b) -- no need to format it yourself, it's already done
  235. else
  236. hexa = RGBToHex(db.datapanel.customcolor.r, db.datapanel.customcolor.g, db.datapanel.customcolor.b) -- no need to duplicate the code you already wrote into the function
  237. end
  238.  
  239. -- Rather than hardcode all the possible plugins here just use a nice table that you can add/remove stuff to much more easily. Scroll to the bottom to see it.
  240. self.plugins = {}
  241. for name, constructor in pairs(self.pluginConstructors) do
  242. local position = db.datapanel[name]
  243. if position and position > 0 then
  244. local plugin = constructor()
  245. self.plugins[name] = plugin
  246. self:PlacePlugin(position, plugin)
  247. end
  248. end
  249.  
  250. -- no need to make a separate frame to handle events, your module object already does this!
  251. self:UpdatePlayerRole()
  252. self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED", "UpdatePlayerRole")
  253. end
  254.  
  255. function Module:UpdatePlayerRole()
  256. local spec = GetSpecialization()
  257. local specRole = GetSpecializationRole(spec) -- no need for a giant table that must be maintained by hand
  258. if specRole == "TANK" then
  259. playerRole = "Tank"
  260. elseif specRole == "HEALER" then
  261. playerRole = "Caster"
  262. elseif specRole == "DAMAGER" then
  263. if UnitPowerType("player") == SPELL_POWER_MANA then
  264. playerRole = "Caster"
  265. else
  266. playerRole = "Melee"
  267. end
  268. else
  269. playerRole = nil -- no spec
  270. end
  271. end
  272.  
  273. function Module:SetFontString(parent, file, size, flags)
  274. local fs = parent:CreateFontString(nil, "OVERLAY")
  275. fs:SetFont(file, size, flags)
  276. fs:SetJustifyH("LEFT")
  277. fs:SetShadowColor(0, 0, 0)
  278. fs:SetShadowOffset(1.25, -1.25)
  279. return fs
  280. end
  281.  
  282. function Module:PlacePlugin(position, plugin)
  283. local left = PanelLeft
  284. local center = PanelCenter
  285. local right = PanelRight
  286.  
  287. -- Left Panel Data
  288. if position == 1 then
  289. plugin:SetParent(left)
  290. plugin:SetHeight(left:GetHeight())
  291. plugin:SetPoint('LEFT', left, 30, 0)
  292. plugin:SetPoint('TOP', left)
  293. plugin:SetPoint('BOTTOM', left)
  294. elseif position == 2 then
  295. plugin:SetParent(left)
  296. plugin:SetHeight(left:GetHeight())
  297. plugin:SetPoint('TOP', left)
  298. plugin:SetPoint('BOTTOM', left)
  299. elseif position == 3 then
  300. plugin:SetParent(left)
  301. plugin:SetHeight(left:GetHeight())
  302. plugin:SetPoint('RIGHT', left, -30, 0)
  303. plugin:SetPoint('TOP', left)
  304. plugin:SetPoint('BOTTOM', left)
  305.  
  306. -- Center Panel Data
  307. elseif position == 4 then
  308. plugin:SetParent(center)
  309. plugin:SetHeight(center:GetHeight())
  310. plugin:SetPoint('LEFT', center, 30, 0)
  311. plugin:SetPoint('TOP', center)
  312. plugin:SetPoint('BOTTOM', center)
  313. elseif position == 5 then
  314. plugin:SetParent(center)
  315. plugin:SetHeight(center:GetHeight())
  316. plugin:SetPoint('TOP', center)
  317. plugin:SetPoint('BOTTOM', center)
  318. elseif position == 6 then
  319. plugin:SetParent(center)
  320. plugin:SetHeight(center:GetHeight())
  321. plugin:SetPoint('RIGHT', center, -30, 0)
  322. plugin:SetPoint('TOP', center)
  323. plugin:SetPoint('BOTTOM', center)
  324.  
  325. -- Right Panel Data
  326. elseif position == 7 then
  327. plugin:SetParent(right)
  328. plugin:SetHeight(right:GetHeight())
  329. plugin:SetPoint('LEFT', right, 30, 0)
  330. plugin:SetPoint('TOP', right)
  331. plugin:SetPoint('BOTTOM', right)
  332. elseif position == 8 then
  333. plugin:SetParent(right)
  334. plugin:SetHeight(right:GetHeight())
  335. plugin:SetPoint('TOP', right)
  336. plugin:SetPoint('BOTTOM', right)
  337. elseif position == 9 then
  338. plugin:SetParent(right)
  339. plugin:SetHeight(right:GetHeight())
  340. plugin:SetPoint('RIGHT', right, -30, 0)
  341. plugin:SetPoint('TOP', right)
  342. plugin:SetPoint('BOTTOM', right)
  343. end
  344. end
  345.  
  346. function Module:CreatePanel()
  347. local db = Core.db.profile
  348.  
  349. if MainPanel then return end -- already done
  350.  
  351. -- These are not "local" here because they're already "local" at the top of the file.
  352. MainPanel = CreateFrame("Frame", "BasicUI_Datapanel", UIParent)
  353. PanelLeft = CreateFrame("Frame", nil, MainPanel)
  354. PanelCenter = CreateFrame("Frame", nil, MainPanel)
  355. PanelRight = CreateFrame("Frame", nil, MainPanel)
  356. BGPanel = CreateFrame("Frame", nil, MainPanel)
  357.  
  358.  
  359. -- These are common to all panel styles, so don't duplicate code.
  360. MainPanel:SetHeight(35)
  361. MainPanel:SetFrameStrata("LOW")
  362. MainPanel:SetBackdrop({ bgFile = db.datapanel.background, edgeFile = db.datapanel.border, edgeSize = 25, insets = { left = 5, right = 5, top = 5, bottom = 5 } })
  363. MainPanel:SetBackdropColor(0, 0, 0, 1)
  364.  
  365. -- Setup the Panels
  366. SetMainPanel()
  367. SetPanelLeft()
  368. SetPanelCenter()
  369. SetPanelRight()
  370.  
  371. -- No Need for function it always sets it self on the PanelLeft
  372. BGPanel:SetAllPoints(PanelLeft)
  373. BGPanel:SetFrameStrata("LOW")
  374. BGPanel:SetFrameLevel(1)
  375.  
  376. -- Move some Objects for the Datapanel
  377. MoveObjects()
  378.  
  379. end
  380.  
  381. ------------------------------------------------------------------------
  382. -- Panel creation
  383. -- This can be simplified hugely by using a table, instead of a bunch of if/end blocks.
  384.  
  385. Module.pluginConstructors = {
  386.  
  387. armor = function()
  388. local db = Core.db.profile
  389.  
  390. local plugin = CreateFrame("Frame", "StatArmor", MainPanel) -- proper parentage
  391. plugin:EnableMouse(true)
  392. plugin:SetFrameLevel(3)
  393. plugin:SetFrameStrata("BACKGROUND")
  394.  
  395. local Text = plugin:CreateFontString("StatArmorText", "OVERLAY") -- proper parentage
  396. Text:SetFont(db.media.fontNormal, db.media.fontSize, "THINOUTLINE")
  397. plugin.text = Text -- important!
  398.  
  399. plugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  400. plugin:RegisterUnitEvent("UNIT_AURA", "player") -- limit UNIT_* events to the player when possible
  401. plugin:RegisterUnitEvent("UNIT_INVENTORY_CHANGED", "player")
  402. plugin:SetScript("OnEvent", function()
  403. local _ , effectiveArmor = UnitArmor("player");
  404. plugin.text:SetFormattedText("%sArmor:|r %s", hexa, effectiveArmor)
  405. plugin:SetWidth(plugin.text:GetStringWidth()) -- important!
  406. end)
  407.  
  408. plugin:SetScript("OnEnter", function(self)
  409. if UnitAffectingCombat("player") then return end
  410.  
  411. local anchor, x, y = GetTooltipAnchor(self)
  412. GameTooltip:SetOwner(self, GameTooltip:SetOwner(self, anchor, x, y))
  413. GameTooltip:AddLine("Mitigation by Level:")
  414. GameTooltip:Show()
  415. end)
  416. plugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  417. plugin:SetScript("OnMouseDown", function(self, button)
  418. ToggleCharacter("PaperDollFrame")
  419. end)
  420.  
  421.  
  422. return plugin -- important!
  423. end,
  424.  
  425. bags = function()
  426. local db = Core.db.profile
  427.  
  428. local plugin = CreateFrame("Frame", nil, MainPanel) -- proper parentage
  429. plugin:EnableMouse(true)
  430.  
  431. local Text = plugin:CreateFontString(nil, "OVERLAY") -- proper parentage
  432. Text:SetFont(db.media.fontNormal, db.media.fontSize,"THINOUTLINE")
  433. --plugin.text = Text -- important!
  434.  
  435. local Profit = 0
  436. local Spent = 0
  437. local OldMoney = 0
  438. local myPlayerRealm = GetRealmName();
  439.  
  440.  
  441. local function formatMoney(c)
  442. local str = ""
  443. if not c or c < 0 then
  444. return str
  445. end
  446.  
  447. if c >= 10000 then
  448. local g = math.floor(c/10000)
  449. c = c - g*10000
  450. str = str..BreakUpLargeNumbers(g).."|cFFFFD800g|r "
  451. end
  452. if c >= 100 then
  453. local s = math.floor(c/100)
  454. c = c - s*100
  455. str = str..s.."|cFFC7C7C7s|r "
  456. end
  457. if c >= 0 then
  458. str = str..c.."|cFFEEA55Fc|r"
  459. end
  460.  
  461. return str
  462. end
  463. plugin:RegisterEvent("PLAYER_MONEY")
  464. plugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  465. plugin:RegisterUnitEvent("SEND_MAIL_MONEY_CHANGED", "player") -- limit UNIT_* events to the player when possible
  466. plugin:RegisterUnitEvent("SEND_MAIL_COD_CHANGED", "player")
  467. plugin:RegisterUnitEvent("PLAYER_TRADE_MONEY", "player")
  468. plugin:RegisterUnitEvent("TRADE_MONEY_CHANGED", "player")
  469. plugin:SetScript("OnEvent", function(self)
  470. local totalSlots, freeSlots = 0, 0
  471. local itemLink, subtype, isBag
  472. for i = 0,NUM_BAG_SLOTS do
  473. isBag = true
  474. if i > 0 then
  475. itemLink = GetInventoryItemLink('player', ContainerIDToInventoryID(i))
  476. if itemLink then
  477. subtype = select(7, GetItemInfo(itemLink))
  478. if (subtype == 'Mining Bag') or (subtype == 'Gem Bag') or (subtype == 'Engineering Bag') or (subtype == 'Enchanting Bag') or (subtype == 'Herb Bag') or (subtype == 'Inscription Bag') or (subtype == 'Leatherworking Bag') or (subtype == 'Fishing Bag')then
  479. isBag = false
  480. end
  481. end
  482. end
  483. if isBag then
  484. totalSlots = totalSlots + GetContainerNumSlots(i)
  485. freeSlots = freeSlots + GetContainerNumFreeSlots(i)
  486. end
  487. Text:SetText(hexa.."Bags:|r"..freeSlots.."/"..totalSlots)
  488. plugin:SetWidth(Text:GetStringWidth()) -- important!
  489. --Text:SetText("Bags: ".. freeSlots.. '/' ..totalSlots)
  490. if freeSlots < 6 then
  491. Text:SetTextColor(1,0,0)
  492. elseif freeSlots < 10 then
  493. Text:SetTextColor(1,0,0)
  494. elseif freeSlots > 10 then
  495. Text:SetTextColor(1,1,1)
  496. end
  497. --self:SetAllPoints(Text)]]
  498.  
  499. end
  500. if event == "PLAYER_ENTERING_WORLD" then
  501. OldMoney = GetMoney()
  502. end
  503.  
  504. local NewMoney = GetMoney()
  505. local Change = NewMoney-OldMoney -- Positive if we gain money
  506.  
  507. if OldMoney>NewMoney then -- Lost Money
  508. Spent = Spent - Change
  509. else -- Gained Money
  510. Profit = Profit + Change
  511. end
  512.  
  513. --Text:SetText(formatMoney(NewMoney))
  514.  
  515.  
  516. local myPlayerName = UnitName("player")
  517. if not BasicDB then BasicDB = {} end
  518. if not BasicDB.gold then BasicDB.gold = {} end
  519. if not BasicDB.gold[myPlayerRealm] then BasicDB.gold[myPlayerRealm]={} end
  520. BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney()
  521.  
  522. OldMoney = NewMoney
  523. end)
  524.  
  525. plugin:SetScript("OnEnter", function(self)
  526. if UnitAffectingCombat("player") then return end
  527.  
  528. local anchor, x, y = GetTooltipAnchor(self)
  529. GameTooltip:SetOwner(self, GameTooltip:SetOwner(self, anchor, x, y))
  530. GameTooltip:AddLine(hexa..PLAYER_NAME.."'s|r".." Gold")
  531. GameTooltip:AddLine' '
  532. GameTooltip:AddLine("This Session: ")
  533. GameTooltip:AddDoubleLine("Earned:", formatMoney(Profit), 1, 1, 1, 1, 1, 1)
  534. GameTooltip:AddDoubleLine("Spent:", formatMoney(Spent), 1, 1, 1, 1, 1, 1)
  535. if Profit < Spent then
  536. GameTooltip:AddDoubleLine("Deficit:", formatMoney(Profit-Spent), 1, 0, 0, 1, 1, 1)
  537. elseif (Profit-Spent)>0 then
  538. GameTooltip:AddDoubleLine("Profit:", formatMoney(Profit-Spent), 0, 1, 0, 1, 1, 1)
  539. end
  540. GameTooltip:AddDoubleLine("Total:", formatMoney(OldMoney), 1, 1, 1, 1, 1, 1)
  541. GameTooltip:AddLine' '
  542.  
  543. local totalGold = 0
  544. GameTooltip:AddLine("Character's: ")
  545. local thisRealmList = BasicDB.gold[myPlayerRealm];
  546. for k,v in pairs(thisRealmList) do
  547. GameTooltip:AddDoubleLine(k, formatMoney(v), 1, 1, 1, 1, 1, 1)
  548. totalGold=totalGold+v;
  549. end
  550. GameTooltip:AddLine' '
  551. GameTooltip:AddLine("Server:")
  552. GameTooltip:AddDoubleLine("Total: ", formatMoney(totalGold), 1, 1, 1, 1, 1, 1)
  553.  
  554. for i = 1, GetNumWatchedTokens() do
  555. local name, count, extraCurrencyType, icon, itemID = GetBackpackCurrencyInfo(i)
  556. if name and i == 1 then
  557. GameTooltip:AddLine(" ")
  558. GameTooltip:AddLine(CURRENCY..":")
  559. end
  560. local r, g, b = 1,1,1
  561. if itemID then r, g, b = GetItemQualityColor(select(3, GetItemInfo(itemID))) end
  562. if name and count then GameTooltip:AddDoubleLine(name, count, r, g, b, 1, 1, 1) end
  563. end
  564. GameTooltip:AddLine' '
  565. GameTooltip:AddLine("|cffeda55fClick|r to Open Bags")
  566. GameTooltip:Show()
  567. end)
  568.  
  569. plugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  570.  
  571. plugin:SetScript("OnMouseDown", function(self, button)
  572. if db.datapanel.bag ~= true then
  573. ToggleAllBags()
  574. else
  575. ToggleBag(0)
  576. end
  577. end)
  578.  
  579. return plugin -- important!
  580. end,
  581. -- You can update the rest yourself if you want.
  582. -- Also, it would be more maintainable to put each plugin in its own file, and add them to this table from there, eg:
  583. --[[
  584. local Core = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  585. local Module = Core:GetModule("Datapanel")
  586.  
  587. Module.pluginConstructors["armor"] = function()
  588. -- create and return the armor plugin
  589. end
  590. ]]
  591.  
  592. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement