Skip to content

Commit

Permalink
table copy improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Mar 9, 2022
1 parent 92e138e commit ade373f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 35 deletions.
5 changes: 5 additions & 0 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ function DF.table.copy (t1, t2)
for key, value in pairs (t2) do
if (key ~= "__index") then
if (type (value) == "table") then

--if (SAVINGDATA) then
-- tinsert (_detalhes_global.exit_log, "copy loop key: " .. key)
--end

t1 [key] = t1 [key] or {}
DF.table.copy (t1 [key], t2 [key])
else
Expand Down
61 changes: 33 additions & 28 deletions classes/class_instance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -360,28 +360,28 @@ end
function _detalhes:ShutDownAllInstances()
for index, instance in _ipairs (_detalhes.tabela_instancias) do
if (instance:IsEnabled() and instance.baseframe and not instance.ignore_mass_showhide) then
instance:ShutDown(true)
instance:ShutDown()
end
end
end

--> alias
function _detalhes:HideWindow(all)
return self:DesativarInstancia(all)
function _detalhes:HideWindow()
return self:DesativarInstancia()
end
function _detalhes:ShutDown(all)
return self:DesativarInstancia(all)
function _detalhes:ShutDown()
return self:DesativarInstancia()
end
function _detalhes:Shutdown(all)
return self:DesativarInstancia(all)
function _detalhes:Shutdown()
return self:DesativarInstancia()
end

function _detalhes:GetNumWindows()

end

--> desativando a inst�ncia ela fica em stand by e apenas hida a janela ~shutdown ~close ~fechar
function _detalhes:DesativarInstancia(all)
function _detalhes:DesativarInstancia()

self.ativa = false
_detalhes.opened_windows = _detalhes.opened_windows-1
Expand Down Expand Up @@ -413,9 +413,8 @@ end
Details.FadeHandler.Fader (self.rowframe, 1)
Details.FadeHandler.Fader (self.windowSwitchButton, 1)

if (not all) then
self:Desagrupar (-1)
end
self:Desagrupar (-1)

if (self.modo == modo_raid) then
_detalhes.RaidTables:DisableRaidMode (self)

Expand Down Expand Up @@ -535,7 +534,7 @@ end
for index = math.min (#_detalhes.tabela_instancias, _detalhes.instances_amount), 1, -1 do
local instancia = _detalhes:GetInstance (index)
if (instancia and not instancia.ignore_mass_showhide) then
instancia:AtivarInstancia (temp, true)
instancia:AtivarInstancia (temp)
end
end
end
Expand Down Expand Up @@ -584,14 +583,14 @@ end
end

--> alias
function _detalhes:ShowWindow (temp, all)
return self:AtivarInstancia (temp, all)
function _detalhes:ShowWindow (temp)
return self:AtivarInstancia (temp)
end
function _detalhes:EnableInstance (temp, all)
return self:AtivarInstancia (temp, all)
function _detalhes:EnableInstance (temp)
return self:AtivarInstancia (temp)
end

function _detalhes:AtivarInstancia (temp, all)
function _detalhes:AtivarInstancia (temp)
self.ativa = true
self.cached_bar_width = self.cached_bar_width or 0

Expand Down Expand Up @@ -648,10 +647,7 @@ end
end

self:DesaturateMenu()

if (not all) then
self:Desagrupar (-1)
end
self:Desagrupar (-1)

self:CheckFor_EnabledTrashSuppression()

Expand Down Expand Up @@ -1752,18 +1748,27 @@ function _detalhes:ExportSkin()
["right"] = self.StatusBar.right.real_name or "NONE",
}
exported.StatusBarSaved.options = {
[exported.StatusBarSaved.left] = Details.CopyTable (self.StatusBar.left.options),
[exported.StatusBarSaved.center] = Details.CopyTable (self.StatusBar.center.options),
[exported.StatusBarSaved.right] = Details.CopyTable (self.StatusBar.right.options)
[exported.StatusBarSaved.left] = DetailsFramework.table.copy({}, self.StatusBar.left.options), --Details.CopyTable (self.StatusBar.left.options),
[exported.StatusBarSaved.center] = DetailsFramework.table.copy({}, self.StatusBar.center.options), --Details.CopyTable (self.StatusBar.center.options),
[exported.StatusBarSaved.right] = DetailsFramework.table.copy({}, self.StatusBar.right.options), --Details.CopyTable (self.StatusBar.right.options)
}

elseif (self.StatusBarSaved) then
exported.StatusBarSaved = Details.CopyTable (self.StatusBarSaved)

end
tinsert (_detalhes_global.exit_log, "StatusBarSaved:")

