/trunk
local bdlc, f, c = select(2, ...):unpack() |
f.rolls = {} |
f.tabs = {} |
f.entries = {} |
function bdlc:fetchUserGear(unit, itemLink) |
local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemLink) |
local found_tier = false |
for k, v in pairs(bdlc.tier_names) do |
if (strfind(name, k)) then found_tier = true end |
end |
if (found_tier) then |
if (strfind(name, "Helm")) then |
equipSlot = "INVTYPE_HEAD" |
elseif (strfind(name, "Shoulders")) then |
equipSlot = "INVTYPE_SHOULDER" |
elseif (strfind(name, "Leggings")) then |
equipSlot = "INVTYPE_LEGS" |
elseif (strfind(name, "Chest")) then |
equipSlot = "INVTYPE_CHEST" |
elseif (strfind(name, "Gauntlets")) then |
equipSlot = "INVTYPE_HAND" |
elseif (strfind(name, "Badge")) then |
equipSlot = "INVTYPE_TRINKET" |
end |
end |
local slotID = 0; |
if (equipSlot == "INVTYPE_HEAD") then slotID = 1 end |
if (equipSlot == "INVTYPE_NECK") then slotID = 2 end |
if (equipSlot == "INVTYPE_SHOULDER") then slotID = 3 end |
if (equipSlot == "INVTYPE_BODY") then slotID = 4 end |
if (equipSlot == "INVTYPE_CHEST" or equipSlot == "INVTYPE_ROBE") then slotID = 5 end |
if (equipSlot == "INVTYPE_WAIST") then slotID = 6 end |
if (equipSlot == "INVTYPE_LEGS") then slotID = 7 end |
if (equipSlot == "INVTYPE_FEET") then slotID = 8 end |
if (equipSlot == "INVTYPE_WRIST") then slotID = 9 end |
if (equipSlot == "INVTYPE_HAND") then slotID = 10 end |
if (equipSlot == "INVTYPE_BACK") then slotID = 15 end |
if (equipSlot == "INVTYPE_CLOAK") then slotID = 15 end |
if (equipSlot == "INVTYPE_OFFHAND") then slotID = 17 end |
if (equipSlot == "INVTYPE_RANGED") then slotID = 18 end |
if (slotID == 0) then |
print("bdlc can't find compare for slot: "..equipSlot..". Let the developer "); |
end |
local itemLink1 = GetInventoryItemLink(unit, slotID) |
local itemLink2 = 0 |
if (equipSlot == "INVTYPE_FINGER") then |
itemLink1 = GetInventoryItemLink(unit, 11) |
itemLink2 = GetInventoryItemLink(unit, 12) |
end |
if (equipSlot == "INVTYPE_TRINKET") then |
itemLink1 = GetInventoryItemLink(unit, 13) |
itemLink2 = GetInventoryItemLink(unit, 14) |
end |
if (equipSlot == "INVTYPE_WEAPON" or equipSlot == "INVTYPE_2HWEAPON" or equipSlot == "INVTYPE_SHIELD" or equipSlot == "INVTYPE_HOLDABLE" or equipSlot == "INVTYPE_RANGEDRIGHT" or equipSlot == "INVTYPE_RANGED") then |
itemLink1 = GetInventoryItemLink(unit, 16) |
itemLink2 = GetInventoryItemLink(unit, 17) |
end |
if (not itemLink1) then |
itemLink1 = 0 |
end |
if (not itemLink2) then |
itemLink2 = 0 |
end |
return itemLink1, itemLink2 |
end |
function bdlc:repositionFrames() |
-- Loop through tabs and entries, sort by want level |
local lasttab = nil |
for t = 1, #f.tabs do |
local currenttab = f.tabs[t] |
local lastentry = nil |
local newtable = {} |
table.sort(f.entries[t], function(a, b) |
a.wantLevel = a.wantLevel or 0 |
b.wantLevel = b.wantLevel or 0 |
if a.rankIndex ~= b.rankIndex then |
return a.rankIndex > b.rankIndex |
end |
if a.wantLevel ~= b.wantLevel then |
return a.wantLevel < b.wantLevel |
end |
return a.name:GetText() > b.name:GetText() |
end) |
for e = 1, #f.entries[t] do |
local currententry = f.entries[t][e] |
if (currententry.active) then |
if (lastentry) then |
currententry:SetPoint("TOPLEFT", lastentry, "BOTTOMLEFT", 0, 1) |
else |
currententry:SetPoint("TOPLEFT", currenttab.table.content, "TOPLEFT", 0, 1) |
end |
lastentry = currententry |
end |
end |
if (currenttab.active) then |
if (lasttab) then |
currenttab:SetPoint("TOPRIGHT", lasttab, "BOTTOMRIGHT", 0, 2) |
else |
currenttab:SetPoint("TOPRIGHT", f.voteFrame.tabs, "TOPRIGHT", 2, 0) |
end |
lasttab = currenttab |
end |
end |
-- Loop through rolls |
local lastroll = nil |
for r = 1, #f.rolls do |
local currentroll = f.rolls[r] |
if (currentroll.active) then |
if (lastroll) then |
currentroll:SetPoint("TOPLEFT", lastroll, "BOTTOMLEFT", 0, 1) |
else |
currentroll:SetPoint("TOPLEFT", rollFrame, "TOPLEFT", 0, 0) |
end |
lastroll = currentroll |
end |
end |
if (not lastroll) then |
rollFrame:Hide() |
end |
if (not lasttab) then |
f.voteFrame:Hide() |
end |
-- if no tab is selected, select the first tab |
local tabselect = nil |
for tabs = 1, #f.tabs do |
if (f.tabs[tabs]:GetAlpha() == 1) then |
tabselect = true |
f.tabs[tabs].selected = true |
else |
f.tabs[tabs].selected = false |
f.tabs[tabs].icon:SetDesaturated(true) |
end |
end |
if (not tabselect) then |
local currenttab = nil |
for i = 1, #f.tabs do |
if (not currenttab and f.tabs[i].active) then |
currenttab = f.tabs[i] |
currenttab:SetAlpha(1) |
currenttab.selected = true |
currenttab.table:Show() |
currenttab.icon:SetDesaturated(false) |
break |
end |
end |
end |
end |
local function awardLoot(name, dropdown, itemLink) |
bdlc:debug("Award "..itemLink.." to "..name) |
bdlc.award_slot = nil |
local name = FetchUnitName(name) |
name, server = strsplit("-",name) |
server = server or bdlc.player_realm; |
if (not itemLink) then |
for t = 1, #f.tabs do |
if (f.tabs[t].active) then |
itemLink = f.tabs[t].itemLink |
break |
end |
end |
end |
for slot = 1, GetNumLootItems() do |
local slot_itemLink = GetLootSlotLink(slot) |
if (slot_itemLink == itemLink) then |
bdlc.award_slot = slot |
break |
end |
end |
if (bdlc.award_slot) then |
for i = 1, 40 do |
local candidate = GetMasterLootCandidate(bdlc.award_slot,i) |
if (candidate == name or candidate == name.."-"..server) then |
print("|cff3399FFBDGLC|r Awarding "..itemLink.." to "..name) |
GiveMasterLoot(bdlc.award_slot, i) |
break |
end |
end |
end |
dropdown:Hide() |
end |
------------------------------------------------------- |
-- Create all the necessary frames now, use them forever. |
------------------------------------------------------- |
bdlc.font_small = CreateFont("BDLC_FONT_SMALL") |
bdlc.font_small:SetFont("Interface\\Addons\\BDLC\\font.ttf", 12) |
bdlc.font_small:SetShadowColor(0, 0, 0) |
bdlc.font_small:SetShadowOffset(1, -1) |
bdlc.font = CreateFont("BDLC_FONT") |
bdlc.font:SetFont("Interface\\Addons\\BDLC\\font.ttf", 13) |
bdlc.font:SetShadowColor(0, 0, 0) |
bdlc.font:SetShadowOffset(1, -1) |
bdlc.font_large = CreateFont("BDLC_FONT_LARGE") |
bdlc.font_large:SetFont("Interface\\Addons\\BDLC\\font.ttf", 14) |
bdlc.font_large:SetShadowColor(0, 0, 0) |
bdlc.font_large:SetShadowOffset(1, -1) |
bdlc.normal_text = CreateFont("bdlc_button") |
bdlc.normal_text:SetFont("Interface\\Addons\\BDLC\\font.ttf", 13) |
bdlc.normal_text:SetTextColor(1,1,1,1) |
bdlc.normal_text:SetShadowColor(0, 0, 0) |
bdlc.normal_text:SetShadowOffset(1, -1) |
bdlc.normal_text:SetJustifyH("CENTER") |
--Vote Window |
f.voteFrame = CreateFrame('frame', 'BDLC', UIParent) |
bdlc:skinBackdrop(f.voteFrame, .1,.1,.1,.8); |
f.voteFrame:EnableMouse(true); |
f.voteFrame:SetMovable(true); |
f.voteFrame:SetUserPlaced(true); |
f.voteFrame:SetFrameStrata("DIALOG"); |
f.voteFrame:SetFrameLevel(1); |
f.voteFrame:SetClampedToScreen(true); |
f.voteFrame:SetSize(600, 400); |
f.voteFrame:SetPoint("CENTER"); |
f.voteFrame:Hide() |
-- Header |
f.voteFrame.header = CreateFrame("frame", nil, f.voteFrame); |
f.voteFrame.header:EnableMouse(true); |
f.voteFrame.header:RegisterForDrag("LeftButton","RightButton") |
f.voteFrame.header:SetScript("OnDragStart", function(self) f.voteFrame:StartMoving() end) |
f.voteFrame.header:SetScript("OnDragStop", function(self) f.voteFrame:StopMovingOrSizing() end) |
f.voteFrame.header:SetPoint("TOPLEFT", f.voteFrame, "TOPLEFT") |
f.voteFrame.header:SetPoint("BOTTOMRIGHT", f.voteFrame, "TOPRIGHT", 0, -24) |
bdlc:skinBackdrop(f.voteFrame.header,.1,.1,.1,1) |
f.voteFrame.header.close = CreateFrame("Button", nil, f.voteFrame.header) |
f.voteFrame.header.close:SetPoint("RIGHT", f.voteFrame.header, "RIGHT", -4, 0) |
f.voteFrame.header.close:SetText("x") |
bdlc:skinButton(f.voteFrame.header.close,true,"red") |
f.voteFrame.header.close:SetScript("OnClick", function() |
f.voteFrame:Hide() |
end) |
f.voteFrame.header.text = f.voteFrame.header:CreateFontString(nil, "OVERLAY", "BDLC_FONT_LARGE") |
f.voteFrame.header.text:SetText("|cff3399FFBig Dumb Loot Council|r") |
f.voteFrame.header.text:SetPoint("CENTER", f.voteFrame.header, "CENTER") |
-- Loot Council Display |
f.voteFrame.loot_council = CreateFrame("frame", nil, f.voteFrame) |
f.voteFrame.loot_council:SetPoint("BOTTOMLEFT", f.voteFrame, "BOTTOMLEFT", 10, 6) |
f.voteFrame.loot_council:SetSize(84, 18) |
bdlc:skinBackdrop(f.voteFrame.loot_council, .1,.1,.1,.8); |
f.voteFrame.loot_council.text = f.voteFrame.loot_council:CreateFontString(nil, "OVERLAY", "BDLC_FONT_LARGE") |
f.voteFrame.loot_council.text:SetPoint("LEFT", f.voteFrame.loot_council, "LEFT", 4, 0) |
f.voteFrame.loot_council.text:SetText("Loot Council") |
f.voteFrame.loot_council.text:SetJustifyH("LEFT") |
f.voteFrame.loot_council.image = f.voteFrame.loot_council:CreateTexture(nil, "OVERLAY") |
f.voteFrame.loot_council.image:SetTexture("Interface\\FriendsFrame\\InformationIcon") |
f.voteFrame.loot_council.image:SetSize(10, 10) |
f.voteFrame.loot_council.image:SetPoint("RIGHT", f.voteFrame.loot_council, "RIGHT", -4, 0) |
f.voteFrame.loot_council.image:SetVertexColor(.8,.8,.8) |
f.voteFrame.loot_council.add = CreateFrame("BUTTON", nil, f.voteFrame.loot_council) |
f.voteFrame.loot_council.add:SetText(" + ") |
bdlc:skinButton(f.voteFrame.loot_council.add,true,"blue") |
f.voteFrame.loot_council.add:SetPoint("LEFT", f.voteFrame.loot_council, "RIGHT", 2, 0) |
f.voteFrame.loot_council.add:SetWidth(18) |
StaticPopupDialogs["ADD_TO_LC_BOX"] = { |
text = "Type the player name to add to Loot Council", |
button1 = "Add", |
button2 = "Cancel", |
hasEditBox = 1, |
maxLetters = 32, |
OnAccept = function(self) |
local text = self.editBox:GetText() |
bdlc:addremoveLC("addtolc", text) |
StaticPopup_Hide("ADD_TO_LC_BOX") |
end, |
EditBoxOnEnterPressed = function(self) |
local text = self:GetText() |
bdlc:addremoveLC("addtolc", text) |
StaticPopup_Hide("ADD_TO_LC_BOX") |
end, |
timeout = 0, |
whileDead = true, |
hideOnEscape = true, |
preferredIndex = 3, |
} |
f.voteFrame.loot_council.add:SetScript("OnClick", function() |
StaticPopup_Show("ADD_TO_LC_BOX") |
end) |
f.voteFrame:HookScript("OnShow", function() |
if (IsMasterLooter() or UnitIsGroupLeader("player") or not IsInRaid()) then |
f.voteFrame.loot_council.add:Show() |
else |
f.voteFrame.loot_council.add:Hide() |
end |
end) |
f.voteFrame.loot_council:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
for councilName, v in pairs(bdlc.loot_council) do |
local name, server = strsplit("-", councilName) |
if (server == player_realm) then |
councilName = name |
end |
local classFileName = select(2, UnitClass(councilName)) |
local color = RAID_CLASS_COLORS[classFileName] or {['r'] = 1, ['b'] = 1, ['g'] = 1} |
GameTooltip:AddLine(councilName, color.r, color.g, color.b) |
end |
GameTooltip:Show() |
end) |
f.voteFrame.loot_council:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
-- Loot Disenchanters |
f.voteFrame.enchanters = CreateFrame("Button", nil, f.voteFrame) |
f.voteFrame.enchanters:SetText("Disenchant") |
f.voteFrame.enchanters:Hide() |
f.voteFrame.enchanters:SetPoint("BOTTOMRIGHT", f.voteFrame, "BOTTOMRIGHT", -8, 6) |
bdlc:skinButton(f.voteFrame.enchanters, true, "blue") |
f.voteFrame.enchanters:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
if (GetNumLootItems() > 0) then |
GameTooltip:AddLine("Click to Disenchant") |
else |
GameTooltip:AddLine("Loot the boss to choose a Disenchanter") |
end |
GameTooltip:Show() |
end) |
f.voteFrame.enchanters:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
f.voteFrame.enchanters:SetScript("OnClick", function() |
if (GetNumLootItems() > 0) then |
if (f.voteFrame.enchanters.dropdown:IsShown()) then |
f.voteFrame.enchanters.dropdown:Hide() |
else |
local itemLink = nil |
for i = 1, #f.tabs do |
if (f.tabs[i].selected) then |
itemLink = f.tabs[i].itemLink |
end |
end |
for i = 1, 4 do |
f.voteFrame.enchanters.dropdown[i]:Hide() |
end |
f.voteFrame.enchanters.dropdown:Show() |
table.sort(bdlc.enchanters, function(a, b) |
return a < b |
end) |
local index = 1 |
for name, gRank in pairs(bdlc.enchanters) do |
if index <= 4 then |
--local vname, server = strsplit("-", name) |
f.voteFrame.enchanters.dropdown[index]:Show() |
f.voteFrame.enchanters.dropdown[index]:SetText(name) |
f.voteFrame.enchanters.dropdown[index].itemLink = itemLink |
f.voteFrame.enchanters.dropdown[index].playerName = name |
index = index + 1 |
end |
end |
end |
end |
end) |
f.voteFrame.enchanters.dropdown = CreateFrame("frame", nil, f.voteFrame.enchanters) |
f.voteFrame.enchanters.dropdown:SetSize(100, (22*4)-2) |
f.voteFrame.enchanters.dropdown:Hide() |
f.voteFrame.enchanters.dropdown:SetPoint("TOP", f.voteFrame.enchanters, "BOTTOM", 0, 1) |
bdlc:skinBackdrop(f.voteFrame.enchanters.dropdown, .1,.1,.1,1) |
for i = 1, 4 do |
f.voteFrame.enchanters.dropdown[i] = CreateFrame("Button", nil, f.voteFrame.enchanters.dropdown) |
local enchanter = f.voteFrame.enchanters.dropdown[i] |
enchanter:Hide() |
enchanter:SetSize(100, 22) |
enchanter:SetPoint("TOP", f.voteFrame.enchanters.dropdown, "TOP", 0, -22*(i-1)) |
enchanter:SetNormalFontObject("bdlc_button") |
enchanter:SetHighlightFontObject("bdlc_button") |
enchanter:SetPushedTextOffset(0,-1) |
enchanter:SetScript("OnClick", function(self) |
awardLoot(self.playerName, f.voteFrame.enchanters.dropdown, self.itemLink) |
end) |
end |
-- Rolls |
rollFrame = CreateFrame('frame', "BDLC Roll Window", bdlc) |
rollFrame:SetSize(418, 1) |
rollFrame:SetPoint("CENTER", UIParent, "CENTER", 600, 0) |
rollFrame:EnableMouse(true) |
rollFrame:SetMovable(true); |
rollFrame:SetUserPlaced(true); |
rollFrame:SetFrameStrata("FULLSCREEN"); |
rollFrame:SetFrameLevel(10) |
rollFrame:SetClampedToScreen(true); |
rollFrame:RegisterForDrag("LeftButton","RightButton") |
rollFrame:SetScript("OnDragStart", function(self) rollFrame:StartMoving() end) |
rollFrame:SetScript("OnDragStop", function(self) rollFrame:StopMovingOrSizing() end) |
rollFrame:Hide() |
-- Create roll children |
for i = 1, 10 do |
local roll = CreateFrame("frame", nil, rollFrame); |
roll:SetPoint("TOPLEFT", rollFrame, "TOPLEFT", 0, -(59*(i-1))) |
roll:SetSize(rollFrame:GetWidth(), 60); |
roll.itemLink = 0 |
roll.active = false |
roll.notes = ""; |
roll:Hide() |
roll:EnableMouse(true) |
roll:SetMovable(true); |
roll:SetClampedToScreen(true); |
roll:RegisterForDrag("LeftButton","RightButton") |
roll:SetScript("OnDragStart", function(self) rollFrame:StartMoving() end) |
roll:SetScript("OnDragStop", function(self) rollFrame:StopMovingOrSizing() end) |
bdlc:skinBackdrop(roll, .2, .2, .2, .9) |
-- Loot item info/hover |
roll.item = CreateFrame("frame", nil, roll); |
roll.item:SetAllPoints(roll) |
roll.item:SetFrameStrata("FULLSCREEN_DIALOG") |
roll.item:SetFrameLevel(4) |
roll.item:EnableMouse(true) |
roll.item:SetMovable(true); |
roll.item:SetClampedToScreen(true); |
roll.item:RegisterForDrag("LeftButton","RightButton") |
roll.item:SetScript("OnDragStart", function(self) rollFrame:StartMoving() end) |
roll.item:SetScript("OnDragStop", function(self) rollFrame:StopMovingOrSizing() end) |
roll.item.icon = CreateFrame("frame", nil, roll) |
roll.item.icon:SetSize(50, 50) |
roll.item.icon:SetPoint("TOPLEFT", roll, "TOPLEFT", 5, -5) |
bdlc:skinBackdrop(roll.item.icon, 0,0,0,.8); |
roll.item.icon.tex = roll.item.icon:CreateTexture(nil, "ARTWORK") |
roll.item.icon.tex:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
roll.item.icon.tex:SetDrawLayer('ARTWORK') |
roll.item.icon.tex:SetTexture(nil) |
roll.item.icon.tex:SetPoint("TOPLEFT", roll.item.icon, "TOPLEFT", 2, -2) |
roll.item.icon.tex:SetPoint("BOTTOMRIGHT", roll.item.icon, "BOTTOMRIGHT", -2, 2) |
roll.item.item_text = roll:CreateFontString(nil, "ARTWORK","BDLC_FONT_LARGE") |
roll.item.item_text:SetText("item name") |
roll.item.item_text:SetPoint("TOPLEFT", roll, "TOPLEFT", 60, -8) |
roll.item.item_text:SetJustifyH("LEFT") |
roll.item.num_items = roll:CreateFontString(nil, "OVERLAY","BDLC_FONT") |
roll.item.num_items:SetText("x1") |
roll.item.num_items:SetPoint("LEFT", roll.item.item_text, "RIGHT", 6, 0) |
roll.item.num_items:SetJustifyH("LEFT") |
roll.item.item_ilvl = roll:CreateFontString(nil, "OVERLAY", "BDLC_FONT_SMALL") |
roll.item.item_ilvl:SetText("ilvl: ") |
roll.item.item_ilvl:SetPoint("TOPRIGHT", roll, "TOPRIGHT", -5, -10) |
roll.item.item_ilvl:SetJustifyH("RIGHT") |
-- Loot Buttons |
roll.buttons = CreateFrame("frame", nil, roll); |
roll.buttons:SetPoint("BOTTOMLEFT", roll, "BOTTOMLEFT", 50, 0); |
roll.buttons:SetPoint("TOPRIGHT", roll, "BOTTOMRIGHT", 0, 40); |
roll.buttons:EnableMouse(1) |
roll.buttons:SetFrameStrata("FULLSCREEN_DIALOG") |
roll.buttons:SetFrameLevel(5) |
roll.buttons.submit = function(wantLevel) |
local itemLink1, itemLink2 = bdlc:fetchUserGear("player", roll.itemLink) |
local itemString = string.match(roll.itemLink, "item[%-?%d:]+") |
local itemType, itemID, enchant, gem1, gem2, gem3, gem4, suffixID, uniqueID, level, upgradeId, instanceDifficultyID, numBonusIDs, bonusID1, bonusID2 = string.split(":", itemString) |
bonusID1 = bonusID1 or 0 |
bonusID2 = bonusID2 or 0 |
local itemUID = itemID..":"..numBonusIDs..":"..bonusID1..":"..bonusID2 |
SendAddonMessage(bdlc.message_prefix, "addUserWant><"..itemUID.."><"..bdlc.local_player.."><"..wantLevel.."><"..itemLink1.."><"..itemLink2, bdlc.sendTo, UnitName("player")); |
if (string.len(roll.notes) > 0) then |
SendAddonMessage(bdlc.message_prefix, "addUserNotes><"..itemUID.."><"..bdlc.local_player.."><"..roll.notes, bdlc.sendTo, UnitName("player")); |
end |
roll.itemLink = 0 |
roll.active = false |
roll.notes = "" |
roll.buttons.notes:SetText("") |
roll.buttons.notes:Hide() |
roll:Hide() |
bdlc:repositionFrames() |
end |
roll.buttons.main = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.main:SetPoint("LEFT", roll.buttons, "LEFT", 8, 0) |
roll.buttons.main:SetText("Mainspec") |
bdlc:skinButton(roll.buttons.main) |
roll.buttons.main:SetScript("OnClick", function() roll.buttons.submit(1) end) |
roll.buttons.minor = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.minor:SetPoint("LEFT", roll.buttons.main, "RIGHT", 1, 0) |
roll.buttons.minor:SetText("Minor Up") |
bdlc:skinButton(roll.buttons.minor) |
roll.buttons.minor:SetScript("OnClick", function() roll.buttons.submit(2) end) |
roll.buttons.off = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.off:SetPoint("LEFT", roll.buttons.minor, "RIGHT", 1, 0) |
roll.buttons.off:SetText("Offspec") |
bdlc:skinButton(roll.buttons.off) |
roll.buttons.off:SetScript("OnClick", function() roll.buttons.submit(3) end) |
roll.buttons.reroll = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.reroll:SetPoint("LEFT", roll.buttons.off, "RIGHT", 1, 0) |
roll.buttons.reroll:SetText("Reroll") |
bdlc:skinButton(roll.buttons.reroll) |
roll.buttons.reroll:SetScript("OnClick", function() roll.buttons.submit(4) end) |
roll.buttons.xmog = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.xmog:SetPoint("LEFT", roll.buttons.reroll, "RIGHT", 1, 0) |
roll.buttons.xmog:SetText("Transmog") |
bdlc:skinButton(roll.buttons.xmog) |
roll.buttons.xmog:SetScript("OnClick", function() roll.buttons.submit(5) end) |
roll.buttons.note = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.note:SetSize(40, 25) |
roll.buttons.note:SetPoint("LEFT", roll.buttons.xmog, "RIGHT", 1, 0) |
roll.buttons.note:SetText("Note") |
bdlc:skinButton(roll.buttons.note,false,"blue") |
roll.buttons.note:SetScript("OnClick", function() |
roll.buttons.notes:Show() |
roll.buttons.notes:SetFocus() |
end) |
roll.buttons.pass = CreateFrame("Button", nil, roll.buttons) |
roll.buttons.pass:SetSize(42, 25) |
roll.buttons.pass:SetPoint("LEFT", roll.buttons.note, "RIGHT", 1, 0) |
roll.buttons.pass:SetText("Pass") |
bdlc:skinButton(roll.buttons.pass,false,"red") |
roll.buttons.pass:SetScript("OnClick", function() |
SendAddonMessage(bdlc.message_prefix, "removeUserConsidering><"..roll.itemLink.."><"..bdlc.local_player, bdlc.sendTo, UnitName("player")); |
roll.itemLink = 0 |
roll.active = false |
roll.notes = "" |
roll.buttons.notes:SetText("") |
roll.buttons.notes:Hide() |
roll:Hide() |
bdlc:repositionFrames() |
end) |
roll.buttons.notes = CreateFrame("EditBox", nil, roll.buttons) |
roll.buttons.notes:SetSize(277, 24) |
roll.buttons.notes:SetPoint("BOTTOMLEFT", roll.buttons, "BOTTOMLEFT", 8, 8) |
roll.buttons.notes:SetMaxLetters(100) |
roll.buttons.notes:IsMultiLine(1) |
roll.buttons.notes:SetTextInsets(6, 2, 2, 2) |
roll.buttons.notes:SetFontObject("BDLC_FONT") |
roll.buttons.notes:SetFrameLevel(8) |
roll.buttons.notes:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8x8", edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1}) |
roll.buttons.notes:SetBackdropColor(.1,.1,.1,1) |
roll.buttons.notes:SetBackdropBorderColor(0,0,0,1) |
roll.buttons.notes:Hide() |
roll.buttons.notes.okay = CreateFrame("Button", nil, roll.buttons.notes) |
roll.buttons.notes.okay:SetSize(40, 25) |
roll.buttons.notes.okay:SetPoint("LEFT", roll.buttons.notes, "RIGHT", 1, 0) |
roll.buttons.notes.okay:SetText("Okay") |
bdlc:skinButton(roll.buttons.notes.okay) |
roll.buttons.notes.okay:SetScript("OnClick", function(self) |
self:GetParent():Hide() |
roll.notes = self:GetParent():GetText() |
end) |
roll.buttons.notes:SetScript("OnEnterPressed", function(self, key) roll.buttons.notes.okay:Click() end) |
roll.buttons.notes:SetScript("OnEscapePressed", function(self, key) roll.buttons.notes.okay:Click() end) |
f.rolls[i] = roll |
end |
-- Tabs |
f.voteFrame.tabs = CreateFrame("frame", nil, f.voteFrame); |
f.voteFrame.tabs:SetPoint("TOPLEFT", f.voteFrame, "TOPLEFT", -40, 0) |
f.voteFrame.tabs:SetPoint("BOTTOMRIGHT", f.voteFrame, "BOTTOMLEFT", 0, 0) |
-- Number of Items |
for i = 1, 10 do |
local tab = CreateFrame('frame', nil, f.voteFrame.tabs) |
tab.active = false |
tab.itemLink = 0 |
tab.selected = false |
tab:Hide() |
tab:SetSize(40, 40) |
tab:SetPoint("TOPRIGHT", tabs, "TOPRIGHT", 2, -38*(i-1)) |
tab:SetAlpha(0.3) |
tab:EnableMouse(1) |
bdlc:skinBackdrop(tab, .1,.1,.1,.8); |
tab:SetScript("OnMouseDown", function(self, b) |
if (b == "LeftButton") then |
for tabs = 1, #f.tabs do |
f.tabs[tabs]:SetAlpha(0.3) |
f.tabs[tabs].table:Hide() |
f.tabs[tabs].icon:SetDesaturated(true) |
f.tabs[tabs].selected = false |
end |
self:SetAlpha(1) |
self.selected = true |
self.table:Show() |
self.icon:SetDesaturated(false) |
end |
end) |
tab.icon = tab:CreateTexture(nil, "OVERLAY") |
tab.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
tab.icon:SetDrawLayer('ARTWORK') |
tab.icon:SetTexture(nil) |
tab.icon:SetDesaturated(true) |
tab.icon:SetPoint("TOPLEFT", tab, "TOPLEFT", 2, -2) |
tab.icon:SetPoint("BOTTOMRIGHT", tab, "BOTTOMRIGHT", -2, 2) |
--parent frame |
local vote_table = CreateFrame("Frame", nil, tab) |
vote_table:SetPoint("TOPLEFT", f.voteFrame, "TOPLEFT", 10, -100) |
vote_table:SetPoint("BOTTOMRIGHT", f.voteFrame, "BOTTOMRIGHT", -30, 30) |
vote_table:Hide() |
bdlc:skinBackdrop(vote_table, .1,.1,.1,.8); |
tab.table = vote_table |
--scrollframe |
scrollframe = CreateFrame("ScrollFrame", nil, vote_table) |
scrollframe:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 0, -2) |
scrollframe:SetPoint("BOTTOMRIGHT", vote_table, "BOTTOMRIGHT", 0, 2) |
vote_table.scrollframe = scrollframe |
--scrollbar |
scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate") |
scrollbar:SetPoint("TOPLEFT", vote_table, "TOPRIGHT", 6, -16) |
scrollbar:SetPoint("BOTTOMLEFT", vote_table, "BOTTOMRIGHT", 0, 16) |
scrollbar:SetMinMaxValues(1, 200) |
scrollbar:SetValueStep(1) |
scrollbar.scrollStep = 1 |
scrollbar:SetValue(0) |
scrollbar:SetWidth(16) |
scrollbar:SetScript("OnValueChanged", function (self, value) self:GetParent():SetVerticalScroll(value) end) |
bdlc:skinBackdrop(scrollbar, .1,.1,.1,.8); |
vote_table.scrollbar = scrollbar |
--content frame |
vote_table.content = CreateFrame("Frame", nil, scrollframe) |
vote_table.content:SetSize(560, 380) |
scrollframe:SetScrollChild(vote_table.content) |
-- Headers |
vote_table.name_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.name_text:SetText("Name"); |
vote_table.name_text:SetTextColor(1, 1, 1); |
vote_table.name_text:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 10, 16); |
vote_table.rank_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.rank_text:SetText("Rank"); |
vote_table.rank_text:SetTextColor(1, 1, 1); |
vote_table.rank_text:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 80, 16); |
vote_table.ilvl_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.ilvl_text:SetText("ilvl"); |
vote_table.ilvl_text:SetTextColor(1, 1, 1); |
vote_table.ilvl_text:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 170, 16); |
vote_table.ilvl_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.ilvl_text:SetText("Interest"); |
vote_table.ilvl_text:SetTextColor(1, 1, 1); |
vote_table.ilvl_text:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 200, 16); |
vote_table.notes_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.notes_text:SetText("Notes"); |
vote_table.notes_text:SetTextColor(1, 1, 1); |
vote_table.notes_text:SetPoint("TOPRIGHT", vote_table, "TOPRIGHT", -250, 16); |
vote_table.current_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.current_text:SetText("Current Gear"); |
vote_table.current_text:SetTextColor(1, 1, 1); |
vote_table.current_text:SetPoint("TOPRIGHT", vote_table, "TOPRIGHT", -160, 16); |
vote_table.votes_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.votes_text:SetText("Votes"); |
vote_table.votes_text:SetTextColor(1, 1, 1); |
vote_table.votes_text:SetPoint("TOPRIGHT", vote_table, "TOPRIGHT", -100, 16); |
vote_table.actions_text = vote_table:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.actions_text:SetText("Vote Remove"); |
vote_table.actions_text:SetTextColor(1, 1, 1); |
vote_table.actions_text:SetPoint("TOPRIGHT", vote_table, "TOPRIGHT", 0, 16); |
-- Item icon and such |
vote_table.item = CreateFrame("frame", nil, vote_table) |
vote_table.item:SetPoint("TOPLEFT", vote_table, "TOPLEFT", 10, 64) |
vote_table.item:SetAlpha(1) |
vote_table.item:SetSize(340, 40) |
vote_table.item.itemtext = vote_table.item:CreateFontString(nil, "OVERLAY", "BDLC_FONT_LARGE") |
vote_table.item.itemtext:SetText("Item Name") |
vote_table.item.itemtext:SetPoint("TOPLEFT", vote_table.item, "TOPLEFT", 50, -6) |
vote_table.item.num_items = vote_table.item:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.item.num_items:SetTextColor(1,1,1,1); |
vote_table.item.num_items:SetText("x1"); |
vote_table.item.num_items:SetPoint("LEFT", vote_table.item.itemtext, "RIGHT", 6, 0) |
vote_table.item.itemdetail = vote_table.item:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
vote_table.item.itemdetail:SetText("ilvl: "); |
vote_table.item.itemdetail:SetTextColor(1,1,1,.7); |
vote_table.item.itemdetail:SetPoint("BOTTOMLEFT", vote_table.item, "BOTTOMLEFT", 50, 6) |
vote_table.item.icon = CreateFrame("frame", nil, vote_table.item) |
vote_table.item.icon:SetSize(40, 40) |
vote_table.item.icon:SetPoint("TOPLEFT", vote_table.item, "TOPLEFT", 0, 0) |
bdlc:skinBackdrop(vote_table.item.icon, 0,0,0,.8); |
vote_table.item.icon.tex = vote_table.item.icon:CreateTexture(nil, "OVERLAY") |
vote_table.item.icon.tex:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
vote_table.item.icon.tex:SetDrawLayer('ARTWORK') |
vote_table.item.icon.tex:SetTexture(nil) |
vote_table.item.icon.tex:SetPoint("TOPLEFT", vote_table.item.icon, "TOPLEFT", 2, -2) |
vote_table.item.icon.tex:SetPoint("BOTTOMRIGHT", vote_table.item.icon, "BOTTOMRIGHT", -2, 2) |
vote_table.endSession = CreateFrame("Button", nil, vote_table) |
vote_table.endSession:SetSize(100, 25) |
vote_table.endSession:SetPoint("TOPRIGHT", vote_table, "TOPRIGHT", 0, 60) |
vote_table.endSession:SetText("End Session") |
bdlc:skinButton(vote_table.endSession,false,"red") |
vote_table.endSession:SetScript("OnClick", function() |
SendAddonMessage(bdlc.message_prefix, "endSession><"..f.tabs[i].itemLink, bdlc.sendTo, UnitName("player")); |
bdlc:endSession(f.tabs[i].itemLink) |
end) |
f.entries[i] = {} |
local lastframe = nil |
for e = 1, 40 do |
-- Create entry in table |
local entry = CreateFrame("Button", nil, vote_table.content) |
entry.itemLink = 0 |
entry.wantLevel = 0 |
entry.rankIndex = 0 |
entry.playerName = "" |
entry.notes = "" |
entry.active = false |
entry:SetSize(vote_table.content:GetWidth(), 22) |
if (lastframe) then |
entry:SetPoint("TOPLEFT", lastframe, "BOTTOMLEFT", 0, 2) |
else |
entry:SetPoint("TOPLEFT", vote_table.content, "TOPLEFT", 0, -3) |
end |
bdlc:skinBackdrop(entry, 1,1,1,.1) |
entry:Hide() |
entry.name = entry:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.name:SetText("test"); |
entry.name:SetTextColor(1, 1, 1); |
entry.name:SetPoint("LEFT", entry, "LEFT", 10, 0) |
entry.award = CreateFrame("Frame",nil, entry) |
entry.award:SetPoint("TOPLEFT", entry.name, "BOTTOMLEFT", 0, -2) |
entry.award:SetSize(100, 42) |
entry.award:Hide() |
bdlc:skinBackdrop(entry.award, .1,.1,.1,1) |
entry.award.text = entry.award:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.award.text:SetText("Award loot to ?"); |
entry.award.text:SetPoint("TOP", entry.award, "TOP", 0, -2) |
entry.award.yes = CreateFrame("Button", nil, entry.award) |
entry.award.yes:SetText("Yes") |
entry.award.yes:SetPoint("BOTTOMLEFT", entry.award, "BOTTOMLEFT", 2, 2) |
bdlc:skinButton(entry.award.yes,false,"blue") |
entry.award.yes:SetScript("OnClick", function(self) |
awardLoot(entry.playerName, entry.award, entry.itemLink) |
end) |
entry.award.no = CreateFrame("Button", nil, entry.award) |
entry.award.no:SetText("No") |
entry.award.no:SetPoint("BOTTOMRIGHT", entry.award, "BOTTOMRIGHT", -2, 2) |
entry.award.no:SetScript("OnClick", function() entry.award:Hide() end) |
bdlc:skinButton(entry.award.no,false,"red") |
entry:SetScript("OnClick", function() |
for i = 1, #f.tabs do |
for e = 1, #f.entries[i] do |
f.entries[i][e].award:Hide() |
end |
end |
if (IsMasterLooter()) then |
if (entry.award:IsShown()) then |
entry.award:Hide() |
else |
entry.award:Show() |
entry.award.text:SetText("Award to "..entry.name:GetText().."?") |
entry.award:SetWidth(entry.award.text:GetWidth()+12) |
end |
else |
entry.award:Hide() |
end |
end) |
entry.rank = entry:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.rank:SetText("rank"); |
entry.rank:SetTextColor(1,1,1); |
entry.rank:SetPoint("LEFT", entry, "LEFT", 80, 0) |
entry.ilvl = entry:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.ilvl:SetText(0); |
entry.ilvl:SetTextColor(1,1,1); |
entry.ilvl:SetPoint("LEFT", entry, "LEFT", 166, 0) |
entry.interest = entry:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.interest:SetText("considering..."); |
entry.interest:SetTextColor(.5,.5,.5); |
entry.interest:SetPoint("LEFT", entry, "LEFT", 198, 0) |
entry.user_notes = CreateFrame('frame', nil, entry) |
entry.user_notes:SetPoint("LEFT", entry, "LEFT", 284, 0) |
entry.user_notes:SetSize(16,16) |
entry.user_notes:Hide() |
entry.user_notes:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:AddLine(entry.notes, 1, 1, 1) |
GameTooltip:Show() |
end) |
entry.user_notes:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
entry.user_notes.tex = entry.user_notes:CreateTexture(nil, "OVERLAY") |
entry.user_notes.tex:SetAllPoints(entry.user_notes) |
entry.user_notes.tex:SetTexture("Interface\\FriendsFrame\\BroadcastIcon") |
entry.voteUser = CreateFrame("Button", nil, entry) |
entry.voteUser:SetSize(45, 20) |
entry.voteUser:SetPoint("RIGHT", entry, "RIGHT", -38, 0) |
entry.voteUser:SetText("Vote") |
bdlc:skinButton(entry.voteUser, true, "blue") |
entry.voteUser:Hide() |
entry.voteUser:SetScript("OnClick", function() |
bdlc:voteForUser(bdlc.local_player, entry.itemLink, entry.playerName) |
SendAddonMessage(bdlc.message_prefix, "voteForUser><"..bdlc.local_player.."><"..entry.itemLink.."><"..entry.playerName, bdlc.sendTo, UnitName("player")); |
end) |
entry.removeUser = CreateFrame("Button", nil, entry) |
entry.removeUser:SetSize(25, 20) |
entry.removeUser:SetPoint("RIGHT", entry, "RIGHT", -7, 0) |
entry.removeUser:SetText("x") |
entry.removeUser:Hide() |
bdlc:skinButton(entry.removeUser,true,"red") |
entry.removeUser:SetScript("OnClick", function() |
bdlc:removeUserConsidering(entry.itemLink, entry.playerName) |
SendAddonMessage(bdlc.message_prefix, "removeUserConsidering><"..entry.itemLink.."><"..entry.playerName, bdlc.sendTo, UnitName("player")); |
end) |
entry.gear1 = CreateFrame("frame", nil, entry) |
entry.gear1:SetSize(20,20); |
entry.gear1:Hide(); |
entry.gear1:SetPoint("RIGHT", entry, "RIGHT", -200, 0); |
bdlc:skinBackdrop(entry.gear1, 0, 0, 0, 1) |
entry.gear1.tex = entry.gear1:CreateTexture(nil, "OVERLAY") |
entry.gear1.tex:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
entry.gear1.tex:SetDrawLayer('ARTWORK') |
entry.gear1.tex:SetTexture(nil) |
entry.gear1.tex:SetPoint("TOPLEFT", entry.gear1, "TOPLEFT", 2, -2) |
entry.gear1.tex:SetPoint("BOTTOMRIGHT", entry.gear1, "BOTTOMRIGHT", -2, 2) |
entry.gear2 = CreateFrame("frame", nil, entry) |
entry.gear2:Hide(); |
entry.gear2:SetSize(20,20); |
entry.gear2:SetPoint("RIGHT", entry, "RIGHT", -170, 0); |
bdlc:skinBackdrop(entry.gear2, 0, 0, 0, 1) |
entry.gear2.tex = entry.gear2:CreateTexture(nil, "OVERLAY") |
entry.gear2.tex:SetTexCoord(0.08, 0.92, 0.08, 0.92) |
entry.gear2.tex:SetDrawLayer('ARTWORK') |
entry.gear2.tex:SetTexture(nil) |
entry.gear2.tex:SetPoint("TOPLEFT", entry.gear2, "TOPLEFT", 2, -2) |
entry.gear2.tex:SetPoint("BOTTOMRIGHT", entry.gear2, "BOTTOMRIGHT", -2, 2) |
entry.votes = CreateFrame('frame', nil, entry) |
entry.votes:SetPoint("RIGHT", entry, "RIGHT", -106, 0); |
entry.votes:SetSize(18, 20) |
entry.votes.text = entry.votes:CreateFontString(nil, "OVERLAY", "BDLC_FONT") |
entry.votes.text:SetText("0"); |
entry.votes.text:SetTextColor(1, 1, 1); |
entry.votes.text:SetPoint("CENTER", entry.votes, "CENTER", 0, 0) |
entry.votes:SetScript("OnEnter", function() |
if (tonumber(entry.votes.text:GetText()) > 0) then |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
for k, v in pairs(bdlc.loot_council_votes[entry.itemLink][entry.playerName]) do |
local name, server = strsplit("-", k) |
GameTooltip:AddLine(name, 1, 1, 1) |
end |
GameTooltip:Show() |
end |
end) |
entry.votes:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
--f.voteFrame.tab.entries[e] = entry |
lastframe = entry |
f.entries[i][e] = entry |
end |
f.tabs[i] = tab |
end |
f.tabs[1]:SetAlpha(1) |
f.tabs[1].table:Show() |
local addon, engine = ... |
engine[1] = CreateFrame("Frame", nil, UIParent) |
engine[2] = {} |
engine[3] = {} |
engine[1]:RegisterEvent("ADDON_LOADED") |
function engine:unpack() |
return self[1], self[2], self[3] |
end |
bdlc = engine[1] |
f = engine[2] |
c = engine[3] |
bdlc.player_realm = GetRealmName() |
bdlc.local_player = UnitName("player").."-"..bdlc.player_realm |
bdlc.tier_names = { |
['Protector'] = true, |
['Conqueror'] = true, |
['Vanquisher'] = true, |
['Defender'] = true, |
['Champion'] = true, |
['Hero'] = true |
} |
bdlc.message_prefix = "BDLC"; |
bdlc.item_drops = {} |
bdlc.enchanters = {} |
bdlc.award_slot = nil |
bdlc.sendTo = "RAID" |
bdlc.loot_sessions = { --[[[ itemLink] = itemUID --]]} |
bdlc.loot_council_votes = { --[[ itemLink[playerName] = {councilNames} --]]} |
bdlc.loot_council = {} |
bdlc.loot_slots = {} |
bdlc.loot_considering = {} |
bdlc.loot_want = {} |
bdlc.items_waiting = {} |
bdlc.player_items_waiting = {} |
-- Config |
bdlc.config = { |
flat = "Interface\\Buttons\\WHITE8x8", |
height = 400, |
width = 600, |
debug = false, |
version = "0.8.1" |
} |
bdlc.defaults = { |
council_min_rank = 2, |
custom_council = {} |
} |
local bdlc, f, c = select(2, ...):unpack() |
function bdlc:Config() |
-- Config window |
bdlcconfig = CreateFrame('frame', 'BDLC Config', UIParent) |
bdlcconfig:SetFrameStrata("HIGH") |
bdlcconfig:SetFrameLevel(50) |
bdlcconfig:SetSize(400, 100); |
bdlcconfig:SetPoint("CENTER"); |
bdlcconfig:EnableMouse(true); |
bdlcconfig:SetMovable(true); |
bdlcconfig:SetUserPlaced(true); |
bdlcconfig:SetClampedToScreen(true); |
bdlcconfig:RegisterForDrag("LeftButton","RightButton") |
bdlcconfig:SetScript("OnDragStart", function(self) bdlcconfig:StartMoving() end) |
bdlcconfig:SetScript("OnDragStop", function(self) bdlcconfig:StopMovingOrSizing() end) |
bdlc:skinBackdrop(bdlcconfig, .1,.1,.1,.9); |
bdlcconfig:Hide(); |
bdlcconfig.title = bdlcconfig:CreateFontString('nil', "OVERLAY", "BDLC_FONT") |
bdlcconfig.title:SetText("Big Dumb Config") |
bdlcconfig.title:SetTextColor(1,1,1) |
bdlcconfig.title:SetPoint("TOP", bdlcconfig, "TOP", 0,-6) |
bdlcconfig.close = CreateFrame("Button", nil, bdlcconfig) |
bdlcconfig.close:SetPoint("TOPRIGHT", bdlcconfig, "TOPRIGHT", -4, -4) |
bdlcconfig.close:SetText("x") |
bdlc:skinButton(bdlcconfig.close,true,"red") |
bdlcconfig.close:SetBackdropColor(.5,.1,.1,.5) |
bdlcconfig.close:SetScript("OnClick", function() |
bdlcconfig:Hide() |
bdlc_config_toggle = false |
end) |
-- Min Rank |
bdlcconfig.guildranks = CreateFrame("Button", "GuildRankDropdown", bdlcconfig, "UIDropDownMenuTemplate") |
bdlcconfig.guildranks:ClearAllPoints() |
bdlcconfig.guildranks:SetPoint("TOP", bdlcconfig, "TOP", 0, -50) |
bdlcconfig.guildranks:Show() |
bdlc:skinBackdrop(bdlcconfig.guildranks) |
bdlcconfig.guildranks.text = bdlcconfig.guildranks:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
bdlcconfig.guildranks.text:SetTextColor(1,1,1) |
bdlcconfig.guildranks.text:SetPoint("BOTTOM", bdlcconfig.guildranks, "TOP", 0, 4) |
bdlcconfig.guildranks.text:SetText("Minimum rank to be included in Loot Council") |
GuildRoster() |
local listOfRanks = {} |
bdlcconfig:RegisterEvent("GUILD_ROSTER_UPDATE") |
bdlcconfig:SetScript("OnEvent", function(self,event,arg1) |
local numGuildMembers, numOnline, numOnlineAndMobile = GetNumGuildMembers() |
for i =1, numGuildMembers do |
local name, rank, rankIndex, _, class = GetGuildRosterInfo(i) |
listOfRanks[rankIndex] = rank |
end |
local function OnClick(self) |
UIDropDownMenu_SetSelectedID(bdlcconfig.guildranks, self:GetID()) |
bdlc_config.council_min_rank = self:GetID() |
SendAddonMessage(bdlc.message_prefix, "fetchLC", "RAID"); |
end |
local function initialize(self, level) |
local info = UIDropDownMenu_CreateInfo() |
for i = 1, #listOfRanks do |
if (listOfRanks[i]) then |
local v = listOfRanks[i] |
info = UIDropDownMenu_CreateInfo() |
info.text = v |
info.value = v |
info.func = OnClick |
UIDropDownMenu_AddButton(info, level) |
end |
end |
UIDropDownMenu_SetSelectedValue(self, bdlc_config.council_min_rank) |
end |
UIDropDownMenu_Initialize(bdlcconfig.guildranks, initialize, "MENU") |
UIDropDownMenu_SetWidth(bdlcconfig.guildranks,200); |
UIDropDownMenu_SetButtonWidth(bdlcconfig.guildranks, 224) |
UIDropDownMenu_SetSelectedValue(bdlcconfig.guildranks, bdlc_config.council_min_rank) |
UIDropDownMenu_SetSelectedID(bdlcconfig.guildranks, bdlc_config.council_min_rank) |
UIDropDownMenu_JustifyText(bdlcconfig.guildranks, "LEFT") |
bdlcconfig:UnregisterEvent("GUILD_ROSTER_UPDATE") |
end) |
-- Custom Council |
-- bdlcconfig.council = CreateFrame("EditBox", nil, bdlcconfig) |
-- bdlcconfig.council:SetSize(240, 48) |
-- bdlcconfig.council:IsMultiLine(1) |
-- bdlcconfig.council:SetPoint("TOPLEFT", bdlcconfig.guildranks, "BOTTOMLEFT", 8, 8) |
-- bdlcconfig.council:SetMaxLetters(200) |
-- bdlcconfig.council:SetTextInsets(6, 2, 2, 2) |
-- bdlcconfig.council:SetFontObject("BDLC_FONT") |
-- bdlcconfig.council:SetScript("OnEnterPressed", function(self, key) bdlcconfig.council:ClearFocus() end) |
-- bdlcconfig.council:SetScript("OnEscapePressed", function(self, key) bdlcconfig.council:ClearFocus() end) |
-- skinBackdrop(bdlcconfig.council, .1,.1,.1,.9); |
local councilstring = '' |
for k, v in pairs(bdlc_config.custom_council) do |
councilstring = councilstring..k..' ' |
end |
--bdlcconfig.council:SetText(councilstring) |
end |
## Interface: 60200 |
## Title: |cff3399FFBig|r Dumb Loot Council |
## Version: 0.8.1 |
## DefaultState: Enabled |
## LoadOnDemand: 0 |
## SavedVariables: bdlc_config |
init.lua |
functions.lua |
versions.lua |
loot_council.lua |
frames.lua |
core.lua |
config.lua |
local bdlc, f, c = select(2, ...):unpack() |
---------------------------------------- |
-- StartSession |
---------------------------------------- |
function bdlc:startSession(itemLink,num) |
local itemString = string.match(itemLink, "item[%-?%d:]+") |
local itemType, itemID, enchant, gem1, gem2, gem3, gem4, suffixID, uniqueID, level, upgradeId, instanceDifficultyID, numBonusIDs, bonusID1, bonusID2 = string.split(":", itemString) |
bonusID1 = bonusID1 or 0 |
bonusID2 = bonusID2 or 0 |
local itemUID = itemID..":"..numBonusIDs..":"..bonusID1..":"..bonusID2 |
bdlc.item_drops[itemLink] = bdlc.item_drops[itemLink] or num |
if (not num) then num = bdlc.item_drops[itemLink] end |
if (GetItemInfo(itemLink)) then |
local equipSlot = select(9, GetItemInfo(itemLink)) |
local name = select(1, GetItemInfo(itemLink)) |
local found_tier = false |
for k, v in pairs(bdlc.tier_names) do |
if (strfind(name, k)) then found_tier = true end |
end |
if (not bdlc.loot_sessions[itemLink] and (string.len(equipSlot) > 0 or found_tier)) then |
bdlc:debug("Starting session for "..itemLink) |
bdlc.loot_sessions[itemLink] = itemUID |
if (bdlc:inLC()) then |
bdlc:createVoteWindow(itemLink,num) |
bdlc.loot_council_votes[itemLink] = {} |
bdlc.loot_considering[itemLink] = {} |
bdlc.loot_want[itemLink] = {} |
end |
bdlc:createRollWindow(itemLink,num) |
end |
else |
bdlc.items_waiting[itemID] = itemLink |
end |
end |
---------------------------------------- |
-- EndSession |
---------------------------------------- |
function bdlc:endSession(itemLink) |
bdlc.item_drops[itemLink] = nil |
local currententry = nil |
local currenttab = nil |
if bdlc:inLC() then |
for i = 1, #f.tabs do |
if (f.tabs[i].itemLink == itemLink) then |
for e = 1, #f.entries[i] do |
if (f.entries[i][e].itemLink == itemLink) then |
currententry = f.entries[i][e] |
currententry:Hide() |
currententry.user_notes:Hide() |
currententry.active = false |
currententry.itemLink = 0 |
currententry.votes.text:SetText("0") |
currententry.playerName = "" |
currententry.voteUser:Hide() |
currententry.wantLevel = 0 |
currententry.notes = "" |
end |
end |
currenttab = f.tabs[i] |
currenttab:Hide() |
currenttab:SetAlpha(0.3) |
currenttab.table:Hide() |
currenttab.active = false |
currenttab.selected = false |
currenttab.itemLink = 0 |
currenttab.table.item.num_items:SetText("x1") |
break |
end |
end |
bdlc.loot_considering[itemLink] = nil |
bdlc.loot_want[itemLink] = nil |
end |
local currentroll = nil |
for i = 1, #f.rolls do |
if (f.rolls[i].itemLink == itemLink) then |
currentroll = f.rolls[i] |
currentroll.active = false |
currentroll.itemLink = 0 |
currentroll.notes = "" |
currentroll:Hide() |
break |
end |
end |
bdlc.loot_sessions[itemLink] = nil |
bdlc.loot_council_votes[itemLink] = nil |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- StartMockSession |
---------------------------------------- |
function bdlc:startMockSession() |
bdlc:debug("Starting mock session") |
local demo_samples = { |
classes = {"HUNTER","WARLOCK","PRIEST","PALADIN","MAGE","ROGUE","DRUID","WARRIOR","DEATHKNIGHT","MONK"}, |
ranks = {"Officer","Raider","Trial","Social","Alt","Officer Alt","Guild Idiot"}, |
names = {"OReilly","Billy","Tìncan","Mango","Ugh","Onebutton","Thor","Deadpool","Atlas"} |
} |
local demo_players = { |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
[demo_samples.names[math.random(#demo_samples.names)]] = {math.random(695,740), demo_samples.ranks[math.random(#demo_samples.ranks)], demo_samples.classes[math.random(#demo_samples.classes)]}, |
} |
bdlc:buildLC() |
bdlc.item_drops = { |
[GetInventoryItemLink("player", 14)] = 1, |
[GetInventoryItemLink("player", 1)] = 3, |
[GetInventoryItemLink("player", 16)] = 1, |
[GetInventoryItemLink("player", 15)] = 2 |
} |
for k, v in pairs(bdlc.item_drops) do |
SendAddonMessage(bdlc.message_prefix, "startSession><"..k.."><"..v, bdlc.sendTo, UnitName("player")); |
end |
for k, v in pairs(bdlc.item_drops) do |
for k2, v2 in pairs(demo_players) do |
SendAddonMessage(bdlc.message_prefix, "addUserConsidering><"..k.."><"..k2.."><"..v2[1].."><"..v2[2].."><"..v2[3], bdlc.sendTo, UnitName("player")); |
end |
end |
end |
---------------------------------------- |
-- CreateVoteWindow |
---------------------------------------- |
function bdlc:createVoteWindow(itemLink,num) |
local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemLink) |
f.voteFrame:Show() |
local itemUID = bdlc.loot_sessions[itemLink] |
itemUID = bdlc:split(itemUID,":") |
local currenttab = nil |
for i = 1, #f.tabs do |
if (not currenttab and not f.tabs[i].active) then |
currenttab = f.tabs[i] |
currenttab.active = true |
currenttab.itemLink = itemLink |
break |
end |
end |
if (not currenttab) then bdlc:debug("couldn't find currenttab") return false end |
-- Set Up tab and item info |
currenttab:Show() |
currenttab.icon:SetTexture(texture) |
currenttab.table.item.itemtext:SetText(link) |
currenttab.table.item.num_items:SetText("x"..num) |
currenttab.table.item.icon.tex:SetTexture(texture) |
if (tonumber(itemUID[2]) >= 2) then |
currenttab:SetBackdropBorderColor(0,.7,0,1) |
currenttab.table.item.icon:SetBackdropBorderColor(0,.7,0,1) |
else |
currenttab:SetBackdropBorderColor(0,0,0,1) |
currenttab.table.item.icon:SetBackdropBorderColor(0,0,0,1) |
end |
local slotname = string.lower(string.gsub(equipSlot, "INVTYPE_", "")); |
slotname = slotname:gsub("^%l", string.upper) |
currenttab.table.item.itemdetail:SetText("ilvl: "..iLevel.." "..subclass..", "..slotname); |
currenttab.table.item:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:SetHyperlink(link) |
GameTooltip:Show() |
end) |
currenttab.table.item:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- CreateRollWindow |
---------------------------------------- |
function bdlc:createRollWindow(itemLink,num) |
local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemLink) |
rollFrame:Show() |
local itemUID = bdlc.loot_sessions[itemLink] |
itemUID = bdlc:split(itemUID,":") |
local currentroll = nil |
for i = 1, #f.rolls do |
if (not currentroll and not f.rolls[i].active) then |
currentroll = f.rolls[i] |
currentroll.active = true |
currentroll.itemLink = itemLink |
break |
end |
end |
if (not currentroll) then bdlc:debug("couldn't find currentroll") return false end |
currentroll:Show() |
currentroll.item.icon.tex:SetTexture(texture) |
currentroll.item.item_text:SetText(link) |
currentroll.item.num_items:SetText("x"..num) |
currentroll.item.item_ilvl:SetText("ilvl: "..iLevel) |
if (tonumber(itemUID[2]) >= 2) then |
currentroll.item.icon:SetBackdropBorderColor(0,.7,0,1) |
else |
currentroll.item.icon:SetBackdropBorderColor(0,0,0,1) |
end |
currentroll.item:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:SetHyperlink(link) |
GameTooltip:Show() |
end) |
currentroll.item:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
local guildRank = select(2,GetGuildInfo("player")) |
local player_itemlvl = math.floor(select(2, GetAverageItemLevel())) |
SendAddonMessage(bdlc.message_prefix, "addUserConsidering><"..itemLink.."><"..bdlc.local_player.."><"..player_itemlvl.."><"..guildRank, bdlc.sendTo, UnitName("player")); |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- RemoveUserRoll |
---------------------------------------- |
function bdlc:removeUserRoll(itemLink) |
local currentroll = nil |
for i = 1, #f.rolls do |
if (f.rolls[i].itemLink == itemLink) then |
currentroll = f.rolls[i] |
currentroll.active = false |
currentroll.itemLink = 0 |
currentroll.notes = "" |
currentroll:Hide() |
break |
end |
end |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- AddUserConsidering |
---------------------------------------- |
function bdlc:addUserConsidering(itemLink, playerName, iLvL, guildRank, playerClass) |
playerName = FetchUnitName(playerName) |
bdlc:debug(playerName.." considering "..itemLink) |
if not bdlc:inLC() then return false end |
if (not bdlc.loot_sessions[itemLink]) then return false end |
local currententry = nil |
for i = 1, #f.tabs do |
if (f.tabs[i].itemLink == itemLink) then |
for e = 1, #f.entries[i] do |
if (f.entries[i][e].active == false) then |
currententry = f.entries[i][e] |
currententry.active = true |
currententry.itemLink = itemLink |
currententry.wantLevel = 15 |
currententry.notes = "" |
currententry.playerName = playerName |
break |
end |
end |
end |
end |
if (not currententry) then return false end |
local itemName, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemLink) |
--local guildName, guildRankName, guildRankIndex = GetGuildInfo(name) |
local name, server = strsplit("-", playerName) |
local classFileName = select(2, UnitClass(name)) or select(2, UnitClass(playerName)) or playerClass |
local color = RAID_CLASS_COLORS[classFileName] |
if (not color) then print(playerName.." not found") return false end |
name = GetUnitName(name,true) or name |
currententry:Show() |
currententry.name:SetText(name) |
currententry.server = server |
currententry.name:SetTextColor(color.r,color.g,color.b); |
currententry.interest:SetText("considering..."); |
currententry.interest:SetTextColor(.5,.5,.5); |
currententry.rank:SetText(guildRank) |
currententry.ilvl:SetText(iLvL) |
currententry.gear1:Hide() |
currententry.gear2:Hide() |
if (IsMasterLooter() or not IsInRaid()) then |
currententry.removeUser:Show() |
else |
currententry.removeUser:Hide() |
end |
bdlc.loot_considering[itemLink][playerName] = {itemLink, playerName, iLvL, guildRank} |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- RemoveUserConsidering |
---------------------------------------- |
function bdlc:removeUserConsidering(itemLink, playerName) |
playerName = FetchUnitName(playerName) |
if bdlc:inLC() then |
local currententry = bdlc:returnEntry(itemLink, playerName) |
if (currententry) then |
currententry:Hide() |
currententry.user_notes:Hide() |
currententry.active = false |
currententry.itemLink = 0 |
currententry.notes = "" |
currententry.playerName = "" |
currententry.wantLevel = 0 |
currententry.voteUser:Hide() |
currententry.votes.text:SetText("0") |
end |
if (bdlc.loot_council_votes[itemLink]) then |
bdlc.loot_council_votes[itemLink][playerName] = nil |
end |
if (bdlc.loot_considering[itemLink]) then |
bdlc.loot_considering[itemLink][playerName] = nil |
end |
if (bdlc.loot_want[itemLink]) then |
bdlc.loot_want[itemLink][playerName] = nil |
end |
if (UnitExists(playerName)) then |
SendAddonMessage(bdlc.message_prefix, "removeUserRoll><"..itemLink, "WHISPER", playerName); |
end |
end |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- AddUserWant |
---------------------------------------- |
function bdlc:addUserWant(itemUID, playerName, want, itemLink1, itemLink2) |
playerName = FetchUnitName(playerName) |
local itemLink = nil |
for link, id in pairs(bdlc.loot_sessions) do |
if (itemUID == id) then |
itemLink = link |
end |
end |
if (not bdlc.loot_sessions[itemLink]) then return false end |
if not bdlc:inLC() then return false end |
local currententry = bdlc:returnEntry(itemLink, playerName) |
if (not currententry) then |
bdlc:debug("didn't find frame for player: "..playerName) |
return false |
end |
local wantTable = { |
[1] = {"Mainspec", {.2, 1, .2}}, |
[2] = {"Minor Up", {.6, 1, .6}}, |
[3] = {"Offspec", {.8, .6, .6}}, |
[4] = {"Reroll", {.1, .6, .6}}, |
[5] = {"Transmog", {.8, .4, 1}} |
} |
local wantText = wantTable[want][1] |
local wantColor = wantTable[want][2] |
bdlc:debug(playerName.." needs "..itemLink.." "..wantText) |
currententry.interest:SetText(wantText); |
currententry.interest:SetTextColor(unpack(wantColor)); |
currententry.voteUser:Show() |
currententry.wantLevel = want |
if (GetItemInfo(itemLink1)) then |
local itemName, link1, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture1, vendorPrice = GetItemInfo(itemLink1) |
currententry.gear1:Show() |
currententry.gear1.tex:SetTexture(texture1) |
currententry.gear1:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:SetHyperlink(link1) |
GameTooltip:Show() |
end) |
currententry.gear1:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
else |
local itemID = select(2, strsplit(":", itemLink1)) |
if (itemID) then |
bdlc.player_items_waiting[itemID] = {itemLink1, currententry.gear1} |
end |
end |
if (itemLink2 ~= 0) then |
if (GetItemInfo(itemLink2)) then |
local itemName, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture2, vendorPrice = GetItemInfo(itemLink2) |
currententry.gear2:Show() |
currententry.gear2.tex:SetTexture(texture2) |
currententry.gear2:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:SetHyperlink(link2) |
GameTooltip:Show() |
end) |
currententry.gear2:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
else |
local itemID = select(2, strsplit(":", itemLink2)) |
if (itemID) then |
bdlc.player_items_waiting[itemID] = {itemLink2, currententry.gear2} |
end |
end |
end |
bdlc.loot_want[itemLink][playerName] = {itemLink, playerName, want, itemLink1, itemLink2} |
bdlc:repositionFrames() |
end |
---------------------------------------- |
-- AddUserNotes |
---------------------------------------- |
function bdlc:addUserNotes(itemUID, playerName, notes) |
playerName = FetchUnitName(playerName) |
local itemLink = nil |
for link, id in pairs(bdlc.loot_sessions) do |
if (itemUID == id) then |
itemLink = link |
end |
end |
bdlc:debug("Add "..playerName.." notes") |
if (not bdlc.loot_sessions[itemLink]) then return false end |
if not bdlc:inLC() then return false end |
local currententry = bdlc:returnEntry(itemLink,playerName) |
if (not currententry) then return false end |
currententry.notes = notes |
currententry.user_notes:Show() |
end |
---------------------------------------- |
-- UpdateUserItem |
---------------------------------------- |
function bdlc:updateUserItem(itemLink, frame) |
local link = select(2, GetItemInfo(itemLink)) |
local texture = select(10, GetItemInfo(itemLink)) |
frame:Show() |
frame.tex:SetTexture(texture) |
frame:SetScript("OnEnter", function() |
ShowUIPanel(GameTooltip) |
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") |
GameTooltip:SetHyperlink(link) |
GameTooltip:Show() |
end) |
frame:SetScript("OnLeave", function() |
GameTooltip:Hide() |
end) |
end |
---------------------------------------- |
-- TakeWhisperEntry |
---------------------------------------- |
function bdlc:takeWhisperEntry(msg, sender) |
--[[msg = string.lower(msg) |
if (string.find(msg, "!bdlc")) then |
local itemLink = string.match(msg,"(\124c%x+\124Hitem:.-\124h\124r)") |
local s2, e2 = string.find(msg,"(\124c%x+\124Hitem:.-\124h\124r)") |
local wantlevel = strtrim(string.sub(msg, e2+2)) |
local raidIndex = 0 |
local name, server = strsplit("-", sender) |
--local findserver = select(1, string.find(sender, "-")) |
--sender = string.sub(sender, 0, findserver-1) |
if (bdlc.loot_sessions[itemLink]) then |
for r = 1, GetNumGroupMembers() do |
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(r) |
if (name == sender) then |
raidIndex = r |
end |
end |
local wantTable = { |
["need"] = 1, |
["bis"] = 1, |
["mainspec"] = 1, |
["main"] = 1, |
["minor"] = 2, |
["sidegrade"] = 2, |
["off"] = 3, |
["offspec"] = 3, |
["rr"] = 4, |
["reroll"] = 4, |
["transmog"] = 5, |
["xmog"] = 5, |
["mog"] = 5, |
} |
local want = wantTable[wantLevel] |
local itemID = select(2, strsplit(":", itemLink)) |
NotifyInspect("raid"..raidIndex) |
InspectUnit("raid"..raidIndex) |
local itemLink1, itemLink2 = bdlc:fetchUserGear("raid"..raidIndex, itemLink) |
local guildRank = select(2, GetGuildInfo("raid"..raidIndex)) |
local ilvl = getUnitItemLevel("raid"..raidIndex) |
local inspectwait = CreateFrame("frame", nil) |
local total = 0 |
inspectwait:SetScript("OnUpdate", function(self, elapsed) |
total = total + elapsed |
if (total > 1) then |
total = 0 |
inspectwait:SetScript("OnUpdate", function() return end) |
guildRank = select(2, GetGuildInfo(sender)) or "" |
itemLink1, itemLink2 = bdlc:fetchUserGear("raid"..raidIndex, itemLink) |
ilvl = getUnitItemLevel("raid"..raidIndex) |
print(itemLink1) |
print(itemLink2) |
SendAddonMessage(bdlc.message_prefix, "addUserConsidering><"..itemLink.."><"..raidIndex.."><"..ilvl.."><"..guildRank, bdlc.sendTo, UnitName("player")); |
SendAddonMessage(bdlc.message_prefix, "addUserWant><"..itemID.."><"..raidIndex.."><1><"..itemLink1.."><"..itemLink2, bdlc.sendTo, UnitName("player")); |
ClearInspectPlayer() |
end |
end) |
end |
end--]] |
end |
---------------------------------------- |
-- VoteForUser |
---------------------------------------- |
function bdlc:voteForUser(councilName, itemLink, playerName) |
playerName = FetchUnitName(playerName) |
if (not bdlc.loot_sessions[itemLink]) then return false end |
if not bdlc:inLC() then return false end |
-- make sure theres an array to represent this user in the raid |
bdlc.loot_council_votes[itemLink][playerName] = bdlc.loot_council_votes[itemLink][playerName] or {} |
-- first, unset this council member on any other user for this item |
for playerName, v in pairs(bdlc.loot_council_votes[itemLink]) do |
v[councilName] = nil |
end |
-- now add this council member as a vote for this raid member and this itemLink |
bdlc.loot_council_votes[itemLink][playerName][councilName] = true |
-- now lets loop through open sessions, and their entries while tallying votes for said item>entry |
for itemLink, _ in pairs(bdlc.loot_sessions) do |
for i = 1, #f.tabs do |
if (f.tabs[i].itemLink == itemLink) then |
for e = 1, #f.entries[i] do |
local currententry = f.entries[i][e] |
if (currententry.active and bdlc.loot_council_votes[itemLink][currententry.playerName]) then |
local votes = 0 |
for k, v in pairs(bdlc.loot_council_votes[itemLink][currententry.playerName]) do |
votes = votes + 1 |
end |
currententry.votes.text:SetText(votes) |
end |
end |
end |
end |
end |
end |
bdlc:SetScript("OnEvent", function(self, event, arg1, arg2, arg3) |
if (event == "ADDON_LOADED" and arg1 == "BDLC") then |
bdlc:UnregisterEvent("ADDON_LOADED") |
------------------------------------------------------- |
--- Register necessary events |
------------------------------------------------------- |
bdlc:RegisterEvent("LOOT_SLOT_CLEARED"); |
bdlc:RegisterEvent("LOOT_OPENED"); |
bdlc:RegisterEvent("LOOT_CLOSED"); |
bdlc:RegisterEvent('GET_ITEM_INFO_RECEIVED') |
bdlc:RegisterEvent('CHAT_MSG_ADDON') |
bdlc:RegisterEvent('GROUP_ROSTER_UPDATE') |
bdlc:RegisterEvent('CHAT_MSG_WHISPER') |
bdlc:RegisterEvent('PARTY_LOOT_METHOD_CHANGED') |
bdlc:RegisterEvent('PLAYER_ENTERING_WORLD') |
-------------------------------------------------------------------------------- |
-- Load configuration or set bdlc.defaults |
-------------------------------------------------------------------------------- |
print("|cff3399FFBig Dumb Loot Council|r loaded. /bdlc for options") |
RegisterAddonMessagePrefix(bdlc.message_prefix); |
if (not bdlc_config) then |
bdlc_config = bdlc.defaults |
end |
-------------------------------------------------------------------------------- |
-- Set up slash commands |
-------------------------------------------------------------------------------- |
SLASH_BDLC1 = "/bdlc" |
bdlc_config_toggle = false |
SlashCmdList["BDLC"] = function(origmsg, editbox) |
origmsg = strtrim(origmsg) |
local param = bdlc:split(origmsg," ") |
local msg = param[0] or origmsg; |
if (msg == "" or msg == " ") then |
print("|cff3399FFBCLC|r Options:") |
print(" /bdlc test - Tests the addon (must be in raid)") |
print(" /bdlc show - Shows the vote window (if you're in the LC)") |
print(" /bdlc hide - Hides the vote window (if you're in the LC)") |
print(" /bdlc version - Check the bdlc versions that the raid is using") |
print(" /bdlc addtolc playername - Adds a player to the loot council (if you're the Masterlooter)") |
print(" /bdlc removefromlc playername - Adds a player to the loot council (if you're the Masterlooter)") |
elseif (msg == "version") then |
bdlc:checkVersions() |
elseif (msg == "reset") then |
bdlc_config = bdlc.defaults |
ReloadUI() |
elseif (msg == "start") then |
local s, e = string.find(origmsg, msg) |
local newmsg = strtrim(string.sub(origmsg, e+1)) |
if (IsMasterLooter() or IsRaidLeader() or not IsInRaid()) then |
SendAddonMessage(bdlc.message_prefix, "startSession><"..newmsg.."><"..1, bdlc.sendTo, UnitName("player")); |
else |
print("bdlc: You must be in the loot council and be either the loot master or the raid leader to do that"); |
end |
elseif (msg == "addtolc" or msg == "removefromlc") then |
bdlc:addremoveLC(msg, param[1]) |
elseif (msg == "config") then |
if (bdlc_config_toggle) then |
bdlc_config_toggle = false |
bdlcconfig:Hide() |
else |
bdlc_config_toggle = true |
bdlcconfig:Show() |
end |
elseif (msg == "test") then |
bdlc:startMockSession() |
elseif (msg == "show" and bdlc:inLC()) then |
f.voteFrame:Show() |
elseif (msg == "hide" and bdlc:inLC()) then |
f.voteFrame:Hide() |
else |
print("/bdlc "..msg.." command not recognized") |
end |
end |
bdlc:Config() |
end |
if (event == "PLAYER_ENTERING_WORLD") then |
SendAddonMessage(bdlc.message_prefix, "fetchLC", bdlc.sendTo, UnitName("player")); |
if (IsInRaid()) then |
bdlc.sendTo = "RAID" |
else |
bdlc.sendTo = "WHISPER" |
end |
end |
if (event == "GROUP_ROSTER_UPDATE" or event == "PARTY_LOOT_METHOD_CHANGED") then |
bdlc:buildLC() |
if (IsInRaid()) then |
bdlc.sendTo = "RAID" |
else |
bdlc.sendTo = "WHISPER" |
end |
--SendAddonMessage(bdlc.message_prefix, "fetchLC", bdlc.sendTo, UnitName("player")); |
--SendAddonMessage(bdlc.message_prefix, "fetchSessions:"..bdlc.local_player, bdlc.sendTo, UnitName("player")) |
--bdlc:UnregisterEvent("GROUP_ROSTER_UPDATE") |
end |
if (IsMasterLooter() and event == "LOOT_CLOSED") then |
f.voteFrame.enchanters:Hide() |
end |
if (IsMasterLooter() and event == "LOOT_OPENED") then |
f.voteFrame.enchanters:Show() |
bdlc.loot_slots = {} |
bdlc.item_drops = {} |
for slot = 1, GetNumLootItems() do |
local texture, item, quantity, quality, locked = GetLootSlotInfo(slot) |
if (quality and quality > 3) then |
local itemLink = GetLootSlotLink(slot) |
bdlc.loot_slots[slot] = itemLink |
bdlc.item_drops[itemLink] = bdlc.item_drops[itemLink] or 0 |
bdlc.item_drops[itemLink] = bdlc.item_drops[itemLink] + 1 |
end |
end |
for k, v in pairs(bdlc.item_drops) do |
SendAddonMessage(bdlc.message_prefix, "startSession><"..k.."><"..v, bdlc.sendTo, UnitName("player")); |
end |
end |
if (event == "CHAT_MSG_WHISPER") then |
if (IsMasterLooter()) then |
bdlc:takeWhisperEntry(arg1, arg2) |
end |
end |
-- Auto close sessions when loot is awarded from the body |
if (event == "LOOT_SLOT_CLEARED" and arg1 == bdlc.award_slot) then |
local itemlink = bdlc.loot_slots[arg1] |
if not itemLink then return false end |
bdlc.item_drops[itemLink] = bdlc.item_drops[itemLink] - 1 |
for i = 1, #f.tabs do |
if (f.tabs[i].itemLink == itemLink) then |
f.tabs[i].table.item.num_items:SetText("x"..bdlc.item_drops[itemLink]) |
end |
end |
if (bdlc.item_drops[itemLink] == 0) then |
SendAddonMessage(bdlc.message_prefix, "endSession><"..itemLink, bdlc.sendTo, UnitName("player")); |
bdlc:endSession(itemLink) |
end |
bdlc.award_slot = {} |
bdlc.loot_slots[arg1] = nil |
end |
if (event == "CHAT_MSG_ADDON" and arg1 == bdlc.message_prefix) then |
local method, partyMaster, raidMaster = GetLootMethod() |
if (method == "master" or not IsInRaid()) then |
local param = bdlc:split(arg2, "><") |
local action = param[0] or arg2; |
--bdlc:debug(action..": "..unpack(param)) |
-- the numbers were made strings by the chat_msg_addon, lets find our numbers and convert them tonumbers |
for p = 0, #param do |
local test = param[p] |
if (tonumber(test)) then |
param[p] = tonumber(param[p]) |
end |
end |
if (action == "startSession") then |
bdlc:startSession(param[1],param[2]) |
elseif (action == "fetchLC") then |
bdlc:fetchLC() |
elseif (action == "sendVersion") then |
bdlc:sendVersion(param[1], param[2]) |
elseif (action == "versionCheck") then |
bdlc:versionCheck(param[1]) |
elseif (action == "addToLC") then |
bdlc:addToLC(param[1]) |
elseif (action == "removeFromLC") then |
bdlc:removeFromLC(param[1]) |
elseif (action == "removeUserConsidering") then |
bdlc:removeUserConsidering(param[1], param[2]) |
elseif (action == "addUserConsidering") then |
bdlc:addUserConsidering(param[1], param[2], param[3], param[4], param[5]) |
elseif (action == "addUserWant") then |
bdlc:addUserWant(param[1], param[2], param[3], param[4], param[5]) |
elseif (action == "addUserNotes") then |
bdlc:addUserNotes(param[1], param[2], param[3]) |
elseif (action == "fetchSessions") then |
fetchSessions(param[1]) |
elseif (action == "voteForUser") then |
bdlc:voteForUser(param[1], param[2], param[3]) |
elseif (action == "removeUserRoll") then |
bdlc:removeUserRoll(param[1]) |
elseif (action == "addEnchanter") then |
bdlc:addEnchanter(param[1], param[2]) |
elseif (action == "findEnchanters") then |
bdlc:findEnchanters() |
elseif (action == "endSession") then |
bdlc:endSession(param[1]) |
else |
end |
end |
end |
-- THIS IS FINISHED DONT TOUCH |
if (event == "GET_ITEM_INFO_RECEIVED") then |
-- Queue items that are starting sessions |
for k, v in pairs(bdlc.items_waiting) do |
local num1 = tonumber(arg1) |
local num2 = tonumber(k) |
if (num1 == num2) then |
bdlc:startSession(v) |
bdlc.items_waiting[k] = nil |
end |
end |
-- Queue items that are showing user's current gear |
for itemID, v in pairs(bdlc.player_items_waiting) do |
local num1 = tonumber(arg1) |
local num2 = tonumber(itemID) |
if (num1 == num2) then |
bdlc:updateUserItem(v[1], v[2]) |
bdlc.player_items_waiting[itemID] = nil |
end |
end |
end |
end) |
local bdlc, f, c = select(2, ...):unpack() |
function bdlc:inLC() |
return bdlc.loot_council[FetchUnitName("player")] or not IsInRaid() |
end |
function IsRaidLeader() |
local rl = nil |
local num = GetNumGroupMembers() |
local player = UnitName("player") |
for i = 1, num do |
local rank = select(2, GetRaidRosterInfo(i)) |
local name = select(1, GetRaidRosterInfo(i)) |
if (rank == 2 and name == player) then |
rl = true |
break |
end |
end |
return rl |
end |
function bdlc:returnEntry(itemLink, playerName) |
playerName = FetchUnitName(playerName) |
local current = nil |
local tab = nil |
for i = 1, #f.tabs do |
if (f.tabs[i].itemLink and f.tabs[i].itemLink == itemLink) then |
tab = i |
break |
end |
end |
if (tab) then |
for i = 1, #f.entries[tab] do |
if (f.entries[tab][i].playerName == playerName) then |
current = f.entries[tab][i] |
break |
end |
end |
end |
return current |
end |
function bdlc:debug(msg) |
if (bdlc.config.debug) then print("|cff3399FFBCLC:|r "..msg) end |
end |
function bdlc:skinBackdrop(frame, ...) |
frame:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8x8", edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1}) |
frame:SetBackdropColor(...) |
frame:SetBackdropBorderColor(0,0,0,1) |
return true |
end |
function bdlc:skinButton(f,small,color) |
local colors = {.1,.1,.1,1} |
local hovercolors = {0,0.55,.85,1} |
if (color == "red") then |
colors = {.6,.1,.1,0.6} |
hovercolors = {.6,.1,.1,1} |
elseif (color == "blue") then |
colors = {0,0.55,.85,0.6} |
hovercolors = {0,0.55,.85,1} |
elseif (color == "dark") then |
colors = {.1,.1,.1,1} |
hovercolors = {.1,.1,.1,1} |
end |
f:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8x8", edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1, insets = {left=1,top=1,right=1,bottom=1}}) |
f:SetBackdropColor(unpack(colors)) |
f:SetBackdropBorderColor(0,0,0,1) |
f:SetNormalFontObject("bdlc_button") |
f:SetHighlightFontObject("bdlc_button") |
f:SetPushedTextOffset(0,-1) |
f:SetSize(f:GetTextWidth()+16,24) |
--if (f:GetWidth() < 24) then |
if (small and f:GetWidth() <= 24 ) then |
f:SetWidth(20) |
end |
if (small) then |
f:SetHeight(18) |
end |
f:HookScript("OnEnter", function(f) |
f:SetBackdropColor(unpack(hovercolors)) |
end) |
f:HookScript("OnLeave", function(f) |
f:SetBackdropColor(unpack(colors)) |
end) |
return true |
end |
function bdlc:split(str, del) |
local t = {} |
local index = 0; |
while (string.find(str, del)) do |
local s, e = string.find(str, del) |
t[index] = string.sub(str, 1, s-1) |
str = string.sub(str, s+#del) |
index = index + 1; |
end |
table.insert(t, str) |
return t; |
end |
local bdlc, f, c = select(2, ...):unpack() |
bdlc.versions = {} |
function bdlc:sendVersion(version, player) |
bdlc.versions[version] = bdlc.versions[version] or {} |
bdlc.versions[version][player] = true |
end |
function bdlc:versionCheck(checker) |
local version = bdlc.config.version |
SendAddonMessage(bdlc.message_prefix, "sendVersion><"..version.."><"..bdlc.local_player, "WHISPER", checker); |
end |
function bdlc:checkVersions() |
bdlc.versions = {} |
SendAddonMessage(bdlc.message_prefix, "versionCheck><"..bdlc.local_player, bdlc.sendTo, UnitName("player")); |
local noaddon = {} |
for i = 1, GetNumGroupMembers() do |
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i) |
noaddon[name] = true |
end |
local total = 0 |
bdlc:SetScript("OnUpdate", function(self, elapsed) |
total = total + elapsed |
if (total > 1) then |
total = 0; |
for version, players in pairs(bdlc.versions) do |
local printString = version..": " |
for name, _ in pairs (players) do |
noaddon[name] = nil |
printString = printString..name..", " |
end |
print(string.sub(printString,0,-2)) |
end |
if (#noaddon > 0) then |
local printString = "BDLC not installed: " |
for name, v in pairs(noaddon) do |
printString = printString..name..", " |
end |
print(printString) |
end |
bdlc.versions = {} |
bdlc:SetScript("OnUpdate", function() return end) |
end |
end) |
end |
local bdlc, f, c = select(2, ...):unpack() |
---------------------------------------- |
-- Get/add/remove |
---------------------------------------- |
function FetchUnitName(name) |
local name, server = strsplit("-", name) |
server_name = GetUnitName(name,true) |
if (server_name) then |
name = server_name |
end |
name, server = strsplit("-", name) |
if (not server) then |
server = GetRealmName() |
end |
if (name) then |
return name.."-"..server |
else |
return nil |
end |
end |
function bdlc:fetchLC() |
bdlc:buildLC() |
end |
function bdlc:addToLC(playerName) |
playerName = FetchUnitName(playerName) |
bdlc.loot_council[playerName] = true |
bdlc:debug(playerName..' added to lc') |
end |
function bdlc:removeFromLC(playerName) |
bdlc.loot_council[playerName] = nil |
bdlc:debug(playerName..' removed from lc') |
end |
function bdlc:addremoveLC(msg, name) |
if (not name) then print("bdlc: Please provide a name to add to the loot council") return false end |
local targetname = FetchUnitName(name) |
if (not targetname) then print("bdlc: Couldn't find any player named "..name..". (they must be in the same group as you) ") return false end |
if (msg == "addtolc") then |
bdlc_config.custom_council[targetname] = true |
if (IsMasterLooter() or IsRaidLeader() or not IsInRaid()) then |
bdlc.loot_council[targetname] = true |
SendAddonMessage(bdlc.message_prefix, "addToLC><"..targetname, bdlc.sendTo, UnitName("player")); |
print("bdlc: Adding "..targetname.." to loot council.") |
SendChatMessage("bdlc: You've been added to loot council for this raid", "WHISPER", nil, targetname) |
else |
print("bdlc: Since you are not group leader or loot master, the player has been added to your own loot council for the next time that you are.") |
end |
else |
bdlc_config.custom_council[targetname] = nil |
if (IsMasterLooter() or IsRaidLeader() or not IsInRaid()) then |
bdlc.loot_council[targetname] = nil |
SendAddonMessage(bdlc.message_prefix, "removeFromLC><"..targetname, bdlc.sendTo, UnitName("player")); |
print("bdlc: Removing "..targetname.." from loot council.") |
else |
print("bdlc: Since you are not group leader or loot master, the player has been removed from your own loot council, not the group's as a whole.") |
end |
end |
end |
---------------------------------------- |
-- Enchanters |
---------------------------------------- |
function bdlc:addEnchanter(playerName, guildRankIndex) |
playerName = FetchUnitName(playerName) |
bdlc.enchanters[playerName] = guildRankIndex |
bdlc:debug("Added "..playerName.." to enchanter quicklist") |
end |
function bdlc:findEnchanters() |
bdlc:debug("Finding enchanters") |
local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions() |
local prof = prof1 == 8 or prof2 |
if (prof == 8) then |
name, rank, maxRank = select(1, GetProfessionInfo(prof)), select(3, GetProfessionInfo(prof)), select(4, GetProfessionInfo(prof)) |
--if (rank >= (maxRank-10)) then |
local masterLooter = select(3, GetLootMethod()) or 1 |
if (masterLooter) then |
local masterLooter = GetRaidRosterInfo(masterLooter) or UnitName("player") |
local mlguildName = select(1, GetGuildInfo(masterLooter)) |
local guildName, guildRankName, guildRankIndex = GetGuildInfo("player") |
if (mlguildName == guildName or not IsInRaid()) then |
SendAddonMessage(bdlc.message_prefix, "addEnchanter><"..bdlc.local_player.."><"..guildRankIndex, "WHISPER", masterLooter); |
--bdlc:addEnchanter(bdlc.local_player, guildRankIndex) |
else |
bdlc:debug("Since this enchanter isn't from the same guild, we're going to ignore them") |
end |
end |
--end |
end |
end |
---------------------------------------- |
-- BuildLC |
---------------------------------------- |
function bdlc:buildLC() |
bdlc.enchanters = {} |
bdlc.loot_council = {} |
if (IsMasterLooter() or not IsInRaid()) then |
SendAddonMessage(bdlc.message_prefix, "findEnchanters", bdlc.sendTo, UnitName("player")); |
bdlc:debug("building LC") |
local autocouncil = {[FetchUnitName("player")] = true} |
local numGuildMembers, numOnline, numOnlineAndMobile = GetNumGuildMembers() |
local numRaid = GetNumGroupMembers() |
if (numRaid == 0) then |
numRaid = 1 |
end |
local inraid = {} |
for i = 1, numRaid do |
local name = FetchUnitName("raid"..i) or FetchUnitName("party"..i) or FetchUnitName("player") |
inraid[name] = true |
end |
for i = 1, numGuildMembers do |
local fullName, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile, canSoR, reputation = GetGuildRosterInfo(i) |
if (online and rankIndex <= bdlc_config.council_min_rank) then |
local name = FetchUnitName(fullName) |
autocouncil[name] = true |
end |
end |
for k, v in pairs (bdlc_config.custom_council) do |
if (inraid[k]) then |
SendAddonMessage(bdlc.message_prefix, "addToLC><"..k, bdlc.sendTo, GetUnitName("player",true),true); |
end |
end |
for k, v in pairs (autocouncil) do |
SendAddonMessage(bdlc.message_prefix, "addToLC><"..k, bdlc.sendTo, GetUnitName("player",true)); |
end |
end |
end |