- Save data on logout now is a separate script and others lua erros do not broke it any more.

- Few improvements on how instances load on logon.
- Slash commands are now more responsible, 'show' shows all windows, 'hide' hide them all, 'new' create a window.
- More Fixes for alpha mods and auto interact.

- New API: instance:InstaceAlpha (alpha) modify the alpha of window textures without saving.
- New API: instance:SetIconAlpha (alpha, hide, no_animations), modify the alpha of buttons without saving.
This commit is contained in:
tercio
2014-06-26 21:56:05 -03:00
parent c92f4e2d1c
commit 4fca65b5f3
8 changed files with 231 additions and 97 deletions
+1 -1
View File
@@ -3,11 +3,11 @@
xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
<!-- event listener -->
<Frame name="_detalhes_listener">
<Scripts>
<OnLoad>
self:RegisterEvent ("ADDON_LOADED");
self:RegisterEvent ("PLAYER_LOGOUT");
</OnLoad>
<OnEvent>
_detalhes.OnEvent (self, event, ...);
+1 -1
View File
@@ -8,7 +8,7 @@
_ = nil
_detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0", "LibHotCorners")
_detalhes.userversion = "v1.17.2"
_detalhes.userversion = "v1.17.3"
_detalhes.version = "Alpha 020"
_detalhes.realversion = 20
+54 -33
View File
@@ -42,22 +42,47 @@ local segmentos = _detalhes.segmentos
end
function _detalhes:ReativarInstancias()
_detalhes.opened_windows = 0
for index = #_detalhes.tabela_instancias, 1, -1 do
--> set metatables
for index = 1, #_detalhes.tabela_instancias do
local instancia = _detalhes.tabela_instancias [index]
if (not _getmetatable (instancia)) then
_setmetatable (_detalhes.tabela_instancias[index], _detalhes)
end
if (instancia:IsAtiva()) then --> só reabre se ela estiver ativa
instancia:RestauraJanela (index)
if (not _detalhes.initializing) then
_detalhes:SendEvent ("DETAILS_INSTANCE_OPEN", nil, instancia)
end
end
--> create frames
for index = 1, #_detalhes.tabela_instancias do
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
--print ("Abertas: " .. _detalhes.opened_windows)
--> load
for index = 1, #_detalhes.tabela_instancias do
local instancia = _detalhes.tabela_instancias [index]
if (instancia:IsEnabled()) then
instancia.iniciada = true
instancia:AtivarInstancia()
instancia:ChangeSkin()
end
end
--> send open event
for index = 1, #_detalhes.tabela_instancias do
local instancia = _detalhes.tabela_instancias [index]
if (instancia:IsEnabled()) then
if (not _detalhes.initializing) then
_detalhes:SendEvent ("DETAILS_INSTANCE_OPEN", nil, instancia)
end
end
end
end
------------------------------------------------------------------------------------------------------------------------
@@ -197,6 +222,14 @@ end
------------------------------------------------------------------------------------------------------------------------
function _detalhes:ShutDownAllInstances()
for index, instance in _ipairs (_detalhes.tabela_instancias) do
if (instance:IsEnabled()) then
instance:ShutDown()
end
end
end
function _detalhes:ShutDown()
return self:DesativarInstancia()
end
@@ -997,7 +1030,7 @@ end
--> ao reiniciar o addon esta função é rodada para recriar a janela da instância
--> search key: ~restaura ~inicio ~start
function _detalhes:RestauraJanela (index, temp)
function _detalhes:RestauraJanela (index, temp, load_only)
--> load
self:LoadInstanceConfig()
@@ -1023,26 +1056,13 @@ function _detalhes:RestauraJanela (index, temp)
self.row_height = self.row_info.height + self.row_info.space.between
--> create frames
local instance_baseframe = _G ["DetailsBaseFrame" .. self.meu_id]
if (instance_baseframe) then
local _baseframe, _bgframe, _bgframe_display, _scrollframe = instance_baseframe, _G ["Details_WindowFrame" .. self.meu_id], _G ["Details_GumpFrame" .. self.meu_id], _G ["Details_ScrollBar" .. self.meu_id]
self.baseframe = _baseframe
self.bgframe = _bgframe
self.bgdisplay = _bgframe_display
self.scroll = _scrollframe
_baseframe:EnableMouseWheel (false)
self.alturaAntiga = _baseframe:GetHeight()
else
local _baseframe, _bgframe, _bgframe_display, _scrollframe = gump:CriaJanelaPrincipal (self.meu_id, self)
self.baseframe = _baseframe
self.bgframe = _bgframe
self.bgdisplay = _bgframe_display
self.scroll = _scrollframe
_baseframe:EnableMouseWheel (false)
self.alturaAntiga = _baseframe:GetHeight()
end
local _baseframe, _bgframe, _bgframe_display, _scrollframe = gump:CriaJanelaPrincipal (self.meu_id, self)
self.baseframe = _baseframe
self.bgframe = _bgframe
self.bgdisplay = _bgframe_display
self.scroll = _scrollframe
_baseframe:EnableMouseWheel (false)
self.alturaAntiga = _baseframe:GetHeight()
--> 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
@@ -1110,13 +1130,14 @@ function _detalhes:RestauraJanela (index, temp)
self:ReajustaGump()
self:SaveMainWindowPosition()
self.iniciada = true
self:AtivarInstancia (temp)
self:ChangeSkin()
if (not load_only) then
self.iniciada = true
self:AtivarInstancia (temp)
self:ChangeSkin()
end
--> all done
return
end
function _detalhes:SwitchBack()
+38 -24
View File
@@ -2780,30 +2780,6 @@
end
end
function _detalhes.parser_functions:PLAYER_LOGOUT (...)
--> close info window
_detalhes:FechaJanelaInfo()
--> leave combat start save tables
if (_detalhes.in_combat) then
_detalhes:SairDoCombate()
_detalhes.can_panic_mode = true
end
_detalhes:CheckSwitchOnLogon() --eh logon mesmo
if (_detalhes.wipe_full_config) then
_detalhes_global = nil
_detalhes_database = nil
return
end
_detalhes:SaveConfig()
_detalhes:SaveProfile()
_detalhes_database.nick_tag_cache = table_deepcopy (_detalhes_database.nick_tag_cache)
end
function _detalhes.parser_functions:ADDON_LOADED (...)
local addon_name = _select (1, ...)
@@ -2866,6 +2842,44 @@
end
_detalhes.listener:SetScript ("OnEvent", _detalhes.OnEvent)
--> protected logout function
function _detalhes:PLAYER_LOGOUT (...)
--> close info window
if (_detalhes.FechaJanelaInfo) then
_detalhes:FechaJanelaInfo()
end
--> leave combat start save tables
if (_detalhes.in_combat and _detalhes.tabela_vigente) then
_detalhes:SairDoCombate()
_detalhes.can_panic_mode = true
end
if (_detalhes.CheckSwitchOnLogon and _detalhes.tabela_instancias[1] and getmetatable (_detalhes.tabela_instancias[1])) then
_detalhes:CheckSwitchOnLogon()
end
if (_detalhes.wipe_full_config) then
_detalhes_global = nil
_detalhes_database = nil
return
end
--> save the config
_detalhes:SaveConfig()
_detalhes:SaveProfile()
--> save the nicktag cache
_detalhes_database.nick_tag_cache = table_deepcopy (_detalhes_database.nick_tag_cache)
end
local saver = CreateFrame ("frame", "_detalhes_saver_frame", UIParent)
saver:RegisterEvent ("PLAYER_LOGOUT")
saver:SetScript ("OnEvent", _detalhes.PLAYER_LOGOUT)
--> end
function _detalhes:OnParserEvent (evento, time, token, hidding, who_serial, who_name, who_flags, who_flags2, alvo_serial, alvo_name, alvo_flags, alvo_flags2, ...)
local funcao = token_list [token]
+9 -21
View File
@@ -17,30 +17,17 @@ function SlashCmdList.DETAILS (msg, editbox)
local command, rest = msg:match("^(%S*)%s*(.-)$")
if (command == Loc ["STRING_SLASH_NEW"]) then
_detalhes:CriarInstancia()
_detalhes:CriarInstancia (nil, true)
elseif (command == Loc ["STRING_SLASH_HIDE"] or command == Loc ["STRING_SLASH_HIDE_ALIAS1"]) then
_detalhes:ShutDownAllInstances()
elseif (command == Loc ["STRING_SLASH_SHOW"] or command == Loc ["STRING_SLASH_SHOW_ALIAS1"]) then
_detalhes:ReabrirTodasInstancias()
elseif (command == Loc ["STRING_SLASH_WIPECONFIG"]) then
_detalhes:WipeConfig()
elseif (command == Loc ["STRING_SLASH_SHOW"]) then
if (_detalhes.opened_windows == 0) then
_detalhes:CriarInstancia()
else
-- ter certeza que não bugou a contagem
local have_opened = false
for _, instance in ipairs (_detalhes.tabela_instancias) do
if (instance.baseframe:IsShown()) then
have_opened = true
break
end
end
if (not have_opened) then
_detalhes:CriarInstancia()
end
end
elseif (command == Loc ["STRING_SLASH_DISABLE"]) then
_detalhes:CaptureSet (false, "damage", true)
@@ -87,7 +74,7 @@ function SlashCmdList.DETAILS (msg, editbox)
print (format ("%s: \124cff%s\124r", _table [1], IsQuestFlaggedCompleted (_table [2]) and "ff0000"..Loc ["STRING_KILLED"] or "00ff00"..Loc ["STRING_ALIVE"]))
end
elseif (command == Loc ["STRING_SLASH_CHANGES"]) then
elseif (command == Loc ["STRING_SLASH_CHANGES"] or command == Loc ["STRING_SLASH_CHANGES_ALIAS1"] or command == Loc ["STRING_SLASH_CHANGES_ALIAS2"]) then
_detalhes:OpenNewsWindow()
-------- debug ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -781,6 +768,7 @@ function SlashCmdList.DETAILS (msg, editbox)
print (Loc ["STRING_DETAILS1"] .. "(" .. _detalhes.userversion .. ") " .. Loc ["STRING_COMMAND_LIST"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_NEW"] .. "|r: " .. Loc ["STRING_SLASH_NEW_DESC"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_SHOW"] .. "|r: " .. Loc ["STRING_SLASH_SHOW_DESC"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_HIDE"] .. "|r: " .. Loc ["STRING_SLASH_HIDE_DESC"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_ENABLE"] .. "|r: " .. Loc ["STRING_SLASH_ENABLE_DESC"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_DISABLE"] .. "|r: " .. Loc ["STRING_SLASH_DISABLE_DESC"])
print ("|cffffaeae/details " .. Loc ["STRING_SLASH_OPTIONS"] .. "|r|cfffcffb0 <instance number>|r: " .. Loc ["STRING_SLASH_OPTIONS_DESC"])
+113 -10
View File
@@ -3222,7 +3222,9 @@ function _detalhes:SetWindowAlphaForInteract (alpha)
if (self.is_interacting) then
--> entrou
self.baseframe:SetAlpha (alpha)
--self.baseframe:SetAlpha (alpha)
self:InstanceAlpha (alpha)
self:SetIconAlpha (alpha, nil, true)
if (ignorebars) then
self.rowframe:SetAlpha (1)
@@ -3232,10 +3234,15 @@ function _detalhes:SetWindowAlphaForInteract (alpha)
else
--> saiu
if (self.combat_changes_alpha) then --> combat alpha
self.baseframe:SetAlpha (self.combat_changes_alpha)
--self.baseframe:SetAlpha (self.combat_changes_alpha)
self:InstanceAlpha (self.combat_changes_alpha)
self:SetIconAlpha (self.combat_changes_alpha, nil, true)
self.rowframe:SetAlpha (self.combat_changes_alpha) --alpha do combate é absoluta
else
self.baseframe:SetAlpha (alpha)
--self.baseframe:SetAlpha (alpha)
self:InstanceAlpha (alpha)
self:SetIconAlpha (alpha, nil, true)
if (ignorebars) then
self.rowframe:SetAlpha (1)
else
@@ -3249,21 +3256,24 @@ end
function _detalhes:SetWindowAlphaForCombat (entering_in_combat, true_hide)
local amount, rowsamount
local amount, rowsamount, menuamount
--get the values
if (entering_in_combat) then
amount = self.hide_in_combat_alpha / 100
self.combat_changes_alpha = amount
rowsamount = amount
menuamount = amount
if (_detalhes.pet_battle) then
amount = 0
rowsamount = 0
menuamount = 0
end
else
if (self.menu_alpha.enabled) then --auto transparency
if (self.is_interacting) then
amount = self.menu_alpha.onenter
menuamount = self.menu_alpha.onenter
if (self.menu_alpha.ignorebars) then
rowsamount = 1
else
@@ -3271,6 +3281,7 @@ function _detalhes:SetWindowAlphaForCombat (entering_in_combat, true_hide)
end
else
amount = self.menu_alpha.onleave
menuamount = self.menu_alpha.onleave
if (self.menu_alpha.ignorebars) then
rowsamount = 1
else
@@ -3279,18 +3290,28 @@ function _detalhes:SetWindowAlphaForCombat (entering_in_combat, true_hide)
end
else
amount = self.color [4]
menuamount = 1
rowsamount = 1
end
self.combat_changes_alpha = nil
end
--print ("baseframe:",amount,"rowframe:",rowsamount,"menu:",menuamount)
--apply
if (true_hide and amount == 0) then
gump:Fade (self.baseframe, _unpack (_detalhes.windows_fade_in))
gump:Fade (self.rowframe, _unpack (_detalhes.windows_fade_in))
self:SetIconAlpha (nil, true)
else
gump:Fade (self.baseframe, "ALPHAANIM", amount)
self.baseframe:Show()
self.baseframe:SetAlpha (1)
--gump:Fade (self.baseframe, "ALPHAANIM", amount)
self:InstanceAlpha (amount)
gump:Fade (self.rowframe, "ALPHAANIM", rowsamount)
self:SetIconAlpha (menuamount)
end
if (self.show_statusbar) then
@@ -3361,6 +3382,18 @@ function _detalhes:InstanceButtonsColors (red, green, blue, alpha, no_save, only
end
end
function _detalhes:InstanceAlpha (alpha)
self.baseframe.cabecalho.ball_r:SetAlpha (alpha)
self.baseframe.cabecalho.ball:SetAlpha (alpha)
self.baseframe.cabecalho.atributo_icon:SetAlpha (alpha)
self.baseframe.cabecalho.emenda:SetAlpha (alpha)
self.baseframe.cabecalho.top_bg:SetAlpha (alpha)
self.baseframe.barra_esquerda:SetAlpha (alpha)
self.baseframe.barra_direita:SetAlpha (alpha)
self.baseframe.barra_fundo:SetAlpha (alpha)
self.baseframe.UPFrame:SetAlpha (alpha)
end
function _detalhes:InstanceColor (red, green, blue, alpha, no_save, change_statusbar)
if (not red) then
@@ -3643,6 +3676,65 @@ function _detalhes:ToolbarMenu2ButtonsSize (size)
self.menu2_icons_size = size
return self:ToolbarMenu2Buttons()
end
local SetIconAlphaCacheButtonsTable = {}
function _detalhes:SetIconAlpha (alpha, hide, no_animations)
table.wipe (SetIconAlphaCacheButtonsTable)
if (self.attribute_text.enabled) then
if (not self.menu_attribute_string) then --> create on demand
self:AttributeMenu()
end
if (hide) then
gump:Fade (self.menu_attribute_string.widget, _unpack (_detalhes.windows_fade_in))
else
if (no_animations) then
self.menu_attribute_string:SetAlpha (alpha)
else
gump:Fade (self.menu_attribute_string.widget, "ALPHAANIM", alpha)
end
end
end
SetIconAlphaCacheButtonsTable [1] = self.baseframe.cabecalho.modo_selecao
SetIconAlphaCacheButtonsTable [2] = self.baseframe.cabecalho.segmento
SetIconAlphaCacheButtonsTable [3] = self.baseframe.cabecalho.atributo
SetIconAlphaCacheButtonsTable [4] = self.baseframe.cabecalho.report
SetIconAlphaCacheButtonsTable [5] = self.baseframe.cabecalho.fechar
SetIconAlphaCacheButtonsTable [6] = self.baseframe.cabecalho.novo
SetIconAlphaCacheButtonsTable [7] = self.baseframe.cabecalho.reset
for index, button in _ipairs (SetIconAlphaCacheButtonsTable) do
if (hide) then
gump:Fade (button, _unpack (_detalhes.windows_fade_in))
else
if (no_animations) then
button:SetAlpha (alpha)
else
gump:Fade (button, "ALPHAANIM", alpha)
end
end
end
if (self:IsLowerInstance()) then
if (#_detalhes.ToolBar.Shown > 0) then
for index, button in ipairs (_detalhes.ToolBar.Shown) do
if (hide) then
gump:Fade (button, _unpack (_detalhes.windows_fade_in))
else
if (no_animations) then
button:SetAlpha (alpha)
else
gump:Fade (button, "ALPHAANIM", alpha)
end
end
end
end
end
end
function _detalhes:ToolbarMenuButtons (_mode, _segment, _attributes, _report)
if (_mode == nil) then
@@ -3672,7 +3764,7 @@ function _detalhes:ToolbarMenuButtons (_mode, _segment, _attributes, _report)
local size = self.menu_icons_size
--> normal buttons
for index, button in ipairs (buttons) do
for index, button in _ipairs (buttons) do
if (self.menu_icons [index]) then
button:ClearAllPoints()
if (got_anchor) then
@@ -4524,6 +4616,15 @@ function _detalhes:ChangeSkin (skin_name)
_detalhes:OpenOptionsWindow (self)
end
--> check if is interacting
if (self.menu_alpha.enabled) then
if (_detalhes.in_combat) then
self:SetWindowAlphaForCombat (true)
else
self:SetWindowAlphaForCombat()
end
end
if (not just_updating or _detalhes.initializing) then
if (this_skin.callback) then
this_skin:callback (self, just_updating)
@@ -4538,7 +4639,6 @@ function _detalhes:ChangeSkin (skin_name)
self.bgframe.skin = this_skin
--self.bgframe.skin_script_instance = true
end
end
end
@@ -4567,10 +4667,10 @@ function _detalhes:SetCombatAlpha (modify_type, alpha_amount, interacting)
return
elseif (self.hide_in_combat_type == 2) then --While In Combat
_detalhes:ScheduleTimer ("DelayedCheckCombatAlpha", 0.5, self)
_detalhes:ScheduleTimer ("DelayedCheckCombatAlpha", 0.3, self)
elseif (self.hide_in_combat_type == 3) then --"While Out of Combat"
_detalhes:ScheduleTimer ("DelayedCheckOutOfCombatAlpha", 0.5, self)
_detalhes:ScheduleTimer ("DelayedCheckOutOfCombatAlpha", 0.3, self)
elseif (self.hide_in_combat_type == 4) then --"While Out of a Group"
if (_detalhes.in_group) then
@@ -4716,7 +4816,7 @@ function _detalhes:AttributeMenu (enabled, pos_x, pos_y, font, size, color, side
self.menu_attribute_string = nil
end
if (not self.menu_attribute_string) then
if (not self.menu_attribute_string) then
local label = gump:NewLabel (self.floatingframe, nil, "DetailsAttributeStringInstance" .. self.meu_id, nil, "", "GameFontHighlightSmall")
self.menu_attribute_string = label
@@ -4903,6 +5003,9 @@ function _detalhes:SetMenuAlpha (enabled, onenter, onleave, ignorebars, interact
if (not enabled) then
--> aqui esta mandando setar a alpha do baseframe
self.baseframe:SetAlpha (1)
self.rowframe:SetAlpha (1)
self:InstanceAlpha (self.color[4])
self:SetIconAlpha (1, nil, true)
return self:InstanceColor (unpack (self.color))
--return self:SetWindowAlphaForInteract (self.color [4])
else
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long