Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Added] Sort by tracked achievements #37

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions HandyNotes_Achievements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,67 @@ function HNA:HandyNotesCoordsNear(c, coord)
end


function SortByTrackedAchievement(nodes)
function getTrackedAchievements()
id1, id2, id3, id4, id5, id6, id7, id8, id9, id10 = GetTrackedAchievements()

local result = {}

function add(id, result)
if id ~= nil then
result[tonumber(id)] = tonumber(id)
end
end

add(id1, result)
add(id2, result)
add(id3, result)
add(id4, result)
add(id5, result)
add(id6, result)
add(id7, result)
add(id8, result)
add(id9, result)
add(id10, result)

return result
end
local trackedAchievements = getTrackedAchievements()
local sortedNodes = {}
local notTrackedNodes = {}

for nodeIndex = 1, #nodes, 2 do
local row = nodes[nodeIndex + 1]
local achievementID = row[2]

if trackedAchievements[achievementID] then
table.insert(sortedNodes, nodes[nodeIndex])
table.insert(sortedNodes, nodes[nodeIndex + 1])
else
table.insert(notTrackedNodes, nodes[nodeIndex])
table.insert(notTrackedNodes, nodes[nodeIndex + 1])
end
end

for nodeIndex = 1, #notTrackedNodes, 2 do
table.insert(sortedNodes, notTrackedNodes[nodeIndex])
table.insert(sortedNodes, notTrackedNodes[nodeIndex + 1])
end

return sortedNodes
end

function HNA:OnEnter(mapFile, nearCoord)
tooltip = QTip:Acquire(ADDON_NAME, 2, "LEFT", "RIGHT")
local firstRow = true
local previousAchievementID

local nodes = activeNodes[mapFile]

if HNA.db.profile.sort_by_tracked == true then
nodes = SortByTrackedAchievement(nodes)
end

for nodeIndex = 1, #nodes, 2 do
local coord, row = nodes[nodeIndex], nodes[nodeIndex + 1]
if HNA:HandyNotesCoordsNear(coord, nearCoord) and HNA:Valid(row) then
Expand Down Expand Up @@ -173,6 +228,7 @@ function HNA:OnInitialize()
season_warning = 14,
clean_continents = true,
completed = false,
sort_by_tracked = false,
}
}

Expand Down Expand Up @@ -257,6 +313,14 @@ function HNA:PLAYER_ENTERING_WORLD(event)
arg = "season_warning",
order = 6,
},
sort_by_tracked = {
type = "toggle",
name = L["Sort by tracked"],
desc = L["Sort achievements by tracked"],
width = "full",
arg = "sort_by_tracked",
order = 7
}
},
}
HandyNotes:RegisterPluginDB(ADDON_NAME, self, options)
Expand Down
2 changes: 2 additions & 0 deletions Locale/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Just Mine"] = "Nur für diesen Charakter"
L["Show more map pins by including achievements completed only by other characters."] = "Auch Kartemsymbole von bereits anderen Charakteren abgeschlossene Errungenschaften anzeigen."
L["Season Warning"] = "Sesonale Errungenschafts Erinnerung"
L["Days in advance to show pins for seasonal holiday achievements."] = "Wie viele Tage im Vorraus sollen mögliche Sesonale Errungenschaften angezeigt werden?"
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Just Mine"] = true
L["Show more map pins by including achievements completed only by other characters."] = true
L["Season Warning"] = true
L["Days in advance to show pins for seasonal holiday achievements."] = true
L["Sort by tracked"] = true
L["Sort achievements by tracked"] = true
2 changes: 2 additions & 0 deletions Locale/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "Opacidad de iconos"
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/esMX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "Opacidad de iconos"
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "Transparence des icônes"
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ if not L then return end
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "아이콘 투명도"
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/ptBR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ if not L then return end
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "Прозрачность значка"
-- L["Show more map pins by including achievements completed only by other characters."] = "Показать больше меток на карте, включая достижения, выполненные только другими персонажами."
-- L["Season Warning"] = "Сезонное Предупреждение"
-- L["Days in advance to show pins for seasonal holiday achievements."] = "За сколько дней заранее показывать метки достижений сезонных праздников."
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Icon Alpha"] = "图标透明度"
-- L["Show more map pins by including achievements completed only by other characters."] = ""
-- L["Season Warning"] = ""
-- L["Days in advance to show pins for seasonal holiday achievements."] = ""
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""
2 changes: 2 additions & 0 deletions Locale/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ L["Just Mine"] = "只有這個角色的成就"
L["Show more map pins by including achievements completed only by other characters."] = "顯示較多的成就內容,包含其他角色已經完成的共通成就。"
L["Season Warning"] = "節慶通知天數"
L["Days in advance to show pins for seasonal holiday achievements."] = "要顯示未來多少天內的季節性節慶成就。"
-- L["Sort by tracked"] = ""
-- L["Sort achievements by tracked"] = ""