Thread Tools Display Modes
09-05-23, 08:31 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
[WoW Classic Era] Bringing back a older addon.

Hello everyone, im trying to resurrect my old addon BasicUI but am having some issues with my datapanel and some datatext.

Mostly the 2 main datatext im having issues with are spec and stat datatext.

I have add LibClassicSpecs to help me get the players roles in classic era but i cant seem to get them to work correctly.

So what i would like to achive is...

spec - show your current spec at a glance (mainly for people that play multiple toons)

stat - show the players current major stat either being Armor for tanks, attack power for damagers and spell power for caster/healers.

Here are the lua codes im working with.

LibClassicSpecs code at the top of the module:
Lua Code:
  1. local LibClassicSpecs = LibStub("LibClassicSpecs")
  2.  
  3. local MAX_TALENT_TIERS                = _G.MAX_TALENT_TIERS or LibClassicSpecs.MAX_TALENT_TIERS
  4. local NUM_TALENT_COLUMNS              = _G.NUM_TALENT_COLUMNS or LibClassicSpecs.NUM_TALENT_COLUMNS
  5.  
  6. local GetNumClasses                   = _G.GetNumClasses or LibClassicSpecs.GetNumClasses
  7. local GetClassInfo                    = _G.GetClassInfo or LibClassicSpecs.GetClassInfo
  8. local GetNumSpecializationsForClassID = _G.GetNumSpecializationsForClassID or LibClassicSpecs.GetNumSpecializationsForClassID
  9.  
  10. local GetActiveSpecGroup              = _G.GetActiveSpecGroup or LibClassicSpecs.GetActiveSpecGroup
  11.  
  12. local GetSpecialization               = _G.GetSpecialization or LibClassicSpecs.GetSpecialization
  13. local GetSpecializationInfo           = _G.GetSpecializationInfo or LibClassicSpecs.GetSpecializationInfo
  14. local GetSpecializationInfoForClassID = _G.GetSpecializationInfoForClassID or LibClassicSpecs.GetSpecializationInfoForClassID
  15.  
  16. local GetSpecializationRole           = _G.GetSpecializationRole or LibClassicSpecs.GetSpecializationRole
  17. local GetSpecializationRoleByID       = _G.GetSpecializationRoleByID or LibClassicSpecs.GetSpecializationRoleByID
  18.  
  19.  
  20. -- Useful constants/enums
  21. local playerRole = LibClassicSpecs.Role
  22. local playerClass = LibClassicSpecs.Class
  23. local playerStat = LibClassicSpecs.Stat

spec code:
Lua Code:
  1. if db.spec then
  2.  
  3.         local specPlugin = CreateFrame('Frame', nil, Datapanel)
  4.         specPlugin:EnableMouse(true)
  5.         specPlugin:SetFrameStrata('BACKGROUND')
  6.         specPlugin:SetFrameLevel(3)
  7.  
  8.         local Text = specPlugin:CreateFontString(nil, 'OVERLAY')
  9.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  10.         PlacePlugin(db.spec, Text)
  11.  
  12.         local talent = {}
  13.         local active
  14.         local talentString = string.join('', '|cffFFFFFF%s|r ')
  15.         local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  16.         local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  17.  
  18.  
  19.  
  20.         --[[local function LoadTalentTrees()
  21.             for i = 1, GetNumSpecGroups(false, false) do
  22.                 talent[i] = {} -- init talent group table
  23.                 for j = 1, GetNumSpecializations(false, false) do
  24.                     talent[i][j] = select(5, GetSpecializationInfo(j, false, false, i))
  25.                 end
  26.             end
  27.         end]]
  28.  
  29.         local int = 5
  30.         local function Update(self, t)
  31.            
  32.             int = int - t
  33.             if int > 0 then return end
  34.             active = GetActiveSpecGroup(false, false)
  35.             if playerRole ~= nil then
  36.                 Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
  37.             else
  38.                 Text:SetText(hexa.."No Spec"..hexb)
  39.             end
  40.             int = 2
  41.  
  42.             -- disable script  
  43.             --self:SetScript('OnUpdate', nil)
  44.            
  45.         end
  46.  
  47.  
  48.         specPlugin:SetScript('OnEnter', function(self)
  49.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  50.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  51.  
  52.             GameTooltip:ClearLines()
  53.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Spec")
  54.             GameTooltip:AddLine' '
  55.             if playerRole ~= nil then
  56.                 for i = 1, GetNumSpecGroups() do
  57.                     if GetSpecialization(false, false, i) then
  58.                         GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == active and activeString or inactiveString)),1,1,1)
  59.                     end
  60.                 end
  61.             else
  62.                 GameTooltip:AddLine("You have not chosen a Spec yet.")
  63.             end
  64.             GameTooltip:AddLine' '     
  65.             GameTooltip:AddLine("|cffeda55fClick|r to Open Talent Tree")
  66.             GameTooltip:Show()
  67.         end)
  68.  
  69.         specPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
  70.  
  71.         local function OnEvent(self, event, ...)
  72.             if event == 'PLAYER_ENTERING_WORLD' then
  73.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  74.             end
  75.            
  76.             -- load talent information
  77.             --LoadTalentTrees()
  78.  
  79.             -- Setup Talents Tooltip
  80.             self:SetAllPoints(Text)
  81.  
  82.             -- update datatext
  83.             if event ~= 'PLAYER_ENTERING_WORLD' then
  84.                 self:SetScript('OnUpdate', Update)
  85.             end
  86.         end
  87.  
  88.  
  89.  
  90.         specPlugin:RegisterEvent('PLAYER_ENTERING_WORLD');
  91.         specPlugin:RegisterEvent('CHARACTER_POINTS_CHANGED');
  92.         specPlugin:RegisterEvent('PLAYER_TALENT_UPDATE');
  93.         specPlugin:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  94.         specPlugin:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  95.         specPlugin:SetScript('OnEvent', OnEvent)
  96.         specPlugin:SetScript('OnUpdate', Update)
  97.  
  98.         specPlugin:SetScript("OnMouseDown", function() ToggleTalentFrame() end)
  99.     end

stat code:
Lua Code:
  1. if db.stats then
  2.  
  3.         local statsPlugin = CreateFrame('Frame', nil, Datapanel)
  4.         statsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  5.         statsPlugin:SetFrameStrata("BACKGROUND")
  6.         statsPlugin:SetFrameLevel(3)
  7.         statsPlugin:EnableMouse(true)
  8.  
  9.         local Text = statsPlugin:CreateFontString(nil, "OVERLAY")
  10.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  11.         PlacePlugin(db.stats, Text)
  12.  
  13.         local playerClass, englishClass = UnitClass("player");
  14.  
  15.         local function ShowTooltip(self)   
  16.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  17.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  18.             GameTooltip:ClearLines()
  19.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  20.             GameTooltip:AddLine' '     
  21.             if playerRole == nil then
  22.                 GameTooltip:AddLine("Choose a Specialization to see Stats")
  23.             else
  24.                 if playerRole == playerRole.Tank then
  25.                     local Total_Dodge = GetDodgeChance()
  26.                     local Total_Parry = GetParryChance()
  27.                     local Total_Block = GetBlockChance()
  28.                    
  29.                     GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  30.                     GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  31.                     GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  32.                     GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)               
  33.                    
  34.                 elseif playerRole == playerRole.Healer then
  35.                     local SC = GetSpellCritChance("2")
  36.                     local Total_Spell_Haste = UnitSpellHaste("player")
  37.                     local base, casting = GetManaRegen()
  38.                     local manaRegenString = "%d / %d"              
  39.                    
  40.                     GameTooltip:AddLine(STAT_CATEGORY_SPELL)
  41.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", SC), 1, 1, 1)
  42.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Spell_Haste), 1, 1, 1)    
  43.                     GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, casting * 5), 1, 1, 1)
  44.  
  45.                 elseif playerRole == playerRole.Damager then           
  46.                     if Class == Class.Hunter then
  47.                         local Total_Range_Haste = GetRangedHaste("player")
  48.                         local Range_Crit = GetRangedCritChance("25")
  49.                         local speed = UnitRangedDamage("player")
  50.                         local Total_Range_Speed = speed
  51.                        
  52.                         GameTooltip:AddLine(STAT_CATEGORY_RANGED)                  
  53.                         GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Range_Crit), 1, 1, 1) 
  54.                         GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Range_Haste), 1, 1, 1)
  55.                         GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", Total_Range_Speed), 1, 1, 1)                 
  56.                     else
  57.                         local Melee_Crit = GetCritChance("player")
  58.                         local Total_Melee_Haste = GetMeleeHaste("player")
  59.                         local mainSpeed = UnitAttackSpeed("player");
  60.                         local MH = mainSpeed
  61.                        
  62.                         GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  63.                         GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  64.                         GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  65.                         GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)
  66.                     end
  67.                 end
  68.                 --[[if GetCombatRating(CR_MASTERY) ~= 0 and GetSpecialization() then
  69.                     local masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  70.                     local Mastery = GetMasteryEffect("player")
  71.                     local masteryName, _, _, _, _, _, _, _, _ = GetSpellInfo(masteryspell)
  72.                     if masteryName then
  73.                         GameTooltip:AddDoubleLine(masteryName, format("%.2f%%", Mastery), 1, 1, 1)
  74.                     end
  75.                 end]]
  76.                    
  77.                 GameTooltip:AddLine' '
  78.                 GameTooltip:AddLine(STAT_CATEGORY_GENERAL)
  79.                
  80.                 --local Life_Steal = GetLifesteal();
  81.                 --local Versatility_Damage_Bonus = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE);
  82.                 --local Avoidance = GetAvoidance();
  83.                
  84.                 --GameTooltip:AddDoubleLine(STAT_LIFESTEAL, format("%.2f%%", Life_Steal), 1, 1, 1)
  85.                 --GameTooltip:AddDoubleLine(STAT_VERSATILITY, format("%.2f%%", Versatility_Damage_Bonus), 1, 1, 1)
  86.                 --GameTooltip:AddDoubleLine(STAT_AVOIDANCE, format("%.2f%%", Avoidance), 1, 1, 1)          
  87.             end
  88.  
  89.             GameTooltip:Show()
  90.         end
  91.  
  92.         local function UpdateTank(self)
  93.             local armorString = hexa..ARMOR..hexb..": "
  94.             local displayNumberString = string.join("", "%s", "%d|r");
  95.             local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  96.             local Melee_Reduction = effectiveArmor
  97.            
  98.             Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  99.             --Setup Tooltip
  100.             self:SetAllPoints(Text)
  101.         end
  102.  
  103.         local function UpdateCaster(self)
  104.             local spellpwr = GetSpellBonusDamage("2");
  105.             local displayNumberString = string.join("", "%s", "%d|r");
  106.            
  107.             Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  108.            
  109.             --Setup Tooltip
  110.             self:SetAllPoints(Text)
  111.         end
  112.  
  113.         local function UpdateDamager(self) 
  114.             local displayNumberString = string.join("", "%s", "%d|r");
  115.                
  116.             if Class == Class.Hunter then
  117.                 local base, posBuff, negBuff = UnitRangedAttackPower("player")
  118.                 local Range_AP = base + posBuff + negBuff  
  119.                 pwr = Range_AP
  120.             else
  121.                 local base, posBuff, negBuff = UnitAttackPower("player")
  122.                 local Melee_AP = base + posBuff + negBuff      
  123.                 pwr = Melee_AP
  124.             end
  125.            
  126.             Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)      
  127.             --Setup Tooltip
  128.             self:SetAllPoints(Text)
  129.         end
  130.  
  131.         -- initial delay for update (let the ui load)
  132.         local int = 5  
  133.         local function Update(self, t)
  134.             int = int - t
  135.             if int > 0 then return end
  136.             if playerRole == nil then
  137.                 Text:SetText(hexa.."No Stats"..hexb)
  138.             else
  139.                 if playerRole == playerRole.Tank then
  140.                     UpdateTank(self)
  141.                 elseif playerRole == playerRole.Healer then
  142.                     UpdateCaster(self)
  143.                 elseif playerRole == playerRole.Damager then
  144.                     UpdateDamager(self)
  145.                 end
  146.             end
  147.             int = 2
  148.         end
  149.  
  150.         statsPlugin:SetScript("OnEnter", function() ShowTooltip(statsPlugin) end)
  151.         statsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  152.         statsPlugin:SetScript("OnUpdate", Update)
  153.         Update(statsPlugin, 10)
  154.     end

neither one populate on the datapanel.

Any help would be great.

Also all my other datatext are working as of right now so its not the datapanel its the datatext itself.

Thanks
Cokedriver
  Reply With Quote
09-05-23, 10:21 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Code:
if db.spec then
Code:
if db.stats then
Are you sure these contain something? I don't see in the top code listing where/with what these are initialsed first time for a character.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-05-23, 10:29 AM   #3
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Yes it has it, i was only trying to show the part of the code im having issues with.

Here is the full lua for my Datapanel...
Lua Code:
  1. local MODULE_NAME = "Datapanel"
  2. local BasicUI = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  3. local MODULE = BasicUI:NewModule(MODULE_NAME, "AceEvent-3.0")
  4. local L = BasicUI.L
  5.  
  6. ------------------------------------------------------------------------
  7. --   Module Database
  8. ------------------------------------------------------------------------
  9.  
  10.  
  11. local db
  12. local defaults = {
  13.     profile = {
  14.         enable = true,
  15.        
  16.         font = [[Fonts\ARIALN.ttf]],
  17.         fontSize = 17,
  18.            
  19.         --battleground = false,                             -- enable 3 stats in battleground only that replace stat1,stat2,stat3.
  20.         bag = false,                                        -- True = Open Backpack; False = Open All bags         
  21.         recountraiddps  = false,                            -- Enables tracking or Recounts Raid DPS
  22.         enableColor = true,                                 -- Enable class color for text.
  23.        
  24.         -- Color Datatext  
  25.         customcolor = { r = 1, g = 1, b = 1},               -- Color of Text for Datapanel
  26.        
  27.         -- Stat Locations
  28.         bags            = "P9",     -- show space used in bags on panel.   
  29.         system          = "P1",     -- show total memory and others systems info (FPS/MS) on panel.
  30.         guild           = "P4",     -- show number on guildmate connected on panel.
  31.         dur             = "P8",     -- show your equipment durability on panel.
  32.         friends         = "P6",     -- show number of friends connected.
  33.         spec            = "P2",     -- show your current spec on panel.
  34.         coords          = "P0",     -- show your current coords on panel.
  35.         pro             = "P7",     -- shows your professions and tradeskills
  36.         stats           = "P5",     -- Stat Based on your Role (Avoidance-Tank, AP-Melee, SP/HP-Caster)
  37.         recount         = "P3",     -- Stat Based on Recount"s DPS 
  38.         calltoarms      = "P0",     -- Show Current Call to Arms.
  39.         dps             = "P0",     -- Show total dps. 
  40.     }
  41. }
  42.  
  43. ------------------------------------------------------------------------
  44. --   Local Module Functions
  45. ------------------------------------------------------------------------
  46. -- Variables that point to frames or other objects:
  47. local DataMain, DataP1, DataP2, DataP3
  48. local currentFightDPS
  49. local _, class = UnitClass("player")
  50. local ccolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  51. local _G = _G
  52.  
  53. local LibClassicSpecs = LibStub("LibClassicSpecs")
  54.  
  55. local MAX_TALENT_TIERS                = _G.MAX_TALENT_TIERS or LibClassicSpecs.MAX_TALENT_TIERS
  56. local NUM_TALENT_COLUMNS              = _G.NUM_TALENT_COLUMNS or LibClassicSpecs.NUM_TALENT_COLUMNS
  57.  
  58. local GetNumClasses                   = _G.GetNumClasses or LibClassicSpecs.GetNumClasses
  59. local GetClassInfo                    = _G.GetClassInfo or LibClassicSpecs.GetClassInfo
  60. local GetNumSpecializationsForClassID = _G.GetNumSpecializationsForClassID or LibClassicSpecs.GetNumSpecializationsForClassID
  61.  
  62. local GetActiveSpecGroup              = _G.GetActiveSpecGroup or LibClassicSpecs.GetActiveSpecGroup
  63.  
  64. local GetSpecialization               = _G.GetSpecialization or LibClassicSpecs.GetSpecialization
  65. local GetSpecializationInfo           = _G.GetSpecializationInfo or LibClassicSpecs.GetSpecializationInfo
  66. local GetSpecializationInfoForClassID = _G.GetSpecializationInfoForClassID or LibClassicSpecs.GetSpecializationInfoForClassID
  67.  
  68. local GetSpecializationRole           = _G.GetSpecializationRole or LibClassicSpecs.GetSpecializationRole
  69. local GetSpecializationRoleByID       = _G.GetSpecializationRoleByID or LibClassicSpecs.GetSpecializationRoleByID
  70.  
  71.  
  72. -- Useful constants/enums
  73. local playerRole = LibClassicSpecs.Role
  74. local playerClass = LibClassicSpecs.Class
  75. local playerStat = LibClassicSpecs.Stat
  76.  
  77. local function RGBToHex(r, g, b)
  78.     if r > 1 then r = 1 elseif r < 0 then r = 0 end
  79.     if g > 1 then g = 1 elseif g < 0 then g = 0 end
  80.     if b > 1 then b = 1 elseif b < 0 then b = 0 end
  81.     return format("|cff%02x%02x%02x", r*255, g*255, b*255)
  82. end
  83.  
  84. local function HexToRGB(hex)
  85.     local rhex, ghex, bhex = strsub(hex, 1, 2), strsub(hex, 3, 4), strsub(hex, 5, 6)
  86.     return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
  87. end
  88.  
  89. local function ShortValue(v)
  90.     if v >= 1e6 then
  91.         return format("%.1fm", v / 1e6):gsub("%.?0+([km])$", "%1")
  92.     elseif v >= 1e3 or v <= -1e3 then
  93.         return format("%.1fk", v / 1e3):gsub("%.?0+([km])$", "%1")
  94.     else
  95.         return v
  96.     end
  97. end
  98.  
  99.  
  100. ------------------------------------------------------------------------
  101. --   Module Functions
  102. ------------------------------------------------------------------------
  103.  
  104. function MODULE:CreatePanels()
  105.     if DataMain then return end -- already done
  106.    
  107.     -- Create All Panels
  108.     ------------------------------------------------------------------------
  109.     DataMain = CreateFrame("Frame", "DataMain", UIParent)
  110.     DataP1 = CreateFrame("Frame", "DataP1", UIParent)
  111.     DataP2 = CreateFrame("Frame", "DataP2", UIParent)
  112.     DataP3 = CreateFrame("Frame", "DataP3", UIParent)
  113.    
  114.    
  115.     -- Multi Panel Settings
  116.     ------------------------------------------------------------------------
  117.     for _, panelz in pairs({
  118.         DataMain,
  119.         DataP1,
  120.         DataP2,
  121.         DataP3,
  122.     }) do
  123.         panelz:SetHeight(30)
  124.         panelz:SetFrameStrata("LOW")   
  125.         panelz:SetFrameLevel(1)
  126.     end
  127.  
  128.     -- Main Panel Settings
  129.     ------------------------------------------------------------------------
  130.     Mixin(DataMain, BackdropTemplateMixin)
  131.     DataMain:SetPoint("BOTTOM", UIParent, 0, 0)
  132.     DataMain:SetWidth(1200)
  133.     DataMain:SetBackdrop({
  134.         bgFile = [[Interface\ChatFrame\ChatFrameBackground]],
  135.         edgeFile = [[Interface\AddOns\BasicUI\Media\UI-DialogBox-Border.blp]],
  136.         edgeSize = 20, insets = { left = 5, right = 5, top = 5, bottom = 5 }
  137.     })
  138.     DataMain:SetBackdropColor(0, 0, 0, 1)
  139.     DataMain:RegisterEvent("PLAYER_ENTERING_WORLD")
  140.     DataMain:SetScript("OnEvent", function(self, event, ...)
  141.         if event == 'PLAYER_ENTERING_WORLD' then
  142.             local inInstance, instanceType = IsInInstance()
  143.             if inInstance and (instanceType == 'pvp') then         
  144.                 self:Hide()
  145.             else
  146.                 self:Show()
  147.             end
  148.         end
  149.     end)   
  150.    
  151.     -- Stat Panel 1 Settings
  152.     ------------------------------------------------------------------------
  153.     Mixin(DataP1, BackdropTemplateMixin)
  154.     DataP1:SetPoint("LEFT", DataMain, 5, 0)
  155.     DataP1:SetWidth(1200 / 3)
  156.     DataP1:SetBackdrop({
  157.         bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
  158.     })
  159.     DataP1:SetBackdropColor(0, 0, 0, 0.60)
  160.    
  161.    
  162.     -- Stat Panel 2 Settings
  163.     -----------------------------------------------------------------------
  164.     Mixin(DataP2, BackdropTemplateMixin)
  165.     DataP2:SetPoint("CENTER", DataMain, 0, 0)
  166.     DataP2:SetWidth(1200 / 3)
  167.     DataP2:SetBackdrop({
  168.         bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
  169.     })
  170.     DataP2:SetBackdropColor(0, 0, 0, 0.60)
  171.    
  172.     -- Stat Panel 3 Settings
  173.     -----------------------------------------------------------------------
  174.     Mixin(DataP3, BackdropTemplateMixin)
  175.     DataP3:SetPoint("RIGHT", DataMain, -5, 0)
  176.     DataP3:SetWidth(1200 / 3)
  177.     DataP3:SetBackdrop({
  178.         bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
  179.     })
  180.     DataP3:SetBackdropColor(0, 0, 0, 0.60)
  181.    
  182. end
  183.  
  184.  
  185. function MODULE:ShowPanel()
  186.  
  187.     local function SetPosition(frame, ...)
  188.         if type(frame) == 'string' then
  189.             UIPARENT_MANAGED_FRAME_POSITIONS[frame] = nil
  190.             frame = _G[frame]
  191.         end
  192.         if type(frame) == 'table' and type(frame.IsObjectType) == 'function' and frame:IsObjectType('Frame') then
  193.             local name = frame:GetName()
  194.             if name then
  195.                 UIPARENT_MANAGED_FRAME_POSITIONS[name] = nil
  196.             end
  197.             frame:SetMovable(true)
  198.             frame:SetUserPlaced(true)
  199.             frame:SetDontSavePosition(true)
  200.             frame.ignoreFramePositionManager = true
  201.             if ... then
  202.                 frame:ClearAllPoints()
  203.                 frame:SetPoint(...)
  204.             end
  205.             frame:SetMovable(false)
  206.         end
  207.     end
  208.  
  209.     -- Move the MainMenuBar.
  210.     SetPosition(MainMenuBar, "BOTTOM", DataMain, "TOP", 0, -4)
  211.    
  212.     DataMain:Show();
  213. end
  214.  
  215. function MODULE:HidePanel() end
  216.  
  217. function MODULE:CreateStats()
  218.  
  219.     local function PlacePlugin(position, plugin)
  220.    
  221.         -- Left Panel Data
  222.         if position == "P1" then
  223.             plugin:SetParent(DataP1)
  224.             plugin:SetHeight(DataP1:GetHeight())
  225.             plugin:SetPoint('LEFT', DataP1, 30, 0)
  226.             plugin:SetPoint('TOP', DataP1)
  227.             plugin:SetPoint('BOTTOM', DataP1)
  228.         elseif position == "P2" then
  229.             plugin:SetParent(DataP1)
  230.             plugin:SetHeight(DataP1:GetHeight())
  231.             plugin:SetPoint('TOP', DataP1)
  232.             plugin:SetPoint('BOTTOM', DataP1)
  233.         elseif position == "P3" then
  234.             plugin:SetParent(DataP1)
  235.             plugin:SetHeight(DataP1:GetHeight())
  236.             plugin:SetPoint('RIGHT', DataP1, -30, 0)
  237.             plugin:SetPoint('TOP', DataP1)
  238.             plugin:SetPoint('BOTTOM', DataP1)
  239.  
  240.         -- Center Panel Data
  241.         elseif position == "P4" then
  242.             plugin:SetParent(DataP2)
  243.             plugin:SetHeight(DataP2:GetHeight())
  244.             plugin:SetPoint('LEFT', DataP2, 30, 0)
  245.             plugin:SetPoint('TOP', DataP2)
  246.             plugin:SetPoint('BOTTOM', DataP2)
  247.         elseif position == "P5" then
  248.             plugin:SetParent(DataP2)
  249.             plugin:SetHeight(DataP2:GetHeight())
  250.             plugin:SetPoint('TOP', DataP2)
  251.             plugin:SetPoint('BOTTOM', DataP2)
  252.         elseif position == "P6" then
  253.             plugin:SetParent(DataP2)
  254.             plugin:SetHeight(DataP2:GetHeight())
  255.             plugin:SetPoint('RIGHT', DataP2, -30, 0)
  256.             plugin:SetPoint('TOP', DataP2)
  257.             plugin:SetPoint('BOTTOM', DataP2)
  258.  
  259.          --Right Panel Data
  260.         elseif position == "P7" then
  261.             plugin:SetParent(DataP3)
  262.             plugin:SetHeight(DataP3:GetHeight())
  263.             plugin:SetPoint('LEFT', DataP3, 30, 0)
  264.             plugin:SetPoint('TOP', DataP3)
  265.             plugin:SetPoint('BOTTOM', DataP3)
  266.         elseif position == "P8" then
  267.             plugin:SetParent(DataP3)
  268.             plugin:SetHeight(DataP3:GetHeight())
  269.             plugin:SetPoint('TOP', DataP3)
  270.             plugin:SetPoint('BOTTOM', DataP3)
  271.         elseif position == "P9" then
  272.             plugin:SetParent(DataP3)
  273.             plugin:SetHeight(DataP3:GetHeight())
  274.             plugin:SetPoint('RIGHT', DataP3, -30, 0)
  275.             plugin:SetPoint('TOP', DataP3)
  276.             plugin:SetPoint('BOTTOM', DataP3)
  277.         elseif position == "P0" then
  278.             return
  279.         end
  280.     end
  281.  
  282.     local function DataTextTooltipAnchor(self)
  283.         local panel = self:GetParent()
  284.         local anchor = 'GameTooltip'
  285.         local xoff = 1
  286.         local yoff = 3
  287.        
  288.        
  289.         for _, panel in pairs ({
  290.             DataP1,
  291.             DataP2,
  292.             DataP3,
  293.         })  do
  294.             anchor = 'ANCHOR_TOP'
  295.         end
  296.         return anchor, panel, xoff, yoff
  297.     end
  298.    
  299.     if db.enableColor ~= true then
  300.         local r, g, b = db.customcolor.r, db.customcolor.g, db.customcolor.b
  301.         hexa = ("|cff%.2x%.2x%.2x"):format(r * 255, g * 255, b * 255)
  302.         hexb = "|r"
  303.     else
  304.         hexa = ("|cff%.2x%.2x%.2x"):format(classColor.r * 255, classColor.g * 255, classColor.b * 255)
  305.         hexb = "|r"
  306.     end
  307.  
  308.     --------
  309.     -- Bags
  310.     --------
  311.  
  312.     if db.bags then
  313.         local bagsPlugin = CreateFrame('Frame', nil, Datapanel)
  314.         bagsPlugin:EnableMouse(true)
  315.         bagsPlugin:SetFrameStrata('BACKGROUND')
  316.         bagsPlugin:SetFrameLevel(3)
  317.  
  318.         local Text = bagsPlugin:CreateFontString(nil, 'OVERLAY')
  319.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  320.         PlacePlugin(db.bags, Text)
  321.  
  322.         local Profit    = 0
  323.         local Spent     = 0
  324.         local OldMoney  = 0
  325.         local myPlayerName  = UnitName("player");
  326.         local myPlayerRealm = GetRealmName();
  327.         local myPlayerFaction = UnitFactionGroup('player')
  328.         local iconAlliance = CreateTextureMarkup('Interface\\AddOns\\BasicUI\\Media\\Faction_Alliance_64.blp', 32,32, 14,14, 0,1,0,1, -2,-1)
  329.         local iconHorde = CreateTextureMarkup('Interface\\AddOns\\BasicUI\\Media\\Faction_Horde_64.blp', 32,32, 14,14, 0,1,0,1, -2,-1)
  330.         local iconNuetral = CreateTextureMarkup('Interface\\AddOns\\BasicUI\\Media\\Faction_Both_64.blp', 32,32, 14,14, 0,1,0,1, -2,-1)
  331.        
  332.         local function formatMoney(c)
  333.             local str = ""
  334.             if not c or c < 0 then
  335.                 return str
  336.             end
  337.            
  338.             if c >= 10000 then
  339.                 local g = math.floor(c/10000)
  340.                 c = c - g*10000
  341.                 str = str..BreakUpLargeNumbers(g).."|cFFFFD800g|r "
  342.             end
  343.             if c >= 100 then
  344.                 local s = math.floor(c/100)
  345.                 c = c - s*100
  346.                 str = str..s.."|cFFC7C7C7s|r "
  347.             end
  348.             if c >= 0 then
  349.                 str = str..c.."|cFFEEA55Fc|r"
  350.             end
  351.            
  352.             return str
  353.         end
  354.        
  355.         local function OnEvent(self, event)
  356.             local totalSlots, freeSlots = 0, 0
  357.             local itemLink, subtype, isBag
  358.             for i = 0,NUM_BAG_SLOTS do
  359.                 isBag = true
  360.                 if i > 0 then
  361.                     itemLink = GetInventoryItemLink('player', C_Container.ContainerIDToInventoryID(i))
  362.                     if itemLink then
  363.                         subtype = select(7, GetItemInfo(itemLink))
  364.                         if (subtype == 'Ammo Pouch') or (subtype == 'Soul Bag') or (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
  365.                             isBag = false
  366.                         end
  367.                     end
  368.                 end
  369.                 if isBag then
  370.                     totalSlots = totalSlots + C_Container.GetContainerNumSlots(i)
  371.                     freeSlots = freeSlots + C_Container.GetContainerNumFreeSlots(i)
  372.                 end
  373.                 Text:SetText(hexa.."Bags: "..hexb.. freeSlots.. '/' ..totalSlots)
  374.                     if freeSlots > 10 then
  375.                         Text:SetTextColor(1,1,1)
  376.                     elseif freeSlots < 9 then
  377.                         Text:SetTextColor(1,0,0)
  378.                     end
  379.                 self:SetAllPoints(Text)
  380.                
  381.             end
  382.         if event == "PLAYER_ENTERING_WORLD" then
  383.             OldMoney = GetMoney()
  384.         end
  385.        
  386.         local NewMoney  = GetMoney()
  387.        
  388.         local Change = NewMoney - OldMoney -- Positive if we gain money
  389.        
  390.         if OldMoney>NewMoney then       -- Lost Money
  391.             Spent = Spent - Change
  392.         else                            -- Gained Money
  393.             Profit = Profit + Change
  394.         end
  395.        
  396.         self:SetAllPoints(Text)
  397.  
  398.         if not db then db = {} end                 
  399.         if not db['Gold'] then db['Gold'] = {} end
  400.         if not db['Gold'][myPlayerRealm] then db['Gold'][myPlayerRealm] = {} end
  401.         if not db['Gold'][myPlayerRealm][myPlayerFaction] then db['Gold'][myPlayerRealm][myPlayerFaction] = {} end
  402.         db['Gold'][myPlayerRealm][myPlayerFaction][myPlayerName] = GetMoney()  
  403.            
  404.         OldMoney = NewMoney
  405.                
  406.         end
  407.  
  408.         bagsPlugin:RegisterEvent("PLAYER_MONEY")
  409.         bagsPlugin:RegisterEvent("SEND_MAIL_MONEY_CHANGED")
  410.         bagsPlugin:RegisterEvent("SEND_MAIL_COD_CHANGED")
  411.         bagsPlugin:RegisterEvent("PLAYER_TRADE_MONEY")
  412.         bagsPlugin:RegisterEvent("TRADE_MONEY_CHANGED")
  413.         bagsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  414.         bagsPlugin:RegisterEvent("BAG_UPDATE")
  415.        
  416.         bagsPlugin:SetScript('OnMouseDown',
  417.             function()
  418.                 if db.bag ~= true then
  419.                     ToggleAllBags()
  420.                 else
  421.                     ToggleBag(0)
  422.                 end
  423.             end
  424.         )
  425.         bagsPlugin:SetScript('OnEvent', OnEvent)   
  426.         bagsPlugin:SetScript("OnEnter", function(self)
  427.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  428.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  429.             GameTooltip:ClearLines()
  430.             GameTooltip:AddDoubleLine(hexa..PLAYER_NAME.."'s"..hexb.."|cffffd700 Gold|r", formatMoney(OldMoney), 1, 1, 1, 1, 1, 1)
  431.             GameTooltip:AddLine(" ")           
  432.             GameTooltip:AddLine("This Session: ")              
  433.             GameTooltip:AddDoubleLine("Earned:", formatMoney(Profit), 1, 1, 1, 1, 1, 1)
  434.             GameTooltip:AddDoubleLine("Spent:", formatMoney(Spent), 1, 1, 1, 1, 1, 1)
  435.             if Profit < Spent then
  436.                 GameTooltip:AddDoubleLine("Deficit:", formatMoney(Spent - Profit), 1, 0, 0, 1, 1, 1)
  437.             elseif (Profit - Spent) > 0 then
  438.                 GameTooltip:AddDoubleLine("Profit:", formatMoney(Profit - Spent), 0, 1, 0, 1, 1, 1)
  439.             end
  440.             GameTooltip:AddLine(" ")
  441.            
  442.             local totalGold = 0
  443.             local totalAllianceGold = 0
  444.             local totalHordeGold = 0
  445.             local totalNeutralGold = 0
  446.              
  447.             if db['Gold'][myPlayerRealm]['Alliance'] then     --so long as this will never have a value of false, you really only care if a value exists
  448.                 GameTooltip:AddLine("Alliance Characters:")     --faction heading
  449.                 for k,v in pairs(db['Gold'][myPlayerRealm]['Alliance']) do     --display all characters
  450.                     GameTooltip:AddDoubleLine(iconAlliance..k, formatMoney(v), 1, 1, 1, 1, 1, 1)
  451.                     totalAllianceGold = totalAllianceGold + v
  452.                 end
  453.                 GameTooltip:AddDoubleLine("Total Alliance Gold", formatMoney(totalAllianceGold))     --faction total
  454.                 GameTooltip:AddLine(" ")     --add a spacer after this faction
  455.             end
  456.              
  457.             if db['Gold'][myPlayerRealm]['Horde'] then
  458.                 GameTooltip:AddLine("Horde Characters:")     --faction heading
  459.                 for k,v in pairs(db['Gold'][myPlayerRealm]['Horde']) do     --display all characters
  460.                     GameTooltip:AddDoubleLine(iconHorde..k, formatMoney(v), 1, 1, 1, 1, 1, 1)
  461.                     totalHordeGold = totalHordeGold + v
  462.                 end
  463.                 GameTooltip:AddDoubleLine("Total Horde Gold", formatMoney(totalHordeGold))     --faction total
  464.                 GameTooltip:AddLine(" ")     --add a spacer after this faction
  465.             end
  466.                
  467.             if db['Gold'][myPlayerRealm]['Neutral'] then
  468.                 GameTooltip:AddLine("Neutral Characters:")     --faction heading
  469.                 for k,v in pairs(db['Gold'][myPlayerRealm]['Neutral']) do     --display all characters
  470.                     GameTooltip:AddDoubleLine(iconNuetral..k, formatMoney(v), 1, 1, 1, 1, 1, 1)
  471.                     totalNeutralGold = totalNeutralGold + v
  472.                 end
  473.                 GameTooltip:AddDoubleLine("Total Neutral Gold", formatMoney(totalNeutralGold))     --faction total
  474.                 GameTooltip:AddLine(" ")     --add a spacer after this faction
  475.             end
  476.                        
  477.             local totalServerGold = totalAllianceGold + totalHordeGold + totalNeutralGold
  478.             GameTooltip:AddDoubleLine("Total Gold for "..myPlayerRealm, formatMoney(totalServerGold))     --server total           
  479.             GameTooltip:AddLine' '
  480.             GameTooltip:AddLine("|cffeda55fClick|r to Open Bags")          
  481.             GameTooltip:Show()
  482.         end)
  483.        
  484.         bagsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)             
  485.  
  486.     end
  487.  
  488.     ----------------
  489.     -- Call To Arms
  490.     ----------------
  491.     if db.calltoarms then
  492.         local ctaPlugin = CreateFrame('Frame', nil, Datapanel)
  493.         ctaPlugin:EnableMouse(true)
  494.         ctaPlugin:SetFrameStrata("MEDIUM")
  495.         ctaPlugin:SetFrameLevel(3)
  496.  
  497.         local Text = ctaPlugin:CreateFontString(nil, "OVERLAY")
  498.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  499.         PlacePlugin(db.calltoarms, Text)
  500.        
  501.         local function MakeIconString(tank, healer, damage)
  502.             local str = ""
  503.             if tank then
  504.                 str = str..'T'
  505.             end
  506.             if healer then
  507.                 str = str..', H'
  508.             end
  509.             if damage then
  510.                 str = str..', D'
  511.             end
  512.            
  513.             return str
  514.         end
  515.        
  516.         local function MakeString(tank, healer, damage)
  517.             local str = ""
  518.             if tank then
  519.                 str = str..'Tank'
  520.             end
  521.             if healer then
  522.                 str = str..', Healer'
  523.             end
  524.             if damage then
  525.                 str = str..', DPS'
  526.             end
  527.            
  528.             return str
  529.         end
  530.  
  531.         local function OnEvent(self, event, ...)
  532.             local tankReward = false
  533.             local healerReward = false
  534.             local dpsReward = false
  535.             local unavailable = true       
  536.             for i=1, GetNumRandomDungeons() do
  537.                 local id, name = GetLFGRandomDungeonInfo(i)
  538.                 for x = 1,LFG_ROLE_NUM_SHORTAGE_TYPES do
  539.                     local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  540.                     if eligible then unavailable = false end
  541.                     if eligible and forTank and itemCount > 0 then tankReward = true end
  542.                     if eligible and forHealer and itemCount > 0 then healerReward = true end
  543.                     if eligible and forDamage and itemCount > 0 then dpsReward = true end              
  544.                 end
  545.             end
  546.            
  547.             if unavailable then
  548.                 Text:SetText(QUEUE_TIME_UNAVAILABLE)
  549.             else
  550.                 Text:SetText(hexa..'C to A'..hexb.." : "..MakeIconString(tankReward, healerReward, dpsReward).." ")
  551.             end
  552.            
  553.             self:SetAllPoints(Text)
  554.         end
  555.  
  556.         local function OnEnter(self)   
  557.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  558.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  559.             GameTooltip:ClearLines()
  560.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Call to Arms")
  561.             GameTooltip:AddLine(' ')
  562.            
  563.             local allUnavailable = true
  564.             local numCTA = 0
  565.             for i=1, GetNumRandomDungeons() do
  566.                 local id, name = GetLFGRandomDungeonInfo(i)
  567.                 local tankReward = false
  568.                 local healerReward = false
  569.                 local dpsReward = false
  570.                 local unavailable = true
  571.                 for x=1, LFG_ROLE_NUM_SHORTAGE_TYPES do
  572.                     local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  573.                     if eligible then unavailable = false end
  574.                     if eligible and forTank and itemCount > 0 then tankReward = true end
  575.                     if eligible and forHealer and itemCount > 0 then healerReward = true end
  576.                     if eligible and forDamage and itemCount > 0 then dpsReward = true end
  577.                 end
  578.                 if not unavailable then
  579.                     allUnavailable = false
  580.                     local rolesString = MakeString(tankReward, healerReward, dpsReward)
  581.                     if rolesString ~= ""  then
  582.                         GameTooltip:AddDoubleLine(name.." : ", rolesString..' ', 1, 1, 1)
  583.                     end
  584.                     if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
  585.                 end
  586.             end
  587.            
  588.             if allUnavailable then
  589.                 GameTooltip:AddLine("Could not get Call To Arms information.")
  590.             elseif numCTA == 0 then
  591.                 GameTooltip:AddLine("Could not get Call To Arms information.")
  592.             end
  593.             GameTooltip:AddLine' '
  594.             GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Dungeon Finder")   
  595.             GameTooltip:AddLine("|cffeda55fRight Click|r to Open PvP Finder")          
  596.             GameTooltip:Show() 
  597.         end
  598.        
  599.         --ctaPlugin:RegisterEvent("LFG_UPDATE_RANDOM_INFO")
  600.         ctaPlugin:RegisterEvent("PLAYER_LOGIN")
  601.         ctaPlugin:SetScript("OnEvent", OnEvent)
  602.         ctaPlugin:SetScript("OnMouseDown", function(self, btn)
  603.             if btn == "LeftButton" then
  604.                 ToggleLFDParentFrame(1)
  605.             elseif btn == "RightButton" then
  606.                 TogglePVPUI(1)
  607.             end
  608.         end)       
  609.         ctaPlugin:SetScript("OnEnter", OnEnter)
  610.         ctaPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  611.     end
  612.  
  613.     ---------------------
  614.     -- Damage Per Second
  615.     ---------------------
  616.     if db.dps then
  617.         local dpsPlugin = CreateFrame('Frame', nil, Datapanel)
  618.         dpsPlugin:EnableMouse(true)
  619.         dpsPlugin:SetFrameStrata('BACKGROUND')
  620.         dpsPlugin:SetFrameLevel(3)
  621.  
  622.         local Text = dpsPlugin:CreateFontString(nil, "OVERLAY")
  623.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  624.         PlacePlugin(db.dps, Text)
  625.  
  626.         local events = {SWING_DAMAGE = true, RANGE_DAMAGE = true, SPELL_DAMAGE = true, SPELL_PERIODIC_DAMAGE = true, DAMAGE_SHIELD = true, DAMAGE_SPLIT = true, SPELL_EXTRA_ATTACKS = true}
  627.         local player_id = UnitGUID('player')
  628.         local dmg_total, last_dmg_amount = 0, 0
  629.         local cmbt_time = 0
  630.  
  631.         local pet_id = UnitGUID('pet')
  632.        
  633.  
  634.         dpsPlugin:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
  635.         dpsPlugin:RegisterEvent('PLAYER_LOGIN')
  636.  
  637.         dpsPlugin:SetScript('OnUpdate', function(self, elap)
  638.             if UnitAffectingCombat('player') then
  639.                 cmbt_time = cmbt_time + elap
  640.             end
  641.            
  642.             Text:SetText(getDPS())
  643.         end)
  644.          
  645.         function dpsPlugin:PLAYER_LOGIN()
  646.             dpsPlugin:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  647.             dpsPlugin:RegisterEvent('PLAYER_REGEN_ENABLED')
  648.             dpsPlugin:RegisterEvent('PLAYER_REGEN_DISABLED')
  649.             dpsPlugin:RegisterEvent('UNIT_PET')
  650.             player_id = UnitGUID('player')
  651.             dpsPlugin:UnregisterEvent('PLAYER_LOGIN')
  652.         end
  653.          
  654.         function dpsPlugin:UNIT_PET(unit)
  655.             if unit == 'player' then
  656.                 pet_id = UnitGUID('pet')
  657.             end
  658.         end
  659.        
  660.         -- handler for the combat log. used [url]http://www.wowwiki.com/API_COMBAT_LOG_EVENT[/url] for api
  661.         function dpsPlugin:COMBAT_LOG_EVENT_UNFILTERED(...)        
  662.             -- filter for events we only care about. i.e heals
  663.             if not events[select(2, ...)] then return end
  664.  
  665.             -- only use events from the player
  666.             local id = select(4, ...)
  667.                
  668.             if id == player_id or id == pet_id then
  669.                 if select(2, ...) == "SWING_DAMAGE" then
  670.                     last_dmg_amount = select(12, ...)
  671.                 else
  672.                     last_dmg_amount = select(15, ...)
  673.                 end
  674.                 dmg_total = dmg_total + last_dmg_amount
  675.             end      
  676.         end
  677.          
  678.         function getDPS()
  679.             if (dmg_total == 0) then
  680.                 return (hexa.."DPS"..hexb..' 0')
  681.             else
  682.                 return string.format(hexa.."DPS: "..hexb..'%.1f ', (dmg_total or 0) / (cmbt_time or 1))
  683.             end
  684.         end
  685.  
  686.         function dpsPlugin:PLAYER_REGEN_ENABLED()
  687.             Text:SetText(getDPS())
  688.         end
  689.        
  690.         function dpsPlugin:PLAYER_REGEN_DISABLED()
  691.             cmbt_time = 0
  692.             dmg_total = 0
  693.             last_dmg_amount = 0
  694.         end
  695.          
  696.         dpsPlugin:SetScript("OnEnter", function(self)
  697.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  698.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  699.             GameTooltip:ClearLines()
  700.             GameTooltip:AddDoubleLine(hexa..PLAYER_NAME.."'s"..hexb.."|cffffd700 DPS|r")
  701.             GameTooltip:AddLine' '
  702.             GameTooltip:AddDoubleLine("Combat Time:", cmbt_time, 1, 0, 0, 1, 1, 1)
  703.             GameTooltip:AddDoubleLine("Total Damage:", dmg_total, 1, 0, 0, 1, 1, 1)
  704.             GameTooltip:AddDoubleLine("Last Damage:", last_dmg_amount, 1, 0, 0, 1, 1, 1)
  705.             GameTooltip:Show()
  706.         end)
  707.     end
  708.  
  709.     --------------
  710.     -- Durability
  711.     --------------
  712.     if db.dur then
  713.  
  714.         Slots = {
  715.             [1] = {1, "Head", 1000},
  716.             [2] = {3, "Shoulder", 1000},
  717.             [3] = {5, "Chest", 1000},
  718.             [4] = {6, "Waist", 1000},
  719.             [5] = {9, "Wrist", 1000},
  720.             [6] = {10, "Hands", 1000},
  721.             [7] = {7, "Legs", 1000},
  722.             [8] = {8, "Feet", 1000},
  723.             [9] = {16, "Main Hand", 1000},
  724.             [10] = {17, "Off Hand", 1000},
  725.             [11] = {18, "Ranged", 1000}
  726.         }
  727.  
  728.  
  729.         local durPlugin = CreateFrame('Frame', nil, Datapanel)
  730.         durPlugin:EnableMouse(true)
  731.         durPlugin:SetFrameStrata("MEDIUM")
  732.         durPlugin:SetFrameLevel(3)
  733.  
  734.         local Text  = durPlugin:CreateFontString(nil, "OVERLAY")
  735.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  736.         PlacePlugin(db.dur, Text)
  737.  
  738.         local function OnEvent(self)
  739.             local Total = 0
  740.             local current, max
  741.            
  742.             for i = 1, 11 do
  743.                 if GetInventoryItemLink("player", Slots[i][1]) ~= nil then
  744.                     current, max = GetInventoryItemDurability(Slots[i][1])
  745.                     if current then
  746.                         Slots[i][3] = current/max
  747.                         Total = Total + 1
  748.                     end
  749.                 end
  750.             end
  751.             table.sort(Slots, function(a, b) return a[3] < b[3] end)
  752.            
  753.             if Total > 0 then
  754.                 Text:SetText(hexa.."Armor: "..hexb..floor(Slots[1][3]*100).."% |r")
  755.             else
  756.                 Text:SetText(hexa.."Armor: "..hexb.."100% |r")
  757.             end
  758.             -- Setup Durability Tooltip
  759.             self:SetAllPoints(Text)
  760.             Total = 0
  761.         end
  762.  
  763.         durPlugin:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
  764.         durPlugin:RegisterEvent("MERCHANT_SHOW")
  765.         durPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  766.         durPlugin:SetScript("OnMouseDown",function(self,btn)
  767.             if btn == "LeftButton" then
  768.                 ToggleCharacter("PaperDollFrame")
  769.             elseif btn == "RightButton" then
  770.                 if not IsShiftKeyDown() then
  771.                     CastSpellByName("Traveler's Tundra Mammoth")
  772.                 else
  773.                     CastSpellByName("Grand Expedition Yak")
  774.                 end
  775.             end
  776.         end)
  777.         durPlugin:SetScript("OnEvent", OnEvent)
  778.         durPlugin:SetScript("OnEnter", function(self)
  779.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  780.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  781.             GameTooltip:ClearLines()
  782.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Durability")
  783.             GameTooltip:AddLine' '
  784.             --GameTooltip:AddDoubleLine("Current "..STAT_AVERAGE_ITEM_LEVEL, format("%.1f", GetAverageItemLevel("player")))
  785.             GameTooltip:AddLine' '
  786.             for i = 1, 11 do
  787.                 if Slots[i][3] ~= 1000 then
  788.                     local green, red
  789.                     green = Slots[i][3]*2
  790.                     red = 1 - green
  791.                     GameTooltip:AddDoubleLine(Slots[i][2], floor(Slots[i][3]*100).."%",1 ,1 , 1, red + 1, green, 0)
  792.                 end
  793.             end
  794.             GameTooltip:AddLine(" ")
  795.             GameTooltip:AddLine("|cffeda55fLeft Click|r opens Character Panel.")
  796.             GameTooltip:AddLine("|cffeda55fRight Click|r summon's Traveler's Tundra Mammoth.")
  797.             GameTooltip:AddLine("|cffeda55fHold Shift + Right Click|r summon's Grand Expedition Yak.")
  798.             GameTooltip:Show()
  799.         end)
  800.         durPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  801.  
  802.     end
  803.  
  804.     -----------
  805.     -- FRIEND
  806.     -----------
  807.  
  808.     if db.friends then
  809.  
  810.  
  811.         --Cache global variables
  812.         --Lua functions
  813.         local type, pairs, select = type, pairs, select
  814.         local sort, next, wipe, tremove, tinsert = sort, next, wipe, tremove, tinsert
  815.         local format, gsub, strfind, strjoin = format, gsub, strfind, strjoin
  816.         --WoW API / Variables
  817.         local BNSetCustomMessage = BNSetCustomMessage
  818.         local BNGetInfo = BNGetInfo
  819.         local IsChatAFK = IsChatAFK
  820.         local IsChatDND = IsChatDND
  821.         local SendChatMessage = SendChatMessage
  822.         local InviteUnit = InviteUnit
  823.         local BNInviteFriend = BNInviteFriend
  824.         local ChatFrame_SendSmartTell = ChatFrame_SendSmartTell
  825.         local SetItemRef = SetItemRef
  826.         local GetFriendInfo = GetFriendInfo
  827.         local BNGetFriendInfo = BNGetFriendInfo
  828.         local BNGetGameAccountInfo = BNGetGameAccountInfo
  829.         local BNet_GetValidatedCharacterName = BNet_GetValidatedCharacterName
  830.         local C_FriendList_GetNumFriends = C_FriendList.GetNumFriends
  831.         local C_FriendList_GetNumOnlineFriends = C_FriendList.GetNumOnlineFriends
  832.         local C_FriendList_GetFriendInfoByIndex = C_FriendList.GetFriendInfoByIndex
  833.         local BNGetNumFriends = BNGetNumFriends
  834.         local GetQuestDifficultyColor = GetQuestDifficultyColor
  835.         local UnitFactionGroup = UnitFactionGroup
  836.         local UnitInParty = UnitInParty
  837.         local UnitInRaid = UnitInRaid
  838.         local ToggleFriendsFrame = ToggleFriendsFrame
  839.         local EasyMenu = EasyMenu
  840.         local IsShiftKeyDown = IsShiftKeyDown
  841.         local GetRealmName = GetRealmName
  842.         local AFK = AFK
  843.         local DND = DND
  844.         local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
  845.         local LOCALIZED_CLASS_NAMES_FEMALE = LOCALIZED_CLASS_NAMES_FEMALE
  846.         local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
  847.         local RAID_CLASS_COLORS = RAID_CLASS_COLORS
  848.        
  849.         local clientSorted = {}
  850.         local clientTags = {
  851.             [BNET_CLIENT_WOW] = "WoW",
  852.             --[BNET_CLIENT_D3] = "D3",
  853.             --[BNET_CLIENT_WTCG] = "HS",
  854.             --[BNET_CLIENT_HEROES] = "HotS",
  855.             --[BNET_CLIENT_OVERWATCH] = "OW",
  856.             --[BNET_CLIENT_SC] = "SC",
  857.             --[BNET_CLIENT_SC2] = "SC2",
  858.             --[BNET_CLIENT_DESTINY2] = "Dst2",
  859.             --[BNET_CLIENT_COD] = "VIPR",
  860.             ["BSAp"] = L["Mobile"],
  861.         }
  862.         local clientIndex = {
  863.             [BNET_CLIENT_WOW] = 1,
  864.             --[BNET_CLIENT_D3] = 2,
  865.             --[BNET_CLIENT_WTCG] = 3,
  866.             --[BNET_CLIENT_HEROES] = 4,
  867.             --[BNET_CLIENT_OVERWATCH] = 5,
  868.             --[BNET_CLIENT_SC] = 6,
  869.             --[BNET_CLIENT_SC2] = 7,
  870.             --[BNET_CLIENT_DESTINY2] = 8,
  871.             --[BNET_CLIENT_COD] = 9,
  872.             ["App"] = 10,
  873.             ["BSAp"] = 11,
  874.         }      
  875.        
  876.         StaticPopupDialogs["SET_BN_BROADCAST"] = {
  877.             preferredIndex = STATICPOPUP_NUMDIALOGS,
  878.             text = BN_BROADCAST_TOOLTIP,
  879.             button1 = ACCEPT,
  880.             button2 = CANCEL,
  881.             hasEditBox = 1,
  882.             editBoxWidth = 350,
  883.             maxLetters = 127,
  884.             OnAccept = function(self)
  885.                 BNSetCustomMessage(self.editBox:GetText())
  886.             end,
  887.             OnShow = function(self)
  888.                 self.editBox:SetText(select(4, BNGetInfo()) )
  889.                 self.editBox:SetFocus()
  890.             end,
  891.             OnHide = ChatEdit_FocusActiveWindow,
  892.             EditBoxOnEnterPressed = function(self)
  893.                 BNSetCustomMessage(self:GetText())
  894.                 self:GetParent():Hide()
  895.             end,
  896.             EditBoxOnEscapePressed = function(self)
  897.                 self:GetParent():Hide()
  898.             end,
  899.             timeout = 0,
  900.             exclusive = 1,
  901.             whileDead = 1,
  902.             hideOnEscape = 1
  903.         }
  904.  
  905.         local friendsPlugin = CreateFrame('Frame', nil, Datapanel)
  906.         friendsPlugin:EnableMouse(true)
  907.         friendsPlugin:SetFrameStrata("MEDIUM")
  908.         friendsPlugin:SetFrameLevel(3)
  909.  
  910.         local Text  = friendsPlugin:CreateFontString(nil, "OVERLAY")
  911.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  912.         PlacePlugin(db.friends, Text)
  913.  
  914.         local menuFrame = CreateFrame("Frame", "FriendDatatextRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  915.         local menuList = {
  916.             { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  917.             { text = INVITE, hasArrow = true,notCheckable=true, },
  918.             { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true, },
  919.             { text = PLAYER_STATUS, hasArrow = true, notCheckable=true,
  920.                 menuList = {
  921.                     { text = "|cff2BC226"..AVAILABLE.."|r", notCheckable=true, func = function() if IsChatAFK() then SendChatMessage("", "AFK") elseif IsChatDND() then SendChatMessage("", "DND") end end },
  922.                     { text = "|cffE7E716"..DND.."|r", notCheckable=true, func = function() if not IsChatDND() then SendChatMessage("", "DND") end end },
  923.                     { text = "|cffFF0000"..AFK.."|r", notCheckable=true, func = function() if not IsChatAFK() then SendChatMessage("", "AFK") end end },
  924.                 },
  925.             },
  926.             { text = BN_BROADCAST_TOOLTIP, notCheckable=true, func = function() StaticPopup_Show("SET_BN_BROADCAST") end },
  927.         }
  928.  
  929.         local function GetTableIndex(table, fieldIndex, value)
  930.             for k,v in ipairs(table) do
  931.                 if v[fieldIndex] == value then return k end
  932.             end
  933.             return -1
  934.         end
  935.        
  936.         local function inviteClick(self, name)
  937.             menuFrame:Hide()
  938.            
  939.             if type(name) ~= 'number' then
  940.                 InviteUnit(name)
  941.             else
  942.                 BNInviteFriend(name);
  943.             end
  944.         end
  945.  
  946.         local function whisperClick(self, name, battleNet)
  947.             menuFrame:Hide()
  948.            
  949.             if battleNet then
  950.                 ChatFrame_SendBNetTell(name)
  951.             else
  952.                 SetItemRef( "player:"..name, ("|Hplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton" )        
  953.             end
  954.         end
  955.  
  956.         local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
  957.         local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s%s"
  958.         local worldOfWarcraftString = _G.WORLD_OF_WARCRAFT
  959.         local battleNetString = _G.BATTLENET_OPTIONS_LABEL
  960.         local totalOnlineString = string.join("", _G.FRIENDS_LIST_ONLINE, ": %s/%s")
  961.         local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  962.         local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  963.         local displayString = string.join("", hexa.."%s:|r %d|r"..hexb)
  964.         local statusTable = { "|cffff0000[AFK]|r", "|cffff0000[DND]|r", "" }
  965.         local groupedTable = { "|cffaaaaaa*|r", "" }
  966.         local friendTable, BNTable, tableList = {}, {}, {}
  967.         local friendOnline, friendOffline = gsub(_G.ERR_FRIEND_ONLINE_SS,"\124Hplayer:%%s\124h%[%%s%]\124h",""), gsub(_G.ERR_FRIEND_OFFLINE_S,"%%s","")
  968.         local wowString = _G.BNET_CLIENT_WOW
  969.         local dataValid = false
  970.        
  971.                 local totalOnline, BNTotalOnline = 0, 0
  972.  
  973.         local function SortAlphabeticName(a, b)
  974.             if a[1] and b[1] then
  975.                 return a[1] < b[1]
  976.             end
  977.         end
  978.        
  979.         local function BuildFriendTable(total)
  980.             totalOnline = 0
  981.             wipe(friendTable)
  982.             local name, level, class, area, connected, status, note
  983.             for i = 1, total do
  984.                 name, level, class, area, connected, status, note = GetFriendInfo(i)
  985.  
  986.                 if status == "<"..AFK..">" then
  987.                     status = "|cffFFFFFF[|r|cffFF0000"..'AFK'.."|r|cffFFFFFF]|r"
  988.                 elseif status == "<"..DND..">" then
  989.                     status = "|cffFFFFFF[|r|cffFF0000"..'DND'.."|r|cffFFFFFF]|r"
  990.                 end
  991.                
  992.                 if connected then
  993.                     for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  994.                     for k,v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if class == v then class = k end end
  995.                     friendTable[i] = { name, level, class, area, connected, status, note }
  996.                 end
  997.             end
  998.             sort(friendTable, SortAlphabeticName)
  999.         end
  1000.  
  1001.         --Sort alphabetic by accountName or characterName
  1002.         local function Sort(a, b)
  1003.             if a[2] and b[2] and a[3] and b[3] then
  1004.                 if a[2] == b[2] then return a[3] < b[3] end
  1005.                 return a[2] < b[2]
  1006.             end
  1007.         end
  1008.        
  1009.         local function AddToBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, realmName, faction, race, className, zoneName, level, guid, gameText)
  1010.             className = ""
  1011.             characterName = BNet_GetValidatedCharacterName(characterName, battleTag, client) or ""
  1012.             BNTable[bnIndex] = { bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, realmName, faction, race, className, zoneName, level, guid, gameText }
  1013.  
  1014.             if tableList[client] then
  1015.                 tableList[client][#tableList[client]+1] = BNTable[bnIndex]
  1016.             else
  1017.                 tableList[client] = {}
  1018.                 tableList[client][1] = BNTable[bnIndex]
  1019.             end
  1020.         end
  1021.        
  1022.         local function PopulateBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, realmName, faction, race, class, zoneName, level, guid, gameText, hasFocus)
  1023.             -- `hasFocus` is not added to BNTable[i]; we only need this to keep our friends datatext in sync with the friends list
  1024.             for i = 1, bnIndex do
  1025.                 local isAdded, bnInfo = 0, BNTable[i]
  1026.                 if bnInfo and (bnInfo[1] == bnetIDAccount) then
  1027.                     if bnInfo[6] == "BSAp" then
  1028.                         if client == "BSAp" then -- unlikely to happen
  1029.                             isAdded = 1
  1030.                         elseif client == "App" then
  1031.                             isAdded = (hasFocus and 2) or 1
  1032.                         else -- Mobile -> Game
  1033.                             isAdded = 2 --swap data
  1034.                         end
  1035.                     elseif bnInfo[6] == "App" then
  1036.                         if client == "App" then -- unlikely to happen
  1037.                             isAdded = 1
  1038.                         elseif client == "BSAp" then
  1039.                             isAdded = (hasFocus and 2) or 1
  1040.                         else -- App -> Game
  1041.                             isAdded = 2 --swap data
  1042.                         end
  1043.                     elseif bnInfo[6] then -- Game
  1044.                         if client == "BSAp" or client == "App" then -- ignore Mobile and App
  1045.                             isAdded = 1
  1046.                         end
  1047.                     end
  1048.                 end
  1049.                 if isAdded == 2 then -- swap data
  1050.                     if bnInfo[6] and tableList[bnInfo[6]] then
  1051.                         for n, y in ipairs(tableList[bnInfo[6]]) do
  1052.                             if y == bnInfo then
  1053.                                 tremove(tableList[bnInfo[6]], n)
  1054.                                 break -- remove the old one from tableList
  1055.                             end
  1056.                         end
  1057.                     end
  1058.                     AddToBNTable(i, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, realmName, faction, race, class, zoneName, level, guid, gameText)
  1059.                 end
  1060.                 if isAdded ~= 0 then
  1061.                     return bnIndex
  1062.                 end
  1063.             end
  1064.  
  1065.             bnIndex = bnIndex + 1 --bump the index one for a new addition
  1066.             AddToBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, realmName, faction, race, class, zoneName, level, guid, gameText)
  1067.  
  1068.             return bnIndex
  1069.         end
  1070.         local function BuildBNTable(total)
  1071.             for _, v in pairs(tableList) do wipe(v) end
  1072.             wipe(BNTable)
  1073.             wipe(clientSorted)
  1074.  
  1075.             local bnIndex = 0
  1076.  
  1077.             for i = 1, total do
  1078.                 local bnetIDAccount, accountName, battleTag, _, characterName, bnetIDGameAccount, client, isOnline, _, isBnetAFK, isBnetDND, _, noteText = BNGetFriendInfo(i)
  1079.                 if isOnline then
  1080.                     local numGameAccounts = BNGetNumFriendGameAccounts(i)
  1081.                     if numGameAccounts > 0 then
  1082.                         for y = 1, numGameAccounts do
  1083.                             local hasFocus, gameCharacterName, gameClient, realmName, _, faction, race, class, _, zoneName, level, gameText, _, _, _, _, _, isGameAFK, isGameBusy, guid = BNGetFriendGameAccountInfo(i, y)
  1084.                             bnIndex = PopulateBNTable(bnIndex, bnetIDAccount, accountName, battleTag, gameCharacterName, bnetIDGameAccount, gameClient, isOnline, isBnetAFK or isGameAFK, isBnetDND or isGameBusy, noteText, realmName, faction, race, class, zoneName, level, guid, gameText, hasFocus)
  1085.                         end
  1086.                     else
  1087.                         bnIndex = PopulateBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText)
  1088.                     end
  1089.                 end
  1090.             end
  1091.  
  1092.             if next(BNTable) then
  1093.                 sort(BNTable, Sort)
  1094.             end
  1095.             for c, v in pairs(tableList) do
  1096.                 if next(v) then
  1097.                     sort(v, Sort)
  1098.                 end
  1099.                 tinsert(clientSorted, c)
  1100.             end
  1101.             if next(clientSorted) then
  1102.                 sort(clientSorted, clientSort)
  1103.             end
  1104.         end
  1105.            
  1106.  
  1107.         friendsPlugin:SetScript("OnEvent", function(self, event, ...)
  1108.             local onlineFriends = C_FriendList_GetNumOnlineFriends()
  1109.             local _, numBNetOnline = BNGetNumFriends()
  1110.  
  1111.             -- special handler to detect friend coming online or going offline
  1112.             -- when this is the case, we invalidate our buffered table and update the
  1113.             -- datatext information
  1114.             if event == "CHAT_MSG_SYSTEM" then
  1115.                 local message = select(1, ...)
  1116.                 if not (strfind(message, friendOnline) or strfind(message, friendOffline)) then return end
  1117.             end
  1118.  
  1119.             -- force update when showing tooltip
  1120.             dataValid = false
  1121.  
  1122.             Text:SetFormattedText(displayString, "Friends", onlineFriends + numBNetOnline)
  1123.             self:SetAllPoints(Text)
  1124.         end)
  1125.  
  1126.         friendsPlugin:SetScript("OnMouseDown", function(self, btn)
  1127.        
  1128.             GameTooltip:Hide()
  1129.            
  1130.             if btn == "RightButton" then
  1131.                 local menuCountWhispers = 0
  1132.                 local menuCountInvites = 0
  1133.                 local factionc, classc, levelc, info
  1134.                
  1135.                 menuList[2].menuList = {}
  1136.                 menuList[3].menuList = {}
  1137.                
  1138.                 if #friendTable > 0 then
  1139.                     for i = 1, #friendTable do
  1140.                         info = friendTable[i]
  1141.                         if (info[5]) then
  1142.                             menuCountInvites = menuCountInvites + 1
  1143.                             menuCountWhispers = menuCountWhispers + 1
  1144.  
  1145.                             classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
  1146.                             classc = classc or GetQuestDifficultyColor(info[2]);
  1147.  
  1148.                             menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info[2],classc.r*255,classc.g*255,classc.b*255,info[1]), arg1 = info[1],notCheckable=true, func = inviteClick}
  1149.                             menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info[2],classc.r*255,classc.g*255,classc.b*255,info[1]), arg1 = info[1],notCheckable=true, func = whisperClick}
  1150.                         end
  1151.                     end
  1152.                 end
  1153.                 if #BNTable > 0 then
  1154.                     local realID, grouped
  1155.                     for i = 1, #BNTable do
  1156.                         info = BNTable[i]
  1157.                         if (info[5]) then
  1158.                             realID = info[2]
  1159.                             menuCountWhispers = menuCountWhispers + 1
  1160.                             menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
  1161.  
  1162.                             if info[6] == wowString and UnitFactionGroup("player") == info[12] then
  1163.                                 classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[14]], GetQuestDifficultyColor(info[16])
  1164.                                 classc = classc or GetQuestDifficultyColor(info[16])
  1165.  
  1166.                                 if UnitInParty(info[4]) or UnitInRaid(info[4]) then grouped = 1 else grouped = 2 end
  1167.                                 menuCountInvites = menuCountInvites + 1
  1168.  
  1169.                                 menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info[16],classc.r*255,classc.g*255,classc.b*255,info[4]), arg1 = info[5], notCheckable=true, func = inviteClick}
  1170.                             end
  1171.                         end
  1172.                     end
  1173.                 end
  1174.  
  1175.                 EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  1176.             else
  1177.                 ToggleFriendsFrame()
  1178.             end
  1179.         end)
  1180.  
  1181.  
  1182.         friendsPlugin:SetScript("OnEnter", function(self)
  1183.            
  1184.             local onlineFriends = C_FriendList_GetNumOnlineFriends()
  1185.             local numberOfFriends = C_FriendList_GetNumFriends()
  1186.             local totalBNet, numBNetOnline = BNGetNumFriends()
  1187.  
  1188.             local totalonline = onlineFriends + numBNetOnline
  1189.            
  1190.             -- no friends online, quick exit
  1191.             if totalonline == 0 then return end
  1192.  
  1193.             if not dataValid then
  1194.                 -- only retrieve information for all on-line members when we actually view the tooltip
  1195.                 if numberOfFriends > 0 then BuildFriendTable(numberOfFriends) end
  1196.                 if totalBNet > 0 then BuildBNTable(totalBNet) end
  1197.                 dataValid = true
  1198.             end
  1199.            
  1200.             local totalfriends = numberOfFriends + totalBNet
  1201.             local zonec, classc, levelc, realmc, grouped
  1202.            
  1203.             if totalonline > 0 then
  1204.                 local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1205.                 GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1206.                 GameTooltip:ClearLines()
  1207.                 GameTooltip:AddDoubleLine(hexa..PLAYER_NAME.."'s"..hexb.." Friends", format(totalOnlineString, totalonline, totalfriends))
  1208.                 if onlineFriends > 0 then
  1209.                     local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1210.                     GameTooltip:SetOwner(panel, anchor, xoff, yoff)    
  1211.                     GameTooltip:AddLine(' ')
  1212.                     GameTooltip:AddLine(worldOfWarcraftString)
  1213.                     for i = 1, #friendTable do
  1214.                         info = friendTable[i]
  1215.                         if info[5] then
  1216.                             if GetZoneText(C_Map.GetBestMapForUnit("player")) == info[4] then zonec = activezone else zonec = inactivezone end
  1217.                             classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
  1218.  
  1219.                             classc = classc or GetQuestDifficultyColor(info[2])
  1220.  
  1221.                             if UnitInParty(info[1]) or UnitInRaid(info[1]) then grouped = 1 else grouped = 2 end
  1222.                             GameTooltip:AddDoubleLine(format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,info[2],info[1],groupedTable[grouped]," "..info[6]),info[4],classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
  1223.                         end
  1224.                     end
  1225.                 end
  1226.                 if numBNetOnline > 0 then
  1227.                     local status = 0
  1228.                     for client, BNTable in pairs(tableList) do
  1229.                         if #BNTable > 0 then
  1230.                             GameTooltip:AddLine(' ')
  1231.                             GameTooltip:AddLine(battleNetString..' ('..client..')')
  1232.                             for i = 1, #BNTable do
  1233.                                 info = BNTable[i]
  1234.                                 if info[6] then
  1235.                                     if info[5] == wowString then
  1236.                                         if (info[7] == true) then status = 1 elseif (info[8] == true) then status = 2 else status = 3 end
  1237.                                         classc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[13]]
  1238.                                         if info[15] ~= '' then
  1239.                                             levelc = GetQuestDifficultyColor(info[15])
  1240.                                         else
  1241.                                             levelc = RAID_CLASS_COLORS["PRIEST"]
  1242.                                             classc = RAID_CLASS_COLORS["PRIEST"]
  1243.                                         end
  1244.  
  1245.                                         if UnitInParty(info[4]) or UnitInRaid(info[4]) then grouped = 1 else grouped = 2 end
  1246.                                         GameTooltip:AddDoubleLine(format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info[15],classc.r*255,classc.g*255,classc.b*255,info[3],groupedTable[grouped], 255, 0, 0, statusTable[status]),info[2],238,238,238,238,238,238)
  1247.                                         if IsShiftKeyDown() then
  1248.                                             if GetZoneText(C_Map.GetBestMapForUnit("player")) == info[14] then zonec = activezone else zonec = inactivezone end
  1249.                                             if GetRealmName() == info[10] then realmc = activezone else realmc = inactivezone end
  1250.                                             GameTooltip:AddDoubleLine(info[14], info[10], zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
  1251.                                         end
  1252.                                     else
  1253.                                         GameTooltip:AddDoubleLine(info[3], info[2], .9, .9, .9, .9, .9, .9)
  1254.                                     end
  1255.                                 end
  1256.                             end
  1257.                         end
  1258.                     end
  1259.                 end
  1260.                 GameTooltip:AddLine' '
  1261.                 GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Friends List")
  1262.                 GameTooltip:AddLine("|cffeda55fShift + Mouseover|r to Show Zone and Realm of Friend")
  1263.                 GameTooltip:AddLine("|cffeda55fRight Click|r to Access Option Menu")           
  1264.                 GameTooltip:Show()
  1265.             else
  1266.                 GameTooltip:Hide()
  1267.             end
  1268.         end)
  1269.        
  1270.         friendsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  1271.         friendsPlugin:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
  1272.         friendsPlugin:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
  1273.         friendsPlugin:RegisterEvent("BN_FRIEND_INFO_CHANGED")
  1274.         friendsPlugin:RegisterEvent("FRIENDLIST_UPDATE")
  1275.         friendsPlugin:RegisterEvent("CHAT_MSG_SYSTEM")
  1276.         friendsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1277.     end
  1278.    
  1279.  
  1280.     ---------
  1281.     -- Guild
  1282.     ---------
  1283.     if db.guild then
  1284.  
  1285.         local guildPlugin = CreateFrame('Frame', nil, Datapanel)
  1286.         guildPlugin:EnableMouse(true)
  1287.         guildPlugin:SetFrameStrata("MEDIUM")
  1288.         guildPlugin:SetFrameLevel(3)
  1289.  
  1290.         local Text  = guildPlugin:CreateFontString(nil, "OVERLAY")
  1291.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  1292.         PlacePlugin(db.guild, Text)
  1293.        
  1294.         local join      = string.join
  1295.         local format    = string.format
  1296.         local split     = string.split 
  1297.  
  1298.         local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  1299.         local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  1300.         local displayString = join("", hexa, GUILD, ":|r ", "%d")
  1301.         local noGuildString = join("", hexa, 'No Guild')
  1302.         local guildInfoString = "%s [%d]"
  1303.         local guildInfoString2 = join("", "Online", ": %d/%d")
  1304.         local guildMotDString = "%s |cffaaaaaa- |cffffffff%s"
  1305.         local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
  1306.         local levelNameStatusString = "|cff%02x%02x%02x%d|r %s %s"
  1307.         local nameRankString = "%s |cff999999-|cffffffff %s"
  1308.         local friendOnline, friendOffline = gsub(_G.ERR_FRIEND_ONLINE_SS,"\124Hplayer:%%s\124h%[%%s%]\124h",""), gsub(_G.ERR_FRIEND_OFFLINE_S,"%%s","")
  1309.         local guildXpCurrentString = gsub(join("", RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b), GUILD_EXPERIENCE_CURRENT), ": ", ":|r |cffffffff", 1)
  1310.         local guildXpDailyString = gsub(join("", RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b), GUILD_EXPERIENCE_DAILY), ": ", ":|r |cffffffff", 1)
  1311.         local standingString = join("", RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b), "%s:|r |cFFFFFFFF%s/%s (%s%%)")
  1312.         local moreMembersOnlineString = join("", "+ %d ", FRIENDS_LIST_ONLINE, "...")
  1313.         local noteString = join("", "|cff999999   ", LABEL_NOTE, ":|r %s")
  1314.         local officerNoteString = join("", "|cff999999   ", GUILD_RANK1_DESC, ":|r %s")
  1315.         local groupedTable = { "|cffaaaaaa*|r", "" }
  1316.         local MOBILE_BUSY_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat-BusyMobile:14:14:0:0:16:16:0:16:0:16|t";
  1317.         local MOBILE_AWAY_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat-AwayMobile:14:14:0:0:16:16:0:16:0:16|t";
  1318.        
  1319.         local guildTable, guildXP, guildMotD = {}, {}, ""
  1320.         local totalOnline = 0
  1321.        
  1322.         local function SortGuildTable(shift)
  1323.             sort(guildTable, function(a, b)
  1324.                 if a and b then
  1325.                     if shift then
  1326.                         return a[10] < b[10]
  1327.                     else
  1328.                         return a[1] < b[1]
  1329.                     end
  1330.                 end
  1331.             end)
  1332.         end
  1333.  
  1334.         local chatframetexture = ChatFrame_GetMobileEmbeddedTexture(73/255, 177/255, 73/255)
  1335.         local onlinestatusstring = "|cffFFFFFF[|r|cffFF0000%s|r|cffFFFFFF]|r"
  1336.         local onlinestatus = {
  1337.             [0] = function () return '' end,
  1338.             [1] = function () return format(onlinestatusstring, 'AFK') end,
  1339.             [2] = function () return format(onlinestatusstring, 'DND') end,
  1340.         }
  1341.         local mobilestatus = {
  1342.             [0] = function () return chatframetexture end,
  1343.             [1] = function () return MOBILE_AWAY_ICON end,
  1344.             [2] = function () return MOBILE_BUSY_ICON end,
  1345.         }
  1346.  
  1347.         local function BuildGuildTable()
  1348.             wipe(guildTable)
  1349.             local statusInfo
  1350.             local _, name, rank, level, zone, note, officernote, connected, memberstatus, class, isMobile
  1351.            
  1352.             local totalMembers = GetNumGuildMembers()
  1353.             for i = 1, totalMembers do
  1354.                 name, rank, rankIndex, level, _, zone, note, officernote, connected, memberstatus, class, _, _, isMobile = GetGuildRosterInfo(i)
  1355.  
  1356.                 statusInfo = isMobile and mobilestatus[memberstatus]() or onlinestatus[memberstatus]()
  1357.                 zone = (isMobile and not connected) and REMOTE_CHAT or zone
  1358.  
  1359.                 if connected or isMobile then
  1360.                     guildTable[#guildTable + 1] = { name, rank, level, zone, note, officernote, connected, statusInfo, class, rankIndex, isMobile }
  1361.                 end
  1362.             end
  1363.         end
  1364.  
  1365.         local function UpdateGuildMessage()
  1366.             guildMotD = GetGuildRosterMOTD()
  1367.         end
  1368.        
  1369.         local FRIEND_ONLINE = select(2, split(" ", ERR_FRIEND_ONLINE_SS, 2))
  1370.         local resendRequest = false
  1371.         local eventHandlers = {
  1372.             ['CHAT_MSG_SYSTEM'] = function(self, arg1)
  1373.                 if(FRIEND_ONLINE ~= nil and arg1 and arg1:find(FRIEND_ONLINE)) then
  1374.                     resendRequest = true
  1375.                 end
  1376.             end,
  1377.             -- when we enter the world and guildframe is not available then
  1378.             -- load guild frame, update guild message and guild xp 
  1379.             ["PLAYER_ENTERING_WORLD"] = function (self, arg1)
  1380.            
  1381.                 if not GuildFrame and IsInGuild() then
  1382.                     LoadAddOn("Blizzard_GuildUI")
  1383.                     GuildRoster()
  1384.                 end
  1385.             end,
  1386.             -- Guild Roster updated, so rebuild the guild table
  1387.             ["GUILD_ROSTER_UPDATE"] = function (self)
  1388.                 if(resendRequest) then
  1389.                     resendRequest = false;
  1390.                     return GuildRoster()
  1391.                 else
  1392.                     BuildGuildTable()
  1393.                     UpdateGuildMessage()
  1394.                     if GetMouseFocus() == self then
  1395.                         self:GetScript("OnEnter")(self, nil, true)
  1396.                     end
  1397.                 end
  1398.             end,
  1399.             -- our guild xp changed, recalculate it
  1400.             ["PLAYER_GUILD_UPDATE"] = function (self, arg1)
  1401.                 GuildRoster()
  1402.             end,
  1403.             -- our guild message of the day changed
  1404.             ["GUILD_MOTD"] = function (self, arg1)
  1405.                 guildMotD = arg1
  1406.             end,
  1407.             --["ELVUI_FORCE_RUN"] = function() end,
  1408.             --["ELVUI_COLOR_UPDATE"] = function() end,
  1409.         }  
  1410.  
  1411.         local function Update(self, event, ...)
  1412.             if IsInGuild() then
  1413.                 eventHandlers[event](self, select(1, ...))
  1414.  
  1415.                 Text:SetFormattedText(displayString, #guildTable)
  1416.             else
  1417.                 Text:SetText(noGuildString)
  1418.             end
  1419.            
  1420.             self:SetAllPoints(Text)
  1421.         end
  1422.            
  1423.         local menuFrame = CreateFrame("Frame", "GuildRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  1424.         local menuList = {
  1425.             { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  1426.             { text = INVITE, hasArrow = true,notCheckable=true,},
  1427.             { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true,}
  1428.         }
  1429.  
  1430.         local function inviteClick(self, arg1, arg2, checked)
  1431.             menuFrame:Hide()
  1432.             InviteUnit(arg1)
  1433.         end
  1434.  
  1435.         local function whisperClick(self,arg1,arg2,checked)
  1436.             menuFrame:Hide()
  1437.             SetItemRef( "player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton" )
  1438.         end
  1439.  
  1440.         --local function ToggleGuildFrame()
  1441.             --if IsInGuild() then
  1442.                 --if not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
  1443.                 --GuildFrame_Toggle()
  1444.                 --GuildFrame_TabClicked(GuildFrameTab2)
  1445.             --else
  1446.                 --if not LookingForGuildFrame then LoadAddOn("Blizzard_LookingForGuildUI") end
  1447.                 --LookingForGuildFrame_Toggle()
  1448.             --end
  1449.         --end
  1450.  
  1451.         guildPlugin:SetScript("OnMouseUp", function(self, btn)
  1452.             if btn ~= "RightButton" or not IsInGuild() then return end
  1453.            
  1454.             GameTooltip:Hide()
  1455.  
  1456.             local classc, levelc, grouped
  1457.             local menuCountWhispers = 0
  1458.             local menuCountInvites = 0
  1459.  
  1460.             menuList[2].menuList = {}
  1461.             menuList[3].menuList = {}
  1462.  
  1463.             for i = 1, #guildTable do
  1464.                 if (guildTable[i][7] and guildTable[i][1] ~= BasicUImyname) then
  1465.                     local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
  1466.  
  1467.                     if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
  1468.                         grouped = "|cffaaaaaa*|r"
  1469.                     else
  1470.                         grouped = ""
  1471.                         if not guildTable[i][10] then
  1472.                             menuCountInvites = menuCountInvites + 1
  1473.                             menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], ""), arg1 = guildTable[i][1],notCheckable=true, func = inviteClick}
  1474.                         end
  1475.                     end
  1476.                     menuCountWhispers = menuCountWhispers + 1
  1477.                     menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], grouped), arg1 = guildTable[i][1],notCheckable=true, func = whisperClick}
  1478.                 end
  1479.             end
  1480.  
  1481.             EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  1482.         end)
  1483.  
  1484.         guildPlugin:SetScript("OnEnter", function(self)
  1485.             if not IsInGuild() then return end
  1486.            
  1487.             local total, _, online = GetNumGuildMembers()
  1488.             if #guildTable == 0 then BuildGuildTable() end
  1489.            
  1490.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1491.             local guildName, guildRank = GetGuildInfo('player')
  1492.            
  1493.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1494.             GameTooltip:ClearLines()       
  1495.             GameTooltip:AddDoubleLine(hexa..PLAYER_NAME.."'s"..hexb.." Guild", format(guildInfoString2, online, total))
  1496.            
  1497.             SortGuildTable(IsShiftKeyDown())
  1498.            
  1499.             if guildMotD ~= "" then
  1500.                 GameTooltip:AddLine(' ')
  1501.                 GameTooltip:AddLine(format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
  1502.             end
  1503.            
  1504.             local col = RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
  1505.            
  1506.             --local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
  1507.             --if standingID ~= 8 then -- Not Max Rep
  1508.                 --barMax = barMax - barMin
  1509.                 --barValue = barValue - barMin
  1510.                 --barMin = 0
  1511.                 --GameTooltip:AddLine(format(standingString, COMBAT_FACTION_CHANGE, ShortValue(barValue), ShortValue(barMax), ceil((barValue / barMax) * 100)))
  1512.             --end
  1513.            
  1514.             local zonec, classc, levelc, info, grouped
  1515.             local shown = 0
  1516.            
  1517.             GameTooltip:AddLine(' ')
  1518.             for i = 1, #guildTable do
  1519.                 -- if more then 30 guild members are online, we don't Show any more, but inform user there are more
  1520.                 if 30 - shown <= 1 then
  1521.                     if online - 30 > 1 then GameTooltip:AddLine(format(moreMembersOnlineString, online - 30), ttsubh.r, ttsubh.g, ttsubh.b) end
  1522.                     break
  1523.                 end
  1524.  
  1525.                 info = guildTable[i]
  1526.                 if GetRealZoneText() == info[4] then zonec = activezone else zonec = inactivezone end
  1527.                 classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[9]], GetQuestDifficultyColor(info[3])
  1528.                
  1529.                 if (UnitInParty(info[1]) or UnitInRaid(info[1])) then grouped = 1 else grouped = 2 end
  1530.  
  1531.                 if IsShiftKeyDown() then
  1532.                     GameTooltip:AddDoubleLine(format(nameRankString, info[1], info[2]), info[4], classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
  1533.                     if info[5] ~= "" then GameTooltip:AddLine(format(noteString, info[5]), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  1534.                     if info[6] ~= "" then GameTooltip:AddLine(format(officerNoteString, info[6]), ttoff.r, ttoff.g, ttoff.b, 1) end
  1535.                 else
  1536.                     GameTooltip:AddDoubleLine(format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, info[3], split("-", info[1]), groupedTable[grouped], info[8]), info[4], classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
  1537.                 end
  1538.                 shown = shown + 1
  1539.             end
  1540.            
  1541.             GameTooltip:Show()
  1542.            
  1543.             if not noUpdate then
  1544.                 GuildRoster()
  1545.             end    
  1546.             GameTooltip:AddLine' '
  1547.             GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Guild Roster")
  1548.             GameTooltip:AddLine("|cffeda55fHold Shift & Mouseover|r to See Guild and Officer Note's")
  1549.             GameTooltip:AddLine("|cffeda55fRight Click|r to open Options Menu")    
  1550.             GameTooltip:Show()
  1551.         end)
  1552.  
  1553.         guildPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1554.         guildPlugin:SetScript("OnMouseDown", function(self, btn)
  1555.             if btn ~= "LeftButton" then return end
  1556.             ToggleFriendsFrame(3)
  1557.         end)
  1558.  
  1559.         --guildPlugin:RegisterEvent("GUILD_ROSTER_SHOW")
  1560.         guildPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  1561.         guildPlugin:RegisterEvent("GUILD_ROSTER_UPDATE")
  1562.         guildPlugin:RegisterEvent("PLAYER_GUILD_UPDATE")
  1563.         guildPlugin:SetScript("OnEvent", Update)
  1564.     end
  1565.  
  1566.     ---------------
  1567.     -- Professions
  1568.     ---------------
  1569.     if db.pro then
  1570.  
  1571.         local proPlugin = CreateFrame('Button', nil, Datapanel)
  1572.         proPlugin:RegisterEvent('PLAYER_ENTERING_WORLD')
  1573.         proPlugin:SetFrameStrata('BACKGROUND')
  1574.         proPlugin:SetFrameLevel(3)
  1575.         proPlugin:EnableMouse(true)
  1576.         proPlugin.tooltip = false
  1577.  
  1578.         local Text = proPlugin:CreateFontString(nil, 'OVERLAY')
  1579.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  1580.         PlacePlugin(db.pro, Text)
  1581.  
  1582.         local function Update(self)
  1583.             Text:SetFormattedText(hexa.."Professions"..hexb)
  1584.             self:SetAllPoints(Text)
  1585.         end
  1586.  
  1587.         proPlugin:SetScript('OnEnter', function()      
  1588.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1589.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1590.             GameTooltip:ClearLines()
  1591.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Professions")
  1592.             GameTooltip:AddLine' '
  1593.             local section, primary, secondary, weapons, other = 0, {}, {}, {}, {}
  1594.              
  1595.             for i = 1, GetNumSkillLines() do
  1596.                 local skillName, isHeader, _, skillRank, _, _, skillMaxRank = GetSkillLineInfo(i)
  1597.                 if isHeader then
  1598.                     section = section + 1
  1599.                     if section == 2 then
  1600.                         primary.n = skillName
  1601.                     elseif section == 3 then
  1602.                         secondary.n = skillName
  1603.                     elseif section == 4 then
  1604.                         weapons.n = skillName
  1605.                     end
  1606.                 else
  1607.                     tinsert( section == 2 and primary or section == 3 and secondary or section == 4 and weapons or other,  {skillName,skillRank..' / '..skillMaxRank,.75,.9,1,.3,1,.3} )
  1608.                 end
  1609.             end
  1610.              
  1611.             GameTooltip:AddLine(primary.n)
  1612.             for i = 1, #primary do
  1613.                 GameTooltip:AddDoubleLine( unpack( primary[i] ) )
  1614.             end
  1615.              
  1616.             GameTooltip:AddLine(" ")
  1617.             GameTooltip:AddLine(secondary.n)
  1618.             for i = 1, #secondary do
  1619.                 GameTooltip:AddDoubleLine( unpack( secondary[i] ) )
  1620.             end
  1621.              
  1622.             GameTooltip:AddLine(" ")
  1623.             GameTooltip:AddLine(weapons.n)
  1624.             for i = 1, #weapons do
  1625.                 GameTooltip:AddDoubleLine( unpack( weapons[i] ) )
  1626.             end
  1627.             GameTooltip:AddLine' '
  1628.             GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Spell Book")
  1629.  
  1630.  
  1631.             GameTooltip:Show()
  1632.         end)
  1633.  
  1634.  
  1635.         proPlugin:SetScript("OnClick",function(self,btn)
  1636.             local section, primary, secondary, weapons, other = 0, {}, {}, {}, {}
  1637.             if btn == "LeftButton" then
  1638.                 ToggleSpellBook("spell");
  1639.             end
  1640.         end)
  1641.  
  1642.  
  1643.         proPlugin:RegisterForClicks("AnyUp")
  1644.         proPlugin:SetScript('OnUpdate', Update)
  1645.         proPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
  1646.     end
  1647.  
  1648.  
  1649.     -----------
  1650.     -- Recount
  1651.     -----------
  1652.     if db.recount then
  1653.  
  1654.         local math_abs=math.abs;
  1655.         local math_floor=math.floor;
  1656.         local math_log10=math.log10;
  1657.         local math_max=math.max;
  1658.         local tostring=tostring;
  1659.          
  1660.         local NumberCaps={"K","M","B","T"};
  1661.         local function AbbreviateNumber(val)
  1662.             local exp=math_max(0,math_floor(math_log10(math_abs(val))));
  1663.             if exp<3 then return tostring(math_floor(val)); end
  1664.          
  1665.             local factor=math_floor(exp/3);
  1666.             local precision=math_max(0,2-exp%3);
  1667.             return ((val<0 and "-" or "").."%0."..precision.."f%s"):format(val/1000^factor,NumberCaps[factor] or "e "..(factor*3));
  1668.         end
  1669.  
  1670.        
  1671.         local recountPlugin = CreateFrame('Frame', nil, Datapanel)
  1672.         recountPlugin:EnableMouse(true)
  1673.         recountPlugin:SetFrameStrata("MEDIUM")
  1674.         recountPlugin:SetFrameLevel(3)
  1675.        
  1676.        
  1677.         local Text  = recountPlugin:CreateFontString(nil, "OVERLAY")
  1678.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  1679.         PlacePlugin(db.recount, Text)
  1680.         recountPlugin:SetAllPoints(Text)
  1681.            
  1682.  
  1683.         function OnEvent(self, event, ...)
  1684.             if event == "PLAYER_LOGIN" then
  1685.                 if IsAddOnLoaded("Recount") then
  1686.                     recountPlugin:RegisterEvent("PLAYER_REGEN_ENABLED")
  1687.                     recountPlugin:RegisterEvent("PLAYER_REGEN_DISABLED")
  1688.                     PLAYER_NAME = UnitName("player")
  1689.                     currentFightDPS = 0
  1690.                 else
  1691.                     return
  1692.                 end
  1693.                 recountPlugin:UnregisterEvent("PLAYER_LOGIN")
  1694.                
  1695.             elseif event == "PLAYER_ENTERING_WORLD" then
  1696.                 self.updateDPS()
  1697.                 recountPlugin:UnregisterEvent("PLAYER_ENTERING_WORLD")
  1698.             end
  1699.         end
  1700.  
  1701.         function recountPlugin:RecountHook_UpdateText()
  1702.             self:updateDPS()
  1703.         end
  1704.  
  1705.         function recountPlugin:updateDPS()
  1706.             if IsAddOnLoaded("Recount") then
  1707.                 Text:SetText(hexa.."DPS: "..hexb.. AbbreviateNumber(recountPlugin.getDPS()) .. "|r")
  1708.             else
  1709.                 Text:SetText(hexa.."DPS: "..hexb.. "N/A".."|r")
  1710.             end
  1711.         end
  1712.  
  1713.         function recountPlugin:getDPS()
  1714.             if not IsAddOnLoaded("Recount") then return "N/A" end
  1715.             if db.recountraiddps == true then
  1716.                 -- show raid dps
  1717.                 _, dps = recountPlugin:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  1718.                 return dps
  1719.             else
  1720.                 return recountPlugin.getValuePerSecond()
  1721.             end
  1722.         end
  1723.  
  1724.         -- quick dps calculation from recount's data
  1725.         function recountPlugin:getValuePerSecond()
  1726.             local _, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[PLAYER_NAME], Recount.db.profile.CurDataSet)
  1727.             return math.floor(10 * dps + 0.5) / 10
  1728.         end
  1729.  
  1730.         function recountPlugin:getRaidValuePerSecond(tablename)
  1731.             local dps, curdps, data, damage, temp = 0, 0, nil, 0, 0
  1732.             for _,data in pairs(Recount.db2.combatants) do
  1733.                 if data.Fights and data.Fights[tablename] and (data.type=="Self" or data.type=="Grouped" or data.type=="Pet" or data.type=="Ungrouped") then
  1734.                     temp, curdps = Recount:MergedPetDamageDPS(data,tablename)
  1735.                     if data.type ~= "Pet" or (not Recount.db.profile.MergePets and data.Owner and (Recount.db2.combatants[data.Owner].type=="Self" or Recount.db2.combatants[data.Owner].type=="Grouped" or Recount.db2.combatants[data.Owner].type=="Ungrouped")) or (not Recount.db.profile.MergePets and data.Name and data.GUID and self:matchUnitGUID(data.Name, data.GUID)) then
  1736.                         dps = dps + 10 * curdps
  1737.                         damage = damage + temp
  1738.                     end
  1739.                 end
  1740.             end
  1741.             return math.floor(damage + 0.5) / 10, math.floor(dps + 0.5)/10
  1742.         end
  1743.  
  1744.         -- tracked events
  1745.         recountPlugin:RegisterEvent("PLAYER_LOGIN")
  1746.         recountPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  1747.  
  1748.         -- scripts
  1749.         recountPlugin:SetScript("OnEnter", function(self)  
  1750.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1751.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1752.             GameTooltip:ClearLines()
  1753.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Damage")
  1754.             GameTooltip:AddLine' '     
  1755.             if IsAddOnLoaded("Recount") then
  1756.                 local damage, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[PLAYER_NAME], Recount.db.profile.CurDataSet)
  1757.                 local raid_damage, raid_dps = recountPlugin:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  1758.                 -- format the number
  1759.                 dps = math.floor(10 * dps + 0.5) / 10
  1760.                 GameTooltip:AddLine("Recount")
  1761.                 GameTooltip:AddDoubleLine("Personal Damage:", AbbreviateNumber(damage), 1, 1, 1, 0.8, 0.8, 0.8)
  1762.                 GameTooltip:AddDoubleLine("Personal DPS:", AbbreviateNumber(dps), 1, 1, 1, 0.8, 0.8, 0.8)
  1763.                 GameTooltip:AddLine(" ")
  1764.                 GameTooltip:AddDoubleLine("Raid Damage:", AbbreviateNumber(raid_damage), 1, 1, 1, 0.8, 0.8, 0.8)
  1765.                 GameTooltip:AddDoubleLine("Raid DPS:", AbbreviateNumber(raid_dps), 1, 1, 1, 0.8, 0.8, 0.8)
  1766.                 GameTooltip:AddLine(" ")
  1767.                 GameTooltip:AddLine("|cffeda55fLeft Click|r to toggle Recount")
  1768.                 GameTooltip:AddLine("|cffeda55fRight Click|r to reset data")
  1769.                 GameTooltip:AddLine("|cffeda55fShift + Right Click|r to open config")
  1770.             else
  1771.                 GameTooltip:AddLine("Recount is not loaded.", 255, 0, 0)
  1772.                 GameTooltip:AddLine("Enable Recount and reload your UI.")
  1773.             end
  1774.             GameTooltip:Show()
  1775.         end)
  1776.         recountPlugin:SetScript("OnMouseUp", function(self, button)
  1777.             if button == "RightButton" then
  1778.                 if not IsShiftKeyDown() then
  1779.                     Recount:ShowReset()
  1780.                 else
  1781.                     Recount:ShowConfig()
  1782.                 end
  1783.             elseif button == "LeftButton" then
  1784.                 if Recount.MainWindow:IsShown() then
  1785.                     Recount.MainWindow:Hide()
  1786.                 else
  1787.                     Recount.MainWindow:Show()
  1788.                     Recount:RefreshMainWindow()
  1789.                 end
  1790.             end
  1791.         end)
  1792.         recountPlugin:SetScript("OnEvent", OnEvent)
  1793.         recountPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  1794.         recountPlugin:SetScript("OnUpdate", function(self, t)
  1795.             local int = -1
  1796.             int = int - t
  1797.             if int < 0 then
  1798.                 self.updateDPS()
  1799.                 int = 1
  1800.             end
  1801.         end)
  1802.     end
  1803.  
  1804.     -----------------
  1805.     -- Spec
  1806.     -----------------
  1807.  
  1808.     if db.spec then
  1809.  
  1810.         local specPlugin = CreateFrame('Frame', nil, Datapanel)
  1811.         specPlugin:EnableMouse(true)
  1812.         specPlugin:SetFrameStrata('BACKGROUND')
  1813.         specPlugin:SetFrameLevel(3)
  1814.  
  1815.         local Text = specPlugin:CreateFontString(nil, 'OVERLAY')
  1816.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  1817.         PlacePlugin(db.spec, Text)
  1818.  
  1819.         local talent = {}
  1820.         local active
  1821.         local talentString = string.join('', '|cffFFFFFF%s|r ')
  1822.         local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  1823.         local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  1824.  
  1825.  
  1826.  
  1827.         --[[local function LoadTalentTrees()
  1828.             for i = 1, GetNumSpecGroups(false, false) do
  1829.                 talent[i] = {} -- init talent group table
  1830.                 for j = 1, GetNumSpecializations(false, false) do
  1831.                     talent[i][j] = select(5, GetSpecializationInfo(j, false, false, i))
  1832.                 end
  1833.             end
  1834.         end]]
  1835.  
  1836.         local int = 5
  1837.         local function Update(self, t)
  1838.            
  1839.             int = int - t
  1840.             if int > 0 then return end
  1841.             active = GetActiveSpecGroup(false, false)
  1842.             if playerRole ~= nil then
  1843.                 Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
  1844.             else
  1845.                 Text:SetText(hexa.."No Spec"..hexb)
  1846.             end
  1847.             int = 2
  1848.  
  1849.             -- disable script  
  1850.             --self:SetScript('OnUpdate', nil)
  1851.            
  1852.         end
  1853.  
  1854.  
  1855.         specPlugin:SetScript('OnEnter', function(self)
  1856.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1857.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1858.  
  1859.             GameTooltip:ClearLines()
  1860.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Spec")
  1861.             GameTooltip:AddLine' '
  1862.             if playerRole ~= nil then
  1863.                 for i = 1, GetNumSpecGroups() do
  1864.                     if GetSpecialization(false, false, i) then
  1865.                         GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == active and activeString or inactiveString)),1,1,1)
  1866.                     end
  1867.                 end
  1868.             else
  1869.                 GameTooltip:AddLine("You have not chosen a Spec yet.")
  1870.             end
  1871.             GameTooltip:AddLine' '      
  1872.             GameTooltip:AddLine("|cffeda55fClick|r to Open Talent Tree")
  1873.             GameTooltip:Show()
  1874.         end)
  1875.  
  1876.         specPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
  1877.  
  1878.         local function OnEvent(self, event, ...)
  1879.             if event == 'PLAYER_ENTERING_WORLD' then
  1880.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  1881.             end
  1882.            
  1883.             -- load talent information
  1884.             --LoadTalentTrees()
  1885.  
  1886.             -- Setup Talents Tooltip
  1887.             self:SetAllPoints(Text)
  1888.  
  1889.             -- update datatext
  1890.             if event ~= 'PLAYER_ENTERING_WORLD' then
  1891.                 self:SetScript('OnUpdate', Update)
  1892.             end
  1893.         end
  1894.  
  1895.  
  1896.  
  1897.         specPlugin:RegisterEvent('PLAYER_ENTERING_WORLD');
  1898.         specPlugin:RegisterEvent('CHARACTER_POINTS_CHANGED');
  1899.         specPlugin:RegisterEvent('PLAYER_TALENT_UPDATE');
  1900.         specPlugin:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  1901.         specPlugin:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  1902.         specPlugin:SetScript('OnEvent', OnEvent)
  1903.         specPlugin:SetScript('OnUpdate', Update)
  1904.  
  1905.         specPlugin:SetScript("OnMouseDown", function() ToggleTalentFrame() end)
  1906.     end
  1907.     -----------------
  1908.     -- Stats
  1909.     -----------------
  1910.     if db.stats then
  1911.  
  1912.         local statsPlugin = CreateFrame('Frame', nil, Datapanel)
  1913.         statsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  1914.         statsPlugin:SetFrameStrata("BACKGROUND")
  1915.         statsPlugin:SetFrameLevel(3)
  1916.         statsPlugin:EnableMouse(true)
  1917.  
  1918.         local Text = statsPlugin:CreateFontString(nil, "OVERLAY")
  1919.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  1920.         PlacePlugin(db.stats, Text)
  1921.  
  1922.         local function ShowTooltip(self)   
  1923.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  1924.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  1925.             GameTooltip:ClearLines()
  1926.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  1927.             GameTooltip:AddLine' '     
  1928.             if playerRole == nil then
  1929.                 GameTooltip:AddLine("Choose a Specialization to see Stats")
  1930.             else
  1931.                 if playerRole == playerRole.Tank then
  1932.                     local Total_Dodge = GetDodgeChance()
  1933.                     local Total_Parry = GetParryChance()
  1934.                     local Total_Block = GetBlockChance()
  1935.                    
  1936.                     GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  1937.                     GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  1938.                     GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  1939.                     GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)               
  1940.                    
  1941.                 elseif playerRole == playerRole.Healer then
  1942.                     local SC = GetSpellCritChance("2")
  1943.                     local Total_Spell_Haste = UnitSpellHaste("player")
  1944.                     local base, casting = GetManaRegen()
  1945.                     local manaRegenString = "%d / %d"              
  1946.                    
  1947.                     GameTooltip:AddLine(STAT_CATEGORY_SPELL)
  1948.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", SC), 1, 1, 1)
  1949.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Spell_Haste), 1, 1, 1)    
  1950.                     GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, casting * 5), 1, 1, 1)
  1951.  
  1952.                 elseif playerRole == playerRole.Damager then           
  1953.                     if Class == Class.Hunter then
  1954.                         local Total_Range_Haste = GetRangedHaste("player")
  1955.                         local Range_Crit = GetRangedCritChance("25")
  1956.                         local speed = UnitRangedDamage("player")
  1957.                         local Total_Range_Speed = speed
  1958.                        
  1959.                         GameTooltip:AddLine(STAT_CATEGORY_RANGED)                  
  1960.                         GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Range_Crit), 1, 1, 1) 
  1961.                         GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Range_Haste), 1, 1, 1)
  1962.                         GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", Total_Range_Speed), 1, 1, 1)                 
  1963.                     else
  1964.                         local Melee_Crit = GetCritChance("player")
  1965.                         local Total_Melee_Haste = GetMeleeHaste("player")
  1966.                         local mainSpeed = UnitAttackSpeed("player");
  1967.                         local MH = mainSpeed
  1968.                        
  1969.                         GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  1970.                         GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  1971.                         GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  1972.                         GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)
  1973.                     end
  1974.                 end
  1975.                 --[[if GetCombatRating(CR_MASTERY) ~= 0 and GetSpecialization() then
  1976.                     local masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  1977.                     local Mastery = GetMasteryEffect("player")
  1978.                     local masteryName, _, _, _, _, _, _, _, _ = GetSpellInfo(masteryspell)
  1979.                     if masteryName then
  1980.                         GameTooltip:AddDoubleLine(masteryName, format("%.2f%%", Mastery), 1, 1, 1)
  1981.                     end
  1982.                 end]]
  1983.                    
  1984.                 GameTooltip:AddLine' '
  1985.                 GameTooltip:AddLine(STAT_CATEGORY_GENERAL)
  1986.                
  1987.                 --local Life_Steal = GetLifesteal();
  1988.                 --local Versatility_Damage_Bonus = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE);
  1989.                 --local Avoidance = GetAvoidance();
  1990.                
  1991.                 --GameTooltip:AddDoubleLine(STAT_LIFESTEAL, format("%.2f%%", Life_Steal), 1, 1, 1)
  1992.                 --GameTooltip:AddDoubleLine(STAT_VERSATILITY, format("%.2f%%", Versatility_Damage_Bonus), 1, 1, 1)
  1993.                 --GameTooltip:AddDoubleLine(STAT_AVOIDANCE, format("%.2f%%", Avoidance), 1, 1, 1)          
  1994.             end
  1995.  
  1996.             GameTooltip:Show()
  1997.         end
  1998.  
  1999.         local function UpdateTank(self)
  2000.             local armorString = hexa..ARMOR..hexb..": "
  2001.             local displayNumberString = string.join("", "%s", "%d|r");
  2002.             local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  2003.             local Melee_Reduction = effectiveArmor
  2004.            
  2005.             Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  2006.             --Setup Tooltip
  2007.             self:SetAllPoints(Text)
  2008.         end
  2009.  
  2010.         local function UpdateCaster(self)
  2011.             local spellpwr = GetSpellBonusDamage("2");
  2012.             local displayNumberString = string.join("", "%s", "%d|r");
  2013.            
  2014.             Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  2015.            
  2016.             --Setup Tooltip
  2017.             self:SetAllPoints(Text)
  2018.         end
  2019.  
  2020.         local function UpdateDamager(self) 
  2021.             local displayNumberString = string.join("", "%s", "%d|r");
  2022.                
  2023.             if playerClass == playerClass.Hunter then
  2024.                 local base, posBuff, negBuff = UnitRangedAttackPower("player")
  2025.                 local Range_AP = base + posBuff + negBuff  
  2026.                 pwr = Range_AP
  2027.             else
  2028.                 local base, posBuff, negBuff = UnitAttackPower("player")
  2029.                 local Melee_AP = base + posBuff + negBuff      
  2030.                 pwr = Melee_AP
  2031.             end
  2032.            
  2033.             Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)      
  2034.             --Setup Tooltip
  2035.             self:SetAllPoints(Text)
  2036.         end
  2037.  
  2038.         -- initial delay for update (let the ui load)
  2039.         local int = 5  
  2040.         local function Update(self, t)
  2041.             if playerRole == nil then
  2042.                 Text:SetText(hexa.."No Stats"..hexb)
  2043.             else
  2044.                 if playerRole == playerRole.Tank then
  2045.                     UpdateTank(self)
  2046.                 elseif playerRole == playerRole.Healer then
  2047.                     UpdateCaster(self)
  2048.                 elseif playerRole == playerRole.Damager then
  2049.                     UpdateDamager(self)
  2050.                 end
  2051.             end
  2052.         end
  2053.  
  2054.         statsPlugin:SetScript("OnEnter", function() ShowTooltip(statsPlugin) end)
  2055.         statsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2056.         statsPlugin:SetScript("OnUpdate", Update)
  2057.         Update(statsPlugin, 10)
  2058.     end
  2059.  
  2060.     -------------------
  2061.     -- System Settings
  2062.     -------------------
  2063.     if db.system then
  2064.  
  2065.         local systemPlugin = CreateFrame('Frame', nil, Datapanel)
  2066.         systemPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  2067.         systemPlugin:SetFrameStrata("BACKGROUND")
  2068.         systemPlugin:SetFrameLevel(3)
  2069.         systemPlugin:EnableMouse(true)
  2070.         systemPlugin.tooltip = false
  2071.  
  2072.         local Text = systemPlugin:CreateFontString(nil, "OVERLAY")
  2073.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  2074.         PlacePlugin(db.system, Text)
  2075.  
  2076.         local bandwidthString = "%.2f Mbps"
  2077.         local percentageString = "%.2f%%"
  2078.         local homeLatencyString = "%d ms"
  2079.         local worldLatencyString = "%d ms"
  2080.         local kiloByteString = "%d kb"
  2081.         local megaByteString = "%.2f mb"
  2082.  
  2083.         local function formatMem(memory)
  2084.             local mult = 10^1
  2085.             if memory > 999 then
  2086.                 local mem = ((memory/1024) * mult) / mult
  2087.                 return string.format(megaByteString, mem)
  2088.             else
  2089.                 local mem = (memory * mult) / mult
  2090.                 return string.format(kiloByteString, mem)
  2091.             end
  2092.         end
  2093.  
  2094.         local memoryTable = {}
  2095.  
  2096.         local function RebuildAddonList(self)
  2097.             local addOnCount = GetNumAddOns()
  2098.             if (addOnCount == #memoryTable) or self.tooltip == true then return end
  2099.  
  2100.             -- Number of loaded addons changed, create new memoryTable for all addons
  2101.             memoryTable = {}
  2102.             for i = 1, addOnCount do
  2103.                 memoryTable[i] = { i, select(2, GetAddOnInfo(i)), 0, IsAddOnLoaded(i) }
  2104.             end
  2105.             self:SetAllPoints(Text)
  2106.         end
  2107.  
  2108.         local function UpdateMemory()
  2109.             -- Update the memory usages of the addons
  2110.             UpdateAddOnMemoryUsage()
  2111.             -- Load memory usage in table
  2112.             local addOnMem = 0
  2113.             local totalMemory = 0
  2114.             for i = 1, #memoryTable do
  2115.                 addOnMem = GetAddOnMemoryUsage(memoryTable[i][1])
  2116.                 memoryTable[i][3] = addOnMem
  2117.                 totalMemory = totalMemory + addOnMem
  2118.             end
  2119.             -- Sort the table to put the largest addon on top
  2120.             table.sort(memoryTable, function(a, b)
  2121.                 if a and b then
  2122.                     return a[3] > b[3]
  2123.                 end
  2124.             end)
  2125.            
  2126.             return totalMemory
  2127.         end
  2128.  
  2129.         -- initial delay for update (let the ui load)
  2130.         local int, int2 = 6, 5
  2131.         local statusColors = {
  2132.             "|cff0CD809",
  2133.             "|cffE8DA0F",
  2134.             "|cffFF9000",
  2135.             "|cffD80909"
  2136.         }
  2137.  
  2138.         local function Update(self, t)
  2139.             int = int - t
  2140.             int2 = int2 - t
  2141.            
  2142.             if int < 0 then
  2143.                 RebuildAddonList(self)
  2144.                 int = 10
  2145.             end
  2146.             if int2 < 0 then
  2147.                 local framerate = floor(GetFramerate())
  2148.                 local fpscolor = 4
  2149.                 local latency = select(4, GetNetStats())
  2150.                 local latencycolor = 4
  2151.                            
  2152.                 if latency < 150 then
  2153.                     latencycolor = 1
  2154.                 elseif latency >= 150 and latency < 300 then
  2155.                     latencycolor = 2
  2156.                 elseif latency >= 300 and latency < 500 then
  2157.                     latencycolor = 3
  2158.                 end
  2159.                 if framerate >= 30 then
  2160.                     fpscolor = 1
  2161.                 elseif framerate >= 20 and framerate < 30 then
  2162.                     fpscolor = 2
  2163.                 elseif framerate >= 10 and framerate < 20 then
  2164.                     fpscolor = 3
  2165.                 end
  2166.                 local displayFormat = string.join("", hexa.."FPS: "..hexb, statusColors[fpscolor], "%d|r", hexa.." MS: "..hexb, statusColors[latencycolor], "%d|r")
  2167.                 Text:SetFormattedText(displayFormat, framerate, latency)
  2168.                 int2 = 1
  2169.             end
  2170.         end
  2171.         systemPlugin:SetScript("OnMouseDown", function () collectgarbage("collect") Update(systemPlugin, 20) end)
  2172.         systemPlugin:SetScript("OnEnter", function(self)       
  2173.             local bandwidth = GetAvailableBandwidth()
  2174.             local _, _, latencyHome, latencyWorld = GetNetStats()
  2175.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2176.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2177.             GameTooltip:ClearLines()
  2178.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Latency")
  2179.             GameTooltip:AddLine' '         
  2180.             GameTooltip:AddDoubleLine("Home Latency: ", string.format(homeLatencyString, latencyHome), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  2181.             GameTooltip:AddDoubleLine("World Latency: ", string.format(worldLatencyString, latencyWorld), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  2182.  
  2183.             if bandwidth ~= 0 then
  2184.                 GameTooltip:AddDoubleLine(L.datatext_bandwidth , string.format(bandwidthString, bandwidth),0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  2185.                 GameTooltip:AddDoubleLine("Download: " , string.format(percentageString, GetDownloadedPercentage() *100),0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
  2186.                 GameTooltip:AddLine(" ")
  2187.             end
  2188.             local totalMemory = UpdateMemory()
  2189.             GameTooltip:AddDoubleLine("Total Memory Usage:", formatMem(totalMemory), 0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  2190.             GameTooltip:AddLine(" ")
  2191.             for i = 1, #memoryTable do
  2192.                 if (memoryTable[i][4]) then
  2193.                     local red = memoryTable[i][3] / totalMemory
  2194.                     local green = 1 - red
  2195.                     GameTooltip:AddDoubleLine(memoryTable[i][2], formatMem(memoryTable[i][3]), 1, 1, 1, red, green + .5, 0)
  2196.                 end                    
  2197.             end
  2198.             GameTooltip:Show()
  2199.         end)
  2200.         systemPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2201.         systemPlugin:SetScript("OnUpdate", Update)
  2202.         Update(systemPlugin, 10)
  2203.     end
  2204. end
  2205.  
  2206. function MODULE:OnInitialize()
  2207.     self.db = BasicUI.db:RegisterNamespace(MODULE_NAME, defaults)
  2208.     db = self.db.profile   
  2209.  
  2210.     local _, class = UnitClass("player")
  2211.     classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  2212.  
  2213.     self:SetEnabledState(BasicUI:GetModuleEnabled(MODULE_NAME))
  2214. end
  2215.  
  2216.  
  2217. function MODULE:OnEnable()
  2218.     -- This line should not be needed if you're using modules correctly:
  2219.     if not db.enable then return end
  2220.  
  2221.     if db.enable then -- How is this different than "enable" ? If the panel is not enabled, what's the point of doing anything else?
  2222.         self:CreatePanels(); -- factor this giant blob out into its own function to keep things clean
  2223.         self:ShowPanel()
  2224.         self:HidePanel()
  2225.         self:Refresh()
  2226.        
  2227.         self:RegisterEvent("PLAYER_LOSES_VEHICLE_DATA", "ShowPanel");
  2228.         self:RegisterEvent("UNIT_EXITED_VEHICLE", "ShowPanel");
  2229.         self:RegisterEvent("PET_BATTLE_CLOSE", "ShowPanel");
  2230.         self:RegisterEvent("PLAYER_ENTERING_WORLD", "ShowPanel");
  2231.         self:RegisterEvent("PLAYER_GAINS_VEHICLE_DATA", "HidePanel");
  2232.         self:RegisterEvent("UNIT_ENTERED_VEHICLE", "HidePanel");
  2233.         self:RegisterEvent("PET_BATTLE_OPENING_DONE", "HidePanel");        
  2234.            
  2235.        
  2236.     end
  2237. end
  2238.  
  2239. function MODULE:Refresh()
  2240.     if InCombatLockdown() then
  2241.         return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
  2242.     end
  2243.     self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  2244.  
  2245.     self:CreateStats()
  2246.  
  2247. end
  2248.  
  2249. function MODULE:SetFontString(parent, file, size, flags)
  2250.     local fs = parent:CreateFontString(nil, "OVERLAY")
  2251.     fs:SetFont(file, size, flags)
  2252.     return fs
  2253. end
  2254.  
  2255.  
  2256. ------------------------------------------------------------------------
  2257. --   Module Options
  2258. ------------------------------------------------------------------------
  2259.  
  2260. local options
  2261. function MODULE:GetOptions()
  2262.     if options then
  2263.         return options
  2264.     end
  2265.  
  2266.     local function isModuleDisabled()
  2267.         return not BasicUI:GetModuleEnabled(MODULE_NAME)
  2268.     end
  2269.  
  2270.     local statposition = {
  2271.         ["P0"] = L["Not Shown"],
  2272.         ["P1"] = L["Position #1"],
  2273.         ["P2"] = L["Position #2"],
  2274.         ["P3"] = L["Position #3"],
  2275.         ["P4"] = L["Position #4"],
  2276.         ["P5"] = L["Position #5"],
  2277.         ["P6"] = L["Position #6"],
  2278.         ["P7"] = L["Position #7"],
  2279.         ["P8"] = L["Position #8"],
  2280.         ["P9"] = L["Position #9"],
  2281.     }
  2282.    
  2283.     options = {
  2284.         type = "group",
  2285.         name = L[MODULE_NAME],
  2286.         childGroups = "tree",
  2287.         get = function(info) return db[ info[#info] ] end,
  2288.         set = function(info, value) db[ info[#info] ] = value; StaticPopup_Show("CFG_RELOAD") end,
  2289.         disabled = isModuleDisabled(),
  2290.         args = {
  2291.             ---------------------------
  2292.             --Option Type Seperators
  2293.             sep1 = {
  2294.                 type = "description",
  2295.                 order = 2,
  2296.                 name = " ",
  2297.             },
  2298.             sep2 = {
  2299.                 type = "description",
  2300.                 order = 3,
  2301.                 name = " ",
  2302.             },
  2303.             sep3 = {
  2304.                 type = "description",
  2305.                 order = 4,
  2306.                 name = " ",
  2307.             },
  2308.             sep4 = {
  2309.                 type = "description",
  2310.                 order = 5,
  2311.                 name = " ",
  2312.             },
  2313.             ---------------------------
  2314.             Text1 = {
  2315.                 type = "description",
  2316.                 order = 1,
  2317.                 name = " ",
  2318.                 width = "full",
  2319.             },
  2320.             enable = {
  2321.                 type = "toggle",
  2322.                 order = 1,
  2323.                 name = L["Enable"],
  2324.                 desc = L["Enables the Datapanel Module for |cff00B4FFBasic|rUI."],
  2325.                 width = "full",
  2326.                 disabled = false,
  2327.             },
  2328.             bag = {
  2329.                 type = "toggle",
  2330.                 order = 2,
  2331.                 name = L["Bag Open"],
  2332.                 desc = L["Checked opens Backpack only, Unchecked opens all bags."],
  2333.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2334.             },
  2335.             battleground = {
  2336.                 type = "toggle",
  2337.                 order = 2,
  2338.                 name = L["Battleground Text"],
  2339.                 desc = L["Display special datapanels when inside a battleground"],
  2340.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2341.             },
  2342.             enableColor = {
  2343.                 type = "toggle",                   
  2344.                 order = 2,
  2345.                 name = L["Enable Class Color"],
  2346.                 desc = L["Use your classcolor text."],
  2347.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2348.             },
  2349.             recountraiddps = {
  2350.                 type = "toggle",
  2351.                 order = 2,
  2352.                 name = L["Recount Raid DPS"],
  2353.                 desc = L["Display Recount's Raid DPS (RECOUNT MUST BE INSTALLED)"],
  2354.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2355.             },
  2356.             fontSize = {
  2357.                 type = "range",
  2358.                 order = 4,                     
  2359.                 name = L["Plugin Font Size"],
  2360.                 desc = L["Controls the Size of the Plugin Font"],
  2361.                 min = 0,
  2362.                 max = 30,
  2363.                 step = 1,
  2364.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2365.             },
  2366.             DataGroup = {
  2367.                 type = "group",
  2368.                 order = 5,
  2369.                 name = L["Text Positions"],
  2370.                 guiInline  = true,
  2371.                 disabled = function() return isModuleDisabled() or not db.enable end,
  2372.                 args = {
  2373.                     GroupDesc = {
  2374.                         type = "description",
  2375.                         order = 0,
  2376.                         name = " ",
  2377.                         desc = L["Chose wich location you would like each stat."],
  2378.                         width = "full",
  2379.                     },
  2380.                     bags = {
  2381.                         type = "select",
  2382.                         order = 2,
  2383.                         name = L["Bags"],
  2384.                         desc = L["Display amount of bag space"],
  2385.                         values = statposition;
  2386.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2387.                     },
  2388.                     calltoarms = {
  2389.                         type = "select",
  2390.                         order = 2,
  2391.                         name = L["Call to Arms"],
  2392.                         desc = L["Display the active roles that will recieve a reward for completing a random dungeon"],
  2393.                         values = statposition;
  2394.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2395.                     },
  2396.                     dps = {
  2397.                         type = "select",
  2398.                         order = 2,
  2399.                         name = L["DPS"],
  2400.                         desc = L["Display amount of DPS"],
  2401.                         values = statposition;
  2402.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2403.                     },
  2404.                     dur = {
  2405.                         type = "select",
  2406.                         order = 2,
  2407.                         name = L["Durability"],
  2408.                         desc = L["Display your current durability"],
  2409.                         values = statposition;
  2410.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2411.                     },
  2412.                     friends = {
  2413.                         type = "select",
  2414.                         order = 2,
  2415.                         name = L["Friends"],
  2416.                         desc = L["Display current online friends"],
  2417.                         values = statposition;
  2418.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2419.                     },
  2420.                     guild = {
  2421.                         type = "select",
  2422.                         order = 2,
  2423.                         name = L["Guild"],
  2424.                         desc = L["Display current online people in guild"],
  2425.                         values = statposition;
  2426.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2427.                     },
  2428.                     pro = {
  2429.                         type = "select",
  2430.                         order = 2,
  2431.                         name = L["Professions"],
  2432.                         desc = L["Display Professions"],
  2433.                         values = statposition;
  2434.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2435.                     },
  2436.                     recount = {
  2437.                         type = "select",
  2438.                         order = 2,
  2439.                         name = L["Recount"],
  2440.                         desc = L["Display Recount's DPS (RECOUNT MUST BE INSTALLED)"],
  2441.                         values = statposition;
  2442.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2443.                     },
  2444.                     spec = {
  2445.                         type = "select",
  2446.                         order = 2,
  2447.                         name = L["Talent Spec"],
  2448.                         desc = L["Display current spec"],
  2449.                         values = statposition;
  2450.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2451.                     },
  2452.                     stats = {
  2453.                         type = "select",
  2454.                         order = 2,
  2455.                         name = L["Stat #1"],
  2456.                         desc = L["Display stat based on your role (Avoidance-Tank, AP-Melee, SP/HP-Caster)"],
  2457.                         values = statposition;
  2458.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2459.                     },
  2460.                     system = {
  2461.                         type = "select",
  2462.                         order = 2,
  2463.                         name = L["System"],
  2464.                         desc = L["Display FPS and Latency"],
  2465.                         values = statposition;
  2466.                         disabled = function() return isModuleDisabled() or not db.enable end,
  2467.                     },
  2468.                 },
  2469.             },
  2470.         },
  2471.     }
  2472.     return options
  2473. end

Last edited by cokedrivers : 09-05-23 at 10:33 AM.
  Reply With Quote
09-05-23, 12:46 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
I get the spec just fine.

With
Code:
 if db.stats then
Your Update function is:
Lua Code:
  1. local function Update(self, t)
  2.                 if playerRole == nil then
  3.                     Text:SetText(hexa.."No Stats"..hexb)
  4.                 else
  5.                     if playerRole == playerRole.Tank then
  6.                         UpdateTank(self)
  7.                     elseif playerRole == playerRole.Healer then
  8.                         UpdateCaster(self)
  9.                     elseif playerRole == playerRole.Damager then
  10.                         UpdateDamager(self)
  11.                     end
  12.                 end
  13.             end
playerRole appeares to be a table so it can't be both not nil and == a sub-key of itself
Code:
if playerRole == playerRole.Tank then
is essentially
Code:
if theTable == theTable.Tank then
You need to re evaluate
Lua Code:
  1. local playerRole = LibClassicSpecs.Role
and maybe add an other variable to hold the actual characters role name string.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-05-23, 01:38 PM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Is this more along the lines of what needs to be done?

Lua Code:
  1. local function Update(self, t)
  2.             if playerRole == nil then
  3.                 Text:SetText(hexa.."No Stats"..hexb)
  4.             else
  5.                 if playerRole == GetSpecializationRole("TANK") then
  6.                     UpdateTank(self)
  7.                 elseif playerRole == GetSpecializationRole("HEALER") then
  8.                     UpdateCaster(self)
  9.                 elseif playerRole == GetSpecializationRole("DAMAGER") then
  10.                     UpdateDamager(self)
  11.                 end
  12.             end
  13.         end
  Reply With Quote
09-05-23, 02:16 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
If playerRole is still a table then no.
Whatever is on the left side has to be able to equate to whatever is on the right.

Taking a look at the library,
Code:
local playerRole = LibClassicSpecs.Role
Just returns a table of
Lua Code:
  1. local Role = {
  2.   Damager = "DAMAGER",
  3.   Tank = "TANK",
  4.   Healer = "HEALER"
  5. }

playerRole should be something like a return from GetSpecializationInfo for the characters current classs/spec. ie. a string with "HEALER", "TANK" etc.
Lua Code:
  1. local playerRole = select(6, GetSpecializationInfo(xxx))

Then where you're using playeRole it can just be
Lua Code:
  1. if playerRole == nil then
  2.     --xxx                Text:SetText(hexa.."No Stats"..hexb)
  3. else
  4.     if playerRole == "TANK" then
  5.         UpdateTank(self)
  6.     elseif playerRole == "HEALER" then
  7.         UpdateCaster(self)
  8.     elseif playerRole == "DAMAGER" then
  9.         UpdateDamager(self)
  10.     end
  11. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-05-23 at 02:27 PM.
  Reply With Quote
09-06-23, 07:53 AM   #7
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Fizzlemizz View Post
If playerRole is still a table then no.
Whatever is on the left side has to be able to equate to whatever is on the right.

Taking a look at the library,
Code:
local playerRole = LibClassicSpecs.Role
Just returns a table of
Lua Code:
  1. local Role = {
  2.   Damager = "DAMAGER",
  3.   Tank = "TANK",
  4.   Healer = "HEALER"
  5. }

playerRole should be something like a return from GetSpecializationInfo for the characters current classs/spec. ie. a string with "HEALER", "TANK" etc.
Lua Code:
  1. local playerRole = select(6, GetSpecializationInfo(xxx))

Then where you're using playeRole it can just be
Lua Code:
  1. if playerRole == nil then
  2.     --xxx                Text:SetText(hexa.."No Stats"..hexb)
  3. else
  4.     if playerRole == "TANK" then
  5.         UpdateTank(self)
  6.     elseif playerRole == "HEALER" then
  7.         UpdateCaster(self)
  8.     elseif playerRole == "DAMAGER" then
  9.         UpdateDamager(self)
  10.     end
  11. end
Thank You for the help, I tried a different route but still doesnt show up on datapanel, i dont get any errors but no text either.

i chose to go by primary stat (Strength/Agility/Intel) to decide which set of stats should be shown, hopefully i have done this correct.

Here is the new code for stats.
Lua Code:
  1. if db.stats then
  2.  
  3.         local statsPlugin = CreateFrame('Frame', nil, Datapanel)
  4.         statsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  5.         statsPlugin:SetFrameStrata("BACKGROUND")
  6.         statsPlugin:SetFrameLevel(3)
  7.         statsPlugin:EnableMouse(true)
  8.  
  9.         local Text = statsPlugin:CreateFontString(nil, "OVERLAY")
  10.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  11.         PlacePlugin(db.stats, Text)
  12.  
  13.         local function ShowTooltip(self)
  14.             local playerStat = select(7, GetSpecializationInfo())
  15.             local playerClass = select(3, GetClassInfo())
  16.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  17.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  18.             GameTooltip:ClearLines()
  19.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  20.             GameTooltip:AddLine' '
  21.             if playerStat == 1 then
  22.                 local Total_Dodge = GetDodgeChance()
  23.                 local Total_Parry = GetParryChance()
  24.                 local Total_Block = GetBlockChance()
  25.                
  26.                 GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  27.                 GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  28.                 GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  29.                 GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)               
  30.                
  31.             elseif playerStat == 4 then
  32.                 local SC = GetSpellCritChance("2")
  33.                 local Total_Spell_Haste = UnitSpellHaste("player")
  34.                 local base, casting = GetManaRegen()
  35.                 local manaRegenString = "%d / %d"              
  36.                
  37.                 GameTooltip:AddLine(STAT_CATEGORY_SPELL)
  38.                 GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", SC), 1, 1, 1)
  39.                 GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Spell_Haste), 1, 1, 1)    
  40.                 GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, casting * 5), 1, 1, 1)
  41.  
  42.             elseif playerStat == 2 then        
  43.                 if playerClass == "HUNTER" then
  44.                     local Total_Range_Haste = GetRangedHaste("player")
  45.                     local Range_Crit = GetRangedCritChance("25")
  46.                     local speed = UnitRangedDamage("player")
  47.                     local Total_Range_Speed = speed
  48.                    
  49.                     GameTooltip:AddLine(STAT_CATEGORY_RANGED)                  
  50.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Range_Crit), 1, 1, 1) 
  51.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Range_Haste), 1, 1, 1)
  52.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", Total_Range_Speed), 1, 1, 1)                 
  53.                 else
  54.                     local Melee_Crit = GetCritChance("player")
  55.                     local Total_Melee_Haste = GetMeleeHaste("player")
  56.                     local mainSpeed = UnitAttackSpeed("player");
  57.                     local MH = mainSpeed
  58.                    
  59.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  60.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  61.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  62.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)
  63.                 end
  64.             end
  65.                
  66.             GameTooltip:AddLine' '
  67.             GameTooltip:AddLine(STAT_CATEGORY_GENERAL)         
  68.  
  69.             GameTooltip:Show()
  70.         end
  71.  
  72.         local function UpdateTank(self)
  73.             local armorString = hexa..ARMOR..hexb..": "
  74.             local displayNumberString = string.join("", "%s", "%d|r");
  75.             local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  76.             local Melee_Reduction = effectiveArmor
  77.            
  78.             Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  79.             --Setup Tooltip
  80.             self:SetAllPoints(Text)
  81.         end
  82.  
  83.         local function UpdateCaster(self)
  84.             local spellpwr = GetSpellBonusDamage("2");
  85.             local displayNumberString = string.join("", "%s", "%d|r");
  86.            
  87.             Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  88.            
  89.             --Setup Tooltip
  90.             self:SetAllPoints(Text)
  91.         end
  92.  
  93.         local function UpdateDamager(self) 
  94.             local displayNumberString = string.join("", "%s", "%d|r");
  95.                
  96.             if playerClass == "HUNTER" then
  97.                 local base, posBuff, negBuff = UnitRangedAttackPower("player")
  98.                 local Range_AP = base + posBuff + negBuff  
  99.                 pwr = Range_AP
  100.             else
  101.                 local base, posBuff, negBuff = UnitAttackPower("player")
  102.                 local Melee_AP = base + posBuff + negBuff      
  103.                 pwr = Melee_AP
  104.             end
  105.            
  106.             Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)      
  107.             --Setup Tooltip
  108.             self:SetAllPoints(Text)
  109.         end
  110.  
  111.         local int = 5  
  112.         local function Update(self, t)
  113.             int = int - t
  114.             if int > 0 then return end
  115.             if playerStat == 1 then
  116.                 UpdateTank(self)
  117.             elseif playerStat == 4 then
  118.                 UpdateCaster(self)
  119.             elseif playerStat == 2 then
  120.                 UpdateDamager(self)
  121.             end
  122.             int = 2
  123.         end
  124.  
  125.         statsPlugin:SetScript("OnEnter", function() ShowTooltip(statsPlugin) end)
  126.         statsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  127.         statsPlugin:SetScript("OnUpdate", Update)
  128.         Update(statsPlugin, 10)
  129.     end
  Reply With Quote
09-06-23, 01:25 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
With the talent reset I haven't updated most of my characterss (and the Era PTR isn't available) so this is just what I would have done first.

Changed:
Lua Code:
  1. local playerRole = LibClassicSpecs.Role
to:
Lua Code:
  1. local playerRole, specIndex

And then in the PLAYER_ENTERING_WORLD event, added:
Lua Code:
  1. if not playerRole then
  2.     specIndex = GetSpecialization()
  3.     playerRole = select(6, GetSpecializationInfo(specIndex))
  4.    print("playerRole", playerRole, specIndex) -- What did we get?
  5. end

That should get you a playerRole of "TANK", "HEALER", "DAMAGER" at login.

Then you could use:
Lua Code:
  1. if playerRole == nil then
  2.         --xxx                Text:SetText(hexa.."No Stats"..hexb)
  3. else
  4.     if playerRole == "TANK" then
  5.         UpdateTank(self)
  6.     elseif playerRole == "HEALER" then
  7.         UpdateCaster(self)
  8.     elseif playerRole == "DAMAGER" then
  9.         UpdateDamager(self)
  10.     end
  11. end

You would need to handle updating when changing/adding talents during a session.

I would probably do most/all class, spec. etc. initialisation at PLAYER_LOGIN or the initial PLAYER_ENTERING_WORLD rather than just as your addon is loaded as it gives the game some time to know more about you current character.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-06-23 at 01:29 PM.
  Reply With Quote
09-06-23, 03:52 PM   #9
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Thank You so much it is working now

https://imgbox.com/8mv1MGox

wont let me add a pic so this is what i did

and for those wondering how i got it done here is the code...

Stats Code
Lua Code:
  1. -----------------
  2.     -- Stats
  3.     -----------------
  4.     if db.stats then
  5.  
  6.         local statsPlugin = CreateFrame('Frame', nil, Datapanel)
  7.         statsPlugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  8.         statsPlugin:SetFrameStrata("BACKGROUND")
  9.         statsPlugin:SetFrameLevel(3)
  10.         statsPlugin:EnableMouse(true)
  11.  
  12.         local Text = statsPlugin:CreateFontString(nil, "OVERLAY")
  13.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  14.         PlacePlugin(db.stats, Text)
  15.  
  16.         local function ShowTooltip(self)
  17.             local playerRole, specIndex, ClassByID
  18.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  19.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  20.             GameTooltip:ClearLines()
  21.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Statistics")
  22.             GameTooltip:AddLine' '
  23.             if playerStat == 1 then
  24.                 local Total_Dodge = GetDodgeChance()
  25.                 local Total_Parry = GetParryChance()
  26.                 local Total_Block = GetBlockChance()
  27.                
  28.                 GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  29.                 GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  30.                 GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  31.                 GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)               
  32.                
  33.             elseif playerStat == 4 then
  34.                 local SC = GetSpellCritChance("2")
  35.                 local Total_Spell_Haste = UnitSpellHaste("player")
  36.                 local base, casting = GetManaRegen()
  37.                 local manaRegenString = "%d / %d"              
  38.                
  39.                 GameTooltip:AddLine(STAT_CATEGORY_SPELL)
  40.                 GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", SC), 1, 1, 1)
  41.                 GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Spell_Haste), 1, 1, 1)    
  42.                 GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, casting * 5), 1, 1, 1)
  43.  
  44.             elseif playerStat == 2 then        
  45.                 if playerClass == 253 then
  46.                     local Total_Range_Haste = GetRangedHaste("player")
  47.                     local Range_Crit = GetRangedCritChance("25")
  48.                     local speed = UnitRangedDamage("player")
  49.                     local Total_Range_Speed = speed
  50.                     local Melee_Crit = GetCritChance("player")
  51.                     local Total_Melee_Haste = GetMeleeHaste("player")
  52.                     local mainSpeed = UnitAttackSpeed("player");
  53.                     local MH = mainSpeed
  54.                    
  55.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  56.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  57.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  58.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)                
  59.                     GameTooltip:AddLine' '
  60.                     GameTooltip:AddLine(STAT_CATEGORY_RANGED)                  
  61.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Range_Crit), 1, 1, 1) 
  62.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Range_Haste), 1, 1, 1)
  63.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", Total_Range_Speed), 1, 1, 1)                 
  64.                 else
  65.                     local Melee_Crit = GetCritChance("player")
  66.                     local Total_Melee_Haste = GetMeleeHaste("player")
  67.                     local mainSpeed = UnitAttackSpeed("player");
  68.                     local MH = mainSpeed
  69.                    
  70.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  71.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  72.                     GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  73.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)
  74.                 end
  75.             end
  76.                
  77.             --GameTooltip:AddLine' '
  78.             --GameTooltip:AddLine(STAT_CATEGORY_GENERAL)           
  79.  
  80.  
  81.             GameTooltip:AddLine' '      
  82.             GameTooltip:AddLine("|cffeda55fClick|r to Open Charater Frame")
  83.             GameTooltip:Show()
  84.         end
  85.  
  86.         local function UpdateTank(self)
  87.             local armorString = hexa..ARMOR..hexb..": "
  88.             local displayNumberString = string.join("", "%s", "%d|r");
  89.             local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  90.             local Melee_Reduction = effectiveArmor
  91.            
  92.             Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  93.             --Setup Tooltip
  94.             self:SetAllPoints(Text)
  95.         end
  96.  
  97.         local function UpdateCaster(self)
  98.             local spellpwr = GetSpellBonusDamage("2");
  99.             local displayNumberString = string.join("", "%s", "%d|r");
  100.            
  101.             Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  102.            
  103.             --Setup Tooltip
  104.             self:SetAllPoints(Text)
  105.         end
  106.  
  107.         local function UpdateDamager(self) 
  108.             local displayNumberString = string.join("", "%s", "%d|r");
  109.                
  110.             if playerClass == 253 then
  111.                 local base, posBuff, negBuff = UnitRangedAttackPower("player")
  112.                 local Range_AP = base + posBuff + negBuff  
  113.                 pwr = Range_AP
  114.             else
  115.                 local base, posBuff, negBuff = UnitAttackPower("player")
  116.                 local Melee_AP = base + posBuff + negBuff      
  117.                 pwr = Melee_AP
  118.             end
  119.            
  120.             Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)      
  121.             --Setup Tooltip
  122.             self:SetAllPoints(Text)
  123.         end
  124.  
  125.         local int = 5  
  126.         local function Update(self, t)
  127.             int = int - t
  128.             if int > 0 then return end
  129.             if playerRole == nil then
  130.                 Text:SetText(hexa.."No Stats"..hexb)
  131.             else
  132.                 if playerRole == "TANK" then
  133.                     UpdateTank(self)
  134.                 elseif playerRole == "HEALER" then
  135.                     UpdateCaster(self)
  136.                 elseif playerRole == "DAMAGER" then
  137.                     UpdateDamager(self)
  138.                 end
  139.             end
  140.             int = 2
  141.         end
  142.  
  143.         local function OnEvent(self, event, ...)
  144.             if event == 'PLAYER_ENTERING_WORLD' then
  145.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  146.             end
  147.            
  148.             if not playerRole then
  149.                 specIndex = GetSpecialization()
  150.                 playerRole = select(6, GetSpecializationInfo(specIndex))
  151.                 playerStat = select(7, GetSpecializationInfo(specIndex))
  152.                 playerClass = select(1, GetSpecializationInfo(specIndex))
  153.                 --print("playerRole", playerRole, specIndex) -- What did we get?
  154.                 --print("playerStat", playerStat, specIndex) -- What did we get?
  155.                 print("playerClass", playerClass, specIndex) -- What did we get?
  156.             end  
  157.  
  158.             -- update datatext
  159.             if event ~= 'PLAYER_ENTERING_WORLD' then
  160.                 self:SetScript('OnUpdate', Update)
  161.             end
  162.         end
  163.  
  164.         statsPlugin:SetScript("OnEnter", function() ShowTooltip(statsPlugin) end)
  165.         statsPlugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  166.         statsPlugin:SetScript('OnEvent', OnEvent)
  167.         statsPlugin:SetScript("OnUpdate", Update)
  168.        
  169.         statsPlugin:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  170.         --Update(statsPlugin, 10)
  171.     end

Spec Code:
Lua Code:
  1. -----------------
  2.     -- Spec
  3.     -----------------
  4.  
  5.     if db.spec then
  6.  
  7.         local specPlugin = CreateFrame('Frame', nil, Datapanel)
  8.         specPlugin:EnableMouse(true)
  9.         specPlugin:SetFrameStrata('BACKGROUND')
  10.         specPlugin:SetFrameLevel(3)
  11.  
  12.         local Text = specPlugin:CreateFontString(nil, 'OVERLAY')
  13.         Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  14.         PlacePlugin(db.spec, Text)
  15.  
  16.         local talent = {}
  17.         local active
  18.         local talentString = string.join('', '|cffFFFFFF%s|r ')
  19.         local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  20.         local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  21.         local playerRole, specIndex
  22.  
  23.         local int = 5
  24.         local function Update(self, t)
  25.            
  26.             int = int - t
  27.             if int > 0 then return end
  28.             --active = GetActiveSpecGroup(false, false)
  29.             if playerClass ~= nil then
  30.                 Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization()))..hexb)
  31.             else
  32.                 Text:SetText(hexa.."No Spec"..hexb)
  33.             end
  34.             int = 2
  35.            
  36.         end
  37.  
  38.  
  39.         specPlugin:SetScript('OnEnter', function(self)
  40.             local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  41.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  42.  
  43.             GameTooltip:ClearLines()
  44.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Spec")
  45.             GameTooltip:AddLine' '
  46.             if playerClass ~= nil then
  47.                 for i = 1, GetActiveSpecGroup() do
  48.                     if GetSpecialization(false, false, i) then
  49.                         GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization())))))
  50.                     end
  51.                 end
  52.             else
  53.                 GameTooltip:AddLine("You have not chosen a Spec yet.")
  54.             end
  55.             GameTooltip:AddLine' '      
  56.             GameTooltip:AddLine("|cffeda55fClick|r to Open Talent Tree")
  57.             GameTooltip:Show()
  58.         end)
  59.  
  60.         specPlugin:SetScript('OnLeave', function() GameTooltip:Hide() end)
  61.  
  62.         local function OnEvent(self, event, ...)
  63.             if event == 'PLAYER_ENTERING_WORLD' then
  64.                 self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  65.             end
  66.      
  67.             -- Setup Talents Tooltip
  68.             self:SetAllPoints(Text)
  69.             if not playerRole then
  70.                 specIndex = GetSpecialization()
  71.                 playerClass = select(2, GetSpecializationInfo(specIndex))
  72.                 --print("playerClass", playerClass, specIndex) -- What did we get?
  73.             end
  74.             -- update datatext
  75.             if event ~= 'PLAYER_ENTERING_WORLD' then
  76.                 self:SetScript('OnUpdate', Update)
  77.             end
  78.         end
  79.  
  80.  
  81.  
  82.         specPlugin:RegisterEvent('PLAYER_ENTERING_WORLD');
  83.         specPlugin:RegisterEvent('CHARACTER_POINTS_CHANGED');
  84.         specPlugin:RegisterEvent('PLAYER_TALENT_UPDATE');
  85.         specPlugin:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  86.         specPlugin:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  87.         specPlugin:SetScript('OnEvent', OnEvent)
  88.         specPlugin:SetScript('OnUpdate', Update)
  89.  
  90.         specPlugin:SetScript("OnMouseDown", function() ToggleTalentFrame() end)
  91.     end

