diff --git a/plugins/Details_RaidCheck/Details_RaidCheck.lua b/plugins/Details_RaidCheck/Details_RaidCheck.lua index 56cde3f9..181a57cd 100644 --- a/plugins/Details_RaidCheck/Details_RaidCheck.lua +++ b/plugins/Details_RaidCheck/Details_RaidCheck.lua @@ -11,395 +11,353 @@ local UnitClass = UnitClass local UnitName = UnitName local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS +local Loc = LibStub("AceLocale-3.0"):GetLocale("Details") +local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0") local DF = DetailsFramework - local UnitGroupRolesAssigned = DF.UnitGroupRolesAssigned - local version = "95" ---> build the list of buffs to track -local flask_list = DF.FlaskIDs - -local is_drinking = 257428 +--build the list of buffs to track +local flaskList = LIB_OPEN_RAID_FLASK_BUFF +local runeIds = DF.RuneIDs +local isDrinking = 257428 local localizedFoodDrink -local food_list = { +local foodList = { --list for previous dragonflight expsansions tier1 = {}, tier2 = {}, tier3 = {}, } -for spellID, power in pairs (DF.FoodIDs) do - if (power == 1) then - food_list.tier1 [spellID] = true +local foodInfoList = {} --list for dragonflight and beyond - elseif (power == 2) then - food_list.tier2 [spellID] = true - - elseif (power == 3) then - food_list.tier3 [spellID] = true - - end -end - -local runes_id = DF.RuneIDs - --- - -local get_unit_id = function (i) - local unitID - +local getUnitId = function(i) + local unitId local unitType = "raid" - if (not IsInRaid()) then --o jogador esta em grupo + if (not IsInRaid()) then unitType = "party" end - + if (unitType == "party") then if (i == GetNumGroupMembers()) then - unitID = "player" + unitId = "player" else - unitID = unitType .. i + unitId = unitType .. i end else - unitID = unitType .. i + unitId = unitType .. i end - - return unitID + + return unitId end ---> localization - local Loc = LibStub ("AceLocale-3.0"):GetLocale ("Details") ---> create the plugin object - local DetailsRaidCheck = _detalhes:NewPluginObject ("Details_RaidCheck", DETAILSPLUGIN_ALWAYSENABLED) - tinsert (UISpecialFrames, "Details_RaidCheck") - DetailsRaidCheck:SetPluginDescription (Loc ["STRING_RAIDCHECK_PLUGIN_DESC"]) +--create the plugin object +local DetailsRaidCheck = Details:NewPluginObject("Details_RaidCheck", DETAILSPLUGIN_ALWAYSENABLED) +tinsert(UISpecialFrames, "Details_RaidCheck") +DetailsRaidCheck:SetPluginDescription(Loc ["STRING_RAIDCHECK_PLUGIN_DESC"]) - - local debugmode = false - --local debugmode = true - - local CreatePluginFrames = function() - - --> localize details functions (localize = it doesn't need to get this through indexed metatable any more) - DetailsRaidCheck.GetOnlyName = DetailsRaidCheck.GetOnlyName - - --> tables - DetailsRaidCheck.usedprepot_table = {} - DetailsRaidCheck.focusaug_table = {} - DetailsRaidCheck.haveflask_table = {} - DetailsRaidCheck.havefood_table = {} - DetailsRaidCheck.iseating_table = {} - DetailsRaidCheck.havefocusaug_table = {} - - DetailsRaidCheck.on_raid = false - DetailsRaidCheck.tracking_buffs = false - - local empty_table = {} - - local PlayerData = {} - local UpdateSpeed = 0.5 - - function DetailsRaidCheck:OnDetailsEvent (event, ...) - - if (event == "ZONE_TYPE_CHANGED") then - - DetailsRaidCheck:CheckCanShowIcon (...) - - elseif (event == "COMBAT_PREPOTION_UPDATED") then - - DetailsRaidCheck.usedprepot_table, DetailsRaidCheck.focusaug_table = select (1, ...) - - elseif (event == "COMBAT_PLAYER_LEAVE") then - - elseif (event == "COMBAT_PLAYER_ENTER") then - - elseif (event == "DETAILS_STARTED") then - - localizedFoodDrink = GetSpellInfo (is_drinking) - DetailsRaidCheck:CheckCanShowIcon() - - elseif (event == "PLUGIN_DISABLED") then - - DetailsRaidCheck.on_raid = false - DetailsRaidCheck.tracking_buffs = false - - DetailsRaidCheck:StopTrackBuffs() - - DetailsRaidCheck:HideToolbarIcon (DetailsRaidCheck.ToolbarButton) - - elseif (event == "PLUGIN_ENABLED") then - - DetailsRaidCheck:CheckCanShowIcon() - - end - +local CreatePluginFrames = function() + --build food tier list + if (DF.IsDragonflightAndBeyond()) then + --{tier = {[220] = 1}, status = {"haste"}, localized = {STAT_HASTE}} + for spellId, foodInfo in pairs(LIB_OPEN_RAID_FOOD_BUFF) do + foodInfoList[spellId] = foodInfo end - - DetailsRaidCheck.ToolbarButton = _detalhes.ToolBar:NewPluginToolbarButton (DetailsRaidCheck.empty_function, [[Interface\Buttons\UI-CheckBox-Check]], Loc ["STRING_RAIDCHECK_PLUGIN_NAME"], "", 16, 16, "RAIDCHECK_PLUGIN_BUTTON") - DetailsRaidCheck.ToolbarButton.shadow = true --> loads icon_shadow.tga when the instance is showing icons with shadows - - function DetailsRaidCheck.GetPlayerAmount() - local playerAmount = GetNumGroupMembers() - - --limit to 20 if in mythic raid and the option is enabled - local _, _, difficulty = GetInstanceInfo() - if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and playerAmount > 20) then - playerAmount = 20 - end - - return playerAmount - end - - function DetailsRaidCheck:SetGreenIcon() - local lower_instance = _detalhes:GetLowerInstanceNumber() - if (not lower_instance) then - return - end - local instance = _detalhes:GetInstance (lower_instance) - - if (instance.menu_icons.shadow) then - DetailsRaidCheck.ToolbarButton:SetNormalTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetPushedTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetDisabledTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetHighlightTexture ([[Interface\Buttons\UI-CheckBox-Check]], "ADD") - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(.2, 1, .2) - else - DetailsRaidCheck.ToolbarButton:SetNormalTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetPushedTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetDisabledTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetHighlightTexture ([[Interface\Buttons\UI-CheckBox-Check]], "ADD") - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(.2, 1, .2) - DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(.2, 1, .2) + else + for spellId, tier in pairs(LIB_OPEN_RAID_FOOD_BUFF) do + if (tier == 1) then + foodList.tier1[spellId] = true + + elseif (tier == 2) then + foodList.tier2[spellId] = true + + elseif (tier == 3) then + foodList.tier3[spellId] = true end end - - function DetailsRaidCheck:SetRedIcon() - local lower_instance = _detalhes:GetLowerInstanceNumber() - if (not lower_instance) then - return - end - local instance = _detalhes:GetInstance (lower_instance) - - if (instance.menu_icons.shadow) then - DetailsRaidCheck.ToolbarButton:SetNormalTexture ([[Interface\Buttons\UI-CheckBox-Check]]) --RED - DetailsRaidCheck.ToolbarButton:SetPushedTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetDisabledTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetHighlightTexture ([[Interface\Buttons\UI-CheckBox-Check]], "ADD") - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(1, .6, .1) - else - DetailsRaidCheck.ToolbarButton:SetNormalTexture ([[Interface\Buttons\UI-CheckBox-Check]]) --RED - DetailsRaidCheck.ToolbarButton:SetPushedTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetDisabledTexture ([[Interface\Buttons\UI-CheckBox-Check]]) - DetailsRaidCheck.ToolbarButton:SetHighlightTexture ([[Interface\Buttons\UI-CheckBox-Check]], "ADD") - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(1, .6, .1) - DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(1, .6, .1) - end + end + + DetailsRaidCheck.GetOnlyName = DetailsRaidCheck.GetOnlyName + + --tables + DetailsRaidCheck.usedprepot_table = {} + DetailsRaidCheck.focusaug_table = {} + DetailsRaidCheck.unitsWithFlaskTable = {} + DetailsRaidCheck.unitWithFoodTable = {} + DetailsRaidCheck.iseating_table = {} + DetailsRaidCheck.havefocusaug_table = {} + + DetailsRaidCheck.on_raid = false + local PlayerData = {} + local UpdateSpeed = 0.5 + + function DetailsRaidCheck:OnDetailsEvent(event, ...) + if (event == "ZONE_TYPE_CHANGED") then + DetailsRaidCheck:CheckCanShowIcon (...) + + elseif (event == "COMBAT_PREPOTION_UPDATED") then + DetailsRaidCheck.usedprepot_table, DetailsRaidCheck.focusaug_table = select(1, ...) + + elseif (event == "COMBAT_PLAYER_LEAVE") then + + elseif (event == "COMBAT_PLAYER_ENTER") then + + elseif (event == "DETAILS_STARTED") then + localizedFoodDrink = GetSpellInfo(isDrinking) + DetailsRaidCheck:CheckCanShowIcon() + + elseif (event == "PLUGIN_DISABLED") then + DetailsRaidCheck.on_raid = false + DetailsRaidCheck:HideToolbarIcon(DetailsRaidCheck.ToolbarButton) + + elseif (event == "PLUGIN_ENABLED") then + DetailsRaidCheck:CheckCanShowIcon() end + end - local show_panel = CreateFrame ("frame", nil, UIParent, "BackdropTemplate") - show_panel:SetPoint ("bottom", DetailsRaidCheck.ToolbarButton, "top", 0, 10) - show_panel:SetClampedToScreen (true) - show_panel:SetFrameStrata ("TOOLTIP") - - -- - - --copying style from the all displays menu - show_panel:SetBackdrop ({bgFile = "Interface\\AddOns\\Details\\images\\background", tile = true, tileSize = 16 }) - show_panel:SetBackdropColor (0.05, 0.05, 0.05, 0.3) - show_panel.background = show_panel:CreateTexture ("DetailsAllAttributesFrameBackground111", "background") - show_panel.background:SetDrawLayer ("background", 2) - show_panel.background:SetPoint ("topleft", show_panel, "topleft", 4, -4) - show_panel.background:SetPoint ("bottomright", show_panel, "bottomright", -4, 4) - show_panel.wallpaper = show_panel:CreateTexture ("DetailsAllAttributesFrameWallPaper111", "background") - show_panel.wallpaper:SetDrawLayer ("background", 4) - show_panel.wallpaper:SetPoint ("topleft", show_panel, "topleft", 4, -4) - show_panel.wallpaper:SetPoint ("bottomright", show_panel, "bottomright", -4, 4) + DetailsRaidCheck.ToolbarButton = Details.ToolBar:NewPluginToolbarButton(DetailsRaidCheck.empty_function, [[Interface\Buttons\UI-CheckBox-Check]], Loc ["STRING_RAIDCHECK_PLUGIN_NAME"], "", 16, 16, "RAIDCHECK_PLUGIN_BUTTON") + DetailsRaidCheck.ToolbarButton.shadow = true - show_panel:SetBackdrop (_detalhes.menu_backdrop_config.menus_backdrop) - show_panel:SetBackdropColor (unpack (_detalhes.menu_backdrop_config.menus_backdropcolor)) - show_panel:SetBackdropBorderColor (unpack (_detalhes.menu_backdrop_config.menus_bordercolor)) - - -- - - local report_string1 = show_panel:CreateFontString (nil, "overlay", "GameFontNormal") - report_string1:SetPoint ("bottomleft", show_panel, "bottomleft", 10, 8) - report_string1:SetText ("|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:225:307|t Report No Food/Flask |TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:328:409|t Report No Pre-Pot |TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:126:204|t Report No Rune | |cFFFFFFFFShift+Click: Options|r") + function DetailsRaidCheck.GetPlayerAmount() + local playerAmount = GetNumGroupMembers() + --limit to 20 if in mythic raid and the option is enabled + local _, _, difficulty = GetInstanceInfo() + if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and playerAmount > 20) then + playerAmount = 20 + end + return playerAmount + end - --local using_details_string1 = show_panel:CreateFontString (nil, "overlay", "GameFontNormal") - --using_details_string1:SetPoint ("bottomleft", show_panel, "bottomleft", 10, 22) - --using_details_string1:SetText ("Receives dynamic updates from other Details! users when they change talents and gear") - - DetailsRaidCheck:SetFontSize (report_string1, 10) - DetailsRaidCheck:SetFontColor (report_string1, "white") - report_string1:SetAlpha (0.6) - - --DetailsRaidCheck:SetFontSize (using_details_string1, 10) - --DetailsRaidCheck:SetFontColor (using_details_string1, "white") - --using_details_string1:SetAlpha (0.6) - - -- - - --header and scroll - local headerTable = { - {text = "Player Name", width = 140}, - {text = "Talents", width = 130}, - {text = "ILevel", width = 45}, - {text = "Repair", width = 45}, - {text = "Food", width = 45}, - {text = "Flask", width = 45}, - {text = "Rune", width = 45}, - --{text = "Pre-Pot Last Try", width = 100}, - --{text = "Using Details!", width = 100}, + function DetailsRaidCheck:SetGreenIcon() + local lowerInstanceId = Details:GetLowerInstanceNumber() + if (not lowerInstanceId) then + return + end + local instance = Details:GetInstance(lowerInstanceId) + + if (instance.menu_icons.shadow) then + DetailsRaidCheck.ToolbarButton:SetNormalTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetPushedTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetDisabledTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetHighlightTexture([[Interface\Buttons\UI-CheckBox-Check]], "ADD") + DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(.2, 1, .2) + else + DetailsRaidCheck.ToolbarButton:SetNormalTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetPushedTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetDisabledTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetHighlightTexture([[Interface\Buttons\UI-CheckBox-Check]], "ADD") + DetailsRaidCheck.ToolbarButton:GetNormalTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetHighlightTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetDisabledTexture():SetVertexColor(.2, 1, .2) + DetailsRaidCheck.ToolbarButton:GetPushedTexture():SetVertexColor(.2, 1, .2) + end + end + + function DetailsRaidCheck:SetRedIcon() + local lowerInstanceId = Details:GetLowerInstanceNumber() + if (not lowerInstanceId) then + return + end + local instance = Details:GetInstance(lowerInstanceId) + + if (instance.menu_icons.shadow) then + DetailsRaidCheck.ToolbarButton:SetNormalTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetPushedTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetDisabledTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetHighlightTexture([[Interface\Buttons\UI-CheckBox-Check]], "ADD") + else + DetailsRaidCheck.ToolbarButton:SetNormalTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetPushedTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetDisabledTexture([[Interface\Buttons\UI-CheckBox-Check]]) + DetailsRaidCheck.ToolbarButton:SetHighlightTexture([[Interface\Buttons\UI-CheckBox-Check]], "ADD") + end + end + + local raidCheckFrame = CreateFrame("frame", nil, UIParent, "BackdropTemplate") + raidCheckFrame:SetPoint("bottom", DetailsRaidCheck.ToolbarButton, "top", 0, 10) + raidCheckFrame:SetClampedToScreen(true) + raidCheckFrame:SetFrameStrata("TOOLTIP") + + raidCheckFrame.background = raidCheckFrame:CreateTexture("DetailsAllAttributesFrameBackground111", "background") + raidCheckFrame.background:SetDrawLayer("background", 2) + raidCheckFrame.background:SetPoint("topleft", raidCheckFrame, "topleft", 4, -4) + raidCheckFrame.background:SetPoint("bottomright", raidCheckFrame, "bottomright", -4, 4) + + raidCheckFrame.wallpaper = raidCheckFrame:CreateTexture("DetailsAllAttributesFrameWallPaper111", "background") + raidCheckFrame.wallpaper:SetDrawLayer("background", 4) + raidCheckFrame.wallpaper:SetPoint("topleft", raidCheckFrame, "topleft", 4, -4) + raidCheckFrame.wallpaper:SetPoint("bottomright", raidCheckFrame, "bottomright", -4, 4) + + raidCheckFrame:SetBackdrop(Details.menu_backdrop_config.menus_backdrop) + raidCheckFrame:SetBackdropColor(unpack(Details.menu_backdrop_config.menus_backdropcolor)) + raidCheckFrame:SetBackdropBorderColor(unpack(Details.menu_backdrop_config.menus_bordercolor)) + + local reportString1 = raidCheckFrame:CreateFontString(nil, "overlay", "GameFontNormal") + reportString1:SetPoint("bottomleft", raidCheckFrame, "bottomleft", 10, 8) + reportString1:SetText("|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:225:307|t Report No Food/Flask |TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:328:409|t Report No Pre-Pot |TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:12:12:0:1:512:512:8:70:126:204|t Report No Rune | |cFFFFFFFFShift+Click: Options|r") + + DetailsRaidCheck:SetFontSize(reportString1, 10) + DetailsRaidCheck:SetFontColor(reportString1, "white") + reportString1:SetAlpha(0.6) + + --header and scroll + local headerTable = { + {text = "Player Name", width = 140}, + {text = "Talents", width = 130}, + {text = "ILevel", width = 45}, + {text = "Repair", width = 45}, + {text = "Food", width = 45}, + {text = "Flask", width = 45}, + {text = "Rune", width = 45}, + --{text = "Pre-Pot Last Try", width = 100}, + --{text = "Using Details!", width = 100}, + } + local headerOptions = { + padding = 2, + } + + DetailsRaidCheck.Header = DF:CreateHeader(raidCheckFrame, headerTable, headerOptions) + DetailsRaidCheck.Header:SetPoint("topleft", raidCheckFrame, "topleft", 10, -10) + + --options + local scrollWidth = 722 + local scrollLinesAmount = 30 + local scrollLineHeight = 16 + local scroll_height = (scrollLinesAmount * scrollLineHeight) + scrollLinesAmount + 2 + local backdrop_color = {.2, .2, .2, 0.2} + local backdrop_color_on_enter = {.8, .8, .8, 0.4} + local y = -10 + local headerY = y - 2 + local scrollY = headerY - 20 + + raidCheckFrame:SetSize(722 + 20, 565) + + function raidCheckFrame:AdjustHeight(height) + raidCheckFrame:SetHeight(height or 565) + end + + --create line for the scroll + local scrollCreateLine = function(self, index) + local line = CreateFrame("button", "$parentLine" .. index, self, "BackdropTemplate") + line:SetPoint("topleft", self, "topleft", 1, -((index-1) * (scrollLineHeight + 1)) - 1) + line:SetSize(scrollWidth - 2, scrollLineHeight) + + line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) + line:SetBackdropColor(unpack(backdrop_color)) + + DF:Mixin(line, DetailsFramework.HeaderFunctions) + + --role icon + local roleIcon = DF:CreateImage(line, nil, scrollLineHeight, scrollLineHeight) + + --spec icon + local specIcon = DF:CreateImage(line, nil, scrollLineHeight, scrollLineHeight) + specIcon:SetPoint("left", roleIcon, "right", 2, 0) + + --covenant icon + local covenantIcon = DF:CreateImage(line, nil, scrollLineHeight, scrollLineHeight) + covenantIcon:SetPoint("left", specIcon, "right", 2, 0) + + --player name + local playerName = DF:CreateLabel(line) + playerName:SetPoint("left", covenantIcon, "right", 2, 0) + + --talents + local talentRowOptions = { + icon_width = 16, + icon_height = 16, + texcoord = {.1, .9, .1, .9}, + show_text = false, + icon_padding = 2, } - local headerOptions = { - padding = 2, - } - - DetailsRaidCheck.Header = DF:CreateHeader (show_panel, headerTable, headerOptions) - DetailsRaidCheck.Header:SetPoint ("topleft", show_panel, "topleft", 10, -10) - - --options - local scroll_width = 722 - local scroll_lines = 30 - local scroll_line_height = 16 - local scroll_height = (scroll_lines * scroll_line_height) + scroll_lines + 2 - local backdrop_color = {.2, .2, .2, 0.2} - local backdrop_color_on_enter = {.8, .8, .8, 0.4} - local y = -10 - local headerY = y - 2 - local scrollY = headerY - 20 - - show_panel:SetSize (722 + 20, 565) + local talentsRow = DF:CreateIconRow(line, "$parentTalentIconsRow", talentRowOptions) - function show_panel:AdjustHeight(height) - show_panel:SetHeight (height or 565) + --item level + local itemLevel = DF:CreateLabel(line) + + --repair status + local repairStatus = DF:CreateLabel(line) + + --no food + local foodIndicator = DF:CreateImage(line, "", scrollLineHeight, scrollLineHeight) + local foodTierIndicator = DF:CreateLabel(line, "", 12, "white") + foodTierIndicator:SetPoint("left", foodIndicator, "right", 6, 0) + + --no flask + local flaskIndicator = DF:CreateImage(line, "", scrollLineHeight, scrollLineHeight) + local flaskTierIndicator = DF:CreateLabel(line, "", 12, "white") + flaskTierIndicator:SetPoint("left", flaskIndicator, "right", 6, 0) + + --no rune + local runeIndicator = DF:CreateImage(line, "", scrollLineHeight, scrollLineHeight) + + --no pre pot + --local PrePotIndicator = DF:CreateImage (line, "", scroll_line_height, scroll_line_height) + --using details! + --local DetailsIndicator = DF:CreateImage(line, "", scroll_line_height, scroll_line_height) + + line:AddFrameToHeaderAlignment(roleIcon) + line:AddFrameToHeaderAlignment(talentsRow) + line:AddFrameToHeaderAlignment(itemLevel) + line:AddFrameToHeaderAlignment(repairStatus) + line:AddFrameToHeaderAlignment(foodIndicator) + line:AddFrameToHeaderAlignment(flaskIndicator) + line:AddFrameToHeaderAlignment(runeIndicator) + --line:AddFrameToHeaderAlignment(PrePotIndicator) + --line:AddFrameToHeaderAlignment(DetailsIndicator) + + line:AlignWithHeader(DetailsRaidCheck.Header, "left") + + line.CovenantIcon = covenantIcon + line.RoleIcon = roleIcon + line.SpecIcon = specIcon + line.PlayerName = playerName + line.TalentsRow = talentsRow + line.ItemLevel = itemLevel + line.RepairStatus = repairStatus + line.FoodIndicator = foodIndicator + line.FoodTierIndicator = foodTierIndicator + line.FlaskIndicator = flaskIndicator + line.FlaskTierIndicator = flaskTierIndicator + line.RuneIndicator = runeIndicator + --line.PrePotIndicator = PrePotIndicator + --line.DetailsIndicator = DetailsIndicator + + return line + end + + --refresh scroll + local has_food_icon = {texture = [[Interface\Scenarios\ScenarioIcon-Check]], coords = {0, 1, 0, 1}} + local eating_food_icon = {texture = [[Interface\AddOns\Details\images\icons]], coords = {225/512, 249/512, 35/512, 63/512}} + + local scrollRefreshLines = function(self, data, offset, totalLines) + local dataInOrder = {} + + for i = 1, #data do + dataInOrder[#dataInOrder+1] = data [i] end - - --create line for the scroll - local scroll_createline = function (self, index) - - local line = CreateFrame ("button", "$parentLine" .. index, self, "BackdropTemplate") - line:SetPoint ("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1)) - 1) - line:SetSize (scroll_width - 2, scroll_line_height) - line:SetScript ("OnEnter", line_onenter) - line:SetScript ("OnLeave", line_onleave) - - line:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) - line:SetBackdropColor (unpack (backdrop_color)) - - DF:Mixin (line, DetailsFramework.HeaderFunctions) - - --role icon - local roleIcon = DF:CreateImage (line, nil, scroll_line_height, scroll_line_height) - - --spec icon - local specIcon = DF:CreateImage (line, nil, scroll_line_height, scroll_line_height) - specIcon:SetPoint ("left", roleIcon, "right", 2, 0) - --covenant icon - local covenantIcon = DF:CreateImage (line, nil, scroll_line_height, scroll_line_height) - covenantIcon:SetPoint ("left", specIcon, "right", 2, 0) - - --player name - local playerName = DF:CreateLabel (line) - playerName:SetPoint ("left", covenantIcon, "right", 2, 0) - - --talents - local talent_row_options = { - icon_width = 16, - icon_height = 16, - texcoord = {.1, .9, .1, .9}, - show_text = false, - icon_padding = 2, - } - local talentsRow = DF:CreateIconRow (line, "$parentTalentIconsRow", talent_row_options) - - --item level - local itemLevel = DF:CreateLabel(line) - --repair status - local repairStatus = DF:CreateLabel(line) - --no food - local FoodIndicator = DF:CreateImage(line, "", scroll_line_height, scroll_line_height) - --no flask - local FlaskIndicator = DF:CreateImage(line, "", scroll_line_height, scroll_line_height) - --no rune - local RuneIndicator = DF:CreateImage(line, "", scroll_line_height, scroll_line_height) - --no pre pot - --local PrePotIndicator = DF:CreateImage (line, "", scroll_line_height, scroll_line_height) - --using details! - --local DetailsIndicator = DF:CreateImage(line, "", scroll_line_height, scroll_line_height) - - line:AddFrameToHeaderAlignment(roleIcon) - line:AddFrameToHeaderAlignment(talentsRow) - line:AddFrameToHeaderAlignment(itemLevel) - line:AddFrameToHeaderAlignment(repairStatus) - line:AddFrameToHeaderAlignment(FoodIndicator) - line:AddFrameToHeaderAlignment(FlaskIndicator) - line:AddFrameToHeaderAlignment(RuneIndicator) - --line:AddFrameToHeaderAlignment(PrePotIndicator) - --line:AddFrameToHeaderAlignment(DetailsIndicator) - - line:AlignWithHeader (DetailsRaidCheck.Header, "left") - - line.CovenantIcon = covenantIcon - line.RoleIcon = roleIcon - line.SpecIcon = specIcon - line.PlayerName = playerName - line.TalentsRow = talentsRow - line.ItemLevel = itemLevel - line.RepairStatus = repairStatus - line.FoodIndicator = FoodIndicator - line.FlaskIndicator = FlaskIndicator - line.RuneIndicator = RuneIndicator - --line.PrePotIndicator = PrePotIndicator - --line.DetailsIndicator = DetailsIndicator - - return line - end - - --refresh scroll - local has_food_icon = {texture = [[Interface\Scenarios\ScenarioIcon-Check]], coords = {0, 1, 0, 1}} - local eating_food_icon = {texture = [[Interface\AddOns\Details\images\icons]], coords = {225/512, 249/512, 35/512, 63/512}} - - local scroll_refresh = function (self, data, offset, total_lines) - - local dataInOrder = {} + table.sort(dataInOrder, DF.SortOrder2) + --table.sort (dataInOrder, DF.SortOrder1R) --alphabetical + data = dataInOrder - for i = 1, #data do - dataInOrder [#dataInOrder+1] = data [i] - end + --get the information of all players + local playersInfoData = openRaidLib.GetAllUnitsInfo() + local playersGearData = openRaidLib.GetAllUnitsGear() - table.sort (dataInOrder, DF.SortOrder2) - --table.sort (dataInOrder, DF.SortOrder1R) --alphabetical - data = dataInOrder + for i = 1, totalLines do + local index = i + offset + local playerTable = data[index] - local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0") - --get the information of all players - local playersInfoData = openRaidLib.GetAllUnitsInfo() - local playersGearData = openRaidLib.GetAllUnitsGear() - - for i = 1, total_lines do - local index = i + offset - local playerTable = data [index] - - if (playerTable) then - local line = self:GetLine (i) - if (line) then - - local thisPlayerInfo = playersInfoData[playerTable.UnitNameRealm] - if (thisPlayerInfo) then + if (playerTable) then + local line = self:GetLine(i) + if (line) then + local thisPlayerInfo = playersInfoData[playerTable.UnitNameRealm] + if (thisPlayerInfo) then + if (DF.IsShadowlandsWow()) then local playerCovenantId = thisPlayerInfo.covenantId if (playerCovenantId > 0) then line.CovenantIcon:SetTexture(LIB_OPEN_RAID_COVENANT_ICONS[playerCovenantId]) @@ -410,474 +368,503 @@ end else line.CovenantIcon:SetTexture("") end - - --repair status - local thisPlayerGearInfo = playersGearData[playerTable.UnitNameRealm] - if (thisPlayerGearInfo) then - line.RepairStatus:SetText(thisPlayerGearInfo.durability .. "%") - else - line.RepairStatus:SetText("") - end - - local roleTexture, L, R, T, B = _detalhes:GetRoleIcon(playerTable.Role or "NONE") - - line.RoleIcon:SetTexture(roleTexture) - line.RoleIcon:SetTexCoord(L, R, T, B) - - if (playerTable.Spec) then - local texture, L, R, T, B = _detalhes:GetSpecIcon(playerTable.Spec) - line.SpecIcon:SetTexture(texture) - line.SpecIcon:SetTexCoord(L, R, T, B) - else - local texture, L, R, T, B = _detalhes:GetClassIcon(playerTable.Class) - line.SpecIcon:SetTexture (texture) - line.SpecIcon:SetTexCoord (L, R, T, B) - end - - line.TalentsRow:ClearIcons() - - if (playerTable.Talents) then - for i = 1, #playerTable.Talents do - local talent = playerTable.Talents [i] - local talentID, name, texture, selected, available = GetTalentInfoByID(talent) - line.TalentsRow:SetIcon(false, false, false, false, texture) - end - end - - local classColor = Details.class_colors [playerTable.Class] - if (classColor) then - line:SetBackdropColor (unpack (classColor)) - else - line:SetBackdropColor (unpack (backdrop_color)) - end - - line.PlayerName.text = playerTable.Name - line.ItemLevel.text = floor (playerTable.ILevel and playerTable.ILevel.ilvl or 0) - - if (playerTable.Food) then - line.FoodIndicator.texture = has_food_icon.texture - line.FoodIndicator.texcoord = has_food_icon.coords - - elseif (playerTable.Eating) then - line.FoodIndicator.texture = eating_food_icon.texture - line.FoodIndicator.texcoord = eating_food_icon.coords - - else - line.FoodIndicator.texture = "" - end - - line.FlaskIndicator.texture = playerTable.Flask and [[Interface\Scenarios\ScenarioIcon-Check]] or "" - line.RuneIndicator.texture = playerTable.Rune and [[Interface\Scenarios\ScenarioIcon-Check]] or "" - --line.PrePotIndicator.texture = playerTable.PrePot and [[Interface\Scenarios\ScenarioIcon-Check]] or "" - --line.DetailsIndicator.texture = playerTable.UseDetails and [[Interface\Scenarios\ScenarioIcon-Check]] or "" - end - end - end - - end - - --create scroll - local mainScroll = DF:CreateScrollBox (show_panel, "$parentMainScroll", scroll_refresh, PlayerData, 1, 1, scroll_lines, scroll_line_height) - DF:ReskinSlider (mainScroll) - mainScroll.HideScrollBar = true - mainScroll:SetPoint ("topleft", show_panel, "topleft", 10, scrollY) - mainScroll:SetPoint ("bottomright", show_panel, "bottomright", -10, 20) - mainScroll:Refresh() - - --create lines - for i = 1, scroll_lines do - mainScroll:CreateLine (scroll_createline) - end - - show_panel:Hide() - - DetailsRaidCheck.report_lines = "" - local reportFunc = function (IsCurrent, IsReverse, AmtLines) - DetailsRaidCheck:SendReportLines (DetailsRaidCheck.report_lines) - end - - --> overwrite the default scripts - DetailsRaidCheck.ToolbarButton:RegisterForClicks ("AnyUp") - DetailsRaidCheck.ToolbarButton:SetScript ("OnClick", function (self, button) - - if (IsShiftKeyDown()) then - DetailsRaidCheck.OpenOptionsPanel() - return - end - - if (button == "LeftButton") then - --> link no food/flask - local s, added = "Details!: No Flask or Food: ", {} - - local amt = GetNumGroupMembers() - local _, _, difficulty = GetInstanceInfo() - if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and amt > 20) then - amt = 20 - end - - for i = 1, amt, 1 do - local unitID = get_unit_id (i) - - local name = UnitName (unitID) - local unitSerial = UnitGUID (unitID) - - if (not DetailsRaidCheck.havefood_table [unitSerial]) then - added [unitSerial] = true - s = s .. DetailsRaidCheck:GetOnlyName (name) .. " " - end - - if (not DetailsRaidCheck.haveflask_table [unitSerial] and not added [unitSerial]) then - s = s .. DetailsRaidCheck:GetOnlyName (name) .. " " - end - end - - if (DetailsRaidCheck.db.use_report_panel) then - DetailsRaidCheck.report_lines = s - DetailsRaidCheck:SendReportWindow (reportFunc) - else - if (IsInRaid()) then - DetailsRaidCheck:SendMsgToChannel (s, "RAID") else - DetailsRaidCheck:SendMsgToChannel (s, "PARTY") + line.CovenantIcon:SetTexture("") end - end - - elseif (button == "RightButton") then - --> link no pre-pot latest segment - - local s = "Details!: No Pre-Pot Last Try: " - - local amt = GetNumGroupMembers() - local _, _, difficulty = GetInstanceInfo() - if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and amt > 20) then - amt = 20 - end - - for i = 1, amt, 1 do - - local unitID = get_unit_id (i) - local role = UnitGroupRolesAssigned (unitID) - - if (role == "DAMAGER" or (role == "HEALER" and DetailsRaidCheck.db.pre_pot_healers) or (role == "TANK" and DetailsRaidCheck.db.pre_pot_tanks)) then - - local playerName, realmName = UnitName (unitID) - if (realmName and realmName ~= "") then - playerName = playerName .. "-" .. realmName - end - - if (not DetailsRaidCheck.usedprepot_table [playerName]) then - s = s .. DetailsRaidCheck:GetOnlyName (playerName) .. " " - end - - end - end - - if (DetailsRaidCheck.db.use_report_panel) then - DetailsRaidCheck.report_lines = s - DetailsRaidCheck:SendReportWindow (reportFunc) - else - if (IsInRaid()) then - DetailsRaidCheck:SendMsgToChannel (s, "RAID") + + --repair status + local thisPlayerGearInfo = playersGearData[playerTable.UnitNameRealm] + if (thisPlayerGearInfo) then + line.RepairStatus:SetText(thisPlayerGearInfo.durability .. "%") else - DetailsRaidCheck:SendMsgToChannel (s, "PARTY") + line.RepairStatus:SetText("") end - end - - elseif (button == "MiddleButton") then - --report focus aug - local s = "Details!: Not using Rune: " - - local amt = GetNumGroupMembers() - local _, _, difficulty = GetInstanceInfo() - if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and amt > 20) then - amt = 20 - end - - for i = 1, amt do - local unitID = get_unit_id (i) - - local name = UnitName (unitID) - local unitSerial = UnitGUID (unitID) - - if (not DetailsRaidCheck.havefocusaug_table [unitSerial]) then - s = s .. DetailsRaidCheck:GetOnlyName (name) .. " " - end - end - - if (DetailsRaidCheck.db.use_report_panel) then - DetailsRaidCheck.report_lines = s - DetailsRaidCheck:SendReportWindow (reportFunc) - else - if (IsInRaid()) then - DetailsRaidCheck:SendMsgToChannel (s, "RAID") + + local roleTexture, L, R, T, B = Details:GetRoleIcon(playerTable.Role or "NONE") + line.RoleIcon:SetTexture(roleTexture) + line.RoleIcon:SetTexCoord(L, R, T, B) + + if (playerTable.Spec) then + local texture, L, R, T, B = Details:GetSpecIcon(playerTable.Spec) + line.SpecIcon:SetTexture(texture) + line.SpecIcon:SetTexCoord(L, R, T, B) else - DetailsRaidCheck:SendMsgToChannel (s, "PARTY") + local texture, L, R, T, B = Details:GetClassIcon(playerTable.Class) + line.SpecIcon:SetTexture(texture) + line.SpecIcon:SetTexCoord(L, R, T, B) end - end - - end - - end) - local update_panel = function (self, elapsed) - - show_panel.NextUpdate = show_panel.NextUpdate - elapsed - - if (show_panel.NextUpdate > 0) then - return - end + line.TalentsRow:ClearIcons() - show_panel.NextUpdate = UpdateSpeed - - if (not IsInRaid() and not IsInGroup()) then - return - end - - wipe (PlayerData) - - local groupTypeID = IsInRaid() and "raid" or "party" - - local playerAmount = DetailsRaidCheck.GetPlayerAmount() - local iterateAmount = playerAmount - if (not IsInRaid()) then - iterateAmount = iterateAmount - 1 - end - - for i = 1, iterateAmount do - local unitID = groupTypeID .. i - local unitName = UnitName (unitID) - local unitNameWithRealm = GetUnitName(unitID, true) - local cleuName = _detalhes:GetCLName (unitID) - local unitSerial = UnitGUID (unitID) - local _, unitClass, unitClassID = UnitClass (unitID) - local unitRole = UnitGroupRolesAssigned (unitID) - local unitSpec = _detalhes:GetSpecFromSerial (unitSerial) or _detalhes:GetSpec (cleuName) - local itemLevelTable = _detalhes.ilevel:GetIlvl (unitSerial) - local talentsTable = _detalhes:GetTalents (unitSerial) - - --> order by class > alphabetically by the unit name - unitClassID = (((unitClassID or 0) + 128) ^ 4) + tonumber (string.byte (unitName, 1) .. "" .. string.byte (unitName, 2)) - - tinsert (PlayerData, {unitName, unitClassID, - Name = unitName, - UnitNameRealm = unitNameWithRealm, - Class = unitClass, - Serial = unitSerial, - Role = unitRole, - Spec = unitSpec, - ILevel = itemLevelTable, - Talents = talentsTable, - Food = DetailsRaidCheck.havefood_table [unitSerial], - Flask = DetailsRaidCheck.haveflask_table [unitSerial], - PrePot = DetailsRaidCheck.usedprepot_table [cleuName], - Rune = DetailsRaidCheck.havefocusaug_table [unitSerial], - Eating = DetailsRaidCheck.iseating_table [unitSerial], - UseDetails = Details.trusted_characters [unitSerial], - }) - end - - if (not IsInRaid()) then - --> add the player data - local unitID = "player" - - local unitName = UnitName (unitID) - local cleuName = _detalhes:GetCLName (unitID) - local unitSerial = UnitGUID (unitID) - local _, unitClass, unitClassID = UnitClass (unitID) - local unitRole = UnitGroupRolesAssigned (unitID) - local unitSpec = _detalhes:GetSpecFromSerial (unitSerial) or _detalhes:GetSpec (cleuName) - local itemLevelTable = _detalhes.ilevel:GetIlvl (unitSerial) - local talentsTable = _detalhes:GetTalents (unitSerial) - - unitClassID = ((unitClassID + 128) ^ 4) + tonumber (string.byte (unitName, 1) .. "" .. string.byte (unitName, 2)) - local unitNameWithRealm = GetUnitName(unitID, true) - - tinsert (PlayerData, {unitName, unitClassID, - Name = unitName, - UnitNameRealm = unitNameWithRealm, - Class = unitClass, - Serial = unitSerial, - Role = unitRole, - Spec = unitSpec, - ILevel = itemLevelTable, - Talents = talentsTable, - Food = DetailsRaidCheck.havefood_table [unitSerial], - Flask = DetailsRaidCheck.haveflask_table [unitSerial], - PrePot = DetailsRaidCheck.usedprepot_table [cleuName], - Rune = DetailsRaidCheck.havefocusaug_table [unitSerial], - Eating = DetailsRaidCheck.iseating_table [unitSerial], - UseDetails = Details.trusted_characters [unitSerial], - }) - end - - mainScroll:Refresh() - - local height = (playerAmount * scroll_line_height) + 75 - show_panel:AdjustHeight(height) - - end - - DetailsRaidCheck.ToolbarButton:SetScript ("OnEnter", function (self) - show_panel:Show() - show_panel:ClearAllPoints() - - local bottomPosition = self:GetBottom() - local screenHeight = GetScreenHeight() - - local positionHeightPercent = bottomPosition / screenHeight - - if (positionHeightPercent > 0.7) then - show_panel:SetPoint("top", DetailsRaidCheck.ToolbarButton, "bottom", 0, -10) - else - show_panel:SetPoint("bottom", DetailsRaidCheck.ToolbarButton, "top", 0, 10) - end - - show_panel.NextUpdate = UpdateSpeed - update_panel (show_panel, 1) - show_panel:SetScript ("OnUpdate", update_panel) - DetailsRaidCheck:StartTrackBuffs() - end) - - DetailsRaidCheck.ToolbarButton:SetScript ("OnLeave", function (self) - show_panel:SetScript ("OnUpdate", nil) - show_panel:Hide() - DetailsRaidCheck:StopTrackBuffs() - DetailsRaidCheck:StartTrackBuffs(5.0) - end) - - function DetailsRaidCheck:CheckCanShowIcon(...) - local isInRaid = IsInRaid() - local isInGroup = IsInGroup() - - if (isInRaid or isInGroup) then - DetailsRaidCheck:ShowToolbarIcon (DetailsRaidCheck.ToolbarButton, "star") - DetailsRaidCheck.on_raid = true - DetailsRaidCheck:StartTrackBuffs(5.0) - else - DetailsRaidCheck:HideToolbarIcon (DetailsRaidCheck.ToolbarButton) - DetailsRaidCheck.on_raid = false - if (DetailsRaidCheck.UpdateBuffsTick and not DetailsRaidCheck.UpdateBuffsTick._cancelled) then - DetailsRaidCheck.UpdateBuffsTick:Cancel() - end - end - end - - function DetailsRaidCheck:CheckUnitBuffs (unitID, consumableTable) - local name = UnitName (unitID) - local unitSerial = UnitGUID (unitID) - - for buffIndex = 1, 40 do - local bname, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellid = UnitBuff (unitID, buffIndex) - - if (bname) then - if (flask_list [spellid]) then - DetailsRaidCheck.haveflask_table [unitSerial] = spellid - consumableTable.Flask = consumableTable.Flask + 1 - end - - if (DetailsRaidCheck.db.food_tier1) then - if (food_list.tier1 [spellid]) then - DetailsRaidCheck.havefood_table [unitSerial] = 1 - consumableTable.Food = consumableTable.Food + 1 + if (playerTable.Talents) then + for i = 1, #playerTable.Talents do + local talent = playerTable.Talents [i] + local talentID, name, texture, selected, available = GetTalentInfoByID(talent) + line.TalentsRow:SetIcon(false, false, false, false, texture) end end - - if (DetailsRaidCheck.db.food_tier2) then - if (food_list.tier2 [spellid]) then - DetailsRaidCheck.havefood_table [unitSerial] = 2 - consumableTable.Food = consumableTable.Food + 1 - end + + local classColor = Details.class_colors[playerTable.Class] + if (classColor) then + line:SetBackdropColor(unpack(classColor)) + else + line:SetBackdropColor(unpack(backdrop_color)) end - - if (DetailsRaidCheck.db.food_tier3) then - if (food_list.tier3 [spellid]) then - DetailsRaidCheck.havefood_table [unitSerial] = 3 - consumableTable.Food = consumableTable.Food + 1 - end + + line.PlayerName.text = playerTable.Name + line.ItemLevel.text = floor(playerTable.ILevel and playerTable.ILevel.ilvl or 0) + + local foodInfo = playerTable.Food + if (foodInfo) then + line.FoodIndicator.texture = foodInfo[3] + line.FoodTierIndicator.text = foodInfo[2] + --line.FoodIndicator.texcoord = has_food_icon.coords + line.FoodIndicator.texcoord = {0, 1, 0, 1} + + elseif (playerTable.Eating) then + line.FoodIndicator.texture = eating_food_icon.texture + line.FoodIndicator.texcoord = eating_food_icon.coords + + else + line.FoodIndicator.texture = "" end - - if (runes_id [spellid]) then - DetailsRaidCheck.havefocusaug_table [unitSerial] = spellid + + local flaskInfo = playerTable.Flask + if (flaskInfo) then + line.FlaskIndicator.texture = flaskInfo[3] + line.FlaskTierIndicator.text = flaskInfo[2] + else + line.FlaskIndicator.texture = "" + line.FlaskTierIndicator.text = "" end - - if (bname == localizedFoodDrink) then - DetailsRaidCheck.iseating_table [unitSerial] = true - end - else - break + + line.RuneIndicator.texture = playerTable.Rune and [[Interface\Scenarios\ScenarioIcon-Check]] or "" + --line.PrePotIndicator.texture = playerTable.PrePot and [[Interface\Scenarios\ScenarioIcon-Check]] or "" + --line.DetailsIndicator.texture = playerTable.UseDetails and [[Interface\Scenarios\ScenarioIcon-Check]] or "" end end end - - function DetailsRaidCheck:BuffTrackTick() - wipe (DetailsRaidCheck.haveflask_table) - wipe (DetailsRaidCheck.havefood_table) - wipe (DetailsRaidCheck.havefocusaug_table) - wipe (DetailsRaidCheck.iseating_table) - - local hasConsumables = { - Flask = 0, - Food = 0, - } - - local playerAmount = DetailsRaidCheck.GetPlayerAmount() - - if (IsInRaid()) then - for i = 1, playerAmount do - local unitId = "raid" .. i - DetailsRaidCheck:CheckUnitBuffs(unitId, hasConsumables) - end - - elseif (IsInGroup()) then - for i = 1, playerAmount-1 do - local unitId = "party" .. i - DetailsRaidCheck:CheckUnitBuffs(unitId, hasConsumables) - end - DetailsRaidCheck:CheckUnitBuffs ("player", hasConsumables) - end - - if (hasConsumables.Food == playerAmount and hasConsumables.Flask == playerAmount) then - DetailsRaidCheck:SetGreenIcon() - else - DetailsRaidCheck:SetRedIcon() - end - end - - function DetailsRaidCheck:StartTrackBuffs(customUpdateSpeed) - if (not DetailsRaidCheck.tracking_buffs) then - DetailsRaidCheck.tracking_buffs = true - - DetailsRaidCheck:BuffTrackTick() - - if (DetailsRaidCheck.UpdateBuffsTick and not DetailsRaidCheck.UpdateBuffsTick._cancelled) then - DetailsRaidCheck.UpdateBuffsTick:Cancel() - end - - if (customUpdateSpeed) then - DetailsRaidCheck.UpdateBuffsTick = C_Timer.NewTicker (customUpdateSpeed-0.01, DetailsRaidCheck.BuffTrackTick) - else - DetailsRaidCheck.UpdateBuffsTick = C_Timer.NewTicker (UpdateSpeed-0.01, DetailsRaidCheck.BuffTrackTick) - end - end - - end - - function DetailsRaidCheck:StopTrackBuffs() - DetailsRaidCheck.tracking_buffs = false - if (DetailsRaidCheck.UpdateBuffsTick and not DetailsRaidCheck.UpdateBuffsTick._cancelled) then - DetailsRaidCheck.UpdateBuffsTick:Cancel() - end - end - end -local build_options_panel = function() + --create scroll + local mainScroll = DF:CreateScrollBox(raidCheckFrame, "$parentMainScroll", scrollRefreshLines, PlayerData, 1, 1, scrollLinesAmount, scrollLineHeight) + DF:ReskinSlider(mainScroll) + mainScroll.HideScrollBar = true + mainScroll:SetPoint("topleft", raidCheckFrame, "topleft", 10, scrollY) + mainScroll:SetPoint("bottomright", raidCheckFrame, "bottomright", -10, 20) + mainScroll:Refresh() - local options_frame = DetailsRaidCheck:CreatePluginOptionsFrame ("DetailsRaidCheckOptionsWindow", "Details! Raid Check Options", 1) + --create lines + for i = 1, scrollLinesAmount do + mainScroll:CreateLine(scrollCreateLine) + end - local menu = { - - {type = "label", get = function() return "General Settings:" end, text_template = DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE")}, + raidCheckFrame:Hide() + + DetailsRaidCheck.report_lines = "" + local reportFunc = function(IsCurrent, IsReverse, AmtLines) + DetailsRaidCheck:SendReportLines(DetailsRaidCheck.report_lines) + end + + --overwrite the default scripts + DetailsRaidCheck.ToolbarButton:RegisterForClicks("AnyUp") + DetailsRaidCheck.ToolbarButton:SetScript("OnClick", function(self, button) + if (IsShiftKeyDown()) then + DetailsRaidCheck.OpenOptionsPanel() + return + end + + if (button == "LeftButton") then + --link no food/flask + local reportString, added = "Details!: No Flask or Food: ", {} + + local amt = GetNumGroupMembers() + local _, _, difficulty = GetInstanceInfo() + if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and amt > 20) then + amt = 20 + end + + for i = 1, amt, 1 do + local unitID = getUnitId(i) + local name = UnitName(unitID) + local unitSerial = UnitGUID(unitID) + + if (not DetailsRaidCheck.unitWithFoodTable[unitSerial]) then + added [unitSerial] = true + reportString = reportString .. DetailsRaidCheck:GetOnlyName(name) .. " " + end + + if (not DetailsRaidCheck.unitsWithFlaskTable[unitSerial] and not added[unitSerial]) then + reportString = reportString .. DetailsRaidCheck:GetOnlyName(name) .. " " + end + end + + if (DetailsRaidCheck.db.use_report_panel) then + DetailsRaidCheck.report_lines = reportString + DetailsRaidCheck:SendReportWindow(reportFunc) + else + if (IsInRaid()) then + DetailsRaidCheck:SendMsgToChannel(reportString, "RAID") + else + DetailsRaidCheck:SendMsgToChannel(reportString, "PARTY") + end + end + + elseif (button == "RightButton") then + --link no pre-pot latest segment + local reportString = "Details!: No Pre-Pot Last Try: " + local groupMembersAmount = GetNumGroupMembers() + local _, _, difficulty = GetInstanceInfo() + if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and groupMembersAmount > 20) then + groupMembersAmount = 20 + end + + for i = 1, groupMembersAmount, 1 do + local unitId = getUnitId(i) + local role = UnitGroupRolesAssigned(unitId) + + if (role == "DAMAGER" or (role == "HEALER" and DetailsRaidCheck.db.pre_pot_healers) or (role == "TANK" and DetailsRaidCheck.db.pre_pot_tanks)) then + local playerName, realmName = UnitName(unitId) + if (realmName and realmName ~= "") then + playerName = playerName .. "-" .. realmName + end + + if (not DetailsRaidCheck.usedprepot_table[playerName]) then + reportString = reportString .. DetailsRaidCheck:GetOnlyName(playerName) .. " " + end + end + end + + if (DetailsRaidCheck.db.use_report_panel) then + DetailsRaidCheck.report_lines = reportString + DetailsRaidCheck:SendReportWindow(reportFunc) + else + if (IsInRaid()) then + DetailsRaidCheck:SendMsgToChannel(reportString, "RAID") + else + DetailsRaidCheck:SendMsgToChannel(reportString, "PARTY") + end + end + + elseif (button == "MiddleButton") then + --report focus aug + local reportString = "Details!: Not using Rune: " + local groupMembersAmount = GetNumGroupMembers() + local _, _, difficulty = GetInstanceInfo() + if (difficulty == 16 and DetailsRaidCheck.db.mythic_1_4 and groupMembersAmount > 20) then + groupMembersAmount = 20 + end + + for i = 1, groupMembersAmount do + local unitID = getUnitId(i) + local name = UnitName(unitID) + local unitSerial = UnitGUID(unitID) + if (not DetailsRaidCheck.havefocusaug_table[unitSerial]) then + reportString = reportString .. DetailsRaidCheck:GetOnlyName(name) .. " " + end + end + + if (DetailsRaidCheck.db.use_report_panel) then + DetailsRaidCheck.report_lines = reportString + DetailsRaidCheck:SendReportWindow(reportFunc) + else + if (IsInRaid()) then + DetailsRaidCheck:SendMsgToChannel(reportString, "RAID") + else + DetailsRaidCheck:SendMsgToChannel(reportString, "PARTY") + end + end + end + end) + + local updateRaidCheckFrame = function(self, deltaTime) + raidCheckFrame.NextUpdate = raidCheckFrame.NextUpdate - deltaTime + if (raidCheckFrame.NextUpdate > 0) then + return + end + + raidCheckFrame.NextUpdate = UpdateSpeed + + if (not IsInRaid() and not IsInGroup()) then + return + end + + DetailsRaidCheck:BuffTrackTick() + wipe(PlayerData) + + local groupTypeId = IsInRaid() and "raid" or "party" + + local playerAmount = DetailsRaidCheck.GetPlayerAmount() + local iterateAmount = playerAmount + if (not IsInRaid()) then + iterateAmount = iterateAmount - 1 + end + + for i = 1, iterateAmount do + local unitID = groupTypeId .. i + local unitName = UnitName (unitID) + local unitNameWithRealm = GetUnitName(unitID, true) + local cleuName = Details:GetCLName (unitID) + local unitSerial = UnitGUID (unitID) + local _, unitClass, unitClassID = UnitClass (unitID) + local unitRole = UnitGroupRolesAssigned (unitID) + local unitSpec = Details:GetSpecFromSerial (unitSerial) or Details:GetSpec (cleuName) + local itemLevelTable = Details.ilevel:GetIlvl (unitSerial) + local talentsTable = Details:GetTalents (unitSerial) + + --order by class > alphabetically by the unit name + unitClassID = (((unitClassID or 0) + 128) ^ 4) + tonumber(string.byte (unitName, 1) .. "" .. string.byte(unitName, 2)) + + tinsert(PlayerData, {unitName, unitClassID, + Name = unitName, + UnitNameRealm = unitNameWithRealm, + Class = unitClass, + Serial = unitSerial, + Role = unitRole, + Spec = unitSpec, + ILevel = itemLevelTable, + Talents = talentsTable, + Food = DetailsRaidCheck.unitWithFoodTable[unitSerial], + Flask = DetailsRaidCheck.unitsWithFlaskTable[unitSerial], + PrePot = DetailsRaidCheck.usedprepot_table[cleuName], + Rune = DetailsRaidCheck.havefocusaug_table[unitSerial], + Eating = DetailsRaidCheck.iseating_table[unitSerial], + UseDetails = Details.trusted_characters[unitSerial], + }) + end + + if (not IsInRaid()) then + --add the player data + local unitId = "player" + local unitName = UnitName(unitId) + local cleuName = Details:GetCLName(unitId) + local unitSerial = UnitGUID(unitId) + local _, unitClass, unitClassID = UnitClass(unitId) + local unitRole = UnitGroupRolesAssigned(unitId) + local unitSpec = Details:GetSpecFromSerial(unitSerial) or Details:GetSpec(cleuName) + local itemLevelTable = Details.ilevel:GetIlvl(unitSerial) + local talentsTable = Details:GetTalents(unitSerial) + + unitClassID = ((unitClassID + 128) ^ 4) + tonumber(string.byte(unitName, 1) .. "" .. string.byte(unitName, 2)) + local unitNameWithRealm = GetUnitName(unitId, true) + + tinsert (PlayerData, {unitName, unitClassID, + Name = unitName, + UnitNameRealm = unitNameWithRealm, + Class = unitClass, + Serial = unitSerial, + Role = unitRole, + Spec = unitSpec, + ILevel = itemLevelTable, + Talents = talentsTable, + Food = DetailsRaidCheck.unitWithFoodTable[unitSerial], + Flask = DetailsRaidCheck.unitsWithFlaskTable[unitSerial], + PrePot = DetailsRaidCheck.usedprepot_table[cleuName], + Rune = DetailsRaidCheck.havefocusaug_table[unitSerial], + Eating = DetailsRaidCheck.iseating_table[unitSerial], + UseDetails = Details.trusted_characters[unitSerial], + }) + end + + mainScroll:Refresh() + + local height = (playerAmount * scrollLineHeight) + 75 + raidCheckFrame:AdjustHeight(height) + end + + DetailsRaidCheck.ToolbarButton:SetScript("OnEnter", function(self) + raidCheckFrame:Show() + raidCheckFrame:ClearAllPoints() + + local bottomPosition = self:GetBottom() + local screenHeight = GetScreenHeight() + + local positionHeightPercent = bottomPosition / screenHeight + + if (positionHeightPercent > 0.7) then + raidCheckFrame:SetPoint("top", DetailsRaidCheck.ToolbarButton, "bottom", 0, -10) + else + raidCheckFrame:SetPoint("bottom", DetailsRaidCheck.ToolbarButton, "top", 0, 10) + end + + raidCheckFrame.NextUpdate = UpdateSpeed + updateRaidCheckFrame(raidCheckFrame, 1) + raidCheckFrame:SetScript("OnUpdate", updateRaidCheckFrame) + end) + + DetailsRaidCheck.ToolbarButton:SetScript("OnLeave", function (self) + raidCheckFrame:SetScript("OnUpdate", nil) + raidCheckFrame:Hide() + end) + + function DetailsRaidCheck:CheckCanShowIcon(...) + local isInRaid = IsInRaid() + local isInGroup = IsInGroup() + + if (isInRaid or isInGroup) then + DetailsRaidCheck:ShowToolbarIcon(DetailsRaidCheck.ToolbarButton, "star") + DetailsRaidCheck.on_raid = true + else + DetailsRaidCheck:HideToolbarIcon(DetailsRaidCheck.ToolbarButton) + DetailsRaidCheck.on_raid = false + end + end + + local checkBuffs_Shadowlands = function(unitId, consumableTable) + local unitSerial = UnitGUID(unitId) + + for buffIndex = 1, 40 do + local bname, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId = UnitBuff(unitId, buffIndex) + + if (bname) then + if (flaskList[spellId]) then + DetailsRaidCheck.unitsWithFlaskTable[unitSerial] = {spellId, 1, texture} + consumableTable.Flask = consumableTable.Flask + 1 + end + + if (DetailsRaidCheck.db.food_tier1) then + if (foodList.tier1[spellId]) then + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, 1, texture} + consumableTable.Food = consumableTable.Food + 1 + end + end + + if (DetailsRaidCheck.db.food_tier2) then + if (foodList.tier2[spellId]) then + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, 2, texture} + consumableTable.Food = consumableTable.Food + 1 + end + end + + if (DetailsRaidCheck.db.food_tier3) then + if (foodList.tier3[spellId]) then + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, 3, texture} + consumableTable.Food = consumableTable.Food + 1 + end + end + + if (runeIds[spellId]) then + DetailsRaidCheck.havefocusaug_table[unitSerial] = spellId + end + + if (bname == localizedFoodDrink) then + DetailsRaidCheck.iseating_table[unitSerial] = true + end + else + break + end + end + end + + local checkBuffs_Dragonflight = function(unitId, consumableTable) + local unitSerial = UnitGUID(unitId) + + local function handleAuraBuff(aura) + local auraInfo = C_UnitAuras.GetAuraDataByAuraInstanceID("player", aura.auraInstanceID) + local buffName = auraInfo.name + local spellId = auraInfo.spellId + + if (buffName) then + local flashInfo = flaskList[spellId] + if (flashInfo) then + local flaskTier = openRaidLib.GetFlaskTierFromAura(auraInfo) + DetailsRaidCheck.unitsWithFlaskTable[unitSerial] = {spellId, flaskTier, auraInfo.icon} + consumableTable.Flask = consumableTable.Flask + 1 + end + + local foodInfo = foodInfoList[spellId] + + if (DetailsRaidCheck.db.food_tier1) then + if (foodInfo) then + local foodTier = openRaidLib.GetFoodTierFromAura(auraInfo) + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, foodTier or 1, auraInfo.icon} + consumableTable.Food = consumableTable.Food + 1 + end + end + + if (DetailsRaidCheck.db.food_tier2) then + if (foodInfo) then + local foodTier = openRaidLib.GetFoodTierFromAura(auraInfo) + if (foodTier and foodTier >= 2) then + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, foodTier, auraInfo.icon} + consumableTable.Food = consumableTable.Food + 1 + end + end + end + + if (DetailsRaidCheck.db.food_tier3) then + if (foodInfo) then + local foodTier = openRaidLib.GetFoodTierFromAura(auraInfo) + if (foodTier and foodTier >= 3) then + DetailsRaidCheck.unitWithFoodTable[unitSerial] = {spellId, foodTier, auraInfo.icon} + consumableTable.Food = consumableTable.Food + 1 + end + end + end + + if (runeIds[spellId]) then + DetailsRaidCheck.havefocusaug_table[unitSerial] = spellId + end + + if (buffName == localizedFoodDrink) then + DetailsRaidCheck.iseating_table[unitSerial] = true + end + end + end + + local batchCount = nil + local usePackedAura = true + AuraUtil.ForEachAura(unitId, "HELPFUL", batchCount, handleAuraBuff, usePackedAura) + end + + function DetailsRaidCheck:CheckUnitBuffs(unitId, consumableTable) + if (DF.IsShadowlandsWow() or DF.IsWotLKWow()) then + checkBuffs_Shadowlands(unitId, consumableTable) + + elseif (DF.IsDragonflight()) then + checkBuffs_Dragonflight(unitId, consumableTable) + end + end + + function DetailsRaidCheck:BuffTrackTick() + wipe(DetailsRaidCheck.unitsWithFlaskTable) + wipe(DetailsRaidCheck.unitWithFoodTable) + wipe(DetailsRaidCheck.havefocusaug_table) + wipe(DetailsRaidCheck.iseating_table) + + local hasConsumables = { + Flask = 0, + Food = 0, + } + + local playerAmount = DetailsRaidCheck.GetPlayerAmount() + + if (IsInRaid()) then + for i = 1, playerAmount do + local unitId = "raid" .. i + DetailsRaidCheck:CheckUnitBuffs(unitId, hasConsumables) + end + + elseif (IsInGroup()) then + for i = 1, playerAmount - 1 do + local unitId = "party" .. i + DetailsRaidCheck:CheckUnitBuffs(unitId, hasConsumables) + end + DetailsRaidCheck:CheckUnitBuffs("player", hasConsumables) + end + + if (hasConsumables.Food == playerAmount and hasConsumables.Flask == playerAmount) then + DetailsRaidCheck:SetGreenIcon() + else + DetailsRaidCheck:SetRedIcon() + end + end +end + +local buildOptionsPanel = function() + local optionsFrame = DetailsRaidCheck:CreatePluginOptionsFrame("DetailsRaidCheckOptionsWindow", "Details! Raid Check Options", 1) + local optionsTable = { + {type = "label", get = function() return "General Settings:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")}, { type = "toggle", get = function() return DetailsRaidCheck.db.pre_pot_healers end, @@ -899,20 +886,10 @@ local build_options_panel = function() desc = "When raiding on Mythic difficult, only check the first 4 groups.", name = "Mythic 1-4 Group Only" }, - - --[=[ - { - type = "toggle", - get = function() return DetailsRaidCheck.db.use_report_panel end, - set = function (self, fixedparam, value) DetailsRaidCheck.db.use_report_panel = value end, - desc = "If enabled, clicking to report open the report panel instead (to be able to choose where to send the report).", - name = "Use Report Panel" - }, - --]=] - + {type = "breakline"}, - - {type = "label", get = function() return "Food Level Tracking:" end, text_template = DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE")}, + + {type = "label", get = function() return "Food Level Tracking:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")}, { type = "toggle", get = function() return DetailsRaidCheck.db.food_tier1 end, @@ -935,80 +912,75 @@ local build_options_panel = function() name = "Food Tier 3 [>= 75]" }, } - - local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE") - local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") - local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE") - local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE") - local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE") - - _detalhes.gump:BuildMenu (options_frame, menu, 15, -45, 180, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template) + local options_text_template = DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE") + local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") + local options_switch_template = DF:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE") + local options_slider_template = DF:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE") + local options_button_template = DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE") + + Details.gump:BuildMenu(optionsFrame, optionsTable, 15, -45, 180, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template) end DetailsRaidCheck.OpenOptionsPanel = function() if (not DetailsRaidCheckOptionsWindow) then - build_options_panel() + buildOptionsPanel() end DetailsRaidCheckOptionsWindow:Show() end - - function DetailsRaidCheck:OnEvent (_, event, ...) - if (event == "GROUP_ROSTER_UPDATE") then - if (DetailsRaidCheck.RosterDelay < GetTime()) then - DetailsRaidCheck:CheckCanShowIcon() - DetailsRaidCheck.RosterDelay = GetTime()+2 - end +function DetailsRaidCheck:OnEvent(_, event, ...) - elseif (event == "ADDON_LOADED") then - local AddonName = select (1, ...) - if (AddonName == "Details_RaidCheck") then - - if (_G._detalhes) then + if (event == "GROUP_ROSTER_UPDATE") then + if (DetailsRaidCheck.RosterDelay < GetTime()) then + DetailsRaidCheck:CheckCanShowIcon() + DetailsRaidCheck.RosterDelay = GetTime()+2 + end - if (DetailsFramework.IsClassicWow()) then - return - end - - --> create widgets - CreatePluginFrames() - - --> core version required - local MINIMAL_DETAILS_VERSION_REQUIRED = 20 - - local default_settings = { - pre_pot_healers = false, --do not report pre pot for healers - pre_pot_tanks = false, --do not report pre pot for tanks - mythic_1_4 = true, --only track groups 1-4 on mythic - use_report_panel = true, --if true, shows the report panel - - food_tier1 = true, --legion food tiers - food_tier2 = true, - food_tier3 = true, - } - - DetailsRaidCheck.RosterDelay = GetTime() - - --make it load after the other plugins - C_Timer.After(1, function() - --> install - local install, saveddata, is_enabled = _G._detalhes:InstallPlugin ("TOOLBAR", Loc ["STRING_RAIDCHECK_PLUGIN_NAME"], [[Interface\Buttons\UI-CheckBox-Check]], DetailsRaidCheck, "DETAILS_PLUGIN_RAIDCHECK", MINIMAL_DETAILS_VERSION_REQUIRED, "Terciob", version, default_settings) - if (type (install) == "table" and install.error) then - return print (install.error) - end - - --> register needed events - _G._detalhes:RegisterEvent (DetailsRaidCheck, "COMBAT_PLAYER_LEAVE") - _G._detalhes:RegisterEvent (DetailsRaidCheck, "COMBAT_PLAYER_ENTER") - _G._detalhes:RegisterEvent (DetailsRaidCheck, "COMBAT_PREPOTION_UPDATED") - _G._detalhes:RegisterEvent (DetailsRaidCheck, "ZONE_TYPE_CHANGED") - - DetailsRaidCheck.Frame:RegisterEvent ("GROUP_ROSTER_UPDATE") - end) + elseif (event == "ADDON_LOADED") then + local AddonName = select(1, ...) + if (AddonName == "Details_RaidCheck") then + if (_G.Details) then + if (DetailsFramework.IsClassicWow()) then + return end + + --create widgets + CreatePluginFrames() + + --core version required + local MINIMAL_DETAILS_VERSION_REQUIRED = 20 + + local defaultSettings = { + pre_pot_healers = false, --do not report pre pot for healers + pre_pot_tanks = false, --do not report pre pot for tanks + mythic_1_4 = true, --only track groups 1-4 on mythic + use_report_panel = true, --if true, shows the report panel + + food_tier1 = true, --legion food tiers + food_tier2 = true, + food_tier3 = true, + } + + DetailsRaidCheck.RosterDelay = GetTime() + + --make it load after the other plugins + C_Timer.After(1, function() + --install + local install, savedData, isEnabled = _G.Details:InstallPlugin("TOOLBAR", Loc["STRING_RAIDCHECK_PLUGIN_NAME"], [[Interface\Buttons\UI-CheckBox-Check]], DetailsRaidCheck, "DETAILS_PLUGIN_RAIDCHECK", MINIMAL_DETAILS_VERSION_REQUIRED, "Terciob", version, defaultSettings) + if (type (install) == "table" and install.error) then + return print(install.error) + end + + --register needed events + Details:RegisterEvent(DetailsRaidCheck, "COMBAT_PLAYER_LEAVE") + Details:RegisterEvent(DetailsRaidCheck, "COMBAT_PLAYER_ENTER") + Details:RegisterEvent(DetailsRaidCheck, "COMBAT_PREPOTION_UPDATED") + Details:RegisterEvent(DetailsRaidCheck, "ZONE_TYPE_CHANGED") + + DetailsRaidCheck.Frame:RegisterEvent("GROUP_ROSTER_UPDATE") + end) end end - end - --- doo \ No newline at end of file + end +end \ No newline at end of file diff --git a/plugins/Details_Streamer/Details_Streamer.lua b/plugins/Details_Streamer/Details_Streamer.lua index 02d77da0..10befad1 100644 --- a/plugins/Details_Streamer/Details_Streamer.lua +++ b/plugins/Details_Streamer/Details_Streamer.lua @@ -1,23 +1,21 @@ -local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" ) + local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0") local LDB = LibStub ("LibDataBroker-1.1", true) local LDBIcon = LDB and LibStub ("LibDBIcon-1.0", true) local LibWindow = LibStub ("LibWindow-1.1") local _ - ---need cleanup Loc ["STRING_MEMORY_ALERT_BUTTON"], --> create the plugin object -- "Details_StreamOverlay" is the old name -local StreamOverlay = _detalhes:NewPluginObject ("Details_Streamer", DETAILSPLUGIN_ALWAYSENABLED) +local StreamOverlay = _detalhes:NewPluginObject("Details_Streamer", DETAILSPLUGIN_ALWAYSENABLED) --tinsert (UISpecialFrames, "Details_StreamOverlays") --> main frame (shortcut) local SOF = StreamOverlay.Frame --> shortcut for details framework -local fw = StreamOverlay.gump -local player_name +local playerName StreamOverlay.CurrentVersion = "v1.2" @@ -55,63 +53,61 @@ StreamOverlay.squares = {} -- StreamOverlay.OnDeath hook deaths from details! and show here (if player only). --frame listening to UNIT_CAST events -local listener = CreateFrame ("frame") +local eventFrame = CreateFrame("frame") --max left and right text sizes, is updated later in a function -local text1_size, text2_size = 200, 200 +local text1Size, text2Size = 200, 200 --icon size, is updated later in a function -local icon_size = 16 +local iconSize = 16 --default icon for an attack on a monster -local default_attack_icon = [[Interface\CURSOR\UnableAttack]] +local defaultAttackIcon = [[Interface\CURSOR\UnableAttack]] local function CreatePluginFrames() - - --> shortcut for details fade function + --shortcut for details fade function local fader = Details.FadeHandler.Fader - function StreamOverlay:OnDetailsEvent (event, ...) + function StreamOverlay:OnDetailsEvent(event, ...) if (event == "HIDE") then --> plugin hidded, disabled self.open = false - + elseif (event == "SHOW") then --> plugin hidded, disabled self.open = true elseif (event == "PLUGIN_DISABLED") then StreamOverlay:OnDisablePlugin() - + elseif (event == "DETAILS_STARTED") then StreamOverlay:OnEnablePlugin() - + elseif (event == "PLUGIN_ENABLED") then StreamOverlay:OnEnablePlugin() - + end end function StreamOverlay:OnEnablePlugin() - - --> show the frame and restore position + --show the frame and restore position SOF:Show() - + --> restore size and location StreamOverlay:RestoreWindowSizeAndLocation() - + --> refresh the frame StreamOverlay:Refresh() StreamOverlay:SetBackgroundColor() StreamOverlay:CreateMinimapIcon() --> enable the minimap icon - LDBIcon:Refresh ("DetailsStreamer", StreamOverlay.db.minimap) + LDBIcon:Refresh("DetailsStreamer", StreamOverlay.db.minimap) StreamOverlay:SetLocked() --> install the death hook - Details:InstallHook (DETAILS_HOOK_DEATH, StreamOverlay.OnDeath) + Details:InstallHook(DETAILS_HOOK_DEATH, StreamOverlay.OnDeath) --> enable event listener - listener:RegisterMyEvents() + eventFrame:RegisterMyEvents() --> enable the tick update - listener:SetScript ("OnUpdate", listener.track_spell_cast) + eventFrame:SetScript ("OnUpdate", eventFrame.track_spell_cast) --> refresh dps frame StreamOverlay:UpdateDpsHpsFrameConfig() @@ -119,10 +115,10 @@ local function CreatePluginFrames() function StreamOverlay:OnDisablePlugin() --> shutdown the tick update - listener:SetScript ("OnUpdate", nil) + eventFrame:SetScript ("OnUpdate", nil) --> disable the event listener - listener:UnregisterMyEvents() + eventFrame:UnregisterMyEvents() --> unistall the death hook Details:UnInstallHook (DETAILS_HOOK_DEATH, StreamOverlay.OnDeath) @@ -213,12 +209,14 @@ local function CreatePluginFrames() SOF:SetResizable (true) SOF:SetClampedToScreen (true) - if (DetailsFramework.IsDragonflight()) then - SOF:SetResizeBounds(150, 10, 800, 1024) - else - SOF:SetMinResize(150, 10) - SOF:SetMaxResize(800, 1024) - end + pcall(function() + if (DetailsFramework.IsDragonflight()) then + SOF:SetResizeBounds(150, 10, 800, 1024) + else + SOF:SetMinResize(150, 10) + SOF:SetMaxResize(800, 1024) + end + end) function StreamOverlay:SaveWindowSizeAnLocation() --> save size first @@ -367,52 +365,59 @@ local function CreatePluginFrames() end function StreamOverlay:CreateSquareBox() - local index = #StreamOverlay.squares+1 - - local f = CreateFrame("frame", "StreamOverlaySquare" .. index, SOF, "BackdropTemplate") - f:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}) - f:SetBackdropBorderColor (0, 0, 0, 0) - f.squareIndex = index + local index = #StreamOverlay.squares + 1 - f.texture = f:CreateTexture(nil, "artwork") - f.texture:SetAllPoints() + local newSquare = CreateFrame("frame", "StreamOverlaySquare" .. index, SOF, "BackdropTemplate") + newSquare:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}) + newSquare:SetBackdropBorderColor(0, 0, 0, 0) + newSquare.squareIndex = index - f.interruptedTexture = f:CreateTexture(nil, "overlay") - f.interruptedTexture:SetColorTexture(1, 0, 0, 0.4) - f.interruptedTexture:SetAllPoints() - f.interruptedTexture:Hide() + newSquare.texture = newSquare:CreateTexture(nil, "artwork") + newSquare.texture:SetAllPoints() - local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", f, "CooldownFrameTemplate, BackdropTemplate") + newSquare.interruptedTexture = newSquare:CreateTexture(nil, "overlay") + newSquare.interruptedTexture:SetColorTexture(1, 0, 0, 0.4) + newSquare.interruptedTexture:SetAllPoints() + newSquare.interruptedTexture:Hide() + + local cooldownFrame = CreateFrame("cooldown", "$parentCooldown", newSquare, "CooldownFrameTemplate, BackdropTemplate") cooldownFrame:SetAllPoints() cooldownFrame:EnableMouse(false) - cooldownFrame:SetHideCountdownNumbers(true) - f.cooldown = cooldownFrame - - if (index == 1) then - f:SetPoint("topleft", SOF, "topleft", 2, 0) - else - f:SetPoint("left", StreamOverlay.squares[index - 1], "right", 2, 0) - end + cooldownFrame:SetHideCountdownNumbers(true) + newSquare.cooldown = cooldownFrame - StreamOverlay.squares [#StreamOverlay.squares+1] = f - - f.in_use = 1 - f:Hide() - - StreamOverlay:SetSquareStyle(f, index) + StreamOverlay.squares[#StreamOverlay.squares+1] = newSquare + newSquare.in_use = 1 + newSquare:Hide() + + StreamOverlay:SetSquareStyle(newSquare, index) + StreamOverlay:ReorderSquares() + end + + function StreamOverlay:ReorderSquares() + local direction = StreamOverlay.db.square_grow_direction + for index = 1, #StreamOverlay.squares do + local thisSquare = StreamOverlay.squares[index] + thisSquare:ClearAllPoints() + if (direction == "right") then --growing from left to right + if (index == 1) then + thisSquare:SetPoint("topleft", SOF, "topleft", 2, 0) + else + thisSquare:SetPoint("left", StreamOverlay.squares[index - 1], "right", 2, 0) + end + else + if (index == 1) then + thisSquare:SetPoint("topright", SOF, "topright", -2, 0) + else + thisSquare:SetPoint("right", StreamOverlay.squares[index - 1], "left", -2, 0) + end + end + end end function StreamOverlay:UpdateSquares() - local direction = StreamOverlay.db.grow_direction - - if (direction == "right") then - for index = 1, StreamOverlay.total_lines do - StreamOverlay:UpdateSquare(index) - end - else - for index = #StreamOverlay.total_lines, 1, -1 do - StreamOverlay:UpdateSquare(index) - end + for index = 1, StreamOverlay.total_lines do + StreamOverlay:UpdateSquare(index) end end @@ -421,7 +426,7 @@ local function CreatePluginFrames() local data = StreamOverlay.battle_content[index] if (data) then - square.texture:SetTexture(data [1]) + square.texture:SetTexture(data[1]) square.texture:SetTexCoord(5/64, 59/64, 5/64, 59/64) --percentage @@ -434,7 +439,7 @@ local function CreatePluginFrames() local startTime = data.startTime local endTime = data.endTime StreamOverlay:UpdateCooldownFrame(square, true, startTime, endTime, castinfo) - + if (castinfo.Interrupted) then --square.interruptedTexture:Show() else @@ -451,15 +456,13 @@ local function CreatePluginFrames() --> iterate each bar and update its text, icons and statusbar function StreamOverlay:UpdateLines() - if (StreamOverlay.db.use_square_mode) then return end - FauxScrollFrame_Update (autoscroll, StreamOverlay.total_lines, StreamOverlay.total_lines, 20) - - for index = 1, StreamOverlay.total_lines do - + FauxScrollFrame_Update(autoscroll, StreamOverlay.total_lines, StreamOverlay.total_lines, 20) + + for index = 1, StreamOverlay.total_lines do --> here gets the bar and the table with the information to shown on the bar local data = StreamOverlay.battle_content [index] local line = StreamOverlay.battle_lines [index] @@ -472,7 +475,7 @@ local function CreatePluginFrames() local text = data [2] line.text1:SetText (text) local loops = 20 - while (line.text1:GetStringWidth() > text1_size and loops > 0) do + while (line.text1:GetStringWidth() > text1Size and loops > 0) do text = strsub (text, 1, #text-1) line.text1:SetText (text) loops = loops - 1 --just to be safe @@ -482,7 +485,7 @@ local function CreatePluginFrames() local text = data [6] line.text2:SetText (text) local loops = 20 - while (line.text2:GetStringWidth() > text2_size and loops > 0) do + while (line.text2:GetStringWidth() > text2Size and loops > 0) do text = strsub (text, 1, #text-1) line.text2:SetText (text) loops = loops - 1 --just to be safe @@ -504,12 +507,12 @@ local function CreatePluginFrames() line.icon2:SetTexture (data [4]) line.icon2:SetTexCoord (unpack (data [5])) - if (data [4] == default_attack_icon) then - line.icon2:SetSize (icon_size*0.8, icon_size*0.8) + if (data [4] == defaultAttackIcon) then + line.icon2:SetSize (iconSize*0.8, iconSize*0.8) line.icon2:SetPoint ("left", line, "center", 8, 0) line.text2:SetPoint ("left", line.icon2, "right", 5, 0) else - line.icon2:SetSize (icon_size, icon_size) + line.icon2:SetSize (iconSize, iconSize) line.icon2:SetPoint ("left", line, "center", 8, 0) line.text2:SetPoint ("left", line.icon2, "right", 5, 0) end @@ -688,13 +691,13 @@ local function CreatePluginFrames() StreamOverlay:SetFontColor (row.text1, StreamOverlay.db.font_color) StreamOverlay:SetFontColor (row.text2, StreamOverlay.db.font_color) - icon_size = StreamOverlay.db.row_height-4 - row.icon1:SetSize (icon_size, icon_size) - row.icon2:SetSize (icon_size, icon_size) + iconSize = StreamOverlay.db.row_height-4 + row.icon1:SetSize (iconSize, iconSize) + row.icon2:SetSize (iconSize, iconSize) local current_texture = row.icon2:GetTexture() - if (current_texture == default_attack_icon) then - row.icon2:SetSize (icon_size*0.8, icon_size*0.8) + if (current_texture == defaultAttackIcon) then + row.icon2:SetSize (iconSize*0.8, iconSize*0.8) row.icon2:SetPoint ("left", row, "center", 8, 0) row.text2:SetPoint ("left", row.icon2, "right", 5, 0) else @@ -766,37 +769,34 @@ local function CreatePluginFrames() end C_Timer.NewTicker(60, StreamOverlay.RefreshInUse) - - function StreamOverlay:Refresh() - - if (StreamOverlay.db.use_square_mode) then + function StreamOverlay:Refresh() + if (StreamOverlay.db.use_square_mode) then --hide any line created for i = 1, #StreamOverlay.battle_lines do StreamOverlay.battle_lines[i]:Hide() end - local amt = StreamOverlay.db.square_amount - StreamOverlay.total_lines = amt + local amountOfSquares = StreamOverlay.db.square_amount + StreamOverlay.total_lines = amountOfSquares - if (amt > #StreamOverlay.squares) then - for i = #StreamOverlay.squares+1, amt do + if (amountOfSquares > #StreamOverlay.squares) then + for i = #StreamOverlay.squares + 1, amountOfSquares do StreamOverlay:CreateSquareBox() end - for i = 1, amt do + for i = 1, amountOfSquares do StreamOverlay.squares[i]:Show() end - - elseif (#StreamOverlay.squares > amt) then - for i = #StreamOverlay.squares, amt+1, -1 do - StreamOverlay.squares [i]:Hide() + + elseif (#StreamOverlay.squares > amountOfSquares) then + for i = #StreamOverlay.squares, amountOfSquares + 1, -1 do + StreamOverlay.squares[i]:Hide() end - for i = 1, amt do - StreamOverlay.squares [i]:Show() + for i = 1, amountOfSquares do + StreamOverlay.squares[i]:Show() end - else - for i = 1, amt do + for i = 1, amountOfSquares do StreamOverlay.squares[i]:Show() end end @@ -810,60 +810,60 @@ local function CreatePluginFrames() StreamOverlay.squares[i]:Hide() end - --> how many lines fit in the frame - local amt = math.floor (SOF:GetHeight() / StreamOverlay.db.row_spacement) + --how many lines fit in the frame + local amountOfLines = math.floor(SOF:GetHeight() / StreamOverlay.db.row_spacement) - if (amt < 0) then - amt = 0 + if (amountOfLines < 0) then + amountOfLines = 0 end - - StreamOverlay.total_lines = amt - - if (amt == 0) then + + StreamOverlay.total_lines = amountOfLines + + if (amountOfLines == 0) then for i = 1, #StreamOverlay.battle_lines do - StreamOverlay.battle_lines [i]:Hide() + StreamOverlay.battle_lines[i]:Hide() end return end - --> need create more lines - if (amt > #StreamOverlay.battle_lines) then - for i = #StreamOverlay.battle_lines+1, amt do + -- need create more lines + if (amountOfLines > #StreamOverlay.battle_lines) then + for i = #StreamOverlay.battle_lines + 1, amountOfLines do StreamOverlay:CreateBattleLine() end - for i = 1, amt do + for i = 1, amountOfLines do StreamOverlay.battle_lines[i]:Show() end - - elseif (#StreamOverlay.battle_lines > amt) then - for i = #StreamOverlay.battle_lines, amt+1, -1 do - StreamOverlay.battle_lines [i]:Hide() + + elseif (#StreamOverlay.battle_lines > amountOfLines) then + for i = #StreamOverlay.battle_lines, amountOfLines + 1, -1 do + StreamOverlay.battle_lines[i]:Hide() end - for i = 1, amt do - StreamOverlay.battle_lines [i]:Show() + for i = 1, amountOfLines do + StreamOverlay.battle_lines[i]:Show() end else - for i = 1, amt do - StreamOverlay.battle_lines [i]:Show() + for i = 1, amountOfLines do + StreamOverlay.battle_lines[i]:Show() end end local width = SOF:GetWidth() / 2 - text1_size, text2_size = width - 28, width - 30 + text1Size, text2Size = width - 28, width - 30 StreamOverlay:UpdateLines() StreamOverlay:RefreshInUse() end end - function StreamOverlay:SetBackgroundColor (r, g, b, a) + function StreamOverlay:SetBackgroundColor(r, g, b, a) if (not r) then - r, g, b, a = unpack (StreamOverlay.db.main_frame_color) + r, g, b, a = unpack(StreamOverlay.db.main_frame_color) else local c = StreamOverlay.db.main_frame_color c[1], c[2], c[3], c[4] = r, g, b, a end - SOF:SetBackdropColor (r, g, b, a) + SOF:SetBackdropColor(r, g, b, a) end function StreamOverlay:ApplyBackgroundColor(r, g, b, a) @@ -871,8 +871,6 @@ local function CreatePluginFrames() end end -local playername = UnitName ("player") - local COLOR_HARMFUL = {.9, .5, .5, .4} local COLOR_HELPFUL = {.1, .9, .1, .4} local COLOR_ATTKCOOLDOWN = {1, 1, 0, .6} @@ -889,47 +887,66 @@ local ClassColorsTable = StreamOverlay.class_colors local ClassSpellList = StreamOverlay.ClassSpellList local AbsorbSpellsTable = StreamOverlay.AbsorbSpells -local ban_spells = { +local ignoredSpells = { [49821] = true, --mind sear ticks [121557] = true, --angelic feather walkon } -function StreamOverlay:GetSpellInformation (spellid) +--spell types: +-- 1 attack cooldown +-- 2 personal defensive cooldown +-- 3 targetted defensive cooldown +-- 4 raid defensive cooldown +-- 5 personal utility cooldown +-- 6 interrupt + +local spellTypeColor = { + [1] = COLOR_ATTKCOOLDOWN, + [2] = COLOR_DEFECOOLDOWN, + [3] = COLOR_DEFECOOLDOWN, + [4] = COLOR_DEFECOOLDOWN, +} + +function StreamOverlay:GetSpellInformation(spellId) + local _, _, icon = GetSpellInfo(spellId) - local spellname, _, icon = GetSpellInfo (spellid) - local backgroundcolor - - if (HarmfulSpellsTable [spellid]) then - backgroundcolor = COLOR_HARMFUL - - elseif (HelpfulSpellsTable [spellid]) then - backgroundcolor = COLOR_HELPFUL - - elseif (AttackCooldownSpellsTable [spellid]) then - backgroundcolor = COLOR_ATTKCOOLDOWN - - elseif (CooldownTable [spellid]) then - backgroundcolor = COLOR_DEFECOOLDOWN - - elseif (ClassSpellsTable [spellid]) then - local class = ClassSpellList [spellid] - backgroundcolor = ClassColorsTable [class] - - else - backgroundcolor = COLOR_HARMFUL - + + local spellInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId] + if (spellInfo) then + backgroundcolor = spellTypeColor[spellInfo.type] end - + + if (HarmfulSpellsTable[spellId]) then + backgroundcolor = COLOR_HARMFUL + + elseif (HelpfulSpellsTable[spellId]) then + backgroundcolor = COLOR_HELPFUL + + elseif (AttackCooldownSpellsTable[spellId]) then + backgroundcolor = COLOR_ATTKCOOLDOWN + + elseif (CooldownTable[spellId]) then + backgroundcolor = COLOR_DEFECOOLDOWN + + elseif (ClassSpellsTable[spellId]) then + local class = ClassSpellList [spellId] + backgroundcolor = ClassColorsTable [class] + + else + if (not backgroundcolor) then + backgroundcolor = COLOR_HARMFUL + end + end + local bordercolor - if (AbsorbSpellsTable [spellid]) then + if (AbsorbSpellsTable[spellId]) then bordercolor = COLOR_BORDER_ABSORB else bordercolor = COLOR_BORDER_DEFAULT end return icon, backgroundcolor, bordercolor - end local RoleIcons = "Interface\\LFGFRAME\\UI-LFG-ICON-PORTRAITROLES" @@ -1018,7 +1035,7 @@ function StreamOverlay:CastStart (castGUID) local startTime = CastsTable [castGUID].CastTimeStart local endTime = CastsTable [castGUID].CastTimeEnd - if (ban_spells [spellid]) then + if (ignoredSpells [spellid]) then return end @@ -1049,7 +1066,7 @@ function StreamOverlay:CastFinished (castid) local caststart = CastsTable [castid].CastStart local hascasttime = CastsTable [castid].HasCastTime - if (ban_spells [spellid]) then + if (ignoredSpells [spellid]) then return end @@ -1083,7 +1100,7 @@ function StreamOverlay:CastFinished (castid) end end -listener.track_spell_cast = function() +eventFrame.track_spell_cast = function() if (not StreamOverlay.db.use_square_mode) then for i = 1, #StreamOverlay.battle_content do @@ -1273,41 +1290,41 @@ listener.track_spell_cast = function() end end -function listener:RegisterMyEvents() - listener:RegisterEvent ("UNIT_SPELLCAST_START") - listener:RegisterEvent ("UNIT_SPELLCAST_SENT") - listener:RegisterEvent ("UNIT_SPELLCAST_SUCCEEDED") - listener:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTED") - listener:RegisterEvent ("UNIT_SPELLCAST_FAILED_QUIET") - listener:RegisterEvent ("UNIT_SPELLCAST_FAILED") - listener:RegisterEvent ("UNIT_SPELLCAST_DELAYED") - listener:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_START") - listener:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP") - listener:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE") - listener:RegisterEvent ("UNIT_SPELLCAST_STOP") +function eventFrame:RegisterMyEvents() + eventFrame:RegisterEvent ("UNIT_SPELLCAST_START") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_SENT") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_SUCCEEDED") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTED") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_FAILED_QUIET") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_FAILED") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_DELAYED") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_START") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_STOP") if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then - listener:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE") - listener:RegisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE") + eventFrame:RegisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE") end end -function listener:UnregisterMyEvents() - listener:UnregisterEvent ("UNIT_SPELLCAST_START") - listener:UnregisterEvent ("UNIT_SPELLCAST_SENT") - listener:UnregisterEvent ("UNIT_SPELLCAST_SUCCEEDED") - listener:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTED") - listener:UnregisterEvent ("UNIT_SPELLCAST_FAILED_QUIET") - listener:UnregisterEvent ("UNIT_SPELLCAST_FAILED") - listener:UnregisterEvent ("UNIT_SPELLCAST_DELAYED") - listener:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_START") - listener:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP") - listener:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE") - listener:UnregisterEvent ("UNIT_SPELLCAST_STOP") +function eventFrame:UnregisterMyEvents() + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_START") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_SENT") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_SUCCEEDED") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTED") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_FAILED_QUIET") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_FAILED") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_DELAYED") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_START") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_STOP") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_CHANNEL_UPDATE") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_STOP") if (not DetailsFramework.IsTBCWow() and not DetailsFramework.IsWotLKWow()) then - listener:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE") - listener:UnregisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_INTERRUPTIBLE") + eventFrame:UnregisterEvent ("UNIT_SPELLCAST_NOT_INTERRUPTIBLE") end end @@ -1329,7 +1346,7 @@ APM_FRAME:SetScript ("OnEvent", function() ACTIONS = ACTIONS + 1 end) -listener:SetScript ("OnEvent", function (self, event, ...) +eventFrame:SetScript ("OnEvent", function (self, event, ...) if (event ~= "UNIT_SPELLCAST_SENT" and event ~= "UNIT_SPELLCAST_SUCCEEDED" and ACTIONS_EVENT_TIME [event] ~= GetTime()) then ACTIONS = ACTIONS + 1 ACTIONS_EVENT_TIME [event] = GetTime() @@ -1477,7 +1494,7 @@ function StreamOverlay.OnDeath (_, token, time, who_serial, who_name, who_flags, if (sourceObject) then classIcon, l, r, t, b = StreamOverlay:GetClassIcon (sourceObject.classe) else - classIcon, l, r, t, b = default_attack_icon, 0, 1, 0, 1 + classIcon, l, r, t, b = defaultAttackIcon, 0, 1, 0, 1 end --spellname @@ -1653,7 +1670,7 @@ end function StreamOverlay:UpdateDpsHpsFrame() --> low level actor parsing - we can just use Details:GetActor(), but is faster without having to call functions local container = _detalhes.tabela_vigente [screen_frame_attribute] - local actor = container._ActorTable [container._NameIndexTable [player_name]] + local actor = container._ActorTable [container._NameIndexTable [playerName]] if (actor) then screen_frame_text:SetText (format_function (_, actor.total / _detalhes.tabela_vigente:GetCombatTime())) @@ -1669,22 +1686,21 @@ end ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -function StreamOverlay.OpenOptionsPanel (from_options_panel) - +function StreamOverlay.OpenOptionsPanel (fromOptionsPanel) if (not StreamOverlayOptionsPanel) then - local fw = Details:GetFramework() + local detailsFramework = Details:GetFramework() - local options_text_template = fw:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE") - local options_dropdown_template = fw:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") - local options_switch_template = fw:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE") - local options_slider_template = fw:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE") - local options_button_template = fw:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE") + local options_text_template = detailsFramework:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE") + local options_dropdown_template = detailsFramework:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") + local options_switch_template = detailsFramework:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE") + local options_slider_template = detailsFramework:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE") + local options_button_template = detailsFramework:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE") local optionsFrame = StreamOverlay:CreatePluginOptionsFrame("StreamOverlayOptionsPanel", "Details! Streamer: Action Tracker", 1) optionsFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) optionsFrame:SetBackdropColor(0, 0, 0, 0.5) optionsFrame:SetBackdropBorderColor(0, 0, 0, 1) - optionsFrame:SetWidth(530) + optionsFrame:SetWidth(535) optionsFrame:SetHeight(655) if (StreamOverlayWelcomeWindow) then @@ -1706,7 +1722,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) local selectModeFrame = CreateFrame("frame", nil, optionsFrame, "BackdropTemplate") DetailsFramework:ApplyStandardBackdrop(selectModeFrame) selectModeFrame:SetPoint("topleft", optionsFrame, "topleft", 5, -95) - selectModeFrame:SetSize(optionsFrame:GetWidth()-10, 120) + selectModeFrame:SetSize(optionsFrame:GetWidth() - 10, 120) local selectedFrame = CreateFrame("frame", nil, selectModeFrame, "BackdropTemplate") selectedFrame:SetSize(260, 81) @@ -1753,29 +1769,29 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) end -- select texture - local set_row_texture = function (_, _, value) + local setRowTexture = function(_, _, value) StreamOverlay.db.row_texture = value StreamOverlay:RefreshAllBattleLineStyle() end - local textures = SharedMedia:HashTable ("statusbar") + local textures = SharedMedia:HashTable("statusbar") local textureTable = {} - for name, texturePath in pairs (textures) do - textureTable[#textureTable+1] = {value = name, label = name, statusbar = texturePath, onclick = set_row_texture} + for name, texturePath in pairs(textures) do + textureTable[#textureTable+1] = {value = name, label = name, statusbar = texturePath, onclick = setRowTexture} end - table.sort (textureTable, function (t1, t2) return t1.label < t2.label end) - - -- select font - local set_font_face= function (_, _, value) + table.sort(textureTable, function(t1, t2) return t1.label < t2.label end) + + --select font + local setFontFace = function(_, _, value) StreamOverlay.db.font_face = value StreamOverlay:RefreshAllBattleLineStyle() end - local fontObjects = SharedMedia:HashTable ("font") + local fontObjects = SharedMedia:HashTable("font") local fontTable = {} - for name, fontPath in pairs (fontObjects) do - fontTable[#fontTable+1] = {value = name, label = name, onclick = set_font_face, font = fontPath, descfont = name} + for name, fontPath in pairs(fontObjects) do + fontTable[#fontTable+1] = {value = name, label = name, onclick = setFontFace, font = fontPath, descfont = name} end - table.sort (fontTable, function (t1, t2) return t1.label < t2.label end) - + table.sort(fontTable, function (t1, t2) return t1.label < t2.label end) + -- select arrow local arrows = { [[Interface\CHATFRAME\ChatFrameExpandArrow]], @@ -1802,36 +1818,47 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) [[Interface\Scenarios\ScenarioIcon-Boss]], [[Interface\Tooltips\ReforgeGreenArrow]], } - - local set_arrow_texture = function (_, _, value) + + local setArrowTextureCallback = function(_, _, value) StreamOverlay.db.arrow_texture = value StreamOverlay:RefreshAllBattleLineStyle() end - + local arrowIconTable = {} - for _, arrow in ipairs (arrows) do - arrowIconTable[#arrowIconTable+1] = {value = arrow, label = arrow:gsub ("Interface(.*)\\", ""), onclick = set_arrow_texture, icon = arrow} + for _, arrow in ipairs (arrows) do + arrowIconTable[#arrowIconTable+1] = {value = arrow, label = arrow:gsub ("Interface(.*)\\", ""), onclick = setArrowTextureCallback, icon = arrow} end + -- - local set_window_strata = function (_, _, strata) + + local setWindowStrataCallback = function (_, _, strata) StreamOverlay.db.main_frame_strata = strata - SOF:SetFrameStrata (strata) - StreamerOverlayDpsHpsFrame:SetFrameStrata (strata) + SOF:SetFrameStrata(strata) + StreamerOverlayDpsHpsFrame:SetFrameStrata(strata) end local strataTable = { - {value = "BACKGROUND", label = "Background", onclick = set_window_strata, icon = [[Interface\Buttons\UI-MicroStream-Green]], iconcolor = {0, .5, 0, .8}, texcoord = nil}, - {value = "LOW", label = "Low", onclick = set_window_strata, icon = [[Interface\Buttons\UI-MicroStream-Green]] , texcoord = nil}, - {value = "MEDIUM", label = "Medium", onclick = set_window_strata, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , texcoord = nil}, - {value = "HIGH", label = "High", onclick = set_window_strata, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , iconcolor = {1, .7, 0, 1}, texcoord = nil}, - {value = "DIALOG", label = "Dialog", onclick = set_window_strata, icon = [[Interface\Buttons\UI-MicroStream-Red]] , iconcolor = {1, 0, 0, 1}, texcoord = nil}, + {value = "BACKGROUND", label = "Background", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Green]], iconcolor = {0, .5, 0, .8}, texcoord = nil}, + {value = "LOW", label = "Low", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Green]] , texcoord = nil}, + {value = "MEDIUM", label = "Medium", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , texcoord = nil}, + {value = "HIGH", label = "High", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Yellow]] , iconcolor = {1, .7, 0, 1}, texcoord = nil}, + {value = "DIALOG", label = "Dialog", onclick = setWindowStrataCallback, icon = [[Interface\Buttons\UI-MicroStream-Red]] , iconcolor = {1, 0, 0, 1}, texcoord = nil}, } + -- - local set_attribute= function (_, _, value) + + local setTextPerSecondTypeCallback = function(_, _, value) StreamOverlay.db.per_second.attribute_type = value end local attributeTable = { - {value = 1, label = "DPS", onclick = set_attribute}, - {value = 2, label = "HPS", onclick = set_attribute}, + {value = 1, label = "DPS", onclick = setTextPerSecondTypeCallback}, + {value = 2, label = "HPS", onclick = setTextPerSecondTypeCallback}, + } + + -- + + local squareGrowOptions = { + {value = "right", label = "RIGHT", onclick = function() StreamOverlay.db.square_grow_direction = "right"; StreamOverlay:ReorderSquares() end}, + {value = "left", label = "LEFT", onclick = function() StreamOverlay.db.square_grow_direction = "left"; StreamOverlay:ReorderSquares() end}, } local options = { @@ -2067,9 +2094,16 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "Square Size", name = "Square Size", }, + { + type = "select", + get = function() return StreamOverlay.db.square_grow_direction end, + values = function() return squareGrowOptions end, + desc = "Square Direction", + name = "Square Direction", + }, {type = "blank"}, - + { type = "select", get = function() return StreamOverlay.db.arrow_texture end, @@ -2077,7 +2111,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "The icon used on the middle of the bar", name = "Arrow Icon" }, - + { type = "range", get = function() return StreamOverlay.db.arrow_size end, @@ -2088,7 +2122,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) desc = "The size of the arrow.", name = "Arrow Size", }, - + { type = "color", get = function() return StreamOverlay.db.arrow_color end, @@ -2171,12 +2205,11 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) } - fw:BuildMenu (optionsFrame, options, 15, -235, 860, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template) + detailsFramework:BuildMenu(optionsFrame, options, 15, -235, 860, true, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template) --select profile dropdown - local select_profile = function (_, _, profileName) - - local pname = UnitName ("player") .. " - " .. GetRealmName() + local selectProfile = function(_, _, profileName) + local pname = UnitName("player") .. " - " .. GetRealmName() --> save the current config on the profile local current_profile = Details_StreamerDB.characters [pname] @@ -2213,7 +2246,7 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) local select_profile_fill = function() local t = {} for profileName, _ in pairs (Details_StreamerDB.profiles) do - t [#t+1] = {value = profileName, label = profileName, onclick = select_profile} + t [#t+1] = {value = profileName, label = profileName, onclick = selectProfile} end return t end @@ -2308,8 +2341,8 @@ function StreamOverlay.OpenOptionsPanel (from_options_panel) end StreamOverlayOptionsPanel:Show() - StreamOverlay.FromOptionsPanel = from_options_panel - if (from_options_panel) then + StreamOverlay.FromOptionsPanel = fromOptionsPanel + if (fromOptionsPanel) then if (DetailsOptionsWindow) then C_Timer.After (0.2, function() DetailsOptionsWindow:Hide() @@ -2326,7 +2359,7 @@ function StreamOverlay:OnEvent (_, event, ...) local AddonName = select (1, ...) if (AddonName == "Details_Streamer") then - player_name = UnitName ("player") + playerName = UnitName ("player") if (_G._detalhes) then @@ -2345,6 +2378,7 @@ function StreamOverlay:OnEvent (_, event, ...) use_square_mode = false, square_size = 32, square_amount = 5, + square_grow_direction = "right", main_frame_locked = false, main_frame_color = {0, 0, 0, .2}, @@ -2366,8 +2400,6 @@ function StreamOverlay:OnEvent (_, event, ...) minimap = {hide = false, radius = 160, minimapPos = 160}, - grow_direction = "right", - use_spark = true, per_second = {