From ff53ee5c5ff046d49d68851ae9fa3b5be8c149f4 Mon Sep 17 00:00:00 2001 From: Peter Bjerg Lidegaard Date: Fri, 23 Aug 2024 23:06:03 +0200 Subject: [PATCH 1/3] added gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file From 0615b757809caaacca4ac4908e34ee6e3dab7601 Mon Sep 17 00:00:00 2001 From: Peter Bjerg Lidegaard Date: Fri, 23 Aug 2024 23:23:32 +0200 Subject: [PATCH 2/3] Players sorted --- Bagnon_Forever/database/database.lua | 23 +++++++++++++++++++++-- Bagnon_Forever/database/ui.lua | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Bagnon_Forever/database/database.lua b/Bagnon_Forever/database/database.lua index 7f6daa3..9bd7fb8 100644 --- a/Bagnon_Forever/database/database.lua +++ b/Bagnon_Forever/database/database.lua @@ -30,10 +30,29 @@ local currentRealm = GetRealmName(); --what currentRealm we're on for playerName, data in BagnonDB.GetPlayers() --]] -function BagnonDB.GetPlayers() - return pairs(BagnonForeverData[currentRealm]) +function BagnonDB.GetPlayers(sort) + if not sort then + -- If sort is false, just return pairs + return pairs(BagnonForeverData[currentRealm]) + end + + -- If sort is true, create a sorted list of keys + local sortedNames = {} + for name in pairs(BagnonForeverData[currentRealm]) do + table.insert(sortedNames, name) + end + table.sort(sortedNames) + + -- Return a custom iterator function + local i = 0 + return function() + i = i + 1 + local playerName = sortedNames[i] + return playerName, BagnonForeverData[currentRealm][playerName] + end end + --[[ BagnonDB.GetBags(player) returns: diff --git a/Bagnon_Forever/database/ui.lua b/Bagnon_Forever/database/ui.lua index 0fc0460..9a86cc8 100644 --- a/Bagnon_Forever/database/ui.lua +++ b/Bagnon_Forever/database/ui.lua @@ -53,7 +53,7 @@ function BagnonDBUI_ShowCharacterList(parentFrame) --update button info local index = 0 - for player in BagnonDB.GetPlayers() do + for player in BagnonDB.GetPlayers(true) do index = index + 1 local button = getglobal("BagnonDBUICharacterList" .. index) or CreatePlayerButton(index, BagnonDBUICharacterList) From a7cb781fa94cffbd39b805a5543d6a233a1b0822 Mon Sep 17 00:00:00 2001 From: Peter Bjerg Lidegaard Date: Fri, 23 Aug 2024 23:26:47 +0200 Subject: [PATCH 3/3] removed ignore to make a clean PR --- .gitignore | 1 - Bagnon_Forever/database/database.lua | 1 - 2 files changed, 2 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 62c8935..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea/ \ No newline at end of file diff --git a/Bagnon_Forever/database/database.lua b/Bagnon_Forever/database/database.lua index 9bd7fb8..4047942 100644 --- a/Bagnon_Forever/database/database.lua +++ b/Bagnon_Forever/database/database.lua @@ -52,7 +52,6 @@ function BagnonDB.GetPlayers(sort) end end - --[[ BagnonDB.GetBags(player) returns: