Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BasicUI = LibStub("AceAddon-3.0"):NewAddon("BasicUI")
- local LSM = LibStub("LibSharedMedia-3.0")
- local BASIC_BORDER = [[Interface\Tooltips\UI-Tooltip-Border]]
- local BASIC_BACKGROUND = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
- local BASIC_STATUSBAR = [[Interface\TargetingFrame\UI-StatusBar]]
- local BASIC_BORDERPANEL = [[Interface\AddOns\BasicUI\Media\UI-DialogBox-Border.blp]]
- SlashCmdList['RELOADUI'] = function()
- ReloadUI()
- end
- SLASH_RELOADUI1 = '/rl'
- local defaults = {
- profile = {
- fontEnable = true,
- fontNormal = [[Interface\Addons\BasicUI\Media\NORMAL.ttf]],
- fontBold = [[Interface\Addons\BasicUI\Media\BOLD.ttf]],
- fontItalic = [[Interface\Addons\BasicUI\Media\ITALIC.ttf]],
- fontBoldItalic = [[Interface\Addons\BasicUI\Media\BOLDITALIC.ttf]],
- fontNumber = [[Interface\Addons\BasicUI\Media\NUMBER.ttf]],
- fontSize = 15,
- classcolor = true,
- buttons = {
- enable = true,
- showHotKeys = false,
- showMacronames = false,
- auraborder = false,
- -- Button Colors
- color = {
- enable = true,
- OutOfRange = { r = 0.9, g = 0, b = 0 },
- OutOfMana = { r = 0, g = 0, b = 0.9 },
- NotUsable = { r = 0.3, g = 0.3, b = 0.3 },
- },
- },
- castbar = {
- enable = true,
- border = BASIC_BORDER,
- background = BASIC_BACKGROUND,
- statusbar = BASIC_STATUSBAR,
- CastingBarFrame = {
- enable = true,
- fontSize = 18,
- textPosition = "CENTER",
- enableLag = true,
- enableTimer = true,
- selfAnchor = "BOTTOM",
- relAnchor = "BOTTOM",
- offSetX = 0,
- offSetY = 175,
- },
- TargetFrameSpellBar = {
- enable = false,
- fontSize = 18,
- textPosition = "CENTER",
- enableLag = true,
- enableTimer = true,
- selfAnchor = "TOP",
- relAnchor = "TOP",
- offSetX = 0,
- offSetY = -250,
- },
- FocusFrameSpellBar = {
- enable = true,
- fontSize = 18,
- textPosition = "CENTER",
- enableLag = true,
- enableTimer = true,
- selfAnchor = "TOP",
- relAnchor = "TOP",
- offSetX = 0,
- offSetY = -165,
- },
- MirrorTimer1 = {
- enable = true,
- fontSize = 18,
- enableTimer = true,
- selfAnchor = "TOP",
- relAnchor = "TOP",
- offSetX = 0,
- offSetY = -75,
- },
- PetCastingBarFrame = {
- enable = true,
- fontSize = 18,
- textPosition = "CENTER",
- enableTimer = true,
- selfAnchor = "BOTTOM",
- relAnchor = "BOTTOM",
- offSetX = 0,
- offSetY = 200,
- },
- },
- chat = {
- enable = true,
- disableFade = false,
- chatOutline = false,
- windowborder = false,
- enableborder = false,
- -- Chat Media
- border = BASIC_BORDER,
- background = BASIC_BACKGROUND,
- editboxborder = BASIC_BORDER,
- editboxbackground = BASIC_BACKGROUND,
- sound = [[Interface\Addons\BasicUI\Media\Whisper.mp3]],
- enableBottomButton = true,
- enableHyperlinkTooltip = true,
- enableBorderColoring = true,
- tab = {
- fontSize = 15,
- fontOutline = true,
- normalColor = {r = 1, g = 1, b = 1},
- specialColor = {r = 1, g = 0, b = 1},
- selectedColor = {r = 0, g = 0.75, b = 1},
- },
- },
- datapanel = {
- enable = true,
- battleground = true, -- enable 3 stats in battleground only that replace stat1,stat2,stat3.
- bag = false, -- True = Open Backpack; False = Open All bags
- -- nData Media
- border = BASIC_BORDERPANEL, -- Border for Datapanel ( Choose either Datapanel or Neav for border choice)
- background = BASIC_BACKGROUND, -- Background for Datapanel
- -- Color Datatext
- color = true, -- Enable Datatext Coloring
- customcolor = { r = 1, g = 1, b = 1}, -- Color of Text for Datapanel
- classcolor = true, -- Enable Classcolor for Text
- panel = "bottom", -- 3 Choices for panel placement = "top", "bottom", or "shortbar". Shortbar is to match nMainbar shortbar.
- armor = 0, -- show your armor value against the level mob you are currently targeting.
- avd = 0, -- show your current avoidance against the level of the mob your targeting
- bags = 9, -- show space used in bags on panel.
- haste = 0, -- show your haste rating on panels.
- system = 0, -- show total memory and others systems info (FPS/MS) on panel.
- guild = 4, -- show number on guildmate connected on panel.
- dur = 8, -- show your equipment durability on panel.
- friends = 6, -- show number of friends connected.
- dps_text = 0, -- show a dps meter on panel.
- hps_text = 0, -- show a heal meter on panel.
- spec = 5, -- show your current spec on panel.
- coords = 0, -- show your current coords on panel.
- pro = 7, -- shows your professions and tradeskills
- stat1 = 1, -- Stat Based on your Role (Avoidance-Tank, AP-Melee, SP/HP-Caster)
- stat2 = 3, -- Stat Based on your Role (Armor-Tank, Crit-Melee, Crit-Caster)
- recount = 2, -- Stat Based on Recount"s DPS
- recountraiddps = false, -- Enables tracking or Recounts Raid DPS
- calltoarms = 0, -- Show Current Call to Arms.
- },
- -- Merchant Options
- merchant = {
- enable = true, -- enable merchant module.
- sellMisc = true, -- allows the user to add spacific items to sell at merchant (please see the local filter in merchant.lua)
- autoSellGrey = true, -- autosell grey items at merchant.
- autoRepair = true, -- autorepair at merchant.
- gpay = false, -- let your guild pay for your repairs if they allow.
- },
- nameplates = {
- enable = true,
- enableTankMode = true, -- Color the nameplate threat border green, if you have no aggro
- colorNameWithThreat = true, -- The name has the same color as the threat of the unit (better visibility)
- showFullHP = true,
- showLevel = true,
- showTargetBorder = true,
- showEliteBorder = true,
- showTotemIcon = true,
- abbrevLongNames = true,
- },
- -- Quest Options
- quest = {
- enable = true, -- enable quest module.
- autocomplete = false, -- enable the autoaccept quest and autocomplete quest if no reward.
- },
- vendor = {
- enable = true,
- },
- vellum = {
- enable = true,
- },
- -- Tooltip
- tooltip = {
- enable = true, -- Move the tooltip up so its not overlapping the MainMenubar
- fontSize = 15,
- fontOutline = true,
- disableFade = false, -- Can cause errors or a buggy tooltip!
- abbrevRealmNames = true,
- border = BASIC_BORDER,
- background = BASIC_BACKGROUND,
- statusbar = BASIC_STATUSBAR,
- hideInCombat = false, -- Hide unit frame tooltips during combat
- hideRealmText = true, -- Hide the coalesced/interactive realm text
- reactionBorderColor = true,
- itemqualityBorderColor = true,
- showPlayerTitles = true,
- showPVPIcons = false, -- Show pvp icons instead of just a prefix
- showMouseoverTarget = true,
- showOnMouseover = false,
- showUnitRole = true,
- showItemLevel = true,
- showSpecializationIcon = false,
- position = {
- selfAnchor = "BOTTOM",
- relAnchor = "BOTTOM",
- offSetX = 0,
- offSetY = 200,
- },
- healthbar = {
- showHealthValue = true,
- showOutline = true,
- healthFormat = '$cur / $max', -- Possible: $cur, $max, $deficit, $perc, $smartperc, $smartcolorperc, $colorperc
- healthFullFormat = '$cur', -- if the tooltip unit has 100% hp
- textPos = "CENTER", -- Possible "TOP" "BOTTOM" "CENTER"
- reactionColoring = false,
- custom = {
- apply = false,
- color = { r = 1, g = 1, b = 0},
- },
- fontSize = 15,
- },
- },
- -- Unitframes
- unitframes = {
- enable = true,
- player = {
- enable = true, -- Enable Player Frame Adjustments
- scale = 1.15, -- Player Frame Scale
- fontSize = 13, -- Stausbar Font Size
- fontSizepet = 10, -- Stausbar Font Size
- },
- target = {
- enable = true, -- Enable Target Frame Adjustments
- scale = 1.15, -- Target Frame Scale
- fontSize = 13, -- Stausbar Font Size
- },
- focus = {
- enable = true, -- Enable Focus Frame Adjustments
- scale = 1.15, -- Focus Frame Scale
- fontSize = 13, -- Stausbar Font Size
- },
- party = {
- enable = true,
- scale = 1.15,
- fontSize = 11, -- Stausbar Font Size
- position = {
- relAnchor = "TOPLEFT",
- offSetX = 10, -- Controls the X offset. (Left - Right)
- offSetY = -150, -- Controls the Y offset. (Up - Down)
- },
- },
- arena = {
- enable = true,
- scale = 1.5,
- fontSize = 11, -- Stausbar Font Size
- tracker = true,
- },
- boss = {
- enable = true,
- scale = 1.15,
- fontSize = 13, -- Stausbar Font Size
- position = {
- relAnchor = "TOPRIGHT",
- offSetX = -50, -- Controls the X offset. (Left - Right)
- offSetY = -250, -- Controls the Y offset. (Up - Down)
- },
- },
- },
- },
- }
- function BasicUI:OnInitialize()
- -- Assuming the .toc says ## SavedVariables: MyAddonDB
- self.db = LibStub("AceDB-3.0"):New("BasicDB", defaults, true)
- end
- function BasicUI:OnEnable()
- self:Actionbar()
- self:Buff()
- self.Castbars()
- self:Chat()
- self:Datapanel()
- self:Font()
- self:Merchant()
- self:Nameplates()
- self:Vellum()
- self:Tooltip()
- self:Unitframes()
- end
- -------------
- -- CastBar --
- -------------
- function BasicUI:Castbars()
- local db = BasicUI.db.profile
- local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
- local m = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)")/min(2, max(.64, 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")));
- local scale = function(v) return m * floor(v/m+.5) end;
- if db.castbar.enable ~= true then return end
- --[[
- All Credit for Castbar.lua goes to thek.
- thek: Castbar = http://www.wowinterface.com/downloads/info11334-thekCastbar.html.
- Edited by Cokedriver.
- ]]
- local d = {};
- local find = string.find;
- local floor = math.floor;
- local function Set(a, k)
- a:SetFrameLevel(_G[k]:GetFrameLevel() - 1);
- if find(k, "MirrorTimer") then
- _G[k.."StatusBar"]:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b);
- _G[k.."StatusBar"]:SetWidth(240);
- _G[k.."StatusBar"]:SetHeight(24);
- _G[k]:ClearAllPoints();
- _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(_G[k].d.x), -scale(_G[k].d.y));
- _G[k.."StatusBar"]:ClearAllPoints();
- _G[k.."StatusBar"]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(5), -scale(_G[k].d.y));
- else
- _G[k]:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b);
- _G[k]:SetWidth(240);
- _G[k]:SetHeight(24);
- _G[k]:ClearAllPoints();
- _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(_G[k].d.x), -scale(_G[k].d.y))
- end;
- if db.castbar[k].enableLag then
- local d, u, l = GetNetStats();
- local min, max = _G[k]:GetMinMaxValues();
- local lv = ( l / 1000 ) / ( max - min );
- if ( lv < 0 ) then lv = 0; elseif ( lv > 1 ) then lv = 1 end;
- if ( _G[k].channeling ) then
- _G[k].lag:ClearAllPoints();
- _G[k].lag:SetPoint("LEFT", _G[k], "LEFT", 0, 0);
- else
- _G[k].lag:ClearAllPoints();
- _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0);
- end;
- _G[k].lag:SetWidth(_G[k]:GetWidth() * lv);
- end
- end;
- if db.castbar["TargetFrameSpellBar"].enable then
- function Target_Spellbar_AdjustPosition()
- Set(_G["TargetFrameSpellBar"].df, "TargetFrameSpellBar");
- end;
- end;
- if db.castbar["FocusFrameSpellBar"].enable then
- function Focus_Spellbar_AdjustPosition()
- Set(_G["FocusFrameSpellBar"].df, "FocusFrameSpellBar");
- end;
- end
- for k, _ in pairs(db.castbar) do
- if (k ~="enable" and db.castbar[k].enable) then
- local a = CreateFrame("Frame", "Castbar"..k, UIParent);
- d.w, d.h, d.x, d.y = nil, nil, nil, nil;
- _G[k.."Border"]:SetTexture("");
- _G[k.."Text"]:ClearAllPoints("");
- _G[k.."Text"]:SetFont(db.fontNormal, db.castbar[k].fontSize, "");
- if find(k, "MirrorTimer") then
- d.w = 240 + (5 * 2);
- d.h = 24 + (5 * 2);
- d.x = 5;
- d.y = 5;
- _G[k.."Text"]:SetPoint("CENTER", k, -10, 2);
- _G[k.."StatusBar"]:SetStatusBarTexture(db.castbar.statusbar);
- else
- d.w = 240 + 24 + (5 * 2) + 5;
- d.h = 24 + (5 * 2);
- d.x = 24 + 5 + 5;
- d.y = 5;
- _G[k.."Text"]:SetPoint(db.castbar[k].textPosition);
- _G[k]:SetStatusBarTexture(db.castbar.statusbar);
- _G[k.."Flash"].Show = _G[k.."Flash"].Hide;
- _G[k.."Spark"].Show = _G[k.."Spark"].Hide;
- if _G[k.."BorderShield"] then
- _G[k.."BorderShield"].Show = _G[k.."BorderShield"].Hide;
- end;
- if _G[k.."Icon"] then
- _G[k.."Icon"]:Show();
- _G[k.."Icon"]:ClearAllPoints();
- _G[k.."Icon"]:SetPoint("LEFT", _G[k], -27, 0);
- _G[k.."Icon"]:SetWidth(23);
- _G[k.."Icon"]:SetHeight(23);
- _G[k.."Icon"]:SetTexCoord(.08, .92, .08, .92);
- end;
- _G[k]:HookScript("OnSizeChanged", function()
- _G[k].reset = true;
- end);
- _G[k]:HookScript("OnValueChanged", function(self)
- if self.reset and not self.reseting then
- self.reseting = true
- Set(a, k)
- self.reseting = nil
- self.reset = nil
- end
- end)
- if db.castbar[k].enableLag then
- _G[k].lag = _G[k]:CreateTexture(nil, "BACKGROUND")
- _G[k].lag:SetHeight(24)
- _G[k].lag:SetWidth(0)
- _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0)
- _G[k].lag:SetTexture(1, 0, 0, 1)
- end;
- end;
- if db.castbar[k].enableTimer then
- _G[k].timer = _G[k]:CreateFontString(nil);
- _G[k].timer:SetFont(db.fontNormal, db.fontSize, "");
- _G[k].timer:SetPoint("RIGHT", _G[k], "RIGHT", -5, 0);
- _G[k].update = .1;
- end;
- a:SetPoint(db.castbar[k].relAnchor,"UIParent",db.castbar[k].selfAnchor, scale(db.castbar[k].offSetX),scale(db.castbar[k].offSetY))
- a:SetWidth(d.w); a:SetHeight(d.h);
- a:SetBackdropColor(.1, .1, .1, .95);
- a:SetBackdrop({
- bgFile = db.castbar.background,
- edgeFile = db.castbar.border,
- tile = true, tileSize = 16, edgeSize = 15,
- insets = {left = 3, right = 3, top = 3, bottom = 3}
- })
- if db.classcolor == true then
- a:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
- end
- a:SetParent(_G[k]);
- a:SetMovable(true);
- a:EnableMouse(false);
- a:RegisterForDrag("LeftButton");
- a:SetScript("OnDragStart", function(self) self:StartMoving() end);
- a:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end);
- a.name = a:CreateFontString(nil, "OVERLAY");
- a.name:SetFont(db.fontNormal, db.fontSize, "");
- a.name:SetPoint("CENTER", a);
- _G[k].d = d; _G[k].df = a; _G[k].name = a.name; _G[k].l = true;
- hooksecurefunc(_G[k], "Show", function() Set(a, k) end);
- end;
- end;
- hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
- if not self.timer then return end
- if self.update and self.update < elapsed then
- if self.casting then
- self.timer:SetText(format("(%.1f)", max(self.maxValue - self.value, 0)))
- elseif self.channeling then
- self.timer:SetText(format("(%.1f)", max(self.value, 0)))
- else
- self.timer:SetText("")
- end
- self.update = .1
- else
- self.update = self.update - elapsed
- end
- end)
- UIPARENT_MANAGED_FRAME_POSITIONS["CastingBarFrame"] = nil;
- end
- ---------------
- -- Actionbar --
- ---------------
- function BasicUI:Actionbar()
- local db = BasicUI.db.profile
- local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
- -- Hide Keybindings
- if db.buttons.showHotKeys ~= true then
- for i=1, 12 do
- _G["ActionButton"..i.."HotKey"]:SetAlpha(0) -- main bar
- _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(0) -- bottom right bar
- _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(0) -- bottom left bar
- _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(0) -- right bar
- _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(0) -- left bar
- end
- end
- -- Hide Macros
- if db.buttons.showMacronames ~= true then
- for i=1, 12 do
- _G["ActionButton"..i.."Name"]:SetAlpha(0) -- main bar
- _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(0) -- bottom right bar
- _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(0) -- bottom left bar
- _G["MultiBarRightButton"..i.."Name"]:SetAlpha(0) -- right bar
- _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(0) -- left bar
- end
- end
- hooksecurefunc('ActionButton_UpdateUsable', function(self)
- if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
- return
- end
- local isUsable, notEnoughMana = IsUsableAction(self.action)
- if (isUsable) then
- _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1)
- elseif (notEnoughMana) then
- _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.OutOfMana.r,db.buttons.color.OutOfMana.g,db.buttons.color.OutOfMana.b)
- else
- _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.NotUsable.r, db.buttons.color.NotUsable.g, db.buttons.color.NotUsable.b)
- end
- end)
- -- BetterBlizzardButtonBorder v1.1.1
- -- By Aprikot - http://aprikot.wowinterface.com
- -- Based upon functions within nMainbar by Neal, and thek: Buttonskin by thek
- -- Functions
- hooksecurefunc("ActionButton_Update", function(self)
- if self:GetName():match("ExtraActionButton") then return end
- local bu = _G[self:GetName()]
- local ic = _G[self:GetName().."Icon"]
- local bo = _G[self:GetName().."NormalTexture"]
- bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
- ic:SetTexCoord(.05, .95, .05, .95);
- ic:SetPoint("TOPLEFT", bu, 0, 0);
- ic:SetPoint("BOTTOMRIGHT", bu, 0, 0);
- bo:ClearAllPoints()
- bo:SetPoint("TOPLEFT", bu, -14, 14)
- bo:SetPoint("BOTTOMRIGHT", bu, 14, -14)
- if db.classcolor ~= true then
- bo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
- else
- bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end);
- hooksecurefunc("ActionButton_UpdateUsable", function(self)
- if self:GetName():match("ExtraActionButton") then return end
- if db.classcolor ~= true then
- (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
- else
- (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end);
- hooksecurefunc("ActionButton_ShowGrid", function(self)
- if self:GetName():match("ExtraActionButton") then return end
- if db.classcolor ~= true then
- (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
- else
- (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end);
- hooksecurefunc("PetActionBar_Update", function()
- for i, v in pairs({"PetActionButton", "ShapeshiftButton", "PossessButton"}) do
- for i = 1, 12 do
- local bu = _G[v..i]
- if bu then
- bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
- local ic = _G[v..i.."Icon"];
- ic:SetTexCoord(.05, .95, .05, .95);
- ic:SetPoint("TOPLEFT", bu, -1, 1);
- ic:SetPoint("BOTTOMRIGHT", bu, 1, -1);
- local bo = _G[v..i.."NormalTexture2"] or _G[v..i.."NormalTexture"]
- bo:ClearAllPoints()
- bo:SetPoint("TOPLEFT", bu, -15, 15)
- bo:SetPoint("BOTTOMRIGHT", bu, 15, -15)
- if db.classcolor ~= true then
- bo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
- else
- bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end
- end
- end
- end);
- hooksecurefunc("AuraButton_Update", function(self, index)
- if db.buttons.auraborder then
- local bu = _G[self..index]
- local ic = _G[self..index.."Icon"]
- local bo = _G[self..index.."Border"]
- if ic then
- ic:SetTexCoord(.07, .93, .07, .93);
- end
- if bo then
- bo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
- bo:ClearAllPoints()
- bo:SetPoint("TOPLEFT", bu, -12, 12)
- bo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
- bo:SetTexCoord(0, 1, 0, 1)
- if db.classcolor ~= true then
- bo:SetVertexColor(db.color.r, db.color.g, db.color.b)
- else
- bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end
- if bu and not bo then
- nbo = bu:CreateTexture("$parentOverlay", "ARTWORK")
- nbo:SetParent(bu)
- nbo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
- nbo:SetPoint("TOPLEFT", bu, -12, 12)
- nbo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
- if db.classcolor ~= true then
- nbo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
- else
- nbo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
- end
- end
- end
- end);
- function ActionButton_OnUpdate(self, elapsed)
- if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
- return
- end
- if (ActionButton_IsFlashing(self)) then
- local flashtime = self.flashtime
- flashtime = flashtime - elapsed
- if (flashtime <= 0) then
- local overtime = - flashtime
- if (overtime >= ATTACK_BUTTON_FLASH_TIME) then
- overtime = 0
- end
- flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
- local flashTexture = _G[self:GetName()..'Flash']
- if (flashTexture:IsShown()) then
- flashTexture:Hide()
- else
- flashTexture:Show()
- end
- end
- self.flashtime = flashtime
- end
- local rangeTimer = self.rangeTimer
- if (rangeTimer) then
- rangeTimer = rangeTimer - elapsed
- if (rangeTimer <= 0.1) then
- local isInRange = false
- if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then
- _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.OutOfRange.r, db.buttons.color.OutOfRange.g, db.buttons.color.OutOfRange.b)
- isInRange = true
- end
- if (self.isInRange ~= isInRange) then
- self.isInRange = isInRange
- ActionButton_UpdateUsable(self)
- end
- rangeTimer = TOOLTIP_UPDATE_TIME
- end
- self.rangeTimer = rangeTimer
- end
- end
- end
- -----------
- -- Buffs --
- -----------
- function BasicUI:Buff()
- BuffFrame:ClearAllPoints()
- BuffFrame:SetScale(1.19)
- BuffFrame:SetPoint('TOPRIGHT', Minimap, 'TOPLEFT', -25, 0)
- end
- ----------
- -- Chat --
- ----------
- function BasicUI:Chat()
- local db = BasicUI.db.profile
- local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
- -- Chat Message Groups
- ChatFrame_RemoveAllMessageGroups(ChatFrame1)
- ChatFrame_AddMessageGroup(ChatFrame1, "SAY")
- ChatFrame_AddMessageGroup(ChatFrame1, "EMOTE")
- ChatFrame_AddMessageGroup(ChatFrame1, "YELL")
- ChatFrame_AddMessageGroup(ChatFrame1, "GUILD")
- ChatFrame_AddMessageGroup(ChatFrame1, "OFFICER")
- ChatFrame_AddMessageGroup(ChatFrame1, "GUILD_ACHIEVEMENT")
- ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_SAY")
- ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_EMOTE")
- ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_YELL")
- ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_BOSS_EMOTE")
- ChatFrame_AddMessageGroup(ChatFrame1, "PARTY")
- ChatFrame_AddMessageGroup(ChatFrame1, "PARTY_LEADER")
- ChatFrame_AddMessageGroup(ChatFrame1, "RAID")
- ChatFrame_AddMessageGroup(ChatFrame1, "RAID_LEADER")
- ChatFrame_AddMessageGroup(ChatFrame1, "RAID_WARNING")
- ChatFrame_AddMessageGroup(ChatFrame1, "INSTANCE_CHAT")
- ChatFrame_AddMessageGroup(ChatFrame1, "INSTANCE_CHAT_LEADER")
- ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND")
- ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND_LEADER")
- ChatFrame_AddMessageGroup(ChatFrame1, "BG_HORDE")
- ChatFrame_AddMessageGroup(ChatFrame1, "BG_ALLIANCE")
- ChatFrame_AddMessageGroup(ChatFrame1, "BG_NEUTRAL")
- ChatFrame_AddMessageGroup(ChatFrame1, "SYSTEM")
- ChatFrame_AddMessageGroup(ChatFrame1, "ERRORS")
- ChatFrame_AddMessageGroup(ChatFrame1, "AFK")
- ChatFrame_AddMessageGroup(ChatFrame1, "DND")
- ChatFrame_AddMessageGroup(ChatFrame1, "IGNORED")
- ChatFrame_AddMessageGroup(ChatFrame1, "ACHIEVEMENT")
- ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_FACTION_CHANGE")
- ChatFrame_AddMessageGroup(ChatFrame1, "SKILL")
- ChatFrame_AddMessageGroup(ChatFrame1, "LOOT")
- ChatFrame_AddMessageGroup(ChatFrame1, "MONEY")
- ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_XP_GAIN")
- ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_HONOR_GAIN")
- ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_GUILD_XP_GAIN")
- ChatFrame_AddMessageGroup(ChatFrame1, "BN_INLINE_TOAST_ALERT")
- ChatFrame_RemoveAllMessageGroups(ChatFrame3)
- ChatFrame_AddMessageGroup(ChatFrame3, "WHISPER")
- ChatFrame_AddMessageGroup(ChatFrame3, "BN_WHISPER")
- ChatFrame_AddMessageGroup(ChatFrame3, "BN_CONVERSATION")
- -- enable classcolor automatically on login and on each character without doing /configure each time.
- ToggleChatColorNamesByClassGroup(true, "SAY")
- ToggleChatColorNamesByClassGroup(true, "EMOTE")
- ToggleChatColorNamesByClassGroup(true, "YELL")
- ToggleChatColorNamesByClassGroup(true, "GUILD")
- ToggleChatColorNamesByClassGroup(true, "OFFICER")
- ToggleChatColorNamesByClassGroup(true, "GUILD_ACHIEVEMENT")
- ToggleChatColorNamesByClassGroup(true, "ACHIEVEMENT")
- ToggleChatColorNamesByClassGroup(true, "WHISPER")
- ToggleChatColorNamesByClassGroup(true, "PARTY")
- ToggleChatColorNamesByClassGroup(true, "PARTY_LEADER")
- ToggleChatColorNamesByClassGroup(true, "RAID")
- ToggleChatColorNamesByClassGroup(true, "RAID_LEADER")
- ToggleChatColorNamesByClassGroup(true, "RAID_WARNING")
- ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND")
- ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND_LEADER")
- ToggleChatColorNamesByClassGroup(true, "INSTANCE_CHAT")
- ToggleChatColorNamesByClassGroup(true, "INSTANCE_CHAT_LEADER")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL1")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL2")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL3")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL4")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL5")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL6")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL7")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL8")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL9")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL10")
- ToggleChatColorNamesByClassGroup(true, "CHANNEL11")
- local _G = _G
- local type = type
- local select = select
- local unpack = unpack
- local tostring = tostring
- local concat = table.concat
- local find = string.find
- local gsub = string.gsub
- local format = string.format
- _G.CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
- _G.CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
- _G.CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 0.5
- _G.CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
- _G.CHAT_FONT_HEIGHTS = {
- [1] = 8,
- [2] = 9,
- [3] = 10,
- [4] = 11,
- [5] = 12,
- [6] = 13,
- [7] = 14,
- [8] = 15,
- [9] = 16,
- [10] = 17,
- [11] = 18,
- [12] = 19,
- [13] = 20,
- }
- _G.CHAT_FLAG_AFK = '[AFK] '
- _G.CHAT_FLAG_DND = '[DND] '
- _G.CHAT_FLAG_GM = '[GM] '
- _G.CHAT_GUILD_GET = '(|Hchannel:Guild|hG|h) %s:\32'
- _G.CHAT_OFFICER_GET = '(|Hchannel:o|hO|h) %s:\32'
- _G.CHAT_PARTY_GET = '(|Hchannel:party|hP|h) %s:\32'
- _G.CHAT_PARTY_LEADER_GET = '(|Hchannel:party|hPL|h) %s:\32'
- _G.CHAT_PARTY_GUIDE_GET = '(|Hchannel:party|hDG|h) %s:\32'
- _G.CHAT_MONSTER_PARTY_GET = '(|Hchannel:raid|hR|h) %s:\32'
- _G.CHAT_RAID_GET = '(|Hchannel:raid|hR|h) %s:\32'
- _G.CHAT_RAID_WARNING_GET = '(RW!) %s:\32'
- _G.CHAT_RAID_LEADER_GET = '(|Hchannel:raid|hL|h) %s:\32'
- _G.CHAT_BATTLEGROUND_GET = '(|Hchannel:Battleground|hBG|h) %s:\32'
- _G.CHAT_BATTLEGROUND_LEADER_GET = '(|Hchannel:Battleground|hBL|h) %s:\32'
- _G.CHAT_INSTANCE_CHAT_GET = '|Hchannel:INSTANCE_CHAT|h[I]|h %s:\32';
- _G.CHAT_INSTANCE_CHAT_LEADER_GET = '|Hchannel:INSTANCE_CHAT|h[IL]|h %s:\32';
- local channelFormat
- do
- local a, b = '.*%[(.*)%].*', '%%[%1%%]'
- channelFormat = {
- [1] = {gsub(CHAT_BATTLEGROUND_GET, a, b), '[BG]'},
- [2] = {gsub(CHAT_BATTLEGROUND_LEADER_GET, a, b), '[BGL]'},
- [3] = {gsub(CHAT_GUILD_GET, a, b), '[G]'},
- [4] = {gsub(CHAT_OFFICER_GET, a, b), '[O]'},
- [5] = {gsub(CHAT_PARTY_GET, a, b), '[P]'},
- [6] = {gsub(CHAT_PARTY_LEADER_GET, a, b), '[PL]'},
- [7] = {gsub(CHAT_PARTY_GUIDE_GET, a, b), '[PL]'},
- [8] = {gsub(CHAT_RAID_GET, a, b), '[R]'},
- [9] = {gsub(CHAT_RAID_LEADER_GET, a, b), '[RL]'},
- [10] = {gsub(CHAT_RAID_WARNING_GET, a, b), '[RW]'},
- [11] = {gsub(CHAT_FLAG_AFK, a, b), '[AFK] '},
- [12] = {gsub(CHAT_FLAG_DND, a, b), '[DND] '},
- [13] = {gsub(CHAT_FLAG_GM, a, b), '[GM] '},
- }
- end
- local AddMessage = ChatFrame1.AddMessage
- local function FCF_AddMessage(self, text, ...)
- if (type(text) == 'string') then
- text = gsub(text, '(|HBNplayer.-|h)%[(.-)%]|h', '%1%2|h')
- text = gsub(text, '(|Hplayer.-|h)%[(.-)%]|h', '%1%2|h')
- text = gsub(text, '%[(%d0?)%. (.-)%]', '[%1]')
- for i = 1, #channelFormat do
- text = gsub(text, channelFormat[i][1], channelFormat[i][2])
- end
- end
- return AddMessage(self, text, ...)
- end
- -- Modify the editbox
- for k = 6, 11 do
- select(k, ChatFrame1EditBox:GetRegions()):SetTexture(nil)
- end
- ChatFrame1EditBox:SetAltArrowKeyMode(false)
- ChatFrame1EditBox:ClearAllPoints()
- ChatFrame1EditBox:SetFont(db.fontNormal, db.fontSize)
- ChatFrame1EditBox:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 2, 33)
- ChatFrame1EditBox:SetPoint('BOTTOMRIGHT', ChatFrame1, 'TOPRIGHT', 0, 33)
- ChatFrame1EditBox:SetBackdrop({
- bgFile = db.chat.editboxbackground,
- edgeFile = db.chat.editboxborder,
- tile = true, tileSize = 16, edgeSize = 18,
- insets = {left = 3, right = 3, top = 2, bottom = 3},
- })
- ChatFrame1EditBox:SetBackdropColor(0, 0, 0, 0.5)
- if (db.chat.enableBorderColoring) then
- hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
- local type = editBox:GetAttribute('chatType')
- if (not type) then
- return
- end
- local info = ChatTypeInfo[type]
- ChatFrame1EditBox:SetBackdropBorderColor(info.r, info.g, info.b)
- end)
- end
- -- Hide the menu and friend button
- FriendsMicroButton:SetAlpha(0)
- FriendsMicroButton:EnableMouse(false)
- FriendsMicroButton:UnregisterAllEvents()
- ChatFrameMenuButton:SetAlpha(0)
- ChatFrameMenuButton:EnableMouse(false)
- -- Tab text colors for the tabs
- hooksecurefunc('FCFTab_UpdateColors', function(self, selected)
- if (selected) then
- self:GetFontString():SetTextColor(0, 0.75, 1)
- else
- self:GetFontString():SetTextColor(1, 1, 1)
- end
- end)
- -- Tab text fadeout
- local origFCF_FadeOutChatFrame = _G.FCF_FadeOutChatFrame
- local function FCF_FadeOutChatFrameHook(chatFrame)
- origFCF_FadeOutChatFrame(chatFrame)
- local frameName = chatFrame:GetName()
- local chatTab = _G[frameName..'Tab']
- local tabGlow = _G[frameName..'TabGlow']
- if (not tabGlow:IsShown()) then
- if (frameName.isDocked) then
- securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
- else
- securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
- end
- end
- end
- FCF_FadeOutChatFrame = FCF_FadeOutChatFrameHook
- -- Improve mousewheel scrolling
- hooksecurefunc('FloatingChatFrame_OnMouseScroll', function(self, direction)
- if (direction > 0) then
- if (IsShiftKeyDown()) then
- self:ScrollToTop()
- else
- self:ScrollUp()
- self:ScrollUp()
- end
- elseif (direction < 0) then
- if (IsShiftKeyDown()) then
- self:ScrollToBottom()
- else
- self:ScrollDown()
- self:ScrollDown()
- end
- end
- if (db.chat.enableBottomButton) then
- local buttonBottom = _G[self:GetName() .. 'ButtonFrameBottomButton']
- if (self:AtBottom()) then
- buttonBottom:SetAlpha(0)
- buttonBottom:EnableMouse(false)
- else
- buttonBottom:SetAlpha(0.7)
- buttonBottom:EnableMouse(true)
- end
- end
- end)
- -- Reposit toast frame
- BNToastFrame:HookScript('OnShow', function(self)
- BNToastFrame:ClearAllPoints()
- BNToastFrame:SetPoint('BOTTOMLEFT', ChatFrame1EditBox, 'TOPLEFT', 0, 15)
- end)
- -- Modify the chat tabs
- function SkinTab(self)
- local chat = _G[self]
- local tab = _G[self..'Tab']
- for i = 1, select('#', tab:GetRegions()) do
- local texture = select(i, tab:GetRegions())
- if (texture and texture:GetObjectType() == 'Texture') then
- texture:SetTexture(nil)
- end
- end
- local tabText = _G[self..'TabText']
- tabText:SetJustifyH('CENTER')
- tabText:SetWidth(60)
- if (db.chat.tab.fontOutline) then
- tabText:SetFont(db.fontBold, db.fontSize, 'THINOUTLINE')
- tabText:SetShadowOffset(0, 0)
- else
- tabText:SetFont(db.fontBold, db.fontLarge)
- tabText:SetShadowOffset(1, -1)
- end
- local a1, a2, a3, a4, a5 = tabText:GetPoint()
- tabText:SetPoint(a1, a2, a3, a4, 1)
- local s1, s2, s3 = db.chat.tab.specialColor.r, db.chat.tab.specialColor.g, db.chat.tab.specialColor.b
- local e1, e2, e3 = db.chat.tab.selectedColor.r, db.chat.tab.selectedColor.g, db.chat.tab.selectedColor.b
- local n1, n2, n3 = db.chat.tab.normalColor.r, db.chat.tab.normalColor.g, db.chat.tab.normalColor.b
- local tabGlow = _G[self..'TabGlow']
- hooksecurefunc(tabGlow, 'Show', function()
- tabText:SetTextColor(s1, s2, s3, CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
- end)
- hooksecurefunc(tabGlow, 'Hide', function()
- tabText:SetTextColor(n1, n2, n3)
- end)
- tab:SetScript('OnEnter', function()
- tabText:SetTextColor(s1, s2, s3, tabText:GetAlpha())
- end)
- tab:SetScript('OnLeave', function()
- local hasNofication = tabGlow:IsShown()
- local r, g, b
- if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
- r, g, b = e1, e2, e3
- elseif (hasNofication) then
- r, g, b = s1, s2, s3
- else
- r, g, b = n1, n2, n3
- end
- tabText:SetTextColor(r, g, b)
- end)
- hooksecurefunc(tab, 'Show', function()
- if (not tab.wasShown) then
- local hasNofication = tabGlow:IsShown()
- if (chat:IsMouseOver()) then
- tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
- else
- tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
- end
- local r, g, b
- if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
- r, g, b = e1, e2, e3
- elseif (hasNofication) then
- r, g, b = s1, s2, s3
- else
- r, g, b = n1, n2, n3
- end
- tabText:SetTextColor(r, g, b)
- tab.wasShown = true
- end
- end)
- end
- local function ModChat(self)
- local chat = _G[self]
- if (not db.chat.chatOutline) then
- chat:SetShadowOffset(1, -1)
- end
- if (db.chat.disableFade) then
- chat:SetFading(false)
- end
- SkinTab(self)
- local font, fontsize, fontflags = chat:GetFont()
- chat:SetFont(db.fontNormal, fontsize, db.chat.chatOutline and 'THINOUTLINE' or fontflags)
- chat:SetClampedToScreen(false)
- chat:SetClampRectInsets(0, 0, 0, 0)
- chat:SetMaxResize(UIParent:GetWidth(), UIParent:GetHeight())
- chat:SetMinResize(150, 25)
- if (self ~= 'ChatFrame2') then
- chat.AddMessage = FCF_AddMessage
- end
- local buttonUp = _G[self..'ButtonFrameUpButton']
- buttonUp:SetAlpha(0)
- buttonUp:EnableMouse(false)
- local buttonDown = _G[self..'ButtonFrameDownButton']
- buttonDown:SetAlpha(0)
- buttonDown:EnableMouse(false)
- local buttonBottom = _G[self..'ButtonFrameBottomButton']
- buttonBottom:SetAlpha(0)
- buttonBottom:EnableMouse(false)
- if (db.chat.enableBottomButton) then
- buttonBottom:ClearAllPoints()
- buttonBottom:SetPoint('BOTTOMRIGHT', chat, -1, -3)
- buttonBottom:HookScript('OnClick', function(self)
- self:SetAlpha(0)
- self:EnableMouse(false)
- end)
- end
- for _, texture in pairs({
- 'ButtonFrameBackground',
- 'ButtonFrameTopLeftTexture',
- 'ButtonFrameBottomLeftTexture',
- 'ButtonFrameTopRightTexture',
- 'ButtonFrameBottomRightTexture',
- 'ButtonFrameLeftTexture',
- 'ButtonFrameRightTexture',
- 'ButtonFrameBottomTexture',
- 'ButtonFrameTopTexture',
- }) do
- _G[self..texture]:SetTexture(nil)
- end
- end
- local function SetChatStyle()
- for _, v in pairs(CHAT_FRAMES) do
- local chat = _G[v]
- if (chat and not chat.hasModification) then
- ModChat(chat:GetName())
- local convButton = _G[chat:GetName()..'ConversationButton']
- if (convButton) then
- convButton:SetAlpha(0)
- convButton:EnableMouse(false)
- end
- local chatMinimize = _G[chat:GetName()..'ButtonFrameMinimizeButton']
- if (chatMinimize) then
- chatMinimize:SetAlpha(0)
- chatMinimize:EnableMouse(0)
- end
- chat.hasModification = true
- end
- end
- end
- hooksecurefunc('FCF_OpenTemporaryWindow', SetChatStyle)
- SetChatStyle()
- -- Chat menu, just a middle click on the chatframe 1 tab
- hooksecurefunc('ChatFrameMenu_UpdateAnchorPoint', function()
- if (FCF_GetButtonSide(DEFAULT_CHAT_FRAME) == 'right') then
- ChatMenu:ClearAllPoints()
- ChatMenu:SetPoint('BOTTOMRIGHT', ChatFrame1Tab, 'TOPLEFT')
- else
- ChatMenu:ClearAllPoints()
- ChatMenu:SetPoint('BOTTOMLEFT', ChatFrame1Tab, 'TOPRIGHT')
- end
- end)
- ChatFrame1Tab:RegisterForClicks('AnyUp')
- ChatFrame1Tab:HookScript('OnClick', function(self, button)
- if (button == 'MiddleButton' or button == 'Button4' or button == 'Button5') then
- if (ChatMenu:IsShown()) then
- ChatMenu:Hide()
- else
- ChatMenu:Show()
- end
- else
- ChatMenu:Hide()
- end
- end)
- -- Modify the gm chatframe and add a sound notification on incoming whispers
- local f = CreateFrame('Frame')
- f:RegisterEvent('ADDON_LOADED')
- f:RegisterEvent('CHAT_MSG_WHISPER')
- f:RegisterEvent('CHAT_MSG_BN_WHISPER')
- f:SetScript('OnEvent', function(_, event)
- if (event == 'ADDON_LOADED' and arg1 == 'Blizzard_GMChatUI') then
- GMChatFrame:EnableMouseWheel(true)
- GMChatFrame:SetScript('OnMouseWheel', ChatFrame1:GetScript('OnMouseWheel'))
- GMChatFrame:SetHeight(200)
- GMChatFrameUpButton:SetAlpha(0)
- GMChatFrameUpButton:EnableMouse(false)
- GMChatFrameDownButton:SetAlpha(0)
- GMChatFrameDownButton:EnableMouse(false)
- GMChatFrameBottomButton:SetAlpha(0)
- GMChatFrameBottomButton:EnableMouse(false)
- end
- if (event == 'CHAT_MSG_WHISPER' or event == 'CHAT_MSG_BN_WHISPER') then
- PlaySoundFile(db.chat.sound)
- end
- end)
- local combatLog = {
- text = 'CombatLog',
- colorCode = '|cffFFD100',
- isNotRadio = true,
- func = function()
- if (not LoggingCombat()) then
- LoggingCombat(true)
- DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGENABLED, 1, 1, 0)
- else
- LoggingCombat(false)
- DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGDISABLED, 1, 1, 0)
- end
- end,
- checked = function()
- if (LoggingCombat()) then
- return true
- else
- return false
- end
- end
- }
- local chatLog = {
- text = 'ChatLog',
- colorCode = '|cffFFD100',
- isNotRadio = true,
- func = function()
- if (not LoggingChat()) then
- LoggingChat(true)
- DEFAULT_CHAT_FRAME:AddMessage(CHATLOGENABLED, 1, 1, 0)
- else
- LoggingChat(false)
- DEFAULT_CHAT_FRAME:AddMessage(CHATLOGDISABLED, 1, 1, 0)
- end
- end,
- checked = function()
- if (LoggingChat()) then
- return true
- else
- return false
- end
- end
- }
- local origFCF_Tab_OnClick = _G.FCF_Tab_OnClick
- local function FCF_Tab_OnClickHook(chatTab, ...)
- origFCF_Tab_OnClick(chatTab, ...)
- combatLog.arg1 = chatTab
- UIDropDownMenu_AddButton(combatLog)
- chatLog.arg1 = chatTab
- UIDropDownMenu_AddButton(chatLog)
- end
- FCF_Tab_OnClick = FCF_Tab_OnClickHook
- -- Chat Copy
- local f = CreateFrame('Frame', nil, UIParent)
- f:SetHeight(220)
- f:SetBackdropColor(0, 0, 0, 1)
- f:SetPoint('BOTTOMLEFT', ChatFrame1EditBox, 'TOPLEFT', 3, 10)
- f:SetPoint('BOTTOMRIGHT', ChatFrame1EditBox, 'TOPRIGHT', -3, 10)
- f:SetFrameStrata('DIALOG')
- f:SetBackdrop({
- bgFile = db.chat.background,
- edgeFile = db.chat.border,
- tile = true, tileSize = 16, edgeSize = 18,
- insets = {left = 3, right = 3, top = 3, bottom = 3
- }})
- f:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
- f:Hide()
- f.t = f:CreateFontString(nil, 'OVERLAY')
- f.t:SetFont(db.fontNormal, db.fontSize)
- f.t:SetPoint('TOPLEFT', f, 8, -8)
- f.t:SetTextColor(1, 1, 0)
- f.t:SetShadowOffset(1, -1)
- f.t:SetJustifyH('LEFT')
- f.b = CreateFrame('EditBox', nil, f)
- f.b:SetMultiLine(true)
- f.b:SetMaxLetters(20000)
- f.b:SetSize(450, 270)
- f.b:SetScript('OnEscapePressed', function()
- f:Hide()
- end)
- f.s = CreateFrame('ScrollFrame', '$parentScrollBar', f, 'UIPanelScrollFrameTemplate')
- f.s:SetPoint('TOPLEFT', f, 'TOPLEFT', 8, -30)
- f.s:SetPoint('BOTTOMRIGHT', f, 'BOTTOMRIGHT', -30, 8)
- f.s:SetScrollChild(f.b)
- f.c = CreateFrame('Button', nil, f, 'UIPanelCloseButton')
- f.c:SetPoint('TOPRIGHT', f, 'TOPRIGHT', 0, -1)
- local lines = {}
- local function GetChatLines(...)
- local count = 1
- for i = select('#', ...), 1, -1 do
- local region = select(i, ...)
- if (region:GetObjectType() == 'FontString') then
- lines[count] = tostring(region:GetText())
- count = count + 1
- end
- end
- return count - 1
- end
- local function copyChat(self)
- local chat = _G[self:GetName()]
- local _, fontSize = chat:GetFont()
- FCF_SetChatWindowFontSize(self, chat, 0.1)
- local lineCount = GetChatLines(chat:GetRegions())
- FCF_SetChatWindowFontSize(self, chat, fontSize)
- if (lineCount > 0) then
- ToggleFrame(f)
- f.t:SetText(chat:GetName())
- local f1, f2, f3 = ChatFrame1:GetFont()
- f.b:SetFont(f1, f2, f3)
- local text = concat(lines, '\n', 1, lineCount)
- f.b:SetText(text)
- end
- end
- local function CreateCopyButton(self)
- self.Copy = CreateFrame('Button', nil, _G[self:GetName()])
- self.Copy:SetSize(20, 20)
- self.Copy:SetPoint('TOPRIGHT', self, -5, -5)
- self.Copy:SetNormalTexture'Interface\\AddOns\\BasicUI\\Media\\textureCopyNormal'
- self.Copy:GetNormalTexture():SetSize(20, 20)
- self.Copy:SetHighlightTexture'Interface\\AddOns\\BasicUI\\Media\\textureCopyHighlight'
- self.Copy:GetHighlightTexture():SetAllPoints(self.Copy:GetNormalTexture())
- local tab = _G[self:GetName()..'Tab']
- hooksecurefunc(tab, 'SetAlpha', function()
- self.Copy:SetAlpha(tab:GetAlpha()*0.55)
- end)
- self.Copy:SetScript('OnMouseDown', function(self)
- self:GetNormalTexture():ClearAllPoints()
- self:GetNormalTexture():SetPoint('CENTER', 1, -1)
- end)
- self.Copy:SetScript('OnMouseUp', function()
- self.Copy:GetNormalTexture():ClearAllPoints()
- self.Copy:GetNormalTexture():SetPoint('CENTER')
- if (self.Copy:IsMouseOver()) then
- copyChat(self)
- end
- end)
- end
- local function EnableCopyButton()
- for _, v in pairs(CHAT_FRAMES) do
- local chat = _G[v]
- if (chat and not chat.Copy) then
- CreateCopyButton(chat)
- end
- end
- end
- hooksecurefunc('FCF_OpenTemporaryWindow', EnableCopyButton)
- EnableCopyButton()
- -- Copy URL
- local urlStyle = '|cffff00ff|Hurl:%1|h%1|h|r'
- local urlPatterns = {
- '(http://%S+)', -- http://xxx.com
- '(www%.%S+)', -- www.xxx.com/site/index.php
- '(%d+%.%d+%.%d+%.%d+:?%d*)', -- 192.168.1.1 / 192.168.1.1:1110
- }
- local messageTypes = {
- 'CHAT_MSG_CHANNEL',
- 'CHAT_MSG_GUILD',
- 'CHAT_MSG_PARTY',
- 'CHAT_MSG_RAID',
- 'CHAT_MSG_SAY',
- 'CHAT_MSG_WHISPER',
- }
- local function urlFilter(self, event, text, ...)
- for _, pattern in ipairs(urlPatterns) do
- local result, matches = gsub(text, pattern, urlStyle)
- if (matches > 0) then
- return false, result, ...
- end
- end
- end
- for _, event in ipairs(messageTypes) do
- ChatFrame_AddMessageEventFilter(event, urlFilter)
- end
- local origSetItemRef = _G.SetItemRef
- local currentLink
- local SetItemRefHook = function(link, text, button)
- if (link:sub(0, 3) == 'url') then
- currentLink = link:sub(5)
- StaticPopup_Show('UrlCopyDialog')
- return
- end
- return origSetItemRef(link, text, button)
- end
- SetItemRef = SetItemRefHook
- StaticPopupDialogs['UrlCopyDialog'] = {
- text = 'URL',
- button2 = CLOSE,
- hasEditBox = 1,
- editBoxWidth = 250,
- OnShow = function(frame)
- local editBox = _G[frame:GetName()..'EditBox']
- if (editBox) then
- editBox:SetText(currentLink)
- editBox:SetFocus()
- editBox:HighlightText(0)
- end
- local button = _G[frame:GetName()..'Button2']
- if (button) then
- button:ClearAllPoints()
- button:SetWidth(100)
- button:SetPoint('CENTER', editBox, 'CENTER', 0, -30)
- end
- end,
- EditBoxOnEscapePressed = function(frame)
- frame:GetParent():Hide()
- end,
- timeout = 0,
- whileDead = 1,
- hideOnEscape = 1,
- maxLetters = 1024,
- }
- if db.chat.enableHyperlinkTooltip ~= true then return end
- --[[
- All Create for hyperlink.lua goes to Neal, ballagarba, and Tuks.
- Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
- Tukui = http://www.tukui.org/download.php.
- Edited by Cokedriver.
- ]]
- local _G = getfenv(0)
- local orig1, orig2 = {}, {}
- local GameTooltip = GameTooltip
- local linktypes = {
- item = true,
- enchant = true,
- spell = true,
- quest = true,
- unit = true,
- talent = true,
- achievement = true,
- glyph = true
- }
- local function OnHyperlinkEnter(frame, link, ...)
- local linktype = link:match('^([^:]+)')
- if (linktype and linktypes[linktype]) then
- GameTooltip:SetOwner(ChatFrame1, 'ANCHOR_CURSOR', 0, 20)
- GameTooltip:SetHyperlink(link)
- GameTooltip:Show()
- else
- GameTooltip:Hide()
- end
- if (orig1[frame]) then
- return orig1[frame](frame, link, ...)
- end
- end
- local function OnHyperlinkLeave(frame, ...)
- GameTooltip:Hide()
- if (orig2[frame]) then
- return orig2[frame](frame, ...)
- end
- end
- local function EnableItemLinkTooltip()
- for _, v in pairs(CHAT_FRAMES) do
- local chat = _G[v]
- if (chat and not chat.URLCopy) then
- orig1[chat] = chat:GetScript('OnHyperlinkEnter')
- chat:SetScript('OnHyperlinkEnter', OnHyperlinkEnter)
- orig2[chat] = chat:GetScript('OnHyperlinkLeave')
- chat:SetScript('OnHyperlinkLeave', OnHyperlinkLeave)
- chat.URLCopy = true
- end
- end
- end
- hooksecurefunc('FCF_OpenTemporaryWindow', EnableItemLinkTooltip)
- EnableItemLinkTooltip()
- if db.chat.windowborder == true then
- for i = 1, NUM_CHAT_WINDOWS do
- local cf = _G['ChatFrame'..i]
- local bg = CreateFrame("Frame", nil, cf);
- bg:SetFrameStrata("BACKGROUND");
- if i == 2 then
- bg:SetPoint("TOPLEFT", -8, 32);
- else
- bg:SetPoint("TOPLEFT", -8, 8);
- end
- bg:SetPoint("BOTTOMRIGHT", 8, -12);
- bg:SetBackdrop({
- edgeFile = db.chat.border,
- tile = true, tileSize = 16, edgeSize = 18,
- })
- bg:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
- end
- end
- -- default position of chat
- local function SetDefaultChatPosition(frame)
- if frame then
- local id = frame:GetID()
- local name = FCF_GetChatWindowInfo(id)
- local fontSize = select(2, frame:GetFont())
- -- font size
- if fontSize < 15 then
- FCF_SetChatWindowFontSize(nil, frame, 15)
- else
- FCF_SetChatWindowFontSize(nil, frame, fontSize)
- end
- if id == 1 then
- frame:ClearAllPoints()
- frame:SetPoint("BOTTOMLEFT", UIParent, 50, 185)
- end
- -- lock them if unlocked
- if not frame.isLocked then FCF_SetLocked(frame, 1) end
- end
- end
- hooksecurefunc("FCF_RestorePositionAndDimensions", SetDefaultChatPosition)
- end
- ---------------
- -- Datapanel --
- ---------------
- function BasicUI:Datapanel()
- local db = BasicUI.db.profile
- local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
- local myclass = UnitClass("player")
- local myname, _ = UnitName("player")
- local myrealm = GetRealmName()
- local getscreenwidth = tonumber(string.match(({GetScreenResolutions()})[GetCurrentResolution()], "(%d+)x+%d"))
- local toc = select(4, GetBuildInfo())
- local locale = GetLocale()
- local currentFightDPS
- PP = function(p, obj)
- local left = PanelLeft
- local center = PanelCenter
- local right = PanelRight
- -- Left Panel Data
- if p == 1 then
- obj:SetParent(left)
- obj:SetHeight(left:GetHeight())
- obj:SetPoint('LEFT', left, 30, 0)
- obj:SetPoint('TOP', left)
- obj:SetPoint('BOTTOM', left)
- elseif p == 2 then
- obj:SetParent(left)
- obj:SetHeight(left:GetHeight())
- obj:SetPoint('TOP', left)
- obj:SetPoint('BOTTOM', left)
- elseif p == 3 then
- obj:SetParent(left)
- obj:SetHeight(left:GetHeight())
- obj:SetPoint('RIGHT', left, -30, 0)
- obj:SetPoint('TOP', left)
- obj:SetPoint('BOTTOM', left)
- -- Center Panel Data
- elseif p == 4 then
- obj:SetParent(center)
- obj:SetHeight(center:GetHeight())
- obj:SetPoint('LEFT', center, 30, 0)
- obj:SetPoint('TOP', center)
- obj:SetPoint('BOTTOM', center)
- elseif p == 5 then
- obj:SetParent(center)
- obj:SetHeight(center:GetHeight())
- obj:SetPoint('TOP', center)
- obj:SetPoint('BOTTOM', center)
- elseif p == 6 then
- obj:SetParent(center)
- obj:SetHeight(center:GetHeight())
- obj:SetPoint('RIGHT', center, -30, 0)
- obj:SetPoint('TOP', center)
- obj:SetPoint('BOTTOM', center)
- -- Right Panel Data
- elseif p == 7 then
- obj:SetParent(right)
- obj:SetHeight(right:GetHeight())
- obj:SetPoint('LEFT', right, 30, 0)
- obj:SetPoint('TOP', right)
- obj:SetPoint('BOTTOM', right)
- elseif p == 8 then
- obj:SetParent(right)
- obj:SetHeight(right:GetHeight())
- obj:SetPoint('TOP', right)
- obj:SetPoint('BOTTOM', right)
- elseif p == 9 then
- obj:SetParent(right)
- obj:SetHeight(right:GetHeight())
- obj:SetPoint('RIGHT', right, -30, 0)
- obj:SetPoint('TOP', right)
- obj:SetPoint('BOTTOM', right)
- end
- end
- DataTextTooltipAnchor = function(self)
- local panel = self:GetParent()
- local anchor = 'GameTooltip'
- local xoff = 1
- local yoff = 3
- for _, panel in pairs ({
- PanelLeft,
- PanelCenter,
- PanelRight,
- }) do
- if db.datapanel.top == true then
- anchor = 'ANCHOR_BOTTOM'
- else
- anchor = 'ANCHOR_TOP'
- end
- end
- return anchor, panel, xoff, yoff
- end
- --Check Player's Role
- local classRoles = {
- PALADIN = {
- [1] = "Caster",
- [2] = "Tank",
- [3] = "Melee",
- },
- PRIEST = "Caster",
- WARLOCK = "Caster",
- WARRIOR = {
- [1] = "Melee",
- [2] = "Melee",
- [3] = "Tank",
- },
- HUNTER = "Melee",
- SHAMAN = {
- [1] = "Caster",
- [2] = "Melee",
- [3] = "Caster",
- },
- ROGUE = "Melee",
- MAGE = "Caster",
- DEATHKNIGHT = {
- [1] = "Tank",
- [2] = "Melee",
- [3] = "Melee",
- },
- DRUID = {
- [1] = "Caster",
- [2] = "Melee",
- [3] = "Tank",
- [4] = "Caster"
- },
- MONK = {
- [1] = "Tank",
- [2] = "Caster",
- [3] = "Melee",
- },
- }
- local _, playerClass = UnitClass("player")
- local Role
- local function CheckRole()
- local talentTree = GetSpecialization()
- if(type(classRoles[playerClass]) == "string") then
- Role = classRoles[playerClass]
- elseif(talentTree) then
- Role = classRoles[playerClass][talentTree]
- end
- end
- local eventHandler = CreateFrame("Frame")
- eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
- eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
- eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
- eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
- eventHandler:SetScript("OnEvent", CheckRole)
- SetFontString = function(parent, fontName, fontHeight, fontStyle)
- local fs = parent:CreateFontString(nil, 'OVERLAY')
- fs:SetFont(fontName, fontHeight, fontStyle)
- fs:SetJustifyH('LEFT')
- fs:SetShadowColor(0, 0, 0)
- fs:SetShadowOffset(1.25, -1.25)
- return fs
- end
- function RGBToHex(r, g, b)
- r = r <= 1 and r >= 0 and r or 0
- g = g <= 1 and g >= 0 and g or 0
- b = b <= 1 and b >= 0 and b or 0
- return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
- end
- ShortValue = function(v)
- if v >= 1e6 then
- return ("%.1fm"):format(v / 1e6):gsub("%.?0+([km])$", "%1")
- elseif v >= 1e3 or v <= -1e3 then
- return ("%.1fk"):format(v / 1e3):gsub("%.?0+([km])$", "%1")
- else
- return v
- end
- end
- function HexToRGB(hex)
- local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
- return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
- end
- --------------
- -- Data Panel
- --------------
- if db.datapanel.enable == true then
- --[[
- All Credit for Datapanel.lua goes to Tuks.
- Tukui = http://www.tukui.org/download.php.
- Edited by Cokedriver.
- ]]
- local DataPanel = CreateFrame('Frame', 'DataPanel', UIParent)
- local PanelLeft = CreateFrame('Frame', 'PanelLeft', UIParent)
- local PanelCenter = CreateFrame('Frame', 'PanelCenter', UIParent)
- local PanelRight = CreateFrame('Frame', 'PanelRight', UIParent)
- local BattleGroundPanel = CreateFrame('Frame', 'BattleGroundPanel', UIParent)
- if db.datapanel.panel == "top" then
- DataPanel:SetPoint('TOP', UIParent, 0, 0)
- DataPanel:SetHeight(35)
- DataPanel:SetWidth(getscreenwidth)
- DataPanel:SetFrameStrata('LOW')
- DataPanel:SetFrameLevel(0)
- DataPanel:SetBackdrop({
- bgFile = db.datapanel.background,
- edgeFile = db.datapanel.border,
- edgeSize = 25,
- insets = {left = 5, right = 5, top = 5, bottom = 5}
- })
- DataPanel:SetBackdropColor(0, 0, 0, 1)
- -- Left Panel
- PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
- PanelLeft:SetHeight(35)
- PanelLeft:SetWidth(getscreenwidth / 3)
- PanelLeft:SetFrameStrata('LOW')
- PanelLeft:SetFrameLevel(1)
- -- Center Panel
- PanelCenter:SetPoint('CENTER', DataPanel, 0, 0)
- PanelCenter:SetHeight(35)
- PanelCenter:SetWidth(getscreenwidth / 3)
- PanelCenter:SetFrameStrata('LOW')
- PanelCenter:SetFrameLevel(1)
- -- Right Panel
- PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
- PanelRight:SetHeight(35)
- PanelRight:SetWidth(getscreenwidth / 3)
- PanelRight:SetFrameStrata('LOW')
- PanelRight:SetFrameLevel(1)
- -- Battleground Panel
- BattleGroundPanel:SetAllPoints(PanelLeft)
- BattleGroundPanel:SetFrameStrata('LOW')
- BattleGroundPanel:SetFrameLevel(1)
- elseif db.datapanel.panel == "bottom" then
- DataPanel:SetPoint('BOTTOM', UIParent, 0, 0)
- DataPanel:SetHeight(35)
- DataPanel:SetWidth(1200)
- DataPanel:SetFrameStrata('LOW')
- DataPanel:SetFrameLevel(0)
- DataPanel:SetBackdrop({
- bgFile = db.datapanel.background,
- edgeFile = db.datapanel.border,
- edgeSize = 25,
- insets = {left = 5, right = 5, top = 5, bottom = 5}
- })
- DataPanel:SetBackdropColor(0, 0, 0, 1)
- -- Left Panel
- PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
- PanelLeft:SetHeight(35)
- PanelLeft:SetWidth(1200 / 3)
- PanelLeft:SetFrameStrata('LOW')
- PanelLeft:SetFrameLevel(1)
- -- Center Panel
- PanelCenter:SetPoint('CENTER', DataPanel, 0, 0)
- PanelCenter:SetHeight(35)
- PanelCenter:SetWidth(1200 / 3)
- PanelCenter:SetFrameStrata('LOW')
- PanelCenter:SetFrameLevel(1)
- -- Right panel
- PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
- PanelRight:SetHeight(35)
- PanelRight:SetWidth(1200 / 3)
- PanelRight:SetFrameStrata('LOW')
- PanelRight:SetFrameLevel(1)
- -- Battleground Panel
- BattleGroundPanel:SetAllPoints(PanelLeft)
- BattleGroundPanel:SetFrameStrata('LOW')
- BattleGroundPanel:SetFrameLevel(1)
- elseif db.datapanel.panel == "shortbar" then
- DataPanel:SetPoint('BOTTOM', UIParent, 0, 0)
- DataPanel:SetHeight(35)
- DataPanel:SetWidth(725)
- DataPanel:SetFrameStrata('LOW')
- DataPanel:SetFrameLevel(0)
- DataPanel:SetBackdrop({
- bgFile = db.datapanel.background,
- edgeFile = db.datapanel.border,
- edgeSize = 25,
- insets = {left = 3, right = 3, top = 3, bottom = 3},
- })
- DataPanel:SetBackdropColor(0, 0, 0, 1)
- -- Left Panel
- PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
- PanelLeft:SetHeight(35)
- PanelLeft:SetWidth(725 / 2)
- PanelLeft:SetFrameStrata('LOW')
- PanelLeft:SetFrameLevel(1)
- -- Right panel
- PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
- PanelRight:SetHeight(35)
- PanelRight:SetWidth(725 / 2)
- PanelRight:SetFrameStrata('LOW')
- PanelRight:SetFrameLevel(1)
- -- Battleground Panel
- BattleGroundPanel:SetAllPoints(PanelLeft)
- BattleGroundPanel:SetFrameStrata('LOW')
- BattleGroundPanel:SetFrameLevel(1)
- end
- -- move some frames to make way for the datapanel
- if db.datapanel.panel == "top" then
- local top = function() end
- -- Player Frame
- PlayerFrame:ClearAllPoints()
- PlayerFrame:SetPoint("TOPLEFT", -19, -20)
- PlayerFrame.ClearAllPoints = top
- PlayerFrame.SetPoint = top
- -- Target Frame
- TargetFrame:ClearAllPoints()
- TargetFrame:SetPoint("TOPLEFT", 250, -20)
- TargetFrame.ClearAllPoints = top
- TargetFrame.SetPoint = top
- -- Minimap Frame
- MinimapCluster:ClearAllPoints()
- MinimapCluster:SetPoint('TOPRIGHT', 0, -32)
- MinimapCluster.ClearAllPoints = top
- MinimapCluster.SetPoint = top
- -- Buff Frame
- BuffFrame:ClearAllPoints()
- BuffFrame:SetPoint('TOP', MinimapCluster, -110, -2)
- BuffFrame.ClearAllPoints = top
- BuffFrame.SetPoint = top
- -- PvP Frame
- WorldStateAlwaysUpFrame:ClearAllPoints()
- WorldStateAlwaysUpFrame:SetPoint('TOP', 0, -32)
- WorldStateAlwaysUpFrame.ClearAllpoints = top
- WorldStateAlwaysUpFrame.Setpoint = top
- else
- -- Move some stuff for the panel on bottom.
- local bottom = function() end
- -- Main Menu Bar
- MainMenuBar:ClearAllPoints()
- MainMenuBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
- MainMenuBar.ClearAllPoints = bottom
- MainMenuBar.SetPoint = bottom
- -- Vehicle Bar
- OverrideActionBar:ClearAllPoints()
- OverrideActionBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
- OverrideActionBar.ClearAllPoints = bottom
- OverrideActionBar.SetPoint = bottom
- -- Pet Battle Bar
- PetBattleFrame.BottomFrame:ClearAllPoints()
- PetBattleFrame.BottomFrame:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
- PetBattleFrame.BottomFrame.ClearAllPoints = bottom
- PetBattleFrame.BottomFrame.SetPoint = bottom
- -- World Status
- WorldStateAlwaysUpFrame:ClearAllPoints()
- WorldStateAlwaysUpFrame:SetPoint('TOP', -20, -40)
- WorldStateAlwaysUpFrame.ClearAllpoints = bottom
- WorldStateAlwaysUpFrame.Setpoint = bottom
- -- Buff Frame
- BuffFrame:ClearAllPoints()
- BuffFrame:SetPoint('TOP', MinimapCluster, -110, -15)
- BuffFrame.ClearAllPoints = bottom
- BuffFrame.SetPoint = bottom
- -- Move the tooltip above the Actionbar
- hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self)
- self:SetPoint('BOTTOMRIGHT', UIParent, -95, 135)
- end)
- -- Move the Bags above the Actionbar
- CONTAINER_WIDTH = 192;
- CONTAINER_SPACING = 5;
- VISIBLE_CONTAINER_SPACING = 3;
- CONTAINER_OFFSET_Y = 70;
- CONTAINER_OFFSET_X = 0;
- function UpdateContainerFrameAnchors()
- local _, xOffset, yOffset, _, _, _, _;
- local containerScale = 1;
- screenHeight = GetScreenHeight() / containerScale;
- -- Adjust the start anchor for bags depending on the multibars
- xOffset = CONTAINER_OFFSET_X / containerScale;
- yOffset = CONTAINER_OFFSET_Y / containerScale + 25;
- -- freeScreenHeight determines when to start a new column of bags
- freeScreenHeight = screenHeight - yOffset;
- column = 0;
- for index, frameName in ipairs(ContainerFrame1.bags) do
- frame = _G[frameName];
- frame:SetScale(containerScale);
- if ( index == 1 ) then
- -- First bag
- frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -xOffset, yOffset );
- elseif ( freeScreenHeight < frame:GetHeight() ) then
- -- Start a new column
- column = column + 1;
- freeScreenHeight = screenHeight - yOffset;
- frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -(column * CONTAINER_WIDTH) - xOffset, yOffset );
- else
- -- Anchor to the previous bag
- frame:SetPoint('BOTTOMRIGHT', ContainerFrame1.bags[index - 1], 'TOPRIGHT', 0, CONTAINER_SPACING);
- end
- freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
- end
- end
- end
- end
- ----------------
- -- Color System
- ----------------
- if db.datapanel.color then
- --[[
- All Credit for Colors.lua goes to Tuks.
- Tukui = http://www.tukui.org/download.php.
- Edited by Cokedriver.
- ]]
- if db.datapanel.classcolor ~= true then
- local r, g, b = db.datapanel.customcolor.r, db.datapanel.customcolor.g, db.datapanel.customcolor.b
- hexa = ("|cff%.2x%.2x%.2x"):format(r * 255, g * 255, b * 255)
- hexb = "|r"
- else
- hexa = ("|cff%.2x%.2x%.2x"):format(ccolor.r * 255, ccolor.g * 255, ccolor.b * 255)
- hexb = "|r"
- end
- end
- ----------------
- -- Player Armor
- ----------------
- if db.datapanel.armor and db.datapanel.armor > 0 then
- local effectiveArmor
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.armor, Text)
- local function Update(self)
- effectiveArmor = select(2, UnitArmor("player"))
- Text:SetText(hexa.."Armor: "..hexb..(effectiveArmor))
- --Setup Armor Tooltip
- self:SetAllPoints(Text)
- end
- Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
- Stat:RegisterEvent("UNIT_AURA")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
- Stat:SetScript("OnEvent", Update)
- Stat:SetScript("OnEnter", function(self)
- if not InCombatLockdown() then
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine("Mitigation By Level: ")
- local lv = 83
- local mitigation = (effectiveArmor/(effectiveArmor+(467.5*lv-22167.5)))
- for i = 1, 4 do
- local format = string.format
- if mitigation > .75 then
- mitigation = .75
- end
- GameTooltip:AddDoubleLine(lv,format("%.2f", mitigation*100) .. "%",1,1,1)
- lv = lv - 1
- end
- if UnitLevel("target") > 0 and UnitLevel("target") < UnitLevel("player") then
- if mitigation > .75 then
- mitigation = .75
- end
- GameTooltip:AddDoubleLine(UnitLevel("target"),format("%.2f", mitigation*100) .. "%",1,1,1)
- end
- GameTooltip:Show()
- end
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- end
- --------------------
- -- Player Avoidance
- --------------------
- if db.datapanel.avd and db.datapanel.avd > 0 then
- local dodge, parry, block, avoidance, targetlv, playerlv, basemisschance, leveldifference
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.avd, Text)
- local targetlv, playerlv
- local function Update(self)
- local format = string.format
- targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
- local basemisschance, leveldifference, avoidance
- if targetlv == -1 then
- basemisschance = (5 - (3*.2)) --Boss Value
- leveldifference = 3
- elseif targetlv > playerlv then
- basemisschance = (5 - ((targetlv - playerlv)*.2)) --Mobs above player level
- leveldifference = (targetlv - playerlv)
- elseif targetlv < playerlv and targetlv > 0 then
- basemisschance = (5 + ((playerlv - targetlv)*.2)) --Mobs below player level
- leveldifference = (targetlv - playerlv)
- else
- basemisschance = 5 --Sets miss chance of attacker level if no target exists, lv80=5, 81=4.2, 82=3.4, 83=2.6
- leveldifference = 0
- end
- if myrace == "NightElf" then
- basemisschance = basemisschance + 2
- end
- if leveldifference >= 0 then
- dodge = (GetDodgeChance()-leveldifference*.2)
- parry = (GetParryChance()-leveldifference*.2)
- block = (GetBlockChance()-leveldifference*.2)
- avoidance = (dodge+parry+block)
- Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
- else
- dodge = (GetDodgeChance()+abs(leveldifference*.2))
- parry = (GetParryChance()+abs(leveldifference*.2))
- block = (GetBlockChance()+abs(leveldifference*.2))
- avoidance = (dodge+parry+block)
- Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
- end
- --Setup Avoidance Tooltip
- self:SetAllPoints(Text)
- end
- Stat:RegisterEvent("UNIT_AURA")
- Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
- Stat:RegisterEvent("PLAYER_TARGET_CHANGED")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript("OnEvent", Update)
- Stat:SetScript("OnEnter", function(self)
- if not InCombatLockdown() then
- local anchor, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(self, anchor, 0, yoff)
- GameTooltip:ClearAllPoints()
- GameTooltip:ClearLines()
- if targetlv > 1 then
- GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
- elseif targetlv == -1 then
- GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."Boss"..")")
- else
- GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
- end
- GameTooltip:AddDoubleLine("Dodge",format("%.2f",dodge) .. "%",1,1,1, 1,1,1)
- GameTooltip:AddDoubleLine("Parry",format("%.2f",parry) .. "%",1,1,1, 1,1,1)
- GameTooltip:AddDoubleLine("Block",format("%.2f",block) .. "%",1,1,1, 1,1,1)
- GameTooltip:Show()
- end
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- end
- --------
- -- Bags
- --------
- if db.datapanel.bags and db.datapanel.bags > 0 then
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.bags, Text)
- local Profit = 0
- local Spent = 0
- local OldMoney = 0
- local myPlayerRealm = GetRealmName();
- local function formatMoney(c)
- local str = ""
- if not c or c < 0 then
- return str
- end
- if c >= 10000 then
- local g = math.floor(c/10000)
- c = c - g*10000
- str = str..g.."|cFFFFD800g|r "
- end
- if c >= 100 then
- local s = math.floor(c/100)
- c = c - s*100
- str = str..s.."|cFFC7C7C7s|r "
- end
- if c >= 0 then
- str = str..c.."|cFFEEA55Fc|r"
- end
- return str
- end
- local function FormatTooltipMoney(c)
- if not c then return end
- local str = ""
- if not c or c < 0 then
- return str
- end
- if c >= 10000 then
- local g = math.floor(c/10000)
- c = c - g*10000
- str = str..g.."|cFFFFD800g|r "
- end
- if c >= 100 then
- local s = math.floor(c/100)
- c = c - s*100
- str = str..s.."|cFFC7C7C7s|r "
- end
- if c >= 0 then
- str = str..c.."|cFFEEA55Fc|r"
- end
- return str
- end
- local function OnEvent(self, event)
- local totalSlots, freeSlots = 0, 0
- local itemLink, subtype, isBag
- for i = 0,NUM_BAG_SLOTS do
- isBag = true
- if i > 0 then
- itemLink = GetInventoryItemLink('player', ContainerIDToInventoryID(i))
- if itemLink then
- subtype = select(7, GetItemInfo(itemLink))
- if (subtype == 'Mining Bag') or (subtype == 'Gem Bag') or (subtype == 'Engineering Bag') or (subtype == 'Enchanting Bag') or (subtype == 'Herb Bag') or (subtype == 'Inscription Bag') or (subtype == 'Leatherworking Bag') or (subtype == 'Fishing Bag')then
- isBag = false
- end
- end
- end
- if isBag then
- totalSlots = totalSlots + GetContainerNumSlots(i)
- freeSlots = freeSlots + GetContainerNumFreeSlots(i)
- end
- Text:SetText(hexa.."Bags: "..hexb.. freeSlots.. '/' ..totalSlots)
- if freeSlots < 6 then
- Text:SetTextColor(1,0,0)
- elseif freeSlots < 10 then
- Text:SetTextColor(1,0,0)
- elseif freeSlots > 10 then
- Text:SetTextColor(1,1,1)
- end
- self:SetAllPoints(Text)
- end
- if event == "PLAYER_ENTERING_WORLD" then
- OldMoney = GetMoney()
- end
- local NewMoney = GetMoney()
- local Change = NewMoney-OldMoney -- Positive if we gain money
- if OldMoney>NewMoney then -- Lost Money
- Spent = Spent - Change
- else -- Gained Moeny
- Profit = Profit + Change
- end
- --Text:SetText(formatMoney(NewMoney))
- -- Setup Money Tooltip
- self:SetAllPoints(Text)
- local myPlayerName = UnitName("player")
- if not BasicDB then BasicDB = {} end
- if not BasicDB.gold then BasicDB.gold = {} end
- if not BasicDB.gold[myPlayerRealm] then BasicDB.gold[myPlayerRealm]={} end
- BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney()
- OldMoney = NewMoney
- end
- Stat:RegisterEvent("PLAYER_MONEY")
- Stat:RegisterEvent("SEND_MAIL_MONEY_CHANGED")
- Stat:RegisterEvent("SEND_MAIL_COD_CHANGED")
- Stat:RegisterEvent("PLAYER_TRADE_MONEY")
- Stat:RegisterEvent("TRADE_MONEY_CHANGED")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript('OnMouseDown',
- function()
- if db.datapanel.bag ~= true then
- ToggleAllBags()
- else
- ToggleBag(0)
- end
- end
- )
- Stat:SetScript('OnEvent', OnEvent)
- Stat:SetScript("OnEnter", function(self)
- if not InCombatLockdown() then
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Gold")
- GameTooltip:AddLine' '
- GameTooltip:AddLine("Session: ")
- GameTooltip:AddDoubleLine("Earned:", formatMoney(Profit), 1, 1, 1, 1, 1, 1)
- GameTooltip:AddDoubleLine("Spent:", formatMoney(Spent), 1, 1, 1, 1, 1, 1)
- if Profit < Spent then
- GameTooltip:AddDoubleLine("Deficit:", formatMoney(Profit-Spent), 1, 0, 0, 1, 1, 1)
- elseif (Profit-Spent)>0 then
- GameTooltip:AddDoubleLine("Profit:", formatMoney(Profit-Spent), 0, 1, 0, 1, 1, 1)
- end
- GameTooltip:AddLine' '
- local totalGold = 0
- GameTooltip:AddLine("Character: ")
- local thisRealmList = BasicDB.gold[myPlayerRealm];
- for k,v in pairs(thisRealmList) do
- GameTooltip:AddDoubleLine(k, FormatTooltipMoney(v), 1, 1, 1, 1, 1, 1)
- totalGold=totalGold+v;
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("Server: ")
- GameTooltip:AddDoubleLine("Total: ", FormatTooltipMoney(totalGold), 1, 1, 1, 1, 1, 1)
- for i = 1, GetNumWatchedTokens() do
- local name, count, extraCurrencyType, icon, itemID = GetBackpackCurrencyInfo(i)
- if name and i == 1 then
- GameTooltip:AddLine(" ")
- GameTooltip:AddLine(CURRENCY)
- end
- local r, g, b = 1,1,1
- if itemID then r, g, b = GetItemQualityColor(select(3, GetItemInfo(itemID))) end
- if name and count then GameTooltip:AddDoubleLine(name, count, r, g, b, 1, 1, 1) end
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("|cffeda55fClick|r to Open Bags")
- GameTooltip:Show()
- end
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- -- reset gold data
- local function RESETGOLD()
- local myPlayerRealm = GetRealmName();
- local myPlayerName = UnitName("player");
- BasicDB.gold = {}
- BasicDB.gold[myPlayerRealm]={}
- BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney();
- end
- SLASH_RESETGOLD1 = "/resetgold"
- SlashCmdList["RESETGOLD"] = RESETGOLD
- end
- ----------------
- -- Battleground
- ----------------
- if db.datapanel.battleground == true then
- --Map IDs
- local WSG = 443
- local TP = 626
- local AV = 401
- local SOTA = 512
- local IOC = 540
- local EOTS = 482
- local TBFG = 736
- local AB = 461
- local bgframe = BattleGroundPanel
- bgframe:SetScript('OnEnter', function(self)
- local numScores = GetNumBattlefieldScores()
- for i=1, numScores do
- local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
- if ( name ) then
- if ( name == UnitName('player') ) then
- GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 0, 4)
- GameTooltip:ClearLines()
- GameTooltip:SetPoint('BOTTOM', self, 'TOP', 0, 1)
- GameTooltip:ClearLines()
- GameTooltip:AddLine("Stats for : "..hexa..name..hexb)
- GameTooltip:AddLine' '
- GameTooltip:AddDoubleLine("Killing Blows:", killingBlows,1,1,1)
- GameTooltip:AddDoubleLine("Honorable Kills:", honorableKills,1,1,1)
- GameTooltip:AddDoubleLine("Deaths:", deaths,1,1,1)
- GameTooltip:AddDoubleLine("Honor Gained:", format('%d', honorGained),1,1,1)
- GameTooltip:AddDoubleLine("Damage Done:", damageDone,1,1,1)
- GameTooltip:AddDoubleLine("Healing Done:", healingDone,1,1,1)
- --Add extra statistics to watch based on what BG you are in.
- if curmapid == WSG or curmapid == TP then
- GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
- GameTooltip:AddDoubleLine("Flags Returned:",GetBattlefieldStatData(i, 2),1,1,1)
- elseif curmapid == EOTS then
- GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
- elseif curmapid == AV then
- GameTooltip:AddDoubleLine("Graveyards Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
- GameTooltip:AddDoubleLine("Graveyards Defended:",GetBattlefieldStatData(i, 2),1,1,1)
- GameTooltip:AddDoubleLine("Towers Assaulted:",GetBattlefieldStatData(i, 3),1,1,1)
- GameTooltip:AddDoubleLine("Towers Defended:",GetBattlefieldStatData(i, 4),1,1,1)
- elseif curmapid == SOTA then
- GameTooltip:AddDoubleLine("Demolishers Destroyed:",GetBattlefieldStatData(i, 1),1,1,1)
- GameTooltip:AddDoubleLine("Gates Destroyed:",GetBattlefieldStatData(i, 2),1,1,1)
- elseif curmapid == IOC or curmapid == TBFG or curmapid == AB then
- GameTooltip:AddDoubleLine("Bases Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
- GameTooltip:AddDoubleLine("Bases Defended:",GetBattlefieldStatData(i, 2),1,1,1)
- end
- GameTooltip:Show()
- end
- end
- end
- end)
- bgframe:SetScript('OnLeave', function(self) GameTooltip:Hide() end)
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- local Text1 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
- Text1:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- Text1:SetPoint('LEFT', BattleGroundPanel, 30, 0)
- Text1:SetHeight(DataPanel:GetHeight())
- local Text2 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
- Text2:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- Text2:SetPoint('CENTER', BattleGroundPanel, 0, 0)
- Text2:SetHeight(DataPanel:GetHeight())
- local Text3 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
- Text3:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- Text3:SetPoint('RIGHT', BattleGroundPanel, -30, 0)
- Text3:SetHeight(DataPanel:GetHeight())
- local int = 2
- local function Update(self, t)
- int = int - t
- if int < 0 then
- local dmgtxt
- RequestBattlefieldScoreData()
- local numScores = GetNumBattlefieldScores()
- for i=1, numScores do
- local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
- if healingDone > damageDone then
- dmgtxt = ("Healing : "..hexa..healingDone..hexb)
- else
- dmgtxt = ("Damage : "..hexa..damageDone..hexb)
- end
- if ( name ) then
- if ( name == myname ) then
- Text2:SetText("Honor : "..hexa..format('%d', honorGained)..hexb)
- Text1:SetText(dmgtxt)
- Text3:SetText("Killing Blows : "..hexa..killingBlows..hexb)
- end
- end
- end
- int = 0
- end
- end
- --hide text when not in an bg
- local function OnEvent(self, event)
- if event == 'PLAYER_ENTERING_WORLD' then
- local inInstance, instanceType = IsInInstance()
- if inInstance and (instanceType == 'pvp') then
- bgframe:Show()
- PanelLeft:Hide()
- else
- Text1:SetText('')
- Text2:SetText('')
- Text3:SetText('')
- bgframe:Hide()
- PanelLeft:Show()
- end
- end
- end
- Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
- Stat:SetScript('OnEvent', OnEvent)
- Stat:SetScript('OnUpdate', Update)
- Update(Stat, 10)
- end
- ----------------
- -- Call To Arms
- ----------------
- if db.datapanel.calltoarms and db.datapanel.calltoarms > 0 then
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("MEDIUM")
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.calltoarms, Text)
- local function MakeIconString(tank, healer, damage)
- local str = ""
- if tank then
- str = str..'T'
- end
- if healer then
- str = str..', H'
- end
- if damage then
- str = str..', D'
- end
- return str
- end
- local function MakeString(tank, healer, damage)
- local str = ""
- if tank then
- str = str..'Tank'
- end
- if healer then
- str = str..', Healer'
- end
- if damage then
- str = str..', DPS'
- end
- return str
- end
- local function OnEvent(self, event, ...)
- local tankReward = false
- local healerReward = false
- local dpsReward = false
- local unavailable = true
- for i=1, GetNumRandomDungeons() do
- local id, name = GetLFGRandomDungeonInfo(i)
- for x = 1,LFG_ROLE_NUM_SHORTAGE_TYPES do
- local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
- if eligible then unavailable = false end
- if eligible and forTank and itemCount > 0 then tankReward = true end
- if eligible and forHealer and itemCount > 0 then healerReward = true end
- if eligible and forDamage and itemCount > 0 then dpsReward = true end
- end
- end
- if unavailable then
- Text:SetText(QUEUE_TIME_UNAVAILABLE)
- else
- Text:SetText(hexa..'C to A'..hexb.." : "..MakeIconString(tankReward, healerReward, dpsReward).." ")
- end
- self:SetAllPoints(Text)
- end
- local function OnEnter(self)
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Call to Arms")
- GameTooltip:AddLine(' ')
- local allUnavailable = true
- local numCTA = 0
- for i=1, GetNumRandomDungeons() do
- local id, name = GetLFGRandomDungeonInfo(i)
- local tankReward = false
- local healerReward = false
- local dpsReward = false
- local unavailable = true
- for x=1, LFG_ROLE_NUM_SHORTAGE_TYPES do
- local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
- if eligible then unavailable = false end
- if eligible and forTank and itemCount > 0 then tankReward = true end
- if eligible and forHealer and itemCount > 0 then healerReward = true end
- if eligible and forDamage and itemCount > 0 then dpsReward = true end
- end
- if not unavailable then
- allUnavailable = false
- local rolesString = MakeString(tankReward, healerReward, dpsReward)
- if rolesString ~= "" then
- GameTooltip:AddDoubleLine(name.." : ", rolesString..' ', 1, 1, 1)
- end
- if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
- end
- end
- if allUnavailable then
- GameTooltip:AddLine("Could not get Call To Arms information.")
- elseif numCTA == 0 then
- GameTooltip:AddLine("Could not get Call To Arms information.")
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Dungeon Finder")
- GameTooltip:AddLine("|cffeda55fRight Click|r to Open PvP Finder")
- GameTooltip:Show()
- end
- Stat:RegisterEvent("LFG_UPDATE_RANDOM_INFO")
- Stat:RegisterEvent("PLAYER_LOGIN")
- Stat:SetScript("OnEvent", OnEvent)
- Stat:SetScript("OnMouseDown", function(self, btn)
- if btn == "LeftButton" then
- ToggleLFDParentFrame(1)
- elseif btn == "RightButton" then
- TogglePVPUI(1)
- end
- end)
- Stat:SetScript("OnEnter", OnEnter)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- end
- ---------------
- -- Coordinates
- ---------------
- if db.datapanel.coords and db.datapanel.coords > 0 then
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.coords, Text)
- local function Update(self)
- local px,py=GetPlayerMapPosition("player")
- Text:SetText(format(hexa.."Loc: "..hexb.."%i , %i",px*100,py*100))
- end
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end
- ---------------------
- -- Damage Per Second
- ---------------------
- if db.datapanel.dps_text and db.datapanel.dps_text > 0 then
- 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}
- local DPS_FEED = CreateFrame('Frame')
- local player_id = UnitGUID('player')
- local dmg_total, last_dmg_amount = 0, 0
- local cmbt_time = 0
- local pet_id = UnitGUID('pet')
- local dText = DataPanel:CreateFontString(nil, 'OVERLAY')
- dText:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- dText:SetText("DPS: ", '0')
- PP(db.datapanel.dps_text, dText)
- DPS_FEED:EnableMouse(true)
- DPS_FEED:SetFrameStrata('BACKGROUND')
- DPS_FEED:SetFrameLevel(3)
- DPS_FEED:SetHeight(20)
- DPS_FEED:SetWidth(100)
- DPS_FEED:SetAllPoints(dText)
- DPS_FEED:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
- DPS_FEED:RegisterEvent('PLAYER_LOGIN')
- DPS_FEED:SetScript('OnUpdate', function(self, elap)
- if UnitAffectingCombat('player') then
- cmbt_time = cmbt_time + elap
- end
- dText:SetText(getDPS())
- end)
- function DPS_FEED:PLAYER_LOGIN()
- DPS_FEED:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
- DPS_FEED:RegisterEvent('PLAYER_REGEN_ENABLED')
- DPS_FEED:RegisterEvent('PLAYER_REGEN_DISABLED')
- DPS_FEED:RegisterEvent('UNIT_PET')
- player_id = UnitGUID('player')
- DPS_FEED:UnregisterEvent('PLAYER_LOGIN')
- end
- function DPS_FEED:UNIT_PET(unit)
- if unit == 'player' then
- pet_id = UnitGUID('pet')
- end
- end
- -- handler for the combat log. used http://www.wowwiki.com/API_COMBAT_LOG_EVENT for api
- function DPS_FEED:COMBAT_LOG_EVENT_UNFILTERED(...)
- -- filter for events we only care about. i.e heals
- if not events[select(2, ...)] then return end
- -- only use events from the player
- local id = select(4, ...)
- if id == player_id or id == pet_id then
- if select(2, ...) == "SWING_DAMAGE" then
- if toc < 40200 then
- last_dmg_amount = select(10, ...)
- else
- last_dmg_amount = select(12, ...)
- end
- else
- if toc < 40200 then
- last_dmg_amount = select(13, ...)
- else
- last_dmg_amount = select(15, ...)
- end
- end
- dmg_total = dmg_total + last_dmg_amount
- end
- end
- function getDPS()
- if (dmg_total == 0) then
- return (hexa.."DPS"..hexb..' 0')
- else
- return string.format(hexa.."DPS: "..hexb..'%.1f ', (dmg_total or 0) / (cmbt_time or 1))
- end
- end
- function DPS_FEED:PLAYER_REGEN_ENABLED()
- dText:SetText(getDPS())
- end
- function DPS_FEED:PLAYER_REGEN_DISABLED()
- cmbt_time = 0
- dmg_total = 0
- last_dmg_amount = 0
- end
- DPS_FEED:SetScript('OnMouseDown', function (self, button, down)
- cmbt_time = 0
- dmg_total = 0
- last_dmg_amount = 0
- end)
- end
- --------------
- -- Durability
- --------------
- if db.datapanel.dur and db.datapanel.dur > 0 then
- Slots = {
- [1] = {1, "Head", 1000},
- [2] = {3, "Shoulder", 1000},
- [3] = {5, "Chest", 1000},
- [4] = {6, "Waist", 1000},
- [5] = {9, "Wrist", 1000},
- [6] = {10, "Hands", 1000},
- [7] = {7, "Legs", 1000},
- [8] = {8, "Feet", 1000},
- [9] = {16, "Main Hand", 1000},
- [10] = {17, "Off Hand", 1000},
- [11] = {18, "Ranged", 1000}
- }
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("MEDIUM")
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.dur, Text)
- local function OnEvent(self)
- local Total = 0
- local current, max
- for i = 1, 11 do
- if GetInventoryItemLink("player", Slots[i][1]) ~= nil then
- current, max = GetInventoryItemDurability(Slots[i][1])
- if current then
- Slots[i][3] = current/max
- Total = Total + 1
- end
- end
- end
- table.sort(Slots, function(a, b) return a[3] < b[3] end)
- if Total > 0 then
- Text:SetText(hexa.."Armor: "..hexb..floor(Slots[1][3]*100).."% |r")
- else
- Text:SetText(hexa.."Armor: "..hexb.."100% |r")
- end
- -- Setup Durability Tooltip
- self:SetAllPoints(Text)
- Total = 0
- end
- Stat:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
- Stat:RegisterEvent("MERCHANT_SHOW")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
- Stat:SetScript("OnEvent", OnEvent)
- Stat:SetScript("OnEnter", function(self)
- if not InCombatLockdown() then
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Durability")
- GameTooltip:AddLine' '
- for i = 1, 11 do
- if Slots[i][3] ~= 1000 then
- local green, red
- green = Slots[i][3]*2
- red = 1 - green
- GameTooltip:AddDoubleLine(Slots[i][2], floor(Slots[i][3]*100).."%",1 ,1 , 1, red + 1, green, 0)
- end
- end
- GameTooltip:AddLine(" ")
- GameTooltip:AddLine("|cffeda55fClick|r to Show Character Panel")
- GameTooltip:Show()
- end
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- end
- ------------
- -- Friends
- ------------
- if db.datapanel.friends and db.datapanel.friends > 0 then
- -- create a popup
- StaticPopupDialogs["SET_BN_BROADCAST"] = {
- text = BN_BROADCAST_TOOLTIP,
- button1 = ACCEPT,
- button2 = CANCEL,
- hasEditBox = 1,
- editBoxWidth = 350,
- maxLetters = 127,
- OnAccept = function(self) BNSetCustomMessage(self.editBox:GetText()) end,
- OnShow = function(self) self.editBox:SetText(select(3, BNGetInfo()) ) self.editBox:SetFocus() end,
- OnHide = ChatEdit_FocusActiveWindow,
- EditBoxOnEnterPressed = function(self) BNSetCustomMessage(self:GetText()) self:GetParent():Hide() end,
- EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end,
- timeout = 0,
- exclusive = 1,
- whileDead = 1,
- hideOnEscape = 1
- }
- --[[ localized references for global functions (about 50% faster)
- local join = string.join
- local find = string.find
- local format = string.format
- local split = string.split
- local sort = table.sort
- local insert = table.insert
- local sizeof = table.getn
- -- for datatext display
- local displayString = join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")]]
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("MEDIUM")
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.friends, Text)
- local menuFrame = CreateFrame("Frame", "TukuiFriendRightClickMenu", UIParent, "UIDropDownMenuTemplate")
- local menuList = {
- { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
- { text = INVITE, hasArrow = true,notCheckable=true, },
- { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true, },
- { text = PLAYER_STATUS, hasArrow = true, notCheckable=true,
- menuList = {
- { text = "|cff2BC226"..AVAILABLE.."|r", notCheckable=true, func = function() if IsChatAFK() then SendChatMessage("", "AFK") elseif IsChatDND() then SendChatMessage("", "DND") end end },
- { text = "|cffE7E716"..DND.."|r", notCheckable=true, func = function() if not IsChatDND() then SendChatMessage("", "DND") end end },
- { text = "|cffFF0000"..AFK.."|r", notCheckable=true, func = function() if not IsChatAFK() then SendChatMessage("", "AFK") end end },
- },
- },
- { text = BN_BROADCAST_TOOLTIP, notCheckable=true, func = function() T.ShowPopup("TUKUI_SET_BN_BROADCAST") end },
- }
- local function GetTableIndex(table, fieldIndex, value)
- for k,v in ipairs(table) do
- if v[fieldIndex] == value then return k end
- end
- return -1
- end
- local function inviteClick(self, arg1, arg2, checked)
- menuFrame:Hide()
- if type(arg1) ~= 'number' then
- InviteUnit(arg1)
- else
- BNInviteFriend(arg1);
- end
- end
- local function whisperClick(self,name,bnet)
- menuFrame:Hide()
- if bnet then
- ChatFrame_SendSmartTell(name)
- else
- SetItemRef( "player:"..name, ("|Hplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton" )
- end
- end
- local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
- local clientLevelNameString = "%s (|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s) |cff%02x%02x%02x%s|r"
- local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s%s"
- local worldOfWarcraftString = "World of Warcraft"
- local battleNetString = "Battle.NET"
- local wowString = "WoW"
- local totalOnlineString = "Online: " .. "%s/%s"
- 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}
- local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
- local displayString = string.join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")
- local statusTable = { "|cffff0000[AFK]|r", "|cffff0000[DND]|r", "" }
- local groupedTable = { "|cffaaaaaa*|r", "" }
- local friendTable, BNTable = {}, {}
- local totalOnline, BNTotalOnline = 0, 0
- local function BuildFriendTable(total)
- totalOnline = 0
- wipe(friendTable)
- local name, level, class, area, connected, status, note
- for i = 1, total do
- name, level, class, area, connected, status, note = GetFriendInfo(i)
- for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
- if status == "<"..AFK..">" then
- status = "|cffff0000[AFK]|r"
- elseif status == "<"..DND..">" then
- status = "|cffff0000[DND]|r"
- end
- friendTable[i] = { name, level, class, area, connected, status, note }
- if connected then totalOnline = totalOnline + 1 end
- end
- end
- local function UpdateFriendTable(total)
- totalOnline = 0
- local name, level, class, area, connected, status, note
- for i = 1, #friendTable do
- name, level, class, area, connected, status, note = GetFriendInfo(i)
- for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
- -- get the correct index in our table
- local index = GetTableIndex(friendTable, 1, name)
- -- we cannot find a friend in our table, so rebuild it
- if index == -1 then
- BuildFriendTable(total)
- break
- end
- -- update on-line status for all members
- friendTable[index][5] = connected
- -- update information only for on-line members
- if connected then
- friendTable[index][2] = level
- friendTable[index][3] = class
- friendTable[index][4] = area
- friendTable[index][6] = status
- friendTable[index][7] = note
- totalOnline = totalOnline + 1
- end
- end
- end
- local function BuildBNTable(total)
- BNTotalOnline = 0
- wipe(BNTable)
- for i = 1, total do
- local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
- local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
- for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
- BNTable[i] = { presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level }
- if isOnline then BNTotalOnline = BNTotalOnline + 1 end
- end
- end
- local function UpdateBNTable(total)
- BNTotalOnline = 0
- for i = 1, #BNTable do
- -- get guild roster information
- local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
- local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
- for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
- -- get the correct index in our table
- local index = GetTableIndex(BNTable, 1, presenceID)
- -- we cannot find a BN member in our table, so rebuild it
- if index == -1 then
- BuildBNTable(total)
- return
- end
- -- update on-line status for all members
- BNTable[index][7] = isOnline
- -- update information only for on-line members
- if isOnline then
- BNTable[index][2] = presenceName
- BNTable[index][3] = battleTag
- BNTable[index][4] = toonName
- BNTable[index][5] = toonID
- BNTable[index][6] = client
- BNTable[index][8] = isAFK
- BNTable[index][9] = isDND
- BNTable[index][10] = noteText
- BNTable[index][11] = realmName
- BNTable[index][12] = faction
- BNTable[index][13] = race
- BNTable[index][14] = class
- BNTable[index][15] = zoneName
- BNTable[index][16] = level
- BNTotalOnline = BNTotalOnline + 1
- end
- end
- end
- Stat:SetScript("OnMouseUp", function(self, btn)
- if btn ~= "RightButton" then return end
- GameTooltip:Hide()
- local menuCountWhispers = 0
- local menuCountInvites = 0
- local classc, levelc
- menuList[2].menuList = {}
- menuList[3].menuList = {}
- if totalOnline > 0 then
- for i = 1, #friendTable do
- if (friendTable[i][5]) then
- menuCountInvites = menuCountInvites + 1
- menuCountWhispers = menuCountWhispers + 1
- classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
- if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
- menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = inviteClick}
- menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = whisperClick}
- end
- end
- end
- if BNTotalOnline > 0 then
- local realID, grouped
- for i = 1, #BNTable do
- if (BNTable[i][7]) then
- realID = BNTable[i][2]
- menuCountWhispers = menuCountWhispers + 1
- menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
- if BNTable[i][6] == wowString and UnitFactionGroup("player") == BNTable[i][12] then
- classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(BNTable[i][16])
- if classc == nil then classc = GetQuestDifficultyColor(BNTable[i][16]) end
- if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
- menuCountInvites = menuCountInvites + 1
- menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4]), arg1 = BNTable[i][5],notCheckable=true, func = inviteClick}
- end
- end
- end
- end
- EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
- end)
- local function Update(self, event)
- if event == "BN_FRIEND_INFO_CHANGED" or "BN_FRIEND_ACCOUNT_ONLINE" or "BN_FRIEND_ACCOUNT_OFFLINE" or "BN_TOON_NAME_UPDATED"
- or "BN_FRIEND_TOON_ONLINE" or "BN_FRIEND_TOON_OFFLINE" or "PLAYER_ENTERING_WORLD" then
- local BNTotal = BNGetNumFriends()
- if BNTotal == #BNTable then
- UpdateBNTable(BNTotal)
- else
- BuildBNTable(BNTotal)
- end
- end
- if event == "FRIENDLIST_UPDATE" or "PLAYER_ENTERING_WORLD" then
- local total = GetNumFriends()
- if total == #friendTable then
- UpdateFriendTable(total)
- else
- BuildFriendTable(total)
- end
- end
- Text:SetFormattedText(displayString, "Friends", totalOnline + BNTotalOnline)
- self:SetAllPoints(Text)
- end
- Stat:SetScript("OnMouseDown", function(self, btn) if btn == "LeftButton" then ToggleFriendsFrame() end end)
- Stat:SetScript("OnEnter", function(self)
- if InCombatLockdown() then return end
- local totalonline = totalOnline + BNTotalOnline
- local totalfriends = #friendTable + #BNTable
- local zonec, classc, levelc, realmc, grouped
- if totalonline > 0 then
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddDoubleLine("Friends list:", format(totalOnlineString, totalonline, totalfriends),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
- if totalOnline > 0 then
- GameTooltip:AddLine(' ')
- GameTooltip:AddLine(worldOfWarcraftString)
- for i = 1, #friendTable do
- if friendTable[i][5] then
- if GetRealZoneText() == friendTable[i][4] then zonec = activezone else zonec = inactivezone end
- classc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]]
- if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
- if friendTable[i][2] ~= '' then
- levelc = GetQuestDifficultyColor(friendTable[i][2])
- else
- levelc = RAID_CLASS_COLORS["PRIEST"]
- classc = RAID_CLASS_COLORS["PRIEST"]
- end
- if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then grouped = 1 else grouped = 2 end
- GameTooltip:AddDoubleLine(format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],friendTable[i][1],groupedTable[grouped]," "..friendTable[i][6]),friendTable[i][4],classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
- end
- end
- end
- if BNTotalOnline > 0 then
- GameTooltip:AddLine(' ')
- GameTooltip:AddLine(battleNetString)
- local status = 0
- for i = 1, #BNTable do
- if BNTable[i][7] then
- if BNTable[i][6] == wowString then
- if (BNTable[i][8] == true) then status = 1 elseif (BNTable[i][9] == true) then status = 2 else status = 3 end
- classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(BNTable[i][16])
- if classc == nil then classc = GetQuestDifficultyColor(BNTable[i][16]) end
- if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
- GameTooltip:AddDoubleLine(format(clientLevelNameString, BNTable[i][6],levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4],groupedTable[grouped], 255, 0, 0, statusTable[status]),BNTable[i][2],238,238,238,238,238,238)
- if IsShiftKeyDown() then
- if GetRealZoneText() == BNTable[i][15] then zonec = activezone else zonec = inactivezone end
- if GetRealmName() == BNTable[i][11] then realmc = activezone else realmc = inactivezone end
- GameTooltip:AddDoubleLine(" "..BNTable[i][15], BNTable[i][11], zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
- end
- else
- GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][6].." ("..BNTable[i][4]..")|r", "|cffeeeeee"..BNTable[i][2].."|r")
- end
- end
- end
- end
- GameTooltip:Show()
- else
- GameTooltip:Hide()
- end
- end)
- Stat:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
- Stat:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
- Stat:RegisterEvent("BN_FRIEND_INFO_CHANGED")
- Stat:RegisterEvent("BN_FRIEND_TOON_ONLINE")
- Stat:RegisterEvent("BN_FRIEND_TOON_OFFLINE")
- Stat:RegisterEvent("BN_TOON_NAME_UPDATED")
- Stat:RegisterEvent("FRIENDLIST_UPDATE")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- Stat:SetScript("OnEvent", Update)
- end
- ---------
- -- Guild
- ---------
- if db.datapanel.guild and db.datapanel.guild > 0 then
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("MEDIUM")
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.guild, Text)
- 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}
- local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
- local displayString = string.join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")
- local guildInfoString0 = "%s"
- local guildInfoString1 = "%s [%d]"
- local guildInfoString2 = "%s: %d/%d"
- local guildMotDString = "%s |cffaaaaaa- |cffffffff%s"
- local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
- local levelNameStatusString = "|cff%02x%02x%02x%d|r %s %s"
- local nameRankString = "%s |cff999999-|cffffffff %s"
- local noteString = " '%s'"
- local officerNoteString = " o: '%s'"
- local guildTable, guildXP, guildMotD = {}, {}, ""
- local totalOnline = 0
- local function BuildGuildTable()
- totalOnline = 0
- wipe(guildTable)
- local _, name, rank, level, zone, note, officernote, connected, status, class, isMobile
- for i = 1, GetNumGuildMembers() do
- name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, isMobile = GetGuildRosterInfo(i)
- if status == 1 then
- status = "|cffff0000["..AFK.."]|r"
- elseif status == 2 then
- status = "|cffff0000["..DND.."]|r"
- else
- status = ""
- end
- guildTable[i] = { name, rank, level, zone, note, officernote, connected, status, class, isMobile }
- if connected then totalOnline = totalOnline + 1 end
- end
- table.sort(guildTable, function(a, b)
- if a and b then
- return a[1] < b[1]
- end
- end)
- end
- local function UpdateGuildXP()
- local currentXP, remainingXP = UnitGetGuildXP("player")
- local nextLevelXP = currentXP + remainingXP
- -- prevent 4.3 division / 0
- if nextLevelXP == 0 or maxDailyXP == 0 then return end
- local percentTotal = tostring(math.ceil((currentXP / nextLevelXP) * 100))
- guildXP[0] = { currentXP, nextLevelXP, percentTotal }
- end
- local function UpdateGuildMessage()
- guildMotD = GetGuildRosterMOTD()
- end
- local function Update(self, event, ...)
- if event == "PLAYER_ENTERING_WORLD" then
- self:UnregisterEvent("PLAYER_ENTERING_WORLD")
- if IsInGuild() and not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
- end
- if IsInGuild() then
- totalOnline = 0
- local name, rank, level, zone, note, officernote, connected, status, class
- for i = 1, GetNumGuildMembers() do
- local connected = select(9, GetGuildRosterInfo(i))
- if connected then totalOnline = totalOnline + 1 end
- end
- Text:SetFormattedText(displayString, "Guild", totalOnline)
- else
- Text:SetText("No Guild")
- end
- self:SetAllPoints(Text)
- end
- local menuFrame = CreateFrame("Frame", "GuildRightClickMenu", UIParent, "UIDropDownMenuTemplate")
- local menuList = {
- { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
- { text = INVITE, hasArrow = true,notCheckable=true,},
- { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true,}
- }
- local function inviteClick(self, arg1, arg2, checked)
- menuFrame:Hide()
- InviteUnit(arg1)
- end
- local function whisperClick(self,arg1,arg2,checked)
- menuFrame:Hide()
- SetItemRef( "player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton" )
- end
- local function ToggleGuildFrame()
- if IsInGuild() then
- if not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
- GuildFrame_Toggle()
- GuildFrame_TabClicked(GuildFrameTab2)
- else
- if not LookingForGuildFrame then LoadAddOn("Blizzard_LookingForGuildUI") end
- LookingForGuildFrame_Toggle()
- end
- end
- Stat:SetScript("OnMouseUp", function(self, btn)
- if btn ~= "RightButton" or not IsInGuild() then return end
- GameTooltip:Hide()
- local classc, levelc, grouped
- local menuCountWhispers = 0
- local menuCountInvites = 0
- menuList[2].menuList = {}
- menuList[3].menuList = {}
- for i = 1, #guildTable do
- if (guildTable[i][7] and guildTable[i][1] ~= nDatamyname) then
- local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
- if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
- grouped = "|cffaaaaaa*|r"
- else
- grouped = ""
- if not guildTable[i][10] then
- menuCountInvites = menuCountInvites + 1
- menuList[2].menuList[menuCountInvites] = {text = string.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}
- end
- end
- menuCountWhispers = menuCountWhispers + 1
- menuList[3].menuList[menuCountWhispers] = {text = string.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}
- end
- end
- EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
- end)
- Stat:SetScript("OnEnter", function(self)
- if InCombatLockdown() or not IsInGuild() then return end
- GuildRoster()
- UpdateGuildMessage()
- BuildGuildTable()
- local name, rank, level, zone, note, officernote, connected, status, class, isMobile
- local zonec, classc, levelc
- local online = totalOnline
- local guildName, guildRankName, guildRankIndex = GetGuildInfo("player");
- local GuildInfo = GetGuildInfo('player')
- local GuildLevel = GetGuildLevel()
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Guild")
- if GuildInfo then
- GameTooltip:AddDoubleLine(string.format(guildInfoString0, GuildInfo), string.format(guildInfoString1, "Guild Level:", GuildLevel),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
- end
- GameTooltip:AddLine' '
- if GuildLevel then
- GameTooltip:AddLine( string.format(guildInfoString2, "Member's Online", online, #guildTable),tthead.r,tthead.g,tthead.b)
- end
- if guildMotD ~= "" then GameTooltip:AddLine(' ')
- GameTooltip:AddLine(string.format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
- end
- local col = RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
- GameTooltip:AddLine' '
- if GuildLevel and GuildLevel ~= 25 then
- --UpdateGuildXP()
- if guildXP[0] then
- local currentXP, nextLevelXP, percentTotal = unpack(guildXP[0])
- GameTooltip:AddLine(string.format(col..GUILD_EXPERIENCE_CURRENT, "|r |cFFFFFFFF"..ShortValue(currentXP), ShortValue(nextLevelXP), percentTotal))
- end
- end
- local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
- if standingID ~= 8 then -- Not Max Rep
- barMax = barMax - barMin
- barValue = barValue - barMin
- barMin = 0
- GameTooltip:AddLine(string.format("%s:|r |cFFFFFFFF%s/%s (%s%%)",col..COMBAT_FACTION_CHANGE, ShortValue(barValue), ShortValue(barMax), math.ceil((barValue / barMax) * 100)))
- end
- if online > 1 then
- GameTooltip:AddLine(' ')
- for i = 1, #guildTable do
- if online <= 1 then
- if online > 1 then GameTooltip:AddLine(format("+ %d More...", online - modules.Guild.maxguild),ttsubh.r,ttsubh.g,ttsubh.b) end
- break
- end
- name, rank, level, zone, note, officernote, connected, status, class, isMobile = unpack(guildTable[i])
- if connected and name ~= nDatamyname then
- if GetRealZoneText() == zone then zonec = activezone else zonec = inactivezone end
- classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
- if isMobile then zone = "" end
- if IsShiftKeyDown() then
- GameTooltip:AddDoubleLine(string.format(nameRankString, name, rank), zone, classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
- if note ~= "" then GameTooltip:AddLine(string.format(noteString, note), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
- if officernote ~= "" then GameTooltip:AddLine(string.format(officerNoteString, officernote), ttoff.r, ttoff.g, ttoff.b ,1) end
- else
- GameTooltip:AddDoubleLine(string.format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, level, name, status), zone, classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
- end
- end
- end
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Guild Roster")
- GameTooltip:AddLine("|cffeda55fHold Shift & Mouseover|r to See Guild and Officer Note's")
- GameTooltip:AddLine("|cffeda55fRight Click|r to open Options Menu")
- GameTooltip:Show()
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- Stat:SetScript("OnMouseDown", function(self, btn)
- if btn ~= "LeftButton" then return end
- ToggleGuildFrame()
- end)
- Stat:RegisterEvent("GUILD_ROSTER_SHOW")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:RegisterEvent("GUILD_ROSTER_UPDATE")
- Stat:RegisterEvent("PLAYER_GUILD_UPDATE")
- Stat:SetScript("OnEvent", Update)
- end
- ----------------
- -- Player Haste
- ----------------
- if db.datapanel.haste and db.datapanel.haste > 0 then
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.haste, Text)
- local int = 1
- local function Update(self, t)
- local spellhaste = GetCombatRating(CR_HASTE_SPELL)
- local rangedhaste = GetCombatRating(CR_HASTE_RANGED)
- local attackhaste = GetCombatRating(CR_HASTE_MELEE)
- if attackhaste > spellhaste and select(2, UnitClass("Player")) ~= "HUNTER" then
- haste = attackhaste
- elseif select(2, UnitClass("Player")) == "HUNTER" then
- haste = rangedhaste
- else
- haste = spellhaste
- end
- int = int - t
- if int < 0 then
- Text:SetText(hexa.."Haste: "..hexb..haste)
- int = 1
- end
- end
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end
- --------------------
- -- Heals Per Second
- --------------------
- if db.datapanel.hps_text and db.datapanel.hps_text > 0 then
- local events = {SPELL_HEAL = true, SPELL_PERIODIC_HEAL = true}
- local HPS_FEED = CreateFrame('Frame')
- local player_id = UnitGUID('player')
- local actual_heals_total, cmbt_time = 0
- local hText = DataPanel:CreateFontString(nil, 'OVERLAY')
- hText:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- hText:SetText("HPS: ", '0')
- PP(db.datapanel.hps_text, hText)
- HPS_FEED:EnableMouse(true)
- HPS_FEED:SetFrameStrata('BACKGROUND')
- HPS_FEED:SetFrameLevel(3)
- HPS_FEED:SetHeight(20)
- HPS_FEED:SetWidth(100)
- HPS_FEED:SetAllPoints(hText)
- HPS_FEED:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
- HPS_FEED:RegisterEvent('PLAYER_LOGIN')
- HPS_FEED:SetScript('OnUpdate', function(self, elap)
- if UnitAffectingCombat('player') then
- HPS_FEED:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
- cmbt_time = cmbt_time + elap
- else
- HPS_FEED:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
- end
- hText:SetText(get_hps())
- end)
- function HPS_FEED:PLAYER_LOGIN()
- HPS_FEED:RegisterEvent('PLAYER_REGEN_ENABLED')
- HPS_FEED:RegisterEvent('PLAYER_REGEN_DISABLED')
- player_id = UnitGUID('player')
- HPS_FEED:UnregisterEvent('PLAYER_LOGIN')
- end
- -- handler for the combat log. used http://www.wowwiki.com/API_COMBAT_LOG_EVENT for api
- function HPS_FEED:COMBAT_LOG_EVENT_UNFILTERED(...)
- -- filter for events we only care about. i.e heals
- if not events[select(2, ...)] then return end
- if event == 'PLAYER_REGEN_DISABLED' then return end
- -- only use events from the player
- local id = select(4, ...)
- if id == player_id then
- if toc < 40200 then
- amount_healed = select(13, ...)
- amount_over_healed = select(14, ...)
- else
- amount_healed = select(15, ...)
- amount_over_healed = select(16, ...)
- end
- -- add to the total the healed amount subtracting the overhealed amount
- actual_heals_total = actual_heals_total + math.max(0, amount_healed - amount_over_healed)
- end
- end
- function get_hps()
- if (actual_heals_total == 0) then
- return (hexa.."HPS: "..hexb..'0' )
- else
- return string.format('%.1f '..hexa.."HPS"..hexb, (actual_heals_total or 0) / (cmbt_time or 1))
- end
- end
- function HPS_FEED:PLAYER_REGEN_ENABLED()
- hText:SetText(get_hps)
- end
- function HPS_FEED:PLAYER_REGEN_DISABLED()
- cmbt_time = 0
- actual_heals_total = 0
- end
- HPS_FEED:SetScript('OnMouseDown', function (self, button, down)
- cmbt_time = 0
- actual_heals_total = 0
- end)
- end
- ---------------
- -- Professions
- ---------------
- if db.datapanel.pro and db.datapanel.pro > 0 then
- local Stat = CreateFrame('Button')
- Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- Stat:EnableMouse(true)
- Stat.tooltip = false
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.pro, Text)
- local function Update(self)
- for i = 1, select("#", GetProfessions()) do
- local v = select(i, GetProfessions());
- if v ~= nil then
- local name, texture, rank, maxRank = GetProfessionInfo(v)
- Text:SetFormattedText(hexa.."Professions"..hexb)
- end
- end
- self:SetAllPoints(Text)
- end
- Stat:SetScript('OnEnter', function()
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Professions")
- GameTooltip:AddLine' '
- for i = 1, select("#", GetProfessions()) do
- local v = select(i, GetProfessions());
- if v ~= nil then
- local name, texture, rank, maxRank = GetProfessionInfo(v)
- GameTooltip:AddDoubleLine(name, rank..' / '..maxRank,.75,.9,1,.3,1,.3)
- end
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Profession #1")
- GameTooltip:AddLine("|cffeda55fMiddle Click|r to Open Spell Book")
- GameTooltip:AddLine("|cffeda55fRight Click|r to Open Profession #2")
- GameTooltip:Show()
- end)
- Stat:SetScript("OnClick",function(self,btn)
- local prof1, prof2 = GetProfessions()
- if btn == "LeftButton" then
- if prof1 then
- if (GetProfessionInfo(prof1) == ('Herbalism')) then
- print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
- elseif(GetProfessionInfo(prof1) == ('Skinning')) then
- print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
- elseif(GetProfessionInfo(prof1) == ('Mining')) then
- CastSpellByName("Smelting")
- else
- CastSpellByName((GetProfessionInfo(prof1)))
- end
- else
- print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
- end
- elseif btn == 'MiddleButton' then
- ToggleSpellBook(BOOKTYPE_PROFESSION);
- elseif btn == "RightButton" then
- if prof2 then
- if (GetProfessionInfo(prof2) == ('Herbalism')) then
- print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
- elseif(GetProfessionInfo(prof2) == ('Skinning')) then
- print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
- elseif(GetProfessionInfo(prof2) == ('Mining')) then
- CastSpellByName("Smelting")
- else
- CastSpellByName((GetProfessionInfo(prof2)))
- end
- else
- print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
- end
- end
- end)
- Stat:RegisterForClicks("AnyUp")
- Stat:SetScript('OnUpdate', Update)
- Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
- end
- -----------
- -- Recount
- -----------
- if db.datapanel.recount and db.datapanel.recount > 0 then
- local RecountDPS = CreateFrame("Frame")
- RecountDPS:EnableMouse(true)
- RecountDPS:SetFrameStrata("MEDIUM")
- RecountDPS:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.recount, Text)
- RecountDPS:SetAllPoints(Text)
- function OnEvent(self, event, ...)
- if event == "PLAYER_LOGIN" then
- if IsAddOnLoaded("Recount") then
- RecountDPS:RegisterEvent("PLAYER_REGEN_ENABLED")
- RecountDPS:RegisterEvent("PLAYER_REGEN_DISABLED")
- myname = UnitName("player")
- currentFightDPS = 0
- else
- return
- end
- RecountDPS:UnregisterEvent("PLAYER_LOGIN")
- elseif event == "PLAYER_ENTERING_WORLD" then
- self.updateDPS()
- RecountDPS:UnregisterEvent("PLAYER_ENTERING_WORLD")
- end
- end
- function RecountDPS:RecountHook_UpdateText()
- self:updateDPS()
- end
- function RecountDPS:updateDPS()
- Text:SetText(hexa.."DPS: "..hexb.. RecountDPS.getDPS() .. "|r")
- end
- function RecountDPS:getDPS()
- if not IsAddOnLoaded("Recount") then return "N/A" end
- if db.datapanel.recountraiddps == true then
- -- show raid dps
- _, dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
- return dps
- else
- return RecountDPS.getValuePerSecond()
- end
- end
- -- quick dps calculation from recount's data
- function RecountDPS:getValuePerSecond()
- local _, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[myname], Recount.db.profile.CurDataSet)
- return math.floor(10 * dps + 0.5) / 10
- end
- function RecountDPS:getRaidValuePerSecond(tablename)
- local dps, curdps, data, damage, temp = 0, 0, nil, 0, 0
- for _,data in pairs(Recount.db2.combatants) do
- if data.Fights and data.Fights[tablename] and (data.type=="Self" or data.type=="Grouped" or data.type=="Pet" or data.type=="Ungrouped") then
- temp, curdps = Recount:MergedPetDamageDPS(data,tablename)
- 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
- dps = dps + 10 * curdps
- damage = damage + temp
- end
- end
- end
- return math.floor(damage + 0.5) / 10, math.floor(dps + 0.5)/10
- end
- -- tracked events
- RecountDPS:RegisterEvent("PLAYER_LOGIN")
- RecountDPS:RegisterEvent("PLAYER_ENTERING_WORLD")
- -- scripts
- RecountDPS:SetScript("OnEnter", function(self)
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Damage")
- GameTooltip:AddLine' '
- if IsAddOnLoaded("Recount") then
- local damage, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[myname], Recount.db.profile.CurDataSet)
- local raid_damage, raid_dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
- -- format the number
- dps = math.floor(10 * dps + 0.5) / 10
- GameTooltip:AddLine("Recount")
- GameTooltip:AddDoubleLine("Personal Damage:", damage, 1, 1, 1, 0.8, 0.8, 0.8)
- GameTooltip:AddDoubleLine("Personal DPS:", dps, 1, 1, 1, 0.8, 0.8, 0.8)
- GameTooltip:AddLine(" ")
- GameTooltip:AddDoubleLine("Raid Damage:", raid_damage, 1, 1, 1, 0.8, 0.8, 0.8)
- GameTooltip:AddDoubleLine("Raid DPS:", raid_dps, 1, 1, 1, 0.8, 0.8, 0.8)
- GameTooltip:AddLine(" ")
- GameTooltip:AddLine("|cffeda55fLeft Click|r to toggle Recount")
- GameTooltip:AddLine("|cffeda55fRight Click|r to reset data")
- GameTooltip:AddLine("|cffeda55fShift + Right Click|r to open config")
- else
- GameTooltip:AddLine("Recount is not loaded.", 255, 0, 0)
- GameTooltip:AddLine("Enable Recount and reload your UI.")
- end
- GameTooltip:Show()
- end)
- RecountDPS:SetScript("OnMouseUp", function(self, button)
- if button == "RightButton" then
- if not IsShiftKeyDown() then
- Recount:ShowReset()
- else
- Recount:ShowConfig()
- end
- elseif button == "LeftButton" then
- if Recount.MainWindow:IsShown() then
- Recount.MainWindow:Hide()
- else
- Recount.MainWindow:Show()
- Recount:RefreshMainWindow()
- end
- end
- end)
- RecountDPS:SetScript("OnEvent", OnEvent)
- RecountDPS:SetScript("OnLeave", function() GameTooltip:Hide() end)
- RecountDPS:SetScript("OnUpdate", function(self, t)
- local int = -1
- int = int - t
- if int < 0 then
- self.updateDPS()
- int = 1
- end
- end)
- end
- --------------------
- -- Talent Spec Swap
- --------------------
- if db.datapanel.spec and db.datapanel.spec > 0 then
- local Stat = CreateFrame('Frame')
- Stat:EnableMouse(true)
- Stat:SetFrameStrata('BACKGROUND')
- Stat:SetFrameLevel(3)
- local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.spec, Text)
- local talent = {}
- local active
- local talentString = string.join('', '|cffFFFFFF%s|r ')
- local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
- local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
- local function LoadTalentTrees()
- for i = 1, GetNumSpecGroups(false, false) do
- talent[i] = {} -- init talent group table
- for j = 1, GetNumSpecializations(false, false) do
- talent[i][j] = select(5, GetSpecializationInfo(j, false, false, i))
- end
- end
- end
- local int = 1
- local function Update(self, t)
- int = int - t
- if int > 0 or not GetSpecialization() then return end
- active = GetActiveSpecGroup(false, false)
- Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
- int = 1
- -- disable script
- self:SetScript('OnUpdate', nil)
- end
- Stat:SetScript('OnEnter', function(self)
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Spec")
- GameTooltip:AddLine' '
- for i = 1, GetNumSpecGroups() do
- if GetSpecialization(false, false, i) then
- GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == active and activeString or inactiveString)),1,1,1)
- end
- end
- GameTooltip:AddLine' '
- GameTooltip:AddLine("|cffeda55fLeft Click|r to Switch Spec's")
- GameTooltip:AddLine("|cffeda55fRight Click|r to Open Talent Tree")
- GameTooltip:Show()
- end)
- Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
- local function OnEvent(self, event, ...)
- if event == 'PLAYER_ENTERING_WORLD' then
- self:UnregisterEvent('PLAYER_ENTERING_WORLD')
- end
- -- load talent information
- LoadTalentTrees()
- -- Setup Talents Tooltip
- self:SetAllPoints(Text)
- -- update datatext
- if event ~= 'PLAYER_ENTERING_WORLD' then
- self:SetScript('OnUpdate', Update)
- end
- end
- Stat:RegisterEvent('PLAYER_ENTERING_WORLD');
- Stat:RegisterEvent('CHARACTER_POINTS_CHANGED');
- Stat:RegisterEvent('PLAYER_TALENT_UPDATE');
- Stat:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
- Stat:RegisterEvent("EQUIPMENT_SETS_CHANGED")
- Stat:SetScript('OnEvent', OnEvent)
- Stat:SetScript('OnUpdate', Update)
- Stat:SetScript("OnMouseDown", function(self, button)
- if button == "LeftButton" then
- SetActiveSpecGroup (active == 1 and 2 or 1)
- elseif button == "RightButton" then
- ToggleTalentFrame()
- end
- end)
- end
- -----------------
- -- Statistics #1
- -----------------
- if db.datapanel.stat1 and db.datapanel.stat1 > 0 then
- local Stat = CreateFrame("Frame")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetFrameStrata("BACKGROUND")
- Stat:SetFrameLevel(3)
- Stat:EnableMouse(true)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.stat1, Text)
- local format = string.format
- local targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
- local basemisschance, leveldifference, dodge, parry, block
- local chanceString = "%.2f%%"
- local modifierString = string.join("", "%d (+", chanceString, ")")
- local manaRegenString = "%d / %d"
- local displayNumberString = string.join("", "%s", "%d|r")
- local displayFloatString = string.join("", "%s", "%.2f%%|r")
- local spellpwr, avoidance, pwr
- local haste, hasteBonus
- local level = UnitLevel("player")
- local function ShowTooltip(self)
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Statistics")
- GameTooltip:AddLine' '
- if Role == "Tank" then
- if targetlv > 1 then
- GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", targetlv, ")"))
- elseif targetlv == -1 then
- GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "Boss", ")"))
- else
- GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", playerlv, ")"))
- end
- GameTooltip:AddLine' '
- GameTooltip:AddDoubleLine(DODGE_CHANCE, format(chanceString, dodge),1,1,1)
- GameTooltip:AddDoubleLine(PARRY_CHANCE, format(chanceString, parry),1,1,1)
- GameTooltip:AddDoubleLine(BLOCK_CHANCE, format(chanceString, block),1,1,1)
- GameTooltip:AddDoubleLine(MISS_CHANCE, format(chanceString, basemisschance),1,1,1)
- elseif Role == "Caster" then
- GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, GetCombatRating(CR_HIT_SPELL), GetCombatRatingBonus(CR_HIT_SPELL)), 1, 1, 1)
- GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, GetCombatRating(CR_HASTE_SPELL), GetCombatRatingBonus(CR_HASTE_SPELL)), 1, 1, 1)
- local base, combat = GetManaRegen()
- GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, combat * 5), 1, 1, 1)
- elseif Role == "Melee" then
- local hit = myclass == "HUNTER" and GetCombatRating(CR_HIT_RANGED) or GetCombatRating(CR_HIT_MELEE)
- local hitBonus = myclass == "HUNTER" and GetCombatRatingBonus(CR_HIT_RANGED) or GetCombatRatingBonus(CR_HIT_MELEE)
- GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, hit, hitBonus), 1, 1, 1)
- local haste = myclass == "HUNTER" and GetCombatRating(CR_HASTE_RANGED) or GetCombatRating(CR_HASTE_MELEE)
- local hasteBonus = myclass == "HUNTER" and GetCombatRatingBonus(CR_HASTE_RANGED) or GetCombatRatingBonus(CR_HASTE_MELEE)
- GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, haste, hasteBonus), 1, 1, 1)
- end
- local masteryspell
- if GetCombatRating(CR_MASTERY) ~= 0 and GetSpecialization() then
- if myclass == "DRUID" then
- if Role == "Melee" then
- masteryspell = select(2, GetSpecializationMasterySpells(GetSpecialization()))
- elseif Role == "Tank" then
- masteryspell = select(1, GetSpecializationMasterySpells(GetSpecialization()))
- else
- masteryspell = GetSpecializationMasterySpells(GetSpecialization())
- end
- else
- masteryspell = GetSpecializationMasterySpells(GetSpecialization())
- end
- local masteryName, _, _, _, _, _, _, _, _ = GetSpellInfo(masteryspell)
- if masteryName then
- GameTooltip:AddLine' '
- GameTooltip:AddDoubleLine(masteryName, format(modifierString, GetCombatRating(CR_MASTERY), GetCombatRatingBonus(CR_MASTERY)), 1, 1, 1)
- end
- end
- GameTooltip:Show()
- end
- local function UpdateTank(self)
- -- the 5 is for base miss chance
- if targetlv == -1 then
- basemisschance = (5 - (3*.2))
- leveldifference = 3
- elseif targetlv > playerlv then
- basemisschance = (5 - ((targetlv - playerlv)*.2))
- leveldifference = (targetlv - playerlv)
- elseif targetlv < playerlv and targetlv > 0 then
- basemisschance = (5 + ((playerlv - targetlv)*.2))
- leveldifference = (targetlv - playerlv)
- else
- basemisschance = 5
- leveldifference = 0
- end
- if select(2, UnitRace("player")) == "NightElf" then basemisschance = basemisschance + 2 end
- if leveldifference >= 0 then
- dodge = (GetDodgeChance()-leveldifference*.2)
- parry = (GetParryChance()-leveldifference*.2)
- block = (GetBlockChance()-leveldifference*.2)
- else
- dodge = (GetDodgeChance()+abs(leveldifference*.2))
- parry = (GetParryChance()+abs(leveldifference*.2))
- block = (GetBlockChance()+abs(leveldifference*.2))
- end
- if dodge <= 0 then dodge = 0 end
- if parry <= 0 then parry = 0 end
- if block <= 0 then block = 0 end
- if myclass == "DRUID" then
- parry = 0
- block = 0
- elseif myclass == "DEATHKNIGHT" then
- block = 0
- end
- avoidance = (dodge+parry+block+basemisschance)
- Text:SetFormattedText(displayFloatString, hexa.."AVD: "..hexb, avoidance)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- local function UpdateCaster(self)
- if GetSpellBonusHealing() > GetSpellBonusDamage(7) then
- spellpwr = GetSpellBonusHealing()
- else
- spellpwr = GetSpellBonusDamage(7)
- end
- Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- local function UpdateMelee(self)
- local base, posBuff, negBuff = UnitAttackPower("player");
- local effective = base + posBuff + negBuff;
- local Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player");
- local Reffective = Rbase + RposBuff + RnegBuff;
- if myclass == "HUNTER" then
- pwr = Reffective
- else
- pwr = effective
- end
- Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- -- initial delay for update (let the ui load)
- local int = 5
- local function Update(self, t)
- int = int - t
- if int > 0 then return end
- if Role == "Tank" then
- UpdateTank(self)
- elseif Role == "Caster" then
- UpdateCaster(self)
- elseif Role == "Melee" then
- UpdateMelee(self)
- end
- int = 2
- end
- Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end
- -----------------
- -- Statistics #2
- -----------------
- if db.datapanel.stat2 and db.datapanel.stat2 > 0 then
- local Stat = CreateFrame("Frame")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetFrameStrata("BACKGROUND")
- Stat:SetFrameLevel(3)
- Stat:EnableMouse(true)
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.stat2, Text)
- local _G = getfenv(0)
- local format = string.format
- local chanceString = "%.2f%%"
- local armorString = hexa..ARMOR..hexb..": "
- local modifierString = string.join("", "%d (+", chanceString, ")")
- local baseArmor, effectiveArmor, armor, posBuff, negBuff
- local displayNumberString = string.join("", "%s", "%d|r")
- local displayFloatString = string.join("", "%s", "%.2f%%|r")
- local level = UnitLevel("player")
- local function CalculateMitigation(level, effective)
- local mitigation
- if not effective then
- _, effective, _, _, _ = UnitArmor("player")
- end
- if level < 60 then
- mitigation = (effective/(effective + 400 + (85 * level)));
- else
- mitigation = (effective/(effective + (467.5 * level - 22167.5)));
- end
- if mitigation > .75 then
- mitigation = .75
- end
- return mitigation
- end
- local function AddTooltipHeader(description)
- GameTooltip:AddLine(description)
- GameTooltip:AddLine(' ')
- end
- local function ShowTooltip(self)
- if InCombatLockdown() then return end
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Statistics")
- GameTooltip:AddLine' '
- if Role == "Tank" then
- AddTooltipHeader("Mitigation By Level: ")
- local lv = level +3
- for i = 1, 4 do
- GameTooltip:AddDoubleLine(lv,format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
- lv = lv - 1
- end
- lv = UnitLevel("target")
- if lv and lv > 0 and (lv > level + 3 or lv < level) then
- GameTooltip:AddDoubleLine(lv, format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
- end
- elseif Role == "Caster" or Role == "Melee" then
- AddTooltipHeader(MAGIC_RESISTANCES_COLON)
- local baseResistance, effectiveResistance, posResitance, negResistance
- for i = 2, 6 do
- baseResistance, effectiveResistance, posResitance, negResistance = UnitResistance("player", i)
- GameTooltip:AddDoubleLine(_G["DAMAGE_SCHOOL"..(i+1)], format(chanceString, (effectiveResistance / (effectiveResistance + (500 + level + 2.5))) * 100),1,1,1)
- end
- local spellpen = GetSpellPenetration()
- if (myclass == "SHAMAN" or Role == "Caster") and spellpen > 0 then
- GameTooltip:AddLine' '
- GameTooltip:AddDoubleLine(ITEM_MOD_SPELL_PENETRATION_SHORT, spellpen,1,1,1)
- end
- end
- GameTooltip:Show()
- end
- local function UpdateTank(self)
- baseArmor, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
- Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- local function UpdateCaster(self)
- local spellcrit = GetSpellCritChance(1)
- Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, spellcrit)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- local function UpdateMelee(self)
- local meleecrit = GetCritChance()
- local rangedcrit = GetRangedCritChance()
- local critChance
- if myclass == "HUNTER" then
- critChance = rangedcrit
- else
- critChance = meleecrit
- end
- Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, critChance)
- --Setup Tooltip
- self:SetAllPoints(Text)
- end
- -- initial delay for update (let the ui load)
- local int = 5
- local function Update(self, t)
- int = int - t
- if int > 0 then return end
- if Role == "Tank" then
- UpdateTank(self)
- elseif Role == "Caster" then
- UpdateCaster(self)
- elseif Role == "Melee" then
- UpdateMelee(self)
- end
- int = 2
- end
- Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end
- -------------------
- -- System Settings
- -------------------
- if db.datapanel.system and db.datapanel.system > 0 then
- local Stat = CreateFrame("Frame")
- Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
- Stat:SetFrameStrata("BACKGROUND")
- Stat:SetFrameLevel(3)
- Stat:EnableMouse(true)
- Stat.tooltip = false
- local Text = DataPanel:CreateFontString(nil, "OVERLAY")
- Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
- PP(db.datapanel.system, Text)
- local bandwidthString = "%.2f Mbps"
- local percentageString = "%.2f%%"
- local homeLatencyString = "%d ms"
- local worldLatencyString = "%d ms"
- local kiloByteString = "%d kb"
- local megaByteString = "%.2f mb"
- local function formatMem(memory)
- local mult = 10^1
- if memory > 999 then
- local mem = ((memory/1024) * mult) / mult
- return string.format(megaByteString, mem)
- else
- local mem = (memory * mult) / mult
- return string.format(kiloByteString, mem)
- end
- end
- local memoryTable = {}
- local function RebuildAddonList(self)
- local addOnCount = GetNumAddOns()
- if (addOnCount == #memoryTable) or self.tooltip == true then return end
- -- Number of loaded addons changed, create new memoryTable for all addons
- memoryTable = {}
- for i = 1, addOnCount do
- memoryTable[i] = { i, select(2, GetAddOnInfo(i)), 0, IsAddOnLoaded(i) }
- end
- self:SetAllPoints(Text)
- end
- local function UpdateMemory()
- -- Update the memory usages of the addons
- UpdateAddOnMemoryUsage()
- -- Load memory usage in table
- local addOnMem = 0
- local totalMemory = 0
- for i = 1, #memoryTable do
- addOnMem = GetAddOnMemoryUsage(memoryTable[i][1])
- memoryTable[i][3] = addOnMem
- totalMemory = totalMemory + addOnMem
- end
- -- Sort the table to put the largest addon on top
- table.sort(memoryTable, function(a, b)
- if a and b then
- return a[3] > b[3]
- end
- end)
- return totalMemory
- end
- -- initial delay for update (let the ui load)
- local int, int2 = 6, 5
- local statusColors = {
- "|cff0CD809",
- "|cffE8DA0F",
- "|cffFF9000",
- "|cffD80909"
- }
- local function Update(self, t)
- int = int - t
- int2 = int2 - t
- if int < 0 then
- RebuildAddonList(self)
- int = 10
- end
- if int2 < 0 then
- local framerate = floor(GetFramerate())
- local fpscolor = 4
- local latency = select(4, GetNetStats())
- local latencycolor = 4
- if latency < 150 then
- latencycolor = 1
- elseif latency >= 150 and latency < 300 then
- latencycolor = 2
- elseif latency >= 300 and latency < 500 then
- latencycolor = 3
- end
- if framerate >= 30 then
- fpscolor = 1
- elseif framerate >= 20 and framerate < 30 then
- fpscolor = 2
- elseif framerate >= 10 and framerate < 20 then
- fpscolor = 3
- end
- local displayFormat = string.join("", hexa.."FPS: "..hexb, statusColors[fpscolor], "%d|r", hexa.." MS: "..hexb, statusColors[latencycolor], "%d|r")
- Text:SetFormattedText(displayFormat, framerate, latency)
- int2 = 1
- end
- end
- Stat:SetScript("OnMouseDown", function () collectgarbage("collect") Update(Stat, 20) end)
- Stat:SetScript("OnEnter", function(self)
- if InCombatLockdown() then return end
- local bandwidth = GetAvailableBandwidth()
- local _, _, latencyHome, latencyWorld = GetNetStats()
- local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
- GameTooltip:SetOwner(panel, anchor, xoff, yoff)
- GameTooltip:ClearLines()
- GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Latency")
- GameTooltip:AddLine' '
- GameTooltip:AddDoubleLine("Home Latency: ", string.format(homeLatencyString, latencyHome), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
- GameTooltip:AddDoubleLine("World Latency: ", string.format(worldLatencyString, latencyWorld), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
- if bandwidth ~= 0 then
- GameTooltip:AddDoubleLine(L.datatext_bandwidth , string.format(bandwidthString, bandwidth),0.69, 0.31, 0.31,0.84, 0.75, 0.65)
- GameTooltip:AddDoubleLine("Download: " , string.format(percentageString, GetDownloadedPercentage() *100),0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
- GameTooltip:AddLine(" ")
- end
- local totalMemory = UpdateMemory()
- GameTooltip:AddDoubleLine("Total Memory Usage:", formatMem(totalMemory), 0.69, 0.31, 0.31,0.84, 0.75, 0.65)
- GameTooltip:AddLine(" ")
- for i = 1, #memoryTable do
- if (memoryTable[i][4]) then
- local red = memoryTable[i][3] / totalMemory
- local green = 1 - red
- GameTooltip:AddDoubleLine(memoryTable[i][2], formatMem(memoryTable[i][3]), 1, 1, 1, red, green + .5, 0)
- end
- end
- GameTooltip:Show()
- end)
- Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
- Stat:SetScript("OnUpdate", Update)
- Update(Stat, 10)
- end
- end
- ----------
- -- Font --
- ----------
- function BasicUI:Font()
- local db = BasicUI.db.profile
- -- Credit Game Font goes to Elv for his ElvUI project.
- -- You can find his Addon at http://tukui.org/dl.php
- -- Editied by Cokedriver
- if db.fontEnable == true then
- local function SetFont(obj, font, size, style, r, g, b, sr, sg, sb, sox, soy)
- obj:SetFont(font, size, style)
- if sr and sg and sb then obj:SetShadowColor(sr, sg, sb) end
- if sox and soy then obj:SetShadowOffset(sox, soy) end
- if r and g and b then obj:SetTextColor(r, g, b)
- elseif r then obj:SetAlpha(r) end
- end
- local NORMAL = db.fontNormal
- local BOLD = db.fontBold
- local BOLDITALIC = db.fontBoldItalic
- local ITALIC = db.fontItalic
- local NUMBER = db.fontNormal
- UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 15
- CHAT_FONT_HEIGHTS = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
- UNIT_NAME_FONT = NORMAL
- DAMAGE_TEXT_FONT = NUMBER
- STANDARD_TEXT_FONT = NORMAL
- -- Base fonts
- SetFont(AchievementFont_Small, BOLD, db.fontSize)
- SetFont(FriendsFont_Large, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_Normal, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_Small, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_UserText, NUMBER, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(GameTooltipHeader, BOLD, db.fontSize, "OUTLINE")
- SetFont(GameFont_Gigantic, BOLD, 32, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(InvoiceFont_Med, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(InvoiceFont_Small, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(MailFont_Large, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04, 0.54, 0.4, 0.1, 1, -1)
- SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, db.fontSize, "OUTLINE")
- SetFont(NumberFont_Outline_Huge, NUMBER, 30, "THICKOUTLINE", 30)
- SetFont(NumberFont_Outline_Large, NUMBER, 17, "OUTLINE")
- SetFont(NumberFont_Outline_Med, NUMBER, db.fontSize, "OUTLINE")
- SetFont(NumberFont_Shadow_Med, NORMAL, db.fontSize)
- SetFont(NumberFont_Shadow_Small, NORMAL, db.fontSize)
- SetFont(QuestFont_Shadow_Small, NORMAL, 16)
- SetFont(QuestFont_Large, NORMAL, 16)
- SetFont(QuestFont_Shadow_Huge, BOLD, 19, nil, nil, nil, nil, 0.54, 0.4, 0.1)
- SetFont(QuestFont_Super_Huge, BOLD, 24)
- SetFont(ReputationDetailFont, BOLD, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(SpellFont_Small, BOLD, db.fontSize)
- SetFont(SystemFont_InverseShadow_Small, BOLD, db.fontSize)
- SetFont(SystemFont_Large, NORMAL, 17)
- SetFont(SystemFont_Med1, NORMAL, db.fontSize)
- SetFont(SystemFont_Med2, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(SystemFont_Med3, NORMAL, db.fontSize)
- SetFont(SystemFont_OutlineThick_Huge2, NORMAL, 22, "THICKOUTLINE")
- SetFont(SystemFont_OutlineThick_Huge4, BOLDITALIC, 27, "THICKOUTLINE")
- SetFont(SystemFont_OutlineThick_WTF, BOLDITALIC, 31, "THICKOUTLINE", nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(SystemFont_Outline_Small, NUMBER, db.fontSize, "OUTLINE")
- SetFont(SystemFont_Shadow_Huge1, BOLD, 20)
- SetFont(SystemFont_Shadow_Huge3, BOLD, 25)
- SetFont(SystemFont_Shadow_Large, NORMAL, 17)
- SetFont(SystemFont_Shadow_Med1, NORMAL, db.fontSize)
- SetFont(SystemFont_Shadow_Med2, NORMAL, db.fontSize)
- SetFont(SystemFont_Shadow_Med3, NORMAL, db.fontSize)
- SetFont(SystemFont_Shadow_Outline_Huge2, NORMAL, 22, "OUTLINE")
- SetFont(SystemFont_Shadow_Small, BOLD, db.fontSize)
- SetFont(SystemFont_Small, NORMAL, db.fontSize)
- SetFont(SystemFont_Tiny, NORMAL, db.fontSize)
- SetFont(ChatBubbleFont, NORMAL, db.fontSize)
- -- Derived fonts
- SetFont(BossEmoteNormalHuge, BOLDITALIC, 27, "THICKOUTLINE")
- SetFont(CombatTextFont, NORMAL, 26)
- SetFont(ErrorFont, ITALIC, 16, nil, 60)
- SetFont(QuestFontNormalSmall, BOLD, db.fontSize, nil, nil, nil, nil, 0.54, 0.4, 0.1)
- SetFont(WorldMapTextFont, BOLDITALIC, 31, "THICKOUTLINE", 40, nil, nil, 0, 0, 0, 1, -1)
- end
- end
- --------------
- -- Merchant --
- --------------
- function BasicUI:Merchant()
- local db = BasicUI.db.profile
- -- Credit for Merchant goes to Tuks for his Tukui project.
- -- You can find his Addon at http://tukui.org/dl.php
- -- Editied by Cokedriver
- if db.merchant.enable then
- local filter = {
- [6289] = true, -- Raw Longjaw Mud Snapper
- [6291] = true, -- Raw Brilliant Smallfish
- [6308] = true, -- Raw Bristle Whisker Catfish
- [6309] = true, -- 17 Pound Catfish
- [6310] = true, -- 19 Pound Catfish
- [41808] = true, -- Bonescale Snapper
- [42336] = true, -- Bloodstone Band
- [42337] = true, -- Sun Rock Ring
- [43244] = true, -- Crystal Citrine Necklace
- [43571] = true, -- Sewer Carp
- [43572] = true, -- Magic Eater
- }
- local f = CreateFrame("Frame")
- f:SetScript("OnEvent", function()
- if db.merchant.autoSellGrey or db.merchant.sellMisc then
- local c = 0
- for b=0,4 do
- for s=1,GetContainerNumSlots(b) do
- local l,lid = GetContainerItemLink(b, s), GetContainerItemID(b, s)
- if l and lid then
- local p = select(11, GetItemInfo(l))*select(2, GetContainerItemInfo(b, s))
- if db.merchant.autoSellGrey and select(3, GetItemInfo(l))==0 then
- UseContainerItem(b, s)
- PickupMerchantItem()
- c = c+p
- end
- if db.merchant.sellMisc and filter[ lid ] then
- UseContainerItem(b, s)
- PickupMerchantItem()
- c = c+p
- end
- end
- end
- end
- if c>0 then
- local g, s, c = math.floor(c/10000) or 0, math.floor((c%10000)/100) or 0, c%100
- DEFAULT_CHAT_FRAME:AddMessage("Your grey item's have been sold for".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r"..".",255,255,0)
- end
- end
- if not IsShiftKeyDown() then
- if CanMerchantRepair() and db.merchant.autoRepair then
- guildRepairFlag = 0
- local cost, possible = GetRepairAllCost()
- -- additional checks for guild repairs
- if (IsInGuild()) and (CanGuildBankRepair()) then
- if cost <= GetGuildBankWithdrawMoney() then
- guildRepairFlag = 1
- end
- end
- if cost>0 then
- if (possible or guildRepairFlag) then
- RepairAllItems(guildRepairFlag)
- local c = cost%100
- local s = math.floor((cost%10000)/100)
- local g = math.floor(cost/10000)
- if db.merchant.gpay == "true" and guildRepairFlag == 1 then
- DEFAULT_CHAT_FRAME:AddMessage("Your guild payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
- else
- DEFAULT_CHAT_FRAME:AddMessage("You payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
- end
- else
- DEFAULT_CHAT_FRAME:AddMessage("You don't have enough money for repair!",255,0,0)
- end
- end
- end
- end
- end)
- f:RegisterEvent("MERCHANT_SHOW")
- end
- end
- ---------------
- -- Nameplates --
- ---------------
- function BasicUI:Nameplates()
- local db = BasicUI.db.profile
- local len = string.len
- local find = string.find
- local gsub = string.gsub
- local select = select
- local tonumber = tonumber
- local UnitName = UnitName
- local UnitCastingInfo = UnitCastingInfo
- local UnitChannelInfo = UnitChannelInfo
- local borderColor = {0.47, 0.47, 0.47}
- local noThreatColor = {0, 1, 0}
- local glowTexture = 'Interface\\AddOns\\BasicUI\\Media\\NameplateNewGlow_LessGlow'
- local overlayTexture = 'Interface\\AddOns\\BasicUI\\Media\\NameplateOverlay'
- local whiteOverlay = 'Interface\\AddOns\\BasicUI\\Media\\NameplateIconOverlay'
- local f = CreateFrame('Frame', nil, UIParent)
- f.elapsed = 0
- f.elapsedLong = 0
- -- Totem data and functions
- local function TotemName(SpellID)
- local name = GetSpellInfo(SpellID)
- return name
- end
- local function TotemIcon(SpellID)
- local _, _, icon = GetSpellInfo(SpellID)
- return icon
- end
- local totemData = {
- -- Air
- [TotemName(8177)] = {TotemIcon(8177)}, -- Grounding Totem
- [TotemName(108269)] = {TotemIcon(108269)}, -- Capacitor Totem
- [TotemName(120668)] = {TotemIcon(120668)}, -- Stormlash Totem
- [TotemName(98009)] = {TotemIcon(98008)}, -- Spirit Link Totem
- -- Earth
- [TotemName(2062)] = {TotemIcon(2062)}, -- Earth Elemental Totem
- [TotemName(2484)] = {TotemIcon(2484)}, -- Earthbind Totem
- [TotemName(8143)] = {TotemIcon(8143)}, -- Tremor Totem
- -- Fire
- [TotemName(2894)] = {TotemIcon(2894)}, -- Fire Elemental Totem
- [TotemName(8190)] = {TotemIcon(8190)}, -- Magma Totem
- [TotemName(3599)] = {TotemIcon(3599)}, -- Searing Totem
- -- Water
- [TotemName(16190)] = {TotemIcon(16190)}, -- Mana Tide Totem
- [TotemName(5394)] = {TotemIcon(5394)}, -- Healing Stream Totem
- }
- -- Some general functions
- local function FormatValue(number)
- if (number >= 1e6) then
- return tonumber(format('%.1f', number/1e6))..'m'
- elseif (number >= 1e3) then
- return tonumber(format('%.1f', number/1e3))..'k'
- else
- return number
- end
- end
- local function RGBHex(r, g, b)
- if (type(r) == 'table') then
- if (r.r) then
- r, g, b = r.r, r.g, r.b
- else
- r, g, b = unpack(r)
- end
- end
- return ('|cff%02x%02x%02x'):format(r * 255, g * 255, b * 255)
- end
- -- The plate functions
- local function GetUnitReaction(r, g, b)
- if (g + b == 0) then
- return true
- end
- return false
- end
- local function GetUnitCombatStatus(r, g, b)
- if (r >= 0.98) then
- return true
- end
- return false
- end
- local function IsTarget(self)
- local targetExists = UnitExists('target')
- if (not targetExists) then
- return false
- end
- local targetName = UnitName('target')
- if (targetName == self.Name:GetText() and self:GetAlpha() >= 0.99) then
- return true
- else
- return false
- end
- end
- local function CanHaveThreat(r, g, b)
- if (r < .01 and b < .01 and g > .99) then
- return false
- elseif (r < .01 and b > .99 and g < .01) then
- return false
- elseif (r > .99 and b < .01 and g > .99) then
- return false
- elseif (r > .99 and b < .01 and g < .01) then
- return true
- else
- return true
- end
- end
- local function UpdateTotemIcon(self)
- if (totemData[self.Name:GetText()]) then
- if (not self.Icon) then
- self.Icon = CreateFrame('Frame', nil, self)
- self.Icon:EnableMouse(false)
- self.Icon:SetSize(24, 24)
- self.Icon:SetPoint('BOTTOM', self.NewName, 'TOP', 0, 1)
- end
- local icon = totemData[self.Name:GetText()]
- self.Icon:SetBackdrop({
- bgFile = icon[1],
- edgeFile = 'Interface\\Buttons\\WHITE8x8',
- tile = true, tileSize = 16, edgeSize = 18,
- insets = { top = -0, left = -0, bottom = -0, right = -0 },
- })
- local r, g, b = self.Health:GetStatusBarColor()
- self.Icon:SetBackdropBorderColor(r, g, b, 1)
- self.Icon:Show()
- else
- if (self.Icon) then
- self.Icon:SetBackdrop(nil)
- self.Icon:Hide()
- self.Icon = nil
- end
- end
- end
- local function UpdateThreatColor(self)
- local r, g, b
- local playerInfight = InCombatLockdown()
- local unitInfight = GetUnitCombatStatus(self.Name:GetTextColor())
- local lowThreat = unitInfight and playerInfight
- local isEnemy = GetUnitReaction(self.Health:GetStatusBarColor())
- if (lowThreat and not self.Glow:IsVisible() and isEnemy and db.nameplates.enableTankMode) then
- r, g, b = unpack(noThreatColor)
- self.NewGlow:SetVertexColor(r, g, b)
- if (not self.NewGlow:IsVisible()) then
- self.NewGlow:Show()
- end
- if (db.nameplates.colorNameWithThreat) then
- self.NewName:SetTextColor(r * 0.7, g * 0.7, b * 0.7)
- end
- elseif (self.Glow:IsVisible()) then
- r, g, b = self.Glow:GetVertexColor()
- self.NewGlow:SetVertexColor(r, g, b)
- if (not self.NewGlow:IsVisible()) then
- self.NewGlow:Show()
- end
- if (db.nameplates.colorNameWithThreat) then
- self.NewName:SetTextColor(r, g, b)
- end
- else
- if (self.NewGlow:IsVisible()) then
- self.NewGlow:Hide()
- if (db.nameplates.colorNameWithThreat) then
- self.NewName:SetTextColor(1, 1, 1)
- end
- end
- end
- end
- local function UpdateHealthText(self)
- local min, max = self.Health:GetMinMaxValues()
- local currentValue = self.Health:GetValue()
- local perc = (currentValue/max)*100
- if (perc >= 100 and currentValue > 5 and db.nameplates.showFullHP) then
- self.Health.Value:SetFormattedText('%s', FormatValue(currentValue))
- elseif (perc < 100 and currentValue > 5) then
- self.Health.Value:SetFormattedText('%s - %.0f%%', FormatValue(currentValue), perc-0.5)
- else
- self.Health.Value:SetText('')
- end
- end
- local function UpdateHealthColor(self)
- local r, g, b = self.Health:GetStatusBarColor()
- if (r + g == 0) then
- self.Health:SetStatusBarColor(0, 0.35, 1)
- return
- end
- end
- local function UpdateCastbarValue(self, curValue)
- local _, maxValue = self:GetMinMaxValues()
- local cast = UnitCastingInfo('target')
- local channel = UnitChannelInfo('target')
- if (self.Shield:IsShown()) then
- self.Overlay:SetVertexColor(1, 0, 1, 1)
- self.Overlay:Show()
- else
- local r, g, b = unpack(borderColor)
- self.Overlay:SetVertexColor(r, g, b, 1 )
- end
- if (channel) then
- self.CastTime:SetFormattedText('%.1fs', curValue)
- else
- self.CastTime:SetFormattedText('%.1fs', maxValue - curValue)
- end
- self.Name:SetText(cast or channel)
- end
- local function UpdateNameL(self)
- local newName = self.Name:GetText()
- if (db.nameplates.abbrevLongNames) then
- newName = (len(newName) > 20) and gsub(newName, '%s?(.[\128-\191]*)%S+%s', '%1. ') or newName
- end
- self.NewName:SetTextColor(1, 1, 1)
- if (db.nameplates.showLevel) then
- local levelText = self.Level:GetText() or ''
- local levelColor = RGBHex(self.Level:GetTextColor())
- local eliteTexture = self.EliteIcon:IsVisible()
- if (self.BossIcon:IsVisible()) then
- self.NewName:SetText('|cffff0000??|r '..newName)
- elseif (eliteTexture) then
- self.NewName:SetText('|cffffff00+|r'..levelColor..levelText..'|r '..newName)
- else
- self.NewName:SetText(levelColor..levelText..'|r '..newName)
- end
- else
- self.NewName:SetText(newName)
- end
- end
- local function UpdateEliteTexture(self)
- local r, g, b = unpack(borderColor)
- if (self.BossIcon:IsVisible() or self.EliteIcon:IsVisible()) then
- self.Overlay:SetGradientAlpha('HORIZONTAL', r, g, b, 1, 1, 1, 0, 1)
- else
- self.Overlay:SetVertexColor(r, g, b, 1)
- end
- end
- local function UpdatePlate(self)
- if (self.Level) then
- UpdateNameL(self)
- end
- if (db.nameplates.showEliteBorder) then
- UpdateEliteTexture(self)
- else
- local r, g, b = unpack(borderColor)
- self.Overlay:SetVertexColor(r, g, b, 1)
- end
- if (db.nameplates.showTotemIcon) then
- UpdateTotemIcon(self)
- end
- UpdateHealthText(self)
- UpdateHealthColor(self)
- UpdateThreatColor(self)
- self.Highlight:ClearAllPoints()
- self.Highlight:SetAllPoints(self.Health)
- if (self.Castbar:IsVisible()) then
- self.Castbar:Hide()
- end
- local r, g, b = self.Health:GetStatusBarColor()
- self.Castbar.IconOverlay:SetVertexColor(r, g, b)
- end
- local function SkinPlate(self, nameFrame)
- self.Health, self.Castbar = self:GetChildren()
- _, self.Castbar.Overlay, self.Castbar.Shield, self.Castbar.Icon = self.Castbar:GetRegions()
- self.Glow, self.Overlay, self.Highlight, self.Level, self.BossIcon, self.RaidIcon, self.EliteIcon = self:GetRegions()
- self.Name = nameFrame:GetRegions()
- -- Hide some nameplate objects
- self.Glow:SetTexCoord(0, 0, 0, 0)
- self.BossIcon:SetTexCoord(0, 0, 0, 0)
- self.EliteIcon:SetTexCoord(0, 0, 0, 0)
- self.Castbar.Shield:SetTexCoord(0, 0, 0, 0)
- self.Name:SetWidth(0.001)
- self.Level:SetWidth(0.0001)
- -- Modify the overlay
- self.Overlay:SetTexCoord(0, 1, 0, 1)
- self.Overlay:ClearAllPoints()
- self.Overlay:SetPoint('TOPRIGHT', self.Health, 35.66666667, 5.66666667)
- self.Overlay:SetPoint('BOTTOMLEFT', self.Health, -36.66666667, -5.66666667)
- --self.Overlay:SetPoint('TOPRIGHT', self.Health, 29.66666667, 4.66666667)
- --self.Overlay:SetPoint('BOTTOMLEFT', self.Health, -31.66666667, -4.66666667)
- self.Overlay:SetDrawLayer('BORDER')
- self.Overlay:SetTexture(overlayTexture)
- -- Healtbar and background
- self.Health:SetBackdrop({
- bgFile = 'Interface\\Buttons\\WHITE8x8',
- insets = { left = -1, right = -1, top = -1, bottom = -1 }
- })
- self.Health:SetBackdropColor(0, 0, 0, 0.55)
- self.Health:SetScript('OnValueChanged', function()
- UpdateHealthText(self)
- UpdateHealthColor(self)
- end)
- -- Create health value font string
- if (not self.Health.Value) then
- self.Health.Value = self.Health:CreateFontString(nil, 'OVERLAY')
- self.Health.Value:SetPoint('CENTER', self.Health, 0, 0)
- self.Health.Value:SetFont(db.fontNormal, 12)
- self.Health.Value:SetShadowOffset(1, -1)
- end
- if (not self.NewName) then
- self.NewName = self:CreateFontString(nil, 'ARTWORK')
- self.NewName:SetFont(db.fontNormal, 15, 'THINOUTLINE')
- self.NewName:SetShadowOffset(0, 0)
- -- self.NewName:SetPoint('CENTER', self.Health, 'CENTER', 0, 9)
- self.NewName:SetPoint('BOTTOM', self.Health, 'TOP', 0, 2)
- self.NewName:SetSize(110, 13)
- end
- if (not self.NewGlow) then
- self.NewGlow = self.Health:CreateTexture(nil, 'BACKGROUND')
- self.NewGlow:SetTexture(glowTexture)
- self.NewGlow:SetAllPoints(self.Overlay)
- self.NewGlow:Hide()
- end
- -- Castbar
- self.Castbar:SetBackdrop({
- bgFile = 'Interface\\Buttons\\WHITE8x8',
- insets = { left = -1, right = -1, top = -1, bottom = -1 }
- })
- self.Castbar:SetBackdropColor(0.2, 0.2, 0.2, 0.5)
- self.Castbar:ClearAllPoints()
- self.Castbar:SetPoint('TOPRIGHT', self.Health, 'BOTTOMRIGHT', 0, -9)
- self.Castbar:SetPoint('BOTTOMLEFT', self.Health, 'BOTTOMLEFT', 0, -20)
- self.Castbar:HookScript('OnValueChanged', UpdateCastbarValue)
- self.Castbar.Overlay:SetTexCoord(0, 1, 0, 1)
- self.Castbar.Overlay:SetDrawLayer('BORDER')
- self.Castbar.Overlay:SetTexture(overlayTexture)
- self.Castbar.Overlay:ClearAllPoints()
- self.Castbar.Overlay:SetPoint('TOPRIGHT', self.Castbar, 35.66666667, 5.66666667)
- self.Castbar.Overlay:SetPoint('BOTTOMLEFT', self.Castbar, -36.66666667, -5.66666667)
- -- Castbar casttime font string
- if (not self.Castbar.CastTime) then
- self.Castbar.CastTime = self.Castbar:CreateFontString(nil, 'OVERLAY')
- self.Castbar.CastTime:SetPoint('RIGHT', self.Castbar, 1.6666667, 0)
- self.Castbar.CastTime:SetFont(db.fontNormal, 16) -- , 'THINOUTLINE')
- self.Castbar.CastTime:SetTextColor(1, 1, 1)
- self.Castbar.CastTime:SetShadowOffset(1, -1)
- end
- -- Castbar castname font string
- if (not self.Castbar.Name) then
- self.Castbar.Name = self.Castbar:CreateFontString(nil, 'OVERLAY')
- self.Castbar.Name:SetPoint('LEFT', self.Castbar, 1.5, 0)
- self.Castbar.Name:SetPoint('RIGHT', self.Castbar.CastTime, 'LEFT', -6, 0)
- self.Castbar.Name:SetFont(db.fontNormal, 10)
- self.Castbar.Name:SetTextColor(1, 1, 1)
- self.Castbar.Name:SetShadowOffset(1, -1)
- self.Castbar.Name:SetJustifyH('LEFT')
- end
- -- Castbar spellicon and overlay
- self.Castbar.Icon:SetParent(self.Castbar)
- self.Castbar.Icon:ClearAllPoints()
- self.Castbar.Icon:SetPoint('BOTTOMLEFT', self.Castbar, 'BOTTOMRIGHT', 7, 3)
- self.Castbar.Icon:SetSize(24, 24)
- self.Castbar.Icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
- self.Castbar.Icon:SetDrawLayer('BACKGROUND')
- if (not self.Castbar.IconOverlay) then
- self.Castbar.IconOverlay = self.Castbar:CreateTexture(nil, 'OVERLAY')
- self.Castbar.IconOverlay:SetPoint('TOPLEFT', self.Castbar.Icon, -1, 1)
- self.Castbar.IconOverlay:SetPoint('BOTTOMRIGHT', self.Castbar.Icon, 1, -1)
- self.Castbar.IconOverlay:SetTexture(whiteOverlay)
- end
- -- Mouseover highlight
- self.Highlight:SetTexture(1, 1, 1, 0.2)
- -- Raidicons
- self.RaidIcon:ClearAllPoints()
- self.RaidIcon:SetDrawLayer('OVERLAY')
- self.RaidIcon:SetPoint('CENTER', self.Health, 'TOP', 0, 12)
- self.RaidIcon:SetSize(16, 16)
- -- Nameplates like cookies
- UpdatePlate(self)
- self:SetScript('OnUpdate', nil)
- self:SetScript('OnShow', UpdatePlate)
- self:SetScript('OnHide', function(self)
- self.Highlight:Hide()
- end)
- self:SetScript('OnUpdate', function(_, elapsed)
- f.elapsed = f.elapsed + elapsed
- if (f.elapsed >= 0.1) then
- if ((CanHaveThreat(self.Health:GetStatusBarColor()) and InCombatLockdown()) or self.NewGlow:IsShown()) then
- UpdateThreatColor(self)
- end
- if (db.nameplates.showTargetBorder) then
- if (IsTarget(self)) then
- if (not self.TargetHighlight) then
- self.TargetHighlight = self:CreateTexture(nil, 'ARTWORK')
- self.TargetHighlight:SetAllPoints(self.Overlay)
- self.TargetHighlight:SetTexture(overlayTexture)
- self.TargetHighlight:Hide()
- end
- if (not self.TargetHighlight:IsVisible()) then
- self.TargetHighlight:Show()
- end
- else
- if (self.TargetHighlight and self.TargetHighlight:IsVisible()) then
- self.TargetHighlight:Hide()
- end
- end
- end
- f.elapsed = 0
- end
- f.elapsedLong = f.elapsedLong + elapsed
- if (f.elapsedLong >= 0.49) then
- UpdateHealthColor(self)
- f.elapsedLong = 0
- end
- end)
- end
- -- Scan the worldframe for nameplates
- local numFrames = 0
- local lastUpdate = 0
- local index = 1
- f:SetScript('OnUpdate', function(self, elapsed)
- lastUpdate = lastUpdate + elapsed
- if (lastUpdate > 0.1) then
- local newNumFrames = WorldFrame:GetNumChildren()
- if (newNumFrames ~= numFrames) then
- numFrames = newNumFrames
- for i = index, numFrames do
- local frame = select(i, WorldFrame:GetChildren())
- local frameName = frame:GetName()
- if (frameName and frameName:find('NamePlate') and not frame.NewName) then
- SkinPlate(frame:GetChildren())
- index = i
- end
- end
- end
- lastUpdate = 0
- end
- end)
- end
- -----------
- -- Quest --
- -----------
- function BasicUI:Quest()
- local db = BasicUI.db.profile
- -- Credit for Quest goes to nightcracker for his ncQuest addon.
- -- You can find his addon at http://www.wowinterface.com/downloads/info14972-ncQuest.html
- -- Editied by Cokedriver
- if db.quest.enable then
- local f = CreateFrame("Frame")
- local function MostValueable()
- local bestp, besti = 0
- for i=1,GetNumQuestChoices() do
- local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i)
- local price = link and select(11, GetItemInfo(link))
- if not price then
- return
- elseif (price * (qty or 1)) > bestp then
- bestp, besti = (price * (qty or 1)), i
- end
- end
- if besti then
- local btn = _G["QuestInfoItem"..besti]
- if (btn.type == "choice") then
- btn:GetScript("OnClick")(btn)
- end
- end
- end
- f:RegisterEvent("QUEST_ITEM_UPDATE")
- f:RegisterEvent("GET_ITEM_INFO_RECEIVED")
- f:RegisterEvent("QUEST_ACCEPT_CONFIRM")
- f:RegisterEvent("QUEST_DETAIL")
- f:RegisterEvent("QUEST_COMPLETE")
- f:SetScript("OnEvent", function(self, event, ...)
- if db.quest.autocomplete ~= false then
- if (event == "QUEST_DETAIL") then
- AcceptQuest()
- CompleteQuest()
- elseif (event == "QUEST_COMPLETE") then
- if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
- GetQuestReward()
- else
- MostValueable()
- end
- elseif (event == "QUEST_ACCEPT_CONFIRM") then
- ConfirmAcceptQuest()
- end
- else
- if (event == "QUEST_COMPLETE") then
- if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
- GetQuestReward()
- else
- MostValueable()
- end
- end
- end
- end)
- end
- if db.vendor.enable then
- local timeout = CreateFrame("Frame")
- timeout:Hide()
- local f = LibStub("tekShiner").new(QuestRewardScrollChildFrame)
- f:Hide()
- f:RegisterEvent("QUEST_COMPLETE")
- f:RegisterEvent("QUEST_ITEM_UPDATE")
- f:RegisterEvent("GET_ITEM_INFO_RECEIVED")
- f:SetScript("OnEvent", function(self, ...)
- self:Hide()
- local bestp, besti = 0
- for i=1,GetNumQuestChoices() do
- local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i)
- if not link then
- timeout:Show()
- return
- end
- local price = link and select(11, GetItemInfo(link))
- if not price then return
- elseif (price * (qty or 1)) > bestp then bestp, besti = (price * (qty or 1)), i end
- end
- if besti then
- self:ClearAllPoints()
- self:SetAllPoints("QuestInfoItem"..besti.."IconTexture")
- self:Show()
- end
- end)
- local elapsed
- timeout:SetScript("OnShow", function() elapsed = 0 end)
- timeout:SetScript("OnHide", function() f:GetScript("OnEvent")(f) end)
- timeout:SetScript("OnUpdate", function(self, elap)
- elapsed = elapsed + elap
- if elapsed < 1 then return end
- self:Hide()
- end)
- if QuestInfoItem1:IsVisible() then f:GetScript("OnEvent")(f) end
- end
- end
- -----------------
- -- Velluminous --
- -----------------
- function BasicUI:Vellum()
- local db = BasicUI.db.profile
- if db.vellum.enable then
- if not TradeSkillFrame then
- print("What the fuck? Velluminous cannot initialize. BAIL! BAIL! BAIL!")
- return
- end
- local butt = CreateFrame("Button", nil, TradeSkillCreateButton, "SecureActionButtonTemplate")
- butt:SetAttribute("type", "macro")
- butt:SetAttribute("macrotext", "/click TradeSkillCreateButton\n/use item:38682")
- butt:SetText("Vellum")
- butt:SetPoint("RIGHT", TradeSkillCreateButton, "LEFT")
- butt:SetWidth(80) butt:SetHeight(22)
- -- Fonts --
- butt:SetDisabledFontObject(GameFontDisable)
- butt:SetHighlightFontObject(GameFontHighlight)
- butt:SetNormalFontObject(GameFontNormal)
- -- Textures --
- butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
- butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
- butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
- butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
- butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875)
- butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875)
- butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875)
- butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875)
- butt:GetHighlightTexture():SetBlendMode("ADD")
- local hider = CreateFrame("Frame", nil, TradeSkillCreateAllButton)
- hider:SetScript("OnShow", function() butt:Hide() end)
- hider:SetScript("OnHide", function() butt:Show() end)
- end
- end
- -------------
- -- Tooltip --
- -------------
- function BasicUI:Tooltip()
- local db = BasicUI.db.profile
- if db.tooltip.enable then
- --[[
- All Credit for Tooltip.lua goes to Neal and ballagarba.
- Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
- Edited by Cokedriver.
- ]]
- local _G = _G
- local select = select
- local format = string.format
- local UnitName = UnitName
- local UnitLevel = UnitLevel
- local UnitExists = UnitExists
- local UnitIsDead = UnitIsDead
- local UnitIsGhost = UnitIsGhost
- local UnitFactionGroup = UnitFactionGroup
- local UnitCreatureType = UnitCreatureType
- local GetQuestDifficultyColor = GetQuestDifficultyColor
- local tankIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:0:19:22:41|t'
- local healIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:20:39:1:20|t'
- local damagerIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:20:39:22:41|t'
- local symbiosis = {
- gain = {
- ['DEATHKNIGHT'] = { ['DK_BLOOD'] = 113072, ['DK_FROST'] = 113516, ['DK_UNHOLY'] = 113516, },
- ['HUNTER'] = { ['HUNTER_BM'] = 113073, ['HUNTER_MM'] = 113073, ['HUNTER_SV'] = 113073, },
- ['MAGE'] = { ['MAGE_ARCANE'] = 113074, ['MAGE_FIRE'] = 113074, ['MAGE_FROST'] = 113074, },
- ['MONK'] = { ['MONK_BREW'] = 113306, ['MONK_MIST'] = 127361, ['MONK_WIND'] = 113275, },
- ['PALADIN'] = { ['PALADIN_HOLY'] = 113269, ['PALADIN_PROT'] = 122287, ['PALADIN_RET'] = 113075, },
- ['PRIEST'] = { ['PRIEST_DISC'] = 113506, ['PRIEST_HOLY'] = 113506, ['PRIEST_SHADOW'] = 113277, },
- ['ROGUE'] = { ['ROGUE_ASS'] = 113613, ['ROGUE_COMBAT'] = 113613, ['ROGUE_SUB'] = 113613, },
- ['SHAMAN'] = { ['SHAMAN_ELE'] = 113286, ['SHAMAN_ENHANCE'] = 113286, ['SHAMAN_RESTO'] = 113289, },
- ['WARLOCK'] = { ['WARLOCK_AFFLICTION'] = 113295, ['WARLOCK_DEMO'] = 113295, ['WARLOCK_DESTRO'] = 113295, },
- ['WARRIOR'] = { ['WARRIOR_ARMS'] = 122294, ['WARRIOR_FURY'] = 122294, ['WARRIOR_PROT'] = 122286, },
- },
- grant = {
- ['DEATHKNIGHT'] = { ['DRUID_BALANCE'] = 110570, ['DRUID_FERAL'] = 122282, ['DRUID_GUARDIAN'] = 122285, ['DRUID_RESTO'] = 110575, },
- ['HUNTER'] = { ['DRUID_BALANCE'] = 110588, ['DRUID_FERAL'] = 110597, ['DRUID_GUARDIAN'] = 110600, ['DRUID_RESTO'] = 19263, },
- ['MAGE'] = { ['DRUID_BALANCE'] = 110621, ['DRUID_FERAL'] = 110693, ['DRUID_GUARDIAN'] = 110694, ['DRUID_RESTO'] = 110696, },
- ['MONK'] = { ['DRUID_BALANCE'] = 126458, ['DRUID_FERAL'] = 128844, ['DRUID_GUARDIAN'] = 126453, ['DRUID_RESTO'] = 126456, },
- ['PALADIN'] = { ['DRUID_BALANCE'] = 110698, ['DRUID_FERAL'] = 110700, ['DRUID_GUARDIAN'] = 110701, ['DRUID_RESTO'] = 122288, },
- ['PRIEST'] = { ['DRUID_BALANCE'] = 110707, ['DRUID_FERAL'] = 110715, ['DRUID_GUARDIAN'] = 110717, ['DRUID_RESTO'] = 110718, },
- ['ROGUE'] = { ['DRUID_BALANCE'] = 110788, ['DRUID_FERAL'] = 110730, ['DRUID_GUARDIAN'] = 122289, ['DRUID_RESTO'] = 110791, },
- ['SHAMAN'] = { ['DRUID_BALANCE'] = 110802, ['DRUID_FERAL'] = 110807, ['DRUID_GUARDIAN'] = 110803, ['DRUID_RESTO'] = 110806, },
- ['WARLOCK'] = { ['DRUID_BALANCE'] = 122291, ['DRUID_FERAL'] = 110810, ['DRUID_GUARDIAN'] = 122290, ['DRUID_RESTO'] = 112970, },
- ['WARRIOR'] = { ['DRUID_BALANCE'] = 122292, ['DRUID_FERAL'] = 112997, ['DRUID_GUARDIAN'] = 113002, ['DRUID_RESTO'] = 113004, },
- }
- }
- -- _G.TOOLTIP_DEFAULT_BACKGROUND_COLOR = {r = 0, g = 0, b = 0}
- -- Some tooltip changes
- if (db.tooltip.fontOutline) then
- GameTooltipHeaderText:SetFont(db.fontBold, (db.tooltip.fontSize + 2), 'THINOUTLINE')
- GameTooltipHeaderText:SetShadowOffset(0, 0)
- GameTooltipText:SetFont(db.fontNormal, (db.tooltip.fontSize), 'THINOUTLINE')
- GameTooltipText:SetShadowOffset(0, 0)
- GameTooltipTextSmall:SetFont(db.fontNormal, (db.tooltip.fontSize), 'THINOUTLINE')
- GameTooltipTextSmall:SetShadowOffset(0, 0)
- else
- GameTooltipHeaderText:SetFont(db.fontBold, (db.tooltip.fontSize + 2))
- GameTooltipText:SetFont(db.fontNormal, (db.tooltip.fontSize))
- GameTooltipTextSmall:SetFont(db.fontNormal, (db.tooltip.fontSize))
- end
- GameTooltipStatusBar:SetHeight(7)
- GameTooltipStatusBar:SetBackdrop({bgFile = 'Interface\\Buttons\\WHITE8x8'})
- GameTooltipStatusBar:SetBackdropColor(0, 1, 0, 0.3)
- function GameTooltip_UnitColor(unit)
- local r, g, b
- if (UnitIsDead(unit) or UnitIsGhost(unit) or UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
- r = 0.5
- g = 0.5
- b = 0.5
- elseif (UnitIsPlayer(unit)) then
- if (UnitIsFriend(unit, 'player')) then
- local _, class = UnitClass(unit)
- r = RAID_CLASS_COLORS[class].r
- g = RAID_CLASS_COLORS[class].g
- b = RAID_CLASS_COLORS[class].b
- elseif (not UnitIsFriend(unit, 'player')) then
- r = 1
- g = 0
- b = 0
- end
- elseif (UnitPlayerControlled(unit)) then
- if (UnitCanAttack(unit, 'player')) then
- if (not UnitCanAttack('player', unit)) then
- r = 157/255
- g = 197/255
- b = 255/255
- else
- r = 1
- g = 0
- b = 0
- end
- elseif (UnitCanAttack('player', unit)) then
- r = 1
- g = 1
- b = 0
- elseif (UnitIsPVP(unit)) then
- r = 0
- g = 1
- b = 0
- else
- r = 157/255
- g = 197/255
- b = 255/255
- end
- else
- local reaction = UnitReaction(unit, 'player')
- if (reaction) then
- r = FACTION_BAR_COLORS[reaction].r
- g = FACTION_BAR_COLORS[reaction].g
- b = FACTION_BAR_COLORS[reaction].b
- else
- r = 157/255
- g = 197/255
- b = 255/255
- end
- end
- return r, g, b
- end
- UnitSelectionColor = GameTooltip_UnitColor
- local function ApplyTooltipStyle(self)
- local bgsize, bsize
- if (self == ConsolidatedBuffsTooltip) then
- bgsize = 1
- bsize = 8
- elseif (self == FriendsTooltip) then
- FriendsTooltip:SetScale(1.1)
- bgsize = 1
- bsize = 9
- else
- bgsize = 3
- bsize = 12
- end
- self:SetBackdrop({
- bgFile = db.tooltip.background, -- 'Interface\\Tooltips\\UI-Tooltip-Background',
- edgeFile = db.tooltip.border,
- tile = true, tileSize = 16, edgeSize = 18,
- insets = {
- left = bgsize, right = bgsize, top = bgsize, bottom = bgsize
- }
- })
- end
- for _, tooltip in pairs({
- GameTooltip,
- ItemRefTooltip,
- ShoppingTooltip1,
- ShoppingTooltip2,
- ShoppingTooltip3,
- WorldMapTooltip,
- DropDownList1MenuBackdrop,
- DropDownList2MenuBackdrop,
- ConsolidatedBuffsTooltip,
- ChatMenu,
- EmoteMenu,
- LanguageMenu,
- VoiceMacroMenu,
- FriendsTooltip,
- }) do
- ApplyTooltipStyle(tooltip)
- end
- -- Itemquaility border
- if (db.tooltip.itemqualityBorderColor) then
- for _, tooltip in pairs({
- GameTooltip,
- ItemRefTooltip,
- ShoppingTooltip1,
- ShoppingTooltip2,
- ShoppingTooltip3,
- }) do
- tooltip:HookScript('OnTooltipSetItem', function(self)
- local name, item = self:GetItem()
- if (item) then
- local quality = select(3, GetItemInfo(item))
- if (quality) then
- local r, g, b = GetItemQualityColor(quality)
- self:SetBackdropBorderColor(r, g, b)
- end
- end
- end)
- tooltip:HookScript('OnTooltipCleared', function(self)
- self:SetBackdropBorderColor(1, 1, 1)
- end)
- end
- end
- -- Itemlvl (by Gsuz) - http://www.tukui.org/forums/topic.php?id=10151
- local function GetItemLevel(unit)
- local total, item = 0, 0
- for i, v in pairs({
- 'Head',
- 'Neck',
- 'Shoulder',
- 'Back',
- 'Chest',
- 'Wrist',
- 'Hands',
- 'Waist',
- 'Legs',
- 'Feet',
- 'Finger0',
- 'Finger1',
- 'Trinket0',
- 'Trinket1',
- 'MainHand',
- 'SecondaryHand',
- }) do
- local slot = GetInventoryItemLink(unit, GetInventorySlotInfo(v..'Slot'))
- if (slot ~= nil) then
- item = item + 1
- total = total + select(4, GetItemInfo(slot))
- end
- end
- if (item > 0) then
- return floor(total / item + 0.5)
- end
- return 0
- end
- -- Make sure we get a correct unit
- local function GetRealUnit(self)
- if (GetMouseFocus() and not GetMouseFocus():GetAttribute('unit') and GetMouseFocus() ~= WorldFrame) then
- return select(2, self:GetUnit())
- elseif (GetMouseFocus() and GetMouseFocus():GetAttribute('unit')) then
- return GetMouseFocus():GetAttribute('unit')
- elseif (select(2, self:GetUnit())) then
- return select(2, self:GetUnit())
- else
- return 'mouseover'
- end
- end
- local function GetFormattedUnitType(unit)
- local creaturetype = UnitCreatureType(unit)
- if (creaturetype) then
- return creaturetype
- else
- return ''
- end
- end
- local function GetFormattedUnitClassification(unit)
- local class = UnitClassification(unit)
- if (class == 'worldboss') then
- return '|cffFF0000'..BOSS..'|r '
- elseif (class == 'rareelite') then
- return '|cffFF66CCRare|r |cffFFFF00'..ELITE..'|r '
- elseif (class == 'rare') then
- return '|cffFF66CCRare|r '
- elseif (class == 'elite') then
- return '|cffFFFF00'..ELITE..'|r '
- else
- return ''
- end
- end
- local function GetFormattedUnitLevel(unit)
- local diff = GetQuestDifficultyColor(UnitLevel(unit))
- if (UnitLevel(unit) == -1) then
- return '|cffff0000??|r '
- elseif (UnitLevel(unit) == 0) then
- return '? '
- else
- return format('|cff%02x%02x%02x%s|r ', diff.r*255, diff.g*255, diff.b*255, UnitLevel(unit))
- end
- end
- local function GetFormattedUnitClass(unit)
- local color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
- if (color) then
- return format(' |cff%02x%02x%02x%s|r', color.r*255, color.g*255, color.b*255, UnitClass(unit))
- end
- end
- local function GetFormattedUnitString(unit, specIcon)
- if (UnitIsPlayer(unit)) then
- if (not UnitRace(unit)) then
- return nil
- end
- return GetFormattedUnitLevel(unit)..UnitRace(unit)..GetFormattedUnitClass(unit)..(db.tooltip.showSpecializationIcon and specIcon or '')
- else
- return GetFormattedUnitLevel(unit)..GetFormattedUnitClassification(unit)..GetFormattedUnitType(unit)
- end
- end
- local function GetUnitRoleString(unit)
- local role = UnitGroupRolesAssigned(unit)
- local roleList = nil
- if (role == 'TANK') then
- roleList = ' '..tankIcon..' '..TANK
- elseif (role == 'HEALER') then
- roleList = ' '..healIcon..' '..HEALER
- elseif (role == 'DAMAGER') then
- roleList = ' '..damagerIcon..' '..DAMAGER
- end
- return roleList
- end
- -- Healthbar coloring funtion
- local function SetHealthBarColor(unit)
- local r, g, b
- if (db.tooltip.healthbar.custom.apply and not db.tooltip.healthbar.reactionColoring) then
- r, g, b = db.tooltip.healthbar.custom.color.r, db.tooltip.healthbar.custom.color.g, db.tooltip.healthbar.custom.color.b
- elseif (db.tooltip.healthbar.reactionColoring and unit) then
- r, g, b = UnitSelectionColor(unit)
- else
- r, g, b = 0, 1, 0
- end
- GameTooltipStatusBar:SetStatusBarColor(r, g, b)
- GameTooltipStatusBar:SetBackdropColor(r, g, b, 0.3)
- end
- local function GetUnitRaidIcon(unit)
- local index = GetRaidTargetIndex(unit)
- if (index) then
- if (UnitIsPVP(unit) and db.tooltip.showPVPIcons) then
- return ICON_LIST[index]..'11|t'
- else
- return ICON_LIST[index]..'11|t '
- end
- else
- return ''
- end
- end
- local function GetUnitPVPIcon(unit)
- local factionGroup = UnitFactionGroup(unit)
- if (UnitIsPVPFreeForAll(unit)) then
- if (db.tooltip.showPVPIcons) then
- return '|TInterface\\AddOns\\MyCore\\Media\\UI-PVP-FFA:12|t'
- else
- return '|cffFF0000# |r'
- end
- elseif (factionGroup and UnitIsPVP(unit)) then
- if (db.tooltip.showPVPIcons) then
- return '|TInterface\\AddOns\\MyCore\\Media\\UI-PVP-'..factionGroup..':12|t'
- else
- return '|cff00FF00# |r'
- end
- else
- return ''
- end
- end
- local function AddMouseoverTarget(self, unit)
- local unitTargetName = UnitName(unit..'target')
- local unitTargetClassColor = RAID_CLASS_COLORS[select(2, UnitClass(unit..'target'))] or { r = 1, g = 0, b = 1 }
- local unitTargetReactionColor = {
- r = select(1, UnitSelectionColor(unit..'target')),
- g = select(2, UnitSelectionColor(unit..'target')),
- b = select(3, UnitSelectionColor(unit..'target'))
- }
- if (UnitExists(unit..'target')) then
- if (UnitName('player') == unitTargetName) then
- self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cffff00ff%s|r', string.upper("** YOU **")), 1, 1, 1)
- else
- if (UnitIsPlayer(unit..'target')) then
- self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cff%02x%02x%02x%s|r', unitTargetClassColor.r*255, unitTargetClassColor.g*255, unitTargetClassColor.b*255, unitTargetName:sub(1, 40)), 1, 1, 1)
- else
- self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cff%02x%02x%02x%s|r', unitTargetReactionColor.r*255, unitTargetReactionColor.g*255, unitTargetReactionColor.b*255, unitTargetName:sub(1, 40)), 1, 1, 1)
- end
- end
- end
- end
- GameTooltip.inspectCache = {}
- GameTooltip:HookScript('OnTooltipSetUnit', function(self, ...)
- local unit = GetRealUnit(self)
- if (db.tooltip.hideInCombat and InCombatLockdown()) then
- self:Hide()
- return
- end
- if (UnitExists(unit) and UnitName(unit) ~= UNKNOWN) then
- local ilvl = 0
- local specIcon = ''
- local lastUpdate = 30
- for index, _ in pairs(self.inspectCache) do
- local inspectCache = self.inspectCache[index]
- if (inspectCache.GUID == UnitGUID(unit)) then
- ilvl = inspectCache.itemLevel or 0
- specIcon = inspectCache.specIcon or ''
- lastUpdate = inspectCache.lastUpdate and math.abs(inspectCache.lastUpdate - math.floor(GetTime())) or 30
- end
- end
- -- Fetch inspect information (ilvl and spec)
- if (unit and CanInspect(unit)) then
- if (not self.inspectRefresh and lastUpdate >= 30 and not self.blockInspectRequests) then
- if (not self.blockInspectRequests) then
- self.inspectRequestSent = true
- NotifyInspect(unit)
- end
- end
- end
- self.inspectRefresh = false
- local name, realm = UnitName(unit)
- -- Hide player titles
- if (db.tooltip.showPlayerTitles) then
- if (UnitPVPName(unit)) then
- name = UnitPVPName(unit)
- end
- end
- GameTooltipTextLeft1:SetText(name)
- -- Color guildnames
- if (GetGuildInfo(unit)) then
- if (GetGuildInfo(unit) == GetGuildInfo('player') and IsInGuild('player')) then
- GameTooltipTextLeft2:SetText('|cffFF66CC'..GameTooltipTextLeft2:GetText()..'|r')
- end
- end
- -- Tooltip level text
- for i = 2, GameTooltip:NumLines() do
- if (_G['GameTooltipTextLeft'..i]:GetText():find('^'..TOOLTIP_UNIT_LEVEL:gsub('%%s', '.+'))) then
- _G['GameTooltipTextLeft'..i]:SetText(GetFormattedUnitString(unit, specIcon))
- end
- end
- -- Role text
- if (db.tooltip.showUnitRole) then
- self:AddLine(GetUnitRoleString(unit), 1, 1, 1)
- end
- -- Mouse over target with raidicon support
- if (db.tooltip.showMouseoverTarget) then
- AddMouseoverTarget(self, unit)
- end
- -- Pvp flag prefix
- for i = 3, GameTooltip:NumLines() do
- if (_G['GameTooltipTextLeft'..i]:GetText():find(PVP_ENABLED)) then
- _G['GameTooltipTextLeft'..i]:SetText(nil)
- GameTooltipTextLeft1:SetText(GetUnitPVPIcon(unit)..GameTooltipTextLeft1:GetText())
- end
- end
- -- Raid icon, want to see the raidicon on the left
- GameTooltipTextLeft1:SetText(GetUnitRaidIcon(unit)..GameTooltipTextLeft1:GetText())
- -- Afk and dnd prefix
- if (UnitIsAFK(unit)) then
- self:AppendText('|cff00ff00 <AFK>|r')
- elseif (UnitIsDND(unit)) then
- self:AppendText('|cff00ff00 <DND>|r')
- end
- -- Player realm names
- if (realm and realm ~= '') then
- if (db.tooltip.abbrevRealmNames) then
- self:AppendText(' (*)')
- else
- self:AppendText(' - '..realm)
- end
- end
- -- Move the healthbar inside the tooltip
- self:AddLine(' ')
- GameTooltipStatusBar:ClearAllPoints()
- GameTooltipStatusBar:SetPoint('LEFT', self:GetName()..'TextLeft'..self:NumLines(), 1, -3)
- GameTooltipStatusBar:SetPoint('RIGHT', self, -10, 0)
- -- Border coloring
- if (db.tooltip.reactionBorderColor) then
- local r, g, b = UnitSelectionColor(unit)
- self:SetBackdropBorderColor(r, g, b)
- end
- -- Dead or ghost recoloring
- if (UnitIsDead(unit) or UnitIsGhost(unit)) then
- GameTooltipStatusBar:SetBackdropColor(0.5, 0.5, 0.5, 0.3)
- else
- if (not db.tooltip.healthbar.custom.apply and not db.tooltip.healthbar.reactionColoring) then
- GameTooltipStatusBar:SetBackdropColor(27/255, 243/255, 27/255, 0.3)
- else
- SetHealthBarColor(unit)
- end
- end
- -- Custom healthbar coloring
- if (db.tooltip.healthbar.reactionColoring or db.tooltip.healthbar.custom.apply) then
- GameTooltipStatusBar:HookScript('OnValueChanged', function()
- SetHealthBarColor(unit)
- end)
- end
- -- Show player item lvl
- if (db.tooltip.showItemLevel and ilvl > 1) then
- GameTooltip:AddLine(STAT_AVERAGE_ITEM_LEVEL .. ': ' .. '|cffFFFFFF'..ilvl..'|r')
- end
- -- Symbiosis
- if (UnitIsPlayer(unit) and not UnitIsEnemy(unit, 'player')) then
- local hasSymbiosisBuff = false
- for i = 1, 40 do
- if select(11, UnitAura(unit, i, 'HELPFUL')) == 110309 then
- hasSymbiosisBuff = true
- break
- end
- end
- local _, playerClass = UnitClass('player')
- local _, unitClass = UnitClass(unit)
- local spec = SPEC_CORE_ABILITY_TEXT[GetSpecializationInfo(GetSpecialization() or 1)]
- local spellID = (playerClass == 'DRUID' and unitClass ~= 'DRUID') and symbiosis.grant[unitClass][spec] or (playerClass ~= 'DRUID' and unitClass == 'DRUID') and symbiosis.grant[playerClass][spec]
- local name, _, icon = GetSpellInfo(spellID)
- if (hasSymbiosisBuff) then
- GameTooltip:AddLine(' ')
- GameTooltip:AddLine('|cff3eea23'..GetSpellInfo(110309)..' already buffed|r')
- end
- if (icon) then
- GameTooltip:AddLine(' ')
- GameTooltip:AddDoubleLine('|T'..icon..':16:16:0:0:64:64:4:60:4:60|t '..name, '|cff3eea23'..GetSpellInfo(110309)..'|r')
- end
- end
- end
- end)
- GameTooltip:HookScript('OnTooltipCleared', function(self)
- GameTooltipStatusBar:ClearAllPoints()
- GameTooltipStatusBar:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', 0.5, 3)
- GameTooltipStatusBar:SetPoint('BOTTOMRIGHT', self, 'TOPRIGHT', -1, 3)
- GameTooltipStatusBar:SetBackdropColor(0, 1, 0, 0.3)
- if (db.tooltip.reactionBorderColor) then
- self:SetBackdropColor(1, 1, 1)
- end
- end)
- -- Hide coalesced/interactive realm information
- if (db.tooltip.hideRealmText) then
- local COALESCED_REALM_TOOLTIP1 = string.split(FOREIGN_SERVER_LABEL, COALESCED_REALM_TOOLTIP)
- local INTERACTIVE_REALM_TOOLTIP1 = string.split(INTERACTIVE_SERVER_LABEL, INTERACTIVE_REALM_TOOLTIP)
- -- Dirty checking of the coalesced realm text because it's added
- -- after the initial OnShow
- GameTooltip:HookScript('OnUpdate', function(self)
- for i = 3, self:NumLines() do
- local row = _G['GameTooltipTextLeft'..i]
- local rowText = row:GetText()
- if (rowText) then
- if (rowText:find(COALESCED_REALM_TOOLTIP1) or rowText:find(INTERACTIVE_REALM_TOOLTIP1)) then
- row:SetText(nil)
- row:Hide()
- local previousRow = _G['GameTooltipTextLeft'..(i - 1)]
- previousRow:SetText(nil)
- previousRow:Hide()
- self:Show()
- end
- end
- end
- end)
- end
- hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self, parent)
- if (db.tooltip.showOnMouseover) then
- self:SetOwner(parent, 'ANCHOR_CURSOR')
- end
- end)
- GameTooltip:RegisterEvent('INSPECT_READY')
- GameTooltip:SetScript('OnEvent', function(self, event, GUID)
- if (not self:IsShown()) then
- return
- end
- local _, unit = self:GetUnit()
- if (not unit) then
- return
- end
- if (self.blockInspectRequests) then
- self.inspectRequestSent = false
- end
- if (UnitGUID(unit) ~= GUID or not self.inspectRequestSent) then
- if (not self.blockInspectRequests) then
- ClearInspectPlayer()
- end
- return
- end
- local _, _, _, icon = GetSpecializationInfoByID(GetInspectSpecialization(unit))
- local ilvl = GetItemLevel(unit)
- local now = GetTime()
- local matchFound
- for index, _ in pairs(self.inspectCache) do
- local inspectCache = self.inspectCache[index]
- if (inspectCache.GUID == GUID) then
- inspectCache.itemLevel = ilvl
- inspectCache.specIcon = icon and ' |T'..icon..':0|t' or ''
- inspectCache.lastUpdate = math.floor(now)
- matchFound = true
- end
- end
- if not matchFound then
- local GUIDInfo = {
- ['GUID'] = GUID,
- ['itemLevel'] = ilvl,
- ['specIcon'] = icon and ' |T'..icon..':0|t' or '',
- ['lastUpdate'] = math.floor(now)
- }
- table.insert(self.inspectCache, GUIDInfo)
- end
- if (#self.inspectCache > 30) then
- table.remove(self.inspectCache, 1)
- end
- self.inspectRefresh = true
- GameTooltip:SetUnit('mouseover')
- if (not self.blockInspectRequests) then
- ClearInspectPlayer()
- end
- self.inspectRequestSent = false
- end)
- local f = CreateFrame('Frame')
- f:RegisterEvent('ADDON_LOADED')
- f:SetScript('OnEvent', function(self, event)
- if IsAddOnLoaded('Blizzard_InspectUI') then
- hooksecurefunc('InspectFrame_Show', function(unit)
- GameTooltip.blockInspectRequests = true
- end)
- InspectFrame:HookScript('OnHide', function()
- GameTooltip.blockInspectRequests = false
- end)
- self:UnregisterEvent('ADDON_LOADED')
- end
- end)
- local select = select
- local tonumber = tonumber
- local modf = math.modf
- local gsub = string.gsub
- local format = string.format
- local bar = GameTooltipStatusBar
- bar.Text = bar:CreateFontString(nil, 'OVERLAY')
- bar.Text:SetPoint('CENTER', bar, db.tooltip.healthbar.textPos, 0, 1)
- if (db.tooltip.healthbar.showOutline) then
- bar.Text:SetFont(db.fontNormal, db.tooltip.healthbar.fontSize, 'THINOUTLINE')
- bar.Text:SetShadowOffset(0, 0)
- else
- bar.Text:SetFont(db.fontNormal, db.tooltip.healthbar.fontSize)
- bar.Text:SetShadowOffset(1, -1)
- end
- local function ColorGradient(perc, ...)
- if (perc >= 1) then
- local r, g, b = select(select('#', ...) - 2, ...)
- return r, g, b
- elseif (perc <= 0) then
- local r, g, b = ...
- return r, g, b
- end
- local num = select('#', ...) / 3
- local segment, relperc = modf(perc*(num-1))
- local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
- return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
- end
- local function FormatValue(value)
- if (value >= 1e6) then
- return tonumber(format('%.1f', value/1e6))..'m'
- elseif (value >= 1e3) then
- return tonumber(format('%.1f', value/1e3))..'k'
- else
- return value
- end
- end
- local function DeficitValue(value)
- if (value == 0) then
- return ''
- else
- return '-'..FormatValue(value)
- end
- end
- local function GetHealthTag(text, cur, max)
- local perc = format('%d', (cur/max)*100)
- if (max == 1) then
- return perc
- end
- local r, g, b = ColorGradient(cur/max, 1, 0, 0, 1, 1, 0, 0, 1, 0)
- text = gsub(text, '$cur', format('%s', FormatValue(cur)))
- text = gsub(text, '$max', format('%s', FormatValue(max)))
- text = gsub(text, '$deficit', format('%s', DeficitValue(max-cur)))
- text = gsub(text, '$perc', format('%d', perc)..'%%')
- text = gsub(text, '$smartperc', format('%d', perc))
- text = gsub(text, '$smartcolorperc', format('|cff%02x%02x%02x%d|r', r*255, g*255, b*255, perc))
- text = gsub(text, '$colorperc', format('|cff%02x%02x%02x%d', r*255, g*255, b*255, perc)..'%%|r')
- return text
- end
- GameTooltipStatusBar:HookScript('OnValueChanged', function(self, value)
- if (self.Text) then
- self.Text:SetText('')
- end
- if (not value) then
- return
- end
- local min, max = self:GetMinMaxValues()
- if ((value < min) or (value > max) or (value == 0) or (value == 1)) then
- return
- end
- if (not self.Text) then
- CreateHealthString(self)
- end
- local fullString = GetHealthTag(db.tooltip.healthbar.healthFullFormat, value, max)
- local normalString = GetHealthTag(db.tooltip.healthbar.healthFormat, value, max)
- local perc = (value/max)*100
- if (perc >= 100 and currentValue ~= 1) then
- self.Text:SetText(fullString)
- elseif (perc < 100 and currentValue ~= 1) then
- self.Text:SetText(normalString)
- else
- self.Text:SetText('')
- end
- end)
- local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
- local watchFrame = _G['WatchFrame']
- watchFrame:SetHeight(400)
- watchFrame:ClearAllPoints()
- watchFrame.ClearAllPoints = function() end
- watchFrame:SetPoint('TOPRIGHT', UIParent, -100, -250)
- watchFrame:SetClampedToScreen(true)
- watchFrame:SetMovable(true)
- watchFrame:SetUserPlaced(true)
- watchFrame.SetPoint = function() end
- watchFrame:SetScale(1.01)
- local watchHead = _G['WatchFrameHeader']
- watchHead:EnableMouse(true)
- watchHead:RegisterForDrag('LeftButton')
- watchHead:SetHitRectInsets(-15, 0, -5, -5)
- watchHead:SetScript('OnDragStart', function(self)
- if (IsShiftKeyDown()) then
- self:GetParent():StartMoving()
- end
- end)
- watchHead:SetScript('OnDragStop', function(self)
- self:GetParent():StopMovingOrSizing()
- end)
- watchHead:SetScript('OnEnter', function()
- if InCombatLockdown() then return end
- GameTooltip:SetOwner(watchHead, "ANCHOR_TOPLEFT")
- GameTooltip:ClearLines()
- GameTooltip:AddLine("|cffeda55fShift+Left Click|r to Drag")
- GameTooltip:Show()
- end)
- watchHead:SetScript('OnLeave', function() GameTooltip:Hide() end)
- local watchHeadTitle = _G['WatchFrameTitle']
- watchHeadTitle:SetFont(db.fontBold, 15)
- if db.classcolor == true then
- watchHeadTitle:SetTextColor(ccolor.r, ccolor.g, ccolor.b)
- end
- end
- end
- ----------------
- -- Unitframes --
- ----------------
- function BasicUI:Unitframes()
- local db = BasicUI.db.profile
- if db.unitframes.enable then
- -- Player Frame
- if db.unitframes.player.enable then
- if PlayerFrame then
- PlayerFrame:SetScale(db.unitframes.player.scale);
- PlayerFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize,"THINOUTLINE");
- PlayerFrameManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize, "THINOUTLINE");
- PlayerFrameAlternateManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize, "THINOUTLINE");
- PetFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.player.fontSizepet,"THINOUTLINE");
- PetFrameManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSizepet, "THINOUTLINE");
- end
- end
- -- Target Frame
- if db.unitframes.target.enable then
- if TargetFrame then
- TargetFrame:SetScale(db.unitframes.target.scale);
- TargetFrameTextureFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.target.fontSize, "THINOUTLINE");
- TargetFrameTextureFrameManaBarText:SetFont(db.fontNormal, db.unitframes.target.fontSize, "THINOUTLINE");
- end;
- end;
- -- Focus Frame
- if db.unitframes.focus.enable then
- if FocusFrame then
- FocusFrame:SetScale(db.unitframes.focus.scale)
- FocusFrameTextureFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.focus.fontSize,"THINOUTLINE")
- FocusFrameTextureFrameManaBarText:SetFont(db.fontNormal, db.unitframes.focus.fontSize,"THINOUTLINE")
- end;
- end;
- -- Party Frames --
- if db.unitframes.party.enable then
- for i = 1, MAX_PARTY_MEMBERS do
- local partyFrame = "PartyMemberFrame"..i
- _G[partyFrame]:SetScale(db.unitframes.party.scale);
- _G[partyFrame.."HealthBarText"]:SetFont(db.fontNormal, db.unitframes.party.fontSize, "THINOUTLINE");
- _G[partyFrame.."ManaBarText"]:SetFont(db.fontNormal, db.unitframes.party.fontSize, "THINOUTLINE");
- end
- end;
- -- Arena Frames
- if db.unitframes.arena.enable then
- hooksecurefunc("Arena_LoadUI", function()
- for i = 1, MAX_ARENA_ENEMIES do
- arenaFrame = "ArenaEnemyFrame"..i
- _G[arenaFrame]:SetScale(db.unitframes.arena.scale);
- _G[arenaFrame.."HealthBarText"]:SetFont(db.fontNormal, db.unitframes.arena.fontSize,"THINOUTLINE");
- _G[arenaFrame.."ManaBarText"]:SetFont(db.fontNormal, db.unitframes.arena.fontSize, "THINOUTLINE");
- end
- end)
- end;
- -- Boss Frames
- if db.unitframes.boss.enable then
- for i = 1, MAX_BOSS_FRAMES do
- local bossFrame = "Boss"..i.."TargetFrame"
- _G[bossFrame]:SetScale(db.unitframes.boss.scale);
- end;
- end;
- -- Font Style / Color thanks to Phanx from WoWinterface.
- -- Font Style
- local shorts = {
- { 1e10, 1e9, "%.0fB" }, -- 10b+ as 12b
- { 1e9, 1e9, "%.1fB" }, -- 1b+ as 8.3b
- { 1e7, 1e6, "%.0fM" }, -- 10m+ as 14m
- { 1e6, 1e6, "%.1fM" }, -- 1m+ as 7.4m
- { 1e5, 1e3, "%.0fK" }, -- 100k+ as 840k
- { 1e3, 1e3, "%.1fK" }, -- 1k+ as 2.5k
- { 0, 1, "%d" }, -- < 1k as 974
- }
- for i = 1, #shorts do
- shorts[i][4] = shorts[i][3] .. " (%.0f%%)"
- end
- hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax)
- if value == 0 then
- return fontString:SetText("")
- end
- local style = GetCVar("statusTextDisplay")
- if style == "PERCENT" then
- return fontString:SetFormattedText("%.0f%%", value / valueMax * 100)
- end
- for i = 1, #shorts do
- local t = shorts[i]
- if value >= t[1] then
- if style == "BOTH" then
- return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100)
- else
- if value < valueMax then
- for j = 1, #shorts do
- local v = shorts[j]
- if valueMax >= v[1] then
- return fontString:SetFormattedText(t[3] .. " / " .. v[3], value / t[2], valueMax / v[2])
- end
- end
- end
- return fontString:SetFormattedText(t[3], value / t[2])
- end
- end
- end
- end)
- -- Font Color
- hooksecurefunc("UnitFrame_Update", function(self)
- if not self.name then return end
- local PET_COLOR = { r = 157/255, g = 197/255, b = 255/255 }
- local unit, color = self.unit
- if UnitPlayerControlled(unit) then
- if UnitIsPlayer(unit) then
- local _, class = UnitClass(unit)
- color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
- else
- color = PET_COLOR
- end
- elseif UnitIsDead(unit) or UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) then
- color = GRAY_FONT_COLOR
- else
- color = FACTION_BAR_COLORS[UnitIsEnemy(unit, "player") and 1 or UnitReaction(unit, "player") or 5]
- end
- if not color then
- color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)["PRIEST"]
- end
- self.name:SetTextColor(color.r, color.g, color.b)
- end)
- local frame = CreateFrame("FRAME")
- frame:RegisterEvent("GROUP_ROSTER_UPDATE")
- frame:RegisterEvent("PLAYER_TARGET_CHANGED")
- frame:RegisterEvent("PLAYER_FOCUS_CHANGED")
- frame:RegisterEvent("UNIT_FACTION")
- local unitRegions = {
- target = TargetFrameNameBackground,
- focus = FocusFrameNameBackground,
- boss1 = Boss1TargetFrameNameBackground,
- boss2 = Boss2TargetFrameNameBackground,
- boss3 = Boss3TargetFrameNameBackground,
- boss4 = Boss4TargetFrameNameBackground,
- }
- frame:SetScript("OnEvent", function(self, event, ...)
- for unit, region in pairs(unitRegions) do
- if UnitIsPlayer(unit) then
- region:SetTexture('Interface\\DialogFrame\\UI-DialogBox-Background')
- end
- end
- end)
- -- Disable healing/damage spam over player/pet frame:
- PlayerHitIndicator:SetText(nil)
- PlayerHitIndicator.SetText = function() end
- PetHitIndicator:SetText(nil)
- PetHitIndicator.SetText = function() end
- end
- end
Add Comment
Please, Sign In to add comment