You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3629 lines
111 KiB

3 years ago
local AceLocale = LibStub("AceLocale-3.0")
4 years ago
local Loc = AceLocale:GetLocale ( "Details" )
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
3 years ago
local type= type --lua local
local ipairs = ipairs --lua local
local pairs = pairs --lua local
local _math_floor = math.floor --lua local
local abs = math.abs --lua local
local _table_remove = table.remove --lua local
local _getmetatable = getmetatable --lua local
local setmetatable = setmetatable --lua local
3 years ago
local _string_len = string.len --lua local
local _unpack = unpack --lua local
local _cstr = string.format --lua local
local _SendChatMessage = SendChatMessage --wow api locals
local _GetChannelName = GetChannelName --wow api locals
local _UnitExists = UnitExists --wow api locals
local _UnitName = UnitName --wow api locals
local _UnitIsPlayer = UnitIsPlayer --wow api locals
local _UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned --wow api locals
4 years ago
local _detalhes = _G._detalhes
local gump = _detalhes.gump
local historico = _detalhes.historico
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 _
local atributos = _detalhes.atributos
local sub_atributos = _detalhes.sub_atributos
local segmentos = _detalhes.segmentos
3 years ago
--STARTUP reativa as instancias e regenera as tabelas das mesmas
4 years ago
function _detalhes:RestartInstances()
return _detalhes:ReativarInstancias()
end
3 years ago
4 years ago
function _detalhes:ReativarInstancias()
3 years ago
4 years ago
_detalhes.opened_windows = 0
3 years ago
--set metatables
for index = 1, #_detalhes.tabela_instancias do
4 years ago
local instancia = _detalhes.tabela_instancias [index]
if (not _getmetatable (instancia)) then
setmetatable(_detalhes.tabela_instancias[index], _detalhes)
4 years ago
end
end
3 years ago
--create frames
for index = 1, #_detalhes.tabela_instancias do
4 years ago
local instancia = _detalhes.tabela_instancias [index]
if (instancia:IsEnabled()) then
_detalhes.opened_windows = _detalhes.opened_windows + 1
instancia:RestauraJanela (index, nil, true)
else
instancia.iniciada = false
end
end
3 years ago
--load
for index = 1, #_detalhes.tabela_instancias do
4 years ago
local instancia = _detalhes.tabela_instancias [index]
if (instancia:IsEnabled()) then
instancia.iniciada = true
instancia:AtivarInstancia()
instancia:ChangeSkin()
end
end
3 years ago
--send open event
for index = 1, #_detalhes.tabela_instancias do
4 years ago
local instancia = _detalhes.tabela_instancias [index]
if (instancia:IsEnabled()) then
if (not _detalhes.initializing) then
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_OPEN", nil, instancia)
4 years ago
end
end
end
end
3 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------
3 years ago
--API: call a function to all enabled instances
function _detalhes:InstanceCall(funcao, ...)
if (type(funcao) == "string") then
4 years ago
funcao = _detalhes [funcao]
end
3 years ago
for index, instance in ipairs(_detalhes.tabela_instancias) do
if (instance:IsAtiva()) then --only enabled
4 years ago
funcao (instance, ...)
end
end
end
3 years ago
--chama a fun��o para ser executada em todas as inst�ncias (internal)
function _detalhes:InstanciaCallFunction(funcao, ...)
for index, instancia in ipairs(_detalhes.tabela_instancias) do
if (instancia:IsAtiva()) then --s� reabre se ela estiver ativa
4 years ago
funcao (_, instancia, ...)
end
end
end
3 years ago
--chama a fun��o para ser executada em todas as inst�ncias (internal)
4 years ago
function _detalhes:InstanciaCallFunctionOffline (funcao, ...)
3 years ago
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
funcao (_, instancia, ...)
end
end
function Details:InstanceGroupCall(instance, funcName, ...)
3 years ago
for _, thisInstance in ipairs(instance:GetInstanceGroup()) do
4 years ago
thisInstance[funcName](thisInstance, ...)
end
end
function Details:InstanceGroupEditSetting(instance, keyName, value)
3 years ago
for _, thisInstance in ipairs(instance:GetInstanceGroup()) do
4 years ago
thisInstance[keyName] = value
end
end
function Details:InstanceGroupEditSettingOnTable(instance, table1Key, table2Key, table3Key, value)
3 years ago
for _, thisInstance in ipairs(instance:GetInstanceGroup()) do
4 years ago
if (value == nil) then
local value1 = table3Key
local table1 = thisInstance[table1Key]
table1[table2Key] = value1
else
local table1 = thisInstance[table1Key]
table1[table2Key][table3Key] = value
end
end
end
function _detalhes:GetLowerInstanceNumber()
local lower = 999
3 years ago
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instancia.ativa and instancia.baseframe) then
if (instancia.meu_id < lower) then
lower = instancia.meu_id
end
end
end
if (lower == 999) then
_detalhes.lower_instance = 0
return nil
else
_detalhes.lower_instance = lower
return lower
end
end
function _detalhes:IsLowerInstance()
local lower = _detalhes:GetLowerInstanceNumber()
if (lower) then
return lower == self.meu_id
end
return false
end
function _detalhes:IsInteracting()
return self.is_interacting
end
function _detalhes:GetMode()
return self.modo
end
3 years ago
function _detalhes:GetInstance(id)
4 years ago
return _detalhes.tabela_instancias [id]
end
3 years ago
--user friendly alias
4 years ago
function _detalhes:GetWindow (id)
return _detalhes.tabela_instancias [id]
end
3 years ago
function Details:GetNumInstances()
return #_detalhes.tabela_instancias
end
4 years ago
function _detalhes:GetId()
return self.meu_id
end
function _detalhes:GetInstanceId()
return self.meu_id
end
function _detalhes:GetSegment()
return self.segmento
end
function _detalhes:GetSoloMode()
return _detalhes.tabela_instancias [_detalhes.solo]
end
function _detalhes:GetRaidMode()
return _detalhes.tabela_instancias [_detalhes.raid]
end
function _detalhes:IsSoloMode (offline)
if (offline) then
return self.modo == 1
end
if (not _detalhes.solo) then
return false
else
return _detalhes.solo == self:GetInstanceId()
end
end
function _detalhes:IsRaidMode()
return self.modo == _detalhes._detalhes_props["MODO_RAID"]
end
function _detalhes:IsGroupMode()
return self.modo == _detalhes._detalhes_props["MODO_GROUP"]
end
function _detalhes:IsNormalMode()
if (self:GetInstanceId() == 2 or self:GetInstanceId() == 3) then
return true
else
return false
end
end
function _detalhes:GetShowingCombat()
return self.showing
end
function _detalhes:GetCustomObject (object_name)
if (object_name) then
3 years ago
for _, object in ipairs(_detalhes.custom) do
4 years ago
if (object.name == object_name) then
return object
end
end
else
return _detalhes.custom [self.sub_atributo]
end
end
function _detalhes:ResetAttribute()
3 years ago
if (self.iniciada) then
self:TrocaTabela(nil, 1, 1, true)
4 years ago
else
self.atributo = 1
self.sub_atributo = 1
end
end
function _detalhes:ListInstances()
3 years ago
return ipairs(_detalhes.tabela_instancias)
4 years ago
end
function _detalhes:GetPosition()
return self.posicao
end
function _detalhes:GetDisplay()
return self.atributo, self.sub_atributo
end
function _detalhes:GetMaxInstancesAmount()
return _detalhes.instances_amount
end
function _detalhes:SetMaxInstancesAmount (amount)
3 years ago
if (type(amount) == "number") then
4 years ago
_detalhes.instances_amount = amount
end
end
function _detalhes:GetFreeInstancesAmount()
return _detalhes.instances_amount - #_detalhes.tabela_instancias
end
function _detalhes:GetOpenedWindowsAmount()
local amount = 0
for _, instance in _detalhes:ListInstances() do
if (instance:IsEnabled()) then
amount = amount + 1
end
end
return amount
end
function _detalhes:GetNumRows()
return self.rows_fit_in_window
end
function _detalhes:GetRow (index)
return self.barras [index]
end
function _detalhes:GetSkin()
return _detalhes.skins [self.skin]
end
function _detalhes:GetSkinTexture()
return _detalhes.skins [self.skin] and _detalhes.skins [self.skin].file
end
function Details:GetAllLines()
return self.barras
end
function Details:GetLine(lineId) --alias of _detalhes:GetRow(index)
return self.barras[lineId]
end
function Details:GetNumLinesShown() --alis of _detalhes:GetNumRows()
return self.rows_fit_in_window
end
3 years ago
--@attributeId: DETAILS_ATTRIBUTE_DAMAGE, DETAILS_ATTRIBUTE_HEAL
function Details:GetTop5Actors(attributeId)
local combatObject = self.showing
if (combatObject) then
local container = combatObject:GetContainer(attributeId)
if (container) then
local actorTable = container._ActorTable
return actorTable[1], actorTable[2], actorTable[3], actorTable[4], actorTable[5]
end
end
end
--@attributeId: DETAILS_ATTRIBUTE_DAMAGE, DETAILS_ATTRIBUTE_HEAL
--@rankIndex: the rank id of the actor shown in the window
function Details:GetActorByRank(attributeId, rankIndex)
local combatObject = self.showing
if (combatObject) then
local container = combatObject:GetContainer(attributeId)
if (container) then
return container._ActorTable[rankIndex]
end
end
--[=[
local firstRow = window1:GetLine(1)
if (firstRow and firstRow:IsShown()) then
local actor = firstRow:GetActor()
if (actor) then
local total = actor.total
local combatTime = Details:GetCurrentCombat():GetCombatTime()
print("dps:", total/combatTime)
end
end
local actorTable = container._ActorTable
for i = 1, #actorTable do
local actor = actorTable[rankIndex]
return actor
end
--]=]
end
4 years ago
------------------------------------------------------------------------------------------------------------------------
3 years ago
--retorna se a inst�ncia esta ou n�o ativa
4 years ago
function _detalhes:IsAtiva()
return self.ativa
end
3 years ago
--english alias
4 years ago
function _detalhes:IsShown()
return self.ativa
end
function _detalhes:IsEnabled()
return self.ativa
end
function _detalhes:IsStarted()
return self.iniciada
end
------------------------------------------------------------------------------------------------------------------------
function _detalhes:LoadLocalInstanceConfig()
local config = _detalhes.local_instances_config [self.meu_id]
if (config) then
3 years ago
4 years ago
if (not _detalhes.profile_save_pos) then
3 years ago
self.posicao = Details.CopyTable(config.pos)
4 years ago
end
3 years ago
if (type(config.attribute) ~= "number") then
4 years ago
config.attribute = 1
end
3 years ago
if (type(config.sub_attribute) ~= "number") then
4 years ago
config.sub_attribute = 1
end
3 years ago
if (type(config.segment) ~= "number") then
4 years ago
config.segment = 1
end
3 years ago
4 years ago
self.ativa = config.is_open
self.atributo = config.attribute
self.sub_atributo = config.sub_attribute
self.modo = config.mode
self.segmento = config.segment
3 years ago
self.snap = config.snap and Details.CopyTable(config.snap) or {}
4 years ago
self.horizontalSnap = config.horizontalSnap
self.verticalSnap = config.verticalSnap
3 years ago
self.sub_atributo_last = Details.CopyTable(config.sub_atributo_last)
4 years ago
self.isLocked = config.isLocked
self.last_raid_plugin = config.last_raid_plugin
end
end
function _detalhes:ShutDownAllInstances()
3 years ago
for index, instance in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instance:IsEnabled() and instance.baseframe and not instance.ignore_mass_showhide) then
instance:ShutDown(true)
end
end
end
3 years ago
--alias
4 years ago
function _detalhes:HideWindow(all)
return self:DesativarInstancia(all)
end
function _detalhes:ShutDown(all)
return self:DesativarInstancia(all)
end
function _detalhes:Shutdown(all)
return self:DesativarInstancia(all)
end
3 years ago
4 years ago
function _detalhes:GetNumWindows()
3 years ago
4 years ago
end
3 years ago
--desativando a inst�ncia ela fica em stand by e apenas hida a janela ~shutdown ~close ~fechar
4 years ago
function _detalhes:DesativarInstancia(all)
3 years ago
4 years ago
self.ativa = false
_detalhes.opened_windows = _detalhes.opened_windows-1
3 years ago
4 years ago
if (not self.baseframe) then
3 years ago
--windown isn't initialized yet
4 years ago
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) called HideWindow() but the window isn't initialized yet.")
4 years ago
end
return
end
3 years ago
4 years ago
local lower = _detalhes:GetLowerInstanceNumber()
_detalhes:GetLowerInstanceNumber()
3 years ago
4 years ago
if (lower == self.meu_id) then
3 years ago
--os icones dos plugins estao hostiados nessa instancia.
4 years ago
_detalhes.ToolBar:ReorganizeIcons (true) --n�o precisa recarregar toda a skin
end
3 years ago
4 years ago
if (_detalhes.switch.current_instancia and _detalhes.switch.current_instancia == self) then
_detalhes.switch:CloseMe()
end
3 years ago
4 years ago
self:ResetaGump()
3 years ago
Details.FadeHandler.Fader(self.baseframe.cabecalho.ball, 1)
Details.FadeHandler.Fader(self.baseframe, 1)
Details.FadeHandler.Fader(self.rowframe, 1)
Details.FadeHandler.Fader(self.windowSwitchButton, 1)
4 years ago
if (not all) then
self:Desagrupar (-1)
end
4 years ago
if (self.modo == modo_raid) then
_detalhes.RaidTables:DisableRaidMode (self)
3 years ago
4 years ago
elseif (self.modo == modo_alone) then
_detalhes.SoloTables:switch()
self.atualizando = false
_detalhes.solo = nil
end
3 years ago
4 years ago
if (not _detalhes.initializing) then
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CLOSE", nil, self)
4 years ago
end
end
3 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------
function _detalhes:InstanciaFadeBarras (instancia, segmento)
3 years ago
local _fadeType, _fadeSpeed = _unpack(_detalhes.row_fade_in)
4 years ago
if (segmento) then
if (instancia.segmento == segmento) then
3 years ago
return Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras")
4 years ago
end
else
3 years ago
return Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras")
4 years ago
end
end
function _detalhes:ToggleWindow (index)
3 years ago
local window = _detalhes:GetInstance(index)
4 years ago
if (window and _getmetatable (window)) then
if (window:IsEnabled()) then
window:ShutDown()
else
window:EnableInstance()
if (window.meu_id == 1) then
local instance2 = _detalhes:GetInstance(2)
if (instance2 and instance2:IsEnabled()) then
3 years ago
_detalhes.move_janela_func(instance2.baseframe, true, instance2, true)
_detalhes.move_janela_func(instance2.baseframe, false, instance2, true)
4 years ago
end
3 years ago
4 years ago
elseif (window.meu_id == 2) then
3 years ago
_detalhes.move_janela_func(window.baseframe, true, window, true)
_detalhes.move_janela_func(window.baseframe, false, window, true)
4 years ago
end
3 years ago
4 years ago
end
end
end
3 years ago
4 years ago
function _detalhes:CheckCoupleWindows (instance1, instance2)
3 years ago
instance1 = instance1 or _detalhes:GetInstance(1)
instance2 = instance2 or _detalhes:GetInstance(2)
4 years ago
if (instance1 and instance2 and not instance1.ignore_mass_showhide and not instance1.ignore_mass_showhide) then
3 years ago
4 years ago
instance1.baseframe:ClearAllPoints()
instance2.baseframe:ClearAllPoints()
3 years ago
4 years ago
instance1:RestoreMainWindowPosition()
instance2:RestoreMainWindowPosition()
3 years ago
4 years ago
instance1:AtualizaPontos()
instance2:AtualizaPontos()
3 years ago
4 years ago
local _R, _T, _L, _B = _detalhes.VPL (instance2, instance1), _detalhes.VPB (instance2, instance1), _detalhes.VPR (instance2, instance1), _detalhes.VPT (instance2, instance1)
3 years ago
4 years ago
if (_R) then
instance2:MakeInstanceGroup ({false, false, 1, false})
elseif (_T) then
instance2:MakeInstanceGroup ({false, false, false, 1})
elseif (_L) then
instance2:MakeInstanceGroup ({1, false, false, false})
elseif (_B) then
instance2:MakeInstanceGroup ({false, 1, false, false})
end
end
3 years ago
4 years ago
end
3 years ago
4 years ago
function _detalhes:ToggleWindows()
3 years ago
4 years ago
local instance
3 years ago
4 years ago
for i = 1, #_detalhes.tabela_instancias do
3 years ago
local this_instance = _detalhes:GetInstance(i)
4 years ago
if (this_instance and not this_instance.ignore_mass_showhide) then
instance = this_instance
break
end
end
3 years ago
4 years ago
if (instance) then
if (instance:IsEnabled()) then
_detalhes:ShutDownAllInstances()
else
_detalhes:ReabrirTodasInstancias()
3 years ago
4 years ago
local instance1 = _detalhes:GetInstance(1)
local instance2 = _detalhes:GetInstance(2)
3 years ago
4 years ago
if (instance1 and instance2) then
if (not Details.disable_window_groups) then
if (not instance1.ignore_mass_showhide and not instance2.ignore_mass_showhide) then
_detalhes:CheckCoupleWindows (instance1, instance2)
end
end
end
end
end
end
3 years ago
4 years ago
-- reabre todas as instancias
function _detalhes:ReabrirTodasInstancias (temp)
3 years ago
for index = math.min (#_detalhes.tabela_instancias, _detalhes.instances_amount), 1, -1 do
local instancia = _detalhes:GetInstance(index)
4 years ago
if (instancia and not instancia.ignore_mass_showhide) then
instancia:AtivarInstancia (temp, true)
end
end
end
3 years ago
4 years ago
function _detalhes:LockInstance (flag)
3 years ago
if (type(flag) == "boolean") then
4 years ago
self.isLocked = not flag
end
3 years ago
4 years ago
if (self.isLocked) then
self.isLocked = false
if (self.baseframe) then
self.baseframe.isLocked = false
3 years ago
self.baseframe.lock_button.label:SetText(Loc ["STRING_LOCK_WINDOW"])
self.baseframe.lock_button:SetWidth(self.baseframe.lock_button.label:GetStringWidth()+2)
self.baseframe.resize_direita:SetAlpha(0)
self.baseframe.resize_esquerda:SetAlpha(0)
4 years ago
self.baseframe.lock_button:ClearAllPoints()
3 years ago
self.baseframe.lock_button:SetPoint("right", self.baseframe.resize_direita, "left", -1, 1.5)
4 years ago
end
else
self.isLocked = true
if (self.baseframe) then
self.baseframe.isLocked = true
3 years ago
self.baseframe.lock_button.label:SetText(Loc ["STRING_UNLOCK_WINDOW"])
self.baseframe.lock_button:SetWidth(self.baseframe.lock_button.label:GetStringWidth()+2)
4 years ago
self.baseframe.lock_button:ClearAllPoints()
3 years ago
self.baseframe.lock_button:SetPoint("bottomright", self.baseframe, "bottomright", -3, 0)
self.baseframe.resize_direita:SetAlpha(0)
self.baseframe.resize_esquerda:SetAlpha(0)
4 years ago
end
end
end
3 years ago
4 years ago
function _detalhes:TravasInstancias()
3 years ago
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
instancia:LockInstance (true)
end
end
3 years ago
4 years ago
function _detalhes:DestravarInstancias()
3 years ago
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
instancia:LockInstance (false)
end
end
3 years ago
--alias
4 years ago
function _detalhes:ShowWindow (temp, all)
return self:AtivarInstancia (temp, all)
end
function _detalhes:EnableInstance (temp, all)
return self:AtivarInstancia (temp, all)
end
3 years ago
4 years ago
function _detalhes:AtivarInstancia (temp, all)
self.ativa = true
self.cached_bar_width = self.cached_bar_width or 0
self.modo = self.modo or 2
3 years ago
4 years ago
local lower = _detalhes:GetLowerInstanceNumber()
3 years ago
4 years ago
if (lower == self.meu_id) then
3 years ago
--os icones dos plugins precisam ser hostiados nessa instancia.
_detalhes.ToolBar:ReorganizeIcons (true) --n�o precisa recarregar toda a skin
4 years ago
end
3 years ago
4 years ago
if (not self.iniciada) then
self:RestauraJanela (self.meu_id, nil, true) --parece que esta chamando o ativar instance denovo... passei true no load_only vamos ver o resultado
--tiny threat parou de funcionar depois de /reload depois dessa mudança, talvez tenha algo para carregar ainda
self.iniciada = true
else
_detalhes.opened_windows = _detalhes.opened_windows+1
end
self:ChangeSkin() --carrega a skin aqui que era antes feito dentro do restaura janela
3 years ago
_detalhes:TrocaTabela(self, nil, nil, nil, true)
4 years ago
if (self.hide_icon) then
3 years ago
Details.FadeHandler.Fader(self.baseframe.cabecalho.atributo_icon, 1)
4 years ago
else
3 years ago
Details.FadeHandler.Fader(self.baseframe.cabecalho.atributo_icon, 0)
end
Details.FadeHandler.Fader(self.baseframe.cabecalho.ball, 0)
Details.FadeHandler.Fader(self.baseframe, 0)
Details.FadeHandler.Fader(self.rowframe, 0)
Details.FadeHandler.Fader(self.windowSwitchButton, 0)
4 years ago
self:SetMenuAlpha()
self.baseframe.cabecalho.fechar:Enable()
self:ChangeIcon()
if (not temp) then
if (self.modo == modo_raid) then
_detalhes.RaidTables:EnableRaidMode(self)
3 years ago
4 years ago
elseif (self.modo == modo_alone) then
self:SoloMode (true)
end
end
3 years ago
4 years ago
if (_detalhes.LastShowCommand and _detalhes.LastShowCommand+10 > GetTime()) then
self:ToolbarMenuButtons()
self:ToolbarSide()
self:AttributeMenu()
else
self:AdjustAlphaByContext(true)
end
self:DesaturateMenu()
if (not all) then
4 years ago
self:Desagrupar (-1)
end
3 years ago
4 years ago
self:CheckFor_EnabledTrashSuppression()
3 years ago
4 years ago
if (not temp and not _detalhes.initializing) then
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_OPEN", nil, self)
4 years ago
end
if (self.modo == modo_raid) then
_detalhes.RaidTables:EnableRaidMode(self)
3 years ago
4 years ago
elseif (self.modo == modo_alone) then
self:SoloMode (true)
end
end
3 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------
3 years ago
--apaga de vez um inst�ncia
4 years ago
function _detalhes:ApagarInstancia (ID)
3 years ago
return _table_remove(_detalhes.tabela_instancias, ID)
4 years ago
end
3 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------
3 years ago
--retorna quantas inst�ncia h� no momento
4 years ago
function _detalhes:GetNumInstancesAmount()
return #_detalhes.tabela_instancias
end
3 years ago
4 years ago
function _detalhes:QuantasInstancias()
return #_detalhes.tabela_instancias
end
3 years ago
4 years ago
------------------------------------------------------------------------------------------------------------------------
function _detalhes:DeleteInstance (id)
3 years ago
local instance = _detalhes:GetInstance(id)
4 years ago
if (not instance) then
return false
end
3 years ago
--break snaps of previous and next window
local left_instance = _detalhes:GetInstance(id-1)
4 years ago
if (left_instance) then
3 years ago
for snap_side, instance_id in pairs(left_instance.snap) do
4 years ago
if (instance_id == id) then --snap na proxima instancia
left_instance.snap [snap_side] = nil
end
end
end
3 years ago
local right_instance = _detalhes:GetInstance(id+1)
4 years ago
if (right_instance) then
3 years ago
for snap_side, instance_id in pairs(right_instance.snap) do
4 years ago
if (instance_id == id) then --snap na proxima instancia
right_instance.snap [snap_side] = nil
end
end
end
3 years ago
--re align snaps for higher instances
4 years ago
for i = id+1, #_detalhes.tabela_instancias do
3 years ago
local this_instance = _detalhes:GetInstance(i)
4 years ago
--fix the snaps
3 years ago
for snap_side, instance_id in pairs(this_instance.snap) do
4 years ago
if (instance_id == i+1) then --snap na proxima instancia
this_instance.snap [snap_side] = i
elseif (instance_id == i-1 and i-2 > 0) then --snap na instancia anterior
this_instance.snap [snap_side] = i-2
else
this_instance.snap [snap_side] = nil
end
end
end
3 years ago
4 years ago
table.remove (_detalhes.tabela_instancias, id)
end
------------------------------------------------------------------------------------------------------------------------
3 years ago
--cria uma nova inst�ncia e a joga para o container de inst�ncias
4 years ago
function _detalhes:CreateInstance (id)
3 years ago
return _detalhes:CriarInstancia(_, id)
4 years ago
end
3 years ago
function _detalhes:CriarInstancia(_, id)
if (id and type(id) == "boolean") then
4 years ago
if (#_detalhes.tabela_instancias >= _detalhes.instances_amount) then
3 years ago
_detalhes:Msg(Loc ["STRING_INSTANCE_LIMIT"])
4 years ago
return false
end
3 years ago
4 years ago
local next_id = #_detalhes.tabela_instancias+1
3 years ago
4 years ago
if (_detalhes.unused_instances [next_id]) then
local new_instance = _detalhes.unused_instances [next_id]
_detalhes.tabela_instancias [next_id] = new_instance
_detalhes.unused_instances [next_id] = nil
new_instance:AtivarInstancia()
return new_instance
end
3 years ago
4 years ago
local new_instance = _detalhes:NovaInstancia (next_id)
3 years ago
4 years ago
if (_detalhes.standard_skin) then
3 years ago
for key, value in pairs(_detalhes.standard_skin) do
if (type(value) == "table") then
new_instance [key] = Details.CopyTable(value)
4 years ago
else
new_instance [key] = value
end
end
new_instance:ChangeSkin()
3 years ago
4 years ago
else
3 years ago
--se n�o tiver um padr�o, criar de outra inst�ncia j� aberta.
4 years ago
local copy_from
for i = 1, next_id-1 do
3 years ago
local opened_instance = _detalhes:GetInstance(i)
4 years ago
if (opened_instance and opened_instance:IsEnabled() and opened_instance.baseframe) then
copy_from = opened_instance
break
end
end
3 years ago
4 years ago
if (copy_from) then
3 years ago
for key, value in pairs(copy_from) do
4 years ago
if (_detalhes.instance_defaults [key] ~= nil) then
3 years ago
if (type(value) == "table") then
new_instance [key] = Details.CopyTable(value)
4 years ago
else
new_instance [key] = value
end
end
end
new_instance:ChangeSkin()
end
end
3 years ago
4 years ago
return new_instance
3 years ago
4 years ago
elseif (id) then
local instancia = _detalhes.tabela_instancias [id]
if (instancia and not instancia:IsAtiva()) then
instancia:AtivarInstancia()
_detalhes:DelayOptionsRefresh (instancia)
return instancia
end
end
3 years ago
--antes de criar uma nova, ver se n�o h� alguma para reativar
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (not instancia:IsAtiva()) then
instancia:AtivarInstancia()
return instancia
end
end
3 years ago
4 years ago
if (#_detalhes.tabela_instancias >= _detalhes.instances_amount) then
3 years ago
return _detalhes:Msg(Loc ["STRING_INSTANCE_LIMIT"])
4 years ago
end
3 years ago
--verifica se n�o tem uma janela na pool de janelas fechadas
4 years ago
local next_id = #_detalhes.tabela_instancias+1
3 years ago
4 years ago
if (_detalhes.unused_instances [next_id]) then
local new_instance = _detalhes.unused_instances [next_id]
_detalhes.tabela_instancias [next_id] = new_instance
_detalhes.unused_instances [next_id] = nil
new_instance:AtivarInstancia()
3 years ago
4 years ago
_detalhes:GetLowerInstanceNumber()
3 years ago
4 years ago
return new_instance
end
3 years ago
--cria uma nova janela
4 years ago
local new_instance = _detalhes:NovaInstancia (#_detalhes.tabela_instancias+1)
3 years ago
4 years ago
if (not _detalhes.initializing) then
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_OPEN", nil, new_instance)
4 years ago
end
3 years ago
4 years ago
_detalhes:GetLowerInstanceNumber()
3 years ago
4 years ago
return new_instance
end
------------------------------------------------------------------------------------------------------------------------
3 years ago
--self � a inst�ncia que esta sendo movida.. instancia � a que esta parada
function _detalhes:EstaAgrupada(esta_instancia, lado) --lado //// 1 = encostou na esquerda // 2 = escostou emaixo // 3 = encostou na direita // 4 = encostou em cima
--local meu_snap = self.snap --pegou a tabela com {side, side, side, side}
4 years ago
if (esta_instancia.snap [lado]) then
3 years ago
return true --ha possui uma janela grudapa neste lado
4 years ago
elseif (lado == 1) then
if (self.snap [3]) then
return true
end
elseif (lado == 2) then
if (self.snap [4]) then
return true
end
elseif (lado == 3) then
if (self.snap [1]) then
return true
end
elseif (lado == 4) then
if (self.snap [2]) then
return true
end
end
3 years ago
return false --do contr�rio retorna false
4 years ago
end
function _detalhes:BaseFrameSnap()
local group = self:GetInstanceGroup()
3 years ago
for meu_id, instancia in ipairs(group) do
4 years ago
if (instancia:IsAtiva()) then
instancia.baseframe:ClearAllPoints()
end
end
local scale = self.window_scale
3 years ago
for _, instance in ipairs(group) do
4 years ago
instance:SetWindowScale (scale)
end
3 years ago
4 years ago
local my_baseframe = self.baseframe
3 years ago
for lado, snap_to in pairs(self.snap) do
4 years ago
local instancia_alvo = _detalhes.tabela_instancias [snap_to]
if (instancia_alvo) then
if (instancia_alvo.ativa and instancia_alvo.baseframe) then
3 years ago
if (lado == 1) then --a esquerda
instancia_alvo.baseframe:SetPoint("TOPRIGHT", my_baseframe, "TOPLEFT")
elseif (lado == 2) then --em baixo
4 years ago
local statusbar_y_mod = 0
if (not self.show_statusbar) then
statusbar_y_mod = 14
end
3 years ago
instancia_alvo.baseframe:SetPoint("TOPLEFT", my_baseframe, "BOTTOMLEFT", 0, -34 + statusbar_y_mod)
elseif (lado == 3) then --a direita
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", my_baseframe, "BOTTOMRIGHT")
elseif (lado == 4) then --em cima
4 years ago
local statusbar_y_mod = 0
if (not instancia_alvo.show_statusbar) then
statusbar_y_mod = -14
end
3 years ago
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", my_baseframe, "TOPLEFT", 0, 34 + statusbar_y_mod)
4 years ago
end
end
end
end
--[
3 years ago
--aqui precisa de um efeito reverso
local reverso = self.meu_id - 2 --se existir
if (reverso > 0) then --se tiver uma inst�ncia l� tr�s
--aqui faz o efeito reverso:
4 years ago
local inicio_retro = self.meu_id - 1
for meu_id = inicio_retro, 1, -1 do
local instancia = _detalhes.tabela_instancias [meu_id]
3 years ago
for lado, snap_to in pairs(instancia.snap) do
if (snap_to < instancia.meu_id and snap_to ~= self.meu_id) then --se o lado que esta grudado for menor que o meu id... EX instnacia #2 grudada na #1
--ent�o tenho que pegar a inst�ncia do snap
4 years ago
local instancia_alvo = _detalhes.tabela_instancias [snap_to]
local lado_reverso
if (lado == 1) then
lado_reverso = 3
elseif (lado == 2) then
lado_reverso = 4
elseif (lado == 3) then
lado_reverso = 1
elseif (lado == 4) then
lado_reverso = 2
end
3 years ago
--fazer os setpoints
4 years ago
if (instancia_alvo.ativa and instancia_alvo.baseframe) then
3 years ago
if (lado_reverso == 1) then --a esquerda
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", instancia.baseframe, "BOTTOMRIGHT")
elseif (lado_reverso == 2) then --em baixo
4 years ago
local statusbar_y_mod = 0
if (not instancia_alvo.show_statusbar) then
statusbar_y_mod = -14
end
3 years ago
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", instancia.baseframe, "TOPLEFT", 0, 34 + statusbar_y_mod) -- + (statusbar_y_mod*-1)
elseif (lado_reverso == 3) then --a direita
instancia_alvo.baseframe:SetPoint("TOPRIGHT", instancia.baseframe, "TOPLEFT")
elseif (lado_reverso == 4) then --em cima
4 years ago
local statusbar_y_mod = 0
if (not instancia.show_statusbar) then
statusbar_y_mod = 14
end
3 years ago
instancia_alvo.baseframe:SetPoint("TOPLEFT", instancia.baseframe, "BOTTOMLEFT", 0, -34 + statusbar_y_mod)
4 years ago
end
end
end
end
end
end
--]]
3 years ago
for meu_id, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (meu_id > self.meu_id) then
3 years ago
for lado, snap_to in pairs(instancia.snap) do
4 years ago
if (snap_to > instancia.meu_id and snap_to ~= self.meu_id) then
local instancia_alvo = _detalhes.tabela_instancias [snap_to]
3 years ago
4 years ago
if (instancia_alvo.ativa and instancia_alvo.baseframe) then
3 years ago
if (lado == 1) then --a esquerda
instancia_alvo.baseframe:SetPoint("TOPRIGHT", instancia.baseframe, "TOPLEFT")
elseif (lado == 2) then --em baixo
4 years ago
local statusbar_y_mod = 0
if (not instancia.show_statusbar) then
statusbar_y_mod = 14
end
3 years ago
instancia_alvo.baseframe:SetPoint("TOPLEFT", instancia.baseframe, "BOTTOMLEFT", 0, -34 + statusbar_y_mod)
elseif (lado == 3) then --a direita
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", instancia.baseframe, "BOTTOMRIGHT")
elseif (lado == 4) then --em cima
4 years ago
local statusbar_y_mod = 0
if (not instancia_alvo.show_statusbar) then
statusbar_y_mod = -14
end
3 years ago
instancia_alvo.baseframe:SetPoint("BOTTOMLEFT", instancia.baseframe, "TOPLEFT", 0, 34 + statusbar_y_mod)
4 years ago
end
end
end
end
end
end
end
3 years ago
function _detalhes:agrupar_janelas(lados)
4 years ago
local instancia = self
3 years ago
for lado, esta_instancia in pairs(lados) do
4 years ago
if (esta_instancia) then
instancia.baseframe:ClearAllPoints()
esta_instancia = _detalhes.tabela_instancias [esta_instancia]
3 years ago
4 years ago
instancia:SetWindowScale (esta_instancia.window_scale)
3 years ago
if (lado == 3) then --direita
--mover frame
instancia.baseframe:SetPoint("TOPRIGHT", esta_instancia.baseframe, "TOPLEFT")
instancia.baseframe:SetPoint("RIGHT", esta_instancia.baseframe, "LEFT")
instancia.baseframe:SetPoint("BOTTOMRIGHT", esta_instancia.baseframe, "BOTTOMLEFT")
4 years ago
local _, height = esta_instancia:GetSize()
3 years ago
instancia:SetSize(nil, height)
--salva o snap
4 years ago
self.snap [3] = esta_instancia.meu_id
esta_instancia.snap [1] = self.meu_id
3 years ago
elseif (lado == 4) then --cima
--mover frame
4 years ago
local statusbar_y_mod = 0
if (not esta_instancia.show_statusbar) then
statusbar_y_mod = 14
end
3 years ago
instancia.baseframe:SetPoint("TOPLEFT", esta_instancia.baseframe, "BOTTOMLEFT", 0, -34 + statusbar_y_mod)
instancia.baseframe:SetPoint("TOP", esta_instancia.baseframe, "BOTTOM", 0, -34 + statusbar_y_mod)
instancia.baseframe:SetPoint("TOPRIGHT", esta_instancia.baseframe, "BOTTOMRIGHT", 0, -34 + statusbar_y_mod)
4 years ago
local _, height = esta_instancia:GetSize()
3 years ago
instancia:SetSize(nil, height)
--salva o snap
4 years ago
self.snap [4] = esta_instancia.meu_id
esta_instancia.snap [2] = self.meu_id
3 years ago
elseif (lado == 1) then --esquerda
--mover frame
instancia.baseframe:SetPoint("TOPLEFT", esta_instancia.baseframe, "TOPRIGHT")
instancia.baseframe:SetPoint("LEFT", esta_instancia.baseframe, "RIGHT")
instancia.baseframe:SetPoint("BOTTOMLEFT", esta_instancia.baseframe, "BOTTOMRIGHT")
4 years ago
local _, height = esta_instancia:GetSize()
3 years ago
instancia:SetSize(nil, height)
--salva o snap
4 years ago
self.snap [1] = esta_instancia.meu_id
esta_instancia.snap [3] = self.meu_id
3 years ago
elseif (lado == 2) then --baixo
--mover frame
4 years ago
local statusbar_y_mod = 0
if (not instancia.show_statusbar) then
statusbar_y_mod = -14
end
3 years ago
instancia.baseframe:SetPoint("BOTTOMLEFT", esta_instancia.baseframe, "TOPLEFT", 0, 34 + statusbar_y_mod)
instancia.baseframe:SetPoint("BOTTOM", esta_instancia.baseframe, "TOP", 0, 34 + statusbar_y_mod)
instancia.baseframe:SetPoint("BOTTOMRIGHT", esta_instancia.baseframe, "TOPRIGHT", 0, 34 + statusbar_y_mod)
4 years ago
local _, height = esta_instancia:GetSize()
3 years ago
instancia:SetSize(nil, height)
--salva o snap
4 years ago
self.snap [2] = esta_instancia.meu_id
esta_instancia.snap [4] = self.meu_id
end
3 years ago
4 years ago
if (not esta_instancia.ativa) then
esta_instancia:AtivarInstancia()
end
3 years ago
4 years ago
end
end
3 years ago
4 years ago
if (not _detalhes.disable_lock_ungroup_buttons) then
3 years ago
instancia.break_snap_button:SetAlpha(1)
4 years ago
end
3 years ago
4 years ago
if (_detalhes.tutorial.unlock_button < 4) then
3 years ago
4 years ago
_detalhes.temp_table1.IconSize = 32
_detalhes.temp_table1.TextHeightMod = -6
3 years ago
_detalhes.popup:ShowMe(instancia.break_snap_button, "tooltip", "Interface\\Buttons\\LockButton-Unlocked-Up", Loc ["STRING_UNLOCK"], 150, _detalhes.temp_table1)
4 years ago
--UIFrameFlash (instancia.break_snap_button, .5, .5, 5, false, 0, 0)
_detalhes.tutorial.unlock_button = _detalhes.tutorial.unlock_button + 1
end
3 years ago
4 years ago
_detalhes:DelayOptionsRefresh()
3 years ago
4 years ago
end
_detalhes.MakeInstanceGroup = _detalhes.agrupar_janelas
function _detalhes:UngroupInstance()
return self:Desagrupar(-1)
end
function _detalhes:Desagrupar (instancia, lado, lado2)
if (lado2 == -1) then
instancia = lado
self = instancia
lado = lado2
end
3 years ago
if (self.meu_id and not lado2) then --significa que self � uma instancia
4 years ago
lado = instancia
instancia = self
end
3 years ago
if (type(instancia) == "number") then --significa que passou o n�mero da inst�ncia
4 years ago
instancia = _detalhes.tabela_instancias [instancia]
end
3 years ago
4 years ago
_detalhes:DelayOptionsRefresh (nil, true)
3 years ago
4 years ago
if (not lado) then
return
end
3 years ago
if (lado < 0) then --clicou no bot�o para desagrupar tudo
4 years ago
local ID = instancia.meu_id
3 years ago
for id, esta_instancia in ipairs(_detalhes.tabela_instancias) do
for index, iid in pairs(esta_instancia.snap) do -- index = 1 left , 3 right, 2 bottom, 4 top
4 years ago
if (iid and (iid == ID or id == ID)) then -- iid = instancia.meu_id
3 years ago
4 years ago
esta_instancia.snap [index] = nil
3 years ago
4 years ago
if (instancia.verticalSnap or esta_instancia.verticalSnap) then
if (not esta_instancia.snap [2] and not esta_instancia.snap [4]) then
esta_instancia.verticalSnap = false
esta_instancia.horizontalSnap = false
end
elseif (instancia.horizontalSnap or esta_instancia.horizontalSnap) then
if (not esta_instancia.snap [1] and not esta_instancia.snap [3]) then
esta_instancia.horizontalSnap = false
esta_instancia.verticalSnap = false
end
end
3 years ago
4 years ago
if (index == 2) then -- index � o codigo do snap
3 years ago
--esta_instancia.baseframe.rodape.StatusBarLeftAnchor:SetPoint("left", esta_instancia.baseframe.rodape.top_bg, "left", 5, 58)
--esta_instancia.baseframe.rodape.StatusBarCenterAnchor:SetPoint("center", esta_instancia.baseframe.rodape.top_bg, "center", 0, 58)
--esta_instancia.baseframe.rodape.esquerdo:SetTexture("Interface\\AddOns\\Details\\images\\bar_down_left")
4 years ago
--esta_instancia.baseframe.rodape.esquerdo.have_snap = nil
end
3 years ago
4 years ago
end
end
end
3 years ago
instancia.break_snap_button:SetAlpha(0)
4 years ago
instancia.verticalSnap = false
instancia.horizontalSnap = false
return
end
3 years ago
4 years ago
local esta_instancia = _detalhes.tabela_instancias [instancia.snap[lado]]
3 years ago
4 years ago
if (not esta_instancia) then
return
end
3 years ago
4 years ago
instancia.snap [lado] = nil
3 years ago
4 years ago
if (lado == 1) then
esta_instancia.snap [3] = nil
elseif (lado == 2) then
esta_instancia.snap [4] = nil
elseif (lado == 3) then
esta_instancia.snap [1] = nil
elseif (lado == 4) then
esta_instancia.snap [2] = nil
end
3 years ago
instancia.break_snap_button:SetAlpha(0)
4 years ago
if (instancia.iniciada) then
instancia:SaveMainWindowPosition()
instancia:RestoreMainWindowPosition()
end
3 years ago
4 years ago
if (esta_instancia.iniciada) then
esta_instancia:SaveMainWindowPosition()
3 years ago
esta_instancia:RestoreMainWindowPosition()
4 years ago
end
end
function _detalhes:SnapTextures (remove)
3 years ago
for id, esta_instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (esta_instancia:IsAtiva()) then
if (esta_instancia.baseframe.rodape.esquerdo.have_snap) then
if (remove) then
3 years ago
--esta_instancia.baseframe.rodape.esquerdo:SetTexture("Interface\\AddOns\\Details\\images\\bar_down_left")
4 years ago
else
3 years ago
--esta_instancia.baseframe.rodape.esquerdo:SetTexture("Interface\\AddOns\\Details\\images\\bar_down_left_snap")
4 years ago
end
end
end
end
end
3 years ago
--cria uma janela para uma nova inst�ncia
--search key: ~new ~nova
4 years ago
function _detalhes:CreateDisabledInstance (ID, skin_table)
3 years ago
--first check if we can recycle a old instance
4 years ago
if (_detalhes.unused_instances [ID]) then
local new_instance = _detalhes.unused_instances [ID]
_detalhes.tabela_instancias [ID] = new_instance
_detalhes.unused_instances [ID] = nil
3 years ago
--replace the values on recycled instance
4 years ago
new_instance:ResetInstanceConfig()
3 years ago
--copy values from a previous skin saved
4 years ago
if (skin_table) then
3 years ago
--copy from skin_table to new_instance
_detalhes.table.copy(new_instance, skin_table)
4 years ago
end
3 years ago
4 years ago
return new_instance
end
3 years ago
--must create a new one
4 years ago
local new_instance = {
3 years ago
--instance id
4 years ago
meu_id = ID,
3 years ago
--internal stuff
4 years ago
barras = {}, --container que ir� armazenar todas as barras
barraS = {nil, nil}, --de x at� x s�o as barras que est�o sendo mostradas na tela
rolagem = false, --barra de rolagem n�o esta sendo mostrada
largura_scroll = 26,
bar_mod = 0,
3 years ago
bgdisplay_loc = 0,
--displaying row info
4 years ago
rows_created = 0,
rows_showing = 0,
rows_max = 50,
3 years ago
--saved pos for normal mode and lone wolf mode
4 years ago
posicao = {
["normal"] = {x = 1, y = 2, w = 300, h = 200},
["solo"] = {x = 1, y = 2, w = 300, h = 200}
},
3 years ago
--save information about window snaps
4 years ago
snap = {},
3 years ago
--current state starts as normal
4 years ago
mostrando = "normal",
3 years ago
--menu consolidated
4 years ago
consolidate = false, --deprecated
icons = {true, true, true, true},
3 years ago
--status bar stuff
4 years ago
StatusBar = {options = {}},
3 years ago
--more stuff
atributo = 1, --dano
sub_atributo = 1, --damage done
4 years ago
sub_atributo_last = {1, 1, 1, 1, 1},
3 years ago
segmento = 0, --combate atual
4 years ago
modo = modo_grupo,
last_modo = modo_grupo,
LastModo = modo_grupo,
}
3 years ago
setmetatable(new_instance, _detalhes)
4 years ago
_detalhes.tabela_instancias [#_detalhes.tabela_instancias+1] = new_instance
3 years ago
--fill the empty instance with default values
4 years ago
new_instance:ResetInstanceConfig()
3 years ago
--copy values from a previous skin saved
4 years ago
if (skin_table) then
3 years ago
--copy from skin_table to new_instance
_detalhes.table.copy(new_instance, skin_table)
4 years ago
end
3 years ago
--setup default wallpaper
4 years ago
new_instance.wallpaper.texture = "Interface\\AddOns\\Details\\images\\background"
3 years ago
--finish
4 years ago
return new_instance
end
3 years ago
4 years ago
function _detalhes:NovaInstancia (ID)
local new_instance = {}
setmetatable(new_instance, _detalhes)
4 years ago
_detalhes.tabela_instancias [#_detalhes.tabela_instancias+1] = new_instance
3 years ago
--instance number
4 years ago
new_instance.meu_id = ID
3 years ago
--setup all config
4 years ago
new_instance:ResetInstanceConfig()
3 years ago
--setup default wallpaper
4 years ago
new_instance.wallpaper.texture = "Interface\\AddOns\\Details\\images\\background"
3 years ago
--internal stuff
4 years ago
new_instance.barras = {} --container que ir� armazenar todas as barras
new_instance.barraS = {nil, nil} --de x at� x s�o as barras que est�o sendo mostradas na tela
new_instance.rolagem = false --barra de rolagem n�o esta sendo mostrada
new_instance.largura_scroll = 26
new_instance.bar_mod = 0
new_instance.bgdisplay_loc = 0
new_instance.cached_bar_width = 0
3 years ago
--displaying row info
4 years ago
new_instance.rows_created = 0
new_instance.rows_showing = 0
new_instance.rows_max = 50
new_instance.rows_fit_in_window = nil
3 years ago
--saved pos for normal mode and lone wolf mode
4 years ago
new_instance.posicao = {
["normal"] = {x = 1, y = 2, w = 300, h = 200},
["solo"] = {x = 1, y = 2, w = 300, h = 200}
3 years ago
}
--save information about window snaps
4 years ago
new_instance.snap = {}
3 years ago
--current state starts as normal
4 years ago
new_instance.mostrando = "normal"
3 years ago
--menu consolidated
4 years ago
new_instance.consolidate = false
new_instance.icons = {true, true, true, true}
3 years ago
--create window frames
4 years ago
local _baseframe, _bgframe, _bgframe_display, _scrollframe = gump:CriaJanelaPrincipal (ID, new_instance, true)
new_instance.baseframe = _baseframe
new_instance.bgframe = _bgframe
new_instance.bgdisplay = _bgframe_display
new_instance.scroll = _scrollframe
3 years ago
--status bar stuff
4 years ago
new_instance.StatusBar = {}
new_instance.StatusBar.left = nil
new_instance.StatusBar.center = nil
new_instance.StatusBar.right = nil
new_instance.StatusBar.options = {}
local clock = _detalhes.StatusBar:CreateStatusBarChildForInstance (new_instance, "DETAILS_STATUSBAR_PLUGIN_CLOCK")
_detalhes.StatusBar:SetCenterPlugin (new_instance, clock)
3 years ago
4 years ago
local segment = _detalhes.StatusBar:CreateStatusBarChildForInstance (new_instance, "DETAILS_STATUSBAR_PLUGIN_PSEGMENT")
_detalhes.StatusBar:SetLeftPlugin (new_instance, segment)
3 years ago
4 years ago
local dps = _detalhes.StatusBar:CreateStatusBarChildForInstance (new_instance, "DETAILS_STATUSBAR_PLUGIN_PDPS")
_detalhes.StatusBar:SetRightPlugin (new_instance, dps)
3 years ago
--internal stuff
4 years ago
new_instance.alturaAntiga = _baseframe:GetHeight()
3 years ago
new_instance.atributo = 1 --dano
new_instance.sub_atributo = 1 --damage done
4 years ago
new_instance.sub_atributo_last = {1, 1, 1, 1, 1}
3 years ago
new_instance.segmento = -1 --combate atual
4 years ago
new_instance.modo = modo_grupo
new_instance.last_modo = modo_grupo
new_instance.LastModo = modo_grupo
3 years ago
--change the attribute
_detalhes:TrocaTabela(new_instance, 0, 1, 1)
--internal stuff
4 years ago
new_instance.row_height = new_instance.row_info.height + new_instance.row_info.space.between
3 years ago
4 years ago
new_instance.oldwith = new_instance.baseframe:GetWidth()
new_instance.iniciada = true
new_instance:SaveMainWindowPosition()
new_instance:ReajustaGump()
3 years ago
new_instance.rows_fit_in_window = _math_floor(new_instance.posicao[new_instance.mostrando].h / new_instance.row_height)
--all done
4 years ago
new_instance:AtivarInstancia()
3 years ago
4 years ago
new_instance:ShowSideBars()
new_instance.skin = "no skin"
new_instance:ChangeSkin (_detalhes.default_skin_to_use)
3 years ago
--apply standard skin if have one saved
4 years ago
--[[
if (_detalhes.standard_skin) then
local style = _detalhes.standard_skin
local instance = new_instance
local skin = style.skin
3 years ago
4 years ago
instance.skin = ""
instance:ChangeSkin (skin)
3 years ago
--overwrite all instance parameters with saved ones
for key, value in pairs(style) do
4 years ago
if (key ~= "skin") then
3 years ago
if (type(value) == "table") then
instance [key] = Details.CopyTable(value)
4 years ago
else
instance [key] = value
end
end
end
end
--]]
3 years ago
--apply all changed attributes
4 years ago
--new_instance:ChangeSkin()
3 years ago
4 years ago
return new_instance
end
------------------------------------------------------------------------------------------------------------------------
function _detalhes:FixToolbarMenu (instance)
3 years ago
--print("fixing...", instance.meu_id)
4 years ago
--instance:ToolbarMenuButtons()
end
3 years ago
--ao reiniciar o addon esta fun��o � rodada para recriar a janela da inst�ncia
--search key: ~restaura ~inicio ~start
4 years ago
function Details:RestoreWindow(index, temp, loadOnly)
self:RestauraJanela (index, temp, loadOnly)
end
function _detalhes:RestauraJanela(index, temp, load_only)
3 years ago
--load
4 years ago
self:LoadInstanceConfig()
3 years ago
--reset internal stuff
4 years ago
self.sub_atributo_last = self.sub_atributo_last or {1, 1, 1, 1, 1}
self.rolagem = false
self.need_rolagem = false
self.barras = {}
self.barraS = {nil, nil}
self.rows_fit_in_window = nil
self.consolidate = self.consolidate or false
self.icons = self.icons or {true, true, true, true}
self.rows_created = 0
self.rows_showing = 0
self.rows_max = 50
self.largura_scroll = 26
self.bar_mod = 0
self.bgdisplay_loc = 0
self.last_modo = self.last_modo or modo_grupo
self.cached_bar_width = self.cached_bar_width or 0
self.row_height = self.row_info.height + self.row_info.space.between
3 years ago
self.rows_fit_in_window = _math_floor(self.posicao[self.mostrando].h / self.row_height)
4 years ago
3 years ago
--create frames
4 years ago
local isLocked = self.isLocked
local _baseframe, _bgframe, _bgframe_display, _scrollframe = gump:CriaJanelaPrincipal (self.meu_id, self)
self.baseframe = _baseframe
self.bgframe = _bgframe
self.bgdisplay = _bgframe_display
3 years ago
self.scroll = _scrollframe
_baseframe:EnableMouseWheel(false)
4 years ago
self.alturaAntiga = _baseframe:GetHeight()
3 years ago
4 years ago
--self.isLocked = isLocked --window isn't locked when just created it
3 years ago
--change the attribute
_detalhes:TrocaTabela(self, self.segmento, self.atributo, self.sub_atributo, true) --passando true no 5� valor para a fun��o ignorar a checagem de valores iguais
--set wallpaper
4 years ago
if (self.wallpaper.enabled) then
self:InstanceWallpaper (true)
end
3 years ago
--set the color of this instance window
4 years ago
self:InstanceColor (self.color)
3 years ago
--scrollbar
4 years ago
self:EsconderScrollBar (true)
3 years ago
--check snaps
4 years ago
self.snap = self.snap or {}
3 years ago
--status bar stuff
4 years ago
self.StatusBar = {}
self.StatusBar.left = nil
self.StatusBar.center = nil
self.StatusBar.right = nil
self.StatusBarSaved = self.StatusBarSaved or {options = {}}
self.StatusBar.options = self.StatusBarSaved.options
if (self.StatusBarSaved.left and self.StatusBarSaved.left == "NONE") then
self.StatusBarSaved.left = "DETAILS_STATUSBAR_PLUGIN_PSEGMENT"
end
local segment = _detalhes.StatusBar:CreateStatusBarChildForInstance (self, self.StatusBarSaved.left or "DETAILS_STATUSBAR_PLUGIN_PSEGMENT")
_detalhes.StatusBar:SetLeftPlugin (self, segment, true)
if (self.StatusBarSaved.center and self.StatusBarSaved.center == "NONE") then
self.StatusBarSaved.center = "DETAILS_STATUSBAR_PLUGIN_CLOCK"
end
local clock = _detalhes.StatusBar:CreateStatusBarChildForInstance (self, self.StatusBarSaved.center or "DETAILS_STATUSBAR_PLUGIN_CLOCK")
_detalhes.StatusBar:SetCenterPlugin (self, clock, true)
if (self.StatusBarSaved.right and self.StatusBarSaved.right == "NONE") then
self.StatusBarSaved.right = "DETAILS_STATUSBAR_PLUGIN_PDURABILITY"
end
local durability = _detalhes.StatusBar:CreateStatusBarChildForInstance (self, self.StatusBarSaved.right or "DETAILS_STATUSBAR_PLUGIN_PDURABILITY")
_detalhes.StatusBar:SetRightPlugin (self, durability, true)
3 years ago
--load mode
4 years ago
if (self.modo == modo_alone) then
3 years ago
if (_detalhes.solo and _detalhes.solo ~= self.meu_id) then --prote��o para ter apenas uma inst�ncia com a janela SOLO
4 years ago
self.modo = modo_grupo
self.mostrando = "normal"
else
self:SoloMode (true)
_detalhes.solo = self.meu_id
end
elseif (self.modo == modo_raid) then
_detalhes.raid = self.meu_id
else
self.mostrando = "normal"
end
--internal stuff
self.oldwith = self.baseframe:GetWidth()
self:RestoreMainWindowPosition()
self:ReajustaGump()
--self:SaveMainWindowPosition()
3 years ago
--fix for the weird white window default skin
--this is a auto detect for configuration corruption, happens usually when the user install Details! over old config settings
--check if the skin used in the window is the default skin, check if statusbar is in use and if the color of the window is full white
if (self.skin == _detalhes.default_skin_to_use and self.show_statusbar) then
if(self.color[1] == 1 and self.color[2] == 1 and self.color[3] == 1 and self.color[4] == 1) then
Details:Msg("error 0xFF85DD")
self.skin = "no skin"
self:ChangeSkin(_detalhes.default_skin_to_use)
end
end
4 years ago
if (not load_only) then
self.iniciada = true
self:AtivarInstancia (temp)
self:ChangeSkin()
end
3 years ago
--all done
4 years ago
return
end
function _detalhes:SwitchBack()
local prev_switch = self.auto_switch_to_old
3 years ago
4 years ago
if (prev_switch) then
if (self.modo ~= prev_switch [1]) then
_detalhes:AlteraModo (self, prev_switch [1])
end
3 years ago
4 years ago
if (self.modo == _detalhes._detalhes_props["MODO_RAID"]) then
3 years ago
_detalhes.RaidTables:switch(nil, prev_switch [5], self)
4 years ago
elseif (self.modo == _detalhes._detalhes_props["MODO_ALONE"]) then
3 years ago
_detalhes.SoloTables:switch(nil, prev_switch [6])
4 years ago
else
3 years ago
_detalhes:TrocaTabela(self, prev_switch [4], prev_switch [2], prev_switch [3])
4 years ago
end
3 years ago
4 years ago
self.auto_switch_to_old = nil
end
end
function _detalhes:SwitchTo (switch_table, nosave)
if (not nosave) then
self.auto_switch_to_old = {self.modo, self.atributo, self.sub_atributo, self.segmento, self:GetRaidPluginName(), _detalhes.SoloTables.Mode}
end
if (switch_table [1] == "raid") then
local plugin_global_name, can_switch = switch_table[2], true
--plugin global name
3 years ago
for _, instance in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instance ~= self and instance:IsEnabled() and instance.baseframe and instance.modo == modo_raid) then
if (instance.current_raid_plugin == plugin_global_name) then
can_switch = false
break
end
end
end
3 years ago
4 years ago
if (can_switch) then
_detalhes.RaidTables:EnableRaidMode (self, switch_table [2])
else
local plugin = _detalhes:GetPlugin (plugin_global_name)
3 years ago
_detalhes:Msg("Auto Switch: a window is already showing " .. (plugin.__name or "" .. ", please review your switch config."))
4 years ago
end
else
--muda para um atributo normal
if (self.modo ~= _detalhes._detalhes_props["MODO_GROUP"]) then
_detalhes:AlteraModo (self, _detalhes._detalhes_props["MODO_GROUP"])
end
3 years ago
_detalhes:TrocaTabela(self, nil, switch_table [1], switch_table [2])
4 years ago
end
end
--backtable indexes: [1]: mode [2]: attribute [3]: sub attribute [4]: segment [5]: raidmode index [6]: solomode index
function _detalhes:CheckSwitchOnCombatEnd (nowipe, warning)
local old_attribute, old_sub_atribute = self:GetDisplay()
self:SwitchBack()
3 years ago
local role = _UnitGroupRolesAssigned("player")
4 years ago
local got_switch = false
3 years ago
4 years ago
if (role == "DAMAGER" and self.switch_damager) then
self:SwitchTo (self.switch_damager)
got_switch = true
3 years ago
4 years ago
elseif (role == "HEALER" and self.switch_healer) then
self:SwitchTo (self.switch_healer)
got_switch = true
3 years ago
4 years ago
elseif (role == "TANK" and self.switch_tank) then
self:SwitchTo (self.switch_tank, true)
got_switch = true
3 years ago
4 years ago
elseif (role == "NONE" and _detalhes.last_assigned_role ~= "NONE") then
self:SwitchBack()
got_switch = true
3 years ago
4 years ago
end
3 years ago
4 years ago
if (warning and got_switch) then
local current_attribute, current_sub_atribute = self:GetDisplay()
if (current_attribute ~= old_attribute or current_sub_atribute ~= old_sub_atribute) then
local attribute_name = self:GetInstanceAttributeText()
3 years ago
self:InstanceAlert (string.format(Loc ["STRING_SWITCH_WARNING"], attribute_name), {[[Interface\CHARACTERFRAME\UI-StateIcon]], 18, 18, false, 0.5, 1, 0, 0.5}, 4)
4 years ago
end
end
3 years ago
4 years ago
if (self.switch_all_roles_after_wipe and not nowipe) then
if (_detalhes.tabela_vigente.is_boss and _detalhes.tabela_vigente.instance_type == "raid" and not _detalhes.tabela_vigente.is_boss.killed and _detalhes.tabela_vigente.is_boss.name) then
self:SwitchBack()
self:SwitchTo (self.switch_all_roles_after_wipe)
end
end
3 years ago
4 years ago
end
function _detalhes:CheckSwitchOnLogon (warning)
3 years ago
for index, instancia in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instancia.ativa) then
instancia:CheckSwitchOnCombatEnd (true, warning)
end
end
end
function _detalhes:CheckSegmentForSwitchOnCombatStart()
3 years ago
4 years ago
end
function _detalhes:CheckSwitchOnCombatStart (check_segment)
self:SwitchBack()
local all_roles = self.switch_all_roles_in_combat
3 years ago
local role = _UnitGroupRolesAssigned("player")
4 years ago
local got_switch = false
3 years ago
4 years ago
if (role == "DAMAGER" and self.switch_damager_in_combat) then
self:SwitchTo (self.switch_damager_in_combat)
got_switch = true
3 years ago
4 years ago
elseif (role == "HEALER" and self.switch_healer_in_combat) then
self:SwitchTo (self.switch_healer_in_combat)
got_switch = true
3 years ago
4 years ago
elseif (role == "TANK" and self.switch_tank_in_combat) then
self:SwitchTo (self.switch_tank_in_combat)
got_switch = true
3 years ago
4 years ago
elseif (self.switch_all_roles_in_combat) then
self:SwitchTo (self.switch_all_roles_in_combat)
got_switch = true
3 years ago
4 years ago
end
3 years ago
4 years ago
if (check_segment and got_switch) then
if (self:GetSegment() ~= 0) then
3 years ago
self:TrocaTabela(0)
4 years ago
end
end
3 years ago
4 years ago
end
local createStatusbarOptions = function(optionsTable)
local newTable = {}
newTable.textColor = optionsTable.textColor
newTable.textSize = optionsTable.textSize
newTable.textFace = optionsTable.textFace
newTable.textXmod = optionsTable.textXmod
newTable.textYmod = optionsTable.textYmod
newTable.isHidden = optionsTable.isHidden
newTable.segmentType = optionsTable.segmentType
newTable.textAlign = optionsTable.textAlign
newTable.timeType = optionsTable.timeType
newTable.textStyle = optionsTable.textStyle
return newTable
end
4 years ago
function _detalhes:ExportSkin()
--create the table
local exported = {
version = _detalhes.preset_version --skin version
}
--export the keys
3 years ago
for key, value in pairs(self) do
if (_detalhes.instance_defaults [key] ~= nil) then
3 years ago
if (type(value) == "table") then
exported [key] = Details.CopyTable(value)
4 years ago
else
exported [key] = value
end
end
end
4 years ago
--export size and positioning
if (_detalhes.profile_save_pos) then
exported.posicao = self.posicao
else
exported.posicao = nil
end
4 years ago
--export mini displays
if (self.StatusBar and self.StatusBar.left) then
exported.StatusBarSaved = {
["left"] = self.StatusBar.left.real_name or "NONE",
["center"] = self.StatusBar.center.real_name or "NONE",
["right"] = self.StatusBar.right.real_name or "NONE",
}
local leftOptions = createStatusbarOptions(self.StatusBar.left.options)
local centerOptions = createStatusbarOptions(self.StatusBar.center.options)
local rightOptions = createStatusbarOptions(self.StatusBar.right.options)
4 years ago
exported.StatusBarSaved.options = {
[exported.StatusBarSaved.left] = leftOptions,
[exported.StatusBarSaved.center] = centerOptions,
[exported.StatusBarSaved.right] = rightOptions,
4 years ago
}
elseif (self.StatusBarSaved) then
local leftName = self.StatusBarSaved.left
local centerName = self.StatusBarSaved.center
local rightName = self.StatusBarSaved.right
local options = self.StatusBarSaved.options
local leftOptions = createStatusbarOptions(options[leftName])
local centerOptions = createStatusbarOptions(options[centerName])
local rightOptions = createStatusbarOptions(options[rightName])
4 years ago
options[leftName] = leftOptions
options[centerName] = centerOptions
options[rightName] = rightOptions
exported.StatusBarSaved = DetailsFramework.table.copy({}, self.StatusBarSaved)
end
4 years ago
return exported
end
function _detalhes:ApplySavedSkin (style)
if (not style.version or _detalhes.preset_version > style.version) then
3 years ago
return _detalhes:Msg(Loc ["STRING_OPTIONS_PRESETTOOLD"])
4 years ago
end
3 years ago
--set skin preset
4 years ago
local skin = style.skin
self.skin = ""
self:ChangeSkin (skin)
3 years ago
--overwrite all instance parameters with saved ones
for key, value in pairs(style) do
4 years ago
if (key ~= "skin") then
3 years ago
if (type(value) == "table") then
self [key] = Details.CopyTable(value)
4 years ago
else
self [key] = value
end
end
end
3 years ago
--check for new keys inside tables
for key, value in pairs(_detalhes.instance_defaults) do
if (type(value) == "table") then
for key2, value2 in pairs(value) do
4 years ago
if (self [key] [key2] == nil) then
3 years ago
if (type(value2) == "table") then
self [key] [key2] = Details.CopyTable(_detalhes.instance_defaults [key] [key2])
4 years ago
else
self [key] [key2] = value2
end
end
end
end
3 years ago
end
self.StatusBarSaved = style.StatusBarSaved and Details.CopyTable(style.StatusBarSaved) or {options = {}}
4 years ago
self.StatusBar.options = self.StatusBarSaved.options
_detalhes.StatusBar:UpdateChilds (self)
3 years ago
--apply all changed attributes
4 years ago
self:ChangeSkin()
3 years ago
4 years ago
--export size and positioning
if (_detalhes.profile_save_pos) then
self.posicao = style.posicao
self:RestoreMainWindowPosition()
else
3 years ago
self.posicao = Details.CopyTable(self.posicao)
4 years ago
end
3 years ago
4 years ago
end
------------------------------------------------------------------------------------------------------------------------
3 years ago
function _detalhes:InstanceReset(instance)
4 years ago
if (instance) then
self = instance
end
3 years ago
Details.FadeHandler.Fader(self, "in", nil, "barras")
self:AtualizaSegmentos(self)
4 years ago
self:AtualizaSoloMode_AfertReset()
self:ResetaGump()
3 years ago
4 years ago
if (not _detalhes.initializing) then
3 years ago
_detalhes:RefreshMainWindow(self, true) --atualiza todas as instancias
4 years ago
end
end
3 years ago
function _detalhes:RefreshBars(instance)
4 years ago
if (instance) then
self = instance
end
3 years ago
self:InstanceRefreshRows(instance)
4 years ago
end
3 years ago
function _detalhes:SetBackgroundColor(...)
local red = select(1, ...)
4 years ago
if (not red) then
3 years ago
self.bgdisplay:SetBackdropColor(self.bg_r, self.bg_g, self.bg_b, self.bg_alpha)
self.baseframe:SetBackdropColor(self.bg_r, self.bg_g, self.bg_b, self.bg_alpha)
4 years ago
return
end
3 years ago
local r, g, b = gump:ParseColors(...)
self.bgdisplay:SetBackdropColor(r, g, b, self.bg_alpha or _detalhes.default_bg_alpha)
self.baseframe:SetBackdropColor(r, g, b, self.bg_alpha or _detalhes.default_bg_alpha)
4 years ago
self.bg_r = r
self.bg_g = g
self.bg_b = b
end
function _detalhes:SetBackgroundAlpha (alpha)
if (not alpha) then
alpha = self.bg_alpha
end
3 years ago
self.bgdisplay:SetBackdropColor(self.bg_r, self.bg_g, self.bg_b, alpha)
self.baseframe:SetBackdropColor(self.bg_r, self.bg_g, self.bg_b, alpha)
4 years ago
self.bg_alpha = alpha
end
function _detalhes:GetSize()
return self.baseframe:GetWidth(), self.baseframe:GetHeight()
end
function _detalhes:GetRealSize()
return self.baseframe:GetWidth() * self.baseframe:GetScale(), self.baseframe:GetHeight() * self.baseframe:GetScale()
end
function _detalhes:GetPositionOnScreen()
local xOfs, yOfs = self.baseframe:GetCenter()
if (not xOfs) then
return
end
3 years ago
-- credits to ckknight (http://www.curseforge.com/profiles/ckknight/)
4 years ago
local _scale = self.baseframe:GetEffectiveScale()
local _UIscale = UIParent:GetScale()
xOfs = xOfs*_scale - GetScreenWidth()*_UIscale/2
yOfs = yOfs*_scale - GetScreenHeight()*_UIscale/2
return xOfs/_UIscale, yOfs/_UIscale
end
3 years ago
--alias
function _detalhes:SetSize(w, h)
4 years ago
return self:Resize (w, h)
end
function _detalhes:Resize (w, h)
if (w) then
3 years ago
self.baseframe:SetWidth(w)
4 years ago
end
3 years ago
4 years ago
if (h) then
3 years ago
self.baseframe:SetHeight(h)
4 years ago
end
3 years ago
4 years ago
self:SaveMainWindowPosition()
3 years ago
4 years ago
return true
end
--/run Details:GetWindow(1):ToggleMaxSize()
function _detalhes:ToggleMaxSize()
if (self.is_in_max_size) then
self.is_in_max_size = false
3 years ago
self:SetSize(self.original_width, self.original_height)
4 years ago
else
local original_width, original_height = self:GetSize()
self.original_width, self.original_height = original_width, original_height
self.is_in_max_size = true
3 years ago
self:SetSize(original_width, 450)
4 years ago
end
end
------------------------------------------------------------------------------------------------------------------------
3 years ago
function Details:PostponeSwitchToCurrent(instance)
4 years ago
if (
3 years ago
not instance.last_interaction or
4 years ago
(
(instance.ativa) and
3 years ago
(instance.last_interaction+3 < Details._tempo) and
(not DetailsReportWindow or not DetailsReportWindow:IsShown()) and
(not Details.playerDetailWindow:IsShown())
4 years ago
)
) then
instance._postponing_switch = nil
if (instance.segmento > 0 and instance.auto_current) then
3 years ago
instance:TrocaTabela(0) --muda o segmento pra current
instance:InstanceAlert(Loc ["STRING_CHANGED_TO_CURRENT"], {[[Interface\AddOns\Details\images\toolbar_icons]], 18, 18, false, 32/256, 64/256, 0, 1}, 6)
4 years ago
return
else
return
end
end
3 years ago
if (instance.is_interacting and instance.last_interaction < Details._tempo) then
instance.last_interaction = Details._tempo
4 years ago
end
3 years ago
--instance._postponing_switch = Details:ScheduleTimer("PostponeSwitchToCurrent", 1, instance)
instance._postponing_switch = Details.Schedules.NewTimer(1, Details.PostponeSwitchToCurrent, Details, instance)
4 years ago
end
3 years ago
function Details:CheckSwitchToCurrent()
for _, instance in ipairs(Details.tabela_instancias) do
4 years ago
if (instance.ativa and instance.auto_current and instance.baseframe and instance.segmento > 0) then
3 years ago
if (instance.is_interacting and instance.last_interaction < Details._tempo) then
instance.last_interaction = Details._tempo
4 years ago
end
3 years ago
if ((instance.last_interaction and (instance.last_interaction+3 > Details._tempo)) or (DetailsReportWindow and DetailsReportWindow:IsShown()) or (Details.playerDetailWindow:IsShown())) then
--postpone
--instance._postponing_switch = Details:ScheduleTimer("PostponeSwitchToCurrent", 1, instance)
instance._postponing_switch = Details.Schedules.NewTimer(1, Details.PostponeSwitchToCurrent, Details, instance)
4 years ago
else
3 years ago
instance:TrocaTabela(0) --muda o segmento pra current
4 years ago
instance:InstanceAlert (Loc ["STRING_CHANGED_TO_CURRENT"], {[[Interface\AddOns\Details\images\toolbar_icons]], 18, 18, false, 32/256, 64/256, 0, 1}, 6)
instance._postponing_switch = nil
end
end
end
end
3 years ago
function Details:Freeze (instancia)
4 years ago
if (not instancia) then
instancia = self
end
if (not _detalhes.initializing) then
instancia:ResetaGump()
3 years ago
Details.FadeHandler.Fader(instancia, "in", nil, "barras")
4 years ago
end
3 years ago
4 years ago
instancia:InstanceMsg (Loc ["STRING_FREEZE"], [[Interface\CHARACTERFRAME\Disconnect-Icon]], "silver")
3 years ago
4 years ago
--instancia.freeze_icon:Show()
--instancia.freeze_texto:Show()
3 years ago
4 years ago
local width = instancia:GetSize()
3 years ago
instancia.freeze_texto:SetWidth(width-64)
4 years ago
instancia.freezed = true
end
function _detalhes:UnFreeze (instancia)
if (not instancia) then
instancia = self
end
self:InstanceMsg (false)
3 years ago
4 years ago
--instancia.freeze_icon:Hide()
--instancia.freeze_texto:Hide()
instancia.freezed = false
3 years ago
4 years ago
if (not _detalhes.initializing) then
--instancia:RestoreMainWindowPosition()
instancia:ReajustaGump()
end
end
function _detalhes:AtualizaSegmentos (instancia)
if (instancia.iniciada) then
if (instancia.segmento == -1) then
3 years ago
--instancia.baseframe.rodape.segmento:SetText(segmentos.overall) --localiza-me
4 years ago
instancia.showing = _detalhes.tabela_overall
elseif (instancia.segmento == 0) then
3 years ago
--instancia.baseframe.rodape.segmento:SetText(segmentos.current) --localiza-me
4 years ago
instancia.showing = _detalhes.tabela_vigente
3 years ago
--print("==> Changing the Segment now! - classe_instancia.lua 1922")
4 years ago
else
instancia.showing = _detalhes.tabela_historico.tabelas [instancia.segmento]
3 years ago
--instancia.baseframe.rodape.segmento:SetText(segmentos.past..instancia.segmento) --localiza-me
4 years ago
end
end
end
function _detalhes:AtualizaSegmentos_AfterCombat (instancia, historico)
if (instancia.freezed) then
3 years ago
return --se esta congelada n�o tem o que fazer
4 years ago
end
local segmento = instancia.segmento
3 years ago
local _fadeType, _fadeSpeed = _unpack(_detalhes.row_fade_in)
4 years ago
3 years ago
if (segmento == _detalhes.segments_amount) then --significa que o index [5] passou a ser [6] com a entrada da nova tabela
instancia.showing = historico.tabelas [_detalhes.segments_amount] --ent�o ele volta a pegar o index [5] que antes era o index [4]
--print("==> Changing the Segment now! - classe_instancia.lua 1942")
Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras")
4 years ago
instancia.showing[instancia.atributo].need_refresh = true
instancia.v_barras = true
instancia:ResetaGump()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
_detalhes:AtualizarJanela (instancia)
3 years ago
4 years ago
elseif (segmento < _detalhes.segments_amount and segmento > 0) then
instancia.showing = historico.tabelas [segmento]
3 years ago
--print("==> Changing the Segment now! - classe_instancia.lua 1952")
Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras") --"in", nil
4 years ago
instancia.showing[instancia.atributo].need_refresh = true
instancia.v_barras = true
instancia:ResetaGump()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
_detalhes:AtualizarJanela (instancia)
end
end
local function ValidateAttribute (atributo, sub_atributo)
if (atributo == 1) then
if (sub_atributo < 0 or sub_atributo > _detalhes.atributos[1]) then
return false
end
elseif (atributo == 2) then
if (sub_atributo < 0 or sub_atributo > _detalhes.atributos[2]) then
return false
end
elseif (atributo == 3) then
if (sub_atributo < 0 or sub_atributo > _detalhes.atributos[3]) then
return false
end
elseif (atributo == 4) then
if (sub_atributo < 0 or sub_atributo > _detalhes.atributos[4]) then
return false
end
elseif (atributo == 5) then
return true
else
return false
end
3 years ago
4 years ago
return true
end
3 years ago
function _detalhes:SetDisplay(segment, attribute, subAttribute, isInstanceStarup, instanceMode)
4 years ago
if (not self.meu_id) then
return
end
3 years ago
return self:TrocaTabela(self, segment, attribute, subAttribute, isInstanceStarup, instanceMode)
4 years ago
end
3 years ago
function _detalhes:TrocaTabela(instancia, segmento, atributo, sub_atributo, iniciando_instancia, InstanceMode)
if (self and self.meu_id and not instancia) then --self � uma inst�ncia
4 years ago
InstanceMode = iniciando_instancia
iniciando_instancia = sub_atributo
sub_atributo = atributo
atributo = segmento
segmento = instancia
instancia = self
end
3 years ago
4 years ago
if (iniciando_instancia == "LeftButton") then
iniciando_instancia = nil
end
3 years ago
if (type(instancia) == "number") then
4 years ago
sub_atributo = atributo
atributo = segmento
segmento = instancia
instancia = self
end
if (InstanceMode and InstanceMode ~= instancia:GetMode()) then
3 years ago
instancia:AlteraModo(instancia, InstanceMode)
4 years ago
end
3 years ago
4 years ago
local update_coolTip = false
local sub_attribute_click = false
3 years ago
if (type(segmento) == "boolean" and segmento) then --clicou em um sub atributo
4 years ago
sub_attribute_click = true
segmento = instancia.segmento
3 years ago
elseif (segmento == -2) then --clicou para mudar de segmento
4 years ago
segmento = instancia.segmento + 1
3 years ago
4 years ago
if (segmento > _detalhes.segments_amount) then
segmento = -1
end
update_coolTip = true
3 years ago
elseif (segmento == -3) then --clicou para mudar de atributo
4 years ago
segmento = instancia.segmento
3 years ago
4 years ago
atributo = instancia.atributo+1
if (atributo > atributos[0]) then
atributo = 1
end
update_coolTip = true
3 years ago
elseif (segmento == -4) then --clicou para mudar de sub atributo
4 years ago
segmento = instancia.segmento
3 years ago
4 years ago
sub_atributo = instancia.sub_atributo+1
if (sub_atributo > atributos[instancia.atributo]) then
sub_atributo = 1
end
update_coolTip = true
3 years ago
end
--pega os atributos desta instancia
4 years ago
local current_segmento = instancia.segmento
local current_atributo = instancia.atributo
local current_sub_atributo = instancia.sub_atributo
3 years ago
4 years ago
local atributo_changed = false
3 years ago
--verifica se os valores passados s�o v�lidos
4 years ago
if (not segmento) then
segmento = instancia.segmento
3 years ago
elseif (type(segmento) ~= "number") then
4 years ago
segmento = instancia.segmento
end
3 years ago
4 years ago
if (not atributo) then
atributo = instancia.atributo
3 years ago
elseif (type(atributo) ~= "number") then
4 years ago
atributo = instancia.atributo
end
3 years ago
4 years ago
if (not sub_atributo) then
if (atributo == current_atributo) then
sub_atributo = instancia.sub_atributo
else
sub_atributo = instancia.sub_atributo_last [atributo]
end
3 years ago
elseif (type(sub_atributo) ~= "number") then
4 years ago
sub_atributo = instancia.sub_atributo
end
3 years ago
--j� esta mostrando isso que esta pedindo
4 years ago
if (not iniciando_instancia and segmento == current_segmento and atributo == current_atributo and sub_atributo == current_sub_atributo and not _detalhes.initializing) then
return
end
if (not ValidateAttribute (atributo, sub_atributo)) then
sub_atributo = 1
atributo = 1
3 years ago
_detalhes:Msg("invalid attribute, switching to damage done.")
4 years ago
end
3 years ago
--Muda o segmento caso necess�rio
if (segmento ~= current_segmento or _detalhes.initializing or iniciando_instancia) then
--na troca de segmento, conferir se a instancia esta frozen
4 years ago
if (instancia.freezed) then
if (not iniciando_instancia) then
instancia:UnFreeze()
else
instancia.freezed = false
end
end
3 years ago
4 years ago
instancia.segmento = segmento
3 years ago
if (segmento == -1) then --overall
4 years ago
instancia.showing = _detalhes.tabela_overall
3 years ago
elseif (segmento == 0) then --combate atual
4 years ago
instancia.showing = _detalhes.tabela_vigente
3 years ago
--print("==> Changing the Segment now! - classe_instancia.lua 2115")
else --alguma tabela do hist�rico
4 years ago
instancia.showing = _detalhes.tabela_historico.tabelas [segmento]
end
3 years ago
4 years ago
if (update_coolTip) then
3 years ago
_detalhes.popup:Select(1, segmento+2)
4 years ago
end
3 years ago
4 years ago
if (instancia.showing and instancia.showing.contra) then
3 years ago
--print("DEBUG: contra", instancia.showing.contra)
4 years ago
end
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGESEGMENT", nil, instancia, segmento)
4 years ago
if (_detalhes.instances_segments_locked and not iniciando_instancia) then
3 years ago
for _, instance in ipairs(_detalhes.tabela_instancias) do
4 years ago
if (instance.meu_id ~= instancia.meu_id and instance.ativa and not instance._postponing_switch and not instance._postponing_current) then
if (instance:GetSegment() >= 0 and instancia:GetSegment() ~= -1) then
if (instance.modo == 2 or instance.modo == 3) then
3 years ago
--na troca de segmento, conferir se a instancia esta frozen
4 years ago
if (instance.freezed) then
if (not iniciando_instancia) then
instance:UnFreeze()
else
instance.freezed = false
end
end
3 years ago
4 years ago
instance.segmento = segmento
3 years ago
if (segmento == -1) then --overall
4 years ago
instance.showing = _detalhes.tabela_overall
3 years ago
elseif (segmento == 0) then --combate atual
instance.showing = _detalhes.tabela_vigente; --print("==> Changing the Segment now! - classe_instancia.lua 2148")
else --alguma tabela do hist�rico
4 years ago
instance.showing = _detalhes.tabela_historico.tabelas [segmento]
end
3 years ago
4 years ago
if (not instance.showing) then
if (not iniciando_instancia) then
instance:Freeze()
end
return
end
3 years ago
4 years ago
instance.v_barras = true
instance.showing [atributo].need_refresh = true
3 years ago
4 years ago
if (not _detalhes.initializing and not iniciando_instancia) then
instance:ResetaGump()
3 years ago
instance:RefreshMainWindow(true)
4 years ago
end
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGESEGMENT", nil, instance, segmento)
4 years ago
end
end
end
end
end
end
3 years ago
--Muda o atributo caso necess�rio
4 years ago
if (atributo == 5) then
3 years ago
if (#_detalhes.custom < 1) then
4 years ago
atributo = 1
sub_atributo = 1
end
end
3 years ago
4 years ago
if (atributo ~= current_atributo or _detalhes.initializing or iniciando_instancia or (instancia.modo == modo_alone or instancia.modo == modo_raid)) then
if (instancia.modo == modo_alone and not (_detalhes.initializing or iniciando_instancia)) then
if (_detalhes.SoloTables.Mode == #_detalhes.SoloTables.Plugins) then
3 years ago
_detalhes.popup:Select(1, 1)
4 years ago
else
if (_detalhes.PluginCount.SOLO > 0) then
3 years ago
_detalhes.popup:Select(1, _detalhes.SoloTables.Mode+1)
4 years ago
end
end
return _detalhes.SoloTables.switch (nil, nil, -1)
3 years ago
elseif ((instancia.modo == modo_raid) and not (_detalhes.initializing or iniciando_instancia)) then --raid
4 years ago
return --nao faz nada quando clicar no bot�o
end
3 years ago
4 years ago
atributo_changed = true
instancia.atributo = atributo
instancia.sub_atributo = instancia.sub_atributo_last [atributo]
3 years ago
--troca icone
4 years ago
instancia:ChangeIcon()
3 years ago
4 years ago
if (update_coolTip) then
3 years ago
_detalhes.popup:Select(1, atributo)
_detalhes.popup:Select(2, instancia.sub_atributo, atributo)
4 years ago
end
3 years ago
4 years ago
if (_detalhes.cloud_process) then
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) instancia #"..instancia.meu_id.." found cloud process.")
4 years ago
end
3 years ago
4 years ago
local atributo = instancia.atributo
local time_left = (_detalhes.last_data_requested+7) - _detalhes._tempo
3 years ago
if (atributo == 1 and _detalhes.in_combat and not _detalhes:CaptureGet("damage") and _detalhes.host_by) then
4 years ago
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) instancia need damage cloud.")
4 years ago
end
3 years ago
elseif (atributo == 2 and _detalhes.in_combat and (not _detalhes:CaptureGet("heal") or _detalhes:CaptureGet("aura")) and _detalhes.host_by) then
4 years ago
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) instancia need heal cloud.")
4 years ago
end
3 years ago
elseif (atributo == 3 and _detalhes.in_combat and not _detalhes:CaptureGet("energy") and _detalhes.host_by) then
4 years ago
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) instancia need energy cloud.")
4 years ago
end
3 years ago
elseif (atributo == 4 and _detalhes.in_combat and not _detalhes:CaptureGet("miscdata") and _detalhes.host_by) then
4 years ago
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) instancia need misc cloud.")
4 years ago
end
else
time_left = nil
end
3 years ago
4 years ago
if (time_left) then
if (_detalhes.debug) then
3 years ago
_detalhes:Msg("(debug) showing instance alert.")
4 years ago
end
instancia:InstanceAlert (Loc ["STRING_PLEASE_WAIT"], {[[Interface\COMMON\StreamCircle]], 22, 22, true}, time_left)
end
end
3 years ago
_detalhes:InstanceCall(_detalhes.CheckPsUpdate)
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEATTRIBUTE", nil, instancia, atributo, sub_atributo)
4 years ago
end
if (sub_atributo ~= current_sub_atributo or _detalhes.initializing or iniciando_instancia or atributo_changed) then
instancia.sub_atributo = sub_atributo
3 years ago
4 years ago
if (sub_attribute_click) then
3 years ago
instancia.sub_atributo_last[instancia.atributo] = instancia.sub_atributo
4 years ago
end
3 years ago
if (instancia.atributo == 5) then --custom
4 years ago
instancia:ChangeIcon()
end
3 years ago
Details:InstanceCall(Details.CheckPsUpdate)
Details:SendEvent("DETAILS_INSTANCE_CHANGEATTRIBUTE", nil, instancia, atributo, sub_atributo)
4 years ago
instancia:ChangeIcon()
end
3 years ago
if (Details.playerDetailWindow:IsShown() and instancia == Details.playerDetailWindow.instancia) then
4 years ago
if (not instancia.showing or instancia.atributo > 4) then
3 years ago
Details:FechaJanelaInfo()
4 years ago
else
3 years ago
local actor = instancia.showing (instancia.atributo, Details.playerDetailWindow.jogador.nome)
4 years ago
if (actor) then
instancia:AbreJanelaInfo (actor, true)
else
3 years ago
Details:FechaJanelaInfo()
4 years ago
end
end
end
3 years ago
--if there's no combat object to show, freeze the window
4 years ago
if (not instancia.showing) then
if (not iniciando_instancia) then
instancia:Freeze()
end
return
else
3 years ago
--verificar relogio, precisaria dar refresh no plugin clock
4 years ago
end
3 years ago
4 years ago
instancia.v_barras = true
3 years ago
instancia.showing[atributo].need_refresh = true
4 years ago
3 years ago
if (not Details.initializing and not iniciando_instancia) then
4 years ago
instancia:ResetaGump()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
end
end
function _detalhes:GetRaidPluginName()
return self.current_raid_plugin or self.last_raid_plugin
end
function _detalhes:GetInstanceAttributeText()
if (self.modo == modo_grupo or self.modo == modo_all) then
local attribute = self.atributo
local sub_attribute = self.sub_atributo
local name = _detalhes:GetSubAttributeName (attribute, sub_attribute)
return name or "Unknown"
3 years ago
4 years ago
elseif (self.modo == modo_raid) then
local plugin_name = self.current_raid_plugin or self.last_raid_plugin
if (plugin_name) then
local plugin_object = _detalhes:GetPlugin (plugin_name)
if (plugin_object) then
return plugin_object.__name
else
return "Unknown Plugin"
end
else
return "Unknown Plugin"
end
3 years ago
4 years ago
elseif (self.modo == modo_alone) then
local atributo = _detalhes.SoloTables.Mode or 1
local SoloInfo = _detalhes.SoloTables.Menu [atributo]
if (SoloInfo) then
return SoloInfo [1]
else
return "Unknown Plugin"
end
end
end
function _detalhes:MontaRaidOption (instancia)
local available_plugins = _detalhes.RaidTables:GetAvailablePlugins()
if (#available_plugins == 0) then
return false
end
3 years ago
4 years ago
local amount = 0
3 years ago
for index, ptable in ipairs(available_plugins) do
4 years ago
if (ptable [3].__enabled) then
GameCooltip:AddMenu (1, _detalhes.RaidTables.switch, ptable [4], instancia, nil, ptable [1], ptable [2], true) --PluginName, PluginIcon, PluginObject, PluginAbsoluteName
amount = amount + 1
end
end
if (amount == 0) then
return false
end
3 years ago
GameCooltip:SetOption("NoLastSelectedBar", true)
4 years ago
GameCooltip:SetWallpaper (1, _detalhes.tooltip.menus_bg_texture, _detalhes.tooltip.menus_bg_coords, _detalhes.tooltip.menus_bg_color, true)
return true
end
function _detalhes:MontaSoloOption (instancia)
3 years ago
for index, ptable in ipairs(_detalhes.SoloTables.Menu) do
4 years ago
if (ptable [3].__enabled) then
GameCooltip:AddMenu (1, _detalhes.SoloTables.switch, index, nil, nil, ptable [1], ptable [2], true)
end
end
3 years ago
4 years ago
if (_detalhes.SoloTables.Mode) then
GameCooltip:SetLastSelected (1, _detalhes.SoloTables.Mode)
end
3 years ago
4 years ago
GameCooltip:SetWallpaper (1, _detalhes.tooltip.menus_bg_texture, _detalhes.tooltip.menus_bg_coords, _detalhes.tooltip.menus_bg_color, true)
3 years ago
4 years ago
return true
end
-- ~menu
local menu_wallpaper_custom_color = {1, 0, 0, 1}
local wallpaper_bg_color = {.8, .8, .8, 0.2}
local menu_icones = {
"Interface\\AddOns\\Details\\images\\atributos_icones_damage",
"Interface\\AddOns\\Details\\images\\atributos_icones_heal",
"Interface\\AddOns\\Details\\images\\atributos_icones_energyze",
"Interface\\AddOns\\Details\\images\\atributos_icones_misc"
}
3 years ago
function _detalhes:MontaAtributosOption (instancia, func)
4 years ago
func = func or instancia.TrocaTabela
local checked1 = instancia.atributo
3 years ago
local atributo_ativo = instancia.atributo --pega o numero
4 years ago
local options
3 years ago
if (atributo_ativo == 5) then --custom
4 years ago
options = {Loc ["STRING_CUSTOM_NEW"]}
3 years ago
for index, custom in ipairs(_detalhes.custom) do
4 years ago
options [#options+1] = custom.name
end
else
options = sub_atributos [atributo_ativo].lista
end
local CoolTip = _G.GameCooltip
3 years ago
local p = 0.125 --32/256
4 years ago
local gindex = 1
3 years ago
for i = 1, atributos[0] do --[0] armazena quantos atributos existem
4 years ago
CoolTip:AddMenu (1, func, nil, i, nil, atributos.lista[i], nil, true)
CoolTip:AddIcon ("Interface\\AddOns\\Details\\images\\atributos_icones", 1, 1, 20, 20, p*(i-1), p*(i), 0, 1)
3 years ago
4 years ago
if (_detalhes.tooltip.submenu_wallpaper) then
if (i == 1) then
CoolTip:SetWallpaper (2, [[Interface\TALENTFRAME\WarlockDestruction-TopLeft]], {1, 0.22, 0, 0.55}, wallpaper_bg_color)
elseif (i == 2) then
CoolTip:SetWallpaper (2, [[Interface\TALENTFRAME\bg-priest-holy]], {1, .6, 0, .2}, wallpaper_bg_color)
elseif (i == 3) then
CoolTip:SetWallpaper (2, [[Interface\TALENTFRAME\ShamanEnhancement-TopLeft]], {0, 1, .2, .6}, wallpaper_bg_color)
elseif (i == 4) then
CoolTip:SetWallpaper (2, [[Interface\TALENTFRAME\WarlockCurses-TopLeft]], {.2, 1, 0, 1}, wallpaper_bg_color)
end
else
3 years ago
--wallpaper = main window
4 years ago
--CoolTip:SetWallpaper (2, _detalhes.tooltip.menus_bg_texture, _detalhes.tooltip.menus_bg_coords, _detalhes.tooltip.menus_bg_color, true)
end
3 years ago
4 years ago
local options = sub_atributos [i].lista
if (not instancia.sub_atributo_last) then
instancia.sub_atributo_last = {1, 1, 1, 1, 1}
end
for o = 1, atributos [i] do
if (_detalhes:CaptureIsEnabled ( _detalhes.atributos_capture [gindex] )) then
CoolTip:AddMenu (2, func, true, i, o, options[o], nil, true)
CoolTip:AddIcon (menu_icones[i], 2, 1, 20, 20, p*(o-1), p*(o), 0, 1)
else
3 years ago
CoolTip:AddLine(options[o], nil, 2, .5, .5, .5, 1)
4 years ago
CoolTip:AddMenu (2, func, true, i, o)
CoolTip:AddIcon (menu_icones[i], 2, 1, 20, 20, p*(o-1), p*(o), 0, 1, {.3, .3, .3, 1})
end
gindex = gindex + 1
end
3 years ago
4 years ago
CoolTip:SetLastSelected (2, i, instancia.sub_atributo_last [i])
end
3 years ago
--custom
--GameCooltip:AddLine("$div")
CoolTip:AddLine("$div", nil, 1, -3, 1)
4 years ago
CoolTip:AddMenu (1, func, nil, 5, nil, atributos.lista[5], nil, true)
CoolTip:AddIcon ("Interface\\AddOns\\Details\\images\\atributos_icones", 1, 1, 20, 20, p*(5-1), p*(5), 0, 1)
3 years ago
4 years ago
CoolTip:AddMenu (2, _detalhes.OpenCustomDisplayWindow, nil, nil, nil, Loc ["STRING_CUSTOM_NEW"], nil, true)
CoolTip:AddIcon ([[Interface\CHATFRAME\UI-ChatIcon-Maximize-Up]], 2, 1, 20, 20, 3/32, 29/32, 3/32, 29/32)
3 years ago
CoolTip:AddLine("$div", nil, 2, nil, -8, -13)
for index, custom in ipairs(_detalhes.custom) do
4 years ago
if (custom.temp) then
3 years ago
CoolTip:AddLine(custom.name .. Loc ["STRING_CUSTOM_TEMPORARILY"], nil, 2)
4 years ago
else
3 years ago
CoolTip:AddLine(custom.name, nil, 2)
4 years ago
end
3 years ago
4 years ago
CoolTip:AddMenu (2, func, true, 5, index)
CoolTip:AddIcon (custom.icon, 2, 1, 20, 20)
end
3 years ago
--set the wallpaper on custom
4 years ago
if (_detalhes.tooltip.submenu_wallpaper) then
CoolTip:SetWallpaper (2, [[Interface\TALENTFRAME\WarriorArm-TopLeft]], menu_wallpaper_custom_color, wallpaper_bg_color)
else
--CoolTip:SetWallpaper (2, _detalhes.tooltip.menus_bg_texture, _detalhes.tooltip.menus_bg_coords, _detalhes.tooltip.menus_bg_color, true)
end
if (#_detalhes.custom == 0) then
CoolTip:SetLastSelected (2, 6, 2)
else
if (instancia.atributo == 5) then
CoolTip:SetLastSelected (2, 6, instancia.sub_atributo+2)
else
CoolTip:SetLastSelected (2, 6, instancia.sub_atributo_last [5]+2)
end
end
3 years ago
CoolTip:SetOption("StatusBarTexture", [[Interface\AddOns\Details\images\bar4_vidro]])
CoolTip:SetOption("ButtonsYMod", -7)
CoolTip:SetOption("HeighMod", 7)
CoolTip:SetOption("ButtonsYModSub", -7)
CoolTip:SetOption("HeighModSub", 7)
CoolTip:SetOption("SelectedTopAnchorMod", -2)
CoolTip:SetOption("SelectedBottomAnchorMod", 2)
CoolTip:SetOption("TextFont", _detalhes.font_faces.menus)
4 years ago
_detalhes:SetTooltipMinWidth()
3 years ago
4 years ago
local last_selected = atributo_ativo
if (atributo_ativo == 5) then
last_selected = 6
end
CoolTip:SetLastSelected (1, last_selected)
3 years ago
4 years ago
--removed the menu backdrop
--CoolTip:SetWallpaper (1, _detalhes.tooltip.menus_bg_texture, _detalhes.tooltip.menus_bg_coords, _detalhes.tooltip.menus_bg_color, true)
3 years ago
4 years ago
return menu_principal, sub_menus
end
local iconCoords = {
[1] = {-1, 0, 0, 0, -1, -1, 0, 0}, --damage, dps, taken, friendldire, frags, enemy damage taken, auras, by spell
[2] = {0, 1, 1, 1, 0, 0, 1}, --healing, hps, overheal, taken, enemyheal, damageprevented, healabsorbed
[3] = {0, -2, -1, 0, 0, 0}, --mana, rage, energy, rune, other resources, alternate power
[4] = {0, 0, -1, 0, 0, 0, 0, 0}, --ccBreak, res, kick, dispel, deaths, cooldowns, buffUptime, debuffUptime
}
local getFineTunedIconCoords = function(attribute, subAttribute)
return iconCoords[attribute] and iconCoords[attribute][subAttribute] or 0
end
function _detalhes:ChangeIcon(icon)
local skin = _detalhes.skins [self.skin]
if (not skin) then
skin = _detalhes.skins [_detalhes.default_skin_to_use]
end
if (not self.hide_icon) then
if (skin.icon_on_top) then
3 years ago
self.baseframe.cabecalho.atributo_icon:SetParent(self.floatingframe)
4 years ago
else
3 years ago
self.baseframe.cabecalho.atributo_icon:SetParent(self.baseframe)
4 years ago
end
end
if (icon) then
3 years ago
--plugin chamou uma troca de icone
self.baseframe.cabecalho.atributo_icon:SetTexture(icon)
self.baseframe.cabecalho.atributo_icon:SetTexCoord(5/64, 60/64, 3/64, 62/64)
4 years ago
local icon_size = skin.icon_plugins_size
3 years ago
self.baseframe.cabecalho.atributo_icon:SetWidth(icon_size[1])
self.baseframe.cabecalho.atributo_icon:SetHeight(icon_size[2])
4 years ago
local icon_anchor = skin.icon_anchor_plugins
self.baseframe.cabecalho.atributo_icon:ClearAllPoints()
3 years ago
self.baseframe.cabecalho.atributo_icon:SetPoint("TOPRIGHT", self.baseframe.cabecalho.ball_point, "TOPRIGHT", icon_anchor[1], icon_anchor[2])
4 years ago
3 years ago
elseif (self.modo == modo_alone) then --solo
4 years ago
--icon is set by the plugin
3 years ago
elseif (self.modo == modo_grupo or self.modo == modo_all) then --grupo
4 years ago
if (self.atributo == 5) then
3 years ago
--custom
4 years ago
if (_detalhes.custom [self.sub_atributo]) then
local icon = _detalhes.custom [self.sub_atributo].icon
3 years ago
self.baseframe.cabecalho.atributo_icon:SetTexture(icon)
self.baseframe.cabecalho.atributo_icon:SetTexCoord(5/64, 60/64, 3/64, 62/64)
4 years ago
local icon_size = skin.icon_plugins_size
3 years ago
self.baseframe.cabecalho.atributo_icon:SetWidth(icon_size[1])
self.baseframe.cabecalho.atributo_icon:SetHeight(icon_size[2])
4 years ago
local icon_anchor = skin.icon_anchor_plugins
3 years ago
4 years ago
self.baseframe.cabecalho.atributo_icon:ClearAllPoints()
3 years ago
self.baseframe.cabecalho.atributo_icon:SetPoint("TOPRIGHT", self.baseframe.cabecalho.ball_point, "TOPRIGHT", icon_anchor[1], icon_anchor[2])
4 years ago
end
else
--set the attribute icon
3 years ago
self.baseframe.cabecalho.atributo_icon:SetTexture(menu_icones [self.atributo])
4 years ago
if (self.icon_desaturated) then
self.baseframe.cabecalho.atributo_icon:SetDesaturated(true)
else
self.baseframe.cabecalho.atributo_icon:SetDesaturated(false)
end
3 years ago
local p = 0.125 --32/256
self.baseframe.cabecalho.atributo_icon:SetTexCoord(p * (self.sub_atributo-1), p * (self.sub_atributo), 0, 1)
self.baseframe.cabecalho.atributo_icon:SetSize(16, 16)
4 years ago
self.baseframe.cabecalho.atributo_icon:ClearAllPoints()
if (self.menu_attribute_string) then
local yOffset = getFineTunedIconCoords(self.atributo, self.sub_atributo)
3 years ago
self.baseframe.cabecalho.atributo_icon:SetPoint("right", self.menu_attribute_string.widget, "left", -4, 1 + yOffset)
4 years ago
end
3 years ago
4 years ago
if (skin.attribute_icon_anchor) then
self.baseframe.cabecalho.atributo_icon:ClearAllPoints()
3 years ago
self.baseframe.cabecalho.atributo_icon:SetPoint("topleft", self.baseframe.cabecalho.ball_point, "topleft", skin.attribute_icon_anchor[1], skin.attribute_icon_anchor[2])
4 years ago
end
3 years ago
4 years ago
if (skin.attribute_icon_size) then
3 years ago
self.baseframe.cabecalho.atributo_icon:SetSize(unpack(skin.attribute_icon_size))
4 years ago
end
end
3 years ago
elseif (self.modo == modo_raid) then --raid
4 years ago
--icon is set by the plugin
end
end
function _detalhes:SetMode (qual)
return self:AlteraModo (qual)
end
function _detalhes:AlteraModo (instancia, qual, from_mode_menu)
3 years ago
if (type(instancia) == "number") then
4 years ago
qual = instancia
instancia = self
end
3 years ago
4 years ago
local update_coolTip = false
3 years ago
4 years ago
if (qual == -2) then --clicou para mudar
local update_coolTip = true
3 years ago
4 years ago
if (instancia.modo == 1) then
qual = 2
elseif (instancia.modo == 2) then
qual = 3
elseif (instancia.modo == 3) then
qual = 4
elseif (instancia.modo == 4) then
qual = 1
end
end
if (instancia.showing) then
if (not instancia.atributo) then
instancia.atributo = 1
instancia.sub_atributo = 1
end
if (not instancia.showing[instancia.atributo]) then
3 years ago
instancia.showing = _detalhes.tabela_vigente; --print("==> Changing the Segment now! - classe_instancia.lua 2636")
4 years ago
end
instancia.atributo = instancia.atributo or 1
instancia.showing[instancia.atributo].need_refresh = true
end
if (qual == modo_alone) then
3 years ago
4 years ago
instancia.LastModo = instancia.modo
3 years ago
4 years ago
if (instancia:IsRaidMode()) then
_detalhes.RaidTables:DisableRaidMode (instancia)
end
3 years ago
--verifica se ja tem alguma instancia desativada em solo e remove o solo dela
4 years ago
_detalhes:InstanciaCallFunctionOffline (_detalhes.InstanciaCheckForDisabledSolo)
3 years ago
4 years ago
instancia.modo = modo_alone
instancia:ChangeIcon()
3 years ago
4 years ago
instancia:SoloMode (true)
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEMODE", nil, instancia, modo_alone)
4 years ago
elseif (qual == modo_raid) then
3 years ago
4 years ago
instancia.LastModo = instancia.modo
3 years ago
4 years ago
if (instancia:IsSoloMode()) then
instancia:SoloMode (false)
end
--_detalhes:InstanciaCallFunctionOffline (_detalhes.InstanciaCheckForDisabledRaid)
instancia.modo = modo_raid
instancia:ChangeIcon()
3 years ago
4 years ago
_detalhes.RaidTables:EnableRaidMode (instancia)
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEMODE", nil, instancia, modo_raid)
4 years ago
elseif (qual == modo_grupo) then
3 years ago
4 years ago
instancia.LastModo = instancia.modo
3 years ago
4 years ago
if (instancia:IsSoloMode()) then
--instancia.modo = modo_grupo
instancia:SoloMode (false)
elseif (instancia:IsRaidMode()) then
_detalhes.RaidTables:DisableRaidMode (instancia)
end
3 years ago
4 years ago
_detalhes:ResetaGump (instancia)
3 years ago
--Details.FadeHandler.Fader(instancia, 1, nil, "barras")
4 years ago
instancia.modo = modo_grupo
instancia:ChangeIcon()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
instancia.last_modo = modo_grupo
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEMODE", nil, instancia, modo_grupo)
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEATTRIBUTE", nil, instancia, instancia.atributo, instancia.sub_atributo)
4 years ago
elseif (qual == modo_all) then
3 years ago
4 years ago
instancia.LastModo = instancia.modo
3 years ago
4 years ago
if (instancia:IsSoloMode()) then
instancia.modo = modo_all
instancia:SoloMode (false)
elseif (instancia:IsRaidMode()) then
_detalhes.RaidTables:DisableRaidMode (instancia)
end
3 years ago
4 years ago
instancia.modo = modo_all
instancia:ChangeIcon()
3 years ago
instancia:RefreshMainWindow(true)
4 years ago
instancia.last_modo = modo_all
3 years ago
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEMODE", nil, instancia, modo_all)
_detalhes:SendEvent("DETAILS_INSTANCE_CHANGEATTRIBUTE", nil, instancia, instancia.atributo, instancia.sub_atributo)
4 years ago
end
local checked
if (instancia.modo == 1) then
checked = 4
elseif (instancia.modo == 2) then
checked = 1
elseif (instancia.modo == 3) then
checked = 2
elseif (instancia.modo == 4) then
checked = 3
3 years ago
end
_detalhes.popup:Select(1, checked)
4 years ago
if (from_mode_menu) then
3 years ago
instancia.baseframe.cabecalho.modo_selecao:GetScript("OnEnter")(instancia.baseframe.cabecalho.modo_selecao, _, true)
--running OnEnter does also trigger an instance enter event, so we need to manually leave the instance:
_detalhes.OnLeaveMainWindow(instancia, instancia.baseframe.cabecalho.modo_selecao)
4 years ago
if (instancia.desaturated_menu) then
3 years ago
instancia.baseframe.cabecalho.modo_selecao:GetNormalTexture():SetDesaturated(true)
4 years ago
end
end
end
local function GetDpsHps (_thisActor, key)
local keyname
if (key == "dps") then
keyname = "last_dps"
elseif (key == "hps") then
keyname = "last_hps"
end
3 years ago
4 years ago
if (_thisActor [keyname]) then
return _thisActor [keyname]
else
3 years ago
if ((_detalhes.time_type == 2 and _thisActor.grupo) or not _detalhes:CaptureGet("damage")) then
4 years ago
local dps = _thisActor.total / _thisActor:GetCombatTime()
_thisActor [keyname] = dps
return dps
else
if (not _thisActor.on_hold) then
local dps = _thisActor.total/_thisActor:Tempo() --calcula o dps deste objeto
_thisActor [keyname] = dps --salva o dps dele
return dps
else
3 years ago
if (_thisActor [keyname] == 0) then --n�o calculou o dps dele ainda mas entrou em standby
4 years ago
local dps = _thisActor.total/_thisActor:Tempo()
_thisActor [keyname] = dps
return dps
else
return _thisActor [keyname]
end
end
end
end
end
-- table sent to report func / f1: format value1 / f2: format value2
-- report_table = a table header: {"report results for:"}
-- data = table with {{value1 (string), value2 ( the value)} , {value1 (string), value2 ( the value)}}
3 years ago
local default_format_value1 = function(v) return v end
local default_format_value2 = function(v) return v end
local default_format_value3 = function(i, v1, v2)
4 years ago
return "" .. i .. ". " .. v1 .. " " .. v2
end
function _detalhes:FormatReportLines (report_table, data, f1, f2, f3)
f1 = f1 or default_format_value1
f2 = f2 or default_format_value2
f3 = f3 or default_format_value3
3 years ago
4 years ago
if (not _detalhes.fontstring_len) then
3 years ago
_detalhes.fontstring_len = _detalhes.listener:CreateFontString(nil, "background", "GameFontNormal")
4 years ago
end
local _, fontSize = FCF_GetChatWindowInfo (1)
if (fontSize < 1) then
fontSize = 10
end
local fonte, _, flags = _detalhes.fontstring_len:GetFont()
_detalhes.fontstring_len:SetFont(fonte, fontSize, flags)
3 years ago
_detalhes.fontstring_len:SetText("DEFAULT NAME")
local biggest_len = _detalhes.fontstring_len:GetStringWidth()
for index, t in ipairs(data) do
4 years ago
local v1 = f1 (t[1])
3 years ago
_detalhes.fontstring_len:SetText(v1)
4 years ago
local len = _detalhes.fontstring_len:GetStringWidth()
if (len > biggest_len) then
biggest_len = len
end
end
3 years ago
4 years ago
if (biggest_len > 130) then
biggest_len = 130
end
3 years ago
for index, t in ipairs(data) do
4 years ago
local v1, v2 = f1 (t[1]), f2 (t[2])
3 years ago
if (v1 and v2 and type(v1) == "string" and type(v2) == "string") then
4 years ago
v1 = v1 .. " "
3 years ago
_detalhes.fontstring_len:SetText(v1)
4 years ago
local len = _detalhes.fontstring_len:GetStringWidth()
3 years ago
while (len < biggest_len) do
4 years ago
v1 = v1 .. "."
3 years ago
_detalhes.fontstring_len:SetText(v1)
4 years ago
len = _detalhes.fontstring_len:GetStringWidth()
3 years ago
end
4 years ago
report_table [#report_table+1] = f3 (index, v1, v2)
end
end
3 years ago
4 years ago
end
3 years ago
local report_name_function = function(name)
local name, index = unpack(name)
if (_detalhes.remove_realm_from_name and name:find("-")) then
return index .. ". " .. name:gsub(("%-.*"), "")
4 years ago
else
return index .. ". " .. name
end
end
3 years ago
local report_amount_function = function(t)
local amount, dps, percent, is_string, index = unpack(t)
4 years ago
if (not is_string) then
if (dps) then
if (_detalhes.report_schema == 1) then
3 years ago
return _detalhes:ToKReport (_math_floor(amount)) .. " (" .. _detalhes:ToKMin (_math_floor(dps)) .. ", " .. percent .. "%)"
4 years ago
elseif (_detalhes.report_schema == 2) then
3 years ago
return percent .. "% (" .. _detalhes:ToKMin (_math_floor(dps)) .. ", " .. _detalhes:ToKReport ( _math_floor(amount)) .. ")"
4 years ago
elseif (_detalhes.report_schema == 3) then
3 years ago
return percent .. "% (" .. _detalhes:ToKReport ( _math_floor(amount) ) .. ", " .. _detalhes:ToKMin (_math_floor(dps)) .. ")"
4 years ago
end
else
if (_detalhes.report_schema == 1) then
return _detalhes:ToKReport (amount) .. " (" .. percent .. "%)"
else
return percent .. "% (" .. _detalhes:ToKReport (amount) .. ")"
end
end
else
return amount
end
end
3 years ago
local report_build_line = function(i, v1, v2)
4 years ago
return v1 .. " " .. v2
end
3 years ago
--Reportar o que esta na janela da inst�ncia
4 years ago
function _detalhes:monta_relatorio (este_relatorio, custom)
if (custom) then
3 years ago
--shrink
4 years ago
local report_lines = {}
for i = 1, _detalhes.report_lines+1, 1 do --#este_relatorio -- o +1 � pq ele conta o cabe�alho como uma linha
report_lines [#report_lines+1] = este_relatorio[i]
end
3 years ago
4 years ago
return self:envia_relatorio (report_lines, true)
end
local amt = _detalhes.report_lines
local report_lines = {}
3 years ago
if (self.atributo == 5) then --custom
4 years ago
if (self.segmento == -1) then --overall
report_lines [#report_lines+1] = "Details!: " .. Loc ["STRING_OVERALL"] .. " " .. self.customName .. " " .. Loc ["STRING_CUSTOM_REPORT"]
else
report_lines [#report_lines+1] = "Details!: " .. self.customName .. " " .. Loc ["STRING_CUSTOM_REPORT"]
end
else
if (self.segmento == -1) then --overall
report_lines [#report_lines+1] = "Details!: " .. Loc ["STRING_OVERALL"] .. " " .. _detalhes.sub_atributos [self.atributo].lista [self.sub_atributo]
else
report_lines [#report_lines+1] = "Details!: " .. _detalhes.sub_atributos [self.atributo].lista [self.sub_atributo]
end
end
3 years ago
4 years ago
if (self.meu_id and self.atributo and self.sub_atributo and _detalhes.report_where ~= "WHISPER" and _detalhes.report_where ~= "WHISPER2") then
local already_exists
3 years ago
for index, reported in ipairs(_detalhes.latest_report_table) do
4 years ago
if (reported [1] == self.meu_id and reported [2] == self.atributo and reported [3] == self.sub_atributo and reported [5] == _detalhes.report_where) then
already_exists = index
break
end
end
3 years ago
4 years ago
if (already_exists) then
--push it to front
3 years ago
local t = tremove(_detalhes.latest_report_table, already_exists)
4 years ago
t [4] = amt
3 years ago
tinsert(_detalhes.latest_report_table, 1, t)
4 years ago
else
if (self.atributo == 5) then
local custom_name = self:GetCustomObject():GetName()
3 years ago
tinsert(_detalhes.latest_report_table, 1, {self.meu_id, self.atributo, self.sub_atributo, amt, _detalhes.report_where, custom_name})
4 years ago
else
3 years ago
tinsert(_detalhes.latest_report_table, 1, {self.meu_id, self.atributo, self.sub_atributo, amt, _detalhes.report_where})
4 years ago
end
end
3 years ago
tremove(_detalhes.latest_report_table, 11)
4 years ago
end
3 years ago
4 years ago
local barras = self.barras
local esta_barra
local is_current = _G ["Details_Report_CB_1"]:GetChecked()
local is_reverse = _G ["Details_Report_CB_2"]:GetChecked()
local name_member = "nome"
3 years ago
4 years ago
if (not is_current) then
local total, keyName, keyNameSec, first
local container_amount = 0
local atributo = self.atributo
local container = self.showing [atributo]._ActorTable
3 years ago
if (atributo == 1) then --damage
if (self.sub_atributo == 5) then --frags
4 years ago
local frags = self.showing.frags
local reportarFrags = {}
3 years ago
for name, amount in pairs(frags) do
--string para imprimir direto sem calculos
reportarFrags [#reportarFrags+1] = {frag = tostring(amount), nome = name}
4 years ago
end
container = reportarFrags
container_amount = #reportarFrags
keyName = "frag"
3 years ago
elseif (self.sub_atributo == 7) then --auras e voidzones
4 years ago
total, keyName, first, container_amount, container, name_member = _detalhes.atributo_damage:RefreshWindow (self, self.showing, true, true)
3 years ago
elseif (self.sub_atributo == 8) then --damage taken by spell
4 years ago
total, keyName, first, container_amount, container = _detalhes.atributo_damage:RefreshWindow (self, self.showing, true, true)
3 years ago
for _, t in ipairs(container) do
t.nome = _detalhes:GetSpellLink(t.spellid)
4 years ago
end
3 years ago
4 years ago
else
total, keyName, first, container_amount = _detalhes.atributo_damage:RefreshWindow (self, self.showing, true, true)
if (self.sub_atributo == 1) then
keyNameSec = "dps"
elseif (self.sub_atributo == 2) then
3 years ago
4 years ago
end
end
3 years ago
elseif (atributo == 2) then --heal
4 years ago
total, keyName, first, container_amount = _detalhes.atributo_heal:RefreshWindow (self, self.showing, true, true)
if (self.sub_atributo == 1) then
keyNameSec = "hps"
end
3 years ago
elseif (atributo == 3) then --energy
4 years ago
total, keyName, first, container_amount = _detalhes.atributo_energy:RefreshWindow (self, self.showing, true, true)
3 years ago
elseif (atributo == 4) then --misc
if (self.sub_atributo == 5) then --mortes
4 years ago
local mortes = self.showing.last_events_tables
local reportarMortes = {}
3 years ago
for index, morte in ipairs(mortes) do
reportarMortes [#reportarMortes+1] = {dead = morte [6], nome = morte [3]:gsub(("%-.*"), "")}
4 years ago
end
container = reportarMortes
container_amount = #reportarMortes
keyName = "dead"
else
total, keyName, first, container_amount = _detalhes.atributo_misc:RefreshWindow (self, self.showing, true, true)
end
3 years ago
elseif (atributo == 5) then --custom
4 years ago
if (_detalhes.custom [self.sub_atributo]) then
total, container, first, container_amount, nm = _detalhes.atributo_custom:RefreshWindow (self, self.showing, true, true)
if (nm) then
name_member = nm
end
keyName = "report_value"
else
total, keyName, first, container_amount = _detalhes.atributo_damage:RefreshWindow (self, self.showing, true, true)
total = 1
atributo = 1
container = self.showing [atributo]._ActorTable
end
end
3 years ago
4 years ago
amt = math.min (amt, container_amount or 0)
local raw_data_to_report = {}
3 years ago
for i = 1, container_amount do
4 years ago
local actor = container [i]
3 years ago
if (actor) then
4 years ago
-- get the total
local amount, is_string
3 years ago
if (type(actor [keyName]) == "number") then
amount = _math_floor(actor [keyName])
4 years ago
else
amount = actor [keyName]
is_string = true
end
3 years ago
4 years ago
-- get the name
local name = actor [name_member] or ""
3 years ago
4 years ago
if (not is_string) then
-- get the percent
local percent
if (self.atributo == 2 and self.sub_atributo == 3) then --overheal
percent = _cstr ("%.1f", actor.totalover / (actor.totalover + actor.total) * 100)
elseif (not is_string) then
percent = _cstr ("%.1f", amount / max(total, 0.00001) * 100)
end
3 years ago
4 years ago
-- get the dps
local dps = false
if (keyNameSec) then
dps = GetDpsHps (actor, keyNameSec)
end
3 years ago
4 years ago
raw_data_to_report [#raw_data_to_report+1] = {{name, i}, {amount, dps, percent, false}}
else
raw_data_to_report [#raw_data_to_report+1] = {{name, i}, {amount, false, false, true}}
end
3 years ago
4 years ago
else
break
end
end
if (is_reverse) then
local t = {}
for i = #raw_data_to_report, 1, -1 do
3 years ago
tinsert(t, raw_data_to_report [i])
4 years ago
if (#t >= amt) then
break
end
end
_detalhes:FormatReportLines (report_lines, t, report_name_function, report_amount_function, report_build_line)
else
for i = #raw_data_to_report, amt+1, -1 do
3 years ago
tremove(raw_data_to_report, i)
4 years ago
end
_detalhes:FormatReportLines (report_lines, raw_data_to_report, report_name_function, report_amount_function, report_build_line)
end
else
local raw_data_to_report = {}
3 years ago
4 years ago
for i = 1, amt do
local window_bar = self.barras [i]
if (window_bar) then
if (not window_bar.hidden or window_bar.fading_out) then
raw_data_to_report [#raw_data_to_report+1] = {window_bar.lineText1:GetText(), window_bar.lineText4:GetText()}
else
break
end
else
break
end
end
3 years ago
4 years ago
_detalhes:FormatReportLines (report_lines, raw_data_to_report, nil, nil, report_build_line)
3 years ago
4 years ago
end
return self:envia_relatorio (report_lines)
end
function _detalhes:envia_relatorio (linhas, custom)
local segmento = self.segmento
local luta = nil
local combatObject
3 years ago
4 years ago
if (not custom) then
3 years ago
4 years ago
if (not linhas[1]) then
3 years ago
return _detalhes:Msg(Loc ["STRING_ACTORFRAME_NOTHING"])
4 years ago
end
if (segmento == -1) then --overall
--luta = Loc ["STRING_REPORT_LAST"] .. " " .. #_detalhes.tabela_historico.tabelas .. " " .. Loc ["STRING_REPORT_FIGHTS"]
luta = _detalhes.tabela_overall.overall_enemy_name
combatObject = _detalhes.tabela_overall
3 years ago
4 years ago
elseif (segmento == 0) then --current
3 years ago
4 years ago
if (_detalhes.tabela_vigente.is_boss) then
local encounterName = _detalhes.tabela_vigente.is_boss.name
if (encounterName) then
luta = encounterName
end
3 years ago
4 years ago
elseif (_detalhes.tabela_vigente.is_pvp) then
local battleground_name = _detalhes.tabela_vigente.is_pvp.name
if (battleground_name) then
luta = battleground_name
end
end
3 years ago
4 years ago
local isMythicDungeon = _detalhes.tabela_vigente:IsMythicDungeon()
if (isMythicDungeon) then
local mythicDungeonInfo = _detalhes.tabela_vigente:GetMythicDungeonInfo()
if (mythicDungeonInfo) then
local isMythicOverallSegment, segmentID, mythicLevel, EJID, mapID, zoneName, encounterID, encounterName, startedAt, endedAt, runID = _detalhes:UnpackMythicDungeonInfo (mythicDungeonInfo)
3 years ago
4 years ago
if (isMythicOverallSegment) then
luta = zoneName .. " +" .. mythicLevel .. " (" .. Loc ["STRING_SEGMENTS_LIST_OVERALL"] .. ")"
else
if (segmentID == "trashoverall") then
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_TRASH"] .. ")"
else
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_BOSS"] .. ")"
end
end
else
luta = Loc ["STRING_SEGMENTS_LIST_TRASH"]
end
end
3 years ago
4 years ago
if (not luta) then
if (_detalhes.tabela_vigente.enemy) then
luta = _detalhes.tabela_vigente.enemy
end
end
3 years ago
4 years ago
if (not luta) then
luta = _detalhes.segmentos.current
end
3 years ago
4 years ago
combatObject = _detalhes.tabela_vigente
3 years ago
4 years ago
else
if (segmento == 1) then
3 years ago
4 years ago
if (_detalhes.tabela_historico.tabelas[1].is_boss) then
local encounterName = _detalhes.tabela_historico.tabelas[1].is_boss.name
if (encounterName) then
luta = encounterName .. " (" .. Loc ["STRING_REPORT_LASTFIGHT"] .. ")"
end
3 years ago
4 years ago
elseif (_detalhes.tabela_historico.tabelas[1].is_pvp) then
local battleground_name = _detalhes.tabela_historico.tabelas[1].is_pvp.name
if (battleground_name) then
luta = battleground_name .. " (" .. Loc ["STRING_REPORT_LASTFIGHT"] .. ")"
end
end
3 years ago
4 years ago
local thisSegment = _detalhes.tabela_historico.tabelas[1]
local isMythicDungeon = thisSegment:IsMythicDungeon()
if (isMythicDungeon) then
local mythicDungeonInfo = thisSegment:GetMythicDungeonInfo()
if (mythicDungeonInfo) then
local isMythicOverallSegment, segmentID, mythicLevel, EJID, mapID, zoneName, encounterID, encounterName, startedAt, endedAt, runID = _detalhes:UnpackMythicDungeonInfo (mythicDungeonInfo)
3 years ago
4 years ago
if (isMythicOverallSegment) then
luta = zoneName .. " +" .. mythicLevel .. " (" .. Loc ["STRING_SEGMENTS_LIST_OVERALL"] .. ")"
else
if (segmentID == "trashoverall") then
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_TRASH"] .. ")"
else
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_BOSS"] .. ")"
end
end
else
luta = Loc ["STRING_SEGMENTS_LIST_TRASH"]
end
end
3 years ago
4 years ago
if (not luta) then
if (_detalhes.tabela_historico.tabelas[1].enemy) then
luta = _detalhes.tabela_historico.tabelas[1].enemy .. " (" .. Loc ["STRING_REPORT_LASTFIGHT"] .. ")"
end
end
3 years ago
4 years ago
if (not luta) then
luta = Loc ["STRING_REPORT_LASTFIGHT"]
end
3 years ago
4 years ago
combatObject = _detalhes.tabela_historico.tabelas[1]
3 years ago
4 years ago
else
3 years ago
4 years ago
if (_detalhes.tabela_historico.tabelas[segmento].is_boss) then
local encounterName = _detalhes.tabela_historico.tabelas[segmento].is_boss.name
if (encounterName) then
luta = encounterName .. " (" .. segmento .. " " .. Loc ["STRING_REPORT_PREVIOUSFIGHTS"] .. ")"
end
3 years ago
4 years ago
elseif (_detalhes.tabela_historico.tabelas[segmento].is_pvp) then
local battleground_name = _detalhes.tabela_historico.tabelas[segmento].is_pvp.name
if (battleground_name) then
luta = battleground_name .. " (" .. Loc ["STRING_REPORT_LASTFIGHT"] .. ")"
end
end
3 years ago
4 years ago
local thisSegment = _detalhes.tabela_historico.tabelas [segmento]
local isMythicDungeon = thisSegment:IsMythicDungeon()
if (isMythicDungeon) then
local mythicDungeonInfo = thisSegment:GetMythicDungeonInfo()
if (mythicDungeonInfo) then
local isMythicOverallSegment, segmentID, mythicLevel, EJID, mapID, zoneName, encounterID, encounterName, startedAt, endedAt, runID = _detalhes:UnpackMythicDungeonInfo (mythicDungeonInfo)
3 years ago
4 years ago
if (isMythicOverallSegment) then
luta = zoneName .. " +" .. mythicLevel .. " (" .. Loc ["STRING_SEGMENTS_LIST_OVERALL"] .. ")"
else
if (segmentID == "trashoverall") then
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_TRASH"] .. ")"
else
luta = encounterName .. " (" .. Loc ["STRING_SEGMENTS_LIST_BOSS"] .. ")"
end
end
else
luta = Loc ["STRING_SEGMENTS_LIST_TRASH"]
end
end
3 years ago
4 years ago
if (not luta) then
if (_detalhes.tabela_historico.tabelas[segmento].enemy) then
luta = _detalhes.tabela_historico.tabelas[segmento].enemy .. " (" .. segmento .. " " .. Loc ["STRING_REPORT_PREVIOUSFIGHTS"] .. ")"
end
end
3 years ago
4 years ago
if (not luta) then
luta = " (" .. segmento .. " " .. Loc ["STRING_REPORT_PREVIOUSFIGHTS"] .. ")"
end
3 years ago
4 years ago
combatObject = _detalhes.tabela_historico.tabelas[segmento]
end
end
3 years ago
4 years ago
linhas[1] = linhas[1] .. " " .. Loc ["STRING_REPORT"] .. " " .. luta
end
3 years ago
4 years ago
--adicionar o tempo de luta
local segmentTime = ""
if (combatObject) then
3 years ago
local combatTime = combatObject:GetCombatTime()
segmentTime = _detalhes.gump:IntegerToTimer(combatTime or 0)
4 years ago
end
3 years ago
4 years ago
--effective ou active time
if (_detalhes.time_type == 2) then
linhas[1] = linhas[1] .. " [" .. segmentTime .. " EF]"
else
linhas[1] = linhas[1] .. " [" .. segmentTime .. " AC]"
end
3 years ago
4 years ago
local editbox = _detalhes.janela_report.editbox
3 years ago
if (editbox.focus) then --n�o precionou enter antes de clicar no okey
4 years ago
local texto = _detalhes:trim (editbox:GetText())
if (_string_len (texto) > 0) then
_detalhes.report_to_who = texto
editbox:AddHistoryLine (texto)
3 years ago
editbox:SetText(texto)
4 years ago
else
_detalhes.report_to_who = ""
3 years ago
editbox:SetText("")
end
editbox.perdeu_foco = true --isso aqui pra quando estiver editando e clicar em outra caixa
4 years ago
editbox:ClearFocus()
end
_detalhes:DelayUpdateReportWindowRecentlyReported()
3 years ago
4 years ago
if (_detalhes.report_where == "COPY") then
_detalhes:SendReportTextWindow (linhas)
return
end
3 years ago
4 years ago
local to_who = _detalhes.report_where
3 years ago
local channel = to_who:find("CHANNEL")
local is_btag = to_who:find("REALID")
local send_report_channel = function(timerObject)
4 years ago
_SendChatMessage (timerObject.Arg1, timerObject.Arg2, timerObject.Arg3, timerObject.Arg4)
end
3 years ago
local sendReportBnet = function(timerObject)
4 years ago
BNSendWhisper(timerObject.Arg1, timerObject.Arg2)
end
3 years ago
4 years ago
local delay = 200
3 years ago
4 years ago
if (channel) then
3 years ago
channel = to_who:gsub((".*|"), "")
for i = 1, #linhas do
4 years ago
if (channel == "Trade") then
channel = "Trade - City"
end
3 years ago
4 years ago
local channelName = GetChannelName (channel)
3 years ago
local timer = C_Timer.NewTimer(i * delay / 1000, send_report_channel)
4 years ago
timer.Arg1 = linhas[i]
timer.Arg2 = "CHANNEL"
timer.Arg3 = nil
timer.Arg4 = channelName
end
3 years ago
4 years ago
return
3 years ago
4 years ago
elseif (is_btag) then
3 years ago
local bnetAccountID = to_who:gsub((".*|"), "")
4 years ago
bnetAccountID = tonumber(bnetAccountID)
3 years ago
4 years ago
for i = 1, #linhas do
3 years ago
local timer = C_Timer.NewTimer(i * delay / 1000, sendReportBnet)
4 years ago
timer.Arg1 = bnetAccountID
timer.Arg2 = linhas[i]
end
3 years ago
4 years ago
return
3 years ago
elseif (to_who == "WHISPER") then --whisper
4 years ago
local alvo = _detalhes.report_to_who
3 years ago
4 years ago
if (not alvo or alvo == "") then
3 years ago
_detalhes:Msg(Loc ["STRING_REPORT_INVALIDTARGET"])
4 years ago
return
end
3 years ago
for i = 1, #linhas do
local timer = C_Timer.NewTimer(i * delay / 1000, send_report_channel)
4 years ago
timer.Arg1 = linhas[i]
timer.Arg2 = to_who
timer.Arg3 = nil
timer.Arg4 = alvo
end
return
3 years ago
elseif (to_who == "WHISPER2") then --whisper target
4 years ago
to_who = "WHISPER"
3 years ago
4 years ago
local alvo
if (_UnitExists ("target")) then
if (_UnitIsPlayer ("target")) then
local nome, realm = _UnitName ("target")
if (realm and realm ~= "") then
nome = nome.."-"..realm
end
alvo = nome
else
3 years ago
_detalhes:Msg(Loc ["STRING_REPORT_INVALIDTARGET"])
4 years ago
return
end
else
3 years ago
_detalhes:Msg(Loc ["STRING_REPORT_INVALIDTARGET"])
4 years ago
return
end
3 years ago
for i = 1, #linhas do
local timer = C_Timer.NewTimer(i * delay / 1000, send_report_channel)
4 years ago
timer.Arg1 = linhas[i]
timer.Arg2 = to_who
timer.Arg3 = nil
timer.Arg4 = alvo
end
return
end
3 years ago
4 years ago
if (to_who == "RAID" or to_who == "PARTY") then
if (GetNumGroupMembers (LE_PARTY_CATEGORY_INSTANCE) > 0) then
to_who = "INSTANCE_CHAT"
end
end
3 years ago
for i = 1, #linhas do
local timer = C_Timer.NewTimer(i * delay / 1000, send_report_channel)
4 years ago
timer.Arg1 = linhas[i]
timer.Arg2 = to_who
timer.Arg3 = nil
timer.Arg4 = nil
3 years ago
4 years ago
end
3 years ago
4 years ago
end
-- enda elsef