Skip to content

Commit

Permalink
- Fix profile page error
Browse files Browse the repository at this point in the history
    - Fix db migration error
    - Handle evoker soar correct
  • Loading branch information
Nils89 committed Jan 18, 2024
1 parent d852cc5 commit a23f212
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 62 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.13.2
FIXES
- Fix profile page error
- Fix db migration error
- Handle evoker soar correct

6.13.1
FIXES
- Fix error a profile rename
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG_NEW_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.13.2
FIXES
- Fix profile page error
- Fix db migration error
- Handle evoker soar correct

6.13.1
FIXES
- Fix error a profile rename
Expand Down
6 changes: 6 additions & 0 deletions changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ AddChange(string addonVersion, table changeList)
}
]]

addChange("6.13.2",{
{ct.bug, [=[Fix profile page error]=]},
{ct.bug, [=[Fix db migration error]=]},
{ct.bug, [=[Handle evoker soar correct]=]},
})

addChange("6.13.1",{
{ct.bug, [=[Fix error a profile rename]=]},
})
Expand Down
31 changes: 19 additions & 12 deletions core/migration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,26 @@ local function DatabaseMigration(globalDb, privateDb)
end

local profileName = profileTbl.profilename
local skipProfile = false
if GW.globalSettings.profiles[profileName] then
local counter = 1
local counter = 0
repeat
counter = counter + 1
profileName = profileTbl.profilename .. counter
until not GW.globalSettings.profiles[profileName]

until not GW.globalSettings.profiles[profileName] or counter == 100
if GW.globalSettings.profiles[profileName] then
skipProfile = true
end
end
profileTbl.profilename = profileName
GW.globalSettings:SetProfile(profileName)
for settings, value in next, profileTbl do
if type(value) == "table" then
GW.settings[settings] = GW.copyTable(value)
else
GW.settings[settings] = value
if not skipProfile then
profileTbl.profilename = profileName
GW.globalSettings:SetProfile(profileName)
for settings, value in next, profileTbl do
if type(value) == "table" then
GW.settings[settings] = GW.copyTable(value)
else
GW.settings[settings] = value
end
end
end
end
Expand All @@ -86,12 +92,13 @@ local function DatabaseMigration(globalDb, privateDb)

if GW2UI_LAYOUTS then
if next(GW2UI_LAYOUTS) then
for k, profileTbl in next, GW2UI_LAYOUTS do
for _, profileTbl in next, GW2UI_LAYOUTS do
if profileTbl and profileTbl.name then
if not GW.globalSettings.global.layouts then GW.globalSettings.global.layouts = {} end

GW.globalSettings.global.layouts[profileTbl.name] = profileTbl
if GW.globalSettings.global.layouts[profileTbl.name].profileLayout and GW.globalSettings.global.layouts[profileTbl.name].profileLayout == true and profileTbl.profileId then
if GW.globalSettings.global.layouts[profileTbl.name].profileLayout and GW.globalSettings.global.layouts[profileTbl.name].profileLayout == true and profileTbl.profileId
and GW2UI_SETTINGS_PROFILES[profileTbl.profileId] and GW2UI_SETTINGS_PROFILES[profileTbl.profileId].profilename then
GW.globalSettings.global.layouts[profileTbl.name].profileName = GW2UI_SETTINGS_PROFILES[profileTbl.profileId].profilename
end
GW.globalSettings.global.layouts[profileTbl.name].id = nil
Expand Down
30 changes: 28 additions & 2 deletions libs/LibGW2/LibGW2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if not lib then return end
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
local CoordsStopTimer = nil
local CoordsTicker = nil
local activeDragonridingBuffs = {}

lib.callbacks = CallbackHandler:New(lib)

Expand Down Expand Up @@ -125,8 +126,10 @@ do
end
end

local function UpdateDragonRidingState(isLogin, useDelay)
if IsMounted() then
local function UpdateDragonRidingState(isLogin, useDelay, dragonridingBuffActive)
if dragonridingBuffActive then
lib.isDragonRiding = true
elseif IsMounted() then
local dragonridingSpellIds = C_MountJournal.GetCollectedDragonridingMounts()
lib.isDragonRiding = false
for _, mountId in ipairs(dragonridingSpellIds) do
Expand All @@ -149,6 +152,7 @@ do
end

local function HandleEvents(_, event, ...)
print(event)
if event == "CRITERIA_UPDATE" or event == "PLAYER_STOPPED_MOVING" or event == "PLAYER_CONTROL_GAINED" then
CoordsWatcherStop(event)
elseif event == "PLAYER_STARTED_MOVING" or event == "PLAYER_CONTROL_LOST" then
Expand All @@ -159,6 +163,27 @@ do
local isLogin, isReload = ...do
UpdateDragonRidingState(isLogin or isReload, true)
end
elseif event == "UNIT_AURA" then
local updateInfo = select(2, ...)
if updateInfo.addedAuras then
for _, data in next, updateInfo.addedAuras do
if data.spellId == 369536 then --soar from evoker
activeDragonridingBuffs[data.auraInstanceID] = data
UpdateDragonRidingState(nil, nil, true)
break
end
end
end