if (self.StatusBarSaved.optionsableable and type(self.StatusBarSaved.optionsableable) == "table") then
for k, v in pairs(self.StatusBarSaved.optionsableable) do
local value = v
if (type(value) == "table") then
value = "table"
end
tinsert (_detalhes_global.exit_log, k .. "|" .. type(v) .. "|" .. value)
end
end

exported.StatusBarSaved = DetailsFramework.table.copy({}, self.StatusBarSaved)
end
return exported

end

function _detalhes:ApplySavedSkin (style)
Expand Down
29 changes: 23 additions & 6 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5658,6 +5658,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
saver:RegisterEvent ("PLAYER_LOGOUT")
saver:SetScript ("OnEvent", function (...)

local currentStep = 0

--SAVINGDATA = true

if (not _detalhes.gump) then
--> failed to load the framework.
return
Expand All @@ -5666,8 +5670,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
local saver_error = function (errortext)
_detalhes_global = _detalhes_global or {}
_detalhes_global.exit_errors = _detalhes_global.exit_errors or {}

tinsert (_detalhes_global.exit_errors, 1, _detalhes.userversion .. " " .. errortext)
tinsert (_detalhes_global.exit_errors, 1, currentStep .. "|" .. date() .. "|" .. _detalhes.userversion .. "|" .. errortext .. "|" .. debugstack())
tremove (_detalhes_global.exit_errors, 6)
end

Expand All @@ -5680,29 +5683,36 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--> close info window
if (_detalhes.FechaJanelaInfo) then
tinsert (_detalhes_global.exit_log, "1 - Closing Janela Info.")
currentStep = "Fecha Janela Info"
xpcall (_detalhes.FechaJanelaInfo, saver_error)
end

--> do not save window pos
if (_detalhes.tabela_instancias) then
currentStep = "Dealing With Instances"
tinsert (_detalhes_global.exit_log, "2 - Clearing user place from instances.")
for id, instance in _detalhes:ListInstances() do
if (instance.baseframe) then
instance.baseframe:SetUserPlaced (false)
instance.baseframe:SetDontSavePosition (true)
if (id) then
tinsert (_detalhes_global.exit_log, " - " .. id .. " has baseFrame: " .. (instance.baseframe and "yes" or "no") .. ".")
if (instance.baseframe) then
instance.baseframe:SetUserPlaced (false)
instance.baseframe:SetDontSavePosition (true)
end
end
end
end

--> leave combat start save tables
if (_detalhes.in_combat and _detalhes.tabela_vigente) then
tinsert (_detalhes_global.exit_log, "3 - Leaving current combat.")
currentStep = "Leaving Current Combat"
xpcall (_detalhes.SairDoCombate, saver_error)
_detalhes.can_panic_mode = true
end

if (_detalhes.CheckSwitchOnLogon and _detalhes.tabela_instancias[1] and _detalhes.tabela_instancias and getmetatable (_detalhes.tabela_instancias[1])) then
tinsert (_detalhes_global.exit_log, "4 - Reversing switches.")
currentStep = "Check Switch on Logon"
xpcall (_detalhes.CheckSwitchOnLogon, saver_error)
end

Expand All @@ -5715,13 +5725,20 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1

--> save the config
tinsert (_detalhes_global.exit_log, "6 - Saving Config.")
currentStep = "Saving Config"
xpcall (_detalhes.SaveConfig, saver_error)

tinsert (_detalhes_global.exit_log, "7 - Saving Profiles.")
currentStep = "Saving Profile"
xpcall (_detalhes.SaveProfile, saver_error)

--> save the nicktag cache
tinsert (_detalhes_global.exit_log, "8 - Saving nicktag cache.")
_detalhes_database.nick_tag_cache = Details.CopyTable (_detalhes_database.nick_tag_cache)

local saveNicktabCache = function()
_detalhes_database.nick_tag_cache = Details.CopyTable(_detalhes_database.nick_tag_cache)
end
xpcall (saveNicktabCache, saver_error)
end)

--> end
Expand Down
1 change: 0 additions & 1 deletion functions/profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ function _detalhes:SaveProfile (saveas)
local profile = _detalhes:GetProfile (profile_name, true)

--> save default keys

for key, _ in pairs (_detalhes.default_profile) do

local current_value = _detalhes [key]
Expand Down
15 changes: 15 additions & 0 deletions functions/slash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ function SlashCmdList.DETAILS (msg, editbox)
elseif (command == "discord") then
_detalhes:CopyPaste ("https://discord.gg/AGSzAZX")


elseif (command == "exitlog") then
local newT = {}
for _, str in ipairs(_detalhes_global.exit_log) do
newT [#newT+1] = str
end

newT [#newT+1] = ""

for _, str in ipairs(_detalhes_global.exit_errors) do
newT [#newT+1] = str
end

Details:Dump(newT)


elseif (command == "debugwindow") then

Expand Down

0 comments on commit ade373f

Please sign in to comment.