From 608861be57b35305c7c29d884dac850cd45c7650 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 13 Jan 2021 15:37:12 +0100 Subject: [PATCH] Revision 9 --- .gitmodules | 3 + Common | 1 + core.lua | 259 ++++++++++++++++++++++++++++++++++++++++++++++++ license.txt | 6 ++ locale_deDE.lua | 14 +++ locale_enEN.lua | 14 +++ locale_esES.lua | 14 +++ locale_esMX.lua | 14 +++ locale_frFR.lua | 14 +++ locale_itIT.lua | 14 +++ locale_koKR.lua | 13 +++ locale_ptBR.lua | 14 +++ locale_ruRU.lua | 13 +++ locale_zhCN.lua | 13 +++ locale_zhTW.lua | 13 +++ pack.xml | 14 +++ zz_LFG.toc | 9 ++ 17 files changed, 442 insertions(+) create mode 100644 .gitmodules create mode 160000 Common create mode 100644 core.lua create mode 100644 license.txt create mode 100644 locale_deDE.lua create mode 100644 locale_enEN.lua create mode 100644 locale_esES.lua create mode 100644 locale_esMX.lua create mode 100644 locale_frFR.lua create mode 100644 locale_itIT.lua create mode 100644 locale_koKR.lua create mode 100644 locale_ptBR.lua create mode 100644 locale_ruRU.lua create mode 100644 locale_zhCN.lua create mode 100644 locale_zhTW.lua create mode 100644 pack.xml create mode 100644 zz_LFG.toc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..34950ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Common"] + path = Common + url = https://git.grml.de/rilgamon/Common.git diff --git a/Common b/Common new file mode 160000 index 0000000..762c59c --- /dev/null +++ b/Common @@ -0,0 +1 @@ +Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..daffd99 --- /dev/null +++ b/core.lua @@ -0,0 +1,259 @@ +local name, addon = ... +local parentName = addon['parentName'] or "BrokerPack" +local childName = "zz_LFG" -- Change childName to your addons foldername +local ldbicon = LibStub("LibDBIcon-1.0") +local defaults = { +} + +local options = { +} + +local db + +local L = LibStub("AceLocale-3.0"):GetLocale(childName, true) +for _, t in pairs(LFG_EYE_TEXTURES) do + local cols = floor(t.width / t.iconSize) + local colWidth = t.iconSize / t.width + local rowHeight = t.iconSize / t.height + + local iconCoords = { } + for i = 1, t.frames do + local L = mod(i - 1, cols) * colWidth + local R = L + colWidth + local T = ceil(i / cols) * rowHeight + local B = T - rowHeight + + iconCoords[i] = { L, R, B, T } + end + t.iconCoords = iconCoords +end + +local currentQueueType +local currentFrame = 1 + +local currentIcon = LFG_EYE_TEXTURES.default +local iconCoords = currentIcon.iconCoords +local updateDelay = currentIcon.delay + +local counter = 0 +local ldbobj = nil +local function UpdateIconCoords(self, elapsed) + counter = counter + elapsed + if counter > updateDelay then + if currentFrame > currentIcon.frames then + currentFrame = 1 + end + ldbobj['iconCoords'] = iconCoords[currentFrame] or iconCoords[1] + currentFrame = currentFrame + 1 + counter = 0 + end +end +local function GetScreenHalf() + local _, y = GetCursorPosition() + if y * 2 > UIParent:GetHeight() then + return "TOP" + else + return "BOTTOM" + end +end +local actions = { + { + text = L["Click to open the Dungeon Finder."], + enabled = function() return C_LFGInfo.CanPlayerUseLFD() end, + selected = function(button) return button == "LeftButton" and not IsModifierKeyDown() end, + func = function() PVEFrame_ToggleFrame("GroupFinderFrame", LFDParentFrame) end, + }, + { + text = L["Alt-Click to open the Raid Finder."], + enabled = function() return C_LFGInfo.CanPlayerUseLFR() end, + selected = function(button) return button == "LeftButton" and IsAltKeyDown() end, + func = function() PVEFrame_ToggleFrame("GroupFinderFrame", RaidFinderFrame) end, + }, + { + text = L["Ctrl-Click to open the Premade Groups window."], + enabled = function() return not IsTrialAccount() end, + selected = function(button) return button == "LeftButton" and IsControlKeyDown() end, + func = function() PVEFrame_ToggleFrame("GroupFinderFrame", LFGListPVEStub) end, + }, + { + text = L["Right-Click to open the PVP window."], + enabled = function() return C_LFGInfo.CanPlayerUsePVP() end, + selected = function(button) return button == "RightButton" end, + func = function() TogglePVPUI() end, + }, + { + text = L["Middle-Click or Shift-Click to open the Pet Journal."], + enabled = function() return C_PetJournal.IsFindBattleEnabled() and C_PetJournal.IsJournalUnlocked() end, + selected = function(button) return button == "MiddleButton" or (button == "LeftButton" and IsShiftKeyDown()) end, + func = function() ToggleCollectionsJournal(2) end, + }, +} + +local queueTypes = { + "dungeon", -- Dungeon Finder + "raid", -- Other Raids + "raid", -- Raid Finder + "scenario", -- Scenarios + "raid", -- Flex Raid + "pvp" -- World PVP +} + +local function GetQueueInfo() + for i = 1, NUM_LE_LFG_CATEGORYS do + local mode, submode = GetLFGMode(i) + if mode then + return queueTypes[i], mode, submode, i + end + end + + for i = 1, GetMaxBattlefieldID() do + local status = GetBattlefieldStatus(i) + if status and status ~= "none" then + return "pvp", status + end + end + + for i = 1, MAX_WORLD_PVP_QUEUES do + local status = GetWorldPVPQueueStatus(i) + if status and status ~= "none" then + return "pvp", status + end + end + + local status = C_PetBattles.GetPVPMatchmakingInfo() + if status then + return "petbattle", status + end +end +local function OnText(message) + addon:OnText(childName, message) +end +local function OnEnter(self,...) + if GetQueueInfo() and not QueueStatusFrame:IsVisible() then + QueueStatusFrame:Show() + QueueStatusFrame:SetParent(UIParent) + QueueStatusFrame:SetClampedToScreen(true) + QueueStatusFrame:SetFrameStrata("TOOLTIP") + QueueStatusFrame:ClearAllPoints() + if GetScreenHalf() == "TOP" then + QueueStatusFrame:SetPoint("TOP", self, "BOTTOM", 0, -5) + else + QueueStatusFrame:SetPoint("BOTTOM", self, "TOP", 0, 5) + end + else + GameTooltip:SetOwner(self, "ANCHOR_BOTTOM") + GameTooltip:ClearLines() + GameTooltip:SetText(L["LFG"]) + for i = 1, #actions do + if actions[i].enabled() then + GameTooltip:AddLine(actions[i].text, 1, 1, 1) + end + end + GameTooltip:Show() + end +end +local function OnLeave(self) + QueueStatusFrame:Hide() + GameTooltip:Hide() +end +local function OnClick(self, button) + if button == "RightButton" and GetQueueInfo() and not IsShiftKeyDown() then + PlaySound(SOUNDKIT.IG_MAINMENU_OPEN) + local screenHalf = GetScreenHalf() + QueueStatusMinimapButtonDropDown.point = screenHalf == "TOP" and "TOPLEFT" or "BOTTOMLEFT" + QueueStatusMinimapButtonDropDown.relativePoint = screenHalf == "TOP" and "BOTTOMLEFT" or "TOPLEFT" + ToggleDropDownMenu(1, nil, QueueStatusMinimapButtonDropDown, self, 0, 0) + else + for i = 1, #actions do + local action = actions[i] + if action.selected(button) then + if action.enabled() then + action.func() + end + break + end + end + end +end +local function OnEvent(self, event) + local queueType, queueStatus = GetQueueInfo() + + if queueType and queueStatus ~= "queued" then + queueType = nil + end + + if queueType == currentQueueType then + return + end + + currentQueueType = queueType + + currentIcon = queueType and LFG_EYE_TEXTURES[queueType] or LFG_EYE_TEXTURES.default + iconCoords = currentIcon.iconCoords + updateDelay = currentIcon.delay + ldbobj['icon'] = currentIcon.file + + if queueType then + currentFrame = 1 + self:SetScript("OnUpdate", UpdateIconCoords) + else + self:SetScript("OnUpdate", nil) + currentFrame = 1 + ldbobj['iconCoords'] = iconCoords[1] + end +end +local function OnEvent2(self, event) + local mode, _ = GetLFGMode(LE_LFG_CATEGORY_LFD) + if(mode == 'queued') then + local hasData, _, tankNeeds, healerNeeds, dpsNeeds, _ = GetLFGQueueStats(LE_LFG_CATEGORY_LFD) + if(hasData) then + local newtext = "" + if(tankNeeds > 0) then + newtext = "T" + end + if(healerNeeds > 0) then + newtext = newtext .. "H" + end + if(dpsNeeds > 0) then + for i = 1, dpsNeeds do + newtext = newtext .. "D" + end + end + ldbobj['text'] = newtext == "" and ldbobj['label'] or format(("|cffFF3300%s|r"),newtext) + else + ldbobj['text'] = ldbobj['label'] + end + else + ldbobj['text'] = ldbobj['label'] + end +end +local function getPref(pref) + return db[pref[#pref]] +end + +local function setPref(pref,value) + db[pref[#pref]] = value +end + +local function init() + options = addon:InitConfig(childName, true, { + ['type'] = "data source", -- 'data source | launcher' + ['icon'] = "Interface\\LFGFrame\\LFG-Eye", + ['text'] = L.LFG, + ['iconCoords'] = LFG_EYE_TEXTURES.default.iconCoords[1], + ['OnEnter'] = OnEnter, + ['OnLeave'] = OnLeave, + ['OnClick'] = OnClick, + }, getPref, setPref) + db = addon['db']['profile'][childName] + ldbobj = addon:GetLDB(childName) + local f = CreateFrame("Frame") + QueueStatusFrame_OnLoad(f) + f:SetScript("OnEvent", OnEvent) + f.StatusEntries = nil + UpdateIconCoords(f,0) + QueueStatusMinimapButton:Hide() + QueueStatusMinimapButton.Show = QueueStatusMinimapButton.Hide + addon:RegisterFunc({"LFG_UPDATE", "LFG_ROLE_CHECK_UPDATE", "LFG_PROPOSAL_UPDATE", "LFG_PROPOSAL_FAILED", "LFG_PROPOSAL_SUCCEEDED", "LFG_PROPOSAL_SHOW", "LFG_QUEUE_STATUS_UPDATE"}, 'OnEvent', OnEvent2) +end +addon:startup(name, childName, init, true, defaults) \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..b9e992f --- /dev/null +++ b/license.txt @@ -0,0 +1,6 @@ +The following license excludes the libraries (Libs) included. See the libraries directory or website. + +This AddOn is public domain. That means you can change it, rename it or paint it yellow. +My name (Rilgamon) is valid only for WoWInterface.com and curse.com. +If you use/offer this addon on another website please remove my name. +If you want to give me credit you can replace it with a link to my profile on WoWInterface.com. \ No newline at end of file diff --git a/locale_deDE.lua b/locale_deDE.lua new file mode 100644 index 0000000..9765eea --- /dev/null +++ b/locale_deDE.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "ALT-klicken, um Schlachtzugsbrowser zu öffnen." + L["Basic LFG button for your DataBroker display."] = "Einfache LFG-Schaltfläche für deine DataBroker-Anzeige." + L["Click to open the Dungeon Finder."] = "Klicken, um Dungeonbrowser zu öffnen." + L["Ctrl-Click to open the Premade Groups window."] = "STRG-klicken, um Organisierte-Gruppenfenster zu öffnen." + L["LFG"] = "LFG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Mittleren klicken oder SHIFT-klicken, um Wildtierführer zu öffnen." + L["Right-Click to open the PVP window."] = "Rechtsklicken, um PvP-Fenster zu öffnen." +end \ No newline at end of file diff --git a/locale_enEN.lua b/locale_enEN.lua new file mode 100644 index 0000000..5d5e46c --- /dev/null +++ b/locale_enEN.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "enEN", true) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = true + L["Basic LFG button for your DataBroker display."] = true + L["Click to open the Dungeon Finder."] = true + L["Ctrl-Click to open the Premade Groups window."] = true + L["LFG"] = true + L["Middle-Click or Shift-Click to open the Pet Journal."] = true + L["Right-Click to open the PVP window."] = true +end \ No newline at end of file diff --git a/locale_esES.lua b/locale_esES.lua new file mode 100644 index 0000000..c3ec075 --- /dev/null +++ b/locale_esES.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "esES", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt+clic para mostrar el buscador de bandas." + L["Basic LFG button for your DataBroker display."] = "Botón básico de BDG para tu exhibición DataBroker." + L["Click to open the Dungeon Finder."] = "Haz clic para mostrar el buscador de mazmorras." + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl+clic para mostrar el cuadro de grupos ya creados." + L["LFG"] = "BDG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Haz clic media o Mayús+clic para mostrar la guía de mascotas." + L["Right-Click to open the PVP window."] = "Haz clic derecho para mostrar el cuadro de JcJ." +end \ No newline at end of file diff --git a/locale_esMX.lua b/locale_esMX.lua new file mode 100644 index 0000000..b54d7a9 --- /dev/null +++ b/locale_esMX.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "esMX", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt-clic para mostrar el buscador de bandas." + L["Basic LFG button for your DataBroker display."] = "Botón básico de BDG para tu exhibición DataBroker." + L["Click to open the Dungeon Finder."] = "Haz clic para mostrar el buscador de calabozos." + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl+clic para mostrar el cuadro de grupos ya creados." + L["LFG"] = "BDG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Haz clic media o Mayús+clic para mostrar la guía de mascotas." + L["Right-Click to open the PVP window."] = "Haz clic derecho para mostrar el cuadro de JcJ." +end \ No newline at end of file diff --git a/locale_frFR.lua b/locale_frFR.lua new file mode 100644 index 0000000..f6978de --- /dev/null +++ b/locale_frFR.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "frFR", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Clic-alt pour afficher la recherche de raid." + L["Basic LFG button for your DataBroker display."] = "Bouton de base de RdG votre étalage DataBroker." + L["Click to open the Dungeon Finder."] = "Cliquer pour afficher la cadre des donjons." + L["Ctrl-Click to open the Premade Groups window."] = "Clic-ctrl pour afficher les groupes prédéfinis." + L["LFG"] = "RdG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Clic milieu ou clic-maj pour afficher le codex des mascottes." + L["Right-Click to open the PVP window."] = "Clic droit pour afficher ou fermer le panneau de JcJ." +end \ No newline at end of file diff --git a/locale_itIT.lua b/locale_itIT.lua new file mode 100644 index 0000000..ed8b7a2 --- /dev/null +++ b/locale_itIT.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "itIT", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt-clicca per mostrare il ricerca delle incursioni." + L["Basic LFG button for your DataBroker display."] = "Bottone di base di CG per vostra esposizione DataBroker." + L["Click to open the Dungeon Finder."] = "Clicca per mostrare il ricerca delle istanze." + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl-clicca per mostrare il pannello delle gruppi organizzati." + L["LFG"] = "CG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Clicca medio o Maiusc-clicca per mostrare il diario delle mascotte." + L["Right-Click to open the PVP window."] = "Clicca destro per mostrare l'interfaccia del PvP." +end \ No newline at end of file diff --git a/locale_koKR.lua b/locale_koKR.lua new file mode 100644 index 0000000..ff3e3f9 --- /dev/null +++ b/locale_koKR.lua @@ -0,0 +1,13 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "koKR", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "ALT클릭 하면 공격대 찾기 창을 켜거나 끕니다." + L["Click to open the Dungeon Finder."] = "클릭 하면 던전 찾기 창을 켜거나 끕니다." + L["Ctrl-Click to open the Premade Groups window."] = "CTRL클릭 하면 파티 구성하기 창을 켜거나 끕니다." + L["LFG"] = "던전 찾기" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "가운데클릭 또는 쉬프트클릭 하면 애완동물 도감 창을 켜거나 끕니다." + L["Right-Click to open the PVP window."] = "오른쪽클릭 하면 명예창 창을 켜거나 끕니다." +end \ No newline at end of file diff --git a/locale_ptBR.lua b/locale_ptBR.lua new file mode 100644 index 0000000..2a3dd3e --- /dev/null +++ b/locale_ptBR.lua @@ -0,0 +1,14 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "ptBR", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt-clique para mostrar o localizador de raides." + L["Basic LFG button for your DataBroker display."] = "Botão básico de PG para seu exibição DataBroker." + L["Click to open the Dungeon Finder."] = "Clique para mostrar o localizador de masmorras." + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl-clique para mostrar o localizador de cenários." + L["LFG"] = "PG" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Meio-clique ou shift-clique para mostrar o diário de mascotes." + L["Right-Click to open the PVP window."] = "Direito-clique para mostrar o quadro de JxJ." +end \ No newline at end of file diff --git a/locale_ruRU.lua b/locale_ruRU.lua new file mode 100644 index 0000000..fb4f26f --- /dev/null +++ b/locale_ruRU.lua @@ -0,0 +1,13 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "ruRU", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt-клик для открытия Поиск рейда." + L["Click to open the Dungeon Finder."] = "Щелкните для открытия Поиск подземелий." + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl-клик для открытия Заранее собранные группы." + L["LFG"] = "ЛФГ" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "Щелкните средней кнопкой мыши или Shift-клик для открытия Транспорт и питомцы." + L["Right-Click to open the PVP window."] = "Щелкните правой кнопкой мыши для открытия Окно PvP." +end \ No newline at end of file diff --git a/locale_zhCN.lua b/locale_zhCN.lua new file mode 100644 index 0000000..21080ef --- /dev/null +++ b/locale_zhCN.lua @@ -0,0 +1,13 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "zhCN", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt+左键点击进入团队浏览器窗口。" + L["Click to open the Dungeon Finder."] = "左键点击进入副本工具窗口。" + L["Ctrl-Click to open the Premade Groups window."] = "按住Ctrl键单击打开/关闭预创建队伍窗口" + L["LFG"] = "寻求组队" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "中键点击或shift+左键点击打开宠物手册。" + L["Right-Click to open the PVP window."] = "右键点击打开PVP窗口。" +end \ No newline at end of file diff --git a/locale_zhTW.lua b/locale_zhTW.lua new file mode 100644 index 0000000..c49e214 --- /dev/null +++ b/locale_zhTW.lua @@ -0,0 +1,13 @@ +local addonname, addon = ... +local name = "zz_LFG" +local L = LibStub("AceLocale-3.0"):NewLocale(name, "zhTW", false) +if L then + L[name] = name + L[name..' Settings'] = name..' Settings' + L["Alt-Click to open the Raid Finder."] = "Alt-點擊開啟/關閉團隊搜尋器視窗。" + L["Click to open the Dungeon Finder."] = "點擊開啟/關閉地城搜尋視窗。" + L["Ctrl-Click to open the Premade Groups window."] = "Ctrl-點擊開啟/關閉 預組隊伍視窗。" + L["LFG"] = "尋求組隊" + L["Middle-Click or Shift-Click to open the Pet Journal."] = "中鍵點擊或Shift+左鍵點擊開啟/關閉寵物手冊。" + L["Right-Click to open the PVP window."] = "右鍵點擊開啟/關閉PVP視窗。" +end \ No newline at end of file diff --git a/pack.xml b/pack.xml new file mode 100644 index 0000000..cd6d600 --- /dev/null +++ b/pack.xml @@ -0,0 +1,14 @@ + +