if updateInfo.removedAuraInstanceIDs then
for _, auraInstanceID in next, updateInfo.removedAuraInstanceIDs do
if activeDragonridingBuffs[auraInstanceID] then
activeDragonridingBuffs[auraInstanceID] = nil
UpdateDragonRidingState(nil, nil, false)
break
end
end
end
else
MapInfoUpdateMapId()
lib.locationData.instanceMapID = select(8, GetInstanceInfo())
Expand All @@ -179,5 +204,6 @@ do
frame:RegisterEvent("PLAYER_STOPPED_MOVING")
frame:RegisterEvent("PLAYER_CONTROL_LOST")
frame:RegisterEvent("PLAYER_CONTROL_GAINED")
frame:RegisterUnitEvent("UNIT_AURA", "player")
frame:SetScript("OnEvent", HandleEvents)
end
16 changes: 0 additions & 16 deletions settings/defaults2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,6 @@ GW.globalDefault = {
focus_FRAME_INVERT= false,
focus_FRAME_ALT_BACKGROUND= false,

multibarleft_pos= {
point= "RIGHT",
relativePoint= "RIGHT",
xOfs= -300,
yOfs= 0,
hasMoved= false,
},

multibarright_pos= {
point= "RIGHT",
relativePoint= "RIGHT",
xOfs= -260,
yOfs= 0,
hasMoved= false,
},

target_pos= {
point= "TOP",
relativePoint= "TOP",
Expand Down
51 changes: 19 additions & 32 deletions settings/panel_profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,27 @@ local ProfileWin = nil
local function loadProfiles(profilewin)
local USED_PROFILE_HEIGHT
local offset = HybridScrollFrame_GetOffset(profilewin)
local profiles = GW.globalSettings:GetProfiles()
local profiles, numProfiles = GW.globalSettings:GetProfiles()
local currentProfile = GW.globalSettings:GetCurrentProfile()
local validProfiles = {}
local validProfileIdx = 1

-- sort out nil tables and sort table by id
for k, name in pairs(profiles) do
if profiles[k] and name ~= "Default" then
validProfiles[validProfileIdx] = GW.globalSettings.profiles[name]
validProfiles[validProfileIdx].profileName = name
validProfileIdx = validProfileIdx + 1
end
end

table.sort(
validProfiles,
profiles,
function(a, b)
return a.profileName < b.profileName
return a < b
end
)

for i = 1, #profilewin.buttons do
local slot = profilewin.buttons[i]

local idx = i + offset
if idx > #validProfiles then
if idx > numProfiles then
-- empty row (blank starter row, final row, and any empty entries)
slot.item:Hide()
slot.item.profileName = nil
else
slot.item.profileName = validProfiles[idx].profileName
slot.item.name:SetText(validProfiles[idx].profileName)
slot.item.profileName = profiles[idx]
slot.item.name:SetText(profiles[idx])

slot.item.hasOptions = true
slot.item.canDelete = true
Expand All @@ -53,36 +42,34 @@ local function loadProfiles(profilewin)
slot.item.canActivate = true
slot.item.activeProfile:Hide()

if currentProfile == validProfiles[idx].profileName then
if currentProfile == profiles[idx] then
slot.item.canActivate = false
slot.item.canDelete = false
slot.item.activeProfile:Show()
end

validProfiles[idx].profileCreatedDate = validProfiles[idx].profileCreatedDate or UNKNOWN
validProfiles[idx].profileCreatedCharacter = validProfiles[idx].profileCreatedCharacter or UNKNOWN
validProfiles[idx].profileLastUpdated = validProfiles[idx].profileLastUpdated or UNKNOWN
validProfiles[idx].profileIcon = validProfiles[idx].profileIcon or ICONS[math.random(1, #ICONS)]
GW.globalSettings.profiles[profiles[idx]].profileCreatedDate = GW.globalSettings.profiles[profiles[idx]].profileCreatedDate or UNKNOWN
GW.globalSettings.profiles[profiles[idx]].profileCreatedCharacter = GW.globalSettings.profiles[profiles[idx]].profileCreatedCharacter or UNKNOWN
GW.globalSettings.profiles[profiles[idx]].profileLastUpdated = GW.globalSettings.profiles[profiles[idx]].profileLastUpdated or UNKNOWN
GW.globalSettings.profiles[profiles[idx]].profileIcon = GW.globalSettings.profiles[profiles[idx]].profileIcon or ICONS[math.random(1, #ICONS)]

if(type(validProfiles[idx].profileIcon) == "number") then
slot.item.activateButton.icon:SetTexture(validProfiles[idx].profileIcon)
if(type(GW.globalSettings.profiles[profiles[idx]].profileIcon) == "number") then
slot.item.activateButton.icon:SetTexture(GW.globalSettings.profiles[profiles[idx]].profileIcon)
else
slot.item.activateButton.icon:SetTexture("INTERFACE\\ICONS\\" .. validProfiles[idx].profileIcon)
slot.item.activateButton.icon:SetTexture("INTERFACE\\ICONS\\" .. GW.globalSettings.profiles[profiles[idx]].profileIcon)
end

local description =
L["Created: "] ..
validProfiles[idx].profileCreatedDate .. "\n" ..
slot.item.desc:SetText(L["Created: "] ..
GW.globalSettings.profiles[profiles[idx]].profileCreatedDate .. "\n" ..
L["Created by: "] ..
validProfiles[idx].profileCreatedCharacter .. "\n" .. L["Last updated: "] .. validProfiles[idx].profileLastUpdated

slot.item.desc:SetText(description)
GW.globalSettings.profiles[profiles[idx]].profileCreatedCharacter .. "\n" .. L["Last updated: "] .. GW.globalSettings.profiles[profiles[idx]].profileLastUpdated
)

slot.item:Show()
end
end

USED_PROFILE_HEIGHT = profilewin.buttons[1]:GetHeight() * #validProfiles
USED_PROFILE_HEIGHT = profilewin.buttons[1]:GetHeight() * numProfiles
HybridScrollFrame_Update(profilewin, USED_PROFILE_HEIGHT, 433)
end

Expand Down

0 comments on commit a23f212

Please sign in to comment.