/
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Script file="Libs\LibStub\LibStub.lua"/> |
<Include file="Libs\CallBackHandler-1.0\CallbackHandler-1.0.xml" /> |
<Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/> |
<Include file="Libs\AceComm-3.0\AceComm-3.0.xml"/> |
<Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml"/> |
<Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml"/> |
<Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/> |
<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/> |
<Include file="Libs\AceEvent-3.0\AceEvent-3.0.xml"/> |
<Include file="Libs\AceDBOptions-3.0\AceDBOptions-3.0.xml"/> |
<Include file="Libs\AceLocale-3.0\AceLocale-3.0.xml"/> |
<Include file="Libs\LibFuBarPlugin-3.0\lib.xml"/> |
</Ui> |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Script file="Locale\Locale-enUS.lua"/> |
</Ui> |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/FrameXML/UI.xsd"> |
<Script file="BattleBar.lua" /> |
<Script file="Gui.lua" /> |
<Script file="Config.lua" /> |
</Ui> |
BB_VERSION = "0.3b"; |
-- Define the ADDON |
BB = LibStub("AceAddon-3.0"):NewAddon("BattleBar", "AceConsole-3.0", "AceEvent-3.0"); |
LibStub("AceAddon-3.0"):EmbedLibrary(BB, "LibFuBarPlugin-3.0", true) |
-- Define the Locale |
local L = LibStub("AceLocale-3.0"):GetLocale("BattleBar"); |
-- Database Support |
local AceDB = LibStub("AceDB-3.0"); |
-- Config Support |
local AceConfig = LibStub("AceConfigDialog-3.0"); |
--------------------------- Debug Functions ------------------------------ |
function BB:DebugData(lots) |
BB.State.Scoreboard = {} |
BB.State.InBattleground = true; |
if (lots == true) then |
BB.State.Scoreboard[1] = { Name = "Narusegawa", Class = "Hunter", Faction = "Alliance", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[2] = { Name = "Voorije", Class = "Shaman", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[3] = { Name = "Deity", Class = "Warrior", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[4] = { Name = "Kasper", Class = "Mage", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[5] = { Name = "Moorije", Class = "Druid", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[6] = { Name = "Evriya", Class = "Warlock", Faction = "Alliance", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[7] = { Name = "Tiesto", Class = "Paladin", Faction = "Alliance", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[8] = { Name = "Speeb", Class = "Priest", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[9] = { Name = "Miriya", Class = "Rogue", Faction = "Alliance", KBS = "23", Dmg = "2353", Heal = "134" } |
else |
BB.State.Scoreboard[1] = { Name = "Narusegawa", Class = "Hunter", Faction = "Alliance", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[2] = { Name = "Voorije", Class = "Shaman", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
BB.State.Scoreboard[3] = { Name = "Deity", Class = "Warrior", Faction = "Horde", KBS = "23", Dmg = "2353", Heal = "134" } |
end |
end |
function BB:Debug(message) |
if (BB.db.profile.debug == true) then |
BB:Print("DEBUG: "..message); |
end |
end |
--------------------------- Basic Addon Functionality ---------------------------------- |
function BB:OnInitialize() |
BB.db = AceDB:New("BB_Vars"); |
BB.db:RegisterDefaults({ |
profile = { |
debug = false, |
hidden = false, |
faction = "both", |
sortMode = "kbs", |
behaviour = { |
hideMode = false, |
rolloverMode = false |
}, |
gui = { |
showSelf = true, |
showCount = 10 |
} |
} |
}); |
-- State Variables |
BB.State = { |
InQueue = false, |
InBattleground = false, |
CurrentBattleground = "", |
Scoreboard = {}, |
Rollover = false |
} |
-- Initial Variables |
BB.TimeSinceLastUpdate = 0; |
BB.TimeSinceLastCheck = 0; |
BB.UpdateInterval = 1; |
BB.CheckInterval = 5; |
-- FuBar Settings |
if LibStub:GetLibrary("LibFuBarPlugin-Mod-3.0", true) then |
-- Create the FuBarPlugin bits. |
self:SetFuBarOption("GameTooltip", true) |
self:SetFuBarOption("hasNoColor", true) |
self:SetFuBarOption("cannotDetachTooltip", true) |
self:SetFuBarOption("hideWithoutStandby", true) |
self:SetFuBarOption("cannotDetachTooltip", true) |
--self:SetFuBarOption("iconPath", "Interface\\AddOns\\MicroManager\\Icon") |
end |
-- Initialize the GUI |
BB:Gui_Init(); |
-- Register Events |
BB:RegisterEvent("PLAYER_LOGIN"); |
BB:RegisterEvent("PLAYER_ENTERING_WORLD"); -- For Checking Enter/Exit Battleground |
BB:RegisterEvent("ZONE_CHANGED_NEW_AREA"); -- For Checking Enter/Exit Battleground |
BB:RegisterEvent("UPDATE_WORLD_STATES"); -- For Parsing Battlfield Score |
BB:RegisterEvent("UPDATE_BATTLEFIELD_SCORE"); -- For Parsing Battlefield Score |
end |
function BB:OnEnable() |
self:Print("Loaded [ v"..BB_VERSION.." ]"); |
BB:Gui_Update(); |
end |
function BB:OnDisable() |
end |
function BB:OnUpdate(elapsed) |
BB.TimeSinceLastCheck = BB.TimeSinceLastCheck + elapsed; |
-- Periodically Check to see if we're in the BG's |
if (BB.TimeSinceLastCheck > BB.CheckInterval) then |
BB:BattlegroundCheck() |
BB:Gui_Update() |
BB.TimeSinceLastCheck = 0; |
end |
-- Update our info |
if (BB.State.InBattleground) then |
BB.TimeSinceLastUpdate = BB.TimeSinceLastUpdate + elapsed; |
if (BB.TimeSinceLastUpdate > BB.UpdateInterval) then |
BB:UpdateInfo(); |
BB.TimeSinceLastUpdate = 0; |
end |
end |
end |
--------------------------- FuBar Plugin --------------------------------------------------- |
function BB:OnUpdateFuBarText() |
self:SetFuBarText("Battle Bar"); |
end |
function BB:OnUpdateFuBarTooltip() |
GameTooltip:AddLine("Battle Bar"); |
GameTooltip:AddLine("Left Click - Open Config."); |
GameTooltip:AddLine("Shift & Left Click - Toggle Main Window."); |
end |
function BB:OnFuBarClick(button) |
if (button == "LeftButton") then |
if (IsShiftKeyDown()) then |
BB:ToggleDialog(); |
else |
BB:ShowConfig(); |
end |
end |
end |
--------------------------- Event Handling ------------------------------------------------ |
function BB:PLAYER_LOGIN() |
BB:BattlegroundCheck() |
BB:Gui_Update(); |
end |
function BB:PLAYER_ENTERING_WORLD() |
BB:BattlegroundCheck() |
BB:Gui_Update(); |
end |
function BB:ZONE_CHANGED_NEW_AREA() |
BB:BattlegroundCheck() |
BB:Gui_Update(); |
end |
function BB:UPDATE_WORLD_STATES() |
BB:UpdateInfo() |
end |
function BB:UPDATE_BATTLEFIELD_SCORE() |
BB:UpdateInfo() |
end |
function BB:ToggleDialog() |
if (BB.db.profile.hidden == true) then |
BB:Print("Now Visible"); |
BB.db.profile.hidden = false |
else |
BB.db.profile.hidden = true |
BB:Print("Now Hidden"); |
end |
BB:Gui_Update(); |
end |
--------------------------- Logic Functions ----------------------------------------------- |
local ClassConvert = |
{ |
DRUID = "Druid", |
MAGE = "Mage", |
HUNTER = "Hunter", |
PRIEST = "Priest", |
PALADIN = "Paladin", |
ROGUE = "Rogue", |
SHAMAN = "Shaman", |
WARLOCK = "Warlock", |
WARRIOR = "Warrior" |
} |
local FactionConvert = |
{ |
[0] = "Horde", |
[1] = "Alliance" |
} |
function BB:ShowConfig() |
--AceConfig:SetDefaultSize("BattleBar", 500, 550) |
AceConfig:Open("BattleBar", nil) |
end |
function BB:UpdateInfo() |
BB:Debug("Update Pong!"); |
RequestBattlefieldScoreData(); |
local member_list = {} |
local n = 0 |
nscores = GetNumBattlefieldScores(); |
qq = 1 |
for n = 1,nscores,1 do |
local name, killingBlows, honorKills, deaths, honorGained, faction, rank, race, class, ct, dmg, heal = GetBattlefieldScore(n); |
member = {} |
member.Name = name |
member.Faction = FactionConvert[faction] |
member.Class = ClassConvert[ct] |
member.KBS = killingBlows |
member.Dmg = dmg |
member.Heal = heal |
if (member.Class == nil) then |
BB:Debug("Error Converting '"..ct.."' / '"..class.."' to format."); |
end |
if (BB.db.profile.faction == "both") then |
tinsert(member_list, member); |
else |
if (BB.db.profile.faction == "alliance" and faction == 1) then |
tinsert(member_list, member) |
end |
if (BB.db.profile.faction == "horde" and faction == 0) then |
tinsert(member_list, member) |
end |
end |
end |
table.sort(member_list, function(a,b) return BB:SortScoreboard(a,b) end); |
BB.State.Scoreboard = member_list |
BB:Gui_Update(); |
end |
function BB:SortScoreboard(a,b) |
local qq = nil; |
local sortMethod = BB.db.profile.sortMode; |
--BB:Debug("Sort Method: "..sortMethod); |
if (sortMethod == "kbs") then |
--BB:Debug("Sorting by Killing Blows"); |
qq = a.KBS>b.KBS; |
if(a.KBS == b.KBS) then |
qq = a.Dmg > b.Dmg |
end |
end |
if (sortMethod == "dmg") then |
--BB:Debug("Sorting by Damage Done"); |
qq = a.Dmg>b.Dmg; |
end |
if (sortMethod == "heal") then |
--BB:Debug("Sorting by Healing Done"); |
qq = a.Heal>b.Heal; |
end |
return qq; |
end |
function BB:Inside_Battlegrounds() |
for i=1, MAX_BATTLEFIELD_QUEUES do |
status, mapName, instanceID = GetBattlefieldStatus(i); |
--BGDebugMessage("DEBUG","status="..status.." mapName="..mapName.." id="..instanceID,"debug"); |
if ( instanceID ~= 0 and status == "active") then |
mapName = mapName.." "..instanceID; |
return true, mapName |
end |
end |
--status="active"; |
return false, "" |
end |
function BB:BattlegroundCheck() |
if (BB.State.InBattleground == true) then |
insBattle, insName = BB:Inside_Battlegrounds() |
if (not insBattle) then |
-- We've left the battleground. |
BB.State.InBattleground = insBattle |
BB.State.CurrentBattleground = insName; |
BB:Debug("Battleground Exit Detected."); |
else |
BB.State.InBattleground = insBattle; |
BB.State.CurrentBattleground = insName; |
end |
else |
insBattle, insName = BB:Inside_Battlegrounds() |
if (insBattle) then |
-- We've entered the battleground. |
BB.State.InBattleground = insBattle |
BB.State.CurrentBattleground = insName; |
BB:Debug("Battleground Enter Detected."); |
else |
BB.State.InBattleground = insBattle; |
BB.State.CurrentBattleground = insName; |
end |
end |
end |
## Interface: 20400 |
## Title: Battle Bar |
## Version: 0.3 Build wowi:revision Beta |
## Author: Voorije of Azjol-Nerub |
## Notes: Battleground Scoreboard |
## OptionalDeps: |
## SavedVariables: BB_Vars |
embeds.xml |
locale.xml |
BattleBar.xml |
local GuiDefaults = { |
Widths = { |
General = 294, |
Button = 288, |
Fields = { |
Position = 16, |
Class = 12, |
Name = 100, |
KBS = 40, |
Damage = 60, |
Heals = 60 |
} |
}, |
Heights = { |
Title = 22, |
Button = 12, |
Header = 12 |
}, |
Colors = { |
Text = { |
Generic = { r = 1, g = 1, b = 1, a = 1 }, |
Header = { r = 1, g = 1, b = 0.6, a = 1 }, |
Alliance = { r = 0.4, g = 0.4, b = 0.8, a = 1 }, |
Horde = { r = 0.8, g = 0.4, b = 0.4, a = 1 }, |
SelfAlliance = { r = 0, g = 0, b = 0, a = 1 }, |
SelfHorde = { r = 0, g = 0, b = 0, a = 1 } |
}, |
Buttons = { |
Generic = { r = 0, g = 0, b = 0, a = 0.5 }, |
Header = { r = 0, g = 0, b = 0, a = 0 }, |
Alliance = { r = 0.0, g = 0.3, b = 1, a = 0.9 }, |
Horde = { r = 1, g = 0.3, b = 0.3, a = 0.9 }, |
SelfAlliance = { r = 0.0, g = 0.0, b = 0.5, a = 0.9 }, |
SelfHorde = { r = 0.5, g = 0.0, b = 0.0, a = 0.9 } |
} |
}, |
Coords = { |
Classes = { |
None = { x = 0, y = .25, z = 0, w = .25 }, |
Warrior = { x = .25, y = 0, z = 0, w = .25 }, |
Mage = { x = .5, y = .25, z = 0, w = .25 }, |
Rogue = { x = .75, y = .5, z = 0, w = .25 }, |
Druid = { x = 1, y = .75, z = 0, w = .25 }, |
Hunter = { x = .25, y = 0, z = .25, w = .5 }, |
Shaman = { x = .5, y = .25, z = .25, w = .5 }, |
Priest = { x = .75, y = .5, z = .25, w = .5 }, |
Warlock = { x = 1, y = .75, z = .25, w = .5 }, |
Paladin = { x = .25, y = 0, z = .5, w = .75 } |
} |
} |
} |
-- Generic GUI Creation |
function BB:Gui_Init() |
-- Initialize the Gui |
BB.Gui = { Detail = {} } |
self:Gui_Create_TitleFrame(); |
self:Gui_Create_GroupFrame(); |
self:Gui_Create_HeaderFrame() |
for i = 1,20 do |
BB:Gui_Create_DetailFrame(i) |
end |
end |
function BB:Gui_Create_TitleFrame() |
-- Create the Titlebar Frame |
local tFrame = CreateFrame("Frame", "BB_Gui_TitleFrame", UIParent); |
-- Base Frame Settings |
tFrame:EnableMouse(true) |
tFrame:SetMovable(true) |
tFrame:SetWidth(GuiDefaults.Widths.General) |
tFrame:SetHeight(GuiDefaults.Heights.Title) |
tFrame:SetPoint("CENTER", UIParent, "CENTER") |
-- Level/Strata |
tFrame:SetFrameStrata("DIALOG") |
tFrame:SetFrameLevel(0) |
-- Backdrop |
tFrame:SetBackdrop( |
{ |
bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
tile = true, |
tileSize = 8, |
edgeSize = 8, |
insets = { left = 2, right = 2, top = 2, bottom = 2 } |
}); |
-- Scripts |
tFrame:SetScript("OnMouseDown", function() |
tFrame:StartMoving(); |
end); |
tFrame:SetScript("OnMouseUp", function() |
tFrame:StopMovingOrSizing(); |
end); |
tFrame:SetScript("OnUpdate", function(s, elapsed) |
BB:OnUpdate(elapsed) |
end); |
tFrame:SetScript("OnEnter", function() |
BB.State.Rollover = true; |
if (BB.db.profile.behaviour.rolloverMode == true) then |
BB:Gui_Update(); |
end |
end); |
tFrame:SetScript("OnLeave", function() |
BB.State.Rollover = false; |
if (BB.db.profile.behaviour.rolloverMode == true) then |
BB:Gui_Update(); |
end |
end); |
-- Title |
local t = tFrame:CreateFontString("$parent_Title", "ARTWORK", "GameFontHighlight"); |
t:SetText("BattleBar"); |
t:SetPoint("TOPLEFT", tFrame, "TOPLEFT", 3, -4); |
t:SetWidth(220); |
t:SetHeight(12); |
t:SetJustifyH("LEFT"); |
tFrame.Title = t; |
tFrame:Show(); |
BB.Gui.TitleFrame = tFrame; |
end |
function BB:Gui_Create_GroupFrame() |
-- Create the Titlebar Frame |
local tFrame = CreateFrame("Frame", "BB_Gui_GroupFrame", BB.Gui.TitleFrame); |
-- Base Frame Settings |
tFrame:SetMovable(true) |
tFrame:SetWidth(GuiDefaults.Widths.General) |
tFrame:SetHeight(GuiDefaults.Heights.Header + (GuiDefaults.Heights.Button * 20) + 4) |
tFrame:SetPoint("TOPLEFT", BB.Gui.TitleFrame, "BOTTOMLEFT", 0, -4); |
-- Level/Strata |
tFrame:SetFrameStrata("DIALOG") |
tFrame:SetFrameLevel(0) |
-- Backdrop |
tFrame:SetBackdrop( |
{ |
bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
tile = true, |
tileSize = 8, |
edgeSize = 8, |
insets = { left = 2, right = 2, top = 2, bottom = 2 } |
}); |
tFrame:Show(); |
BB.Gui.GroupFrame = tFrame; |
end |
function BB:Gui_Create_HeaderFrame() |
-- Create the Titlebar Frame |
local tFrame = CreateFrame("Frame", "$parent_ButtonHeader", BB.Gui.GroupFrame); |
-- Base Frame Settings |
tFrame:SetMovable(true) |
tFrame:SetWidth(GuiDefaults.Widths.Button) |
tFrame:SetHeight(GuiDefaults.Heights.Button) |
tFrame:SetPoint("TOPLEFT", BB.Gui.GroupFrame, "TOPLEFT", 3, -2); |
-- Level/Strata |
tFrame:SetFrameStrata("DIALOG") |
tFrame:SetFrameLevel(5) |
-- Backdrop |
local bDropColor = GuiDefaults.Colors.Buttons.Header; |
local bDrop = tFrame:CreateTexture("$parent_Background", "BACKGROUND"); |
bDrop:SetTexture("Interface/Tooltips/UI-Tooltip-Background"); |
bDrop:SetAllPoints(tFrame); |
bDrop:SetVertexColor(bDropColor.r, bDropColor.g, bDropColor.b, bDropColor.a); |
-- Titles |
local hdtCol = GuiDefaults.Colors.Text.Header |
local fPos = self:Gui_Create_SmallFontString(tFrame, "$parent_Position", "#", GuiDefaults.Widths.Fields.Position, "LEFT"); |
local fClass = self:Gui_Create_SmallFontString(tFrame, "$parent_Class", "C", GuiDefaults.Widths.Fields.Class, "CENTER"); |
local fName = self:Gui_Create_SmallFontString(tFrame, "$parent_Name", "Name", GuiDefaults.Widths.Fields.Name, "LEFT"); |
local fKBS = self:Gui_Create_SmallFontString(tFrame, "$parent_KBS", "KBs", GuiDefaults.Widths.Fields.KBS, "RIGHT"); |
local fDmg = self:Gui_Create_SmallFontString(tFrame, "$parent_Damage", "Dmg", GuiDefaults.Widths.Fields.Damage, "RIGHT"); |
local fHeal = self:Gui_Create_SmallFontString(tFrame, "$parent_Healing", "Heal", GuiDefaults.Widths.Fields.Heals, "RIGHT"); |
fPos:SetPoint("TOPLEFT", tFrame, "TOPLEFT", 0, 0); |
fClass:SetPoint("TOPLEFT", fPos, "TOPRIGHT", 0, 0); |
fName:SetPoint("TOPLEFT", fClass, "TOPRIGHT", 0, 0); |
fKBS:SetPoint("TOPLEFT", fName, "TOPRIGHT", 0, 0); |
fDmg:SetPoint("TOPLEFT", fKBS, "TOPRIGHT", 0, 0); |
fHeal:SetPoint("TOPLEFT", fDmg, "TOPRIGHT", 0, 0); |
tFrame.Position = fPos; |
tFrame.Class = fClass; |
tFrame.Name = fName; |
tFrame.KBS = fKBS; |
tFrame.Damage = fDmg; |
tFrame.Healing = fHeal; |
local hTxtCol = GuiDefaults.Colors.Text.Header |
self:Gui_Update_RowTextColor(tFrame, hTxtCol.r, hTxtCol.g, hTxtCol.b, hTxtCol.a) |
fClass:SetTextColor(hTxtCol.r, hTxtCol.g, hTxtCol.b, hTxtCol.a); -- Hack for Header Only |
tFrame:Show(); |
BB.Gui.HeaderFrame = tFrame; |
end |
function BB:Gui_Create_DetailFrame(index) |
-- Create the Titlebar Frame |
local tFrame = CreateFrame("Frame", "$parent_Button"..index, BB.Gui.GroupFrame); |
-- Base Frame Settings |
tFrame:SetMovable(true) |
tFrame:SetWidth(GuiDefaults.Widths.Button) |
tFrame:SetHeight(GuiDefaults.Heights.Button) |
if (index == 1) then |
tFrame:SetPoint("TOPLEFT", BB.Gui.HeaderFrame, "BOTTOMLEFT", 0, 0); |
else |
tFrame:SetPoint("TOPLEFT", BB.Gui.Detail[index-1], "BOTTOMLEFT", 0, 0); |
end |
-- Level/Strata |
tFrame:SetFrameStrata("DIALOG") |
tFrame:SetFrameLevel(5) |
-- Backdrop |
local bDropColor = GuiDefaults.Colors.Buttons.Header; |
local bDrop = tFrame:CreateTexture("$parent_Background", "BACKGROUND"); |
bDrop:SetTexture("Interface/Tooltips/UI-Tooltip-Background"); |
bDrop:SetAllPoints(tFrame); |
bDrop:SetVertexColor(bDropColor.r, bDropColor.g, bDropColor.b, bDropColor.a); |
tFrame.Background = bDrop; |
-- Titles |
local hdtCol = GuiDefaults.Colors.Text.Generic |
local fPos = self:Gui_Create_SmallFontString(tFrame, "$parent_Position", "00", GuiDefaults.Widths.Fields.Position, "LEFT"); |
local fName = self:Gui_Create_SmallFontString(tFrame, "$parent_Name", "Name Of Player", GuiDefaults.Widths.Fields.Name, "LEFT"); |
local fKBS = self:Gui_Create_SmallFontString(tFrame, "$parent_KBS", "0000", GuiDefaults.Widths.Fields.KBS, "RIGHT"); |
local fDmg = self:Gui_Create_SmallFontString(tFrame, "$parent_Damage", "000000", GuiDefaults.Widths.Fields.Damage, "RIGHT"); |
local fHeal = self:Gui_Create_SmallFontString(tFrame, "$parent_Healing", "000000", GuiDefaults.Widths.Fields.Heals, "RIGHT"); |
local tClass = tFrame:CreateTexture("$parent_Class", "ARTWORK"); |
tClass:SetWidth(12); |
tClass:SetHeight(12); |
tClass:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes") |
local tCc = GuiDefaults.Coords.Classes.None; |
tClass:SetTexCoord(tCc.x, tCc.y, tCc.z, tCc.w); |
fPos:SetPoint("TOPLEFT", tFrame, "TOPLEFT", 0, 0); |
tClass:SetPoint("TOPLEFT", fPos, "TOPRIGHT", 0, 0); |
fName:SetPoint("TOPLEFT", tClass, "TOPRIGHT", 0, 0); |
fKBS:SetPoint("TOPLEFT", fName, "TOPRIGHT", 0, 0); |
fDmg:SetPoint("TOPLEFT", fKBS, "TOPRIGHT", 0, 0); |
fHeal:SetPoint("TOPLEFT", fDmg, "TOPRIGHT", 0, 0); |
tFrame.Position = fPos; |
tFrame.Class = tClass; |
tFrame.Name = fName; |
tFrame.KBS = fKBS; |
tFrame.Damage = fDmg; |
tFrame.Healing = fHeal; |
local hTxtCol = GuiDefaults.Colors.Text.Generic |
self:Gui_Update_RowTextColor(tFrame, hTxtCol.r, hTxtCol.g, hTxtCol.b, hTxtCol.a) |
tFrame:Show(); |
BB.Gui.Detail[index] = tFrame; |
end |
function BB:Gui_Create_SmallFontString(frame, name, text, width, just) |
local t = frame:CreateFontString(name, "ARTWORK", "GameFontHighlight"); |
-- Set Style |
t:SetFont("Fonts\FRIZQT__.TTF", 10); |
--t:SetTextHeight(10); |
local txtCol = |
t:SetTextColor(1,1,1,1); |
-- Set Data |
t:SetText(text); |
t:SetWidth(width); |
t:SetHeight(GuiDefaults.Heights.Button-2); |
t:SetJustifyH(just); |
return t; |
end |
------------------------------------------------ Update Functions ----------------------------------------------- |
function BB:Gui_Update() |
-- Update the GUI |
if (BB.db.profile.hidden == true) then |
BB.Gui.TitleFrame:Hide(); |
else |
BB.Gui.TitleFrame:Show(); |
end |
if (BB.db.profile.behaviour.hideMode == true and BB.State.InBattleground == false) then |
BB.Gui.TitleFrame:Hide() |
end |
-- Update The Title-Bar First |
local tTxtCol = {} |
local tBgCol = {} |
local selfFaction = UnitFactionGroup("player"); |
if (selfFaction == "Alliance") then |
tTxtCol = GuiDefaults.Colors.Text.Alliance; |
tBgCol = GuiDefaults.Colors.Buttons.Alliance; |
else |
tTxtCol = GuiDefaults.Colors.Text.Horde; |
tBgCol = GuiDefaults.Colors.Buttons.Horde; |
end |
BB.Gui.TitleFrame:SetBackdropColor(tBgCol.r, tBgCol.g, tBgCol.b, 0.8); |
BB.Gui.GroupFrame:SetBackdropColor(tBgCol.r, tBgCol.g, tBgCol.b, 0.8); |
BB.Gui.TitleFrame.Title:SetTextColor(tTxtCol.r, tTxtCol.g, tTxtCol.b, tTxtCol.a); |
-- Update Group Bar |
BB.Gui.GroupFrame:SetHeight(GuiDefaults.Heights.Header + (GuiDefaults.Heights.Button * BB.db.profile.gui.showCount) + 4) |
local showCount = BB.db.profile.gui.showCount |
local showSelf = BB.db.profile.gui.showSelf |
local myName = UnitName("player"); |
BB.Gui.GroupFrame:Show(); |
if (BB.db.profile.behaviour.rolloverMode == true and BB.State.Rollover == false) then |
BB.Gui.GroupFrame:Hide() |
else |
-- Check if we're in a BG |
if (BB.State.InBattleground == false) then |
-- Hide Everything |
BB.Gui.GroupFrame:Hide(); |
for i = 1, 20 do |
BB.Gui.Detail[i]:Hide(); |
end |
-- We're done here |
return |
end |
end |
-- Show/Hide Appropriate # of Bars |
for i = 1, (showCount) do |
BB.Gui.Detail[i]:Show(); |
end |
if (showCount ~= 20) then |
for i = (showCount+1), 20 do |
BB.Gui.Detail[i]:Hide(); |
end |
end |
local myScore = {} |
local myIndex = -1; |
for i = 1, #BB.State.Scoreboard do |
if (BB.State.Scoreboard[i].Name == myName) then |
myScore = BB.State.Scoreboard[i]; |
myIndex = i; |
end |
end |
if (myScore.Name == nil) then |
self:Debug("Update Failed, Unable to locate self in the list!"); |
end |
local seenSelf = false; |
for i = 1, (showCount) do |
local score = BB.State.Scoreboard[i]; |
local isSelf = false; |
local handled = false; |
if (score == nil) then |
-- End of the line! |
BB.Gui.Detail[i]:Hide(); |
handled = true; |
end |
if (handled == false) then |
-- Is this us? |
if (score == myScore) then |
isSelf = true; -- Current Record is us! |
seenSelf = true; -- We've seen ourselves! |
end |
-- Make sure our last entry is us unless we've already been shown. |
if (i == (showCount) and showSelf == true) then |
-- We're on the last entry. |
if (seenSelf == false and isSelf == false) then |
-- Not Us, and we havent seen ourselves yet. |
self:Gui_Update_Row(i, myIndex, myScore.Name, myScore.Faction, myScore.Class, myScore.KBS, myScore.Dmg, myScore.Heal, true); |
handled = true; |
end |
end |
if (handled == false) then |
self:Gui_Update_Row(i, i, score.Name, score.Faction, score.Class, score.KBS, score.Dmg, score.Heal, isSelf); |
end |
end |
end |
end |
function BB:Gui_Update_Row(index, pos, name, faction, class, kbs, dmg, heal, isSelf) |
local frame = BB.Gui.Detail[index]; |
frame:Show(); |
frame.Position:SetText(pos); |
frame.Name:SetText(name); |
frame.KBS:SetText(kbs); |
frame.Damage:SetText(dmg); |
frame.Healing:SetText(heal); |
bgCol = GuiDefaults.Colors.Text.Generic |
if (faction == "Alliance") then |
if (isSelf == true) then |
bgCol = GuiDefaults.Colors.Buttons.SelfAlliance |
else |
bgCol = GuiDefaults.Colors.Buttons.Alliance |
end |
else |
if (isSelf == true) then |
bgCol = GuiDefaults.Colors.Buttons.SelfHorde |
else |
bgCol = GuiDefaults.Colors.Buttons.Horde |
end |
end |
frame.Background:SetVertexColor(bgCol.r, bgCol.g, bgCol.b, bgCol.a); |
-- Class Icon |
local co = GuiDefaults.Coords.Classes[class]; |
if (co == nil) then |
self:Debug("Unable to find class name '"..class.."'"); |
co = GuiDefaults.Coords.Classes.None |
end |
frame.Class:SetTexCoord(co.x, co.y, co.z, co.w); |
end |
function BB:Gui_Update_RowTextColor(frame, r, g, b, a) |
local hcol = GuiDefaults.Colors.Text.Header; |
frame.Position:SetTextColor(hcol.r, hcol.g, hcol.b, hcol.a); |
frame.Name:SetTextColor(r, g, b, a); |
frame.KBS:SetTextColor(r, g, b, a); |
frame.Damage:SetTextColor(r, g, b, a); |
frame.Healing:SetTextColor(r, g, b, a); |
end |
local L = LibStub("AceLocale-3.0"):GetLocale("BattleBar") |
local options = { |
type = "group", |
args = { |
config = { |
type = "execute", |
name = L["Configure"], |
desc = L["Open the configuration dialog"], |
func = function() BB:ShowConfig() end, |
guiHidden = true |
}, |
toggle = { |
type = "execute", |
name = L["Toggle"], |
desc = L["Toggle the BattleBar"], |
func = function() BB:ToggleDialog() end, |
guiHidden = true |
}, |
refresh = { |
type = "execute", |
name = "Refresh", |
desc = "Refresh the interface, forcing an update.", |
func = function() BB:BattlegroundCheck(); BB:UpdateInfo(); end |
}, |
debug = { |
type = "toggle", |
name = L["Debug Mode"], |
desc = L["Toggle Debug Mode"], |
get = function(info) return BB.db.profile.debug end, |
set = function(info, v) BB.db.profile.debug = v end |
}, |
list = { |
type = "group", |
name = "List", |
desc = "List Options", |
args = { |
sortMode = { |
type = "select", |
name = "Sort Mode", |
desc = "The Sorting Mode for the List", |
values = { kbs = "Killing Blows", dmg = "Damage Done", heal = "Healing Done" }, |
style = "radio", |
get = function(info) return BB.db.profile.sortMode end, |
set = function(info, v) BB.db.profile.sortMode = v; BB:Gui_Update() end |
}, |
showFaction = { |
type = "select", |
name = "Show Faction", |
desc = "The Faction(s) you wish to show.", |
values = { both = "Both", alliance = "Alliance", horde = "Horde" }, |
style = "radio", |
get = function(info) return BB.db.profile.faction end, |
set = function(info, v) BB.db.profile.faction = v; BB:Gui_Update() end |
}, |
showCount = { |
type = "range", |
name = L["Show Count"], |
desc = L["How many players should be shown on the BattleBar"], |
min = 5, |
max = 20, |
step = 1, |
get = function(info) return BB.db.profile.gui.showCount end, |
set = function(info, v) BB.db.profile.gui.showCount = v BB:Gui_Update() end |
}, |
showSelf = { |
type = "toggle", |
name = L["Show Self"], |
desc = L["Show yourself regardless of position on the scoreboard"], |
get = function(info) return BB.db.profile.gui.showSelf end, |
set = function(info, v) BB.db.profile.gui.showSelf = v BB:Gui_Update() end |
} |
} |
}, |
behaviour = { |
type = "group", |
name = "Behaviour", |
desc = "General BattleBar Behaviour Options", |
args = { |
hideMode = { |
type = "toggle", |
name = "Hide Mode", |
desc = "Toggles 'Hide Mode' which will makes BattleBar completely invisible when not in a battleground.", |
get = function(info) return BB.db.profile.behaviour.hideMode end, |
set = function(info, v) |
BB.db.profile.behaviour.hideMode = v |
BB:Gui_Update(); |
end |
}, |
rolloverMode = { |
type = "toggle", |
name = "Rollover Mode", |
desc = "Toggles 'Rollover Mode' which will makes BattleBar's Scoreboard hidden until you mouse-over the title-bar.", |
get = function(info) return BB.db.profile.behaviour.rolloverMode end, |
set = function(info, v) |
BB.db.profile.behaviour.rolloverMode = v |
BB:Gui_Update(); |
end |
} |
} |
}, |
gui = { |
type = "group", |
name = L["Appearance"], |
desc = L["Appearance"], |
args = { |
update = { |
type = "execute", |
name = L["Update"], |
desc = L["Update GUI"], |
func = function() BB:Gui_Update() end, |
guiHidden = true |
}, |
}, |
guiHidden = true |
} |
} |
} |
BB.configOptions = options |
LibStub("AceConfig-3.0"):RegisterOptionsTable("BattleBar", options, {"battlebar", "bb"}) |