More development on the Coach packager feature, /details coach

This commit is contained in:
Tercio Jose
2020-12-06 14:14:51 -03:00
parent 3af27dc7b1
commit 0ca2822753
5 changed files with 313 additions and 280 deletions
+1 -1
View File
@@ -429,7 +429,7 @@
if (UnitIsGroupLeader("player")) then
if (Details.Coach.Server.IsEnabled()) then
--update the current combat with new information
Details.packFunctions.DeployUnpackedCombatData(data)
Details.packFunctions.DeployPackedCombatData(data)
end
end
end
+75 -126
View File
@@ -7,35 +7,26 @@ local _
local gump = _detalhes.gump
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
local atributos = _detalhes.atributos
local sub_atributos = _detalhes.sub_atributos
local segmentos = _detalhes.segmentos
--lua locals
local _cstr = tostring
local _math_ceil = math.ceil
local _math_floor = math.floor
local _math_max = math.max
local _ipairs = ipairs
local _pairs = pairs
local abs = _G.abs
local _string_lower = string.lower
local _unpack = unpack
--api locals
local CreateFrame = CreateFrame
local _GetTime = GetTime
local _GetCursorPosition = GetCursorPosition
local _GameTooltip = GameTooltip
local _UIParent = UIParent
local _GetScreenWidth = GetScreenWidth
local _GetScreenHeight = GetScreenHeight
local _IsAltKeyDown = IsAltKeyDown
local _IsShiftKeyDown = IsShiftKeyDown
local _IsControlKeyDown = IsControlKeyDown
local modo_raid = _detalhes._detalhes_props["MODO_RAID"]
local modo_alone = _detalhes._detalhes_props["MODO_ALONE"]
local modo_grupo = _detalhes._detalhes_props["MODO_GROUP"]
local modo_all = _detalhes._detalhes_props["MODO_ALL"]
local IsInInstance = _G.IsInInstance
local tok_functions = _detalhes.ToKFunctions
@@ -46,8 +37,7 @@ local gump_fundo_backdrop = {
bgFile = [[Interface\AddOns\Details\images\background]], tile = true, tileSize = 16,
insets = {left = 0, right = 0, top = 0, bottom = 0}}
function _detalhes:ScheduleUpdate (instancia)
function _detalhes:ScheduleUpdate (instancia)
instancia.barraS = {nil, nil}
instancia.update = true
if (instancia.showing) then
@@ -62,66 +52,30 @@ function _detalhes:ScheduleUpdate (instancia)
end
--> skins TCoords
-- 0.00048828125
local DEFAULT_SKIN = [[Interface\AddOns\Details\images\skins\classic_skin]]
--local COORDS_LEFT_BALL = {0.15673828125, 0.27978515625, 0.08251953125, 0.20556640625} -- 160 84 287 211 (updated)
--local COORDS_LEFT_BALL = {0.15576171875, 0.27978515625, 0.08251953125, 0.20556640625} -- 160 84 287 211 (updated)
local COORDS_LEFT_BALL = {0.15625, 0.2802734375, 0.08203125, 0.2060546875} -- 160 287 84 211
--local COORDS_LEFT_CONNECTOR = {0.29541015625, 0.30126953125, 0.08251953125, 0.20556640625} --302 84 309 211 (updated)
local COORDS_LEFT_CONNECTOR = {0.294921875, 0.3017578125, 0.08203125, 0.2060546875} --302 84 309 211 (updated)
--local COORDS_LEFT_CONNECTOR_NO_ICON = {0.58837890625, 0.59423828125, 0.08251953125, 0.20556640625} -- 602 84 609 211 (updated)
local COORDS_LEFT_CONNECTOR_NO_ICON = {0.587890625+0.00048828125, 0.5947265625, 0.08203125, 0.2060546875} -- 602 609 x 84 211
--local COORDS_TOP_BACKGROUND = {0.15673828125, 0.65478515625, 0.22314453125, 0.34619140625} -- 160 228 671 355 (updated)
local COORDS_TOP_BACKGROUND = {0.15625, 0.6552734375, 0.22265625, 0.3466796875} -- 160 671 x 228 355
--local COORDS_RIGHT_BALL = {0.31591796875, 0.43994140625, 0.08251953125, 0.20556640625} --324 84 451 211 (updated)
--local COORDS_RIGHT_BALL = {0.3154296875+0.00048828125, 0.439453125+0.00048828125, 0.08203125, 0.2060546875-0.00048828125} --323 84 450 211 (updated)
local COORDS_RIGHT_BALL = {0.3154296875, 0.439453125, 0.08203125, 0.2060546875} -- 323 450 x 84 211
--local COORDS_LEFT_BALL_NO_ICON = {0.44970703125, 0.57275390625, 0.08251953125, 0.20556640625} --460 84 587 211 (updated)
--local COORDS_LEFT_BALL_NO_ICON = {0.44921875, 0.57421875, 0.08203125, 0.20703125} --460 84 588 212 (updated)
--local COORDS_LEFT_BALL_NO_ICON = {0.44970703125, 0.57275390625, 0.08251953125, 0.20556640625} --460 84 587 211 (updated) 588 212
local COORDS_LEFT_BALL_NO_ICON = {0.44921875, 0.5732421875, 0.08203125, 0.2060546875} -- 460 587 84 211
--local COORDS_LEFT_SIDE_BAR = {0.76611328125, 0.82763671875, 0.00244140625, 0.50146484375} -- 784 2 848 514 (updated)
local COORDS_LEFT_SIDE_BAR = {0.765625, 0.828125, 0.001953125, 0.501953125} -- 784 2 848 514 (updated)
--local COORDS_RIGHT_SIDE_BAR = {0.70068359375, 0.76220703125, 0.00244140625, 0.50146484375} -- 717 2 781 514 (updated)
--local COORDS_RIGHT_SIDE_BAR = {0.7001953125, 0.763671875, 0.00244140625, 0.50146484375} -- 717 2 781 514 (updated)
--local COORDS_RIGHT_SIDE_BAR = {0.7001953125+0.00048828125, 0.76171875, 0.001953125, 0.5009765625} -- --717 2 780 513
local COORDS_RIGHT_SIDE_BAR = {0.7001953125, 0.7626953125, 0.001953125, 0.501953125} -- --717 2 781 513
local COORDS_BOTTOM_SIDE_BAR = {0.32861328125, 0.82666015625, 0.50537109375, 0.56494140625} -- 336 517 847 579 (updated)
local COORDS_SLIDER_TOP = {0.00146484375, 0.03076171875, 0.00244140625, 0.03173828125} -- 1 2 32 33 -ok
local COORDS_SLIDER_MIDDLE = {0.00146484375, 0.03076171875, 0.03955078125, 0.10009765625} -- 1 40 32 103 -ok
local COORDS_SLIDER_DOWN = {0.00146484375, 0.03076171875, 0.10986328125, 0.13916015625} -- 1 112 32 143 -ok
--local COORDS_STRETCH = {0.00146484375, 0.03076171875, 0.21435546875, 0.22802734375} -- 1 219 32 234 -ok
local COORDS_STRETCH = {0.0009765625, 0.03125, 0.2138671875, 0.228515625} -- 1 32 219 234
local COORDS_RESIZE_RIGHT = {0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375} -- 1 251 16 266 -ok
local COORDS_RESIZE_LEFT = {0.02001953125, 0.03173828125, 0.24560546875, 0.25927734375} -- 20 251 33 266 -ok
local COORDS_UNLOCK_BUTTON = {0.00146484375, 0.01513671875, 0.27197265625, 0.28564453125} -- 1 278 16 293 -ok
local COORDS_BOTTOM_BACKGROUND = {0.15673828125, 0.65478515625, 0.35400390625, 0.47705078125} -- 160 362 671 489 -ok
local COORDS_PIN_LEFT = {0.00146484375, 0.03076171875, 0.30126953125, 0.33056640625} -- 1 308 32 339 -ok
local COORDS_PIN_RIGHT = {0.03564453125, 0.06494140625, 0.30126953125, 0.33056640625} -- 36 308 67 339 -ok
-- icones: 365 = 0.35693359375 // 397 = 0.38720703125
local menus_backdrop = {
edgeFile = [[Interface\Buttons\WHITE8X8]],
edgeSize=1,
--bgFile="Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
--bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
bgFile = [[Interface\AddOns\Details\images\background]],
tileSize=16,
tile=true,
@@ -132,7 +86,6 @@ end
local menus_bordercolor = {0, 0, 0, .25}
--menus are ignoring the value set on the profile
_detalhes.menu_backdrop_config = {
menus_backdrop = menus_backdrop,
menus_backdropcolor = menus_backdropcolor,
@@ -141,7 +94,7 @@ end
}
function _detalhes:RefreshScrollBar (x) --> x = quantas barras esta sendo mostrado
function _detalhes:RefreshScrollBar(x) --> x = quantas barras esta sendo mostrado
local cabe = self.rows_fit_in_window --> quantas barras cabem na janela
@@ -174,7 +127,7 @@ function _detalhes:RefreshScrollBar (x) --> x = quantas barras esta sendo mostra
local nao_mostradas = self.rows_showing - self.rows_fit_in_window
local slider_height = nao_mostradas*self.row_height
self.scroll.scrollMax = slider_height
self.scroll:SetMinMaxValues (0, slider_height)
self.scroll:SetMinMaxValues(0, slider_height)
else --> diminuiu a quantidade, acontece depois de uma coleta de lixo
self.rows_showing = x
@@ -188,7 +141,6 @@ function _detalhes:RefreshScrollBar (x) --> x = quantas barras esta sendo mostra
self.scroll.scrollMax = slider_height
self.scroll:SetMinMaxValues (0, slider_height)
end
end
end
@@ -199,13 +151,15 @@ function _detalhes:RefreshScrollBar (x) --> x = quantas barras esta sendo mostra
end
end
--> self a janela das barras
--> self é a janela das barras
local function move_barras (self, elapsed)
self._move_func.time = self._move_func.time+elapsed
if (self._move_func.time > 0.01) then
if (self._move_func.instancia.bgdisplay_loc == self._move_func._end) then --> se o tamanho atual igual ao final declarado
self:SetScript ("OnUpdate", nil)
self._move_func = nil
else
self._move_func.time = 0
self._move_func.instancia.bgdisplay_loc = self._move_func.instancia.bgdisplay_loc + self._move_func.inc --> inc -1 ou 1 e ir crescer ou diminuir a janela
@@ -213,8 +167,8 @@ local function move_barras (self, elapsed)
for index = 1, self._move_func.instancia.rows_fit_in_window do
self._move_func.instancia.barras [index]:SetWidth (self:GetWidth()+self._move_func.instancia.bgdisplay_loc-3)
end
self._move_func.instancia.bgdisplay:SetPoint ("bottomright", self, "bottomright", self._move_func.instancia.bgdisplay_loc, 0)
self._move_func.instancia.bar_mod = self._move_func.instancia.bgdisplay_loc+(-3)
--> verifica o tamanho do text
@@ -245,6 +199,7 @@ function _detalhes:MoveBarrasTo (destino)
janela:SetScript ("OnUpdate", move_barras)
end
--almost deprecated
function _detalhes:MostrarScrollBar (sem_animacao)
if (self.rolagem) then
@@ -267,7 +222,7 @@ function _detalhes:MostrarScrollBar (sem_animacao)
else
--> set size of rows
for index = 1, self.rows_fit_in_window do
self.barras [index]:SetWidth (self.baseframe:GetWidth()+mover_para -3) --> -3 distance between row end and scroll start
self.barras[index]:SetWidth (self.baseframe:GetWidth()+mover_para -3) --> -3 distance between row end and scroll start
end
--> move the semi-background to the left (which moves the scroll)
self.bgdisplay:SetPoint ("bottomright", self.baseframe, "bottomright", mover_para, 0)
@@ -300,6 +255,7 @@ function _detalhes:MostrarScrollBar (sem_animacao)
end
--almost deprecated
function _detalhes:EsconderScrollBar (sem_animacao, force)
if (not self.rolagem) then
@@ -483,65 +439,7 @@ _detalhes.VPT, _detalhes.VPR, _detalhes.VPB, _detalhes.VPL = VPT, VPR, VPB, VPL
local color_red = {1, 0.2, 0.2}
local color_green = {0.2, 1, 0.2}
local update_line = function (self, target_frame)
--> based on weak auras frame movement code
--local selfX, selfY = target_frame:GetCenter()
local selfX, selfY = target_frame.instance:GetPositionOnScreen()
--local anchorX, anchorY = self:GetCenter()
local anchorX, anchorY = self.instance:GetPositionOnScreen()
selfX, selfY = selfX or 0, selfY or 0
anchorX, anchorY = anchorX or 0, anchorY or 0
local dX = selfX - anchorX
local dY = selfY - anchorY
local distance = sqrt (dX^2 + dY^2)
local angle = atan2(dY, dX)
local numInterim = floor(distance/40)
local guide_balls = _detalhes.guide_balls
if (not guide_balls) then
_detalhes.guide_balls = {}
guide_balls = _detalhes.guide_balls
end
for index, ball in ipairs (guide_balls) do
ball:Hide()
end
self.instance:AtualizaPontos()
target_frame.instance:AtualizaPontos()
local color = color_red
local _R, _T, _L, _B = VPL (self.instance, target_frame.instance), VPB (self.instance, target_frame.instance), VPR (self.instance, target_frame.instance), VPT (self.instance, target_frame.instance)
if (_R or _T or _L or _B) then
color = color_green
end
for i = 0, numInterim do
local x = (distance - (i * 40)) * cos (angle)
local y = (distance - (i * 40)) * sin (angle)
local ball = guide_balls [i]
if (not ball) then
ball = _detalhes.overlay_frame:CreateTexture (nil, "Overlay")
ball:SetTexture ([[Interface\AddOns\Details\images\icons]])
ball:SetSize (16, 16)
ball:SetAlpha (0.3)
ball:SetTexCoord (410/512, 426/512, 2/512, 18/512)
tinsert (guide_balls, ball)
end
ball:ClearAllPoints()
ball:SetPoint("CENTER", self, "CENTER", x, y) --baseframse center
ball:Show()
ball:SetVertexColor (unpack (color))
end
end
local pixels_per_arrow = 50
local show_instance_ids = function()
@@ -594,10 +492,65 @@ local show_instance_ids = function()
instance.baseframe.id_texture1:Show()
instance.baseframe.id_texture2:Hide()
end
end
end
end
local update_line = function (self, target_frame)
local target_instance_PosX, target_instance_PosY = target_frame.instance:GetPositionOnScreen()
local moving_instance_PosX, moving_instance_PosY = self.instance:GetPositionOnScreen()
target_instance_PosX = target_instance_PosX or 0
target_instance_PosY = target_instance_PosY or 0
moving_instance_PosX = moving_instance_PosX or 0
moving_instance_PosY = moving_instance_PosY or 0
local dX = target_instance_PosX - moving_instance_PosX
local dY = target_instance_PosY - moving_instance_PosY
local distance = (dX^2 + dY^2) ^ 0.5
local angle = atan2(dY, dX)
local guide_balls = _detalhes.guide_balls
if (not guide_balls) then
_detalhes.guide_balls = {}
guide_balls = _detalhes.guide_balls
end
for index, ball in ipairs (guide_balls) do
ball:Hide()
end
self.instance:AtualizaPontos()
target_frame.instance:AtualizaPontos()
local color = color_red
local _R, _T, _L, _B = VPL (self.instance, target_frame.instance), VPB (self.instance, target_frame.instance), VPR (self.instance, target_frame.instance), VPT (self.instance, target_frame.instance)
if (_R or _T or _L or _B) then
color = color_green
end
for i = 0, (distance/pixels_per_arrow) do
local x = distance - (i * pixels_per_arrow)
x = x * cos(angle)
local y = distance - (i * pixels_per_arrow)
y = y * sin(angle)
local ball = guide_balls [i]
if (not ball) then
ball = _detalhes.overlay_frame:CreateTexture (nil, "Overlay")
ball:SetTexture ([[Interface\AddOns\Details\images\icons]])
ball:SetSize (16, 16)
ball:SetAlpha (0.3)
ball:SetTexCoord (410/512, 426/512, 2/512, 18/512)
tinsert (guide_balls, ball)
end
ball:ClearAllPoints()
ball:SetPoint("CENTER", self, "CENTER", x, y) --baseframse center
ball:Show()
ball:SetVertexColor (unpack (color))
end
end
local tempo_movendo, precisa_ativar, instancia_alvo, tempo_fades, nao_anexados, flash_bounce, start_draw_lines, instance_ids_shown, need_show_group_guide
@@ -7543,6 +7496,14 @@ function _detalhes:AdjustAlphaByContext(interacting)
end
end
function _detalhes:LeftMenuAnchorSide (side)
if (not side) then
side = self.menu_anchor.side
end
self.menu_anchor.side = side
return self:MenuAnchor()
end
function _detalhes:SetFrameStrata (strata)
@@ -7590,18 +7551,6 @@ function _detalhes:SetFrameStrata (strata)
self:StretchButtonAlwaysOnTop()
end
function _detalhes:LeftMenuAnchorSide (side)
if (not side) then
side = self.menu_anchor.side
end
self.menu_anchor.side = side
return self:MenuAnchor()
end
-- ~attributemenu (text with attribute name)
function _detalhes:RefreshAttributeTextSize()
if (self.attribute_text.enabled and self.total_buttons_shown and self.baseframe and self.menu_attribute_string) then
+20 -20
View File
@@ -35,21 +35,21 @@ Details.Coach = {
function Details.Coach.AskRLForCoachStatus(raidLeaderName)
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CIEA"), "WHISPER", raidLeaderName)
if (_detalhes.debug) then
Details:Msg("asked the raid leader the coach status.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] asked the raid leader the coach status.")
end
end
function Details.Coach.SendRLCombatStartNotify(raidLeaderName)
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CCS"), "WHISPER", raidLeaderName)
if (_detalhes.debug) then
Details:Msg("sent to raid leader a combat start notification.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid leader a combat start notification.")
end
end
function Details.Coach.SendRLCombatEndNotify(raidLeaderName)
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CCE"), "WHISPER", raidLeaderName)
if (_detalhes.debug) then
Details:Msg("sent to raid leader a combat end notification.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid leader a combat end notification.")
end
end
@@ -57,7 +57,7 @@ end
function Details.Coach.SendRaidCoachEndNotify()
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CE"), "RAID")
if (_detalhes.debug) then
Details:Msg("sent to raid a coach end notification.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid a coach end notification.")
end
end
@@ -65,7 +65,7 @@ end
function Details.Coach.SendRaidCoachStartNotify()
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, UnitName("player"), GetRealmName(), Details.realversion, "CS"), "RAID")
if (_detalhes.debug) then
Details:Msg("sent to raid a coach start notification.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent to raid a coach start notification.")
end
end
@@ -98,7 +98,7 @@ function Details.Coach.StartUp()
if (raidLeaderName) then
--client ask for the raid leader if the Coach is enabled, GetRaidLeader returns nil is the user isn't in raid
if (_detalhes.debug) then
Details:Msg("sent ask to raid leader, is coach?")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
end
Details.Coach.AskRLForCoachStatus(raidLeaderName)
end
@@ -117,7 +117,7 @@ function Details.Coach.StartUp()
local raidLeaderName = Details:GetRaidLeader()
if (raidLeaderName) then
if (_detalhes.debug) then
Details:Msg("sent ask to raid leader, is coach?")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
end
Details.Coach.AskRLForCoachStatus(raidLeaderName)
end
@@ -142,7 +142,7 @@ function Details.Coach.StartUp()
local raidLeaderName = Details.Coach.Client.GetLeaderName()
if (raidLeaderName) then
if (_detalhes.debug) then
Details:Msg("i'm a raid assistant, sent combat start notification to raid leader.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] i'm a raid assistant, sent combat start notification to raid leader.")
end
Details.Coach.SendRLCombatStartNotify(raidLeaderName)
end
@@ -165,7 +165,7 @@ function Details.Coach.StartUp()
local raidLeaderName = Details.Coach.Client.GetLeaderName()
if (raidLeaderName) then
if (_detalhes.debug) then
Details:Msg("i'm a raid assistant, sent combat end notification to raid leader.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] i'm a raid assistant, sent combat end notification to raid leader.")
end
Details.Coach.SendRLCombatEndNotify(raidLeaderName)
end
@@ -183,7 +183,7 @@ function Details.Coach.StartUp()
--the raid leader entered a raid instance
Details.Coach.Disable()
if (_detalhes.debug) then
Details:Msg("Coach feature stopped: you entered in a raid instance.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] Coach feature stopped: you entered in a raid instance.")
end
end
return
@@ -194,7 +194,7 @@ function Details.Coach.StartUp()
if (not Details.Coach.Server.IsEnabled()) then --the coach feature isn't running
Details.Coach.Server.EnableCoach()
if (_detalhes.debug) then
Details:Msg("Coach feature is now running, if this come as surprise, use '/details coach' to disable.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] Coach feature is now running, if this come as surprise, use '/details coach' to disable.")
end
end
end
@@ -210,7 +210,7 @@ function Details.Coach.StartUp()
local raidLeaderName = Details:GetRaidLeader()
if (raidLeaderName) then
if (_detalhes.debug) then
Details:Msg("sent ask to raid leader, is coach?")
Details:Msg("[|cFFAAFFAADetails! Coach|r] sent ask to raid leader, is coach?")
end
Details.Coach.AskRLForCoachStatus(raidLeaderName)
return
@@ -267,7 +267,7 @@ end
function Details.Coach.Server.EnableCoach(fromStartup)
if (not IsInRaid()) then
if (_detalhes.debug) then
Details:Msg("cannot enabled coach: not in raid.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: not in raid.")
end
Details.coach.enabled = false
Details.Coach.Server.enabled = false
@@ -275,7 +275,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
elseif (not UnitIsGroupLeader("player")) then
if (_detalhes.debug) then
Details:Msg("cannot enabled coach: you aren't the raid leader.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: you aren't the raid leader.")
end
Details.coach.enabled = false
Details.Coach.Server.enabled = false
@@ -283,7 +283,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
elseif (isInRaidZone()) then
if (_detalhes.debug) then
Details:Msg("cannot enabled coach: you are inside a raid zone.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] cannot enabled coach: you are inside a raid zone.")
end
Details.coach.enabled = false
Details.Coach.Server.enabled = false
@@ -301,7 +301,7 @@ function Details.Coach.Server.EnableCoach(fromStartup)
if (fromStartup) then
if (_detalhes.debug) then
Details:Msg("coach feature enabled, welcome back captain!")
Details:Msg("[|cFFAAFFAADetails! Coach|r] coach feature enabled, welcome back captain!")
end
end
end
@@ -335,7 +335,7 @@ function Details.Coach.Client.EnableCoach(raidLeaderName)
Details.Coach.EventFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
if (_detalhes.debug) then
Details:Msg("there's a new coach: ", raidLeaderName)
Details:Msg("[|cFFAAFFAADetails! Coach|r] there's a new coach: ", raidLeaderName)
end
end
@@ -396,7 +396,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
if (_G.Ambiguate(unitName .. "-" .. GetRealmName(), "none") ~= Details.Coach.Client.coachName) then
--the raid leader has changed, finish the coach feature on the client
if (_detalhes.debug) then
Details:Msg("raid leader has changed, coach feature has been disabled.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] raid leader has changed, coach feature has been disabled.")
end
Details.Coach.Client.CoachEnd()
end
@@ -413,7 +413,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
if (IsInRaid()) then
if (not isInRaidZone()) then
if (_detalhes.debug) then
Details:Msg("you're now the coach of the group.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] you're now the coach of the group.")
end
--delay to set the new leader to give time for SendRaidCoachEndNotify()
_G.C_Timer.After(3, Details.Coach.Server.EnableCoach)
@@ -426,7 +426,7 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
if (Details.Coach.IsEnabled()) then
if (Details.Coach.Server.IsEnabled()) then
if (_detalhes.debug) then
Details:Msg("you're not the raid leader, disabling the coach feature.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] you're not the raid leader, disabling the coach feature.")
end
Details.Coach.Disable()
end
+213 -129
View File
@@ -50,6 +50,8 @@ local TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 6
local entitySerialCounter = 0
local isDebugging = true
function Dexport() --test case
local combat = Details:GetCurrentCombat()
local readyToSendData = Details.packFunctions.PackCombatData(combat, 0x1)
@@ -62,6 +64,15 @@ function Details.packFunctions.GetAllData()
return packedData
end
--debug
function Details.packFunctions.GetAllDataDebug()
local combat = Details:GetCurrentCombat()
local packedData = Details.packFunctions.PackCombatData(combat, 0x13)
--unpack data
Details.packFunctions.DeployPackedCombatData(packedData)
end
--pack the combat
function Details.packFunctions.PackCombatData(combatObject, flags)
@@ -92,6 +103,11 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
isBossEncouter and isBossEncouter.encounter or "Unknown Enemy" --5
}
--if there's no combat information, indexes for combat data is zero
if (bit.band(flags, 0x10) ~= 0) then
TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 0
end
if (bit.band(flags, 0x1) ~= 0) then
Details.packFunctions.PackDamage(combatObject)
end
@@ -326,11 +342,11 @@ function Details.packFunctions.AddActorInformation(actor)
local currentIndex = #actorInformation + 1
--calculate where this actor will be placed on the combatData table
local indexOnCombatDataTable = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + currentIndex
local indexOnCombatDataTable = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + currentIndex + 1
--add the actor start information index
actorInformationIndexes[actor.nome] = indexOnCombatDataTable
--index 1: actor name
actorInformation[currentIndex] = actor.nome or "unnamed" --[1]
@@ -381,6 +397,10 @@ end
--each player will also send an enemy, the enemy will be in order of raidIndex of the player
function Details.packFunctions.PackDamage(combatObject)
if (isDebugging) then
print("PackDamage(): START.")
end
--store actorObjects to pack
local actorsToPack = {}
@@ -388,6 +408,9 @@ function Details.packFunctions.PackDamage(combatObject)
local playerName = UnitName("player")
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_DAMAGE, playerName)
if (not playerObject) then
if (isDebugging) then
print("PackDamage(): RETURN | no player object.")
end
return
end
@@ -404,10 +427,9 @@ function Details.packFunctions.PackDamage(combatObject)
local playerIndex
--check if this player has to send information about an enemy npc
if (IsInRaid()) then
if (IsInGroup()) then
for i = 1, GetNumGroupMembers() do
local unitId = "raid" .. i
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
local name = GetRaidRosterInfo(i) --, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML
if (name == playerName) then
playerIndex = i
break
@@ -416,6 +438,9 @@ function Details.packFunctions.PackDamage(combatObject)
end
if (not playerIndex) then --no player index
if (isDebugging) then
print("PackDamage(): RETURN | no player index found.")
end
return
end
@@ -517,6 +542,10 @@ function Details.packFunctions.PackDamage(combatObject)
--amount of indexes spells are using
actorDamageInfo[reservedSpellSizeIndex] = totalSpellIndexes
end
if (isDebugging) then
print("PackDamage(): DONE.")
end
end
--------------------------------------------------------------------------------------------------------------------------------
@@ -526,6 +555,9 @@ end
--@combatData: array with strings with combat information
--@tablePosition: first index of the first damage actor
function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
if (isDebugging) then
print("UnPackDamage(): START.")
end
--get the damage container
local damageContainer = currentCombat[DETAILS_ATTRIBUTE_DAMAGE]
@@ -539,16 +571,23 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
local actorReference = tonumber(combatData[tablePosition]) --[1]
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
if (isDebugging) then
print("UnPackDamage(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
end
--check if all damage actors has been processed
--if there's no actor name it means it reached the end
if (not actorName) then
print("damage END index (debug):", i, actorReference, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
if (isDebugging) then
print("UnPackDamage(): BREAK damage END index:", i, actorReference, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
end
break
end
--get or create the actor object
local actorObject = damageContainer:GetOrCreateActor(serialNumber, actorName, actorFlag, true)
--set the actor class, spec and group
actorObject.classe = class
actorObject.spec = spec
actorObject.grupo = isActorInGroup(class, actorFlag)
@@ -586,10 +625,17 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
tablePosition = tablePosition + spellsSize --increase table position
end
if (isDebugging) then
print("UnPackDamage(): DONE.")
end
return tablePosition
end
function Details.packFunctions.PackHeal(combatObject)
if (isDebugging) then
print("PackHeal(): START.")
end
--store actorObjects to pack
local actorsToPack = {}
@@ -598,6 +644,9 @@ function Details.packFunctions.PackHeal(combatObject)
local playerName = UnitName("player")
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_HEAL, playerName)
if (not playerObject) then
if (isDebugging) then
print("PackHeal(): RETURN | no player object.")
end
return
end
@@ -614,10 +663,9 @@ function Details.packFunctions.PackHeal(combatObject)
local playerIndex
--check if this player has to send information about an enemy npc
if (IsInRaid()) then
if (IsInGroup()) then
for i = 1, GetNumGroupMembers() do
local unitId = "raid" .. i
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
local name = GetRaidRosterInfo(i)
if (name == playerName) then
playerIndex = i
break
@@ -626,6 +674,9 @@ function Details.packFunctions.PackHeal(combatObject)
end
if (not playerIndex) then
if (isDebugging) then
print("PackHeal(): RETURN | no player index found.")
end
return
end
@@ -726,7 +777,10 @@ function Details.packFunctions.PackHeal(combatObject)
--amount of indexes spells are using
actorDamageInfo[reservedSpellSizeIndex] = totalSpellIndexes
end
if (isDebugging) then
print("PackHeal(): DONE.")
end
end
@@ -734,17 +788,28 @@ end
--> unpack
function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
--get the damage container
if (isDebugging) then
print("UnPackHeal(): START.")
end
--get the healing container
local healContainer = currentCombat[DETAILS_ATTRIBUTE_HEAL]
for i = 1, 199 do
--this is the same as damage, all comments for the code are there
local actorInfoIndex = tonumber(combatData[tablePosition]) --[1]
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorInfoIndex)
local actorReference = tonumber(combatData[tablePosition]) --[1]
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
if (isDebugging) then
print("UnPackHeal(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
end
--if there's no actor name it means it reached the end
if (not actorName) then
print("Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
if (isDebugging) then
print("UnPackHeal(): BREAK | Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
end
break
end
@@ -788,125 +853,19 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi
tablePosition = tablePosition + spellsSize --increase table position
end
if (isDebugging) then
print("UnPackHeal(): DONE.")
end
return tablePosition
end
--what this function receives?
--@packedCombatData: packed combat, ready to be unpacked
function Details.packFunctions.UnPackCombatData(packedCombatData)
if (true) then
print("Details is calling the wrong function UnPackCombatData()")
return
end
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
--[=
local function count(text, pattern)
return select(2, text:gsub(pattern, ""))
end
--]=]
local combatData = {}
local amountOfIndexes = count(combatDataString, ",") + 1
print ("amountOfIndexes (debug):", amountOfIndexes)
while (amountOfIndexes > 0) do
local splitPart = {strsplit(",", combatDataString, 4000)} --strsplit(): Stack overflow, max allowed: 4000
if (#splitPart == 4000 and amountOfIndexes > 4000) then
print ("#combatDataString (debug) must be > 4000:", amountOfIndexes)
for i = 1, 3999 do
combatData[#combatData+1] = splitPart[i]
end
--get get part that couldn't be read this loop
combatDataString = splitPart[4000]
amountOfIndexes = amountOfIndexes - 3999
print ("#combatDataString (debug) left over:", amountOfIndexes)
else
for i = 1, #splitPart do
combatData[#combatData+1] = splitPart[i]
end
amountOfIndexes = amountOfIndexes - #splitPart
end
end
print("total indexes (debug):", #combatData)
--if true then return end
local flags = tonumber(combatData[INDEX_EXPORT_FLAG])
local tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1 --[[ +1 to jump to damage ]]
--tablePosition now have the first index of the actorInfoTable
--stop the combat if already in one
if (Details.in_combat) then
Details:EndCombat()
end
--start a new combat
Details:StartCombat()
--get the current combat
local currentCombat = Details:GetCurrentCombat()
--check if this export has include damage info
if (bit.band(flags, 0x1) ~= 0) then
--find the index where the damage information start
for i = tablePosition, #combatData do
if (combatData[i] == "!D") then
tablePosition = i + 1;
break
end
end
--unpack damage
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
end
if (bit.band(flags, 0x2) ~= 0) then
--find the index where the heal information start
for i = tablePosition, #combatData do
if (combatData[i] == "!H") then
tablePosition = i + 1;
break
end
end
--unpack heal
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
end
--all done, end combat
Details:EndCombat()
--set the start and end of combat time and date
currentCombat:SetStartTime(combatData[INDEX_COMBAT_START_TIME])
currentCombat:SetEndTime(combatData[INDEX_COMBAT_END_TIME])
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
--debug: delete the segment just created (debug)
--[[
local combat2 = _detalhes.tabela_historico.tabelas[2]
if (combat2) then
tremove (_detalhes.tabela_historico.tabelas, 1)
_detalhes.tabela_historico.tabelas[1] = combat2
_detalhes.tabela_vigente = combat2
end
--]]
end
--this function does the same as the function above but does not create a new combat, it just add new information
function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
function Details.packFunctions.DeployPackedCombatData(packedCombatData)
if (isDebugging) then
print("DeployPackedCombatData(): START.")
end
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
@@ -942,6 +901,7 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
if (bit.band(flags, 0x10) ~= 0) then
tablePosition = 2
TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 0 --there's no combat info, data starts after the dataFlag on position [1]
else
tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1
end
@@ -958,6 +918,11 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
break
end
end
if (isDebugging) then
print("DeployPackedCombatData(): data has damage info, Damage Index:", tablePosition)
end
--unpack damage
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
end
@@ -970,6 +935,11 @@ function Details.packFunctions.DeployUnpackedCombatData(packedCombatData)
break
end
end
if (isDebugging) then
print("DeployPackedCombatData(): data has healing info, Heal Index:", tablePosition)
end
--unpack heal
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
end
@@ -1039,3 +1009,117 @@ function Details.packFunctions.UnpackTable(table, index, isPair, valueAsTable, a
return result
end
--what this function receives?
--@packedCombatData: packed combat, ready to be unpacked
function Details.packFunctions.UnPackCombatData(packedCombatData)
if (true) then
print("Details is calling the wrong function UnPackCombatData()")
return
end
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
--[=
local function count(text, pattern)
return select(2, text:gsub(pattern, ""))
end
--]=]
local combatData = {}
local amountOfIndexes = count(combatDataString, ",") + 1
print ("amountOfIndexes (debug):", amountOfIndexes)
while (amountOfIndexes > 0) do
local splitPart = {strsplit(",", combatDataString, 4000)} --strsplit(): Stack overflow, max allowed: 4000
if (#splitPart == 4000 and amountOfIndexes > 4000) then
print ("#combatDataString (debug) must be > 4000:", amountOfIndexes)
for i = 1, 3999 do
combatData[#combatData+1] = splitPart[i]
end
--get get part that couldn't be read this loop
combatDataString = splitPart[4000]
amountOfIndexes = amountOfIndexes - 3999
print ("#combatDataString (debug) left over:", amountOfIndexes)
else
for i = 1, #splitPart do
combatData[#combatData+1] = splitPart[i]
end
amountOfIndexes = amountOfIndexes - #splitPart
end
end
print("total indexes (debug):", #combatData)
--if true then return end
local flags = tonumber(combatData[INDEX_EXPORT_FLAG])
local tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1 --[[ +1 to jump to damage ]] --DEPRECATED FUNC
--tablePosition now have the first index of the actorInfoTable
--stop the combat if already in one
if (Details.in_combat) then
Details:EndCombat()
end
--start a new combat
Details:StartCombat()
--get the current combat
local currentCombat = Details:GetCurrentCombat()
--check if this export has include damage info
if (bit.band(flags, 0x1) ~= 0) then
--find the index where the damage information start
for i = tablePosition, #combatData do
if (combatData[i] == "!D") then
tablePosition = i + 1;
break
end
end
--unpack damage
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
end
if (bit.band(flags, 0x2) ~= 0) then
--find the index where the heal information start
for i = tablePosition, #combatData do
if (combatData[i] == "!H") then
tablePosition = i + 1;
break
end
end
--unpack heal
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
end
--all done, end combat
Details:EndCombat()
--set the start and end of combat time and date
currentCombat:SetStartTime(combatData[INDEX_COMBAT_START_TIME])
currentCombat:SetEndTime(combatData[INDEX_COMBAT_END_TIME])
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
--debug: delete the segment just created (debug)
--[[
local combat2 = _detalhes.tabela_historico.tabelas[2]
if (combat2) then
tremove (_detalhes.tabela_historico.tabelas, 1)
_detalhes.tabela_historico.tabelas[1] = combat2
_detalhes.tabela_vigente = combat2
end
--]]
end
+4 -4
View File
@@ -1594,10 +1594,10 @@ Damage Update Status: @INSTANCEDAMAGESTATUS
Details.coach.enabled = not Details.coach.enabled
if (Details.coach.enabled) then
Details:Msg("coach enabled, good luck!")
Details:Msg("[raid leader] stay outside the raid.")
Details:Msg("[assistants] at least one player inside the raid need to have assistant.")
Details:Msg("[players] have an updated version of Details!.")
Details:Msg("Details! Coach enabled, good luck commander!")
Details:Msg("[|cFFAAFFAADetails! Coach|r] raid leader stay outside the raid.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] assistants, at least one player inside the raid need to have assistant.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] players have an updated version of Details!.")
Details.Coach.Server.EnableCoach()
else