From a2e0615659c4d4db5b291a0a4377e7de1652673e Mon Sep 17 00:00:00 2001 From: Road-block Date: Wed, 27 Sep 2017 04:55:02 +0300 Subject: [PATCH] loot: add advanced masterloot menu --- api/api.lua | 119 ++++++++++- api/config.lua | 1 + env/colors.lua | 3 +- env/tables.lua | 17 ++ env/translations_deDE.lua | 18 +- env/translations_enUS.lua | 18 +- env/translations_esES.lua | 18 +- env/translations_frFR.lua | 14 ++ env/translations_koKR.lua | 14 ++ env/translations_ruRU.lua | 18 +- env/translations_zhCN.lua | 18 +- env/translations_zhTW.lua | 18 +- modules/gui.lua | 1 + modules/loot.lua | 405 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 668 insertions(+), 14 deletions(-) diff --git a/api/api.lua b/api/api.lua index e5543116..68846bd5 100644 --- a/api/api.lua +++ b/api/api.lua @@ -184,9 +184,68 @@ function pfUI.api.Abbreviate(number) return number end +-- [ SendChatMessageWide ] +-- Sends a message to widest audience the player can broadcast to +-- 'msg' [string] the message to send +function pfUI.api.SendChatMessageWide(msg) + local channel = "SAY" + if UnitInRaid("player") then + channel = "RAID" + elseif UnitExists("party1") then + channel = "PARTY" + end + SendChatMessage(msg,channel) +end + +-- [ GroupInfoByName ] +-- Gets the unit id by name +-- 'name' [string] party or raid member +-- 'group' [string] "raid" or "party" +-- returns: [table] {name='name',unitId='unitId',Id=Id,lclass='lclass',class='class'} +do -- create a scope so we don't have to worry about upvalue collisions + local party, raid, unitinfo = {}, {}, {} + party[0] = "player" -- fake unit + for i=1, MAX_PARTY_MEMBERS do + party[i] = "party"..i + end + for i=1, MAX_RAID_MEMBERS do + raid[i] = "raid"..i + end + function pfUI.api.GroupInfoByName(name,group) + unitinfo = pfUI.api.wipe(unitinfo) + if group == "party" then + for i=0, MAX_PARTY_MEMBERS do + local unitName = UnitName(party[i]) + if unitName == name then + local lclass,class = UnitClass(party[i]) + if not (lclass and class) then + lclass,class = _G.UNKNOWN, "UNKNOWN" + end + unitinfo.name,unitinfo.unitId,unitinfo.Id,unitinfo.lclass,unitinfo.class = + unitName,party[i],i,lclass,class + return unitinfo + end + end + elseif group == "raid" then + for i=1, MAX_RAID_MEMBERS do + local unitName = UnitName(raid[i]) + if unitName == name then + local lclass,class = UnitClass(raid[i]) + if not (lclass and class) then + lclass,class = _G.UNKNOWN, "UNKNOWN" + end + unitinfo.name,unitinfo.unitId,unitinfo.Id,unitinfo.lclass,unitinfo.class = + unitName,raid[i],i,lclass,class + return unitinfo + end + end + end + end +end + -- [ hooksecurefunc ] -- Hooks a global function and injects custom code --- 'name' [string] name of the function that shold be hooked +-- 'name' [string] name of the function that should be hooked -- 'func' [function] function containing the custom code -- 'append' [bool] optional variable, used to append custom -- code instead of prepending it @@ -212,6 +271,43 @@ function pfUI.api.hooksecurefunc(name, func, append) _G[name] = pfUI.hooks[tostring(func)]["function"] end +-- [ QueueFunction ] +-- Add functions to a FIFO queue for execution after a short delay. +-- '...' [vararg] function, [arguments] +local timer +function pfUI.api.QueueFunction(...) + if not (timer) then + timer = CreateFrame("frame") + timer.queue = {} + timer.interval = TOOLTIP_UPDATE_TIME + timer.DeQueue = function() + local item = table.remove(timer.queue,1) + if (item) then + item[1](unpack(item[2])) + end + if table.getn(timer.queue) == 0 then + timer:Hide() -- no need to run the OnUpdate when the queue is empty + end + end + timer:SetScript("OnUpdate",function() + this.sinceLast = (this.sinceLast or 0) + arg1 + while (this.sinceLast > this.interval) do + this.DeQueue() + this.sinceLast = this.sinceLast - this.interval + end + end) + end + assert(type(arg[1])=="function","QueueFunction: arg1 is not a function") + local func = arg[1] + local args + for i=2,arg.n do + args = args or {} + table.insert(args,arg[i]) + end + table.insert(timer.queue,{func,args}) + timer:Show() -- start the OnUpdate +end + -- [ Create Gold String ] -- Transforms a amount of copper into a fully fledged gold string -- 'money' [int] the amount of coppy (GetMoney()) @@ -304,6 +400,27 @@ function pfUI.api.CopyTable(src) return _copy(src) end +-- [ Wipe Table ] +-- Empties a table and returns it +-- 'src' [table] the table that should be emptied. +-- return: [table] the emptied table. +function pfUI.api.wipe(src) + -- notes: table.insert, table.remove will have undefined behavior + -- when used on tables emptied this way because Lua removes nil + -- entries from tables after an indeterminate time. + -- Instead of table.insert(t,v) use t[table.getn(t)+1]=v as table.getn collapses nil entries. + -- There are no issues with hash tables, t[k]=v where k is not a number behaves as expected. + local mt = getmetatable(src) or {} + if mt.__mode == nil or mt.__mode ~= "kv" then + mt.__mode = "kv" + src=setmetatable(src,mt) + end + for k in pairs(src) do + src[k] = nil + end + return src +end + -- [ Update Movable ] -- Loads and update the configured position of the specified frame. -- It also creates an entry in the movables table. diff --git a/api/config.lua b/api/config.lua index cfad74ca..2d57a1b8 100644 --- a/api/config.lua +++ b/api/config.lua @@ -71,6 +71,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("loot", nil, "autoresize", "1") pfUI:UpdateConfig("loot", nil, "autopickup", "1") pfUI:UpdateConfig("loot", nil, "mousecursor", "1") + pfUI:UpdateConfig("loot", nil, "advancedloot", "1") pfUI:UpdateConfig("unitframes", nil, "disable", "0") pfUI:UpdateConfig("unitframes", nil, "pastel", "1") diff --git a/env/colors.lua b/env/colors.lua index 34b51cb8..c4ac06a6 100644 --- a/env/colors.lua +++ b/env/colors.lua @@ -16,7 +16,8 @@ function pfUI.environment:UpdateColors() ["SHAMAN"] = { r = 0.14, g = 0.35, b = 1.0, colorStr = "ff0070de" }, ["PRIEST"] = { r = 1, g = 1, b = 1, colorStr = "ffffffff" }, ["WARLOCK"] = { r = 0.58, g = 0.51, b = 0.79, colorStr = "ff9482c9" }, - ["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73, colorStr = "fff58cba" } + ["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73, colorStr = "fff58cba" }, + ["UNKNOWN"] = { r = 0.6, g = 0.6, b = 0.6, colorStr = "ff999999" } } end diff --git a/env/tables.lua b/env/tables.lua index 82298cc5..09079b1e 100644 --- a/env/tables.lua +++ b/env/tables.lua @@ -1,3 +1,20 @@ +-- this table is added in later expansions +CLASS_SORT_ORDER = CLASS_SORT_ORDER or { + "WARRIOR", + "DEATHKNIGHT", + "PALADIN", + "MONK", + "PRIEST", + "SHAMAN", + "DRUID", + "ROGUE", + "MAGE", + "WARLOCK", + "HUNTER", + "DEMONHUNTER", + "UNKNOWN", +} + -- barlength = {[formfactor]={cols, rows}} pfGridmath = { [1] = {{1,1}}, diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index af442a47..3c171cee 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -22,9 +22,10 @@ pfUI_translation["deDE"] = { ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, ["Bagspace"] = nil, + ["Banker"] = nil, ["Border Color"] = nil, - ["Bottom"] = nil, ["Bottom Left"] = nil, + ["Bottom"] = nil, ["Bottom Right"] = nil, ["Buff Limit"] = nil, ["Buff Position"] = nil, @@ -49,6 +50,7 @@ pfUI_translation["deDE"] = { ["Chat"] = nil, ["Class"] = nil, ["CleanUp"] = nil, + ["Clear Rolls"] = nil, ["Click Action"] = nil, ["Clickcast Spells"] = nil, ["Clock"] = nil, @@ -94,6 +96,7 @@ pfUI_translation["deDE"] = { ["Disable pfUI Player Castbar"] = nil, ["Disable pfUI Target Castbar"] = nil, ["Disable pfUI Unit Frames"] = nil, + ["Disenchanter"] = nil, ["Display Debuff Durations"] = nil, ["Display Focus Frame"] = nil, ["Display Group Frames"] = nil, @@ -115,6 +118,7 @@ pfUI_translation["deDE"] = { ["Enable 24h Clock"] = nil, ["Enable 2D Portraits As Fallback"] = nil, ["Enable Action Bar Backgrounds"] = nil, + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = nil, ["Enable Autohide For BarBottomLeft"] = nil, ["Enable Autohide For BarBottomRight"] = nil, @@ -274,9 +278,14 @@ pfUI_translation["deDE"] = { ["Profile"] = nil, ["Raid Icon Size"] = nil, ["Raid"] = nil, + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = nil, ["Remaining"] = nil, ["Reputation"] = nil, + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = nil, ["Rested"] = nil, ["Resting"] = nil, @@ -290,6 +299,7 @@ pfUI_translation["deDE"] = { ["Right Panel: Left"] = nil, ["Right Panel: Right"] = nil, ["Right Text"] = nil, + ["Roll for"] = nil, ["Save current settings to profile"] = nil, ["Save"] = nil, ["Save profile"] = nil, @@ -300,7 +310,10 @@ pfUI_translation["deDE"] = { ["Seconds Until Action Bars Autohide"] = nil, ["Selected Core"] = nil, ["Select profile"] = nil, + ["Self"] = nil, ["Servertime"] = nil, + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = nil, ["Shapeshift Bar (BarShapeShift)"] = nil, ["Shift-Click Action"] = nil, @@ -320,6 +333,7 @@ pfUI_translation["deDE"] = { ["Soulshard Counter"] = nil, ["Soulshards"] = nil, ["Spacing"] = nil, + ["Special Recipient"] = nil, ["Standard Text Font"] = nil, ["Standard Text Font Size"] = nil, ["Status"] = nil, @@ -336,8 +350,8 @@ pfUI_translation["deDE"] = { ["Timestamp Format"] = nil, ["Tooltip"] = nil, ["Tooltip Position"] = nil, - ["Top"] = nil, ["Top Left"] = nil, + ["Top"] = nil, ["Top Right"] = nil, ["UI-Scale"] = nil, ["Unit Frame Border Size"] = nil, diff --git a/env/translations_enUS.lua b/env/translations_enUS.lua index b8cda70d..4970533f 100644 --- a/env/translations_enUS.lua +++ b/env/translations_enUS.lua @@ -22,9 +22,10 @@ pfUI_translation["enUS"] = { ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, ["Bagspace"] = nil, + ["Banker"] = nil, ["Border Color"] = nil, - ["Bottom"] = nil, ["Bottom Left"] = nil, + ["Bottom"] = nil, ["Bottom Right"] = nil, ["Buff Limit"] = nil, ["Buff Position"] = nil, @@ -49,6 +50,7 @@ pfUI_translation["enUS"] = { ["Chat"] = nil, ["Class"] = nil, ["CleanUp"] = nil, + ["Clear Rolls"] = nil, ["Click Action"] = nil, ["Clickcast Spells"] = nil, ["Clock"] = nil, @@ -94,6 +96,7 @@ pfUI_translation["enUS"] = { ["Disable pfUI Player Castbar"] = nil, ["Disable pfUI Target Castbar"] = nil, ["Disable pfUI Unit Frames"] = nil, + ["Disenchanter"] = nil, ["Display Debuff Durations"] = nil, ["Display Focus Frame"] = nil, ["Display Group Frames"] = nil, @@ -115,6 +118,7 @@ pfUI_translation["enUS"] = { ["Enable 24h Clock"] = nil, ["Enable 2D Portraits As Fallback"] = nil, ["Enable Action Bar Backgrounds"] = nil, + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = nil, ["Enable Autohide For BarBottomLeft"] = nil, ["Enable Autohide For BarBottomRight"] = nil, @@ -274,9 +278,14 @@ pfUI_translation["enUS"] = { ["Profile"] = nil, ["Raid Icon Size"] = nil, ["Raid"] = nil, + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = nil, ["Remaining"] = nil, ["Reputation"] = nil, + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = nil, ["Rested"] = nil, ["Resting"] = nil, @@ -290,6 +299,7 @@ pfUI_translation["enUS"] = { ["Right Panel: Left"] = nil, ["Right Panel: Right"] = nil, ["Right Text"] = nil, + ["Roll for"] = nil, ["Save current settings to profile"] = nil, ["Save"] = nil, ["Save profile"] = nil, @@ -300,7 +310,10 @@ pfUI_translation["enUS"] = { ["Seconds Until Action Bars Autohide"] = nil, ["Selected Core"] = nil, ["Select profile"] = nil, + ["Self"] = nil, ["Servertime"] = nil, + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = nil, ["Shapeshift Bar (BarShapeShift)"] = nil, ["Shift-Click Action"] = nil, @@ -320,6 +333,7 @@ pfUI_translation["enUS"] = { ["Soulshard Counter"] = nil, ["Soulshards"] = nil, ["Spacing"] = nil, + ["Special Recipient"] = nil, ["Standard Text Font"] = nil, ["Standard Text Font Size"] = nil, ["Status"] = nil, @@ -336,8 +350,8 @@ pfUI_translation["enUS"] = { ["Timestamp Format"] = nil, ["Tooltip"] = nil, ["Tooltip Position"] = nil, - ["Top"] = nil, ["Top Left"] = nil, + ["Top"] = nil, ["Top Right"] = nil, ["UI-Scale"] = nil, ["Unit Frame Border Size"] = nil, diff --git a/env/translations_esES.lua b/env/translations_esES.lua index 6d8ee525..226b5a28 100644 --- a/env/translations_esES.lua +++ b/env/translations_esES.lua @@ -22,9 +22,10 @@ pfUI_translation["esES"] = { ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, ["Bagspace"] = nil, + ["Banker"] = nil, ["Border Color"] = nil, - ["Bottom"] = nil, ["Bottom Left"] = nil, + ["Bottom"] = nil, ["Bottom Right"] = nil, ["Buff Limit"] = nil, ["Buff Position"] = nil, @@ -49,6 +50,7 @@ pfUI_translation["esES"] = { ["Chat"] = nil, ["Class"] = nil, ["CleanUp"] = nil, + ["Clear Rolls"] = nil, ["Click Action"] = nil, ["Clickcast Spells"] = nil, ["Clock"] = nil, @@ -94,6 +96,7 @@ pfUI_translation["esES"] = { ["Disable pfUI Player Castbar"] = nil, ["Disable pfUI Target Castbar"] = nil, ["Disable pfUI Unit Frames"] = nil, + ["Disenchanter"] = nil, ["Display Debuff Durations"] = nil, ["Display Focus Frame"] = nil, ["Display Group Frames"] = nil, @@ -115,6 +118,7 @@ pfUI_translation["esES"] = { ["Enable 24h Clock"] = nil, ["Enable 2D Portraits As Fallback"] = nil, ["Enable Action Bar Backgrounds"] = nil, + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = nil, ["Enable Autohide For BarBottomLeft"] = nil, ["Enable Autohide For BarBottomRight"] = nil, @@ -274,9 +278,14 @@ pfUI_translation["esES"] = { ["Profile"] = nil, ["Raid Icon Size"] = nil, ["Raid"] = nil, + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = nil, ["Remaining"] = nil, ["Reputation"] = nil, + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = nil, ["Rested"] = nil, ["Resting"] = nil, @@ -290,6 +299,7 @@ pfUI_translation["esES"] = { ["Right Panel: Left"] = nil, ["Right Panel: Right"] = nil, ["Right Text"] = nil, + ["Roll for"] = nil, ["Save current settings to profile"] = nil, ["Save"] = nil, ["Save profile"] = nil, @@ -300,7 +310,10 @@ pfUI_translation["esES"] = { ["Seconds Until Action Bars Autohide"] = nil, ["Selected Core"] = nil, ["Select profile"] = nil, + ["Self"] = nil, ["Servertime"] = nil, + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = nil, ["Shapeshift Bar (BarShapeShift)"] = nil, ["Shift-Click Action"] = nil, @@ -320,6 +333,7 @@ pfUI_translation["esES"] = { ["Soulshard Counter"] = nil, ["Soulshards"] = nil, ["Spacing"] = nil, + ["Special Recipient"] = nil, ["Standard Text Font"] = nil, ["Standard Text Font Size"] = nil, ["Status"] = nil, @@ -336,8 +350,8 @@ pfUI_translation["esES"] = { ["Timestamp Format"] = nil, ["Tooltip"] = nil, ["Tooltip Position"] = nil, - ["Top"] = nil, ["Top Left"] = nil, + ["Top"] = nil, ["Top Right"] = nil, ["UI-Scale"] = nil, ["Unit Frame Border Size"] = nil, diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 646ff441..8bca009f 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -22,6 +22,7 @@ pfUI_translation["frFR"] = { ["Bags & Bank"] = "Sacs et Banque", ["Bags Border Size"] = "Taille de la bordure des Sacs", ["Bagspace"] = "Place libre des sacs", + ["Banker"] = nil, ["Border Color"] = "Couleur de la bordure", ["Bottom"] = "Bas", ["Bottom Left"] = nil, @@ -49,6 +50,7 @@ pfUI_translation["frFR"] = { ["Chat"] = "Chat", ["Class"] = "Classe", ["CleanUp"] = "CleanUp", + ["Clear Rolls"] = nil, ["Click Action"] = "Action au clic", ["Clickcast Spells"] = "Sorts à lancer au clic", ["Clock"] = "Horloge", @@ -94,6 +96,7 @@ pfUI_translation["frFR"] = { ["Disable pfUI Player Castbar"] = "Désactiver la barre d'incantation pfUI", ["Disable pfUI Target Castbar"] = "Désactiver la barre d'incantation de la cible pfUI", ["Disable pfUI Unit Frames"] = "Désactiver les cadres d'unité pfUI", + ["Disenchanter"] = nil, ["Display Debuff Durations"] = "Afficher la durée des débuff", ["Display Focus Frame"] = "Afficher le cadre de focus", ["Display Group Frames"] = "Afficher le cadre de groupe", @@ -115,6 +118,7 @@ pfUI_translation["frFR"] = { ["Enable 24h Clock"] = "Activer le format 24 heures de l'horloge", ["Enable 2D Portraits As Fallback"] = "Afficher les portraits 2D en arrière-plan", ["Enable Action Bar Backgrounds"] = "Afficher l'arrière-plan des barres d'action", + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = "Activer le masquage automatique de la barre d'action principale (hors combat)", ["Enable Autohide For BarBottomLeft"] = "Activer le masquage automatique de la barre d'action en bas gauche (hors combat)", ["Enable Autohide For BarBottomRight"] = "Activer le masquage automatique de la barre d'action en bas droite (hors combat)", @@ -274,9 +278,14 @@ pfUI_translation["frFR"] = { ["Profile"] = "Profil", ["Raid Icon Size"] = "Taille des icônes de Raid", ["Raid"] = "Raid", + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = "Couleur de la portée affichée", ["Remaining"] = "Restant", ["Reputation"] = "Réputation", + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = "Redémarrage du Timer", ["Rested"] = "Reposé", ["Resting"] = "Au Repos", @@ -290,6 +299,7 @@ pfUI_translation["frFR"] = { ["Right Panel: Left"] = "Panneau de droite : texte de gauche", ["Right Panel: Right"] = "Panneau de droite : texte de droite", ["Right Text"] = "Texte de droite", + ["Roll for"] = nil, ["Save current settings to profile"] = "Enregistrer les paramètres actuels au profil", ["Save profile"] = "Enregistrer un profil", ["Save"] = "Sauvegarder", @@ -300,7 +310,10 @@ pfUI_translation["frFR"] = { ["Seconds Until Action Bars Autohide"] = "Secondes avant le masquage des barres d'actions", ["Selected Core"] = "Core Sélectionné", ["Select profile"] = "Choisir un profil", + ["Self"] = nil, ["Servertime"] = "Heure server", + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = "Options", ["Shapeshift Bar (BarShapeShift)"] = "Barre des changements formes", ["Shift-Click Action"] = "Action au Shift+Clic", @@ -320,6 +333,7 @@ pfUI_translation["frFR"] = { ["Soulshard Counter"] = "Compteur des éclats d'âme", ["Soulshards"] = "Pierre d'âme", ["Spacing"] = "Espacement", + ["Special Recipient"] = nil, ["Standard Text Font"] = "Police standard du texte", ["Standard Text Font Size"] = "Taille de la police standard du texte", ["Status"] = "Statut", diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 0f3568ff..d446a18d 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -22,6 +22,7 @@ pfUI_translation["koKR"] = { ["Bags & Bank"] = "가방&은행", ["Bags Border Size"] = "가방 테두리 크기", ["Bagspace"] = "가방 공간", + ["Banker"] = nil, ["Border Color"] = "테두리 색상", ["Bottom"] = "아래", ["Bottom Left"] = nil, @@ -49,6 +50,7 @@ pfUI_translation["koKR"] = { ["Chat Border Size"] = "채팅 테두리 크기", ["Class"] = "클래스(직업)", ["CleanUp"] = "CleanUp(가방&은행 자동정렬)", + ["Clear Rolls"] = nil, ["Click Action"] = "클릭 액션", ["Clickcast Spells"] = "스펠 클릭캐스트", ["Clock"] = "시계", @@ -94,6 +96,7 @@ pfUI_translation["koKR"] = { ["Disable pfUI Player Castbar"] = "pfUI 플레이어 캐스트바 비활성화", ["Disable pfUI Target Castbar"] = "pfUI 대상 캐스트바 비활성화", ["Disable pfUI Unit Frames"] = "pfUI 유닛프레임 비활성화", + ["Disenchanter"] = nil, ["Display Debuff Durations"] = "디버프 지속 시간 표시", ["Display Focus Frame"] = "주시대상 프레임 표시", ["Display Group Frames"] = "파티 프레임 표시", @@ -115,6 +118,7 @@ pfUI_translation["koKR"] = { ["Enable 24h Clock"] = "24시간 시계 활성화", ["Enable 2D Portraits As Fallback"] = "2D 초상화를 배경 활성화", ["Enable Action Bar Backgrounds"] = "액션바 배경 활성화", + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = "메인액션바 자동 숨기기 표시", ["Enable Autohide For BarBottomLeft"] = "왼쪽하단바 자동 숨기기 표시", ["Enable Autohide For BarBottomRight"] = "오른쪽하단바 자동 숨기기 표시", @@ -274,9 +278,14 @@ pfUI_translation["koKR"] = { ["Profile"] = "프로파일", ["Raid"] = "레이드", ["Raid Icon Size"] = "레이드 아이콘 크기", + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = "스킬 거리 색상 표시", ["Remaining"] = "남은 경험치", ["Reputation"] = "평판", + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = "타이머 재설정", ["Rested"] = "휴식 경험치", ["Resting"] = "휴식", @@ -290,6 +299,7 @@ pfUI_translation["koKR"] = { ["Right Panel: Left"] = "오른쪽 패널:좌측", ["Right Panel: Right"] = "오른쪽 패널:우측", ["Right Text"] = "오른쪽 텍스트", + ["Roll for"] = nil, ["Save"] = "저장", ["Save current settings to profile"] = "현재 설정을 프로필에 저장", ["Save profile"] = "프로파일 저장", @@ -300,7 +310,10 @@ pfUI_translation["koKR"] = { ["Seconds Until Action Bars Autohide"] = "액션바 자동 숨길때까지의 시간(초)", ["Selected Core"] = "선택된 코어", ["Select profile"] = "프로파일 선택", + ["Self"] = nil, ["Servertime"] = "서버타임", + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = "설정", ["Shapeshift Bar (BarShapeShift)"] = "태새바(BarShapeShift)", ["Shift-Click Action"] = "쉬프트-클릭 액션", @@ -320,6 +333,7 @@ pfUI_translation["koKR"] = { ["Soulshard Counter"] = "영혼조각 갯수", ["Soulshards"] = "영혼의 조각", ["Spacing"] = "간격", + ["Special Recipient"] = nil, ["Standard Text Font"] = "기본 텍스트 폰트", ["Standard Text Font Size"] = "기본 텍스트 폰트크기", ["Status"] = "상태", diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index 7a219f57..463b5c13 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -22,10 +22,11 @@ pfUI_translation["ruRU"] = { ["Bags & Bank"] = "Сумки & Банк", ["Bags Border Size"] = "Размер бордюра сумок", ["Bagspace"] = "Место в сумках", + ["Banker"] = nil, ["Border Color"] = "Цвет бордюра", - ["Bottom"] = "Снизу", ["Bottom Left"] = nil, ["Bottom Right"] = nil, + ["Bottom"] = "Снизу", ["Buff Limit"] = "Предел баффов", ["Buff Position"] = "Расположение баффов", ["Buff Size"] = "Размер баффов", @@ -49,6 +50,7 @@ pfUI_translation["ruRU"] = { ["Chat"] = "Чат", ["Class"] = "Класс", ["CleanUp"] = nil, + ["Clear Rolls"] = nil, ["Click Action"] = "Действие при нажатии", ["Clickcast Spells"] = "Произнесение заклинаний по нажатию", ["Clock"] = "Часы", @@ -94,6 +96,7 @@ pfUI_translation["ruRU"] = { ["Disable pfUI Target Castbar"] = "Отключить панель применения pfUI цели", ["Disable pfUI Unit Frames"] = "Отключить окна юнита pfUI", ["Disable"] = "Отключить", + ["Disenchanter"] = nil, ["Display Debuff Durations"] = "Отобразить длительность дебаффов", ["Display Focus Frame"] = "Отобразить окно фокуса", ["Display Group Frames"] = "Отобразить окно группы", @@ -115,6 +118,7 @@ pfUI_translation["ruRU"] = { ["Enable 24h Clock"] = "Включить 24-часовой формат", ["Enable 2D Portraits As Fallback"] = "Включить 2D-портреты как резервные", ["Enable Action Bar Backgrounds"] = "Включить фон панели действий", + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = "Включить автоматическое скрытие для основной панели действий", ["Enable Autohide For BarBottomLeft"] = "Включить автоматическое скрытие для нижней левой панели", ["Enable Autohide For BarBottomRight"] = "Включить автоматическое скрытие для нижней правой панели", @@ -274,9 +278,14 @@ pfUI_translation["ruRU"] = { ["Profile"] = "Профиль", ["Raid Icon Size"] = "Размер иконки рейда", ["Raid"] = "Рейд", + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = "Цвет отображения диапазона", ["Remaining"] = "Осталось", ["Reputation"] = "Репутация", + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = "Сбросить таймер", ["Rested"] = "Отдохнувший", ["Resting"] = "Отдыхающий", @@ -290,6 +299,7 @@ pfUI_translation["ruRU"] = { ["Right Panel: Right"] = "Правая панель: справа", ["Right Text"] = "Текст справа", ["Right"] = "Справа", + ["Roll for"] = nil, ["Save current settings to profile"] = "Сохранить текущие настройки в профиле", ["Save profile"] = "Сохранить профиль", ["Save"] = "Сохранить", @@ -300,7 +310,10 @@ pfUI_translation["ruRU"] = { ["Seconds Until Action Bars Autohide"] = "Время до автоматического скрытия панелей действий (в секундах)", ["Selected Core"] = "Выбранное ядро", ["Select profile"] = "Выбрать профиль", + ["Self"] = nil, ["Servertime"] = "Серверное время", + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = "Настройки", ["Shapeshift Bar (BarShapeShift)"] = "Панель стоек (BarShapeShift)", ["Shift-Click Action"] = "Действие при Shift+нажатие", @@ -320,6 +333,7 @@ pfUI_translation["ruRU"] = { ["Soulshard Counter"] = "Счетчик камней душ", ["Soulshards"] = "Камни душ", ["Spacing"] = "Расстояние", + ["Special Recipient"] = nil, ["Standard Text Font Size"] = "Размер шрифта стандартного текста", ["Standard Text Font"] = "Шрифт стандартного текста", ["Status"] = "Статус", @@ -336,9 +350,9 @@ pfUI_translation["ruRU"] = { ["Time"] = "Время", ["Tooltip Position"] = "Расположение подсказки", ["Tooltip"] = "Подсказка", - ["Top"] = "Сверху", ["Top Left"] = nil, ["Top Right"] = nil, + ["Top"] = "Сверху", ["UI-Scale"] = "Масштаб UI", ["Unit Frame Border Size"] = "Размер бордюра окна юнита", ["Unit Frame Layout"] = "Макет окна юнита", diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index 5a70366a..54e7f54d 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -22,10 +22,11 @@ pfUI_translation["zhCN"] = { ["Bags & Bank"] = "背包和银行", ["Bags Border Size"] = "背包边框大小", ["Bagspace"] = "背包空间", + ["Banker"] = nil, ["Border Color"] = "边框颜色", - ["Bottom"] = "底部", ["Bottom Left"] = nil, ["Bottom Right"] = nil, + ["Bottom"] = "底部", ["Buff Limit"] = "Buff总数量", ["Buff Position"] = "Buff显示的位置", ["Buff Size"] = "Buff图标大小", @@ -49,6 +50,7 @@ pfUI_translation["zhCN"] = { ["Chat"] = "聊天窗口", ["Class"] = "职业", ["CleanUp"] = "CleanUp", + ["Clear Rolls"] = nil, ["Click Action"] = "点击操作", ["Clickcast Spells"] = "点击施法", ["Clock"] = "时间", @@ -94,6 +96,7 @@ pfUI_translation["zhCN"] = { ["Disable pfUI Target Castbar"] = "隐藏目标施法条", ["Disable pfUI Unit Frames"] = "禁用头像框架", ["Disable"] = "禁用", + ["Disenchanter"] = nil, ["Display Debuff Durations"] = "显示Debuff持续时间", ["Display Focus Frame"] = "启用焦点目标模块", ["Display Group Frames"] = "启用小队模块", @@ -115,6 +118,7 @@ pfUI_translation["zhCN"] = { ["Enable 24h Clock"] = "启用24小时制式", ["Enable 2D Portraits As Fallback"] = "启动2D头像备用", ["Enable Action Bar Backgrounds"] = "启用动作条背景", + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = "自动隐藏主动作条", ["Enable Autohide For BarBottomLeft"] = "自动隐藏左下动作条", ["Enable Autohide For BarBottomRight"] = "自动隐藏右下动作条", @@ -274,9 +278,14 @@ pfUI_translation["zhCN"] = { ["Profile"] = "配置文件", ["Raid Icon Size"] = "团队图标大小", ["Raid"] = "团队", + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = "技能使用距离超限颜色", ["Remaining"] = "升级经验", ["Reputation"] = "声望", + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = "重置定时器", ["Rested"] = "精力充沛", ["Resting"] = "休息中", @@ -290,6 +299,7 @@ pfUI_translation["zhCN"] = { ["Right Panel: Right"] = "右侧面板:右侧", ["Right Text"] = "右侧文字", ["Right"] = "右边", + ["Roll for"] = nil, ["Save current settings to profile"] = "将当前设置保存到配置文件", ["Save profile"] = "保存配置", ["Save"] = "保存", @@ -300,7 +310,10 @@ pfUI_translation["zhCN"] = { ["Seconds Until Action Bars Autohide"] = "自动隐藏动作条延时", ["Selected Core"] = "选择游戏核心", ["Select profile"] = "选择配置", + ["Self"] = nil, ["Servertime"] = "服务器时间", + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = "默认设置", ["Shapeshift Bar (BarShapeShift)"] = "姿态条", ["Shift-Click Action"] = "SHIFT点击操作", @@ -320,6 +333,7 @@ pfUI_translation["zhCN"] = { ["Soulshard Counter"] = "灵魂碎片", ["Soulshards"] = "灵魂碎片", ["Spacing"] = "血条能量条间隔", + ["Special Recipient"] = nil, ["Standard Text Font Size"] = "标准字体字号", ["Standard Text Font"] = "标准字体", ["Status"] = "当前状态", @@ -336,9 +350,9 @@ pfUI_translation["zhCN"] = { ["Time"] = "计时器", ["Tooltip Position"] = "鼠标提示框位置", ["Tooltip"] = "鼠标提示框", - ["Top"] = "顶部", ["Top Left"] = nil, ["Top Right"] = nil, + ["Top"] = "顶部", ["UI-Scale"] = "UI缩放比例", ["Unit Frame Border Size"] = "头像边框大小", ["Unit Frame Layout"] = "头像框架样式", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index df28cd6f..1ede001d 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -22,10 +22,11 @@ pfUI_translation["zhTW"] = { ["Bags & Bank"] = "背包和銀行", ["Bags Border Size"] = "背包邊框大小", ["Bagspace"] = "背包空間", + ["Banker"] = nil, ["Border Color"] = "邊框顏色", - ["Bottom"] = "底部", ["Bottom Left"] = nil, ["Bottom Right"] = nil, + ["Bottom"] = "底部", ["Buff Limit"] = "Buff總數量", ["Buff Position"] = "Buff顯示的位置", ["Buff Size"] = "Buff圖示大小", @@ -49,6 +50,7 @@ pfUI_translation["zhTW"] = { ["Chat"] = "聊天窗口", ["Class"] = "職業", ["CleanUp"] = "CleanUp", + ["Clear Rolls"] = nil, ["Click Action"] = "點擊操作", ["Clickcast Spells"] = "點擊施法", ["Clock"] = "時間", @@ -94,6 +96,7 @@ pfUI_translation["zhTW"] = { ["Disable pfUI Target Castbar"] = "隱藏目標施法條", ["Disable pfUI Unit Frames"] = "禁用頭像框架", ["Disable"] = "禁用", + ["Disenchanter"] = nil, ["Display Debuff Durations"] = "顯示Debuff持續時間", ["Display Focus Frame"] = "啟用焦點目的模組", ["Display Group Frames"] = "啟用小隊模組", @@ -115,6 +118,7 @@ pfUI_translation["zhTW"] = { ["Enable 24h Clock"] = "啟用24小時制式", ["Enable 2D Portraits As Fallback"] = "啟動2D頭像備用", ["Enable Action Bar Backgrounds"] = "啟用動作條背景", + ["Enable Advanced Master Loot Menu"] = nil, ["Enable Autohide For BarActionMain"] = "自動隱藏主動作條", ["Enable Autohide For BarBottomLeft"] = "自動隱藏左下動作條", ["Enable Autohide For BarBottomRight"] = "自動隱藏右下動作條", @@ -274,9 +278,14 @@ pfUI_translation["zhTW"] = { ["Profile"] = "設定檔", ["Raid Icon Size"] = "團隊圖示大小", ["Raid"] = "團隊", + ["Random"] = nil, + ["Random Rolling "] = nil, ["Range Display Color"] = "技能使用距離超限顏色", ["Remaining"] = "升級經驗", ["Reputation"] = "聲望", + ["Request Rolls"] = nil, + ["Reroll"] = nil, + ["Reroll Ties"] = nil, ["Reset Timer"] = "重置計時器", ["Rested"] = "精力充沛", ["Resting"] = "休息中", @@ -290,6 +299,7 @@ pfUI_translation["zhTW"] = { ["Right Panel: Right"] = "右側面板:右側", ["Right Text"] = "右側文字", ["Right"] = "右邊", + ["Roll for"] = nil, ["Save current settings to profile"] = "將當前設置保存到設定檔", ["Save profile"] = "保存配置", ["Save"] = "保存", @@ -300,7 +310,10 @@ pfUI_translation["zhTW"] = { ["Seconds Until Action Bars Autohide"] = "自動隱藏動作條延時", ["Selected Core"] = "選擇遊戲核心", ["Select profile"] = "選擇配置", + ["Self"] = nil, ["Servertime"] = "伺服器時間", + ["Set Banker"] = nil, + ["Set Disenchanter"] = nil, ["Settings"] = "默認設置", ["Shapeshift Bar (BarShapeShift)"] = "姿態條", ["Shift-Click Action"] = "SHIFT點擊操作", @@ -320,6 +333,7 @@ pfUI_translation["zhTW"] = { ["Soulshard Counter"] = "靈魂碎片", ["Soulshards"] = "靈魂碎片", ["Spacing"] = "血條能量條間隔", + ["Special Recipient"] = nil, ["Standard Text Font Size"] = "標準字體字型大小", ["Standard Text Font"] = "標準字體", ["Status"] = "當前狀態", @@ -336,9 +350,9 @@ pfUI_translation["zhTW"] = { ["Time"] = "計時器", ["Tooltip Position"] = "滑鼠提示框位置", ["Tooltip"] = "滑鼠提示框", - ["Top"] = "頂部", ["Top Left"] = nil, ["Top Right"] = nil, + ["Top"] = "頂部", ["UI-Scale"] = "UI縮放比例", ["Unit Frame Border Size"] = "頭像邊框大小", ["Unit Frame Layout"] = "頭像框架樣式", diff --git a/modules/gui.lua b/modules/gui.lua index 0bbbfd82..e3c9ab05 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1121,6 +1121,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Enable Auto-Resize Loot Frame"], C.loot, "autoresize", "checkbox") CreateConfig(this, T["Disable Loot Confirmation Dialog (Without Group)"], C.loot, "autopickup", "checkbox") CreateConfig(this, T["Enable Loot Window On MouseCursor"], C.loot, "mousecursor", "checkbox") + CreateConfig(this, T["Enable Advanced Master Loot Menu"], C.loot, "advancedmasterloot", "checkbox") this.setup = true end end) diff --git a/modules/loot.lua b/modules/loot.lua index 18137b05..160fd7fc 100644 --- a/modules/loot.lua +++ b/modules/loot.lua @@ -17,6 +17,378 @@ pfUI:RegisterModule("loot", function () UpdateMovable(pfUI.loot) end + pfUI.loot.unitbuttons = { + ["PF_BANKLOOTER"] = {T["Set Banker"],"bankLooter"}, + ["PF_DISENCHANTLOOTER"] = {T["Set Disenchanter"],"disenchantLooter"}, + } + pfUI.loot.rollCapture = SanitizePattern(RANDOM_ROLL_RESULT) + pfUI.loot.me = (UnitName("player")) + pfUI.loot.index_to_name = {} + pfUI.loot.name_to_index = {} + pfUI.loot.classes_in_raid = {} + pfUI.loot.players_in_class = {} + pfUI.loot.randoms = {} + pfUI.loot.rollers = {} + pfUI.loot.rollers_sorted = {} + pfUI.loot.info = {} + local info = pfUI.loot.info + + function pfUI.loot.RaidRoll(candidates) + if type(candidates) ~= "table" then return end + local slot = pfUI.loot.selectedSlot or 0 + local to = table.getn(candidates) + if to >= 1 then + SendChatMessageWide(T["Random Rolling "]..GetLootSlotLink(slot)) + local k,names = 1, "" + for i=1,to do + names = (k==1) and (i..":"..pfUI.loot.index_to_name[candidates[i]]) or (names..", "..i..":"..pfUI.loot.index_to_name[candidates[i]]) + -- fit the maximum names in a single 255 char message (15) + if i == to or k == 15 then + QueueFunction(SendChatMessageWide,names) + names = "" + end + k = k<15 and k+1 or 1 + end + pfUI.loot:RegisterEvent("CHAT_MSG_SYSTEM") + pfUI.loot.randomRolling = true + QueueFunction(RandomRoll,"1",tostring(to)) + end + end + + function pfUI.loot.RequestRolls() + local slot = pfUI.loot.selectedSlot or 0 + local rollers = wipe(pfUI.loot.rollers) + local rollers_sorted = wipe(pfUI.loot.rollers_sorted) + SendChatMessageWide(T["Roll for"].. " " .. GetLootSlotLink(slot)) + pfUI.loot:RegisterEvent("CHAT_MSG_SYSTEM") + pfUI.loot.monitorRolling = true + UIDropDownMenu_Refresh(GroupLootDropDown) + end + + function pfUI.loot:BuildSpecialRecipientsMenu(level) + local slot = pfUI.loot.selectedSlot or 0 + if level == 1 then + if pfUI.loot.my_index or pfUI.loot.disenchanter_index or pfUI.loot.banker_index then + info = wipe(info) + info.text = T["Special Recipient"] + info.textR = NORMAL_FONT_COLOR.r + info.textG = NORMAL_FONT_COLOR.g + info.textB = NORMAL_FONT_COLOR.b + info.textHeight = 12 + info.hasArrow = 1 + info.notCheckable = 1 + info.value = "PFRECIPIENTS" + info.func = nil + UIDropDownMenu_AddButton(info) + end + elseif level == 2 then + if UIDROPDOWNMENU_MENU_VALUE == "PFRECIPIENTS" then + if (pfUI.loot.my_index) then + info = wipe(info) + info.text = T["Self"] + info.textHeight = 12 + info.value = pfUI.loot.my_index + info.func = GroupLootDropDown_GiveLoot + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + end + if (pfUI.loot.disenchanter_index) then + info = wipe(info) + info.text = T["Disenchanter"] + info.textHeight = 12 + info.value = pfUI.loot.disenchanter_index + info.func = GroupLootDropDown_GiveLoot + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + end + if (pfUI.loot.banker_index) then + info = wipe(info) + info.text = T["Banker"] + info.textHeight = 12 + info.value = pfUI.loot.banker_index + info.func = GroupLootDropDown_GiveLoot + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + end + end + end + end + + function pfUI.loot.ClearRolls() + wipe(pfUI.loot.rollers) + wipe(pfUI.loot.rollers_sorted) + pfUI.loot.monitorRolling = nil + UIDropDownMenu_Refresh(GroupLootDropDown) + end + + function pfUI.loot.CallTieRoll(rollers) + if type(rollers) ~= "table" then return end + local highroll + local ties = {} + local num_rollers = table.getn(rollers) + for i=1,num_rollers do + if rollers[i].value ~= "disabled" then + if highroll == nil then + highroll = rollers[i].roll + table.insert(ties,rollers[i]) + elseif rollers[i].roll == highroll then + table.insert(ties,rollers[i]) + end + end + end + local num_ties = table.getn(ties) + if num_ties > 1 then + local names = "" + for i=1, num_ties do + names = i==1 and (names..ties[i].who) or (names..", "..ties[i].who) + end + pfUI.loot:ClearRolls() + SendChatMessageWide(names.." "..T["Reroll"]) + pfUI.loot:RegisterEvent("CHAT_MSG_SYSTEM") + pfUI.loot.monitorRolling = true + end + UIDropDownMenu_Refresh(GroupLootDropDown) + end + + function pfUI.loot:BuildSpecialRollsMenu(level) + local slot = pfUI.loot.selectedSlot or 0 + if level == 1 then + info = wipe(info) + info.text = T["Random"] + info.textR = NORMAL_FONT_COLOR.r + info.textG = NORMAL_FONT_COLOR.g + info.textB = NORMAL_FONT_COLOR.b + info.value = "PFRANDOM" + info.textHeight = 12 + info.notCheckable = 1 + info.arg1 = pfUI.loot.randoms + info.func = pfUI.loot.RaidRoll + UIDropDownMenu_AddButton(info) + + info = wipe(info) + info.text = T["Request Rolls"] + info.textR = NORMAL_FONT_COLOR.r + info.textG = NORMAL_FONT_COLOR.g + info.textB = NORMAL_FONT_COLOR.b + info.value = "PFROLLS" + info.textHeight = 12 + info.hasArrow = 1 + info.notCheckable = 1 + info.func = pfUI.loot.RequestRolls + UIDropDownMenu_AddButton(info) + elseif level == 2 then + if UIDROPDOWNMENU_MENU_VALUE == "PFROLLS" then + info = wipe(info) + info.text = T["Clear Rolls"] + info.textR = NORMAL_FONT_COLOR.r + info.textG = NORMAL_FONT_COLOR.g + info.textB = NORMAL_FONT_COLOR.b + info.value = "PFCLEARROLLS" + info.notCheckable = 1 + info.func = pfUI.loot.ClearRolls + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + + info = wipe(info) + info.text = T["Reroll Ties"] + info.textR = NORMAL_FONT_COLOR.r + info.textG = NORMAL_FONT_COLOR.g + info.textB = NORMAL_FONT_COLOR.b + info.value = "PFTIEROLL" + info.notCheckable = 1 + info.arg1 = pfUI.loot.rollers_sorted + info.func = pfUI.loot.CallTieRoll + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + for _,roller in ipairs(pfUI.loot.rollers_sorted) do + info = wipe(info) + info.text = string.format("%02d - %s",roller.roll,roller.who) + info.textHeight = 12 + if roller.value == "disabled" then + info.disabled = 1 + info.value = "disabled" + else + info.value = roller.value + info.func = GroupLootDropDown_GiveLoot + end + info.notCheckable = 1 + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + end + end + end + end + + function pfUI.loot:BuildRaidMenu(level) + local slot = pfUI.loot.selectedSlot or 0 + local index_to_name = wipe(pfUI.loot.index_to_name) + local name_to_index = wipe(pfUI.loot.name_to_index) + local classes_in_raid = wipe(pfUI.loot.classes_in_raid) -- [global class]=localized class for display + local players_in_class = wipe(pfUI.loot.players_in_class) + local randoms = wipe(pfUI.loot.randoms) + pfUI.loot.my_index = false + pfUI.loot.disenchanter_index = false + pfUI.loot.banker_index = false + local disenchantLooter = pfUI.loot.disenchantLooter or "" + local bankLooter = pfUI.loot.bankLooter or "" + for i = 1, MAX_RAID_MEMBERS do -- masterlootcandidate index does not correspond with unit id index + local candidate = GetMasterLootCandidate(i) + if (candidate) then + index_to_name[i] = candidate + name_to_index[candidate] = i + randoms[table.getn(randoms)+1]=i + if candidate == pfUI.loot.me then + pfUI.loot.my_index = i + end + if candidate == disenchantLooter then + pfUI.loot.disenchanter_index = i + end + if candidate == bankLooter then + pfUI.loot.banker_index = i + end + local unit = GroupInfoByName(candidate,"raid") + classes_in_raid[unit.class] = unit.lclass + if players_in_class[unit.class] == nil then players_in_class[unit.class] = {} end + table.insert(players_in_class[unit.class],candidate) + end + end + if level == 1 then -- classes + info = wipe(info) + info.text = GIVE_LOOT + info.textHeight = 12 + info.notCheckable = 1 + info.isTitle = 1 + UIDropDownMenu_AddButton(info) + for order, class in ipairs(CLASS_SORT_ORDER) do + local lclass = classes_in_raid[class] + if (lclass) then + info = wipe(info) + info.text = lclass + info.textR = RAID_CLASS_COLORS[class].r + info.textG = RAID_CLASS_COLORS[class].g + info.textB = RAID_CLASS_COLORS[class].b + info.textHeight = 12 + info.hasArrow = 1 + info.notCheckable = 1 + info.value = class + info.func = nil + UIDropDownMenu_AddButton(info) + end + end + pfUI.loot:BuildSpecialRecipientsMenu(UIDROPDOWNMENU_MENU_LEVEL) + pfUI.loot:BuildSpecialRollsMenu(UIDROPDOWNMENU_MENU_LEVEL) + elseif level == 2 then -- players + local players = players_in_class[UIDROPDOWNMENU_MENU_VALUE] + if (players) and next(players) then + table.sort(players) + for _, candidate in ipairs(players) do + info = wipe(info) + info.text = candidate + info.textR = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].r + info.textG = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].g + info.textB = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].b + info.textHeight = 12 + info.value = name_to_index[candidate] + info.func = GroupLootDropDown_GiveLoot + UIDropDownMenu_AddButton(info,UIDROPDOWNMENU_MENU_LEVEL) + end + end + pfUI.loot:BuildSpecialRecipientsMenu(UIDROPDOWNMENU_MENU_LEVEL) + pfUI.loot:BuildSpecialRollsMenu(UIDROPDOWNMENU_MENU_LEVEL) + end + end + + function pfUI.loot:BuildPartyMenu(level) + local slot = pfUI.loot.selectedSlot or 0 + if level == 1 then + for i=1, MAX_PARTY_MEMBERS+1, 1 do + local candidate = GetMasterLootCandidate(i) + if (candidate) then + info = wipe(info) + local unit = GroupInfoByName(candidate,"party") + info.text = candidate + info.textR = RAID_CLASS_COLORS[unit.class].r + info.textG = RAID_CLASS_COLORS[unit.class].g + info.textB = RAID_CLASS_COLORS[unit.class].b + info.textHeight = 12 + info.value = i + info.func = GroupLootDropDown_GiveLoot + UIDropDownMenu_AddButton(info) + end + end + end + end + + function pfUI.loot:InitGroupDropDown() + local inRaid = UnitInRaid("player") + if UIDROPDOWNMENU_MENU_LEVEL == 1 then + if ( inRaid ) then + pfUI.loot:BuildRaidMenu(UIDROPDOWNMENU_MENU_LEVEL) + else + pfUI.loot:BuildPartyMenu(UIDROPDOWNMENU_MENU_LEVEL) + end + elseif UIDROPDOWNMENU_MENU_LEVEL == 2 and (inRaid) then + pfUI.loot:BuildRaidMenu(UIDROPDOWNMENU_MENU_LEVEL) + end + end + + function pfUI.loot:AddMasterLootMenus() + for index,value in ipairs(UnitPopupMenus["SELF"]) do + if value == "LOOT_PROMOTE" then + table.insert(UnitPopupMenus["SELF"],index+1,"PF_BANKLOOTER") + table.insert(UnitPopupMenus["SELF"],index+1,"PF_DISENCHANTLOOTER") + end + end + for index,value in ipairs(UnitPopupMenus["PARTY"]) do + if value == "LOOT_PROMOTE" then + table.insert(UnitPopupMenus["PARTY"],index+1,"PF_BANKLOOTER") + table.insert(UnitPopupMenus["PARTY"],index+1,"PF_DISENCHANTLOOTER") + end + end + end + + function pfUI.loot:RemoveMasterlootMenus() + for index = table.getn(UnitPopupMenus["SELF"]),1,-1 do + if UnitPopupMenus["SELF"][index] == "PF_BANKLOOTER" or UnitPopupMenus["SELF"][index] == "PF_DISENCHANTLOOTER" then + table.remove(UnitPopupMenus["SELF"],index,value) + end + end + for index = table.getn(UnitPopupMenus["PARTY"]),1,-1 do + if UnitPopupMenus["PARTY"][index] == "PF_BANKLOOTER" or UnitPopupMenus["PARTY"][index] == "PF_DISENCHANTLOOTER" then + table.remove(UnitPopupMenus["PARTY"],index,value) + end + end + end + + if C.loot.advancedloot == "1" then + UIDropDownMenu_Initialize(GroupLootDropDown, pfUI.loot.InitGroupDropDown, "MENU") + for button, data in pairs(pfUI.loot.unitbuttons) do + UnitPopupButtons[button] = { text = data[1], dist = 0} + end + pfUI.loot:RemoveMasterlootMenus() -- remove then add to ensure no duplicate menus + pfUI.loot:AddMasterLootMenus() + hooksecurefunc("UnitPopup_OnClick",function() + local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU) + local button = this.value + local unit = dropdownFrame.unit + local name = dropdownFrame.name + if button and pfUI.loot.unitbuttons[button] then + if name then + -- resolves to pfUI.loot.bankLooter|disenchantLooter = name + pfUI.loot[pfUI.loot.unitbuttons[button][2]] = name + end + end + end) + hooksecurefunc("UnitPopup_HideButtons",function() + local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU) + for index,value in pairs(UnitPopupMenus[dropdownFrame.which]) do + if pfUI.loot.unitbuttons[value] then + local method, lootmasterID = GetLootMethod() + if not (method == "master" and lootmasterID == 0) then + UnitPopupShown[index] = 0 + end + end + end + end) + else + pfUI.loot:RemoveMasterlootMenus() + UIDropDownMenu_Initialize(GroupLootDropDown, GroupLootDropDown_Initialize, "MENU") + end + pfUI.loot.slots = {} function pfUI.loot:UpdateLootFrame() local maxrarity, maxwidth = 0, 0 @@ -113,6 +485,9 @@ pfUI:RegisterModule("loot", function () pfUI.loot.selectedSlot = this:GetID() pfUI.loot.selectedQuality = this.quality pfUI.loot.selectedItemName = this.name:GetText() + LootFrame.selectedSlot = pfUI.loot.selectedSlot + LootFrame.selectedQuality = pfUI.loot.selectedQuality + LootFrame.selectedItemName = pfUI.loot.selectedItemName end) frame:SetScript("OnEnter", function() @@ -230,6 +605,36 @@ pfUI:RegisterModule("loot", function () end end + if event == "CHAT_MSG_SYSTEM" then + -- random rolling, check for our own roll + if pfUI.loot.randomRolling ~= nil then + local _, _, who, roll, from, to = string.find(arg1, pfUI.loot.rollCapture) + if (who) and who == pfUI.loot.me then + local winner = tonumber(roll) + GiveMasterLoot(pfUI.loot.selectedSlot, pfUI.loot.randoms[winner]) + end + pfUI.loot.randomRolling = nil + end + -- collecting rolls from raid, discard duplicates and 'cheating' + if pfUI.loot.monitorRolling ~= nil then + local _, _, who, roll, from, to = string.find(arg1, pfUI.loot.rollCapture) + if (who) and not pfUI.loot.rollers[who] then + if tonumber(from)==1 and tonumber(to)==100 then + if pfUI.loot.name_to_index[who] ~= nil then + pfUI.loot.rollers[who] = {roll=tonumber(roll),value=pfUI.loot.name_to_index[who]} + else -- not an eligible candidate for that item + pfUI.loot.rollers[who] = {roll=tonumber(roll),value="disabled"} + end + pfUI.loot.rollers_sorted[table.getn(pfUI.loot.rollers_sorted)+1]={who=who,roll=tonumber(roll),value=pfUI.loot.rollers[who].value} + end + end + table.sort(pfUI.loot.rollers_sorted,function(a,b) + return a.roll > b.roll + end) + QueueFunction(UIDropDownMenu_Refresh,GroupLootDropDown) + end + end + if C.loot.autopickup == "1" and event == "LOOT_BIND_CONFIRM" then if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then local dialog = StaticPopup_Show("LOOT_BIND")