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

149 lines
4.8 KiB

4 years ago
--[[this file save the data when player leave the game]]
local _detalhes = _G._detalhes
function _detalhes:WipeConfig()
3 years ago
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local wipeButton = CreateFrame("button", "DetailsResetConfigButton", UIParent, "BackdropTemplate")
wipeButton:SetSize(270, 40)
wipeButton:SetScript("OnClick", function() _detalhes.wipe_full_config = true; ReloadUI(); end)
wipeButton:SetPoint("center", UIParent, "center", 0, 0)
3 years ago
tinsert(UISpecialFrames, "DetailsResetConfigButton")
DetailsFramework:ApplyStandardBackdrop(wipeButton)
local label = DetailsFramework:CreateLabel(wipeButton, Loc ["STRING_SLASH_WIPECONFIG_CONFIRM"])
label:SetPoint("center", 0, 0)
wipeButton.close_button = CreateFrame("Button", nil, wipeButton, "UIPanelCloseButton")
wipeButton.close_button:SetWidth(16)
wipeButton.close_button:SetHeight(16)
wipeButton.close_button:SetPoint("TOPRIGHT", wipeButton, "TOPRIGHT", -1, -1)
wipeButton.close_button:SetText("X")
wipeButton.close_button:SetFrameLevel(wipeButton:GetFrameLevel()+5)
4 years ago
end
local is_exception = {
["nick_tag_cache"] = true
}
function _detalhes:SaveLocalInstanceConfig()
for index, instance in _detalhes:ListInstances() do
3 years ago
--check for the max size toggle, don't save it
4 years ago
if (instance.is_in_max_size) then
instance.is_in_max_size = false
3 years ago
instance:SetSize(instance.original_width, instance.original_height)
4 years ago
end
3 years ago
--save local instance data
4 years ago
local a1, a2 = instance:GetDisplay()
local t = {
3 years ago
pos = Details.CopyTable(instance:GetPosition()),
4 years ago
is_open = instance:IsEnabled(),
attribute = a1 or 1,
sub_attribute = a2 or 1,
modo = instance:GetMode() or 2,
mode = instance:GetMode() or 2,
segment = instance:GetSegment() or 0,
3 years ago
snap = Details.CopyTable(instance.snap),
4 years ago
horizontalSnap = instance.horizontalSnap,
verticalSnap = instance.verticalSnap,
sub_atributo_last = instance.sub_atributo_last or {1, 1, 1, 1, 1},
isLocked = instance.isLocked,
last_raid_plugin = instance.last_raid_plugin
}
if (t.isLocked == nil) then
t.isLocked = false
end
if (_detalhes.profile_save_pos) then
local cprofile = _detalhes:GetProfile()
local skin = cprofile.instances [instance:GetId()]
if (skin) then
3 years ago
t.pos = Details.CopyTable(skin.__pos)
4 years ago
t.horizontalSnap = skin.__snapH
t.verticalSnap = skin.__snapV
3 years ago
t.snap = Details.CopyTable(skin.__snap)
4 years ago
t.is_open = skin.__was_opened
t.isLocked = skin.__locked
end
end
_detalhes.local_instances_config [index] = t
end
end
function _detalhes:SaveConfig()
3 years ago
--save instance configs localy
4 years ago
_detalhes:SaveLocalInstanceConfig()
3 years ago
--cleanup
4 years ago
_detalhes:PrepareTablesForSave()
_detalhes_database.tabela_instancias = {} --_detalhes.tabela_instancias --[[instances now saves only inside the profile --]]
_detalhes_database.tabela_historico = _detalhes.tabela_historico
if (not _detalhes.overall_clear_logout) then
_detalhes_database.tabela_overall = _detalhes.tabela_overall
end
local name, ttype, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()
if (ttype == "party" or ttype == "raid") then
3 years ago
--salvar container de pet
4 years ago
_detalhes_database.tabela_pets = _detalhes.tabela_pets.pets
end
3 years ago
xpcall(_detalhes.TimeDataCleanUpTemporary, _detalhes.saver_error_func)
4 years ago
3 years ago
--buffs
xpcall(_detalhes.Buffs.SaveBuffs, _detalhes.saver_error_func)
4 years ago
3 years ago
--date
4 years ago
_detalhes.last_day = date ("%d")
3 years ago
--salva o container do personagem
for key, value in pairs(_detalhes.default_player_data) do
4 years ago
if (not is_exception [key]) then
_detalhes_database [key] = _detalhes [key]
end
end
3 years ago
--salva o container das globais
for key, value in pairs(_detalhes.default_global_data) do
4 years ago
if (key ~= "__profiles") then
_detalhes_global [key] = _detalhes [key]
end
end
3 years ago
--solo e raid mode
4 years ago
if (_detalhes.SoloTables.Mode) then
_detalhes_database.SoloTablesSaved = {}
_detalhes_database.SoloTablesSaved.Mode = _detalhes.SoloTables.Mode
if (_detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode]) then
_detalhes_database.SoloTablesSaved.LastSelected = _detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode].real_name
end
end
_detalhes_database.RaidTablesSaved = nil
3 years ago
--salva switch tables
4 years ago
_detalhes_global.switchSaved.slots = _detalhes.switch.slots
_detalhes_global.switchSaved.table = _detalhes.switch.table
3 years ago
--last boss
4 years ago
_detalhes_database.last_encounter = _detalhes.last_encounter
3 years ago
--last versions
_detalhes_database.last_realversion = _detalhes.realversion --core number
_detalhes_database.last_version = _detalhes.userversion --version
4 years ago
_detalhes_global.got_first_run = true
end