From 0a4946707f63df2dc23b3c53e26a1532a28dee8c Mon Sep 17 00:00:00 2001 From: Guillaume Chopelet Date: Wed, 22 Jan 2020 14:00:34 +0100 Subject: [PATCH 01/37] basic hunter frames --- Gui.lua | 93 +++++++++++++++++++++++++++++++++++++++++++++ TranqRotate.lua | 3 ++ TranqRotate.toc | 1 + textures/steel.tga | Bin 0 -> 32812 bytes 4 files changed, 97 insertions(+) create mode 100644 Gui.lua create mode 100644 textures/steel.tga diff --git a/Gui.lua b/Gui.lua new file mode 100644 index 0000000..ada51ed --- /dev/null +++ b/Gui.lua @@ -0,0 +1,93 @@ +local TranqRotate = select(2, ...) + +function TranqRotate:initGui() + + TranqRotate.hunterList = CreateFrame("Frame", nil, UIParent); + TranqRotate.hunterList:SetFrameStrata("MEDIUM") + TranqRotate.hunterList:SetWidth(120) + TranqRotate.hunterList:SetHeight(150) + + local texture = TranqRotate.hunterList:CreateTexture(nil, "BACKGROUND") + texture:SetTexture("Interface\\framegeneral\\UI-Background-Marble") + texture:SetAllPoints() + texture:SetVertexColor(0,0,0,0.5) + + TranqRotate.hunterList.texture = texture + TranqRotate.hunterList:SetPoint("RIGHT",-400,0) + TranqRotate.hunterList:Show() + + TranqRotate:registerHunter('Slivo', 'TEST') + TranqRotate:registerHunter('Guigne', 'TEST') + TranqRotate:registerHunter('Rango', 'TEST') + TranqRotate:registerHunter('Hakooh', 'TEST') + + TranqRotate:drawHunterFrames() +end + +function TranqRotate:registerHunter(hunterName, GUID) + + local hunter = {} + hunter.name = hunterName + hunter.GUID = GUID + hunter.frame = nil + + --TranqRotate.hunterTable[hunterName] = hunter + table.insert(TranqRotate.hunterTable, hunter) + +end + +function TranqRotate:drawHunterFrames() + + local index = 1; + local previousHunt = nil + + for key,hunter in pairs(TranqRotate.hunterTable) do + + print(hunter.name) + --print(hunter) + + hunter.frame = CreateFrame("Frame", nil, TranqRotate.hunterList); + hunter.frame:SetFrameStrata("MEDIUM") + hunter.frame:SetHeight(20) + + if (index == 1) then + print('First Hunter') + hunter.frame:SetParent(TranqRotate.hunterList) + hunter.frame:SetPoint('TOP', 0, -10) + hunter.frame:SetPoint('LEFT', 10, 0) + hunter.frame:SetPoint('RIGHT', -10, 0) + else + print('Previous hunter name ' .. previousHunt.name) + hunter.frame:ClearAllPoints() + hunter.frame:SetParent(previousHunt.frame) + hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -2) + hunter.frame:SetPoint('LEFT', 0, 0) + end + + -- Set Texture + hunter.frame.texture = hunter.frame:CreateTexture(nil, "BACKGROUND") + hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") + hunter.frame.texture:SetAllPoints() + hunter.frame.texture:SetVertexColor(0.3,0.6,0.3,1) + + -- Set Text + hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 13) + hunter.frame.text:SetPoint("LEFT",5,0) + hunter.frame.text:SetText(hunter.name) + + hunter.frame:Show() + + hunter.frame.hunter = hunter + + previousHunt = hunter + index = index + 1 + end + + local red = {0.5, 0.1, 0.1, 1} + + TranqRotate.hunterTable[1].frame.texture:SetVertexColor(0.5,0.1,0.1,1) + TranqRotate.hunterTable[2].frame.texture:SetVertexColor(0.3,0.3,0.7,1) + TranqRotate.hunterTable[3].frame.texture:SetVertexColor(0.3,0.3,0.3,1) + +end diff --git a/TranqRotate.lua b/TranqRotate.lua index 35113a9..b3a721a 100644 --- a/TranqRotate.lua +++ b/TranqRotate.lua @@ -17,6 +17,9 @@ function TranqRotate:init() self:CreateConfig() + TranqRotate.hunterTable = {} + TranqRotate:initGui(); + printMessage(L['LOADED_MESSAGE']) end diff --git a/TranqRotate.toc b/TranqRotate.toc index e36246f..4adf1ce 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -21,5 +21,6 @@ locales\zhCN.lua locales\zhTW.lua TranqRotate.lua +Gui.Lua defaults.lua settings.lua \ No newline at end of file diff --git a/textures/steel.tga b/textures/steel.tga new file mode 100644 index 0000000000000000000000000000000000000000..3f8aee4b882091fb9363ae41448b00d788273ae7 GIT binary patch literal 32812 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 literal 0 HcmV?d00001 From a138d2cbe76ddd16383b1b51a17559b512ccb63b Mon Sep 17 00:00:00 2001 From: Guillaume Chopelet Date: Mon, 27 Jan 2020 13:40:56 +0100 Subject: [PATCH 02/37] update gui, adds draw & redraw --- Gui.lua | 111 ++++++++++++++++++++++++++++++------------------ TranqRotate.lua | 24 ++++++++--- TranqRotate.toc | 1 + constants.lua | 9 ++++ 4 files changed, 97 insertions(+), 48 deletions(-) create mode 100644 constants.lua diff --git a/Gui.lua b/Gui.lua index ada51ed..3842b50 100644 --- a/Gui.lua +++ b/Gui.lua @@ -2,24 +2,32 @@ local TranqRotate = select(2, ...) function TranqRotate:initGui() - TranqRotate.hunterList = CreateFrame("Frame", nil, UIParent); - TranqRotate.hunterList:SetFrameStrata("MEDIUM") - TranqRotate.hunterList:SetWidth(120) - TranqRotate.hunterList:SetHeight(150) - - local texture = TranqRotate.hunterList:CreateTexture(nil, "BACKGROUND") - texture:SetTexture("Interface\\framegeneral\\UI-Background-Marble") - texture:SetAllPoints() - texture:SetVertexColor(0,0,0,0.5) - - TranqRotate.hunterList.texture = texture - TranqRotate.hunterList:SetPoint("RIGHT",-400,0) - TranqRotate.hunterList:Show() - - TranqRotate:registerHunter('Slivo', 'TEST') - TranqRotate:registerHunter('Guigne', 'TEST') - TranqRotate:registerHunter('Rango', 'TEST') - TranqRotate:registerHunter('Hakooh', 'TEST') + TranqRotate.mainWindow = CreateFrame("Frame", nil, UIParent); + TranqRotate.mainWindow:SetFrameStrata("MEDIUM") + TranqRotate.mainWindow:SetWidth(120) + TranqRotate.mainWindow:SetHeight(10) + TranqRotate.mainWindow:SetPoint("RIGHT",-400,0) + TranqRotate.mainWindow:Show() + + TranqRotate.mainWindow.rotationFrame = CreateFrame("Frame", nil, TranqRotate.mainWindow); + TranqRotate.mainWindow.rotationFrame:SetPoint('TOPLEFT') + TranqRotate.mainWindow.rotationFrame:SetPoint('TOPRIGHT') + TranqRotate.mainWindow.rotationFrame:SetHeight(20) + + TranqRotate.mainWindow.rotationFrame.texture = TranqRotate.mainWindow.rotationFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainWindow.rotationFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainWindow.rotationFrame.texture:SetAllPoints() + TranqRotate.mainWindow.rotationFrame.texture = texture + + TranqRotate.mainWindow.backupFrame = CreateFrame("Frame", nil, TranqRotate.mainWindow.rotationFrame); + TranqRotate.mainWindow.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainWindow.rotationFrame, 'BOTTOMLEFT', 0, 0) + TranqRotate.mainWindow.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainWindow.rotationFrame, 'BOTTOMRIGHT', 0, 0) + TranqRotate.mainWindow.backupFrame:SetHeight(10) + + TranqRotate.mainWindow.backupFrame.texture = TranqRotate.mainWindow.backupFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainWindow.backupFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainWindow.backupFrame.texture:SetAllPoints() + TranqRotate.mainWindow.backupFrame.texture = texture TranqRotate:drawHunterFrames() end @@ -31,63 +39,84 @@ function TranqRotate:registerHunter(hunterName, GUID) hunter.GUID = GUID hunter.frame = nil - --TranqRotate.hunterTable[hunterName] = hunter table.insert(TranqRotate.hunterTable, hunter) + if (#TranqRotate.rotationTable.rotation > 2) then + table.insert(TranqRotate.rotationTable.backup, hunter) + else + table.insert(TranqRotate.rotationTable.rotation, hunter) + end end function TranqRotate:drawHunterFrames() + TranqRotate.mainWindow.rotationFrame:SetHeight(20) + TranqRotate.mainWindow.backupFrame:SetHeight(10) + + TranqRotate:drawList(TranqRotate.rotationTable.rotation, TranqRotate.mainWindow.rotationFrame) + TranqRotate:drawList(TranqRotate.rotationTable.backup, TranqRotate.mainWindow.backupFrame) + +end + +function TranqRotate:drawList(hunterList, parentFrame) + local index = 1; local previousHunt = nil + local basicFrameHeight = 20; + local sameGroupSpacing = 2 - for key,hunter in pairs(TranqRotate.hunterTable) do + if (#hunterList < 1) then + parentFrame:Hide() + else + parentFrame:Show() + end - print(hunter.name) - --print(hunter) + for key,hunter in pairs(hunterList) do - hunter.frame = CreateFrame("Frame", nil, TranqRotate.hunterList); - hunter.frame:SetFrameStrata("MEDIUM") - hunter.frame:SetHeight(20) + -- Using existing frame if possible + if (hunter.frame == nil) then + hunter.frame = CreateFrame("Frame", nil, parentFrame); + hunter.frame:SetFrameStrata("MEDIUM") + hunter.frame:SetHeight(basicFrameHeight) + end + -- Handling anchor and spacing for group first hunter if (index == 1) then - print('First Hunter') - hunter.frame:SetParent(TranqRotate.hunterList) - hunter.frame:SetPoint('TOP', 0, -10) + hunter.frame:SetParent(parentFrame) + + if (parentFrame ~= TranqRotate.mainWindow.backupFrame) then + hunter.frame:SetPoint('TOP', 0, -10) + else + hunter.frame:SetPoint('TOP', 0, 0) + end + hunter.frame:SetPoint('LEFT', 10, 0) hunter.frame:SetPoint('RIGHT', -10, 0) + parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight) else - print('Previous hunter name ' .. previousHunt.name) - hunter.frame:ClearAllPoints() hunter.frame:SetParent(previousHunt.frame) - hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -2) + hunter.frame:ClearAllPoints() + hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -sameGroupSpacing) hunter.frame:SetPoint('LEFT', 0, 0) + parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) end -- Set Texture hunter.frame.texture = hunter.frame:CreateTexture(nil, "BACKGROUND") hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") hunter.frame.texture:SetAllPoints() - hunter.frame.texture:SetVertexColor(0.3,0.6,0.3,1) + hunter.frame.texture:SetVertexColor(TranqRotate.colors.green:GetRGB()) -- Hunter color from unknown -- Set Text hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") - hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 13) + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) hunter.frame.text:SetPoint("LEFT",5,0) hunter.frame.text:SetText(hunter.name) hunter.frame:Show() - hunter.frame.hunter = hunter previousHunt = hunter index = index + 1 end - - local red = {0.5, 0.1, 0.1, 1} - - TranqRotate.hunterTable[1].frame.texture:SetVertexColor(0.5,0.1,0.1,1) - TranqRotate.hunterTable[2].frame.texture:SetVertexColor(0.3,0.3,0.7,1) - TranqRotate.hunterTable[3].frame.texture:SetVertexColor(0.3,0.3,0.3,1) - end diff --git a/TranqRotate.lua b/TranqRotate.lua index b3a721a..1b3ba2d 100644 --- a/TranqRotate.lua +++ b/TranqRotate.lua @@ -18,8 +18,9 @@ function TranqRotate:init() self:CreateConfig() TranqRotate.hunterTable = {} - TranqRotate:initGui(); + TranqRotate.rotationTable = { rotation = {}, backup = {} } + TranqRotate:initGui(); printMessage(L['LOADED_MESSAGE']) end @@ -56,14 +57,23 @@ end SLASH_TRANQROTATE1 = "/tranq" SLASH_TRANQROTATE2 = "/tranqrotate" SlashCmdList["TRANQROTATE"] = function(msg) - local AceConfigDialog = LibStub("AceConfigDialog-3.0") - AceConfigDialog:Open("TranqRotate") + local _, _, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)") + + if (cmd == 'redraw') then + TranqRotate:drawHunterFrames() + elseif (cmd == 'add' and args ~= nil) then + TranqRotate:registerHunter(args, 'GUID') + TranqRotate:drawHunterFrames() + else + local AceConfigDialog = LibStub("AceConfigDialog-3.0") + AceConfigDialog:Open("TranqRotate") + end end -local frame = CreateFrame("Frame") -frame:RegisterEvent("PLAYER_LOGIN") -frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") -frame:SetScript( +local eventFrame = CreateFrame("Frame") +eventFrame:RegisterEvent("PLAYER_LOGIN") +eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") +eventFrame:SetScript( "OnEvent", function(self, event, ...) if( event == "PLAYER_LOGIN" ) then diff --git a/TranqRotate.toc b/TranqRotate.toc index 4adf1ce..45d50cb 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -21,6 +21,7 @@ locales\zhCN.lua locales\zhTW.lua TranqRotate.lua +constants.lua Gui.Lua defaults.lua settings.lua \ No newline at end of file diff --git a/constants.lua b/constants.lua new file mode 100644 index 0000000..ab81058 --- /dev/null +++ b/constants.lua @@ -0,0 +1,9 @@ +local TranqRotate = select(2, ...) + +TranqRotate.colors = { + ['green'] = CreateColor(0.67, 0.83, 0.45), + ['blue'] = CreateColor(0.3, 0.3, 0.7), + ['red'] = CreateColor(0.7, 0.3, 0.3), + ['gray'] = CreateColor(0.3, 0.3, 0.3), + +} \ No newline at end of file From 816dcbeea4fff388b86dfad73295fec1d3a0bfaf Mon Sep 17 00:00:00 2001 From: Guillaume Chopelet Date: Thu, 30 Jan 2020 12:59:33 +0100 Subject: [PATCH 03/37] adds base rotation mechanics --- Gui.lua | 122 ----------- TranqRotate.lua | 86 -------- TranqRotate.toc | 12 +- locales/enUS.lua | 7 + locales/frFR.lua | 7 + locales/zhCN.lua | 7 + locales/zhTW.lua | 7 + constants.lua => src/constants.lua | 2 +- defaults.lua => src/defaults.lua | 5 +- src/events.lua | 60 ++++++ src/gui.lua | 153 ++++++++++++++ src/rotation.lua | 317 +++++++++++++++++++++++++++++ settings.lua => src/settings.lua | 16 +- src/tranqRotate.lua | 107 ++++++++++ 14 files changed, 691 insertions(+), 217 deletions(-) delete mode 100644 Gui.lua delete mode 100644 TranqRotate.lua rename constants.lua => src/constants.lua (83%) rename defaults.lua => src/defaults.lua (51%) create mode 100644 src/events.lua create mode 100644 src/gui.lua create mode 100644 src/rotation.lua rename settings.lua => src/settings.lua (88%) create mode 100644 src/tranqRotate.lua diff --git a/Gui.lua b/Gui.lua deleted file mode 100644 index 3842b50..0000000 --- a/Gui.lua +++ /dev/null @@ -1,122 +0,0 @@ -local TranqRotate = select(2, ...) - -function TranqRotate:initGui() - - TranqRotate.mainWindow = CreateFrame("Frame", nil, UIParent); - TranqRotate.mainWindow:SetFrameStrata("MEDIUM") - TranqRotate.mainWindow:SetWidth(120) - TranqRotate.mainWindow:SetHeight(10) - TranqRotate.mainWindow:SetPoint("RIGHT",-400,0) - TranqRotate.mainWindow:Show() - - TranqRotate.mainWindow.rotationFrame = CreateFrame("Frame", nil, TranqRotate.mainWindow); - TranqRotate.mainWindow.rotationFrame:SetPoint('TOPLEFT') - TranqRotate.mainWindow.rotationFrame:SetPoint('TOPRIGHT') - TranqRotate.mainWindow.rotationFrame:SetHeight(20) - - TranqRotate.mainWindow.rotationFrame.texture = TranqRotate.mainWindow.rotationFrame:CreateTexture(nil, "BACKGROUND") - TranqRotate.mainWindow.rotationFrame.texture:SetColorTexture(0,0,0,0.5) - TranqRotate.mainWindow.rotationFrame.texture:SetAllPoints() - TranqRotate.mainWindow.rotationFrame.texture = texture - - TranqRotate.mainWindow.backupFrame = CreateFrame("Frame", nil, TranqRotate.mainWindow.rotationFrame); - TranqRotate.mainWindow.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainWindow.rotationFrame, 'BOTTOMLEFT', 0, 0) - TranqRotate.mainWindow.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainWindow.rotationFrame, 'BOTTOMRIGHT', 0, 0) - TranqRotate.mainWindow.backupFrame:SetHeight(10) - - TranqRotate.mainWindow.backupFrame.texture = TranqRotate.mainWindow.backupFrame:CreateTexture(nil, "BACKGROUND") - TranqRotate.mainWindow.backupFrame.texture:SetColorTexture(0,0,0,0.5) - TranqRotate.mainWindow.backupFrame.texture:SetAllPoints() - TranqRotate.mainWindow.backupFrame.texture = texture - - TranqRotate:drawHunterFrames() -end - -function TranqRotate:registerHunter(hunterName, GUID) - - local hunter = {} - hunter.name = hunterName - hunter.GUID = GUID - hunter.frame = nil - - table.insert(TranqRotate.hunterTable, hunter) - - if (#TranqRotate.rotationTable.rotation > 2) then - table.insert(TranqRotate.rotationTable.backup, hunter) - else - table.insert(TranqRotate.rotationTable.rotation, hunter) - end -end - -function TranqRotate:drawHunterFrames() - - TranqRotate.mainWindow.rotationFrame:SetHeight(20) - TranqRotate.mainWindow.backupFrame:SetHeight(10) - - TranqRotate:drawList(TranqRotate.rotationTable.rotation, TranqRotate.mainWindow.rotationFrame) - TranqRotate:drawList(TranqRotate.rotationTable.backup, TranqRotate.mainWindow.backupFrame) - -end - -function TranqRotate:drawList(hunterList, parentFrame) - - local index = 1; - local previousHunt = nil - local basicFrameHeight = 20; - local sameGroupSpacing = 2 - - if (#hunterList < 1) then - parentFrame:Hide() - else - parentFrame:Show() - end - - for key,hunter in pairs(hunterList) do - - -- Using existing frame if possible - if (hunter.frame == nil) then - hunter.frame = CreateFrame("Frame", nil, parentFrame); - hunter.frame:SetFrameStrata("MEDIUM") - hunter.frame:SetHeight(basicFrameHeight) - end - - -- Handling anchor and spacing for group first hunter - if (index == 1) then - hunter.frame:SetParent(parentFrame) - - if (parentFrame ~= TranqRotate.mainWindow.backupFrame) then - hunter.frame:SetPoint('TOP', 0, -10) - else - hunter.frame:SetPoint('TOP', 0, 0) - end - - hunter.frame:SetPoint('LEFT', 10, 0) - hunter.frame:SetPoint('RIGHT', -10, 0) - parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight) - else - hunter.frame:SetParent(previousHunt.frame) - hunter.frame:ClearAllPoints() - hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -sameGroupSpacing) - hunter.frame:SetPoint('LEFT', 0, 0) - parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) - end - - -- Set Texture - hunter.frame.texture = hunter.frame:CreateTexture(nil, "BACKGROUND") - hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") - hunter.frame.texture:SetAllPoints() - hunter.frame.texture:SetVertexColor(TranqRotate.colors.green:GetRGB()) -- Hunter color from unknown - - -- Set Text - hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") - hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) - hunter.frame.text:SetPoint("LEFT",5,0) - hunter.frame.text:SetText(hunter.name) - - hunter.frame:Show() - hunter.frame.hunter = hunter - - previousHunt = hunter - index = index + 1 - end -end diff --git a/TranqRotate.lua b/TranqRotate.lua deleted file mode 100644 index 1b3ba2d..0000000 --- a/TranqRotate.lua +++ /dev/null @@ -1,86 +0,0 @@ -TranqRotate = select(2, ...) - -local L = TranqRotate.L -local ACR = LibStub("AceConfigRegistry-3.0", true) -TranqRotate.version = "1.0.1" - -local TranqShot = GetSpellInfo(19801) ---local TranqShot = GetSpellInfo(14287) --Arcane shot for testing -local canTranq = IsUsableSpell(TranqShot) - -function TranqRotate:init() - self:LoadDefaults() - - self.db = LibStub:GetLibrary("AceDB-3.0"):New("TranqRotateDb", self.defaults, true) - self.db.RegisterCallback(self, "OnProfileChanged", "ProfilesChanged") - self.db.RegisterCallback(self, "OnProfileCopied", "ProfilesChanged") - - self:CreateConfig() - - TranqRotate.hunterTable = {} - TranqRotate.rotationTable = { rotation = {}, backup = {} } - - TranqRotate:initGui(); - printMessage(L['LOADED_MESSAGE']) -end - -function TranqRotate:ProfilesChanged() - self.db:RegisterDefaults(self.defaults) -end - -function printMessage(msg) - print(msg); -end - -function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() - - local timestamp, event, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo() - local spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand = select(12, CombatLogGetCurrentEventInfo()) - - if event == "SPELL_CAST_SUCCESS" and spellName == TranqShot and sourceGUID == UnitGUID("player") then - TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceSuccessMessage, destName) - elseif event == "SPELL_MISSED" and spellName == TranqShot and sourceGUID == UnitGUID("player") then - TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceFailMessage, destName) - end -end - -function TranqRotate:sendAnnounceMessage(message, destName) - if TranqRotate.db.profile.enableAnnounces then - local channelNumber - if TranqRotate.db.profile.channelType == "CHANNEL" then - channelNumber = GetChannelName(TranqRotate.db.profile.targetChannel) - end - SendChatMessage(string.format(message,destName), TranqRotate.db.profile.channelType, nil, channelNumber or TranqRotate.db.profile.targetChannel) - end -end - -SLASH_TRANQROTATE1 = "/tranq" -SLASH_TRANQROTATE2 = "/tranqrotate" -SlashCmdList["TRANQROTATE"] = function(msg) - local _, _, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)") - - if (cmd == 'redraw') then - TranqRotate:drawHunterFrames() - elseif (cmd == 'add' and args ~= nil) then - TranqRotate:registerHunter(args, 'GUID') - TranqRotate:drawHunterFrames() - else - local AceConfigDialog = LibStub("AceConfigDialog-3.0") - AceConfigDialog:Open("TranqRotate") - end -end - -local eventFrame = CreateFrame("Frame") -eventFrame:RegisterEvent("PLAYER_LOGIN") -eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") -eventFrame:SetScript( - "OnEvent", - function(self, event, ...) - if( event == "PLAYER_LOGIN" ) then - TranqRotate:init() - self:UnregisterEvent("PLAYER_LOGIN") - else - TranqRotate[event](TranqRotate, ...) - end - end -) diff --git a/TranqRotate.toc b/TranqRotate.toc index 45d50cb..569709c 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -20,8 +20,10 @@ locales\frFR.lua locales\zhCN.lua locales\zhTW.lua -TranqRotate.lua -constants.lua -Gui.Lua -defaults.lua -settings.lua \ No newline at end of file +src\tranqRotate.lua +src\events.lua +src\rotation.lua +src\constants.lua +src\gui.lua +src\defaults.lua +src\settings.lua \ No newline at end of file diff --git a/locales/enUS.lua b/locales/enUS.lua index ad7d809..bbca44f 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -39,6 +39,13 @@ local L = { ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TRANQSHOT FAILED ON %s !!!", + --- Rotation + ["SETTING_ROTATION"] = "Rotation", + ["LOCK_WINDOW"] = "Lock window", + ["LOCK_WINDOW_DESC"] = "Lock window", + ["WINDOW_LOCKED"] = "TranqRotate: Window locked", + ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", + --- Profiles ["SETTING_PROFILES"] = "Profiles" } diff --git a/locales/frFR.lua b/locales/frFR.lua index 7c066e1..3359374 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -41,6 +41,13 @@ local L = { ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait sur %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TIR TRANQUILLISANT RATE SUR %s !!!", + --- Rotation + ["SETTING_ROTATION"] = "Rotation", + ["LOCK_WINDOW"] = "Verrouiller la position de la fênetre", + ["LOCK_WINDOW_DESC"] = "Verrouiller la position de la fênetre", + ["WINDOW_LOCKED"] = "TranqRotate: Fenêtre verrouillée", + ["WINDOW_UNLOCKED"] = "TranqRotate: Fenêtre déverrouillée", + --- Profiles ["SETTING_PROFILES"] = "Profils" } diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 35b1539..2c427e7 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -41,6 +41,13 @@ local L = { ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已对 %s 施放了宁神射击!", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 对 %s 宁神失败!!!", + --- Rotation + ["SETTING_ROTATION"] = "Rotation", + ["LOCK_WINDOW"] = "Lock window", + ["LOCK_WINDOW_DESC"] = "Lock window", + ["WINDOW_LOCKED"] = "TranqRotate: Window locked", + ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", + --- Profiles ["SETTING_PROFILES"] = "配置" } diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 6f55e73..0fc2100 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -41,6 +41,13 @@ local L = { ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已對 %s 施放了寧神射擊!", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 對 %s 寧神失敗!!!", + --- Rotation + ["SETTING_ROTATION"] = "Rotation", + ["LOCK_WINDOW"] = "Lock window", + ["LOCK_WINDOW_DESC"] = "Lock window", + ["WINDOW_LOCKED"] = "TranqRotate: Window locked", + ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", + --- Profiles ["SETTING_PROFILES"] = "配置" } diff --git a/constants.lua b/src/constants.lua similarity index 83% rename from constants.lua rename to src/constants.lua index ab81058..c9482fd 100644 --- a/constants.lua +++ b/src/constants.lua @@ -5,5 +5,5 @@ TranqRotate.colors = { ['blue'] = CreateColor(0.3, 0.3, 0.7), ['red'] = CreateColor(0.7, 0.3, 0.3), ['gray'] = CreateColor(0.3, 0.3, 0.3), - + ['purple'] = CreateColor(0.71,0.45,0.75) } \ No newline at end of file diff --git a/defaults.lua b/src/defaults.lua similarity index 51% rename from defaults.lua rename to src/defaults.lua index c1f193e..c1c7d80 100644 --- a/defaults.lua +++ b/src/defaults.lua @@ -5,8 +5,9 @@ function TranqRotate:LoadDefaults() profile = { enableAnnounces = true, channelType = "YELL", - announceSuccessMessage = L["DEFAULT_SUCCESS_ANNOUNCE_MESSAGE"], - announceFailMessage = L["DEFAULT_FAIL_ANNOUNCE_MESSAGE"], + announceSuccessMessage = L["DEFAULT_SUCCESS_ANNOUNCE_MESSAGE"], + announceFailMessage = L["DEFAULT_FAIL_ANNOUNCE_MESSAGE"], + lock = false }, } end \ No newline at end of file diff --git a/src/events.lua b/src/events.lua new file mode 100644 index 0000000..e164bf3 --- /dev/null +++ b/src/events.lua @@ -0,0 +1,60 @@ +local TranqRotate = select(2, ...) + +local TranqShot = GetSpellInfo(19801) +--local TranqShot = GetSpellInfo(14287) --Arcane shot for testing + +local eventFrame = CreateFrame("Frame") +eventFrame:RegisterEvent("PLAYER_LOGIN") +eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") +eventFrame:RegisterEvent("GROUP_ROSTER_UPDATE") +eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED") + +--PARTY_MEMBER_DISABLE +--PARTY_MEMBER_ENABLE +--PLAYER_ROLES_ASSIGNED + +eventFrame:SetScript( + "OnEvent", + function(self, event, ...) + if (event == "PLAYER_LOGIN") then + TranqRotate:init() + self:UnregisterEvent("PLAYER_LOGIN") + elseif (event == "PLAYER_TARGET_CHANGED") then + -- Ugly hack to initialize hunter list when player login right into raid + -- Raid members data is unreliable on PLAYER_LOGIN and PLAYER_ENTERING_WORLD events + TranqRotate:refreshHunterList() + self:UnregisterEvent("PLAYER_TARGET_CHANGED") + else + TranqRotate[event](TranqRotate, ...) + end + end +) + +function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() + + local timestamp, event, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo() + local spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand = select(12, CombatLogGetCurrentEventInfo()) + + if (spellName == TranqShot) then + if (event == "SPELL_CAST_SUCCESS") then + TranqRotate:rotate(TranqRotate:getHunter(nil, sourceGUID), false) + if (sourceGUID == UnitGUID("player")) then + TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceSuccessMessage, destName) + end + elseif (event == "SPELL_MISSED") then + TranqRotate:rotate(TranqRotate:getHunter(nil, sourceGUID), true) + if (sourceGUID == UnitGUID("player")) then + TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceFailMessage, destName) + end + end + end +end + +function TranqRotate:GROUP_ROSTER_UPDATE() + TranqRotate:refreshHunterList() +end + +function TranqRotate:PLAYER_TARGET_CHANGED() + TranqRotate:refreshHunterList() + self:UnregisterEvent("PLAYER_TARGET_CHANGED") +end \ No newline at end of file diff --git a/src/gui.lua b/src/gui.lua new file mode 100644 index 0000000..d98a6ff --- /dev/null +++ b/src/gui.lua @@ -0,0 +1,153 @@ +local TranqRotate = select(2, ...) + +-- Initialize GUI frames. Shouldn't be called more than once +function TranqRotate:initGui() + + TranqRotate.mainFrame = CreateFrame("Frame", nil, UIParent) + TranqRotate.mainFrame:SetFrameStrata("MEDIUM") + TranqRotate.mainFrame:SetWidth(120) + TranqRotate.mainFrame:SetHeight(30) + TranqRotate.mainFrame:Show() + + TranqRotate.mainFrame:RegisterForDrag("LeftButton") + TranqRotate.mainFrame:SetClampedToScreen(true) + TranqRotate.mainFrame:SetScript("OnDragStart", function() TranqRotate.mainFrame:StartMoving() end) + TranqRotate.mainFrame:SetScript("OnDragStop", function() + local config, meh = TranqRotate.db.profile + TranqRotate.mainFrame:StopMovingOrSizing() + config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() + end) + + TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame) + TranqRotate.mainFrame.rotationFrame:SetPoint('TOPLEFT') + TranqRotate.mainFrame.rotationFrame:SetPoint('TOPRIGHT') + TranqRotate.mainFrame.rotationFrame:SetHeight(20) + + TranqRotate.mainFrame.rotationFrame.texture = TranqRotate.mainFrame.rotationFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() + + TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) + TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) + TranqRotate.mainFrame.backupFrame:SetHeight(10) + + TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() + + TranqRotate:drawHunterFrames() +end + +-- render / re-render hunter frames to reflect table changes. +function TranqRotate:drawHunterFrames() + + -- Different height to reduce spacing between both groups + TranqRotate.mainFrame:SetHeight(20) + TranqRotate.mainFrame.rotationFrame:SetHeight(20) + + TranqRotate:drawList(TranqRotate.rotationTables.rotation, TranqRotate.mainFrame.rotationFrame) + + if (#TranqRotate.rotationTables.backup > 0) then + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + 10) + TranqRotate.mainFrame.backupFrame:SetHeight(10) + end + + TranqRotate:drawList(TranqRotate.rotationTables.backup, TranqRotate.mainFrame.backupFrame) + +end + +-- Handle the render of a single hunter frames group +function TranqRotate:drawList(hunterList, parentFrame) + + local index = 1 + local previousHunt = nil + local basicFrameHeight = 20 + local sameGroupSpacing = 2 + + if (#hunterList < 1) then + parentFrame:Hide() + else + parentFrame:Show() + end + + for key,hunter in pairs(hunterList) do + + -- Using existing frame if possible + if (hunter.frame == nil) then + hunter.frame = CreateFrame("Frame", nil, parentFrame) + hunter.frame:SetFrameStrata("MEDIUM") + hunter.frame:SetHeight(basicFrameHeight) + end + + -- Handling anchor and spacing for the first hunter of the group + if (index == 1) then + hunter.frame:SetParent(parentFrame) + + if (parentFrame ~= TranqRotate.mainFrame.backupFrame) then + hunter.frame:SetPoint('TOP', 0, -10) + else + hunter.frame:SetPoint('TOP', 0, 0) + end + + hunter.frame:SetPoint('LEFT', 10, 0) + hunter.frame:SetPoint('RIGHT', -10, 0) + parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + basicFrameHeight) + else + hunter.frame:SetParent(previousHunt.frame) + hunter.frame:ClearAllPoints() + hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -sameGroupSpacing) + hunter.frame:SetPoint('LEFT', 0, 0) + parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) + end + + -- Set Texture + hunter.frame.texture = hunter.frame:CreateTexture(nil, "BACKGROUND") + hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") + hunter.frame.texture:SetAllPoints() + + -- SetColor + setHunterFrameColor(hunter) + + -- Set Text + hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) + hunter.frame.text:SetPoint("LEFT",5,0) + hunter.frame.text:SetText(hunter.name) + + hunter.frame:Show() + hunter.frame.hunter = hunter + + previousHunt = hunter + index = index + 1 + end +end + +-- Hide the hunter frame +function TranqRotate:hideHunter(hunter) + if (hunter.frame ~= nil) then + hunter.frame:Hide() + end +end + +function TranqRotate:refreshHunterFrame(hunter) + setHunterFrameColor(hunter) +end + +-- Set the hunter frame color regarding it's status +function setHunterFrameColor(hunter) + + local color = TranqRotate.colors.green + + if (hunter.offline) then + color = TranqRotate.colors.gray + elseif (not hunter.alive) then + color = TranqRotate.colors.red + elseif (hunter.nextTranq) then + color = TranqRotate.colors.purple + end + + hunter.frame.texture:SetVertexColor(color:GetRGB()) +end \ No newline at end of file diff --git a/src/rotation.lua b/src/rotation.lua new file mode 100644 index 0000000..1f8b6ab --- /dev/null +++ b/src/rotation.lua @@ -0,0 +1,317 @@ +local TranqRotate = select(2, ...) + +function TranqRotate:registerHunter(hunterName) + + -- Init hunter 'object' + local hunter = {} + hunter.name = hunterName + hunter.GUID = UnitGUID(hunterName) + hunter.frame = nil + hunter.offline = false + hunter.alive = true + hunter.nextTranq = false + + -- Add to global list + table.insert(TranqRotate.hunterTable, hunter) + + -- Add to rotation or backup group depending on rotation group size + if (#TranqRotate.rotationTables.rotation > 2) then + table.insert(TranqRotate.rotationTables.backup, hunter) + else + table.insert(TranqRotate.rotationTables.rotation, hunter) + end + + TranqRotate:drawHunterFrames() + + return hunter +end + +function TranqRotate:removeHunter(deletedHunter) + + -- Clear from global list + for key, hunter in pairs(TranqRotate.hunterTable) do + if (hunter.name == deletedHunter.name) then + TranqRotate:hideHunter(hunter) + table.remove(TranqRotate.hunterTable, key) + break + end + end + + -- clear from rotation lists + for key, hunterTable in pairs(TranqRotate.rotationTables) do + for subkey, hunter in pairs(hunterTable) do + if (hunter.name == deletedHunter.name) then + table.remove(hunterTable, subkey) + end + end + end + + TranqRotate:drawHunterFrames() +end + +-- Update the rotation list once a tranq has been done. +-- The parameter is the hunter that used it's tranq (successfully or not) +function TranqRotate:rotate(lastHunter, fail) + + -- Default value to false + local fail = fail or false + local nextHunter = TranqRotate:getNextRotationHunter(lastHunter) + + TranqRotate:setNextTranq(nextHunter) + + if (fail) then + -- Throw alert to the next hunter in the rotation, maybe alert backup too ... + end + +end + +function TranqRotate:setNextTranq(nextHunter) + for key, hunter in pairs(TranqRotate.rotationTables.rotation) do + if (hunter.name == nextHunter.name) then + hunter.nextTranq = true + else + hunter.nextTranq = false + end + + TranqRotate:refreshHunterFrame(hunter) + end +end + +-- Find and returns the next hunter that will tranq base on last shooter +function TranqRotate:getNextRotationHunter(lastHunter) + + local rotationTable = TranqRotate.rotationTables.rotation + local nextHunter = nil + local lastHunterIndex = 1 + local nextHunterIndex = 1 + + -- Finding last hunter index in rotation + for key, hunter in pairs(rotationTable) do + if (hunter.name == lastHunter.name) then + lastHunterIndex = key + break + end + end + + -- Search from last hunter index + for index = lastHunterIndex + 1 , #rotationTable, 1 do + local hunter = rotationTable[index] + if (hunter.alive and not hunter.offline) then + nextHunter = hunter + break + end + end + + -- Restart search from first index + if (nextHunter == nil) then + for index = 1 , lastHunterIndex, 1 do + local hunter = rotationTable[index] + if (hunter.alive and not hunter.offline) then + nextHunter = hunter + break + end + end + end + + return nextHunter +end + +-- Init/Reset rotation status, next tranq is the first hunter on the list +function TranqRotate:resetRotation() + + for key, hunter in pairs(TranqRotate.rotationTables.rotation) do + hunter.nextTranq = false + TranqRotate:refreshHunterFrame(hunter) + end + + if (#TranqRotate.rotationTables.rotation > 0) then + local firstHunter = TranqRotate.rotationTables.rotation[1] + + firstHunter.nextTranq = true + TranqRotate:refreshHunterFrame(firstHunter) + end + +end + +-- TEST FUNCTION - Manually rotate hunters for test purpose +function TranqRotate:testRotation() + + for key, hunter in pairs(TranqRotate.rotationTables.rotation) do + if (hunter.nextTranq) then + TranqRotate:rotate(hunter) + break + end + end +end + +-- Check if a hunter is already registered +function TranqRotate:isHunterRegistered(GUID) + + for key,hunter in pairs(TranqRotate.hunterTable) do + if (hunter.GUID == GUID) then + return true + end + end + + return false +end + +-- Return our hunter object from name or GUID +function TranqRotate:getHunter(name, GUID) + + for key,hunter in pairs(TranqRotate.hunterTable) do + if ((GUID ~= nil and hunter.GUID == GUID) or (name ~= nil and hunter.name == name)) then + return hunter + end + end + + return nil +end + +-- Iterate over hunter list and purge hunter that aren't in the group anymore +function TranqRotate:purgeHunterList() + + local change = false + + for key,hunter in pairs(TranqRotate.hunterTable) do + if (not UnitInParty(hunter.name)) then + TranqRotate:removeHunter(hunter) + change = true + end + end + + if (change) then + TranqRotate:drawHunterFrames() + end + +end + +function TranqRotate:refreshHunterList() + + if (IsInGroup() and IsInRaid()) then + + local playerCount = GetNumGroupMembers() + + --print('player count : ' .. playerCount) + + for index = 1, playerCount, 1 do + + local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(index) + --print(name) + --print('online : ', online) + + -- Players name might be nil at loading + if (name ~= nil) then + local GUID = UnitGUID(name) + local hunter = nil + + if(select(2,UnitClass(name)) == 'HUNTER') then + + if (not TranqRotate:isHunterRegistered(GUID)) then + hunter = TranqRotate:registerHunter(name)GetRaidRosterInfo(index) + else + hunter = TranqRotate:getHunter(nil, GUID) + end + + hunter.offline = not online + hunter.alive = not isDead + + TranqRotate:refreshHunterFrame(hunter) + end + + end + end + + TranqRotate:purgeHunterList() + end +end + +function TranqRotate:moveHunterFromName(name, group, position) + TranqRotate:moveHunter(TranqRotate:getHunter(name, nil), group, position) +end + +function TranqRotate:moveHunter(hunter, group, position) + + local originIndex = nil + local finalIndex = position + + local originTable = TranqRotate:getHunterRotationTable(hunter) + local destinationTable = TranqRotate.rotationTables.rotation + + if (group == 'BACKUP') then + destinationTable = TranqRotate.rotationTables.backup + end + + -- Setting originalIndex + for key, loopHunter in pairs(originTable) do + if (hunter.name == loopHunter.name) then + originIndex = key + break + end + end + + local sameTableMove = originTable == destinationTable + + -- Defining finalIndex + if (sameTableMove) then + if (position > #destinationTable or position == 0) then + if (#destinationTable > 0) then + finalIndex = #destinationTable + else + finalIndex = 1 + end + end + else + if (position > #destinationTable + 1 or position == 0) then + if (#destinationTable > 0) then + finalIndex = #destinationTable + 1 + else + finalIndex = 1 + end + end + end + + if (sameTableMove) then + if (originIndex ~= finalIndex) then + table.remove(originTable, originIndex) + table.insert(originTable, finalIndex, hunter) + end + else + table.remove(originTable, originIndex) + table.insert(destinationTable, finalIndex, hunter) + end + + TranqRotate:drawHunterFrames() +end + +function TranqRotate:getHunterRotationTable(hunter) + if (table.contains(TranqRotate.rotationTables.rotation, hunter)) then + return TranqRotate.rotationTables.rotation + end + if (table.contains(TranqRotate.rotationTables.backup, hunter)) then + return TranqRotate.rotationTables.backup + end +end + +function TranqRotate:test() + --if (IsInRaid()) then + -- local raid_units = {} + -- for i=1,40 do + -- raid_units[i]="raid"..tostring(i) + -- end + -- + -- for i=1,#raid_units do + -- local unit = raid_units[i] + -- + -- if UnitExists(unit) then + -- --print(UnitName(unit)) + -- local index = UnitInRaid(UnitName(unit)) + -- + -- local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(index) + -- + -- print (name, online) + -- + -- end + -- end + --end +end \ No newline at end of file diff --git a/settings.lua b/src/settings.lua similarity index 88% rename from settings.lua rename to src/settings.lua index 8b45594..b4036a3 100644 --- a/settings.lua +++ b/src/settings.lua @@ -13,6 +13,7 @@ function TranqRotate:CreateConfig() local function set(info, value) TranqRotate.db.profile[info[#info]] = value + TranqRotate:applySettings() end local options = { @@ -45,6 +46,19 @@ function TranqRotate:CreateConfig() width = "full", order = 3, }, + spacer = { + name = ' ', + type = "description", + width = "full", + order = 4, + }, + lock = { + name = L["LOCK_WINDOW"], + desc = L["LOCK_WINDOW_DESC"], + type = "toggle", + order = 5, + width = "double", + } } }, announces = { @@ -105,7 +119,7 @@ function TranqRotate:CreateConfig() width = "double", }, } - } + }, } } diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua new file mode 100644 index 0000000..c61e08d --- /dev/null +++ b/src/tranqRotate.lua @@ -0,0 +1,107 @@ +TranqRotate = select(2, ...) + +local L = TranqRotate.L +TranqRotate.version = "1.0.1" + +--local TranqShot = GetSpellInfo(19801) +--local TranqShot = GetSpellInfo(14287) --Arcane shot for testing +--local canTranq = IsUsableSpell(TranqShot) + +function TranqRotate:init() + + self:LoadDefaults() + + self.db = LibStub:GetLibrary("AceDB-3.0"):New("TranqRotateDb", self.defaults, true) + self.db.RegisterCallback(self, "OnProfileChanged", "ProfilesChanged") + self.db.RegisterCallback(self, "OnProfileCopied", "ProfilesChanged") + self.db.RegisterCallback(self, "OnProfileReset", "ProfilesChanged") + + self:CreateConfig() + + TranqRotate.hunterTable = {} + TranqRotate.rotationTables = { rotation = {}, backup = {} } + + TranqRotate:refreshHunterList() + TranqRotate:initGui() + TranqRotate:applySettings() + + TranqRotate:printMessage(L['LOADED_MESSAGE']) +end + +function TranqRotate:ProfilesChanged() + self.db:RegisterDefaults(self.defaults) + + self:applySettings() +end + +function TranqRotate:applySettings() + + TranqRotate.mainFrame:ClearAllPoints() + local config = TranqRotate.db.profile + if config.point then + TranqRotate.mainFrame:SetPoint(config.point, UIParent, config.relativePoint, config.x, config.y) + else + TranqRotate.mainFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + end + + TranqRotate.mainFrame:EnableMouse(not TranqRotate.db.profile.lock) + TranqRotate.mainFrame:SetMovable(not TranqRotate.db.profile.lock) +end + +function TranqRotate:printMessage(msg) + print(msg) +end + +function TranqRotate:sendAnnounceMessage(message, destName) + if TranqRotate.db.profile.enableAnnounces then + local channelNumber + if TranqRotate.db.profile.channelType == "CHANNEL" then + channelNumber = GetChannelName(TranqRotate.db.profile.targetChannel) + end + SendChatMessage(string.format(message,destName), TranqRotate.db.profile.channelType, nil, channelNumber or TranqRotate.db.profile.targetChannel) + end +end + +SLASH_TRANQROTATE1 = "/tranq" +SLASH_TRANQROTATE2 = "/tranqrotate" +SlashCmdList["TRANQROTATE"] = function(msg) + local _, _, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)") + + if (cmd == 'redraw') then + TranqRotate:drawHunterFrames() + elseif (cmd == 'init') then + TranqRotate:resetRotation() + elseif (cmd == 'lock') then + TranqRotate.db.profile.lock = true + TranqRotate:applySettings() + TranqRotate:printMessage(L['WINDOW_LOCKED']) + elseif (cmd == 'unlock') then + TranqRotate.db.profile.lock = false + TranqRotate:applySettings() + TranqRotate:printMessage(L['WINDOW_UNLOCKED']) + elseif (cmd == 'rotate') then + TranqRotate:testRotation() + elseif (cmd == 'raid') then + TranqRotate:refreshHunterList() + elseif (cmd == 'test') then + TranqRotate:test() + elseif (cmd == 'move' and args ~= nil) then + chunks = {} + for substring in args:gmatch("%S+") do + table.insert(chunks, substring) + end + TranqRotate:moveHunterFromName(chunks[1], chunks[2], tonumber(chunks[3])) + else + local AceConfigDialog = LibStub("AceConfigDialog-3.0") + AceConfigDialog:Open("TranqRotate") + end +end + +function table.contains(table, element) + for _, value in pairs(table) do + if value == element then + return true + end + end + return false +end \ No newline at end of file From 8eaec2e915f66271c2e0622314b0af4a7b41d456 Mon Sep 17 00:00:00 2001 From: Guillaume Chopelet Date: Mon, 3 Feb 2020 12:54:37 +0100 Subject: [PATCH 04/37] death/offline handling, lock refactor --- src/events.lua | 39 +++++++++++++++++++++++++++++++++++---- src/gui.lua | 15 +++++++++++++++ src/rotation.lua | 36 +++++++++++++++++++++++++++--------- src/tranqRotate.lua | 35 ++++++++++++++++------------------- 4 files changed, 93 insertions(+), 32 deletions(-) diff --git a/src/events.lua b/src/events.lua index e164bf3..d97e036 100644 --- a/src/events.lua +++ b/src/events.lua @@ -9,6 +9,10 @@ eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") eventFrame:RegisterEvent("GROUP_ROSTER_UPDATE") eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED") +-- @todo: clean this +--eventFrame:RegisterEvent("PARTY_MEMBER_DISABLE") +--eventFrame:RegisterEvent("PARTY_MEMBER_ENABLE") + --PARTY_MEMBER_DISABLE --PARTY_MEMBER_ENABLE --PLAYER_ROLES_ASSIGNED @@ -22,7 +26,7 @@ eventFrame:SetScript( elseif (event == "PLAYER_TARGET_CHANGED") then -- Ugly hack to initialize hunter list when player login right into raid -- Raid members data is unreliable on PLAYER_LOGIN and PLAYER_ENTERING_WORLD events - TranqRotate:refreshHunterList() + TranqRotate:updateRaidStatus() self:UnregisterEvent("PLAYER_TARGET_CHANGED") else TranqRotate[event](TranqRotate, ...) @@ -50,11 +54,38 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() end end +-- Register single unit events for a given hunter +function TranqRotate:registerUnitEvents(hunter) + + hunter.frame:RegisterUnitEvent("PARTY_MEMBER_DISABLE", hunter.name) + hunter.frame:RegisterUnitEvent("PARTY_MEMBER_ENABLE", hunter.name) + --hunter.frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", hunter.name) -- Could be needed with UNIT_HEALTH throtle + hunter.frame:RegisterUnitEvent("UNIT_HEALTH", hunter.name) + hunter.frame:RegisterUnitEvent("UNIT_CONNECTION", hunter.name) + hunter.frame:RegisterUnitEvent("UNIT_FLAGS", hunter.name) + + hunter.frame:SetScript( + "OnEvent", + function(self, event, ...) + TranqRotate:updateHuntersStatus() + end + ) + +end + +function TranqRotate:unregisterUnitEvents() + self:UnregisterEvent("PARTY_MEMBER_DISABLE") + self:UnregisterEvent("PARTY_MEMBER_ENABLE") + self:UnregisterEvent("UNIT_HEALTH_FREQUENT") + self:UnregisterEvent("UNIT_CONNECTION") + self:UnregisterEvent("UNIT_FLAGS") +end + function TranqRotate:GROUP_ROSTER_UPDATE() - TranqRotate:refreshHunterList() + TranqRotate:updateRaidStatus() end function TranqRotate:PLAYER_TARGET_CHANGED() - TranqRotate:refreshHunterList() + TranqRotate:updateRaidStatus() self:UnregisterEvent("PLAYER_TARGET_CHANGED") -end \ No newline at end of file +end diff --git a/src/gui.lua b/src/gui.lua index d98a6ff..ecaf651 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -1,5 +1,7 @@ local TranqRotate = select(2, ...) +local L = TranqRotate.L + -- Initialize GUI frames. Shouldn't be called more than once function TranqRotate:initGui() @@ -132,6 +134,7 @@ function TranqRotate:hideHunter(hunter) end end +-- Refresh a single hunter frame function TranqRotate:refreshHunterFrame(hunter) setHunterFrameColor(hunter) end @@ -150,4 +153,16 @@ function setHunterFrameColor(hunter) end hunter.frame.texture:SetVertexColor(color:GetRGB()) +end + +-- Lock/Unlock the mainFrame position +function TranqRotate:lock(lock) + TranqRotate.db.profile.lock = lock + TranqRotate:applySettings() + + if (lock) then + TranqRotate:printMessage(L['WINDOW_LOCKED']) + else + TranqRotate:printMessage(L['WINDOW_UNLOCKED']) + end end \ No newline at end of file diff --git a/src/rotation.lua b/src/rotation.lua index 1f8b6ab..2178968 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -1,8 +1,9 @@ local TranqRotate = select(2, ...) +-- Adds hunter to global table and one of the two rotation tables function TranqRotate:registerHunter(hunterName) - -- Init hunter 'object' + -- Initialize hunter 'object' local hunter = {} hunter.name = hunterName hunter.GUID = UnitGUID(hunterName) @@ -26,6 +27,7 @@ function TranqRotate:registerHunter(hunterName) return hunter end +-- Removes a hunter from all lists function TranqRotate:removeHunter(deletedHunter) -- Clear from global list @@ -65,6 +67,7 @@ function TranqRotate:rotate(lastHunter, fail) end +-- Removes all nextTranq flags and set it true for next shooter function TranqRotate:setNextTranq(nextHunter) for key, hunter in pairs(TranqRotate.rotationTables.rotation) do if (hunter.name == nextHunter.name) then @@ -133,7 +136,7 @@ function TranqRotate:resetRotation() end --- TEST FUNCTION - Manually rotate hunters for test purpose +-- @todo: remove this | TEST FUNCTION - Manually rotate hunters for test purpose function TranqRotate:testRotation() for key, hunter in pairs(TranqRotate.rotationTables.rotation) do @@ -176,6 +179,7 @@ function TranqRotate:purgeHunterList() for key,hunter in pairs(TranqRotate.hunterTable) do if (not UnitInParty(hunter.name)) then TranqRotate:removeHunter(hunter) + TranqRotate:unregisterUnitEvents() change = true end end @@ -186,29 +190,27 @@ function TranqRotate:purgeHunterList() end -function TranqRotate:refreshHunterList() +-- Iterate over all raid members to find hunters and update their status +function TranqRotate:updateRaidStatus() if (IsInGroup() and IsInRaid()) then local playerCount = GetNumGroupMembers() - --print('player count : ' .. playerCount) - for index = 1, playerCount, 1 do local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(index) - --print(name) - --print('online : ', online) -- Players name might be nil at loading if (name ~= nil) then local GUID = UnitGUID(name) local hunter = nil - if(select(2,UnitClass(name)) == 'HUNTER') then + if(true or select(2,UnitClass(name)) == 'HUNTER') then if (not TranqRotate:isHunterRegistered(GUID)) then - hunter = TranqRotate:registerHunter(name)GetRaidRosterInfo(index) + hunter = TranqRotate:registerHunter(name) + TranqRotate:registerUnitEvents(hunter) else hunter = TranqRotate:getHunter(nil, GUID) end @@ -226,10 +228,24 @@ function TranqRotate:refreshHunterList() end end +-- Update registered hunters status to reflect dead/offline players +function TranqRotate:updateHuntersStatus() + + for key,hunter in pairs(TranqRotate.hunterTable) do + + hunter.alive = not UnitIsDeadOrGhost(hunter.name) + hunter.offline = not UnitIsConnected(hunter.name) + + TranqRotate:refreshHunterFrame(hunter) + end +end + +-- @todo: Remove once drag & drop is ok | TEST function allowing slash command with name to move hunters function TranqRotate:moveHunterFromName(name, group, position) TranqRotate:moveHunter(TranqRotate:getHunter(name, nil), group, position) end +-- Moves given hunter to the given position in the given group (ROTATION or BACKUP) function TranqRotate:moveHunter(hunter, group, position) local originIndex = nil @@ -284,6 +300,7 @@ function TranqRotate:moveHunter(hunter, group, position) TranqRotate:drawHunterFrames() end +-- Find the table that contains given hunter (rotation or backup) function TranqRotate:getHunterRotationTable(hunter) if (table.contains(TranqRotate.rotationTables.rotation, hunter)) then return TranqRotate.rotationTables.rotation @@ -293,6 +310,7 @@ function TranqRotate:getHunterRotationTable(hunter) end end +-- @todo: remove this function TranqRotate:test() --if (IsInRaid()) then -- local raid_units = {} diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index c61e08d..000b675 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -1,12 +1,9 @@ TranqRotate = select(2, ...) local L = TranqRotate.L -TranqRotate.version = "1.0.1" - ---local TranqShot = GetSpellInfo(19801) ---local TranqShot = GetSpellInfo(14287) --Arcane shot for testing ---local canTranq = IsUsableSpell(TranqShot) +TranqRotate.version = "1.1.0" +-- Initialize addon - Shouldn't be call more than once function TranqRotate:init() self:LoadDefaults() @@ -21,19 +18,21 @@ function TranqRotate:init() TranqRotate.hunterTable = {} TranqRotate.rotationTables = { rotation = {}, backup = {} } - TranqRotate:refreshHunterList() TranqRotate:initGui() + TranqRotate:updateRaidStatus() TranqRotate:applySettings() TranqRotate:printMessage(L['LOADED_MESSAGE']) end +-- Apply setting on profile change function TranqRotate:ProfilesChanged() self.db:RegisterDefaults(self.defaults) self:applySettings() end +-- Apply settings function TranqRotate:applySettings() TranqRotate.mainFrame:ClearAllPoints() @@ -48,10 +47,12 @@ function TranqRotate:applySettings() TranqRotate.mainFrame:SetMovable(not TranqRotate.db.profile.lock) end +-- Print wrapper, just in case function TranqRotate:printMessage(msg) print(msg) end +-- Send a message to a given channel function TranqRotate:sendAnnounceMessage(message, destName) if TranqRotate.db.profile.enableAnnounces then local channelNumber @@ -67,25 +68,21 @@ SLASH_TRANQROTATE2 = "/tranqrotate" SlashCmdList["TRANQROTATE"] = function(msg) local _, _, cmd, args = string.find(msg, "%s?(%w+)%s?(.*)") - if (cmd == 'redraw') then + if (cmd == 'redraw') then -- @todo decide if this should be removed or not TranqRotate:drawHunterFrames() - elseif (cmd == 'init') then + elseif (cmd == 'init') then -- @todo: remove this TranqRotate:resetRotation() elseif (cmd == 'lock') then - TranqRotate.db.profile.lock = true - TranqRotate:applySettings() - TranqRotate:printMessage(L['WINDOW_LOCKED']) + TranqRotate:lock(true) elseif (cmd == 'unlock') then - TranqRotate.db.profile.lock = false - TranqRotate:applySettings() - TranqRotate:printMessage(L['WINDOW_UNLOCKED']) - elseif (cmd == 'rotate') then + TranqRotate:lock(false) + elseif (cmd == 'rotate') then -- @todo decide if this should be removed or not TranqRotate:testRotation() - elseif (cmd == 'raid') then - TranqRotate:refreshHunterList() - elseif (cmd == 'test') then + elseif (cmd == 'raid') then -- @todo: (Maybe) remove once raid members are properly updated + TranqRotate:updateRaidStatus() + elseif (cmd == 'test') then -- @todo: remove this TranqRotate:test() - elseif (cmd == 'move' and args ~= nil) then + elseif (cmd == 'move' and args ~= nil) then -- @todo: remove this when drag & drop is ok chunks = {} for substring in args:gmatch("%S+") do table.insert(chunks, substring) From 98005f51d6b89126fba38bcccf0df6aa0cd895d0 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Wed, 5 Feb 2020 13:43:16 +0100 Subject: [PATCH 05/37] Adds base drag mechanics, Adds base drophint mechanics --- src/constants.lua | 7 +- src/defaults.lua | 2 +- src/gui.lua | 207 +++++++++++++++++++++++++++++++++++++------- src/rotation.lua | 27 ++++-- src/tranqRotate.lua | 1 - 5 files changed, 201 insertions(+), 43 deletions(-) diff --git a/src/constants.lua b/src/constants.lua index c9482fd..4d5611c 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -6,4 +6,9 @@ TranqRotate.colors = { ['red'] = CreateColor(0.7, 0.3, 0.3), ['gray'] = CreateColor(0.3, 0.3, 0.3), ['purple'] = CreateColor(0.71,0.45,0.75) -} \ No newline at end of file +} + +TranqRotate.constants = { + ['hunterFrameHeight'] = 20, + ['hunterFrameSpacing'] = 4, +} diff --git a/src/defaults.lua b/src/defaults.lua index c1c7d80..e7890ba 100644 --- a/src/defaults.lua +++ b/src/defaults.lua @@ -10,4 +10,4 @@ function TranqRotate:LoadDefaults() lock = false }, } -end \ No newline at end of file +end diff --git a/src/gui.lua b/src/gui.lua index ecaf651..a6c1146 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -5,7 +5,7 @@ local L = TranqRotate.L -- Initialize GUI frames. Shouldn't be called more than once function TranqRotate:initGui() - TranqRotate.mainFrame = CreateFrame("Frame", nil, UIParent) + TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) TranqRotate.mainFrame:SetFrameStrata("MEDIUM") TranqRotate.mainFrame:SetWidth(120) TranqRotate.mainFrame:SetHeight(30) @@ -20,7 +20,7 @@ function TranqRotate:initGui() config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() end) - TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame) + TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.rotationFrame:SetPoint('TOPLEFT') TranqRotate.mainFrame.rotationFrame:SetPoint('TOPRIGHT') TranqRotate.mainFrame.rotationFrame:SetHeight(20) @@ -29,16 +29,24 @@ function TranqRotate:initGui() TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() - TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) - TranqRotate.mainFrame.backupFrame:SetHeight(10) + TranqRotate.mainFrame.backupFrame:SetHeight(20) TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() + TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0.8,0.8,0.8,0.8) + TranqRotate.mainFrame.backupFrame.texture:SetHeight(1) + TranqRotate.mainFrame.backupFrame.texture:SetWidth(60) + TranqRotate.mainFrame.backupFrame.texture:SetPoint('TOP') + TranqRotate:drawHunterFrames() + TranqRotate:createDropHintFrame() + TranqRotate:createMeterFrame() end -- render / re-render hunter frames to reflect table changes. @@ -51,8 +59,8 @@ function TranqRotate:drawHunterFrames() TranqRotate:drawList(TranqRotate.rotationTables.rotation, TranqRotate.mainFrame.rotationFrame) if (#TranqRotate.rotationTables.backup > 0) then - TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + 10) - TranqRotate.mainFrame.backupFrame:SetHeight(10) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + 20) + TranqRotate.mainFrame.backupFrame:SetHeight(20) end TranqRotate:drawList(TranqRotate.rotationTables.backup, TranqRotate.mainFrame.backupFrame) @@ -63,11 +71,10 @@ end function TranqRotate:drawList(hunterList, parentFrame) local index = 1 - local previousHunt = nil - local basicFrameHeight = 20 - local sameGroupSpacing = 2 + local hunterFrameHeight = TranqRotate.constants.hunterFrameHeight + local hunterFrameSpacing = TranqRotate.constants.hunterFrameSpacing - if (#hunterList < 1) then + if (#hunterList < 1 and parentFrame == TranqRotate.mainFrame.backupFrame) then parentFrame:Hide() else parentFrame:Show() @@ -79,34 +86,32 @@ function TranqRotate:drawList(hunterList, parentFrame) if (hunter.frame == nil) then hunter.frame = CreateFrame("Frame", nil, parentFrame) hunter.frame:SetFrameStrata("MEDIUM") - hunter.frame:SetHeight(basicFrameHeight) - end + hunter.frame:SetHeight(hunterFrameHeight) - -- Handling anchor and spacing for the first hunter of the group - if (index == 1) then + TranqRotate:setHunterFrameDraggable(hunter) + else hunter.frame:SetParent(parentFrame) + end - if (parentFrame ~= TranqRotate.mainFrame.backupFrame) then - hunter.frame:SetPoint('TOP', 0, -10) - else - hunter.frame:SetPoint('TOP', 0, 0) - end + hunter.frame:ClearAllPoints() + hunter.frame:SetPoint('LEFT', 10, 0) + hunter.frame:SetPoint('RIGHT', -10, 0) - hunter.frame:SetPoint('LEFT', 10, 0) - hunter.frame:SetPoint('RIGHT', -10, 0) - parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight) - TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + basicFrameHeight) + -- Setting top margin + local marginTop = 10 + (index - 1) * (hunterFrameHeight + hunterFrameSpacing) + hunter.frame:SetPoint('TOP', parentFrame, 'TOP', 0, -marginTop) + + -- Handling parent windows height increase + if (index == 1) then + parentFrame:SetHeight(parentFrame:GetHeight() + hunterFrameHeight) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + hunterFrameHeight) else - hunter.frame:SetParent(previousHunt.frame) - hunter.frame:ClearAllPoints() - hunter.frame:SetPoint('TOP', previousHunt.frame, 'BOTTOM', 0, -sameGroupSpacing) - hunter.frame:SetPoint('LEFT', 0, 0) - parentFrame:SetHeight(parentFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) - TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + basicFrameHeight + sameGroupSpacing) + parentFrame:SetHeight(parentFrame:GetHeight() + hunterFrameHeight + hunterFrameSpacing) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + hunterFrameHeight + hunterFrameSpacing) end -- Set Texture - hunter.frame.texture = hunter.frame:CreateTexture(nil, "BACKGROUND") + hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") hunter.frame.texture:SetAllPoints() @@ -122,7 +127,6 @@ function TranqRotate:drawList(hunterList, parentFrame) hunter.frame:Show() hunter.frame.hunter = hunter - previousHunt = hunter index = index + 1 end end @@ -165,4 +169,145 @@ function TranqRotate:lock(lock) else TranqRotate:printMessage(L['WINDOW_UNLOCKED']) end +end + +-- Enable drag & drop for all hunter frames +function TranqRotate:enableListSorting() + for key,hunter in pairs(TranqRotate.hunterTable) do + TranqRotate:enableHunterFrameDragging(hunter, true) + end +end + +-- configure hunter frame drag behavior +function TranqRotate:setHunterFrameDraggable(hunter) + + hunter.frame:RegisterForDrag("LeftButton") + hunter.frame:SetClampedToScreen(true) + + hunter.frame:SetScript( + "OnDragStart", + function() + hunter.frame:StartMoving() + hunter.frame:SetFrameStrata("HIGH") + TranqRotate.mainFrame.meterFrame:SetPoint('BOTTOMRIGHT', hunter.frame, 'TOPLEFT', 0, 0) + TranqRotate.mainFrame.dropHintFrame:Show() + TranqRotate.mainFrame.backupFrame:Show() + end + ) + + hunter.frame:SetScript( + "OnDragStop", + function() + hunter.frame:StopMovingOrSizing() + hunter.frame:SetFrameStrata("MEDIUM") + TranqRotate.mainFrame.dropHintFrame:Hide() + + if (#TranqRotate.rotationTables.backup < 1) then + TranqRotate.mainFrame.backupFrame:Hide() + end + --config.point, meh , config.relativePoint, config.x, config.y = hunter.frame:GetPoint() + + --print(hunter.frame:GetPoint()) + --print(hunter.frame:GetParent():GetName()) + print('Drop') + end + ) +end + +-- Enable or disable drag & drop for the hunter frame +function TranqRotate:enableHunterFrameDragging(hunter, movable) + hunter.frame:EnableMouse(movable) + hunter.frame:SetMovable(movable) +end + +-- create and initialize the drop hint frame +function TranqRotate:createDropHintFrame() + + local hintFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + + hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) + hintFrame:SetFrameStrata("MEDIUM") + hintFrame:SetHeight(20) + hintFrame:SetWidth(110) + + hintFrame.texture = hintFrame:CreateTexture(nil, "BACKGROUND") + hintFrame.texture:SetColorTexture(TranqRotate.colors.blue:GetRGB()) + hintFrame.texture:SetPoint('LEFT') + hintFrame.texture:SetPoint('RIGHT') + hintFrame.texture:SetHeight(2) + + hintFrame:Hide() + + TranqRotate.mainFrame.dropHintFrame = hintFrame +end + +-- Create and initialize the 'meter' frame. +-- It's height will be used as a ruler for position calculation +function TranqRotate:createMeterFrame() + + local meterFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + + meterFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame, 'TOPLEFT', 0, 0) + + -- @todo : Remove this + --meterFrame.texture = meterFrame:CreateTexture(nil, "BACKGROUND") + --meterFrame.texture:SetColorTexture(0.8, 0.5, 0.5, 0.2) + --meterFrame.texture:SetAllPoints() + --meterFrame:Show() + + TranqRotate.mainFrame.meterFrame = meterFrame + + meterFrame:SetScript( + "OnSizeChanged", + function (self, width, height) + TranqRotate:setDropHintPosition(self, width, height) + end + ) + +end + +-- Set the drop hint frame position to match dragged frame position +function TranqRotate:setDropHintPosition(self, width, height) + + local hunterFrameHeight = TranqRotate.constants.hunterFrameHeight + local hunterFrameSpacing = TranqRotate.constants.hunterFrameSpacing + local hintPosition = 0 + + -- Hunt frame is above rotation frames + if (TranqRotate.mainFrame.meterFrame:GetTop() > TranqRotate.mainFrame.rotationFrame:GetTop()) then + height = 0 + end + + local index = floor(height / 22) + + -- Small offset to the first position so it does not clip hunt frame + if (index == 0) then + hintPosition = -2 + else + hintPosition = (index) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; + end + + -- Hunter frame is bellow rotation frame + if (height > TranqRotate.mainFrame.rotationFrame:GetHeight()) then + + -- Removing rotation frame size from calculation, using it's height as base hintPosition offset + height = height - TranqRotate.mainFrame.rotationFrame:GetHeight() + hintPosition = TranqRotate.mainFrame.rotationFrame:GetHeight() + + if (height > TranqRotate.mainFrame.backupFrame:GetHeight()) then + -- Frame is bellow backup frame + hintPosition = hintPosition + TranqRotate.mainFrame.backupFrame:GetHeight() - hunterFrameHeight + hunterFrameSpacing / 2 + else + index = floor(height / (hunterFrameHeight + hunterFrameSpacing)) + + -- Small offset to the first position so it does not clip hunt frame + if (index == 0) then + hintPosition = hintPosition - 2 + else + hintPosition = hintPosition + (index) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; + end + end + end + + TranqRotate.mainFrame.dropHintFrame:SetPoint('TOP', 0 , -hintPosition) end \ No newline at end of file diff --git a/src/rotation.lua b/src/rotation.lua index 2178968..7af3597 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -178,8 +178,8 @@ function TranqRotate:purgeHunterList() for key,hunter in pairs(TranqRotate.hunterTable) do if (not UnitInParty(hunter.name)) then - TranqRotate:removeHunter(hunter) TranqRotate:unregisterUnitEvents() + TranqRotate:removeHunter(hunter) change = true end end @@ -208,24 +208,31 @@ function TranqRotate:updateRaidStatus() if(true or select(2,UnitClass(name)) == 'HUNTER') then - if (not TranqRotate:isHunterRegistered(GUID)) then - hunter = TranqRotate:registerHunter(name) - TranqRotate:registerUnitEvents(hunter) + local registered = TranqRotate:isHunterRegistered(GUID) + + if (not registered) then + if (not InCombatLockdown()) then + hunter = TranqRotate:registerHunter(name) + TranqRotate:registerUnitEvents(hunter) + registered = true + end else hunter = TranqRotate:getHunter(nil, GUID) end - hunter.offline = not online - hunter.alive = not isDead + if (registered) then + hunter.offline = not online + hunter.alive = not isDead - TranqRotate:refreshHunterFrame(hunter) + TranqRotate:refreshHunterFrame(hunter) + end end end end - - TranqRotate:purgeHunterList() end + + TranqRotate:purgeHunterList() end -- Update registered hunters status to reflect dead/offline players @@ -312,6 +319,8 @@ end -- @todo: remove this function TranqRotate:test() + + TranqRotate:enableListSorting() --if (IsInRaid()) then -- local raid_units = {} -- for i=1,40 do diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 000b675..1757cc9 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -28,7 +28,6 @@ end -- Apply setting on profile change function TranqRotate:ProfilesChanged() self.db:RegisterDefaults(self.defaults) - self:applySettings() end From eb0c360647e653138f88d66c1dc56c9bf84625a2 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 6 Feb 2020 13:28:10 +0100 Subject: [PATCH 06/37] adds drop mechanics --- TranqRotate.toc | 1 + src/dragdrop.lua | 185 +++++++++++++++++++++++++++++++++++++++++++++++ src/events.lua | 18 ++--- src/gui.lua | 167 ++++-------------------------------------- src/rotation.lua | 48 +++++------- 5 files changed, 224 insertions(+), 195 deletions(-) create mode 100644 src/dragdrop.lua diff --git a/TranqRotate.toc b/TranqRotate.toc index 569709c..8d7a0a8 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -25,5 +25,6 @@ src\events.lua src\rotation.lua src\constants.lua src\gui.lua +src\dragdrop.lua src\defaults.lua src\settings.lua \ No newline at end of file diff --git a/src/dragdrop.lua b/src/dragdrop.lua new file mode 100644 index 0000000..8fbe707 --- /dev/null +++ b/src/dragdrop.lua @@ -0,0 +1,185 @@ +local TranqRotate = select(2, ...) + +-- Enable drag & drop for all hunter frames +function TranqRotate:enableListSorting() + for key,hunter in pairs(TranqRotate.hunterTable) do + TranqRotate:enableHunterFrameDragging(hunter, true) + end +end + +-- Enable or disable drag & drop for the hunter frame +function TranqRotate:enableHunterFrameDragging(hunter, movable) + hunter.frame:EnableMouse(movable) + hunter.frame:SetMovable(movable) +end + +-- configure hunter frame drag behavior +function TranqRotate:configureHunterFrameDrag(hunter) + + hunter.frame:RegisterForDrag("LeftButton") + hunter.frame:SetClampedToScreen(true) + + hunter.frame:SetScript( + "OnDragStart", + function() + hunter.frame:StartMoving() + hunter.frame:SetFrameStrata("HIGH") + TranqRotate.mainFrame.rulerFrame:SetPoint('BOTTOMRIGHT', hunter.frame, 'TOPLEFT', 0, 0) + TranqRotate.mainFrame.dropHintFrame:Show() + TranqRotate.mainFrame.backupFrame:Show() + end + ) + + hunter.frame:SetScript( + "OnDragStop", + function() + hunter.frame:StopMovingOrSizing() + hunter.frame:SetFrameStrata("MEDIUM") + TranqRotate.mainFrame.dropHintFrame:Hide() + + if (#TranqRotate.rotationTables.backup < 1) then + TranqRotate.mainFrame.backupFrame:Hide() + end + + local group, position = TranqRotate:getDropPosition(TranqRotate.mainFrame.rulerFrame:GetHeight()) + TranqRotate:handleDrop(hunter, group, position) + + end + ) +end + +-- create and initialize the drop hint frame +function TranqRotate:createDropHintFrame() + + local hintFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + + hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) + hintFrame:SetFrameStrata("MEDIUM") + hintFrame:SetHeight(20) + hintFrame:SetWidth(110) + + hintFrame.texture = hintFrame:CreateTexture(nil, "BACKGROUND") + hintFrame.texture:SetColorTexture(TranqRotate.colors.blue:GetRGB()) + -- @todo tweak the hint bar color + --hintFrame.texture:SetAlpha('LEFT') + hintFrame.texture:SetPoint('LEFT') + hintFrame.texture:SetPoint('RIGHT') + hintFrame.texture:SetHeight(2) + + hintFrame:Hide() + + TranqRotate.mainFrame.dropHintFrame = hintFrame +end + +-- Create and initialize the 'ruler' frame. +-- It's height will be used as a ruler for position calculation +function TranqRotate:createRulerFrame() + + local rulerFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) + TranqRotate.mainFrame.rulerFrame = rulerFrame + + rulerFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame, 'TOPLEFT', 0, 0) + + rulerFrame:SetScript( + "OnSizeChanged", + function (self, width, height) + TranqRotate:setDropHintPosition(self, width, height) + end + ) + +end + +-- Set the drop hint frame position to match dragged frame position +function TranqRotate:setDropHintPosition(self, width, height) + + local hunterFrameHeight = TranqRotate.constants.hunterFrameHeight + local hunterFrameSpacing = TranqRotate.constants.hunterFrameSpacing + local hintPosition = 0 + + local group, position = TranqRotate:getDropPosition(height) + + if (group == 'ROTATION') then + if (position == 0) then + hintPosition = -2 + else + hintPosition = (position) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; + end + else + hintPosition = TranqRotate.mainFrame.rotationFrame:GetHeight() + + if (position == 0) then + hintPosition = hintPosition - 2 + else + hintPosition = hintPosition + (position) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; + end + end + + TranqRotate.mainFrame.dropHintFrame:SetPoint('TOP', 0 , -hintPosition) +end + +-- Compute drop group and position from ruler height +function TranqRotate:getDropPosition(rulerHeight) + + local group = 'ROTATION' + local position = 0 + + local hunterFrameHeight = TranqRotate.constants.hunterFrameHeight + local hunterFrameSpacing = TranqRotate.constants.hunterFrameSpacing + + -- Dragged frame is above rotation frames + if (TranqRotate.mainFrame.rulerFrame:GetTop() > TranqRotate.mainFrame.rotationFrame:GetTop()) then + rulerHeight = 0 + end + + position = floor(rulerHeight / (hunterFrameHeight + hunterFrameSpacing)) + + -- Dragged frame is bellow rotation frame + if (rulerHeight > TranqRotate.mainFrame.rotationFrame:GetHeight()) then + + group = 'BACKUP' + + -- Removing rotation frame size from calculation, using it's height as base hintPosition offset + rulerHeight = rulerHeight - TranqRotate.mainFrame.rotationFrame:GetHeight() + + if (rulerHeight > TranqRotate.mainFrame.backupFrame:GetHeight()) then + -- Dragged frame is bellow backup frame + position = #TranqRotate.rotationTables.backup + else + position = floor(rulerHeight / (hunterFrameHeight + hunterFrameSpacing)) + end + end + + return group, position +end + +-- Compute the table final position from the drop position +function TranqRotate:handleDrop(hunter, group, position) + + local originTable = TranqRotate:getHunterRotationTable(hunter) + local originIndex = TranqRotate:getHunterIndex(hunter, originTable) + + local destinationTable = TranqRotate.rotationTables.rotation + local finalPosition = 1 + + if (group == "BACKUP") then + destinationTable = TranqRotate.rotationTables.backup + end + + if (destinationTable == originTable) then + + if (position == originIndex or position == originIndex - 1 ) then + finalPosition = originIndex + else + if (position > originIndex) then + finalPosition = position + else + finalPosition = position + 1 + end + end + + else + finalPosition = position + 1 + end + + TranqRotate:moveHunter(hunter, group, finalPosition) +end diff --git a/src/events.lua b/src/events.lua index d97e036..096196b 100644 --- a/src/events.lua +++ b/src/events.lua @@ -10,11 +10,6 @@ eventFrame:RegisterEvent("GROUP_ROSTER_UPDATE") eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED") -- @todo: clean this ---eventFrame:RegisterEvent("PARTY_MEMBER_DISABLE") ---eventFrame:RegisterEvent("PARTY_MEMBER_ENABLE") - ---PARTY_MEMBER_DISABLE ---PARTY_MEMBER_ENABLE --PLAYER_ROLES_ASSIGNED eventFrame:SetScript( @@ -73,12 +68,13 @@ function TranqRotate:registerUnitEvents(hunter) end -function TranqRotate:unregisterUnitEvents() - self:UnregisterEvent("PARTY_MEMBER_DISABLE") - self:UnregisterEvent("PARTY_MEMBER_ENABLE") - self:UnregisterEvent("UNIT_HEALTH_FREQUENT") - self:UnregisterEvent("UNIT_CONNECTION") - self:UnregisterEvent("UNIT_FLAGS") +-- Unregister single unit events for a given hunter +function TranqRotate:unregisterUnitEvents(hunter) + hunter.frame:UnregisterEvent("PARTY_MEMBER_DISABLE") + hunter.frame:UnregisterEvent("PARTY_MEMBER_ENABLE") + hunter.frame:UnregisterEvent("UNIT_HEALTH_FREQUENT") + hunter.frame:UnregisterEvent("UNIT_CONNECTION") + hunter.frame:UnregisterEvent("UNIT_FLAGS") end function TranqRotate:GROUP_ROSTER_UPDATE() diff --git a/src/gui.lua b/src/gui.lua index a6c1146..ef125bd 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -46,7 +46,7 @@ function TranqRotate:initGui() TranqRotate:drawHunterFrames() TranqRotate:createDropHintFrame() - TranqRotate:createMeterFrame() + TranqRotate:createRulerFrame() end -- render / re-render hunter frames to reflect table changes. @@ -88,7 +88,18 @@ function TranqRotate:drawList(hunterList, parentFrame) hunter.frame:SetFrameStrata("MEDIUM") hunter.frame:SetHeight(hunterFrameHeight) - TranqRotate:setHunterFrameDraggable(hunter) + -- Set Texture + hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") + hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") + hunter.frame.texture:SetAllPoints() + + -- Set Text + hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) + hunter.frame.text:SetPoint("LEFT",5,0) + hunter.frame.text:SetText(hunter.name) + + TranqRotate:configureHunterFrameDrag(hunter) else hunter.frame:SetParent(parentFrame) end @@ -110,20 +121,9 @@ function TranqRotate:drawList(hunterList, parentFrame) TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + hunterFrameHeight + hunterFrameSpacing) end - -- Set Texture - hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") - hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") - hunter.frame.texture:SetAllPoints() - -- SetColor setHunterFrameColor(hunter) - -- Set Text - hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") - hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) - hunter.frame.text:SetPoint("LEFT",5,0) - hunter.frame.text:SetText(hunter.name) - hunter.frame:Show() hunter.frame.hunter = hunter @@ -170,144 +170,3 @@ function TranqRotate:lock(lock) TranqRotate:printMessage(L['WINDOW_UNLOCKED']) end end - --- Enable drag & drop for all hunter frames -function TranqRotate:enableListSorting() - for key,hunter in pairs(TranqRotate.hunterTable) do - TranqRotate:enableHunterFrameDragging(hunter, true) - end -end - --- configure hunter frame drag behavior -function TranqRotate:setHunterFrameDraggable(hunter) - - hunter.frame:RegisterForDrag("LeftButton") - hunter.frame:SetClampedToScreen(true) - - hunter.frame:SetScript( - "OnDragStart", - function() - hunter.frame:StartMoving() - hunter.frame:SetFrameStrata("HIGH") - TranqRotate.mainFrame.meterFrame:SetPoint('BOTTOMRIGHT', hunter.frame, 'TOPLEFT', 0, 0) - TranqRotate.mainFrame.dropHintFrame:Show() - TranqRotate.mainFrame.backupFrame:Show() - end - ) - - hunter.frame:SetScript( - "OnDragStop", - function() - hunter.frame:StopMovingOrSizing() - hunter.frame:SetFrameStrata("MEDIUM") - TranqRotate.mainFrame.dropHintFrame:Hide() - - if (#TranqRotate.rotationTables.backup < 1) then - TranqRotate.mainFrame.backupFrame:Hide() - end - --config.point, meh , config.relativePoint, config.x, config.y = hunter.frame:GetPoint() - - --print(hunter.frame:GetPoint()) - --print(hunter.frame:GetParent():GetName()) - print('Drop') - end - ) -end - --- Enable or disable drag & drop for the hunter frame -function TranqRotate:enableHunterFrameDragging(hunter, movable) - hunter.frame:EnableMouse(movable) - hunter.frame:SetMovable(movable) -end - --- create and initialize the drop hint frame -function TranqRotate:createDropHintFrame() - - local hintFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) - - hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) - hintFrame:SetFrameStrata("MEDIUM") - hintFrame:SetHeight(20) - hintFrame:SetWidth(110) - - hintFrame.texture = hintFrame:CreateTexture(nil, "BACKGROUND") - hintFrame.texture:SetColorTexture(TranqRotate.colors.blue:GetRGB()) - hintFrame.texture:SetPoint('LEFT') - hintFrame.texture:SetPoint('RIGHT') - hintFrame.texture:SetHeight(2) - - hintFrame:Hide() - - TranqRotate.mainFrame.dropHintFrame = hintFrame -end - --- Create and initialize the 'meter' frame. --- It's height will be used as a ruler for position calculation -function TranqRotate:createMeterFrame() - - local meterFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) - - meterFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame, 'TOPLEFT', 0, 0) - - -- @todo : Remove this - --meterFrame.texture = meterFrame:CreateTexture(nil, "BACKGROUND") - --meterFrame.texture:SetColorTexture(0.8, 0.5, 0.5, 0.2) - --meterFrame.texture:SetAllPoints() - --meterFrame:Show() - - TranqRotate.mainFrame.meterFrame = meterFrame - - meterFrame:SetScript( - "OnSizeChanged", - function (self, width, height) - TranqRotate:setDropHintPosition(self, width, height) - end - ) - -end - --- Set the drop hint frame position to match dragged frame position -function TranqRotate:setDropHintPosition(self, width, height) - - local hunterFrameHeight = TranqRotate.constants.hunterFrameHeight - local hunterFrameSpacing = TranqRotate.constants.hunterFrameSpacing - local hintPosition = 0 - - -- Hunt frame is above rotation frames - if (TranqRotate.mainFrame.meterFrame:GetTop() > TranqRotate.mainFrame.rotationFrame:GetTop()) then - height = 0 - end - - local index = floor(height / 22) - - -- Small offset to the first position so it does not clip hunt frame - if (index == 0) then - hintPosition = -2 - else - hintPosition = (index) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; - end - - -- Hunter frame is bellow rotation frame - if (height > TranqRotate.mainFrame.rotationFrame:GetHeight()) then - - -- Removing rotation frame size from calculation, using it's height as base hintPosition offset - height = height - TranqRotate.mainFrame.rotationFrame:GetHeight() - hintPosition = TranqRotate.mainFrame.rotationFrame:GetHeight() - - if (height > TranqRotate.mainFrame.backupFrame:GetHeight()) then - -- Frame is bellow backup frame - hintPosition = hintPosition + TranqRotate.mainFrame.backupFrame:GetHeight() - hunterFrameHeight + hunterFrameSpacing / 2 - else - index = floor(height / (hunterFrameHeight + hunterFrameSpacing)) - - -- Small offset to the first position so it does not clip hunt frame - if (index == 0) then - hintPosition = hintPosition - 2 - else - hintPosition = hintPosition + (index) * (hunterFrameHeight + hunterFrameSpacing) - hunterFrameSpacing / 2; - end - end - end - - TranqRotate.mainFrame.dropHintFrame:SetPoint('TOP', 0 , -hintPosition) -end \ No newline at end of file diff --git a/src/rotation.lua b/src/rotation.lua index 7af3597..5adf495 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -178,7 +178,7 @@ function TranqRotate:purgeHunterList() for key,hunter in pairs(TranqRotate.hunterTable) do if (not UnitInParty(hunter.name)) then - TranqRotate:unregisterUnitEvents() + TranqRotate:unregisterUnitEvents(hunter) TranqRotate:removeHunter(hunter) change = true end @@ -206,7 +206,7 @@ function TranqRotate:updateRaidStatus() local GUID = UnitGUID(name) local hunter = nil - if(true or select(2,UnitClass(name)) == 'HUNTER') then + if(select(2,UnitClass(name)) == 'HUNTER') then local registered = TranqRotate:isHunterRegistered(GUID) @@ -266,12 +266,7 @@ function TranqRotate:moveHunter(hunter, group, position) end -- Setting originalIndex - for key, loopHunter in pairs(originTable) do - if (hunter.name == loopHunter.name) then - originIndex = key - break - end - end + originIndex = TranqRotate:getHunterIndex(hunter, originTable) local sameTableMove = originTable == destinationTable @@ -319,26 +314,19 @@ end -- @todo: remove this function TranqRotate:test() - TranqRotate:enableListSorting() - --if (IsInRaid()) then - -- local raid_units = {} - -- for i=1,40 do - -- raid_units[i]="raid"..tostring(i) - -- end - -- - -- for i=1,#raid_units do - -- local unit = raid_units[i] - -- - -- if UnitExists(unit) then - -- --print(UnitName(unit)) - -- local index = UnitInRaid(UnitName(unit)) - -- - -- local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(index) - -- - -- print (name, online) - -- - -- end - -- end - --end -end \ No newline at end of file +end + +-- Returns a hunter's index in the given table +function TranqRotate:getHunterIndex(hunter, table) + local originIndex = 0 + + for key, loopHunter in pairs(table) do + if (hunter.name == loopHunter.name) then + originIndex = key + break + end + end + + return originIndex +end From 2655e65f3a9049131eec3a5e368ce2c1823378fe Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 6 Feb 2020 14:20:45 +0100 Subject: [PATCH 07/37] remove 'move' slash command --- src/rotation.lua | 5 ----- src/tranqRotate.lua | 6 ------ 2 files changed, 11 deletions(-) diff --git a/src/rotation.lua b/src/rotation.lua index 5adf495..63badef 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -247,11 +247,6 @@ function TranqRotate:updateHuntersStatus() end end --- @todo: Remove once drag & drop is ok | TEST function allowing slash command with name to move hunters -function TranqRotate:moveHunterFromName(name, group, position) - TranqRotate:moveHunter(TranqRotate:getHunter(name, nil), group, position) -end - -- Moves given hunter to the given position in the given group (ROTATION or BACKUP) function TranqRotate:moveHunter(hunter, group, position) diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 1757cc9..75788b0 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -81,12 +81,6 @@ SlashCmdList["TRANQROTATE"] = function(msg) TranqRotate:updateRaidStatus() elseif (cmd == 'test') then -- @todo: remove this TranqRotate:test() - elseif (cmd == 'move' and args ~= nil) then -- @todo: remove this when drag & drop is ok - chunks = {} - for substring in args:gmatch("%S+") do - table.insert(chunks, substring) - end - TranqRotate:moveHunterFromName(chunks[1], chunks[2], tonumber(chunks[3])) else local AceConfigDialog = LibStub("AceConfigDialog-3.0") AceConfigDialog:Open("TranqRotate") From 83b2d6b018ec5af418fe1fa2b05d0559481625e7 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 13:01:50 +0100 Subject: [PATCH 08/37] finalize drag & drop --- src/constants.lua | 3 ++- src/dragdrop.lua | 7 +++---- src/gui.lua | 12 ++++++++++-- src/rotation.lua | 20 ++++++++------------ src/settings.lua | 1 + src/tranqRotate.lua | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/constants.lua b/src/constants.lua index 4d5611c..dd20b5a 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -5,7 +5,8 @@ TranqRotate.colors = { ['blue'] = CreateColor(0.3, 0.3, 0.7), ['red'] = CreateColor(0.7, 0.3, 0.3), ['gray'] = CreateColor(0.3, 0.3, 0.3), - ['purple'] = CreateColor(0.71,0.45,0.75) + ['purple'] = CreateColor(0.71,0.45,0.75), + ['white'] = CreateColor(1,1,1) } TranqRotate.constants = { diff --git a/src/dragdrop.lua b/src/dragdrop.lua index 8fbe707..76c54ca 100644 --- a/src/dragdrop.lua +++ b/src/dragdrop.lua @@ -55,13 +55,12 @@ function TranqRotate:createDropHintFrame() hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) hintFrame:SetFrameStrata("MEDIUM") - hintFrame:SetHeight(20) + hintFrame:SetHeight(TranqRotate.constants.hunterFrameHeight) hintFrame:SetWidth(110) hintFrame.texture = hintFrame:CreateTexture(nil, "BACKGROUND") - hintFrame.texture:SetColorTexture(TranqRotate.colors.blue:GetRGB()) - -- @todo tweak the hint bar color - --hintFrame.texture:SetAlpha('LEFT') + hintFrame.texture:SetColorTexture(TranqRotate.colors.white:GetRGB()) + hintFrame.texture:SetAlpha(0.7) hintFrame.texture:SetPoint('LEFT') hintFrame.texture:SetPoint('RIGHT') hintFrame.texture:SetHeight(2) diff --git a/src/gui.lua b/src/gui.lua index ef125bd..f746196 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -5,10 +5,11 @@ local L = TranqRotate.L -- Initialize GUI frames. Shouldn't be called more than once function TranqRotate:initGui() + -- Main window TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) TranqRotate.mainFrame:SetFrameStrata("MEDIUM") TranqRotate.mainFrame:SetWidth(120) - TranqRotate.mainFrame:SetHeight(30) + TranqRotate.mainFrame:SetHeight(40) TranqRotate.mainFrame:Show() TranqRotate.mainFrame:RegisterForDrag("LeftButton") @@ -20,6 +21,7 @@ function TranqRotate:initGui() config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() end) + -- Rotation frame TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.rotationFrame:SetPoint('TOPLEFT') TranqRotate.mainFrame.rotationFrame:SetPoint('TOPRIGHT') @@ -29,6 +31,7 @@ function TranqRotate:initGui() TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() + -- Backup frame TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) @@ -38,6 +41,7 @@ function TranqRotate:initGui() TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() + -- Visual separator TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0.8,0.8,0.8,0.8) TranqRotate.mainFrame.backupFrame.texture:SetHeight(1) @@ -60,9 +64,9 @@ function TranqRotate:drawHunterFrames() if (#TranqRotate.rotationTables.backup > 0) then TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + 20) - TranqRotate.mainFrame.backupFrame:SetHeight(20) end + TranqRotate.mainFrame.backupFrame:SetHeight(20) TranqRotate:drawList(TranqRotate.rotationTables.backup, TranqRotate.mainFrame.backupFrame) end @@ -100,6 +104,10 @@ function TranqRotate:drawList(hunterList, parentFrame) hunter.frame.text:SetText(hunter.name) TranqRotate:configureHunterFrameDrag(hunter) + + if (TranqRotate.enableDrag) then + TranqRotate:enableHunterFrameDragging(hunter, true) + end else hunter.frame:SetParent(parentFrame) end diff --git a/src/rotation.lua b/src/rotation.lua index 63badef..65c4f17 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -56,7 +56,7 @@ end function TranqRotate:rotate(lastHunter, fail) -- Default value to false - local fail = fail or false + fail = fail or false local nextHunter = TranqRotate:getNextRotationHunter(lastHunter) TranqRotate:setNextTranq(nextHunter) @@ -127,12 +127,13 @@ function TranqRotate:resetRotation() TranqRotate:refreshHunterFrame(hunter) end - if (#TranqRotate.rotationTables.rotation > 0) then - local firstHunter = TranqRotate.rotationTables.rotation[1] - - firstHunter.nextTranq = true - TranqRotate:refreshHunterFrame(firstHunter) - end + -- @todo remove this if neutral reset is fine + --if (#TranqRotate.rotationTables.rotation > 0) then + -- local firstHunter = TranqRotate.rotationTables.rotation[1] + -- + -- firstHunter.nextTranq = true + -- TranqRotate:refreshHunterFrame(firstHunter) + --end end @@ -307,11 +308,6 @@ function TranqRotate:getHunterRotationTable(hunter) end end --- @todo: remove this -function TranqRotate:test() - TranqRotate:enableListSorting() -end - -- Returns a hunter's index in the given table function TranqRotate:getHunterIndex(hunter, table) local originIndex = 0 diff --git a/src/settings.lua b/src/settings.lua index b4036a3..f05842f 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -46,6 +46,7 @@ function TranqRotate:CreateConfig() width = "full", order = 3, }, + -- @todo : find a way to space widget properly spacer = { name = ' ', type = "description", diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 75788b0..10cde39 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -17,6 +17,7 @@ function TranqRotate:init() TranqRotate.hunterTable = {} TranqRotate.rotationTables = { rotation = {}, backup = {} } + TranqRotate.enableDrag = true TranqRotate:initGui() TranqRotate:updateRaidStatus() @@ -69,6 +70,8 @@ SlashCmdList["TRANQROTATE"] = function(msg) if (cmd == 'redraw') then -- @todo decide if this should be removed or not TranqRotate:drawHunterFrames() + elseif (cmd == 'toggle') then -- @todo: remove this + TranqRotate:toggleDisplay() elseif (cmd == 'init') then -- @todo: remove this TranqRotate:resetRotation() elseif (cmd == 'lock') then @@ -87,6 +90,21 @@ SlashCmdList["TRANQROTATE"] = function(msg) end end +function TranqRotate:toggleDisplay() + if (TranqRotate.mainFrame:IsShown()) then + TranqRotate.mainFrame:Hide() + TranqRotate:printMessage('Tranqrotate window hidden. Use /tranq toggle toggle display') + else + TranqRotate.mainFrame:Show() + end +end + +-- @todo: remove this +function TranqRotate:test() + TranqRotate:printMessage('test') +-- TranqRotate:enableListSorting() +end + function table.contains(table, element) for _, value in pairs(table) do if value == element then From 3281ef34d0c372bdfc9f2cc89cf79a3e75611507 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 13:12:24 +0100 Subject: [PATCH 09/37] Move hunter frame creation in it's own function --- src/gui.lua | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/gui.lua b/src/gui.lua index f746196..23f4791 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -88,26 +88,7 @@ function TranqRotate:drawList(hunterList, parentFrame) -- Using existing frame if possible if (hunter.frame == nil) then - hunter.frame = CreateFrame("Frame", nil, parentFrame) - hunter.frame:SetFrameStrata("MEDIUM") - hunter.frame:SetHeight(hunterFrameHeight) - - -- Set Texture - hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") - hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") - hunter.frame.texture:SetAllPoints() - - -- Set Text - hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") - hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) - hunter.frame.text:SetPoint("LEFT",5,0) - hunter.frame.text:SetText(hunter.name) - - TranqRotate:configureHunterFrameDrag(hunter) - - if (TranqRotate.enableDrag) then - TranqRotate:enableHunterFrameDragging(hunter, true) - end + TranqRotate:createHunterFrame(hunter, parentFrame) else hunter.frame:SetParent(parentFrame) end @@ -178,3 +159,26 @@ function TranqRotate:lock(lock) TranqRotate:printMessage(L['WINDOW_UNLOCKED']) end end + +function TranqRotate:createHunterFrame(hunter, parentFrame) + hunter.frame = CreateFrame("Frame", nil, parentFrame) + hunter.frame:SetFrameStrata("MEDIUM") + hunter.frame:SetHeight(hunterFrameHeight) + + -- Set Texture + hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") + hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") + hunter.frame.texture:SetAllPoints() + + -- Set Text + hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) + hunter.frame.text:SetPoint("LEFT",5,0) + hunter.frame.text:SetText(hunter.name) + + TranqRotate:configureHunterFrameDrag(hunter) + + if (TranqRotate.enableDrag) then + TranqRotate:enableHunterFrameDragging(hunter, true) + end +end \ No newline at end of file From 0163db8803797869905fb2ff4aec11dc6aad07ea Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 13:19:03 +0100 Subject: [PATCH 10/37] Removes unnecessary strata usages --- src/dragdrop.lua | 1 - src/gui.lua | 4 +--- src/rotation.lua | 10 ++++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/dragdrop.lua b/src/dragdrop.lua index 76c54ca..5a21051 100644 --- a/src/dragdrop.lua +++ b/src/dragdrop.lua @@ -54,7 +54,6 @@ function TranqRotate:createDropHintFrame() local hintFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) - hintFrame:SetFrameStrata("MEDIUM") hintFrame:SetHeight(TranqRotate.constants.hunterFrameHeight) hintFrame:SetWidth(110) diff --git a/src/gui.lua b/src/gui.lua index 23f4791..c668ff5 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -7,7 +7,6 @@ function TranqRotate:initGui() -- Main window TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) - TranqRotate.mainFrame:SetFrameStrata("MEDIUM") TranqRotate.mainFrame:SetWidth(120) TranqRotate.mainFrame:SetHeight(40) TranqRotate.mainFrame:Show() @@ -162,8 +161,7 @@ end function TranqRotate:createHunterFrame(hunter, parentFrame) hunter.frame = CreateFrame("Frame", nil, parentFrame) - hunter.frame:SetFrameStrata("MEDIUM") - hunter.frame:SetHeight(hunterFrameHeight) + hunter.frame:SetHeight(TranqRotate.constants.hunterFrameHeight) -- Set Texture hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") diff --git a/src/rotation.lua b/src/rotation.lua index 65c4f17..f47bda2 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -205,7 +205,7 @@ function TranqRotate:updateRaidStatus() -- Players name might be nil at loading if (name ~= nil) then local GUID = UnitGUID(name) - local hunter = nil + local hunter if(select(2,UnitClass(name)) == 'HUNTER') then @@ -251,19 +251,17 @@ end -- Moves given hunter to the given position in the given group (ROTATION or BACKUP) function TranqRotate:moveHunter(hunter, group, position) - local originIndex = nil - local finalIndex = position - local originTable = TranqRotate:getHunterRotationTable(hunter) + local originIndex = TranqRotate:getHunterIndex(hunter, originTable) + local destinationTable = TranqRotate.rotationTables.rotation + local finalIndex = position if (group == 'BACKUP') then destinationTable = TranqRotate.rotationTables.backup end -- Setting originalIndex - originIndex = TranqRotate:getHunterIndex(hunter, originTable) - local sameTableMove = originTable == destinationTable -- Defining finalIndex From d5404384812fbbdf4b4c8fa9c5bb14a3e5dc220c Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 23:02:15 +0100 Subject: [PATCH 11/37] Adds title bar, move frame to new file, adds buttons --- TranqRotate.toc | 1 + src/constants.lua | 2 + src/dragdrop.lua | 4 +- src/frames.lua | 117 ++++++++++++++++++++++++++++++++++++++++++++ src/gui.lua | 50 +++---------------- src/rotation.lua | 2 +- src/tranqRotate.lua | 37 ++++++++++++-- 7 files changed, 164 insertions(+), 49 deletions(-) create mode 100644 src/frames.lua diff --git a/TranqRotate.toc b/TranqRotate.toc index 8d7a0a8..70ae0ee 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -24,6 +24,7 @@ src\tranqRotate.lua src\events.lua src\rotation.lua src\constants.lua +src\frames.lua src\gui.lua src\dragdrop.lua src\defaults.lua diff --git a/src/constants.lua b/src/constants.lua index dd20b5a..c0cbfcf 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -2,6 +2,7 @@ local TranqRotate = select(2, ...) TranqRotate.colors = { ['green'] = CreateColor(0.67, 0.83, 0.45), + ['darkGreen'] = CreateColor(0.1, 0.4, 0.1), ['blue'] = CreateColor(0.3, 0.3, 0.7), ['red'] = CreateColor(0.7, 0.3, 0.3), ['gray'] = CreateColor(0.3, 0.3, 0.3), @@ -12,4 +13,5 @@ TranqRotate.colors = { TranqRotate.constants = { ['hunterFrameHeight'] = 20, ['hunterFrameSpacing'] = 4, + ['titleBarHeight'] = 18 } diff --git a/src/dragdrop.lua b/src/dragdrop.lua index 5a21051..278705c 100644 --- a/src/dragdrop.lua +++ b/src/dragdrop.lua @@ -34,7 +34,7 @@ function TranqRotate:configureHunterFrameDrag(hunter) "OnDragStop", function() hunter.frame:StopMovingOrSizing() - hunter.frame:SetFrameStrata("MEDIUM") + hunter.frame:SetFrameStrata(TranqRotate.mainFrame:GetFrameStrata()) TranqRotate.mainFrame.dropHintFrame:Hide() if (#TranqRotate.rotationTables.backup < 1) then @@ -76,7 +76,7 @@ function TranqRotate:createRulerFrame() local rulerFrame = CreateFrame("Frame", nil, TranqRotate.mainFrame.rotationFrame) TranqRotate.mainFrame.rulerFrame = rulerFrame - rulerFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame, 'TOPLEFT', 0, 0) + rulerFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'TOPLEFT', 0, 0) rulerFrame:SetScript( "OnSizeChanged", diff --git a/src/frames.lua b/src/frames.lua new file mode 100644 index 0000000..4e6bc81 --- /dev/null +++ b/src/frames.lua @@ -0,0 +1,117 @@ +local TranqRotate = select(2, ...) + +function TranqRotate:createMainFrame() + TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) + TranqRotate.mainFrame:SetWidth(120) + TranqRotate.mainFrame:SetHeight(40 + TranqRotate.constants.titleBarHeight) + TranqRotate.mainFrame:Show() + + TranqRotate.mainFrame:RegisterForDrag("LeftButton") + TranqRotate.mainFrame:SetClampedToScreen(true) + TranqRotate.mainFrame:SetScript("OnDragStart", function() TranqRotate.mainFrame:StartMoving() end) + + TranqRotate.mainFrame:SetScript( + "OnDragStop", + function() + local config, meh = TranqRotate.db.profile + TranqRotate.mainFrame:StopMovingOrSizing() + config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() + end + ) +end + +function TranqRotate:createTitleFrame() + TranqRotate.mainFrame.titleFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) + TranqRotate.mainFrame.titleFrame:SetPoint('TOPLEFT') + TranqRotate.mainFrame.titleFrame:SetPoint('TOPRIGHT') + TranqRotate.mainFrame.titleFrame:SetHeight(TranqRotate.constants.titleBarHeight) + + TranqRotate.mainFrame.titleFrame.texture = TranqRotate.mainFrame.titleFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.titleFrame.texture:SetColorTexture(TranqRotate.colors.darkGreen:GetRGB()) + TranqRotate.mainFrame.titleFrame.texture:SetAllPoints() + + TranqRotate.mainFrame.titleFrame.text = TranqRotate.mainFrame.titleFrame:CreateFontString(nil, "ARTWORK") + TranqRotate.mainFrame.titleFrame.text:SetFont("Fonts\\ARIALN.ttf", 12) + TranqRotate.mainFrame.titleFrame.text:SetShadowColor(0,0,0,0.5) + TranqRotate.mainFrame.titleFrame.text:SetShadowOffset(1,-1) + TranqRotate.mainFrame.titleFrame.text:SetPoint("LEFT",5,0) + TranqRotate.mainFrame.titleFrame.text:SetText('TranqRotate') + TranqRotate.mainFrame.titleFrame.text:SetTextColor(1,1,1,1) +end + +function TranqRotate:createButtons() + + local buttons = { + { + ['texture'] = 'Interface/GossipFrame/BinderGossipIcon', + ['callback'] = TranqRotate.openSettings + }, + { + ['texture'] = 'Interface/Buttons/UI-RefreshButton', + ['callback'] = TranqRotate.resetRotation + }, + { + ['texture'] = 'Interface/Buttons/UI-GuildButton-MOTD-Up', + ['callback'] = TranqRotate.broadcastToRaid + }, + } + + local position = 5 + + for key, button in pairs(buttons) do + TranqRotate:createButton(position, button.texture, button.callback ) + position = position + 13 + end +end + + +function TranqRotate:createButton(position, texture, callback) + + local button = CreateFrame("Button", nil, TranqRotate.mainFrame.titleFrame) + button:SetPoint('RIGHT', -position, 0) + button:SetWidth(10) + button:SetHeight(10) + + local normal = button:CreateTexture() + normal:SetTexture(texture) + normal:SetAllPoints() + button:SetNormalTexture(normal) + + local highlight = button:CreateTexture() + highlight:SetTexture(texture) + highlight:SetAllPoints() + button:SetHighlightTexture(highlight) + + button:SetScript("OnClick", callback) +end + +function TranqRotate:createRotationFrame() + TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) + TranqRotate.mainFrame.rotationFrame:SetPoint('LEFT') + TranqRotate.mainFrame.rotationFrame:SetPoint('RIGHT') + TranqRotate.mainFrame.rotationFrame:SetPoint('TOP', 0, -TranqRotate.constants.titleBarHeight) + TranqRotate.mainFrame.rotationFrame:SetHeight(20) + + TranqRotate.mainFrame.rotationFrame.texture = TranqRotate.mainFrame.rotationFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() +end + +function TranqRotate:createBackupFrame() + -- Backup frame + TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) + TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) + TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) + TranqRotate.mainFrame.backupFrame:SetHeight(20) + + TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) + TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() + + -- Visual separator + TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") + TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0.8,0.8,0.8,0.8) + TranqRotate.mainFrame.backupFrame.texture:SetHeight(1) + TranqRotate.mainFrame.backupFrame.texture:SetWidth(60) + TranqRotate.mainFrame.backupFrame.texture:SetPoint('TOP') +end diff --git a/src/gui.lua b/src/gui.lua index c668ff5..382e4e6 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -3,49 +3,13 @@ local TranqRotate = select(2, ...) local L = TranqRotate.L -- Initialize GUI frames. Shouldn't be called more than once -function TranqRotate:initGui() - - -- Main window - TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) - TranqRotate.mainFrame:SetWidth(120) - TranqRotate.mainFrame:SetHeight(40) - TranqRotate.mainFrame:Show() - - TranqRotate.mainFrame:RegisterForDrag("LeftButton") - TranqRotate.mainFrame:SetClampedToScreen(true) - TranqRotate.mainFrame:SetScript("OnDragStart", function() TranqRotate.mainFrame:StartMoving() end) - TranqRotate.mainFrame:SetScript("OnDragStop", function() - local config, meh = TranqRotate.db.profile - TranqRotate.mainFrame:StopMovingOrSizing() - config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() - end) - - -- Rotation frame - TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) - TranqRotate.mainFrame.rotationFrame:SetPoint('TOPLEFT') - TranqRotate.mainFrame.rotationFrame:SetPoint('TOPRIGHT') - TranqRotate.mainFrame.rotationFrame:SetHeight(20) - - TranqRotate.mainFrame.rotationFrame.texture = TranqRotate.mainFrame.rotationFrame:CreateTexture(nil, "BACKGROUND") - TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) - TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() - - -- Backup frame - TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) - TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) - TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) - TranqRotate.mainFrame.backupFrame:SetHeight(20) - - TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") - TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) - TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() +function TranqRotate:initGui() - -- Visual separator - TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") - TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0.8,0.8,0.8,0.8) - TranqRotate.mainFrame.backupFrame.texture:SetHeight(1) - TranqRotate.mainFrame.backupFrame.texture:SetWidth(60) - TranqRotate.mainFrame.backupFrame.texture:SetPoint('TOP') + TranqRotate:createMainFrame() + TranqRotate:createTitleFrame() + TranqRotate:createButtons() + TranqRotate:createRotationFrame() + TranqRotate:createBackupFrame() TranqRotate:drawHunterFrames() TranqRotate:createDropHintFrame() @@ -56,7 +20,7 @@ end function TranqRotate:drawHunterFrames() -- Different height to reduce spacing between both groups - TranqRotate.mainFrame:SetHeight(20) + TranqRotate.mainFrame:SetHeight(20 + TranqRotate.constants.titleBarHeight) TranqRotate.mainFrame.rotationFrame:SetHeight(20) TranqRotate:drawList(TranqRotate.rotationTables.rotation, TranqRotate.mainFrame.rotationFrame) diff --git a/src/rotation.lua b/src/rotation.lua index f47bda2..c8cfa73 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -84,7 +84,7 @@ end function TranqRotate:getNextRotationHunter(lastHunter) local rotationTable = TranqRotate.rotationTables.rotation - local nextHunter = nil + local nextHunter local lastHunterIndex = 1 local nextHunterIndex = 1 diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 10cde39..0fd8779 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -85,15 +85,14 @@ SlashCmdList["TRANQROTATE"] = function(msg) elseif (cmd == 'test') then -- @todo: remove this TranqRotate:test() else - local AceConfigDialog = LibStub("AceConfigDialog-3.0") - AceConfigDialog:Open("TranqRotate") + TranqRotate:openSettings() end end function TranqRotate:toggleDisplay() if (TranqRotate.mainFrame:IsShown()) then TranqRotate.mainFrame:Hide() - TranqRotate:printMessage('Tranqrotate window hidden. Use /tranq toggle toggle display') + TranqRotate:printMessage('Tranqrotate window hidden. Use /tranq toggle to get it back') else TranqRotate.mainFrame:Show() end @@ -112,4 +111,36 @@ function table.contains(table, element) end end return false +end + +function TranqRotate:openSettings() + local AceConfigDialog = LibStub("AceConfigDialog-3.0") + AceConfigDialog:Open("TranqRotate") +end + +function TranqRotate:broadcastToRaid() + local channel = 'RAID' + + SendChatMessage('--- Hunter tranqshot setup ---', channel) + SendChatMessage( + TranqRotate:buildGroupMessage('Rotation : ', TranqRotate.rotationTables.rotation), + channel + ) + + if (#TranqRotate.rotationTables.backup > 0) then + SendChatMessage( + TranqRotate:buildGroupMessage('Backup : ', TranqRotate.rotationTables.backup), + channel + ) + end +end + +function TranqRotate:buildGroupMessage(prefix, rotationTable) + local hunters = {} + + for key, hunt in pairs(rotationTable) do + table.insert(hunters, hunt.name) + end + + return prefix .. table.concat(hunters, ', ') end \ No newline at end of file From 45de566560d4d88e35027e4f69e9ced65e0e0c7b Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 23:39:33 +0100 Subject: [PATCH 12/37] Adds fail whisper to next hunter --- locales/enUS.lua | 2 ++ locales/frFR.lua | 2 ++ locales/zhCN.lua | 2 ++ locales/zhTW.lua | 2 ++ src/defaults.lua | 1 + src/rotation.lua | 15 +++++++++++++-- src/settings.lua | 6 ++++++ 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index bbca44f..5cfde26 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -35,9 +35,11 @@ local L = { ["ANNOUNCES_MESSAGE_HEADER"] = "Announce messages", ["SUCCESS_MESSAGE_LABEL"] = "Successful announce message", ["FAIL_MESSAGE_LABEL"] = "Fail announce message", + ["FAIL_WHISPER_LABEL"] = "Fail whisper message", ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TRANQSHOT FAILED ON %s !!!", + ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation ["SETTING_ROTATION"] = "Rotation", diff --git a/locales/frFR.lua b/locales/frFR.lua index 3359374..dcccf03 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -37,9 +37,11 @@ local L = { ["ANNOUNCES_MESSAGE_HEADER"] = "Messages", ["SUCCESS_MESSAGE_LABEL"] = "Message de réussite", ["FAIL_MESSAGE_LABEL"] = "Message d'échec", + ["FAIL_WHISPER_LABEL"] = "Message d'echec chuchotté", ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait sur %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TIR TRANQUILLISANT RATE SUR %s !!!", + ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TIR TRANQUILISANT RATE ! TRANQ MAINTENANT !", --- Rotation ["SETTING_ROTATION"] = "Rotation", diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 2c427e7..30714ee 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -37,9 +37,11 @@ local L = { ["ANNOUNCES_MESSAGE_HEADER"] = "通告信息", ["SUCCESS_MESSAGE_LABEL"] = "施放成功通告信息", ["FAIL_MESSAGE_LABEL"] = "施放失败通告信息", + ["FAIL_WHISPER_LABEL"] = "Fail whisper message", ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已对 %s 施放了宁神射击!", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 对 %s 宁神失败!!!", + ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation ["SETTING_ROTATION"] = "Rotation", diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 0fc2100..0af6971 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -37,9 +37,11 @@ local L = { ["ANNOUNCES_MESSAGE_HEADER"] = "通告資訊", ["SUCCESS_MESSAGE_LABEL"] = "施放成功通告資訊", ["FAIL_MESSAGE_LABEL"] = "施放失敗通告資訊", + ["FAIL_WHISPER_LABEL"] = "Fail whisper message", ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已對 %s 施放了寧神射擊!", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 對 %s 寧神失敗!!!", + ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation ["SETTING_ROTATION"] = "Rotation", diff --git a/src/defaults.lua b/src/defaults.lua index e7890ba..ccdfc4a 100644 --- a/src/defaults.lua +++ b/src/defaults.lua @@ -7,6 +7,7 @@ function TranqRotate:LoadDefaults() channelType = "YELL", announceSuccessMessage = L["DEFAULT_SUCCESS_ANNOUNCE_MESSAGE"], announceFailMessage = L["DEFAULT_FAIL_ANNOUNCE_MESSAGE"], + whisperFailMessage = L["DEFAULT_FAIL_WHISPER_MESSAGE"], lock = false }, } diff --git a/src/rotation.lua b/src/rotation.lua index c8cfa73..7ee49ca 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -60,9 +60,10 @@ function TranqRotate:rotate(lastHunter, fail) local nextHunter = TranqRotate:getNextRotationHunter(lastHunter) TranqRotate:setNextTranq(nextHunter) + local name, realm = UnitName("player") - if (fail) then - -- Throw alert to the next hunter in the rotation, maybe alert backup too ... + if (name == lastHunter.name and fail) then + SendChatMessage(TranqRotate.db.profile.whisperFailMessage, 'WHISPER', nil, nextHunter.name) end end @@ -80,6 +81,16 @@ function TranqRotate:setNextTranq(nextHunter) end end +-- Returns the hunter that will shoot next +function TranqRotate:getNextTranq() + for key, hunter in pairs(TranqRotate.rotationTables.rotation) do + if (hunter.nextTranq) then + return hunter + end + end +end + + -- Find and returns the next hunter that will tranq base on last shooter function TranqRotate:getNextRotationHunter(lastHunter) diff --git a/src/settings.lua b/src/settings.lua index f05842f..ba69d98 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -119,6 +119,12 @@ function TranqRotate:CreateConfig() order = 22, width = "double", }, + whisperFailMessage = { + name = L["FAIL_WHISPER_LABEL"], + type = "input", + order = 23, + width = "double", + }, } }, } From 62a60d71e39fd39356e57975429f57247051d81f Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 23:42:19 +0100 Subject: [PATCH 13/37] Removes nextTranq flag from hunter that are moved to backup --- src/rotation.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rotation.lua b/src/rotation.lua index 7ee49ca..b45a7d3 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -270,6 +270,8 @@ function TranqRotate:moveHunter(hunter, group, position) if (group == 'BACKUP') then destinationTable = TranqRotate.rotationTables.backup + -- Remove nextTranq flag when moved to backup + hunter.nextTranq = false end -- Setting originalIndex From 789e5f80f3ad074ff7d8fc33763e448a1b65a091 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Fri, 7 Feb 2020 23:57:14 +0100 Subject: [PATCH 14/37] Update interface version --- TranqRotate.toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TranqRotate.toc b/TranqRotate.toc index 70ae0ee..f605c6e 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -1,4 +1,4 @@ -## Interface: 11302 +## Interface: 11303 ## Title: TranqRotate ## Notes: A tranqshot rotation assistant ## Author: Slivo From d3a5d2b859143e062b5b0320fa418d7377ccaa60 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Sat, 8 Feb 2020 10:44:58 +0100 Subject: [PATCH 15/37] Adds raid message to translations, add slash command help --- locales/enUS.lua | 7 ++++++- locales/frFR.lua | 9 +++++++-- locales/zhCN.lua | 7 ++++++- locales/zhTW.lua | 7 ++++++- src/tranqRotate.lua | 36 +++++++++++++++++++++++++++--------- 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index 5cfde26..268a98e 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -49,7 +49,12 @@ local L = { ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", --- Profiles - ["SETTING_PROFILES"] = "Profiles" + ["SETTING_PROFILES"] = "Profiles", + + --- Raid broadcast messages + ["BROADCAST_HEADER_TEXT"] = "Hunter tranqshot setup", + ["BROADCAST_ROTATION_PREFIX"] = "Rotation", + ["BROADCAST_BACKUP_PREFIX"] = "Backup", } TranqRotate.L = L diff --git a/locales/frFR.lua b/locales/frFR.lua index dcccf03..e3633dd 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -37,7 +37,7 @@ local L = { ["ANNOUNCES_MESSAGE_HEADER"] = "Messages", ["SUCCESS_MESSAGE_LABEL"] = "Message de réussite", ["FAIL_MESSAGE_LABEL"] = "Message d'échec", - ["FAIL_WHISPER_LABEL"] = "Message d'echec chuchotté", + ["FAIL_WHISPER_LABEL"] = "Message d'échec cdhuchoté", ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait sur %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TIR TRANQUILLISANT RATE SUR %s !!!", @@ -51,7 +51,12 @@ local L = { ["WINDOW_UNLOCKED"] = "TranqRotate: Fenêtre déverrouillée", --- Profiles - ["SETTING_PROFILES"] = "Profils" + ["SETTING_PROFILES"] = "Profils", + + --- Raid broadcast messages + ["BROADCAST_HEADER_TEXT"] = "Hunter tranqshot setup", + ["BROADCAST_ROTATION_PREFIX"] = "Rotation", + ["BROADCAST_BACKUP_PREFIX"] = "Backup", } TranqRotate.L = L diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 30714ee..2429847 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -51,7 +51,12 @@ local L = { ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", --- Profiles - ["SETTING_PROFILES"] = "配置" + ["SETTING_PROFILES"] = "配置", + + --- Raid broadcast messages + ["BROADCAST_HEADER_TEXT"] = "Hunter tranqshot setup", + ["BROADCAST_ROTATION_PREFIX"] = "Rotation", + ["BROADCAST_BACKUP_PREFIX"] = "Backup", } TranqRotate.L = L diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 0af6971..2a03d20 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -51,7 +51,12 @@ local L = { ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", --- Profiles - ["SETTING_PROFILES"] = "配置" + ["SETTING_PROFILES"] = "配置", + + --- Raid broadcast messages + ["BROADCAST_HEADER_TEXT"] = "Hunter tranqshot setup", + ["BROADCAST_ROTATION_PREFIX"] = "Rotation", + ["BROADCAST_BACKUP_PREFIX"] = "Backup", } TranqRotate.L = L diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 0fd8779..b02e7be 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -84,8 +84,10 @@ SlashCmdList["TRANQROTATE"] = function(msg) TranqRotate:updateRaidStatus() elseif (cmd == 'test') then -- @todo: remove this TranqRotate:test() - else + elseif (cmd == 'settings') then -- @todo: remove this TranqRotate:openSettings() + else + TranqRotate:printHelp() end end @@ -121,18 +123,22 @@ end function TranqRotate:broadcastToRaid() local channel = 'RAID' - SendChatMessage('--- Hunter tranqshot setup ---', channel) - SendChatMessage( - TranqRotate:buildGroupMessage('Rotation : ', TranqRotate.rotationTables.rotation), - channel - ) + if (IsInGroup() and IsInRaid()) then - if (#TranqRotate.rotationTables.backup > 0) then + SendChatMessage('--- ' .. L['BROADCAST_HEADER_TEXT'] .. ' ---', channel) SendChatMessage( - TranqRotate:buildGroupMessage('Backup : ', TranqRotate.rotationTables.backup), + TranqRotate:buildGroupMessage(L['BROADCAST_ROTATION_PREFIX'] .. ' : ', TranqRotate.rotationTables.rotation), channel ) + + if (#TranqRotate.rotationTables.backup > 0) then + SendChatMessage( + TranqRotate:buildGroupMessage(L['BROADCAST_BACKUP_PREFIX'] .. ' : ', TranqRotate.rotationTables.backup), + channel + ) + end end + end function TranqRotate:buildGroupMessage(prefix, rotationTable) @@ -143,4 +149,16 @@ function TranqRotate:buildGroupMessage(prefix, rotationTable) end return prefix .. table.concat(hunters, ', ') -end \ No newline at end of file +end + +function TranqRotate:printHelp() + TranqRotate:printMessage(TranqRotate:colorText('/tranqrotate') .. ' commands options :') + TranqRotate:printMessage(' ' .. TranqRotate:colorText('toggle') .. ' : Show/Hide the main window') + TranqRotate:printMessage(' ' .. TranqRotate:colorText('lock') .. ' : Lock the main window position') + TranqRotate:printMessage(' ' .. TranqRotate:colorText('unlock') .. ' : Unlock the main window position') + TranqRotate:printMessage(' ' .. TranqRotate:colorText('settings') .. ' : Open TranqRotate settings') +end + +function TranqRotate:colorText(text) + return '|cffffbf00' .. text .. '|r' +end From fd764d7e7fc1fe6ab2b498ad884146dc4c85a052 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Sat, 8 Feb 2020 13:03:37 +0100 Subject: [PATCH 16/37] Adds whisper to backup hunter when tranq is missed --- src/rotation.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rotation.lua b/src/rotation.lua index b45a7d3..fed8485 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -64,8 +64,10 @@ function TranqRotate:rotate(lastHunter, fail) if (name == lastHunter.name and fail) then SendChatMessage(TranqRotate.db.profile.whisperFailMessage, 'WHISPER', nil, nextHunter.name) + for key, backupHunter in pairs(TranqRotate.rotationTables.backup) do + SendChatMessage(TranqRotate.db.profile.whisperFailMessage, 'WHISPER', nil, backupHunter.name) + end end - end -- Removes all nextTranq flags and set it true for next shooter From 92913ffe6314a08beb2eef8897bee4ba9fb43364 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Sun, 9 Feb 2020 20:49:22 +0100 Subject: [PATCH 17/37] Adds option to hide window when out of raid --- locales/enUS.lua | 3 ++- locales/frFR.lua | 3 ++- locales/zhCN.lua | 3 ++- locales/zhTW.lua | 3 ++- src/defaults.lua | 3 ++- src/events.lua | 1 + src/gui.lua | 19 +++++++++++++++++++ src/rotation.lua | 2 +- src/settings.lua | 12 ++++++++++++ src/tranqRotate.lua | 7 ++++++- 10 files changed, 49 insertions(+), 7 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index 268a98e..8073115 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -42,9 +42,10 @@ local L = { ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation - ["SETTING_ROTATION"] = "Rotation", ["LOCK_WINDOW"] = "Lock window", ["LOCK_WINDOW_DESC"] = "Lock window", + ["HIDE_WINDOW_NOT_IN_RAID"] = "Hide the window when not in a raid", + ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Hide the window when not in a raid", ["WINDOW_LOCKED"] = "TranqRotate: Window locked", ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", diff --git a/locales/frFR.lua b/locales/frFR.lua index e3633dd..1fd6264 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -44,9 +44,10 @@ local L = { ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TIR TRANQUILISANT RATE ! TRANQ MAINTENANT !", --- Rotation - ["SETTING_ROTATION"] = "Rotation", ["LOCK_WINDOW"] = "Verrouiller la position de la fênetre", ["LOCK_WINDOW_DESC"] = "Verrouiller la position de la fênetre", + ["HIDE_WINDOW_NOT_IN_RAID"] = "Hide the window when not in a raid", + ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Hide the window when not in a raid", ["WINDOW_LOCKED"] = "TranqRotate: Fenêtre verrouillée", ["WINDOW_UNLOCKED"] = "TranqRotate: Fenêtre déverrouillée", diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 2429847..2c200b9 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -44,9 +44,10 @@ local L = { ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation - ["SETTING_ROTATION"] = "Rotation", ["LOCK_WINDOW"] = "Lock window", ["LOCK_WINDOW_DESC"] = "Lock window", + ["HIDE_WINDOW_NOT_IN_RAID"] = "Hide the window when not in a raid", + ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Hide the window when not in a raid", ["WINDOW_LOCKED"] = "TranqRotate: Window locked", ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 2a03d20..b797452 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -44,9 +44,10 @@ local L = { ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT FAILED ! TRANQ NOW !", --- Rotation - ["SETTING_ROTATION"] = "Rotation", ["LOCK_WINDOW"] = "Lock window", ["LOCK_WINDOW_DESC"] = "Lock window", + ["HIDE_WINDOW_NOT_IN_RAID"] = "Hide the window when not in a raid", + ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Hide the window when not in a raid", ["WINDOW_LOCKED"] = "TranqRotate: Window locked", ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", diff --git a/src/defaults.lua b/src/defaults.lua index ccdfc4a..fef3f86 100644 --- a/src/defaults.lua +++ b/src/defaults.lua @@ -8,7 +8,8 @@ function TranqRotate:LoadDefaults() announceSuccessMessage = L["DEFAULT_SUCCESS_ANNOUNCE_MESSAGE"], announceFailMessage = L["DEFAULT_FAIL_ANNOUNCE_MESSAGE"], whisperFailMessage = L["DEFAULT_FAIL_WHISPER_MESSAGE"], - lock = false + lock = false, + hideNotInRaid = false, }, } end diff --git a/src/events.lua b/src/events.lua index 096196b..11623f2 100644 --- a/src/events.lua +++ b/src/events.lua @@ -79,6 +79,7 @@ end function TranqRotate:GROUP_ROSTER_UPDATE() TranqRotate:updateRaidStatus() + TranqRotate:updateDisplay() end function TranqRotate:PLAYER_TARGET_CHANGED() diff --git a/src/gui.lua b/src/gui.lua index 382e4e6..8e4ee61 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -14,6 +14,25 @@ function TranqRotate:initGui() TranqRotate:drawHunterFrames() TranqRotate:createDropHintFrame() TranqRotate:createRulerFrame() + + TranqRotate.manuallyHiddenWhileInRaid = false + TranqRotate:updateDisplay() +end + +-- Show/Hide main window based on user settings +function TranqRotate:updateDisplay() + if (TranqRotate.db.profile.hideNotInRaid and not IsInRaid()) then + TranqRotate.mainFrame:Hide() + else + if (not TranqRotate.manuallyHiddenWhileInRaid) then + TranqRotate.mainFrame:Show() + end + end + + -- Reset manual hide during the raid when leaving it + if (not IsInRaid()) then + TranqRotate.manuallyHiddenWhileInRaid = false + end end -- render / re-render hunter frames to reflect table changes. diff --git a/src/rotation.lua b/src/rotation.lua index fed8485..962a657 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -207,7 +207,7 @@ end -- Iterate over all raid members to find hunters and update their status function TranqRotate:updateRaidStatus() - if (IsInGroup() and IsInRaid()) then + if (IsInRaid()) then local playerCount = GetNumGroupMembers() diff --git a/src/settings.lua b/src/settings.lua index ba69d98..7adcb85 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -59,6 +59,18 @@ function TranqRotate:CreateConfig() type = "toggle", order = 5, width = "double", + }, + hideNotInRaid = { + name = L["HIDE_WINDOW_NOT_IN_RAID"], + desc = L["HIDE_WINDOW_NOT_IN_RAID_DESC"], + type = "toggle", + order = 6, + width = "double", + set = function(info, value) + set(info,value) + LibStub("AceConfigRegistry-3.0", true):NotifyChange("TranqRotate") + TranqRotate:updateDisplay() + end } } }, diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index b02e7be..7991782 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -94,6 +94,11 @@ end function TranqRotate:toggleDisplay() if (TranqRotate.mainFrame:IsShown()) then TranqRotate.mainFrame:Hide() + + if (IsInRaid()) then + TranqRotate.manuallyHiddenWhileInRaid = true + end + TranqRotate:printMessage('Tranqrotate window hidden. Use /tranq toggle to get it back') else TranqRotate.mainFrame:Show() @@ -123,7 +128,7 @@ end function TranqRotate:broadcastToRaid() local channel = 'RAID' - if (IsInGroup() and IsInRaid()) then + if (IsInRaid()) then SendChatMessage('--- ' .. L['BROADCAST_HEADER_TEXT'] .. ' ---', channel) SendChatMessage( From 9cf32f9c3bc0f52965d28a579b3a98ba4ae4e6d9 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Sun, 9 Feb 2020 20:52:18 +0100 Subject: [PATCH 18/37] Update french locale --- locales/frFR.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locales/frFR.lua b/locales/frFR.lua index 1fd6264..de24481 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -46,8 +46,8 @@ local L = { --- Rotation ["LOCK_WINDOW"] = "Verrouiller la position de la fênetre", ["LOCK_WINDOW_DESC"] = "Verrouiller la position de la fênetre", - ["HIDE_WINDOW_NOT_IN_RAID"] = "Hide the window when not in a raid", - ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Hide the window when not in a raid", + ["HIDE_WINDOW_NOT_IN_RAID"] = "Masquer la fenêtre principale hors raid", + ["HIDE_WINDOW_NOT_IN_RAID_DESC"] = "Masquer la fenêtre principale hors raid", ["WINDOW_LOCKED"] = "TranqRotate: Fenêtre verrouillée", ["WINDOW_UNLOCKED"] = "TranqRotate: Fenêtre déverrouillée", From b451548018c79b6d0f82e6b208ceece6c4592986 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 12:48:58 +0100 Subject: [PATCH 19/37] Fix table.contains, update hide out of raid setting mechanic --- TranqRotate.toc | 3 ++- src/events.lua | 21 +++++++++++---------- src/frames.lua | 30 +++++++++++++++++++++++++++++- src/gui.lua | 22 ---------------------- src/rotation.lua | 4 ++-- src/settings.lua | 5 ----- src/tranqRotate.lua | 17 ++++++++--------- src/utils.lua | 13 +++++++++++++ 8 files changed, 65 insertions(+), 50 deletions(-) create mode 100644 src/utils.lua diff --git a/TranqRotate.toc b/TranqRotate.toc index f605c6e..28b620a 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -28,4 +28,5 @@ src\frames.lua src\gui.lua src\dragdrop.lua src\defaults.lua -src\settings.lua \ No newline at end of file +src\settings.lua +src\utils.lua \ No newline at end of file diff --git a/src/events.lua b/src/events.lua index 11623f2..ade9f4e 100644 --- a/src/events.lua +++ b/src/events.lua @@ -49,6 +49,17 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() end end +function TranqRotate:GROUP_ROSTER_UPDATE() + TranqRotate:updateRaidStatus() + TranqRotate:updateDisplay() +end + +function TranqRotate:PLAYER_TARGET_CHANGED() + TranqRotate:updateRaidStatus() + self:UnregisterEvent("PLAYER_TARGET_CHANGED") +end + + -- Register single unit events for a given hunter function TranqRotate:registerUnitEvents(hunter) @@ -76,13 +87,3 @@ function TranqRotate:unregisterUnitEvents(hunter) hunter.frame:UnregisterEvent("UNIT_CONNECTION") hunter.frame:UnregisterEvent("UNIT_FLAGS") end - -function TranqRotate:GROUP_ROSTER_UPDATE() - TranqRotate:updateRaidStatus() - TranqRotate:updateDisplay() -end - -function TranqRotate:PLAYER_TARGET_CHANGED() - TranqRotate:updateRaidStatus() - self:UnregisterEvent("PLAYER_TARGET_CHANGED") -end diff --git a/src/frames.lua b/src/frames.lua index 4e6bc81..b9985e8 100644 --- a/src/frames.lua +++ b/src/frames.lua @@ -1,5 +1,6 @@ local TranqRotate = select(2, ...) +-- Create main window function TranqRotate:createMainFrame() TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) TranqRotate.mainFrame:SetWidth(120) @@ -20,6 +21,7 @@ function TranqRotate:createMainFrame() ) end +-- Create Title frame function TranqRotate:createTitleFrame() TranqRotate.mainFrame.titleFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.titleFrame:SetPoint('TOPLEFT') @@ -39,6 +41,7 @@ function TranqRotate:createTitleFrame() TranqRotate.mainFrame.titleFrame.text:SetTextColor(1,1,1,1) end +-- Create title bar buttons function TranqRotate:createButtons() local buttons = { @@ -64,7 +67,7 @@ function TranqRotate:createButtons() end end - +-- Create a single button in the title bar function TranqRotate:createButton(position, texture, callback) local button = CreateFrame("Button", nil, TranqRotate.mainFrame.titleFrame) @@ -85,6 +88,7 @@ function TranqRotate:createButton(position, texture, callback) button:SetScript("OnClick", callback) end +-- Create rotation frame function TranqRotate:createRotationFrame() TranqRotate.mainFrame.rotationFrame = CreateFrame("Frame", 'rotationFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.rotationFrame:SetPoint('LEFT') @@ -97,6 +101,7 @@ function TranqRotate:createRotationFrame() TranqRotate.mainFrame.rotationFrame.texture:SetAllPoints() end +-- Create backup frame function TranqRotate:createBackupFrame() -- Backup frame TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) @@ -115,3 +120,26 @@ function TranqRotate:createBackupFrame() TranqRotate.mainFrame.backupFrame.texture:SetWidth(60) TranqRotate.mainFrame.backupFrame.texture:SetPoint('TOP') end + +-- Create single hunter frame +function TranqRotate:createHunterFrame(hunter, parentFrame) + hunter.frame = CreateFrame("Frame", nil, parentFrame) + hunter.frame:SetHeight(TranqRotate.constants.hunterFrameHeight) + + -- Set Texture + hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") + hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") + hunter.frame.texture:SetAllPoints() + + -- Set Text + hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") + hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) + hunter.frame.text:SetPoint("LEFT",5,0) + hunter.frame.text:SetText(hunter.name) + + TranqRotate:configureHunterFrameDrag(hunter) + + if (TranqRotate.enableDrag) then + TranqRotate:enableHunterFrameDragging(hunter, true) + end +end \ No newline at end of file diff --git a/src/gui.lua b/src/gui.lua index 8e4ee61..a3e085d 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -141,25 +141,3 @@ function TranqRotate:lock(lock) TranqRotate:printMessage(L['WINDOW_UNLOCKED']) end end - -function TranqRotate:createHunterFrame(hunter, parentFrame) - hunter.frame = CreateFrame("Frame", nil, parentFrame) - hunter.frame:SetHeight(TranqRotate.constants.hunterFrameHeight) - - -- Set Texture - hunter.frame.texture = hunter.frame:CreateTexture(nil, "ARTWORK") - hunter.frame.texture:SetTexture("Interface\\AddOns\\TranqRotate\\textures\\steel.tga") - hunter.frame.texture:SetAllPoints() - - -- Set Text - hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") - hunter.frame.text:SetFont("Fonts\\ARIALN.ttf", 12) - hunter.frame.text:SetPoint("LEFT",5,0) - hunter.frame.text:SetText(hunter.name) - - TranqRotate:configureHunterFrameDrag(hunter) - - if (TranqRotate.enableDrag) then - TranqRotate:enableHunterFrameDragging(hunter, true) - end -end \ No newline at end of file diff --git a/src/rotation.lua b/src/rotation.lua index 962a657..54347e6 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -313,10 +313,10 @@ end -- Find the table that contains given hunter (rotation or backup) function TranqRotate:getHunterRotationTable(hunter) - if (table.contains(TranqRotate.rotationTables.rotation, hunter)) then + if (TranqRotate:tableContains(TranqRotate.rotationTables.rotation, hunter)) then return TranqRotate.rotationTables.rotation end - if (table.contains(TranqRotate.rotationTables.backup, hunter)) then + if (TranqRotate:tableContains(TranqRotate.rotationTables.backup, hunter)) then return TranqRotate.rotationTables.backup end end diff --git a/src/settings.lua b/src/settings.lua index 7adcb85..92ef0c1 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -66,11 +66,6 @@ function TranqRotate:CreateConfig() type = "toggle", order = 6, width = "double", - set = function(info, value) - set(info,value) - LibStub("AceConfigRegistry-3.0", true):NotifyChange("TranqRotate") - TranqRotate:updateDisplay() - end } } }, diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 7991782..8d63498 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -36,6 +36,7 @@ end function TranqRotate:applySettings() TranqRotate.mainFrame:ClearAllPoints() + local config = TranqRotate.db.profile if config.point then TranqRotate.mainFrame:SetPoint(config.point, UIParent, config.relativePoint, config.x, config.y) @@ -43,6 +44,8 @@ function TranqRotate:applySettings() TranqRotate.mainFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0) end + TranqRotate:updateDisplay() + TranqRotate.mainFrame:EnableMouse(not TranqRotate.db.profile.lock) TranqRotate.mainFrame:SetMovable(not TranqRotate.db.profile.lock) end @@ -111,20 +114,13 @@ function TranqRotate:test() -- TranqRotate:enableListSorting() end -function table.contains(table, element) - for _, value in pairs(table) do - if value == element then - return true - end - end - return false -end - +-- Open ace settings function TranqRotate:openSettings() local AceConfigDialog = LibStub("AceConfigDialog-3.0") AceConfigDialog:Open("TranqRotate") end +-- Sends rotation setup to raid channel function TranqRotate:broadcastToRaid() local channel = 'RAID' @@ -146,6 +142,7 @@ function TranqRotate:broadcastToRaid() end +-- Serialize hunters names of a given rotation group function TranqRotate:buildGroupMessage(prefix, rotationTable) local hunters = {} @@ -156,6 +153,7 @@ function TranqRotate:buildGroupMessage(prefix, rotationTable) return prefix .. table.concat(hunters, ', ') end +-- Print command options to chat function TranqRotate:printHelp() TranqRotate:printMessage(TranqRotate:colorText('/tranqrotate') .. ' commands options :') TranqRotate:printMessage(' ' .. TranqRotate:colorText('toggle') .. ' : Show/Hide the main window') @@ -164,6 +162,7 @@ function TranqRotate:printHelp() TranqRotate:printMessage(' ' .. TranqRotate:colorText('settings') .. ' : Open TranqRotate settings') end +-- Adds color to given text function TranqRotate:colorText(text) return '|cffffbf00' .. text .. '|r' end diff --git a/src/utils.lua b/src/utils.lua new file mode 100644 index 0000000..f23ca2f --- /dev/null +++ b/src/utils.lua @@ -0,0 +1,13 @@ +local TranqRotate = select(2, ...) + +-- Check if a table contains the given element +function TranqRotate:tableContains(table, element) + + for _, value in pairs(table) do + if value == element then + return true + end + end + + return false +end \ No newline at end of file From 7d11cbeec8467a7fb6f8b4050c9001c1b208beb2 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:08:29 +0100 Subject: [PATCH 20/37] update settings general description --- locales/enUS.lua | 5 +++-- locales/frFR.lua | 5 +++-- locales/zhCN.lua | 5 +++-- locales/zhTW.lua | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index 8073115..f5ae276 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -7,8 +7,9 @@ local L = { -- Settings ["SETTING_GENERAL"] = "General", ["SETTING_GENERAL_REPORT"] = "Please report any issue at", - ["SETTING_GENERAL_DESC"] = "This first version will only allow you to get automatic tranq annouce messages\n".. - "I'm planning to add more features giving visual feedback about tranqshot rotation", + ["SETTING_GENERAL_DESC"] = "New : TranqRotate now has a window allowing hunters to track rotation status\n".. + "It still automatically announce tranq or miss and now whispers next and backup when you miss\n".. + "It doesn't sync rotation order between hunters yet, you have to manually set the correct groups and order.", --- Announces ["SETTING_ANNOUNCES"] = "Announces", diff --git a/locales/frFR.lua b/locales/frFR.lua index de24481..3a2b5d6 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -9,8 +9,9 @@ local L = { -- Settings ["SETTING_GENERAL"] = "Général", ["SETTING_GENERAL_REPORT"] = "Merci de signaler tout bug rencontré sur", - ["SETTING_GENERAL_DESC"] = "Cette première version permet uniquement des annonces automatique pour le tir tranquillisant\n".. - "D'autres fonctionnalités sont prévues, permettant entre autre un affichage temps réel de la rotation et des cooldowns", + ["SETTING_GENERAL_DESC"] = "Nouveau : Une fenetre permet maintenant de régler et suivre la rotation\n".. + "TranRotate va également et automatiquement chuchoter le chasseur suivant et le backup en cas de raté !\n".. + "Aucune synchronisation n'est encore en place, chaque chasseur dois régler l'ordre de son coté.", --- Announces ["SETTING_ANNOUNCES"] = "Annonces", diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 2c200b9..22f129f 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -9,8 +9,9 @@ local L = { -- Settings ["SETTING_GENERAL"] = "General", ["SETTING_GENERAL_REPORT"] = "Please report any issue at", - ["SETTING_GENERAL_DESC"] = "This first version will only allow you to get automatic tranq annouce messages\n".. - "I'm planning to add more features giving visual feedback about tranqshot rotation", + ["SETTING_GENERAL_DESC"] = "New : TranqRotate now has a window allowing hunters to track rotation status\n".. + "It still automatically announce tranq or miss and now whispers next and backup when you miss\n".. + "It doesn't sync rotation order between hunters yet, you have to manually set the correct groups and order.", --- Announces ["SETTING_ANNOUNCES"] = "通告", diff --git a/locales/zhTW.lua b/locales/zhTW.lua index b797452..254da2b 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -9,8 +9,9 @@ local L = { -- Settings ["SETTING_GENERAL"] = "General", ["SETTING_GENERAL_REPORT"] = "Please report any issue at", - ["SETTING_GENERAL_DESC"] = "This first version will only allow you to get automatic tranq annouce messages\n".. - "I'm planning to add more features giving visual feedback about tranqshot rotation", + ["SETTING_GENERAL_DESC"] = "New : TranqRotate now has a window allowing hunters to track rotation status\n".. + "It still automatically announce tranq or miss and now whispers next and backup when you miss\n".. + "It doesn't sync rotation order between hunters yet, you have to manually set the correct groups and order.", --- Announces ["SETTING_ANNOUNCES"] = "通告", From 1cfcc247b77e9f4f13d12daf52ed3da95eae3bad Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:09:51 +0100 Subject: [PATCH 21/37] Update loaded message --- locales/enUS.lua | 2 +- locales/zhCN.lua | 2 +- locales/zhTW.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index f5ae276..1217315 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -2,7 +2,7 @@ local TranqRotate = select(2, ...) local L = { - ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for settings", + ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", -- Settings ["SETTING_GENERAL"] = "General", diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 22f129f..6aabaa7 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -4,7 +4,7 @@ local TranqRotate = select(2, ...) local L = { - ["LOADED_MESSAGE"] = "TranqRotate 已加载, 输入 /tranq 进入设置", + ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", -- Settings ["SETTING_GENERAL"] = "General", diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 254da2b..c0347cc 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -4,7 +4,7 @@ local TranqRotate = select(2, ...) local L = { - ["LOADED_MESSAGE"] = "TranqRotate 已加載, 輸入 /tranq 進入設置", + ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", -- Settings ["SETTING_GENERAL"] = "General", From 5822d1e96ded3d672c63c04c93b321e3e2594969 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:48:35 +0100 Subject: [PATCH 22/37] Update readme --- README.md | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6c6c53d..185185c 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,48 @@ This addon is meant to help hunters to setup tranqshot rotation and give them real time visual feedback about it. -This first version is missing a lot of features I want to implement, and will only let you configure automatic success and miss tranqshot announces to a defined channel, hopefully you won't have to bother with that crappy macro anymore ! +**TranqRotate DOES NOT synchronize anything with other hunters (yet), even if they use the addon too.** + +This addon is still in a (stable) beta state, a stable release should come soon. + +## Feedback + +I'm looking for feedback ! Feel free to contact me at any time ingame (Slivo@Sulfuron) or elsewhere. +Please report any issue using github issues : https://github.com/Slivo-fr/TranqRotate/issues + +## Features + +- Automatically send messages to notify others player about your tranq success or fail, hopefully you won't have to bother with that crappy macro anymore ! +- Display the list of raid hunters +- Allow player to re-order players between two groups : main rotation and backup. +- Whisper the next hunter on the rotation as well as all backup hunters if you miss your tranqshot +- Provide a real time visual feedback about the rotation status, even if no one else use the addon in your raid +- Allow player to broadcast the configured rotation and backup group to the raid +- Display offline and dead status on hunters frames + +## Usage + +Use `/tranq` for options + +You must be in a raid for hunters to get registered and displayed by the addon. + +First step is to set your tranq order using drag & drop on hunters. You may use the trumpet button to get it written in raid chat so others hunters can know what you planned (And set their TranqRotate order if they use it). Please note the backup group is hidden if empty but you can still drag hunters into it. + +You can now just pull the boss and start shooting your tranqshots, TranqRotate will track the rotation and use a purple tranq-like color on the next hunter that should tranq. + +Once boss has died (or you wiped), just use the reset button in the top bar to reset the rotation state ## Roadmap Here is a list of feature I want to implement at some point, no specific order is decided yet. -- Display of hunter's tranqhot cooldowns -- Transhot rotation configuration (raid assist required, order hunters, make groupe of multiple hunters, leave some hunt out of rotation as backup) -- Transhot rotation display (Synchronized list will rotate as hunters tranq successfully or miss, showing at top the next hunter or hunter group that will have to tranq) +- Display of every hunter tranqhot cooldowns +- Data sync between all users, allowing raid leader or raid assistant to setup the rotation for everyone +- Automatic handling of death and disconnection of hunters on the rotation group (swap with a backup, send an alert about it) +- Use raid symbols to mark hunters that need to tranq, or that need to backup a failed tranqshot +- Automatic reset of rotation when raid wipe or boss die +- Encounter detection and frenzy cooldown progress bar +- Add a button to close the window without using `/tranq toggle` ### Download @@ -20,13 +53,7 @@ Also available here https://www.curseforge.com/wow/addons/tranqrotate and there ### Credits -I've been learning and using some code of https://github.com/Aviana/YaHT to build this first codebase. It helped a lot ! - -### About me - -I work as developer in a very different field, I have been wanting to make some addon for a long time but I'm a total newbie on this topic. - -Here is my first try, don't be too harsh but let me know if somethings looks wrong to you ! -Please report any issue using github issues : https://github.com/Slivo-fr/TranqRotate/issues +I've been learning and using some code of https://github.com/Aviana/YaHT to build this first codebase. Thanks for his work. +Many thanks to the wow addon discord members that helped me a lot too. From f1b421dccec3ce45c6ba7a38c3eebbd3b0db9e9e Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:51:00 +0100 Subject: [PATCH 23/37] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 185185c..ddcbb82 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ This addon is still in a (stable) beta state, a stable release should come soon. ## Feedback -I'm looking for feedback ! Feel free to contact me at any time ingame (Slivo@Sulfuron) or elsewhere. +I'm looking for feedback ! Feel free to contact me at any time ingame (Slivo@Sulfuron) or elsewhere. + Please report any issue using github issues : https://github.com/Slivo-fr/TranqRotate/issues ## Features From 9bcd2758d0f9bb7492085f59036a3f9d7816c1a6 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:57:17 +0100 Subject: [PATCH 24/37] Update readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ddcbb82..d627ba3 100644 --- a/README.md +++ b/README.md @@ -46,15 +46,13 @@ Here is a list of feature I want to implement at some point, no specific order i - Encounter detection and frenzy cooldown progress bar - Add a button to close the window without using `/tranq toggle` -### Download +## Download Do not use github download button on this page, get the latest release zip file from https://github.com/Slivo-fr/TranqRotate/releases Also available here https://www.curseforge.com/wow/addons/tranqrotate and there https://wowclassicui.com/fr/addons/tranqrotate -### Credits +## Credits I've been learning and using some code of https://github.com/Aviana/YaHT to build this first codebase. Thanks for his work. Many thanks to the wow addon discord members that helped me a lot too. - - From cee7c495fa5ceacf15aec42bde62e4f7ad147106 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Mon, 10 Feb 2020 13:58:21 +0100 Subject: [PATCH 25/37] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d627ba3..1de47f6 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,5 @@ Also available here https://www.curseforge.com/wow/addons/tranqrotate and there ## Credits I've been learning and using some code of https://github.com/Aviana/YaHT to build this first codebase. Thanks for his work. + Many thanks to the wow addon discord members that helped me a lot too. From d34f05c3e5e574a662e53af66f0b904a65eba284 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:01:16 +0100 Subject: [PATCH 26/37] Adds hidden window message to locales --- locales/enUS.lua | 1 + locales/frFR.lua | 1 + locales/zhCN.lua | 1 + locales/zhTW.lua | 1 + 4 files changed, 4 insertions(+) diff --git a/locales/enUS.lua b/locales/enUS.lua index 1217315..361b480 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -3,6 +3,7 @@ local TranqRotate = select(2, ...) local L = { ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", + ["TRANQ_WINDOW_HIDDEN"] = "Tranqrotate window hidden. Use /tranq toggle to get it back", -- Settings ["SETTING_GENERAL"] = "General", diff --git a/locales/frFR.lua b/locales/frFR.lua index 3a2b5d6..b9c39b8 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -5,6 +5,7 @@ local TranqRotate = select(2, ...) local L = { ["LOADED_MESSAGE"] = "TranqRotate chargé, utilisez /tranq pour les options", + ["TRANQ_WINDOW_HIDDEN"] = "Tranqrotate window hidden. Use /tranq toggle to get it back", -- Settings ["SETTING_GENERAL"] = "Général", diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 6aabaa7..a404c00 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -5,6 +5,7 @@ local TranqRotate = select(2, ...) local L = { ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", + ["TRANQ_WINDOW_HIDDEN"] = "Tranqrotate window hidden. Use /tranq toggle to get it back", -- Settings ["SETTING_GENERAL"] = "General", diff --git a/locales/zhTW.lua b/locales/zhTW.lua index c0347cc..9bd1b01 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -5,6 +5,7 @@ local TranqRotate = select(2, ...) local L = { ["LOADED_MESSAGE"] = "TranqRotate loaded, type /tranq for options", + ["TRANQ_WINDOW_HIDDEN"] = "Tranqrotate window hidden. Use /tranq toggle to get it back", -- Settings ["SETTING_GENERAL"] = "General", From b1b651f74aa66ed844ac5cd006a2a9f774e190f7 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:01:43 +0100 Subject: [PATCH 27/37] Adds changelog --- changelog.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..81ea064 --- /dev/null +++ b/changelog.md @@ -0,0 +1,40 @@ +## TranqRotate Changelog + +#### v1.1.0 + +- Adds TranqRotate window +- Adds raid hunters detection +- Adds rotation handling +- Adds main window position change using drag & drop +- Adds main window position lock setting +- Adds hunter death and disconnection display on hunter frames +- Adds hunter group and order change using drag & drop +- Adds lock/unlock slash command option +- Adds toggle slash command option +- Adds "broadcast rotation setup to raid chat" +- Adds rotation reset button to re-initialize betweeen/after pulls +- Adds whisper message to next hunter and all backup hunters when you miss +- Adds close button to top bar +- Adds option to hide main window when not in a raid + +- Change base slash command to display available options +- Change slash command settings to `/tranq settings` + +- Splits code in multiple files +- Moves all lua files to src/ +- Use first target change event to update raid status if player login while already in raid +- Updates game interface version to 11303 + +#### v1.0.1 + +- Fix missing libs in toc file + +#### v1.0.0 + +- Adds slash command +- Adds settings +- Adds base combat log handling +- Adds automatic success and fail tranqshot messages +- Adds frFR locale +- Adds znTW locale +- Adds znTW locale From 9120c0d9a8291d6d1e2f50bb8812a975832d65a9 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:02:19 +0100 Subject: [PATCH 28/37] Update readme, adds close button --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1de47f6..751a816 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,6 @@ Here is a list of feature I want to implement at some point, no specific order i - Use raid symbols to mark hunters that need to tranq, or that need to backup a failed tranqshot - Automatic reset of rotation when raid wipe or boss die - Encounter detection and frenzy cooldown progress bar -- Add a button to close the window without using `/tranq toggle` ## Download From 43dd4cb0f226b8c8c85b470779cbc9543219dede Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:02:54 +0100 Subject: [PATCH 29/37] Remove unused getNextTranq function --- src/rotation.lua | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/rotation.lua b/src/rotation.lua index 54347e6..fc3b2a2 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -83,16 +83,6 @@ function TranqRotate:setNextTranq(nextHunter) end end --- Returns the hunter that will shoot next -function TranqRotate:getNextTranq() - for key, hunter in pairs(TranqRotate.rotationTables.rotation) do - if (hunter.nextTranq) then - return hunter - end - end -end - - -- Find and returns the next hunter that will tranq base on last shooter function TranqRotate:getNextRotationHunter(lastHunter) From 9312c7cb64ebc83ab2ddfb44b2afbd68f9e0b255 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:06:56 +0100 Subject: [PATCH 30/37] Use hide window localized message --- src/tranqRotate.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 8d63498..f56ea03 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -102,7 +102,7 @@ function TranqRotate:toggleDisplay() TranqRotate.manuallyHiddenWhileInRaid = true end - TranqRotate:printMessage('Tranqrotate window hidden. Use /tranq toggle to get it back') + TranqRotate:printMessage(L['TRANQ_WINDOW_HIDDEN']) else TranqRotate.mainFrame:Show() end From 642c418d4d1e8113ee6e7c2144e4d6073affcc92 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Tue, 11 Feb 2020 13:07:33 +0100 Subject: [PATCH 31/37] Adds close button, replace hard values with constants --- src/constants.lua | 4 +++- src/frames.lua | 23 +++++++++++++++++------ src/gui.lua | 8 ++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/constants.lua b/src/constants.lua index c0cbfcf..aad7eef 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -13,5 +13,7 @@ TranqRotate.colors = { TranqRotate.constants = { ['hunterFrameHeight'] = 20, ['hunterFrameSpacing'] = 4, - ['titleBarHeight'] = 18 + ['titleBarHeight'] = 18, + ['mainFrameWidth'] = 130, + ['rotationFramesBaseHeight'] = 20, } diff --git a/src/frames.lua b/src/frames.lua index b9985e8..f28ef71 100644 --- a/src/frames.lua +++ b/src/frames.lua @@ -3,8 +3,8 @@ local TranqRotate = select(2, ...) -- Create main window function TranqRotate:createMainFrame() TranqRotate.mainFrame = CreateFrame("Frame", 'mainFrame', UIParent) - TranqRotate.mainFrame:SetWidth(120) - TranqRotate.mainFrame:SetHeight(40 + TranqRotate.constants.titleBarHeight) + TranqRotate.mainFrame:SetWidth(TranqRotate.constants.mainFrameWidth) + TranqRotate.mainFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight * 2 + TranqRotate.constants.titleBarHeight) TranqRotate.mainFrame:Show() TranqRotate.mainFrame:RegisterForDrag("LeftButton") @@ -45,6 +45,11 @@ end function TranqRotate:createButtons() local buttons = { + { + ['texture'] = 'Interface/Buttons/UI-Panel-MinimizeButton-Up', + ['callback'] = TranqRotate.toggleDisplay, + ['textCoord'] = {0.18, 0.8, 0.2, 0.8} + }, { ['texture'] = 'Interface/GossipFrame/BinderGossipIcon', ['callback'] = TranqRotate.openSettings @@ -62,13 +67,13 @@ function TranqRotate:createButtons() local position = 5 for key, button in pairs(buttons) do - TranqRotate:createButton(position, button.texture, button.callback ) + TranqRotate:createButton(position, button.texture, button.callback, button.textCoord) position = position + 13 end end -- Create a single button in the title bar -function TranqRotate:createButton(position, texture, callback) +function TranqRotate:createButton(position, texture, callback, textCoord) local button = CreateFrame("Button", nil, TranqRotate.mainFrame.titleFrame) button:SetPoint('RIGHT', -position, 0) @@ -85,6 +90,11 @@ function TranqRotate:createButton(position, texture, callback) highlight:SetAllPoints() button:SetHighlightTexture(highlight) + if (textCoord) then + normal:SetTexCoord(unpack(textCoord)) + highlight:SetTexCoord(unpack(textCoord)) + end + button:SetScript("OnClick", callback) end @@ -94,7 +104,7 @@ function TranqRotate:createRotationFrame() TranqRotate.mainFrame.rotationFrame:SetPoint('LEFT') TranqRotate.mainFrame.rotationFrame:SetPoint('RIGHT') TranqRotate.mainFrame.rotationFrame:SetPoint('TOP', 0, -TranqRotate.constants.titleBarHeight) - TranqRotate.mainFrame.rotationFrame:SetHeight(20) + TranqRotate.mainFrame.rotationFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight) TranqRotate.mainFrame.rotationFrame.texture = TranqRotate.mainFrame.rotationFrame:CreateTexture(nil, "BACKGROUND") TranqRotate.mainFrame.rotationFrame.texture:SetColorTexture(0,0,0,0.5) @@ -107,8 +117,9 @@ function TranqRotate:createBackupFrame() TranqRotate.mainFrame.backupFrame = CreateFrame("Frame", 'backupFrame', TranqRotate.mainFrame) TranqRotate.mainFrame.backupFrame:SetPoint('TOPLEFT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMLEFT', 0, 0) TranqRotate.mainFrame.backupFrame:SetPoint('TOPRIGHT', TranqRotate.mainFrame.rotationFrame, 'BOTTOMRIGHT', 0, 0) - TranqRotate.mainFrame.backupFrame:SetHeight(20) + TranqRotate.mainFrame.backupFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight) + -- Set Texture TranqRotate.mainFrame.backupFrame.texture = TranqRotate.mainFrame.backupFrame:CreateTexture(nil, "BACKGROUND") TranqRotate.mainFrame.backupFrame.texture:SetColorTexture(0,0,0,0.5) TranqRotate.mainFrame.backupFrame.texture:SetAllPoints() diff --git a/src/gui.lua b/src/gui.lua index a3e085d..b56e76d 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -39,16 +39,16 @@ end function TranqRotate:drawHunterFrames() -- Different height to reduce spacing between both groups - TranqRotate.mainFrame:SetHeight(20 + TranqRotate.constants.titleBarHeight) - TranqRotate.mainFrame.rotationFrame:SetHeight(20) + TranqRotate.mainFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight + TranqRotate.constants.titleBarHeight) + TranqRotate.mainFrame.rotationFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight) TranqRotate:drawList(TranqRotate.rotationTables.rotation, TranqRotate.mainFrame.rotationFrame) if (#TranqRotate.rotationTables.backup > 0) then - TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + 20) + TranqRotate.mainFrame:SetHeight(TranqRotate.mainFrame:GetHeight() + TranqRotate.constants.rotationFramesBaseHeight) end - TranqRotate.mainFrame.backupFrame:SetHeight(20) + TranqRotate.mainFrame.backupFrame:SetHeight(TranqRotate.constants.rotationFramesBaseHeight) TranqRotate:drawList(TranqRotate.rotationTables.backup, TranqRotate.mainFrame.backupFrame) end From c0a47c49cbdd120a49baeacb651dc4fa09cd56f9 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Wed, 12 Feb 2020 08:37:59 +0100 Subject: [PATCH 32/37] fr locale misstyping --- locales/frFR.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/frFR.lua b/locales/frFR.lua index b9c39b8..ed9cdde 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -11,7 +11,7 @@ local L = { ["SETTING_GENERAL"] = "Général", ["SETTING_GENERAL_REPORT"] = "Merci de signaler tout bug rencontré sur", ["SETTING_GENERAL_DESC"] = "Nouveau : Une fenetre permet maintenant de régler et suivre la rotation\n".. - "TranRotate va également et automatiquement chuchoter le chasseur suivant et le backup en cas de raté !\n".. + "TranqRotate va également et automatiquement chuchoter le chasseur suivant et le backup en cas de raté !\n".. "Aucune synchronisation n'est encore en place, chaque chasseur dois régler l'ordre de son coté.", --- Announces From 25cf7e8d55bf1ce1f1d30037395e5cb173c53eff Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Wed, 12 Feb 2020 09:42:15 +0100 Subject: [PATCH 33/37] Update drop hint width --- src/dragdrop.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dragdrop.lua b/src/dragdrop.lua index 278705c..5b20f50 100644 --- a/src/dragdrop.lua +++ b/src/dragdrop.lua @@ -55,7 +55,7 @@ function TranqRotate:createDropHintFrame() hintFrame:SetPoint('TOP', TranqRotate.mainFrame.rotationFrame, 'TOP', 0, 0) hintFrame:SetHeight(TranqRotate.constants.hunterFrameHeight) - hintFrame:SetWidth(110) + hintFrame:SetWidth(TranqRotate.constants.mainFrameWidth - 10) hintFrame.texture = hintFrame:CreateTexture(nil, "BACKGROUND") hintFrame.texture:SetColorTexture(TranqRotate.colors.white:GetRGB()) From 25858ce90c319fd59a33e44dade44b8cf0ab66e7 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 13 Feb 2020 13:15:49 +0100 Subject: [PATCH 34/37] Do not consider feigned hunter as dead --- src/rotation.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rotation.lua b/src/rotation.lua index fc3b2a2..9f000d2 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -226,7 +226,7 @@ function TranqRotate:updateRaidStatus() if (registered) then hunter.offline = not online - hunter.alive = not isDead + hunter.alive = TranqRotate:isHunterAlive(hunter.name) TranqRotate:refreshHunterFrame(hunter) end @@ -244,13 +244,17 @@ function TranqRotate:updateHuntersStatus() for key,hunter in pairs(TranqRotate.hunterTable) do - hunter.alive = not UnitIsDeadOrGhost(hunter.name) + hunter.alive = TranqRotate:isHunterAlive(hunter.name) hunter.offline = not UnitIsConnected(hunter.name) TranqRotate:refreshHunterFrame(hunter) end end +function TranqRotate:isHunterAlive(name) + return UnitIsFeignDeath(name) or not UnitIsDeadOrGhost(name) +end + -- Moves given hunter to the given position in the given group (ROTATION or BACKUP) function TranqRotate:moveHunter(hunter, group, position) From 28cd93301ebba7316f3666c0c6e0478feb07d72b Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 13 Feb 2020 13:19:54 +0100 Subject: [PATCH 35/37] Update window position logic --- src/frames.lua | 7 +++++-- src/tranqRotate.lua | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frames.lua b/src/frames.lua index f28ef71..b7fd5c3 100644 --- a/src/frames.lua +++ b/src/frames.lua @@ -14,9 +14,12 @@ function TranqRotate:createMainFrame() TranqRotate.mainFrame:SetScript( "OnDragStop", function() - local config, meh = TranqRotate.db.profile + local config = TranqRotate.db.profile TranqRotate.mainFrame:StopMovingOrSizing() - config.point, meh , config.relativePoint, config.x, config.y = TranqRotate.mainFrame:GetPoint() + + config.point = 'TOPLEFT' + config.y = TranqRotate.mainFrame:GetTop() + config.x = TranqRotate.mainFrame:GetLeft() end ) end diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index f56ea03..68af0f6 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -39,7 +39,7 @@ function TranqRotate:applySettings() local config = TranqRotate.db.profile if config.point then - TranqRotate.mainFrame:SetPoint(config.point, UIParent, config.relativePoint, config.x, config.y) + TranqRotate.mainFrame:SetPoint(config.point, UIParent, 'BOTTOMLEFT', config.x, config.y) else TranqRotate.mainFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0) end From be85ff5fb5a7b70bc5cdb9eb7dfb12100d6876f2 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 13 Feb 2020 13:20:45 +0100 Subject: [PATCH 36/37] Update readme, 45m limit --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 751a816..89d1df8 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ This addon is meant to help hunters to setup tranqshot rotation and give them real time visual feedback about it. -**TranqRotate DOES NOT synchronize anything with other hunters (yet), even if they use the addon too.** +**TranqRotate DOES NOT synchronize anything with other hunters (yet), even if they use the addon too. +Considering this fact and the Blizzard 45m combat log limit, I would advice to not have your hunters spread too much until sync is added.** This addon is still in a (stable) beta state, a stable release should come soon. ## Feedback -I'm looking for feedback ! Feel free to contact me at any time ingame (Slivo@Sulfuron) or elsewhere. +I'm looking for feedback ! Feel free to contact me ingame (Slivo@Sulfuron). Please report any issue using github issues : https://github.com/Slivo-fr/TranqRotate/issues @@ -28,7 +29,9 @@ Use `/tranq` for options You must be in a raid for hunters to get registered and displayed by the addon. -First step is to set your tranq order using drag & drop on hunters. You may use the trumpet button to get it written in raid chat so others hunters can know what you planned (And set their TranqRotate order if they use it). Please note the backup group is hidden if empty but you can still drag hunters into it. +First step is to set your tranq order using drag & drop on hunters. +You may use the trumpet button to get it written in raid chat so others hunters can know what you planned (And set their TranqRotate order if they use it). +Please note the backup group is hidden if empty but you can still drag hunters into it. You can now just pull the boss and start shooting your tranqshots, TranqRotate will track the rotation and use a purple tranq-like color on the next hunter that should tranq. @@ -44,6 +47,7 @@ Here is a list of feature I want to implement at some point, no specific order i - Use raid symbols to mark hunters that need to tranq, or that need to backup a failed tranqshot - Automatic reset of rotation when raid wipe or boss die - Encounter detection and frenzy cooldown progress bar +- Handling of battleground raids ## Download From 944ff8f7510d817cbc98a89b8e55b89951603567 Mon Sep 17 00:00:00 2001 From: Slivo-fr Date: Thu, 13 Feb 2020 13:22:00 +0100 Subject: [PATCH 37/37] Factorise command option spacing --- src/tranqRotate.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 68af0f6..96f0cea 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -155,11 +155,12 @@ end -- Print command options to chat function TranqRotate:printHelp() + local spacing = ' ' TranqRotate:printMessage(TranqRotate:colorText('/tranqrotate') .. ' commands options :') - TranqRotate:printMessage(' ' .. TranqRotate:colorText('toggle') .. ' : Show/Hide the main window') - TranqRotate:printMessage(' ' .. TranqRotate:colorText('lock') .. ' : Lock the main window position') - TranqRotate:printMessage(' ' .. TranqRotate:colorText('unlock') .. ' : Unlock the main window position') - TranqRotate:printMessage(' ' .. TranqRotate:colorText('settings') .. ' : Open TranqRotate settings') + TranqRotate:printMessage(spacing .. TranqRotate:colorText('toggle') .. ' : Show/Hide the main window') + TranqRotate:printMessage(spacing .. TranqRotate:colorText('lock') .. ' : Lock the main window position') + TranqRotate:printMessage(spacing .. TranqRotate:colorText('unlock') .. ' : Unlock the main window position') + TranqRotate:printMessage(spacing .. TranqRotate:colorText('settings') .. ' : Open TranqRotate settings') end -- Adds color to given text