Last edited by cokedrivers : 09-06-23 at 08:04 PM.
  Reply With Quote
09-09-23, 07:55 AM   #10
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
ok so everything is working "kinda" the stat datatext i would like to dive in a little deeper and have it choose by player spec.

for instance a Pally has a heal spec, a DPS spec, and a tank spec so i would like the stats to adjust to this.

Heal = SP (not sure if classic doe SP or not)
DPS = AP
Tank = Armor

the following code gives me there spec numbers:
Lua Code:
  1. local Warrior = {
  2.   ID = 1,
  3.   displayName = "Warrior",
  4.   name = "WARRIOR",
  5.   Arms = 71,
  6.   Fury = 72,
  7.   Prot = 73,
  8.   specs = {71, 72, 73}
  9. }
  10. local Paladin = {
  11.   ID = 2,
  12.   displayName = "Paladin",
  13.   name = "PALADIN",
  14.   Holy = 65,
  15.   Prot = 66,
  16.   Ret = 70,
  17.   specs = {65, 66, 70}
  18. }
  19. local Hunter = {
  20.   ID = 3,
  21.   displayName = "Hunter",
  22.   name = "HUNTER",
  23.   BM = 253,
  24.   MM = 254,
  25.   SV = 255,
  26.   specs = {253, 254, 255}
  27. }
  28. local Rogue = {
  29.   ID = 4,
  30.   displayName = "Rogue",
  31.   name = "ROGUE",
  32.   Assasin = 259,
  33.   Combat = 260,
  34.   Sub = 261,
  35.   specs = {259, 260, 261}
  36. }
  37. local Priest = {
  38.   ID = 5,
  39.   displayName = "Priest",
  40.   name = "PRIEST",
  41.   Disc = 256,
  42.   Holy = 257,
  43.   Shadow = 258,
  44.   specs = {256, 257, 258}
  45. }
  46. local DK = {
  47.   ID = 6,
  48.   displayName = "Death knight",
  49.   name = "DEATHKNIGHT",
  50.   Blood = 250,
  51.   Frost = 251,
  52.   Unholy = 252,
  53.   specs = {250, 251, 252}
  54. }
  55. local Shaman = {
  56.   ID = 7,
  57.   displayName = "Shaman",
  58.   name = "SHAMAN",
  59.   Ele = 262,
  60.   Enh = 263,
  61.   Resto = 264,
  62.   specs = {262, 263, 264}
  63. }
  64. local Mage = {
  65.   ID = 8,
  66.   displayName = "Mage",
  67.   name = "MAGE",
  68.   Arcane = 62,
  69.   Fire = 63,
  70.   Frost = 64,
  71.   specs = {62, 63, 64}
  72. }
  73. local Warlock = {
  74.   ID = 9,
  75.   displayName = "Warlock",
  76.   name = "WARLOCK",
  77.   Affl = 265,
  78.   Demo = 266,
  79.   Destro = 267,
  80.   specs = {265, 266, 267}
  81. }
  82. local Monk = {
  83.   ID = 10,
  84.   displayName = "Monk",
  85.   name = "MONK",
  86.   BRM = 268,
  87.   WW = 269,
  88.   MW = 270,
  89.   specs = {268, 269, 270}
  90. }
  91. local Druid = {
  92.   ID = 11,
  93.   displayName = "Druid",
  94.   name = "DRUID",
  95.   Balance = 102,
  96.   Feral = 103,
  97.   Guardian = 104,
  98.   Resto = 105,
  99.   specs = {102, 103, 104, 105}
  100. }
  101. local DH = {
  102.   ID = 12,
  103.   displayName = "Demon hunter",
  104.   name = "DEMONHUNTER",
  105.   Havoc = 577,
  106.   Veng = 581,
  107.   specs = {577, 581}
  108. }

