@@ -901,8 +901,15 @@ local RetrieveWorldQuests = function(mapId)
901
901
quest .timeLeftString = timeLeftStr
902
902
elseif string.find (widgetInfo .text , " Complete" ) then
903
903
local quests , zone = string.match (widgetInfo .text , " Complete (%d+) |4world quest:world quests; in ?(.-) to unlock" )
904
- if string.find (zone ," the" ) then
905
- zone = string.match (zone , " ^the%s*(.+)" ) -- remove the word "the" if it's the first word in the string and lowercase.
904
+ if zone then
905
+ -- TODO: Why am I parsing the zone name rather than just using C_Map.GetMapInfo(mapId).name or "UNKNOWN" ??
906
+ if string.find (zone ," the" ) then
907
+ zone = string.match (zone , " ^the%s*(.+)" ) -- remove the word "the" if it's the first word in the string and lowercase.
908
+ end
909
+ else
910
+ quest .LockedWQ_QuestToComplete = string.match (widgetInfo .text , " Complete ?(.-) to unlock" )
911
+ -- print(string.format("[BWQ]: %s", quest.LockedWQ_QuestToComplete))
912
+ zone = C_Map .GetMapInfo (mapId ).name or " UNKNOWN"
906
913
end
907
914
quest .LockedWQ_questsRemaining = quests and tonumber (quests ) or 0
908
915
quest .LockedWQ_zone = zone or " "
@@ -931,9 +938,27 @@ local RetrieveWorldQuests = function(mapId)
931
938
end
932
939
933
940
if BWQ :C (" sortByTimeRemaining" ) then
934
- table.sort (BWQ .MAP_ZONES [BWQ .expansion ][mapId ].questsSort , function (a , b ) return BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [a ].timeLeft < BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [b ].timeLeft end )
941
+ table.sort (BWQ .MAP_ZONES [BWQ .expansion ][mapId ].questsSort , function (a , b )
942
+ local questA = BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [a ]
943
+ local questB = BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [b ]
944
+
945
+ -- If either quest is nil, put it at the end
946
+ if not questA or not questA .timeLeft then return false end
947
+ if not questB or not questB .timeLeft then return true end
948
+
949
+ return questA .timeLeft < questB .timeLeft
950
+ end )
935
951
else -- reward type
936
- table.sort (BWQ .MAP_ZONES [BWQ .expansion ][mapId ].questsSort , function (a , b ) return BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [a ].sort > BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [b ].sort end )
952
+ table.sort (BWQ .MAP_ZONES [BWQ .expansion ][mapId ].questsSort , function (a , b )
953
+ local questA = BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [a ]
954
+ local questB = BWQ .MAP_ZONES [BWQ .expansion ][mapId ].quests [b ]
955
+
956
+ -- If either quest is nil, put it at the end
957
+ if not questA or not questA .sort then return false end
958
+ if not questB or not questB .sort then return true end
959
+
960
+ return questA .sort > questB .sort
961
+ end )
937
962
end
938
963
939
964
BWQ .MAP_ZONES [BWQ .expansion ][mapId ].numQuests = numQuests
@@ -1264,12 +1289,20 @@ function BWQ:UpdateBlock()
1264
1289
local rewardText = " "
1265
1290
if button .quest .LockedWQ then
1266
1291
-- To find Atlas textures such as the "padlock" below. Use the /tav command (Texture Atlas Viewer addon).
1267
- rewardText = string.format (
1268
- " |cnWARNING_FONT_COLOR:|A:%s:14:14|a Complete %d more %s in %s|r" ,
1269
- " Garr_LockedBuilding" ,
1270
- button .quest .LockedWQ_questsRemaining and button .quest .LockedWQ_questsRemaining or " " ,
1271
- button .quest .LockedWQ_questsRemaining > 1 and " WQs" or " WQ" ,
1272
- button .quest .LockedWQ_zone and button .quest .LockedWQ_zone or " " )
1292
+ if button .quest .LockedWQ_QuestToComplete then
1293
+ rewardText = string.format (
1294
+ " |cnWARNING_FONT_COLOR:|A:%s:14:14|a Complete the quest '%s' in %s|r" ,
1295
+ " Garr_LockedBuilding" ,
1296
+ button .quest .LockedWQ_QuestToComplete ,
1297
+ button .quest .LockedWQ_zone and button .quest .LockedWQ_zone or " " )
1298
+ else
1299
+ rewardText = string.format (
1300
+ " |cnWARNING_FONT_COLOR:|A:%s:14:14|a Complete %d more %s in %s|r" ,
1301
+ " Garr_LockedBuilding" ,
1302
+ button .quest .LockedWQ_questsRemaining and button .quest .LockedWQ_questsRemaining or " " ,
1303
+ button .quest .LockedWQ_questsRemaining > 1 and " WQs" or " WQ" ,
1304
+ button .quest .LockedWQ_zone and button .quest .LockedWQ_zone or " " )
1305
+ end
1273
1306
button .reward :SetScript (" OnEvent" , function (self , event )
1274
1307
if event == " MODIFIER_STATE_CHANGED" then
1275
1308
if button .reward :IsMouseOver () and button .reward :IsShown () then
0 commit comments