- Rework on Activity Time, now it will be more accurate with warcraftlogs.com
- Added two new customs: Damage Activity Time and Healing Activity Time. - TimeAttack plugin now have only have six time amount options. - TimeAttack plugin can now share damage results with other players with the same class in the realm. - New API: instance:EnableInstance() active and open a closed instance. - New API: _detalhes:RegisterBackgroundTask (name, func, priority, ...) background task runs slowly when player isn't in group nor inside instances. - New API: _detalhes:UnregisterBackgroundTask (name) cancel a backgroup task. - New API: plugin:RegisterPluginComm (prefix, func) register for receive comm msg. - New API: plugin:UnregisterPluginComm (prefix) unregister a previous registred comm. - New API: plugin:SendPluginCommMessage (prefix, channel, ...) send a msg through channel. - New API: _detalhes:IsConnected() return true is Details! is connected to realm comm channel. - New API: plugin:IsPluginEnabled() return is the plugin is enabled.
This commit is contained in:
@@ -273,6 +273,13 @@
|
||||
if (jogador:Iniciar()) then -- retorna se ele esta com o dps ativo
|
||||
jogador:TerminarTempo()
|
||||
jogador:Iniciar (false) --trava o dps do jogador
|
||||
else
|
||||
if (jogador.start_time == 0) then
|
||||
jogador.start_time = _tempo
|
||||
end
|
||||
if (not jogador.end_time) then
|
||||
jogador.end_time = _tempo
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -281,19 +288,21 @@
|
||||
if (jogador:Iniciar()) then -- retorna se ele esta com o dps ativo
|
||||
jogador:TerminarTempo()
|
||||
jogador:Iniciar (false) --trava o dps do jogador
|
||||
else
|
||||
|
||||
--print ("Tempo NAO Iniciando:", self.nome, self.start_time, self.end_time, self.delay, _tempo)
|
||||
|
||||
if (jogador.start_time == 0) then
|
||||
jogador.start_time = _tempo
|
||||
end
|
||||
if (not jogador.end_time) then
|
||||
jogador.end_time = _tempo
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function combate:UltimaAcao (tempo)
|
||||
if (tempo) then
|
||||
self.last_event = tempo
|
||||
else
|
||||
return self.last_event
|
||||
end
|
||||
end
|
||||
|
||||
function combate:seta_data (tipo)
|
||||
if (tipo == _detalhes._detalhes_props.DATA_TYPE_START) then
|
||||
self.data_inicio = _date ("%H:%M:%S")
|
||||
|
||||
+191
-32
@@ -102,13 +102,27 @@
|
||||
instance_container:ResetCustomActorContainer()
|
||||
|
||||
local func
|
||||
|
||||
if (_detalhes.custom_function_cache [instance.customName]) then
|
||||
func = _detalhes.custom_function_cache [instance.customName]
|
||||
else
|
||||
func = loadstring (custom_object.script)
|
||||
if (not func) then
|
||||
if (func) then
|
||||
_detalhes.custom_function_cache [instance.customName] = func
|
||||
end
|
||||
|
||||
local tooltip_script = custom_object.tooltip and loadstring (custom_object.tooltip)
|
||||
if (tooltip_script) then
|
||||
_detalhes.custom_function_cache [instance.customName .. "Tooltip"] = tooltip_script
|
||||
end
|
||||
local total_script = custom_object.total_script and loadstring (custom_object.total_script)
|
||||
if (total_script) then
|
||||
_detalhes.custom_function_cache [instance.customName .. "Total"] = total_script
|
||||
end
|
||||
local percent_script = custom_object.percent_script and loadstring (custom_object.percent_script)
|
||||
if (percent_script) then
|
||||
_detalhes.custom_function_cache [instance.customName .. "Percent"] = percent_script
|
||||
end
|
||||
end
|
||||
|
||||
if (not func) then
|
||||
@@ -118,7 +132,6 @@
|
||||
|
||||
--> call the loop function
|
||||
total, top, amount = func (combat, instance_container, instance)
|
||||
|
||||
else
|
||||
--> get the attribute
|
||||
local attribute = custom_object:GetAttribute()
|
||||
@@ -164,7 +177,7 @@
|
||||
|
||||
instance:AtualizarScrollBar (amount)
|
||||
|
||||
atributo_custom:Refresh (instance, instance_container, combat, force, total, top)
|
||||
atributo_custom:Refresh (instance, instance_container, combat, force, total, top, custom_object)
|
||||
|
||||
return _detalhes:EndRefresh (instance, total, combat, combat [container_index])
|
||||
|
||||
@@ -274,7 +287,7 @@
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--> refresh functions
|
||||
|
||||
function atributo_custom:Refresh (instance, instance_container, combat, force, total, top)
|
||||
function atributo_custom:Refresh (instance, instance_container, combat, force, total, top, custom_object)
|
||||
local qual_barra = 1
|
||||
local barras_container = instance.barras
|
||||
local percentage_type = instance.row_info.percent_type
|
||||
@@ -291,7 +304,10 @@
|
||||
use_total_bar = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local percent_script = _detalhes.custom_function_cache [instance.customName .. "Percent"]
|
||||
local total_script = _detalhes.custom_function_cache [instance.customName .. "Total"]
|
||||
|
||||
if (instance.bars_sort_direction == 1) then --top to bottom
|
||||
|
||||
if (use_total_bar and instance.barraS[1] == 1) then
|
||||
@@ -317,13 +333,13 @@
|
||||
gump:Fade (row1, "out")
|
||||
|
||||
for i = instance.barraS[1], iter_last, 1 do
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force)
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force, percent_script, total_script, combat)
|
||||
qual_barra = qual_barra+1
|
||||
end
|
||||
|
||||
else
|
||||
for i = instance.barraS[1], instance.barraS[2], 1 do
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force)
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force, percent_script, total_script, combat)
|
||||
qual_barra = qual_barra+1
|
||||
end
|
||||
end
|
||||
@@ -353,13 +369,13 @@
|
||||
gump:Fade (row1, "out")
|
||||
|
||||
for i = iter_last, instance.barraS[1], -1 do --> vai atualizar só o range que esta sendo mostrado
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force)
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force, percent_script, total_script, combat)
|
||||
qual_barra = qual_barra+1
|
||||
end
|
||||
|
||||
else
|
||||
for i = instance.barraS[2], instance.barraS[1], -1 do --> vai atualizar só o range que esta sendo mostrado
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force)
|
||||
instance_container._ActorTable[i]:UpdateBar (barras_container, qual_barra, percentage_type, i, total, top, instance, force, percent_script, total_script, combat)
|
||||
qual_barra = qual_barra+1
|
||||
end
|
||||
end
|
||||
@@ -380,7 +396,7 @@
|
||||
|
||||
local actor_class_color_r, actor_class_color_g, actor_class_color_b
|
||||
|
||||
function atributo_custom:UpdateBar (row_container, index, percentage_type, rank, total, top, instance, is_forced)
|
||||
function atributo_custom:UpdateBar (row_container, index, percentage_type, rank, total, top, instance, is_forced, percent_script, total_script, combat)
|
||||
|
||||
local row = row_container [index]
|
||||
|
||||
@@ -390,19 +406,32 @@
|
||||
self.minha_barra = row
|
||||
|
||||
local percent
|
||||
|
||||
if (percentage_type == 1) then
|
||||
percent = _cstr ("%.1f", self.value / total * 100)
|
||||
elseif (percentage_type == 2) then
|
||||
percent = _cstr ("%.1f", self.value / top * 100)
|
||||
|
||||
if (percent_script) then
|
||||
--local value, top, total, combat, instance = ...
|
||||
percent = percent_script (self.value, top, total, combat, instance)
|
||||
else
|
||||
if (percentage_type == 1) then
|
||||
percent = _cstr ("%.1f", self.value / total * 100)
|
||||
elseif (percentage_type == 2) then
|
||||
percent = _cstr ("%.1f", self.value / top * 100)
|
||||
end
|
||||
end
|
||||
|
||||
local formated_value = SelectedToKFunction (_, self.value)
|
||||
|
||||
if (UsingCustomRightText) then
|
||||
row.texto_direita:SetText (instance.row_info.textR_custom_text:ReplaceData (formated_value, "", percent, self))
|
||||
if (total_script) then
|
||||
local value = total_script (self.value, top, total, combat, instance)
|
||||
if (type (value) == "number") then
|
||||
row.texto_direita:SetText (SelectedToKFunction (_, value) .. " (" .. percent .. "%)")
|
||||
else
|
||||
row.texto_direita:SetText (value .. " (" .. percent .. "%)")
|
||||
end
|
||||
else
|
||||
row.texto_direita:SetText (formated_value .. " (" .. percent .. "%)")
|
||||
local formated_value = SelectedToKFunction (_, self.value)
|
||||
if (UsingCustomRightText) then
|
||||
row.texto_direita:SetText (instance.row_info.textR_custom_text:ReplaceData (formated_value, "", percent, self))
|
||||
else
|
||||
row.texto_direita:SetText (formated_value .. " (" .. percent .. "%)")
|
||||
end
|
||||
end
|
||||
|
||||
local row_value = _math_floor ((self.value / top) * 100)
|
||||
@@ -605,7 +634,8 @@
|
||||
|
||||
function atributo_custom:ResetCustomActorContainer()
|
||||
for _, actor in _ipairs (self._ActorTable) do
|
||||
actor.value = _detalhes:GetOrderNumber (actor.nome)
|
||||
actor.value = actor.value - _math_floor (actor.value)
|
||||
--actor.value = _detalhes:GetOrderNumber (actor.nome)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -615,7 +645,6 @@
|
||||
end
|
||||
|
||||
function atributo_custom:AddValue (actor, actortotal, checktop)
|
||||
--print (debugstack())
|
||||
local actor_table = self:GetActorTable (actor)
|
||||
actor_table.my_actor = actor
|
||||
actor_table.value = actor_table.value + actortotal
|
||||
@@ -833,9 +862,9 @@
|
||||
end
|
||||
|
||||
function _detalhes.refresh:r_atributo_custom()
|
||||
|
||||
--> check for non used temp displays
|
||||
if (_detalhes.tabela_instancias) then
|
||||
|
||||
for i = #_detalhes.custom, 1, -1 do
|
||||
local custom_object = _detalhes.custom [i]
|
||||
if (custom_object.temp) then
|
||||
@@ -880,7 +909,7 @@
|
||||
function _detalhes:AddDefaultCustomDisplays()
|
||||
|
||||
local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" )
|
||||
|
||||
|
||||
local PotionUsed = {
|
||||
name = Loc ["STRING_CUSTOM_POT_DEFAULT"],
|
||||
icon = [[Interface\ICONS\Trade_Alchemy_PotionD4]],
|
||||
@@ -1054,11 +1083,19 @@
|
||||
]]
|
||||
}
|
||||
|
||||
setmetatable (PotionUsed, _detalhes.atributo_custom)
|
||||
PotionUsed.__index = _detalhes.atributo_custom
|
||||
|
||||
self.custom [#self.custom+1] = PotionUsed
|
||||
|
||||
local have = false
|
||||
for _, custom in ipairs (self.custom) do
|
||||
if (custom.name == Loc ["STRING_CUSTOM_POT_DEFAULT"]) then
|
||||
have = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if (not have) then
|
||||
setmetatable (PotionUsed, _detalhes.atributo_custom)
|
||||
PotionUsed.__index = _detalhes.atributo_custom
|
||||
self.custom [#self.custom+1] = PotionUsed
|
||||
end
|
||||
|
||||
local Healthstone = {
|
||||
name = Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT"],
|
||||
icon = [[Interface\ICONS\warlock_ healthstone]],
|
||||
@@ -1072,12 +1109,134 @@
|
||||
tooltip = false
|
||||
}
|
||||
|
||||
setmetatable (Healthstone, _detalhes.atributo_custom)
|
||||
Healthstone.__index = _detalhes.atributo_custom
|
||||
local have = false
|
||||
for _, custom in ipairs (self.custom) do
|
||||
if (custom.name == Loc ["STRING_CUSTOM_HEALTHSTONE_DEFAULT"]) then
|
||||
have = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if (not have) then
|
||||
setmetatable (Healthstone, _detalhes.atributo_custom)
|
||||
Healthstone.__index = _detalhes.atributo_custom
|
||||
self.custom [#self.custom+1] = Healthstone
|
||||
end
|
||||
|
||||
self.custom [#self.custom+1] = Healthstone
|
||||
local DamageActivityTime = {
|
||||
name = Loc ["STRING_CUSTOM_ACTIVITY_DPS"],
|
||||
icon = [[Interface\ICONS\Achievement_PVP_H_06]],
|
||||
attribute = false,
|
||||
spellid = false,
|
||||
author = "Details!",
|
||||
desc = Loc ["STRING_CUSTOM_ACTIVITY_DPS_DESC"],
|
||||
source = false,
|
||||
target = false,
|
||||
total_script = [[
|
||||
local value, top, total, combat, instance = ...
|
||||
local minutos, segundos = math.floor (value/60), math.floor (value%60)
|
||||
return minutos .. "m " .. segundos .. "s"
|
||||
]],
|
||||
percent_script = [[
|
||||
local value, top, total, combat, instance = ...
|
||||
return string.format ("%.1f", value/top*100)
|
||||
]],
|
||||
script = [[
|
||||
--init:
|
||||
local combat, instance_container, instance = ...
|
||||
local total, amount = 0, 0
|
||||
|
||||
--get the misc actor container
|
||||
local damage_container = combat:GetActorList ( DETAILS_ATTRIBUTE_DAMAGE )
|
||||
|
||||
--do the loop:
|
||||
for _, player in ipairs ( damage_container ) do
|
||||
if (player.grupo) then
|
||||
local activity = player:Tempo()
|
||||
total = total + activity
|
||||
amount = amount + 1
|
||||
--add amount to the player
|
||||
instance_container:AddValue (player, activity)
|
||||
end
|
||||
end
|
||||
|
||||
--return:
|
||||
return total, combat:GetCombatTime(), amount
|
||||
]],
|
||||
tooltip = [[
|
||||
|
||||
]],
|
||||
}
|
||||
|
||||
local have = false
|
||||
for _, custom in ipairs (self.custom) do
|
||||
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_DPS"]) then
|
||||
have = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if (not have) then
|
||||
setmetatable (DamageActivityTime, _detalhes.atributo_custom)
|
||||
DamageActivityTime.__index = _detalhes.atributo_custom
|
||||
self.custom [#self.custom+1] = DamageActivityTime
|
||||
end
|
||||
|
||||
local HealActivityTime = {
|
||||
name = Loc ["STRING_CUSTOM_ACTIVITY_HPS"],
|
||||
icon = [[Interface\ICONS\Achievement_PVP_G_06]],
|
||||
attribute = false,
|
||||
spellid = false,
|
||||
author = "Details!",
|
||||
desc = Loc ["STRING_CUSTOM_ACTIVITY_HPS_DESC"],
|
||||
source = false,
|
||||
target = false,
|
||||
total_script = [[
|
||||
local value, top, total, combat, instance = ...
|
||||
local minutos, segundos = math.floor (value/60), math.floor (value%60)
|
||||
return minutos .. "m " .. segundos .. "s"
|
||||
]],
|
||||
percent_script = [[
|
||||
local value, top, total, combat, instance = ...
|
||||
return string.format ("%.1f", value/top*100)
|
||||
]],
|
||||
script = [[
|
||||
--init:
|
||||
local combat, instance_container, instance = ...
|
||||
local total, top, amount = 0, 0, 0
|
||||
|
||||
--get the misc actor container
|
||||
local damage_container = combat:GetActorList ( DETAILS_ATTRIBUTE_HEAL )
|
||||
|
||||
--do the loop:
|
||||
for _, player in ipairs ( damage_container ) do
|
||||
if (player.grupo) then
|
||||
local activity = player:Tempo()
|
||||
total = total + activity
|
||||
amount = amount + 1
|
||||
--add amount to the player
|
||||
instance_container:AddValue (player, activity)
|
||||
end
|
||||
end
|
||||
|
||||
--return:
|
||||
return total, combat:GetCombatTime(), amount
|
||||
]],
|
||||
tooltip = [[
|
||||
|
||||
]],
|
||||
}
|
||||
|
||||
local have = false
|
||||
for _, custom in ipairs (self.custom) do
|
||||
if (custom.name == Loc ["STRING_CUSTOM_ACTIVITY_HPS"]) then
|
||||
have = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if (not have) then
|
||||
setmetatable (HealActivityTime, _detalhes.atributo_custom)
|
||||
HealActivityTime.__index = _detalhes.atributo_custom
|
||||
self.custom [#self.custom+1] = HealActivityTime
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ function atributo_heal:AtualizaBarra (instancia, barras_container, qual_barra, l
|
||||
hps = healing_total / combat_time
|
||||
self.last_hps = hps
|
||||
end
|
||||
else
|
||||
else -- /dump _detalhes:GetCombat (2)(1, "Ditador").on_hold
|
||||
if (not self.on_hold) then
|
||||
hps = healing_total/self:Tempo() --calcula o dps deste objeto
|
||||
self.last_hps = hps --salva o dps dele
|
||||
|
||||
@@ -171,7 +171,10 @@ function _detalhes:GetRaidMode()
|
||||
return _detalhes.tabela_instancias [_detalhes.raid]
|
||||
end
|
||||
|
||||
function _detalhes:IsSoloMode()
|
||||
function _detalhes:IsSoloMode (offline)
|
||||
if (offline) then
|
||||
return self.modo == 1
|
||||
end
|
||||
if (not _detalhes.solo) then
|
||||
return false
|
||||
else
|
||||
@@ -403,6 +406,12 @@ end
|
||||
end
|
||||
|
||||
--> oposto do desativar, ela apenas volta a mostrar a janela
|
||||
|
||||
--> alias
|
||||
function _detalhes:EnableInstance (temp)
|
||||
return self:AtivarInstancia (temp)
|
||||
end
|
||||
|
||||
function _detalhes:AtivarInstancia (temp)
|
||||
|
||||
self.ativa = true
|
||||
|
||||
+62
-1
@@ -141,4 +141,65 @@ function _detalhes:GetPerformanceRaidType()
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
local background_tasks = {}
|
||||
local task_timers = {
|
||||
["LOW"] = 30,
|
||||
["MEDIUM"] = 18,
|
||||
["HIGH"] = 10,
|
||||
}
|
||||
|
||||
function _detalhes:RegisterBackgroundTask (name, func, priority, ...)
|
||||
|
||||
assert (type (self) == "table", "RegisterBackgroundTask 'self' must be a table.")
|
||||
assert (type (name) == "string", "RegisterBackgroundTask param #1 must be a string.")
|
||||
if (type (func) == "string") then
|
||||
assert (type (self [func]) == "function", "RegisterBackgroundTask param #2 function not found on main object.")
|
||||
else
|
||||
assert (type (func) == "function", "RegisterBackgroundTask param #2 expect a function or function name.")
|
||||
end
|
||||
|
||||
priority = priority or "LOW"
|
||||
priority = string.upper (priority)
|
||||
if (not task_timers [priority]) then
|
||||
priority = "LOW"
|
||||
end
|
||||
|
||||
if (background_tasks [name]) then
|
||||
background_tasks [name].func = func
|
||||
background_tasks [name].priority = priority
|
||||
background_tasks [name].args = {...}
|
||||
background_tasks [name].args_amt = select ("#", ...)
|
||||
background_tasks [name].object = self
|
||||
return
|
||||
else
|
||||
background_tasks [name] = {func = func, lastexec = time(), priority = priority, nextexec = time() + task_timers [priority] * 60, args = {...}, args_amt = select ("#", ...), object = self}
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:UnregisterBackgroundTask (name)
|
||||
background_tasks [name] = nil
|
||||
end
|
||||
|
||||
function _detalhes:DoBackgroundTasks()
|
||||
if (_detalhes:GetZoneType() ~= "none" or _detalhes:InGroup()) then
|
||||
return
|
||||
end
|
||||
|
||||
local t = time()
|
||||
|
||||
for taskName, taskTable in pairs (background_tasks) do
|
||||
if (t > taskTable.nextexec) then
|
||||
if (type (taskTable.func) == "string") then
|
||||
taskTable.object [taskTable.func] (taskTable.object, unpack (taskTable.args, 1, taskTable.args_amt))
|
||||
else
|
||||
taskTable.func (unpack (taskTable.args, 1, taskTable.args_amt))
|
||||
end
|
||||
|
||||
taskTable.nextexec = random (30, 120) + t + (task_timers [taskTable.priority] * 60)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_detalhes.background_tasks_loop = _detalhes:ScheduleRepeatingTimer ("DoBackgroundTasks", 120)
|
||||
|
||||
+97
-42
@@ -257,67 +257,110 @@
|
||||
--> register comm
|
||||
|
||||
function _detalhes:CommReceived (_, data, _, source)
|
||||
local type, player, realm, dversion, arg6, arg7, arg8, arg9 = _select (2, _detalhes:Deserialize (data))
|
||||
local prefix, player, realm, dversion, arg6, arg7, arg8, arg9 = _select (2, _detalhes:Deserialize (data))
|
||||
|
||||
if (_detalhes.debug) then
|
||||
_detalhes:Msg ("(debug) network received:", type, "length:",string.len (data))
|
||||
_detalhes:Msg ("(debug) network received:", prefix, "length:",string.len (data))
|
||||
end
|
||||
|
||||
local func = _detalhes.network.functions [type]
|
||||
local func = _detalhes.network.functions [prefix]
|
||||
if (func) then
|
||||
func (player, realm, dversion, arg6, arg7, arg8, arg9)
|
||||
else
|
||||
local t = plugins_registred [type]
|
||||
if (t) then
|
||||
func (player, realm, dversion, t[3], arg6, arg7, arg8, arg9)
|
||||
func = plugins_registred [prefix]
|
||||
if (func) then
|
||||
func (player, realm, dversion, arg6, arg7, arg8, arg9)
|
||||
else
|
||||
_detalhes:Msg ("comm type not found:", type)
|
||||
_detalhes:Msg ("comm prefix not found:", prefix)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_detalhes:RegisterComm ("DTLS", "CommReceived")
|
||||
|
||||
function _detalhes:RegisterPluginComm (name, prefix, func, version)
|
||||
assert (type (name) == "string" and string.len (name) > 3, "RegisterPluginComm expects a string with at least 4 characters on #1 argument.")
|
||||
assert (type (prefix) == "string" and string.len (prefix) == 2, "RegisterPluginComm expects a string with 2 characters on #2 argument.")
|
||||
assert (type (func) == "function", "RegisterPluginComm expects a function on #3 argument.")
|
||||
assert (plugins_registred [prefix] == nil, "Prefix " .. prefix .. " already in use.")
|
||||
assert (_detalhes.network.functions [prefix] == nil, "Prefix " .. prefix .. " already in use.")
|
||||
function _detalhes:RegisterPluginComm (prefix, func)
|
||||
assert (type (prefix) == "string" and string.len (prefix) >= 2 and string.len (prefix) <= 4, "RegisterPluginComm expects a string with 2-4 characters on #1 argument.")
|
||||
assert (type (func) == "function" or (type (func) == "string" and type (self [func]) == "function"), "RegisterPluginComm expects a function or function name on #2 argument.")
|
||||
assert (plugins_registred [prefix] == nil, "Prefix " .. prefix .. " already in use 1.")
|
||||
assert (_detalhes.network.functions [prefix] == nil, "Prefix " .. prefix .. " already in use 2.")
|
||||
|
||||
plugins_registred [prefix] = {func, name, version}
|
||||
if (type (func) == "string") then
|
||||
plugins_registred [prefix] = self [func]
|
||||
else
|
||||
plugins_registred [prefix] = func
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function _detalhes:UnregisterPluginComm (name)
|
||||
local prefix
|
||||
for p, t in _pairs (plugins_registred) do
|
||||
if (t [2] == name) then
|
||||
prefix = p
|
||||
break
|
||||
end
|
||||
end
|
||||
if (prefix) then
|
||||
plugins_registred [prefix] = nil
|
||||
end
|
||||
function _detalhes:UnregisterPluginComm (prefix)
|
||||
plugins_registred [prefix] = nil
|
||||
return true
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--> send functions
|
||||
|
||||
function _detalhes:SendPluginCommMessage (name, channel, ...)
|
||||
local prefix
|
||||
for p, t in _pairs (plugins_registred) do
|
||||
if (t [2] == name) then
|
||||
prefix = p
|
||||
break
|
||||
|
||||
function _detalhes:GetChannelId (channel)
|
||||
for id = 1, GetNumDisplayChannels() do
|
||||
local name, _, _, room_id = GetChannelDisplayInfo (id)
|
||||
if (name == channel) then
|
||||
return room_id
|
||||
end
|
||||
end
|
||||
if (prefix) then
|
||||
end
|
||||
|
||||
function _detalhes.parser_functions:CHAT_MSG_CHANNEL (...)
|
||||
local message, _, _, _, _, _, _, _, channelName = ...
|
||||
if (channelName == "Details") then
|
||||
local prefix, data = strsplit ("_", message, 2)
|
||||
|
||||
else
|
||||
self:Msg ("comm not registred:", name)
|
||||
local func = plugins_registred [prefix]
|
||||
if (func) then
|
||||
func (_select (2, _detalhes:Deserialize (data)))
|
||||
else
|
||||
_detalhes:Msg ("comm prefix not found:", prefix)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:SendPluginCommMessage (prefix, channel, ...)
|
||||
|
||||
if (not _detalhes:IsConnected()) then
|
||||
return false
|
||||
end
|
||||
|
||||
if (not channel) then
|
||||
channel = "Details"
|
||||
end
|
||||
|
||||
if (channel == "RAID") then
|
||||
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
|
||||
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "INSTANCE_CHAT")
|
||||
else
|
||||
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "RAID")
|
||||
end
|
||||
|
||||
elseif (channel == "PARTY") then
|
||||
if (IsInGroup (LE_PARTY_CATEGORY_INSTANCE) and IsInInstance()) then
|
||||
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "INSTANCE_CHAT")
|
||||
else
|
||||
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), "PARTY")
|
||||
end
|
||||
|
||||
elseif (channel == "Details") then
|
||||
local id = _detalhes:GetChannelId (channel)
|
||||
if (id) then
|
||||
SendChatMessage (prefix .. "_" .. _detalhes:Serialize (self.__version, ...), "CHANNEL", nil, id)
|
||||
end
|
||||
|
||||
else
|
||||
_detalhes:SendCommMessage (prefix, _detalhes:Serialize (self.__version, ...), channel)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--> send as
|
||||
function _detalhes:SendRaidDataAs (type, player, realm, ...)
|
||||
@@ -428,17 +471,20 @@
|
||||
local realm = GetRealmName()
|
||||
realm = realm or ""
|
||||
|
||||
if (realm ~= "Azralon") then
|
||||
return
|
||||
end
|
||||
--if (realm ~= "Azralon") then
|
||||
-- return
|
||||
--end
|
||||
|
||||
--> room name
|
||||
local room_name = "Details"
|
||||
|
||||
_detalhes.listener:RegisterEvent ("CHAT_MSG_CHANNEL")
|
||||
|
||||
--> already in?
|
||||
for room_index = 1, 10 do
|
||||
local _, name = GetChannelName (room_index)
|
||||
if (name == room_name) then
|
||||
_detalhes.is_connected = true
|
||||
return --> already in the room
|
||||
end
|
||||
end
|
||||
@@ -446,6 +492,7 @@
|
||||
--> enter
|
||||
--print ("entrando no canal")
|
||||
JoinChannelByName (room_name)
|
||||
_detalhes.is_connected = true
|
||||
end
|
||||
|
||||
function _detalhes:LeaveChatChannel()
|
||||
@@ -459,13 +506,14 @@
|
||||
local realm = GetRealmName()
|
||||
realm = realm or ""
|
||||
|
||||
if (realm ~= "Azralon") then
|
||||
return
|
||||
end
|
||||
--if (realm ~= "Azralon") then
|
||||
-- return
|
||||
--end
|
||||
|
||||
--> room name
|
||||
local room_name = "Details"
|
||||
local is_in = false
|
||||
|
||||
--> already in?
|
||||
for room_index = 1, 10 do
|
||||
local _, name = GetChannelName (room_index)
|
||||
@@ -478,6 +526,10 @@
|
||||
--print ("saindo do canal")
|
||||
LeaveChannelByName (room_name)
|
||||
end
|
||||
|
||||
_detalhes.is_connected = false
|
||||
|
||||
_detalhes.listener:UnregisterEvent ("CHAT_MSG_CHANNEL")
|
||||
end
|
||||
|
||||
--> sair do canal quando estiver em grupo
|
||||
@@ -538,4 +590,7 @@
|
||||
_detalhes:RegisterEvent (event_handler, "GROUP_ONENTER", "GROUP_ONENTER")
|
||||
_detalhes:RegisterEvent (event_handler, "GROUP_ONLEAVE", "GROUP_ONLEAVE")
|
||||
_detalhes:RegisterEvent (event_handler, "ZONE_TYPE_CHANGED", "ZONE_TYPE_CHANGED")
|
||||
|
||||
|
||||
function _detalhes:IsConnected()
|
||||
return _detalhes.is_connected
|
||||
end
|
||||
+20
-6
@@ -327,21 +327,21 @@
|
||||
|
||||
if (not este_jogador.dps_started) then
|
||||
|
||||
este_jogador:Iniciar (true)
|
||||
este_jogador:Iniciar (true) --registra na timemachine
|
||||
|
||||
if (meu_dono and not meu_dono.dps_started) then
|
||||
meu_dono:Iniciar (true)
|
||||
if (meu_dono.end_time) then
|
||||
meu_dono.end_time = nil
|
||||
else
|
||||
meu_dono:IniciarTempo (_tempo-2.5, meu_dono.shadow)
|
||||
meu_dono:IniciarTempo (_tempo, meu_dono.shadow)
|
||||
end
|
||||
end
|
||||
|
||||
if (este_jogador.end_time) then
|
||||
este_jogador.end_time = nil
|
||||
else
|
||||
este_jogador:IniciarTempo (_tempo-2.5, este_jogador.shadow)
|
||||
este_jogador:IniciarTempo (_tempo, este_jogador.shadow)
|
||||
end
|
||||
|
||||
if (este_jogador.nome == _detalhes.playername and token ~= "SPELL_PERIODIC_DAMAGE") then --> iniciando o dps do "PLAYER"
|
||||
@@ -678,12 +678,22 @@
|
||||
--> timer
|
||||
|
||||
if (not este_jogador.iniciar_hps) then
|
||||
este_jogador:Iniciar (true) --inicia o dps do jogador
|
||||
|
||||
este_jogador:Iniciar (true) --inicia o hps do jogador
|
||||
|
||||
if (meu_dono and not meu_dono.dps_started) then
|
||||
meu_dono:Iniciar (true)
|
||||
if (meu_dono.end_time) then
|
||||
meu_dono.end_time = nil
|
||||
else
|
||||
meu_dono:IniciarTempo (_tempo, meu_dono.shadow)
|
||||
end
|
||||
end
|
||||
|
||||
if (este_jogador.end_time) then --> o combate terminou, reabrir o tempo
|
||||
este_jogador.end_time = nil
|
||||
este_jogador.shadow.end_time = nil --> não tenho certeza se isso aqui não pode dar merda
|
||||
else
|
||||
este_jogador:IniciarTempo (_tempo-3.0, este_jogador.shadow)
|
||||
este_jogador:IniciarTempo (_tempo, este_jogador.shadow)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -735,6 +745,10 @@
|
||||
este_alvo.total = este_alvo.total + cura_efetiva
|
||||
end
|
||||
|
||||
if (meu_dono) then
|
||||
meu_dono.last_event = _tempo
|
||||
end
|
||||
|
||||
if (overhealing > 0) then
|
||||
este_jogador.totalover = este_jogador.totalover + overhealing
|
||||
este_alvo.overheal = este_alvo.overheal + overhealing
|
||||
|
||||
@@ -19,6 +19,17 @@
|
||||
return _detalhes.plugin_database [PluginAbsoluteName]
|
||||
end
|
||||
|
||||
function _detalhes:IsPluginEnabled (PluginAbsoluteName)
|
||||
if (PluginAbsoluteName) then
|
||||
local plugin = _detalhes.plugin_database [PluginAbsoluteName]
|
||||
if (plugin) then
|
||||
return plugin.__enabled
|
||||
end
|
||||
else
|
||||
return self.__enabled
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:CheckDefaultTable (current, default)
|
||||
for key, value in pairs (default) do
|
||||
if (type (value) == "table") then
|
||||
|
||||
+53
-51
@@ -17,6 +17,7 @@
|
||||
local _ipairs = ipairs --lua local
|
||||
local _pairs = pairs --lua local
|
||||
local _time = time --lua local
|
||||
local _math_floor = math.floor
|
||||
local timeMachine = _detalhes.timeMachine --details local
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -37,16 +38,13 @@
|
||||
for tipo, tabela in _pairs (self.tabelas) do
|
||||
for nome, jogador in _ipairs (tabela) do
|
||||
if (jogador) then
|
||||
|
||||
local ultima_acao = jogador.last_event+10
|
||||
|
||||
if (ultima_acao > _tempo) then --> okey o jogador esta dando dps
|
||||
if (jogador.last_event+10 > _tempo) then --> okey o jogador esta dando dps
|
||||
if (jogador.on_hold) then --> o dps estava pausado, retornar a ativa
|
||||
jogador:HoldOn (false)
|
||||
end
|
||||
else
|
||||
if (not jogador.on_hold) then --> não ta pausado, precisa por em pausa
|
||||
--> verifica se esta castando alguma coisa que leve + que 3 segundos
|
||||
--> verifica se esta castando alguma coisa que leve + que 10 segundos
|
||||
jogador:HoldOn (true)
|
||||
end
|
||||
end
|
||||
@@ -131,11 +129,32 @@
|
||||
|
||||
function _detalhes:Tempo()
|
||||
if (self.end_time) then --> o tempo do jogador esta trancado
|
||||
return self.end_time - self.start_time
|
||||
local t = self.end_time - self.start_time
|
||||
if (t < 10) then
|
||||
t = 10
|
||||
end
|
||||
return t
|
||||
elseif (self.on_hold) then --> o tempo esta em pausa
|
||||
return self.delay - self.start_time
|
||||
local t = self.delay - self.start_time
|
||||
if (t < 10) then
|
||||
t = 10
|
||||
end
|
||||
return t
|
||||
else
|
||||
return _tempo - self.start_time
|
||||
if (self.start_time == 0) then
|
||||
return 10
|
||||
end
|
||||
local t = _tempo - self.start_time
|
||||
if (t < 10) then
|
||||
if (_detalhes.in_combat) then
|
||||
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
|
||||
if (combat_time < 10) then
|
||||
return combat_time
|
||||
end
|
||||
end
|
||||
t = 10
|
||||
end
|
||||
return t
|
||||
end
|
||||
end
|
||||
|
||||
@@ -144,73 +163,56 @@
|
||||
-- inicia o tempo no objeto atual
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
if (self.start_time > 0) then
|
||||
print ("DEBUG: "..self.name.." ja tinha start_time...")
|
||||
else
|
||||
self.start_time = tempo
|
||||
end
|
||||
|
||||
self.start_time = tempo
|
||||
|
||||
-- inicia o tempo no shadow do objeto
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
if (shadow.end_time) then
|
||||
-- tempo do inicio da shadow = tempo de abertura ATUAL menos tempo de combate da shadow
|
||||
local subs = shadow.end_time - shadow.start_time
|
||||
shadow.start_time = tempo - subs
|
||||
shadow.end_time = nil -- o tempo foi aberto retirando o end_time
|
||||
|
||||
--if (self.nome == "Ditador") then print ("shadow ja itnha end_time") end
|
||||
|
||||
else -- pela minha logica se nao tiver end_time significa que precisa apenas gravar o tempo de inicio
|
||||
-- a shadow foi recém criada e esta abrindo o tempo pela primeira vez
|
||||
|
||||
if (shadow.start_time == 0) then --> ja esta em um combate
|
||||
shadow.end_time = nil
|
||||
else
|
||||
if (shadow.start_time == 0) then
|
||||
shadow.start_time = tempo
|
||||
--if (self.nome == "Ditador") then print ("shadom sem end_time com start_time == 0") end
|
||||
else
|
||||
--if (self.nome == "Ditador") then print ("shadom sem end_time") end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:TerminarTempo (subs)
|
||||
function _detalhes:TerminarTempo()
|
||||
if (self.end_time) then
|
||||
return
|
||||
end
|
||||
subs = subs or 0
|
||||
|
||||
if (self.on_hold) then
|
||||
self.end_time = self.delay - subs -- isso ta certo? por que self.delay carrega o tempo quando o jogador parou o dps
|
||||
self.on_hold = false
|
||||
self.delay = nil
|
||||
else
|
||||
self.end_time = _tempo - subs
|
||||
end
|
||||
if (self.shadow) then
|
||||
return self.shadow:TerminarTempo (subs)
|
||||
self:HoldOn (false)
|
||||
end
|
||||
|
||||
self.end_time = _tempo
|
||||
end
|
||||
|
||||
--> diz se o dps deste jogador esta em pausa
|
||||
function _detalhes:HoldOn (pausa)
|
||||
--if (self.nome == "Ditador") then print ("colocando em hold on") end
|
||||
if (pausa == nil) then
|
||||
return self.on_hold --retorna se o dps esta aberto ou fechado para este jogador
|
||||
elseif (pausa) then --> true
|
||||
self.delay = _tempo
|
||||
|
||||
elseif (pausa) then --> true - colocar como inativo
|
||||
self.delay = _math_floor (self.last_event) --_tempo - 10
|
||||
if (self.delay < self.start_time) then
|
||||
self.delay = self.start_time
|
||||
end
|
||||
self.on_hold = true
|
||||
else --> false
|
||||
self.start_time = self.start_time + (_tempo-self.delay)
|
||||
|
||||
else --> false - retornar a atividade
|
||||
local diff = _tempo - self.delay - 1
|
||||
if (diff > 0) then
|
||||
self.start_time = self.start_time + diff
|
||||
end
|
||||
--if (_tempo - self.start_time < 20) then
|
||||
-- self.start_time = self.start_time - 1
|
||||
--end
|
||||
self.on_hold = false
|
||||
end
|
||||
end
|
||||
|
||||
--controla quando foi a ultima vez que este jogador deu dano
|
||||
function _detalhes:UltimaAcao (tempo)
|
||||
if (not tempo) then
|
||||
return self.last_event
|
||||
else
|
||||
self.last_event = tempo
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+17
-1
@@ -479,7 +479,7 @@ local ButtonMetaFunctions = {}
|
||||
end
|
||||
|
||||
--> custom textures
|
||||
function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split)
|
||||
function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split, side_textures)
|
||||
|
||||
self.button:SetNormalTexture (nil)
|
||||
self.button:SetPushedTexture (nil)
|
||||
@@ -540,6 +540,22 @@ local ButtonMetaFunctions = {}
|
||||
|
||||
self.button.texture:SetTexture (texture)
|
||||
end
|
||||
|
||||
if (side_textures) then
|
||||
local left = self.button:CreateTexture (nil, "overlay")
|
||||
left:SetTexture ([[Interface\TALENTFRAME\talent-main]])
|
||||
left:SetTexCoord (0.13671875, 0.25, 0.486328125, 0.576171875)
|
||||
left:SetPoint ("left", self.button, 0, 0)
|
||||
left:SetWidth (10)
|
||||
left:SetHeight (self.button:GetHeight()+2)
|
||||
|
||||
local right = self.button:CreateTexture (nil, "overlay")
|
||||
right:SetTexture ([[Interface\TALENTFRAME\talent-main]])
|
||||
right:SetTexCoord (0.01953125, 0.13671875, 0.486328125, 0.576171875)
|
||||
right:SetPoint ("right", self.button, 0, 0)
|
||||
right:SetWidth (10)
|
||||
right:SetHeight (self.button:GetHeight()+2)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -231,7 +231,9 @@ do
|
||||
function _detalhes:GetSubAttributeName (attribute, subAttribute)
|
||||
if (attribute == 5) then
|
||||
local CustomObject = _detalhes.custom [subAttribute]
|
||||
-- ??
|
||||
if (not CustomObject) then
|
||||
return "--x--x--"
|
||||
end
|
||||
return CustomObject.name
|
||||
end
|
||||
return _detalhes.sub_atributos [attribute].lista [subAttribute]
|
||||
|
||||
@@ -17,6 +17,9 @@ function _detalhes:ApplyBasicKeys()
|
||||
|
||||
--> we are not in debug mode
|
||||
self.debug = false
|
||||
|
||||
--> connected to realm channel
|
||||
self.is_connected = false
|
||||
|
||||
--> who is
|
||||
self.playername = UnitName ("player")
|
||||
@@ -270,10 +273,6 @@ function _detalhes:LoadConfig()
|
||||
_detalhes.savedbuffs = _detalhes_database.savedbuffs
|
||||
_detalhes.Buffs:BuildTables()
|
||||
|
||||
--> custom
|
||||
_detalhes.custom = _detalhes_global.custom
|
||||
_detalhes.refresh:r_atributo_custom()
|
||||
|
||||
--> initialize parser
|
||||
_detalhes.capture_current = {}
|
||||
for captureType, captureValue in pairs (_detalhes.capture_real) do
|
||||
@@ -362,6 +361,10 @@ function _detalhes:LoadConfig()
|
||||
--> apply the profile
|
||||
_detalhes:ApplyProfile (current_profile_name, true)
|
||||
|
||||
--> custom
|
||||
_detalhes.custom = _detalhes_global.custom
|
||||
_detalhes.refresh:r_atributo_custom()
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1478,7 +1478,7 @@ local function barra_scripts (esta_barra, instancia, i)
|
||||
setmetatable (new_custom_object, _detalhes.atributo_custom)
|
||||
new_custom_object.__index = _detalhes.atributo_custom
|
||||
|
||||
instancia:TrocaTabela (instancia.segmento, 5, #_detalhes.custom)
|
||||
return instancia:TrocaTabela (instancia.segmento, 5, #_detalhes.custom)
|
||||
--func, true, 5, index
|
||||
|
||||
end
|
||||
|
||||
@@ -34,7 +34,8 @@ local function CreatePluginFrames()
|
||||
elseif (event == "SHOW") then
|
||||
instance = _detalhes.SoloTables.instancia --> update wich instance solo mode are running
|
||||
DetailsFrameWork:RegisterForDetailsMove (DetailsTimeAttackHistoryBackground, instance)
|
||||
|
||||
TimeAttack:RequestRealmResults()
|
||||
|
||||
elseif (event == "COMBAT_PLAYER_ENTER") then --> combat started
|
||||
TimeAttack:ScheduleTimer ("TimeAttackPluginStart", 2)
|
||||
|
||||
@@ -44,6 +45,8 @@ local function CreatePluginFrames()
|
||||
|
||||
elseif (event == "DETAILS_STARTED") then
|
||||
TimeAttack:CheckTimeAttackTutorial()
|
||||
TimeAttack.PlayerRealm = GetRealmName()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -106,14 +109,39 @@ local function CreatePluginFrames()
|
||||
texturedown:SetPoint ("bottomright", TimeAttackFrame)
|
||||
texturedown:SetWidth (300)
|
||||
|
||||
--> text informing about the amount of time
|
||||
local TimeDesc = DetailsFrameWork:NewLabel (TimeAttackFrame, TimeAttackFrame, nil, "TimeDesc", Loc ["STRING_TIME_SELECTION"])
|
||||
TimeDesc:SetPoint ("topleft", TimeAttackFrame, 15, -260)
|
||||
--> slider
|
||||
--local TimeAmount = DetailsFrameWork:NewSlider (TimeAttackFrame, nil, "DetailsTimeAttackTimeSelect", "TimeSelect", 270, 20, 30, 330, 1, TimeAttack.db.time)
|
||||
--TimeAmount:SetPoint ("topleft", TimeAttackFrame, 15, -270)
|
||||
--TimeAmount.OnChangeHook = function (_, _, value) TimeAttack.db.time = value end
|
||||
|
||||
local on_select_time = function (_, _, time)
|
||||
TimeAttack.db.time = time
|
||||
end
|
||||
local icon = [[Interface\Challenges\challenges-minimap-banner]]
|
||||
local textcoord = {0.2, 0.8, 0.2, 0.8}
|
||||
local time_table = {
|
||||
{value = 40, icon = icon, texcoord = textcoord, label = "40 seconds", onclick = on_select_time},
|
||||
{value = 90, icon = icon, texcoord = textcoord, label = "1 minute 30 seconds", onclick = on_select_time},
|
||||
{value = 120, icon = icon, texcoord = textcoord, label = "2 minutes", onclick = on_select_time},
|
||||
{value = 180, icon = icon, texcoord = textcoord, label = "3 minutes", onclick = on_select_time},
|
||||
{value = 300, icon = icon, texcoord = textcoord, label = "5 minutes", onclick = on_select_time},
|
||||
{value = 480, icon = icon, texcoord = textcoord, label = "8 minutes", onclick = on_select_time},
|
||||
}
|
||||
local build_time_menu = function()
|
||||
return time_table
|
||||
end
|
||||
local TimeAmount2 = DetailsFrameWork:NewDropDown (TimeAttackFrame, _, "$parentTimeDropdown", "TimeDropdown", 180, 20, build_time_menu, TimeAttack.db.time)
|
||||
|
||||
local TimeAmount = DetailsFrameWork:NewSlider (TimeAttackFrame, nil, "DetailsTimeAttackTimeSelect", "TimeSelect", 270, 20, 30, 330, 1, TimeAttack.db.time)
|
||||
TimeAmount:SetPoint ("topleft", TimeAttackFrame, 15, -270)
|
||||
TimeAmount.OnChangeHook = function (_, _, value) TimeAttack.db.time = value end
|
||||
--> text informing about the amount of time
|
||||
local TimeDesc = DetailsFrameWork:NewLabel (TimeAttackFrame, TimeAttackFrame, nil, "TimeDesc", "Time Amount:", "GameFontNormal")
|
||||
TimeDesc:SetPoint ("topleft", TimeAttackFrame, 10, -280)
|
||||
|
||||
local text_size = TimeDesc:GetStringWidth()
|
||||
local TimeAmountWidth = 300 - text_size - 11 - 4 - 14
|
||||
TimeAmount2:SetWidth (TimeAmountWidth)
|
||||
|
||||
--TimeAmount2:SetPoint ("topleft", TimeAttackFrame, 15, -270)
|
||||
TimeAmount2:SetPoint ("left", TimeDesc, "right", 4, 0)
|
||||
|
||||
--> main time/damage/dps texts
|
||||
local clock = DetailsFrameWork:NewLabel (TimeAttackFrame, TimeAttackFrame, nil, "TIMER", "00:00:00", "GameFontHighlightLarge")
|
||||
@@ -154,35 +182,178 @@ local function CreatePluginFrames()
|
||||
Hystory = TimeAttack.db.history
|
||||
}
|
||||
HistoryPanelObject.__index = HistoryPanelObject
|
||||
TimeAttack.HistoryPanelObject = HistoryPanelObject
|
||||
|
||||
--> build the button to switch between recent times and saved times
|
||||
local displayTipes = {Loc ["STRING_RECENTLY"], Loc ["STRING_SAVED"]}
|
||||
local switchButton
|
||||
function changedisplay()
|
||||
HistoryPanelObject.NowShowing = math.abs (HistoryPanelObject.NowShowing-3)
|
||||
local function changedisplay (param)
|
||||
HistoryPanelObject.NowShowing = param
|
||||
HistoryPanelObject:Refresh()
|
||||
switchButton.text = displayTipes [HistoryPanelObject.NowShowing]
|
||||
--HistoryPanelObject.NowShowing = math.abs (HistoryPanelObject.NowShowing-3)
|
||||
--switchButton.text = displayTipes [HistoryPanelObject.NowShowing]
|
||||
end
|
||||
|
||||
switchButton = DetailsFrameWork:NewButton (TimeAttackFrame, nil, "DetailsTimeAttackSwitchButton", "switchButton", 70, 15, changedisplay)
|
||||
switchButton:InstallCustomTexture()
|
||||
switchButton = DetailsFrameWork:NewButton (TimeAttackFrame, nil, "DetailsTimeAttackSwitchButton", "switchButton", 70, 14, changedisplay, 1)
|
||||
switchButton:InstallCustomTexture (nil, nil, nil, nil, true)
|
||||
switchButton:SetPoint (227, -35)
|
||||
switchButton.text = displayTipes [HistoryPanelObject.NowShowing]
|
||||
|
||||
local leftSwitchTexture = switchButton:CreateTexture (nil, "overlay")
|
||||
leftSwitchTexture:SetTexture ("Interface\\TALENTFRAME\\talent-main")
|
||||
leftSwitchTexture:SetTexCoord (0.13671875, 0.25, 0.486328125, 0.576171875)
|
||||
leftSwitchTexture:SetPoint ("left", switchButton.button, 0, 0)
|
||||
leftSwitchTexture:SetWidth (10)
|
||||
leftSwitchTexture:SetHeight (17)
|
||||
local savedButton = DetailsFrameWork:NewButton (TimeAttackFrame, nil, "DetailsTimeAttackSavedButton", "SavedButton", 70, 14, changedisplay, 2)
|
||||
savedButton:InstallCustomTexture (nil, nil, nil, nil, true)
|
||||
savedButton:SetPoint (227, -19)
|
||||
savedButton.text = "Saved"
|
||||
|
||||
local rightSwitchTexture = switchButton:CreateTexture (nil, "overlay")
|
||||
rightSwitchTexture:SetTexture ("Interface\\TALENTFRAME\\talent-main")
|
||||
rightSwitchTexture:SetTexCoord (0.01953125, 0.13671875, 0.486328125, 0.576171875)
|
||||
rightSwitchTexture:SetPoint ("right", switchButton.button, 0, 0)
|
||||
rightSwitchTexture:SetWidth (10)
|
||||
rightSwitchTexture:SetHeight (17)
|
||||
local realmButton = DetailsFrameWork:NewButton (TimeAttackFrame, nil, "DetailsTimeAttackSwitchButton", "RealmButton", 70, 14, changedisplay, 3)
|
||||
realmButton:InstallCustomTexture (nil, nil, nil, nil, true)
|
||||
realmButton:SetPoint (227, -3)
|
||||
realmButton.text = "Realm"
|
||||
|
||||
--> realm times
|
||||
|
||||
--> select realm history type
|
||||
local on_select_historytype = function (_, _, type)
|
||||
TimeAttack.db.realm_last_shown = type
|
||||
changedisplay (3)
|
||||
end
|
||||
local menu = {
|
||||
{value = 40, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "40 seconds", onclick = on_select_historytype},
|
||||
{value = 90, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "1 minute 30 seconds", onclick = on_select_historytype},
|
||||
{value = 120, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "2 minutes", onclick = on_select_historytype},
|
||||
{value = 180, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "3 minutes", onclick = on_select_historytype},
|
||||
{value = 300, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "5 minutes", onclick = on_select_historytype},
|
||||
{value = 480, icon = icon, iconcolor = "orange", texcoord = textcoord, label = "8 minutes", onclick = on_select_historytype}
|
||||
}
|
||||
local build_historytype_menu = function()
|
||||
return menu
|
||||
end
|
||||
local RealmHistoryType = DetailsFrameWork:NewDropDown (TimeAttackFrame, _, "$parentRealmHistoryType", "RealmHistoryType", 180, 20, build_historytype_menu, TimeAttack.db.realm_last_shown)
|
||||
RealmHistoryType:SetPoint ("topleft", TimeAttackFrame, "topleft", 2, -31)
|
||||
RealmHistoryType:SetPoint ("right", switchButton, "left", -4, 1)
|
||||
|
||||
local scrollframe_realm = CreateFrame ("scrollframe", "TimeAttackRealmDpsScroll", TimeAttackFrame, "ListScrollFrameTemplate")
|
||||
scrollframe_realm:SetPoint ("topleft", TimeAttackFrame, "topleft", 0, -50)
|
||||
scrollframe_realm:SetSize (295, 100)
|
||||
|
||||
local sort_dps = function (t1, t2) return t1.Dps > t2.Dps end
|
||||
|
||||
local update_scrollrealm = function (self)
|
||||
|
||||
local sample_size = TimeAttack.db.realm_last_shown
|
||||
local container = TimeAttack.db.realm_history
|
||||
|
||||
local samples = {}
|
||||
for i = 1, #container do
|
||||
local this_sample = TimeAttack.db.realm_history [i]
|
||||
if (this_sample.Time == sample_size) then
|
||||
tinsert (samples, this_sample)
|
||||
end
|
||||
end
|
||||
|
||||
table.sort (samples, sort_dps)
|
||||
|
||||
local total_samples = #samples
|
||||
local offset = FauxScrollFrame_GetOffset (self)
|
||||
--print (total_samples)
|
||||
|
||||
for i = 1, 14 do
|
||||
local frame = self.childs [i]
|
||||
local index = (offset * 2) + i
|
||||
|
||||
local sample = samples [index]
|
||||
|
||||
if (index <= total_samples and sample) then
|
||||
frame:Show()
|
||||
local player_name = sample.Source
|
||||
if (player_name:find (TimeAttack.PlayerRealm)) then
|
||||
player_name = TimeAttack:GetOnlyName (player_name)
|
||||
end
|
||||
frame.lefttext.text = index .. ". " .. player_name
|
||||
frame.righttext.text = TimeAttack:comma_value (_math_floor (sample.Dps))
|
||||
frame.sample = sample
|
||||
else
|
||||
frame:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
FauxScrollFrame_Update (self, ceil (#samples / 2) , 5, 14)
|
||||
end
|
||||
|
||||
scrollframe_realm.Update = update_scrollrealm
|
||||
scrollframe_realm:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scrollframe_realm, offset, 14, update_scrollrealm) end)
|
||||
scrollframe_realm.childs = {}
|
||||
|
||||
local on_enter = function (self)
|
||||
self:SetBackdrop ({tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = [[Interface\AddOns\Details\images\border_2]], edgeSize = 8})
|
||||
self:SetBackdropColor (.1, .1, .1, .1)
|
||||
|
||||
GameCooltip:Reset()
|
||||
|
||||
local TimeObject = self.sample
|
||||
|
||||
GameCooltip:AddLine (TimeAttack:comma_value (TimeObject.DamageDone))
|
||||
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\PetBadge-Undead")
|
||||
|
||||
GameCooltip:AddLine (TimeAttack:comma_value (_math_floor (TimeObject.Dps)))
|
||||
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\PetBadge-Elemental")
|
||||
|
||||
GameCooltip:AddLine (string.format ("%.1f", TimeObject.ItemLevel))
|
||||
GameCooltip:AddIcon ("Interface\\TARGETINGFRAME\\PetBadge-Humanoid")
|
||||
|
||||
local age = _math_floor ((time() - TimeObject [1]) / 86400) --one day
|
||||
GameCooltip:AddLine (age .. " days")
|
||||
GameCooltip:AddIcon ([[Interface\FriendsFrame\StatusIcon-Away]], 1, 1, 16, 16, 0, 0.85, 0, 1)
|
||||
|
||||
GameCooltip:ShowCooltip (self, "tooltip")
|
||||
|
||||
end
|
||||
local on_leave = function (self)
|
||||
self:SetBackdrop ({tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background"})
|
||||
self:SetBackdropColor (.1, .1, .1, .3)
|
||||
GameCooltip:Hide()
|
||||
end
|
||||
|
||||
local row_index = 0
|
||||
for i = 1, 14 do
|
||||
local child = CreateFrame ("frame", "TimeAttackRealmDpsScrollChield" .. i, TimeAttackFrame)
|
||||
if (i%2 == 0) then
|
||||
child:SetPoint ("left", scrollframe_realm.childs [i-1], "right", 2, 0)
|
||||
else
|
||||
child:SetPoint ("topleft", scrollframe_realm, "topleft", 2, (row_index*14*-1) - 2)
|
||||
row_index = row_index + 1
|
||||
end
|
||||
|
||||
child:SetFrameLevel (scrollframe_realm:GetFrameLevel()+1)
|
||||
child:SetSize (146, 13)
|
||||
child:SetBackdrop ({tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background"})
|
||||
child:SetBackdropColor (.1, .1, .1, .3)
|
||||
scrollframe_realm.childs [i] = child
|
||||
|
||||
local left_text = DetailsFrameWork:CreateLabel (child, "", 10, "white", nil, "lefttext")
|
||||
left_text:SetPoint ("left", child, "left", 2, 0)
|
||||
local right_text = DetailsFrameWork:CreateLabel (child, "", 10, "white", nil, "righttext")
|
||||
right_text:SetPoint ("right", child, "right", -2, 0)
|
||||
|
||||
child:SetScript ("OnEnter", on_enter)
|
||||
child:SetScript ("OnLeave", on_leave)
|
||||
end
|
||||
|
||||
function TimeAttack:HideRealmScroll()
|
||||
RealmHistoryType:Hide()
|
||||
scrollframe_realm:Hide()
|
||||
for i = 1, 14 do
|
||||
scrollframe_realm.childs [i]:Hide()
|
||||
end
|
||||
end
|
||||
function TimeAttack:ShowRealmScroll()
|
||||
RealmHistoryType:Show()
|
||||
scrollframe_realm:Show()
|
||||
for i = 1, 14 do
|
||||
scrollframe_realm.childs [i]:Show()
|
||||
end
|
||||
scrollframe_realm:Update()
|
||||
end
|
||||
|
||||
--> remove a saved or recently time
|
||||
local remove = function (index)
|
||||
if (HistoryPanelObject.NowShowing == 1) then --> recently
|
||||
@@ -205,6 +376,8 @@ local function CreatePluginFrames()
|
||||
NewSave.ItemLevel = ToSaveTimeObject.FinishIlevel
|
||||
NewSave.Date = ToSaveTimeObject.Date
|
||||
NewSave.note = ToSaveTimeObject.note
|
||||
NewSave.ID = ToSaveTimeObject.ID or math.random (10000000, 99999999)
|
||||
NewSave.Age = ToSaveTimeObject.Age or time()
|
||||
|
||||
table.insert (TimeAttack.db.history, 1, NewSave)
|
||||
table.remove (TimeAttack.db.history, 25)
|
||||
@@ -218,12 +391,17 @@ local function CreatePluginFrames()
|
||||
end
|
||||
|
||||
elseif (TimeAttack.Time and TimeAttack.Time.FinishOkey and not TimeAttack.Time.FinishSaved) then --> click on SAVE button
|
||||
|
||||
local NewSave = {}
|
||||
|
||||
NewSave.DamageDone = TimeAttack.Time.FinishDamage
|
||||
NewSave.Dps = TimeAttack.Time.FinishDps
|
||||
NewSave.Time = TimeAttack.Time.FinishTime
|
||||
NewSave.ItemLevel = TimeAttack.Time.FinishIlevel
|
||||
NewSave.Date = TimeAttack.Time.Date
|
||||
NewSave.ID = TimeAttack.Time.ID or math.random (10000000, 99999999)
|
||||
NewSave.Age = TimeAttack.Time.Age or time()
|
||||
|
||||
TimeAttack.Time.FinishSaved = true
|
||||
table.insert (TimeAttack.db.history, 1, NewSave)
|
||||
table.remove (TimeAttack.db.history, 25)
|
||||
@@ -339,6 +517,9 @@ local function CreatePluginFrames()
|
||||
|
||||
local OnEnterHook = function (self, arg2, arg3)
|
||||
|
||||
self:SetBackdrop ({tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile = [[Interface\AddOns\Details\images\border_2]], edgeSize = 8})
|
||||
self:SetBackdropColor (.1, .1, .1, .1)
|
||||
|
||||
self = self.BoxObject
|
||||
|
||||
if (HistoryPanelObject.NowShowing == 1) then --> recently
|
||||
@@ -381,10 +562,16 @@ local function CreatePluginFrames()
|
||||
|
||||
GameCooltip:ShowCooltip (self.background, "tooltip")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local OnLeaveHook= function (self)
|
||||
GameCooltip:ShowMe (false)
|
||||
self:SetBackdrop ({tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background"})
|
||||
self:SetBackdropColor (.1, .1, .1, .3)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
TimeAttack.HistoryX = 4
|
||||
@@ -452,17 +639,17 @@ local function CreatePluginFrames()
|
||||
SaveButton:Disable()
|
||||
ReportButton:Hide()
|
||||
end
|
||||
|
||||
|
||||
function HistoryPanelObject:CreateNewLabel (index)
|
||||
|
||||
local LabelBoxObject = {}
|
||||
self.LabelsCreated [#self.LabelsCreated+1] = LabelBoxObject
|
||||
setmetatable (LabelBoxObject, HistoryPanelObject)
|
||||
LabelBoxObject.index = index
|
||||
|
||||
local LabelBackground = DetailsFrameWork:NewPanel (bg1.frame, bg1.frame, "DetailsTimeAttackPanel"..index, "label"..index, 95, 12,
|
||||
{tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background"}, {.5, .5, .5, 1})
|
||||
|
||||
local LabelBackground = DetailsFrameWork:NewPanel (bg1.frame, bg1.frame, "DetailsTimeAttackPanel"..index, "label"..index, 95, 12,
|
||||
{tile = true, tileSize = 16, bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background"}, {.1, .1, .1, .3})
|
||||
|
||||
LabelBackground:SetPoint ("topleft", TimeAttackFrame, TimeAttack.HistoryX, TimeAttack.HistoryY)
|
||||
LabelBackground.frame.Gradient.OnEnter = {.9, .9, .9, 1}
|
||||
LabelBackground.frame:SetFrameLevel (bg1.frame:GetFrameLevel()+1)
|
||||
@@ -513,8 +700,14 @@ local function CreatePluginFrames()
|
||||
end
|
||||
|
||||
function HistoryPanelObject:Refresh()
|
||||
|
||||
if (self.NowShowing == 1) then --> recent
|
||||
|
||||
TimeAttackFrame.switchButton:SetTextColor (1, 1, 1, 1)
|
||||
TimeAttackFrame.SavedButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttackFrame.RealmButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttack:HideRealmScroll()
|
||||
|
||||
--> sort by damage done
|
||||
table.sort (self.Recently, function (a,b) return a.FinishDamage > b.FinishDamage end)
|
||||
local first = self.Recently [1]
|
||||
@@ -539,7 +732,13 @@ local function CreatePluginFrames()
|
||||
thisLabel.background:Hide()
|
||||
end
|
||||
|
||||
elseif (self.NowShowing == 2) then
|
||||
elseif (self.NowShowing == 2) then --> saved
|
||||
|
||||
TimeAttackFrame.switchButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttackFrame.SavedButton:SetTextColor (1, 1, 1, 1)
|
||||
TimeAttackFrame.RealmButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttack:HideRealmScroll()
|
||||
|
||||
for index, AttemptTable in ipairs (TimeAttack.db.history) do
|
||||
local thisLabel = self.LabelsCreated [index]
|
||||
if (not thisLabel) then
|
||||
@@ -552,6 +751,19 @@ local function CreatePluginFrames()
|
||||
local thisLabel = self.LabelsCreated [amt]
|
||||
thisLabel.background:Hide()
|
||||
end
|
||||
|
||||
elseif (self.NowShowing == 3) then --> realm
|
||||
|
||||
for amt = 1, #self.LabelsCreated do
|
||||
local thisLabel = self.LabelsCreated [amt]
|
||||
thisLabel.background:Hide()
|
||||
end
|
||||
|
||||
TimeAttackFrame.switchButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttackFrame.SavedButton:SetTextColor (1, 0.8, 0, 1)
|
||||
TimeAttackFrame.RealmButton:SetTextColor (1, 1, 1, 1)
|
||||
|
||||
TimeAttack:ShowRealmScroll()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -627,10 +839,14 @@ local function CreatePluginFrames()
|
||||
TimeAttack.Time.FinishIlevel = equipped
|
||||
TimeAttack.Time.Date = date ("%H:%M %d/%m/%y")
|
||||
TimeAttack.Time.N = TimeAttack.try
|
||||
TimeAttack.Time.ID = math.random (10000000, 99999999)
|
||||
TimeAttack.Time.Age = time()
|
||||
HistoryPanelObject:AddRecently (TimeAttack.Time)
|
||||
TimeAttack.try = TimeAttack.try + 1
|
||||
SaveButton:Enable()
|
||||
ReportButton:Show()
|
||||
|
||||
TimeAttack:ShareRecently (TimeAttack.Time)
|
||||
end
|
||||
|
||||
function _detalhes:TimeAttackPluginStart()
|
||||
@@ -646,7 +862,7 @@ local function CreatePluginFrames()
|
||||
|
||||
TimeAttack.Time = {}
|
||||
TimeAttack.Time.StartTime = _GetTime()
|
||||
TimeAttack.Time.EndTime = TimeAttack.Time.StartTime + TimeAmount.value - 2
|
||||
TimeAttack.Time.EndTime = TimeAttack.Time.StartTime + TimeAttack.db.time - 2
|
||||
TimeAttack.Time.Elapsed = 2
|
||||
TimeAttack.Time.Done = nil
|
||||
TimeAttack.Time.Working = true
|
||||
@@ -655,7 +871,7 @@ local function CreatePluginFrames()
|
||||
TimeAttack.Time.FinishOkey = false
|
||||
TimeAttack.Time.FinishSaved = false
|
||||
TimeAttack.Time.FinishDamage = nil
|
||||
TimeAttack.Time.FinishTime = TimeAmount.value
|
||||
TimeAttack.Time.FinishTime = TimeAttack.db.time
|
||||
TimeAttack.Time.FinishDps = nil
|
||||
TimeAttack.Time.FinishIlevel = nil
|
||||
TimeAttack.Time.Date = nil
|
||||
@@ -675,6 +891,13 @@ local function CreatePluginFrames()
|
||||
|
||||
end
|
||||
|
||||
local options = DetailsFrameWork:NewButton (TimeAttackFrame, nil, "$parentOptionsButton", "OptionsButton", 86, 16, TimeAttack.OpenOptionsPanel, nil, nil, nil, "Options")
|
||||
options:SetPoint ("bottomleft", TimeAttackFrame, "bottomleft", 5, 22)
|
||||
--options:SetPoint ("bottomright", TimeAttackFrame, "bottomright", -10, 30)
|
||||
--options:SetPoint ("bottomright", TimeAmount2, "topright", 0, 1)
|
||||
--options:InstallCustomTexture()
|
||||
options:SetTextColor (1, 0.93, 0.74)
|
||||
options:SetIcon ([[Interface\Buttons\UI-OptionsButton]], 14, 14, nil, {0, 1, 0, 1}, nil, 3)
|
||||
end
|
||||
|
||||
function TimeAttack:CheckTimeAttackTutorial()
|
||||
@@ -709,6 +932,176 @@ function TimeAttack:ShowTargetTutorial()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TimeAttack:AddRealmData (damage, time, ilevel, age, id, class, source)
|
||||
local t = {
|
||||
age,
|
||||
DamageDone = damage[1],
|
||||
Dps = damage[2],
|
||||
Time = time,
|
||||
ItemLevel = ilevel,
|
||||
ID = id,
|
||||
Source = source
|
||||
}
|
||||
|
||||
tinsert (TimeAttack.db.realm_history, t)
|
||||
table.sort (TimeAttack.db.realm_history, TimeAttack.Sort1)
|
||||
|
||||
if (#TimeAttack.db.realm_history > 60) then
|
||||
table.remove (TimeAttack.db.realm_history, 61)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--request data
|
||||
function TimeAttack:RequestRealmResults()
|
||||
if (TimeAttack.last_channel_request+600 < time()) then
|
||||
TimeAttack.last_channel_request = time()
|
||||
TimeAttack:SendPluginCommMessage ("TARE", nil, select (2, UnitClass ("player")))
|
||||
end
|
||||
end
|
||||
|
||||
function TimeAttack:OnReceiveRequest (class)
|
||||
if (class == select (2, UnitClass ("player")) and TimeAttack.last_forced_share+20 < time()) then
|
||||
TimeAttack.last_forced_share = time()
|
||||
TimeAttack:ShareResults() --share saved
|
||||
TimeAttack:ShareAllRecently() --share recently
|
||||
end
|
||||
end
|
||||
|
||||
--saved
|
||||
function TimeAttack:ShareResults()
|
||||
for i = TimeAttack.db.history_lastindex+1, TimeAttack.db.history_lastindex+3 do
|
||||
local this_saved = TimeAttack.db.history [i]
|
||||
if (not this_saved) then
|
||||
TimeAttack.db.history_lastindex = 0
|
||||
break
|
||||
end
|
||||
|
||||
TimeAttack:ShareSaved (this_saved)
|
||||
TimeAttack.db.history_lastindex = i
|
||||
end
|
||||
end
|
||||
|
||||
function TimeAttack:ShareSaved (saved)
|
||||
local data = TimeAttack:PrepareToShare (saved)
|
||||
|
||||
if (TimeAttack.db.saved_as_anonymous) then
|
||||
data [7] = "Unidentified"
|
||||
else
|
||||
data [7] = UnitName ("player") .. "-" .. GetRealmName()
|
||||
end
|
||||
|
||||
TimeAttack:ScheduleTimer ("SendQueuedData", math.random (1, 5), data)
|
||||
end
|
||||
|
||||
--recentrly
|
||||
function TimeAttack:ShareAllRecently()
|
||||
local amt = 0
|
||||
for index, recent in ipairs (TimeAttack.HistoryPanelObject.Recently) do
|
||||
TimeAttack:ShareRecently (recent)
|
||||
amt = amt + 1
|
||||
if (amt == 3) then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TimeAttack:ShareRecently (recent)
|
||||
local data = TimeAttack:PrepareToShare (recent)
|
||||
|
||||
if (TimeAttack.db.recently_as_anonymous) then
|
||||
data [7] = "Unidentified"
|
||||
else
|
||||
data [7] = UnitName ("player") .. "-" .. GetRealmName()
|
||||
end
|
||||
|
||||
TimeAttack:ScheduleTimer ("SendQueuedData", math.random (1, 5), data)
|
||||
end
|
||||
|
||||
--send and receive data functions
|
||||
|
||||
function TimeAttack:OnReceiveShared (damage, time, ilevel, age, id, class, source)
|
||||
--print ("TA:", damage[1], damage[2], time, ilevel, age, id, class, source) --debug
|
||||
|
||||
if (not TimeAttack:IsPluginEnabled()) then
|
||||
return
|
||||
end
|
||||
|
||||
--same class
|
||||
if (class ~= select (2, UnitClass ("player"))) then
|
||||
return
|
||||
end
|
||||
--already exists
|
||||
for index, data in ipairs (TimeAttack.db.realm_history) do
|
||||
if (data.ID == id) then
|
||||
return
|
||||
end
|
||||
end
|
||||
--add
|
||||
TimeAttack:AddRealmData (damage, time, ilevel, age, id, class, source)
|
||||
end
|
||||
|
||||
function TimeAttack:SendQueuedData (data)
|
||||
TimeAttack:SendPluginCommMessage ("TASH", nil, data[1], data[2], data[3], data[4], data[5], data[6], data [7])
|
||||
end
|
||||
|
||||
function TimeAttack:PrepareToShare (sample)
|
||||
local send_table = {}
|
||||
send_table [1] = {_math_floor (sample.FinishDamage or sample.DamageDone), _math_floor (sample.FinishDps or sample.Dps)} --damage and dps
|
||||
send_table [2] = sample.FinishTime or sample.Time --time
|
||||
send_table [3] = _math_floor (sample.FinishIlevel or sample.ItemLevel) --ilevel
|
||||
send_table [4] = sample.Age --age
|
||||
send_table [5] = sample.ID --id
|
||||
send_table [6] = select (2, UnitClass ("player"))
|
||||
return send_table
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--options
|
||||
local build_options_panel = function()
|
||||
|
||||
local options_frame = TimeAttack:CreatePluginOptionsFrame ("TimeAttackOptionsWindow", "Time Attack Options", 1)
|
||||
local menu = {
|
||||
{
|
||||
type = "toggle",
|
||||
get = function() return TimeAttack.db.recently_as_anonymous end,
|
||||
set = function (self, fixedparam, value) TimeAttack.db.recently_as_anonymous = value end,
|
||||
desc = "When enabled, your recently samples are shared without telling your character name.",
|
||||
name = "Share Recently as Anonymous"
|
||||
},
|
||||
{
|
||||
type = "toggle",
|
||||
get = function() return TimeAttack.db.saved_as_anonymous end,
|
||||
set = function (self, fixedparam, value) TimeAttack.db.saved_as_anonymous = value end,
|
||||
desc = "When enabled, your saved samples are shared without telling your character name.",
|
||||
name = "Share Saved as Anonymous"
|
||||
},
|
||||
{
|
||||
type = "toggle",
|
||||
get = function() return TimeAttack.db.disable_sharing end,
|
||||
set = function (self, fixedparam, value) TimeAttack.db.disable_sharing = value end,
|
||||
desc = "When enabled, your damage samples aren't shared with other players in your realm.\n\n|cFFFFFF00Important|r: when disabled you also can't get samples from other players.",
|
||||
name = "Disable Sharing"
|
||||
},
|
||||
}
|
||||
|
||||
_detalhes.gump:BuildMenu (options_frame, menu, 15, -65, 260)
|
||||
|
||||
end
|
||||
TimeAttack.OpenOptionsPanel = function()
|
||||
if (not TimeAttackOptionsWindow) then
|
||||
build_options_panel()
|
||||
end
|
||||
TimeAttackOptionsWindow:Show()
|
||||
end
|
||||
|
||||
function TimeAttack:OnEvent (_, event, ...)
|
||||
|
||||
if (event == "PLAYER_TARGET_CHANGED") then
|
||||
@@ -723,9 +1116,16 @@ function TimeAttack:OnEvent (_, event, ...)
|
||||
local MINIMAL_DETAILS_VERSION_REQUIRED = 1
|
||||
|
||||
local default_settings = {
|
||||
time = 60,
|
||||
time = 40,
|
||||
dps = 0,
|
||||
history = {},
|
||||
history_lastindex = 0,
|
||||
realm_history = {},
|
||||
realm_lastamt = 0,
|
||||
realm_last_shown = 40,
|
||||
recently_as_anonymous = true,
|
||||
saved_as_anonymous = true,
|
||||
disable_sharing = false,
|
||||
}
|
||||
|
||||
if (_detalhes_databaseTimeAttack) then
|
||||
@@ -740,12 +1140,61 @@ function TimeAttack:OnEvent (_, event, ...)
|
||||
return
|
||||
end
|
||||
|
||||
--> fix for old versions
|
||||
local ta = TimeAttack.db.time
|
||||
if (ta ~= 40 and ta ~= 90 and ta ~= 120 and ta ~= 180 and ta ~= 300 and ta ~= 480) then
|
||||
TimeAttack.db.time = 40
|
||||
end
|
||||
for index, saved in ipairs (TimeAttack.db.history) do
|
||||
if (not saved.ID) then
|
||||
saved.ID = math.random (10000000, 99999999)
|
||||
end
|
||||
if (not saved.Age) then
|
||||
saved.Age = time()
|
||||
end
|
||||
end
|
||||
--
|
||||
|
||||
--> Register needed events
|
||||
_G._detalhes:RegisterEvent (TimeAttack, "COMBAT_PLAYER_ENTER")
|
||||
|
||||
--> create widgets
|
||||
CreatePluginFrames()
|
||||
|
||||
--> register comm
|
||||
TimeAttack:RegisterPluginComm ("TASH", "OnReceiveShared")
|
||||
TimeAttack:RegisterPluginComm ("TARE", "OnReceiveRequest")
|
||||
TimeAttack.last_forced_share = 0
|
||||
TimeAttack.last_channel_request = 0
|
||||
|
||||
--/run DETAILS_PLUGIN_TIME_ATTACK:ShareResults()
|
||||
|
||||
--> register background task
|
||||
TimeAttack:RegisterBackgroundTask ("TimeAttackSharer", "ShareResults", "LOW")
|
||||
|
||||
--> Register slash commands
|
||||
SLASH_DETAILS_TIMEATTACK1, SLASH_DETAILS_TIMEATTACK2 = "/timeattack", "/ta"
|
||||
function SlashCmdList.DETAILS_TIMEATTACK (msg, editbox)
|
||||
if (not TimeAttackFrame:IsShown()) then
|
||||
--> check if there is a instance closed with time attack
|
||||
for index, instance in TimeAttack:ListInstances() do
|
||||
if (instance:IsSoloMode (true)) then
|
||||
instance:EnableInstance()
|
||||
TimeAttack.SoloTables:switch (nil, "DETAILS_PLUGIN_TIME_ATTACK")
|
||||
return
|
||||
end
|
||||
end
|
||||
--> open a new instance
|
||||
if (TimeAttack:GetFreeInstancesAmount() > 0) then
|
||||
local newinstance = TimeAttack:CreateInstance (true) --> force create a new one
|
||||
if (newinstance) then
|
||||
newinstance:SetMode (DETAILS_MODE_SOLO)
|
||||
TimeAttack.SoloTables:switch (nil, "DETAILS_PLUGIN_TIME_ATTACK")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -307,6 +307,7 @@ function _G._detalhes:Start()
|
||||
end
|
||||
|
||||
_detalhes:FillUserCustomSpells()
|
||||
_detalhes:AddDefaultCustomDisplays()
|
||||
|
||||
if (_detalhes_database.last_realversion and _detalhes_database.last_realversion < 20 and enable_reset_warning) then
|
||||
table.wipe (self.custom)
|
||||
|
||||
Reference in New Issue
Block a user