Here is the function to get the spec number:
Lua Code:
  1. playerClass = select(1, GetSpecializationInfo(specIndex))

How would i group them together to use them in:
Lua Code:
  1. if playerStat == 1 then        
  2.                 if playerClass == 66 or 73 or 104 then
  3.                     local Total_Dodge = GetDodgeChance()
  4.                     local Total_Parry = GetParryChance()
  5.                     local Total_Block = GetBlockChance()
  6.                    
  7.                     GameTooltip:AddLine(STAT_CATEGORY_DEFENSE)
  8.                     GameTooltip:AddDoubleLine(DODGE_CHANCE, format("%.2f%%", Total_Dodge),1,1,1)
  9.                     GameTooltip:AddDoubleLine(PARRY_CHANCE, format("%.2f%%", Total_Parry),1,1,1)
  10.                     GameTooltip:AddDoubleLine(BLOCK_CHANCE, format("%.2f%%", Total_Block),1,1,1)
  11.                 elseif playerClass == 70 or 71 or 72 then
  12.                     local Melee_Crit = GetCritChance("player")
  13.                     local Total_Melee_Haste = GetMeleeHaste("player")
  14.                     local mainSpeed = UnitAttackSpeed("player");
  15.                     local MH = mainSpeed
  16.                    
  17.                     GameTooltip:AddLine(STAT_CATEGORY_MELEE)
  18.                     GameTooltip:AddDoubleLine(STAT_CRITICAL_STRIKE, format("%.2f%%", Melee_Crit), 1, 1, 1)     
  19.                     --GameTooltip:AddDoubleLine(STAT_HASTE, format("%.2f%%", Total_Melee_Haste), 1, 1, 1)
  20.                     GameTooltip:AddDoubleLine(STAT_ATTACK_SPEED, format("%.2f".." (sec)", MH), 1, 1, 1)                            
  21.                 end

so when i do the print to chat to see what i get (on my ret pally) I get
Lua Code:
  1. playerStat 1 3
  2. playerClass 70 3

so if we referance the top table we can see that playerClass 70 is a Ret Pally which should give me a stat for AP but it currently is just giving me playerStat 1 which is the tank spec for Armor.


I have attached the whole Datapanel.lua file if you need to see the whole thing.
thanks for any help with this.
Attached Files
File Type: lua Datapanel.lua (82.5 KB, 22 views)
  Reply With Quote
09-09-23, 11:19 AM   #11
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
If this is using LibClassicSpec then
Lua Code:
  1. [Paladin.Ret] = {
  2.     ID = Paladin.Ret,
  3.     name = "Retribution",
  4.     description = "",
  5.     icon = "",
  6.     background = "",
  7.     role = Role.Damager,
  8.     isRecommended = true,
  9.     primaryStat = Stat.Strength
  10.   },

and
Lua Code:
  1. local Stat = {
  2.   Strength = 1,
  3.   Agility = 2,
  4.   Stamina = 3,
  5.   Intellect = 4,
  6.   Spirit = 5
  7. }
No AP in Classic but Stat.Strength has an ID of 1
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-09-23, 01:53 PM   #12
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Fizzlemizz View Post
If this is using LibClassicSpec then
Lua Code:
  1. [Paladin.Ret] = {
  2.     ID = Paladin.Ret,
  3.     name = "Retribution",
  4.     description = "",
  5.     icon = "",
  6.     background = "",
  7.     role = Role.Damager,
  8.     isRecommended = true,
  9.     primaryStat = Stat.Strength
  10.   },

and
Lua Code:
  1. local Stat = {
  2.   Strength = 1,
  3.   Agility = 2,
  4.   Stamina = 3,
  5.   Intellect = 4,
  6.   Spirit = 5
  7. }
No AP in Classic but Stat.Strength has an ID of 1
how do i pull the Paladin.Ret?
  Reply With Quote
09-09-23, 02:12 PM   #13
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
how do i pull the Paladin.Ret?
It should be:
Lua Code:
  1. local LibClassicSpecs = LibStub("LibClassicSpecs")
  2. --...
  3. local specIndex = GetSpecialization()
  4. local specData = LibClassicSpecs.SpecInfo[specIndex] -- specData should be the class.spec table
  5. for k, v in pairs(specData) do -- what's in the table?
  6.     print(k, v)
  7. end

But this is data mostly returned by GetSpecializationInfo

If you wanted to get "Strength" instead of 1 then you would have to build your own table and access that as the library does not appear to export this information (because locales are a thing)
Lua Code:
  1. local StatIds = {
  2.   "Strength",
  3.   "Agility",
  4.   "Stamina",
  5.   "Intellect",
  6.   "Spiri",
  7. }
  8.  
  9. local statName = StatIds[playerStat]
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-09-23 at 02:21 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » [WoW Classic Era] Bringing back a older addon.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off