@@ -14,7 +14,7 @@ local defaultPopupBlacklist = { -- If a popup dialog contains one of these strin
1414 AREA_SPIRIT_HEAL = true , -- Prevents cancelling the resurrection
1515 TOO_MANY_LUA_ERRORS = true ,
1616 END_BOUND_TRADEABLE = true , EQUIP_BIND_TRADEABLE = true , -- Probably quite reasonable to make the user click on this one
17- ADDON_ACTION_FORBIDDEN = true , -- Don't disable and reload UI on errors
17+ ADDON_ACTION_FORBIDDEN = true , -- Don't disable and reload UI on errors
1818 CONFIRM_LEAVE_RESTRICTED_CHALLENGE_MODE = true ,
1919 WARN_LEAVE_RESTRICTED_CHALLENGE_MODE = true ,
2020}
@@ -69,7 +69,9 @@ function DialogKey:OnInitialize()
6969 self :InitMainProxyFrame ()
7070
7171 self :SecureHook (" QuestInfoItem_OnClick" , " SelectItemReward" )
72- self :SecureHook (GossipFrame , " Update" , " OnGossipFrameUpdate" )
72+ GossipFrame .GreetingPanel .ScrollBox :RegisterCallback (" OnAcquiredFrame" , self .OnGossipFrameAcquired , self )
73+ GossipFrame .GreetingPanel .ScrollBox :RegisterCallback (" OnReleasedFrame" , self .OnGossipFrameReleased , self )
74+ GossipFrame .GreetingPanel .ScrollBox :RegisterCallback (ScrollBoxListMixin .Event .OnDataProviderReassigned , self .OnGossipDataProviderChange , self )
7375
7476 ns :RegisterOptions ()
7577
@@ -216,45 +218,93 @@ function DialogKey:OnSpecFrameHide()
216218 self .specButtons = {}
217219end
218220
219- --- @param GossipFrame GossipFrame
220- function DialogKey :OnGossipFrameUpdate (GossipFrame )
221+ function DialogKey :OnGossipDataProviderChange ()
222+ self .frames = {}
223+ self .orderedGossipFrames = {}
221224 local scrollbox = GossipFrame .GreetingPanel .ScrollBox
222-
223- self .frames = {};
224225 local n = 1
225- for _ , frame in scrollbox :EnumerateFrames () do
226- local data = frame .GetElementData and frame :GetElementData ()
226+ for _ , elementData in scrollbox :GetDataProvider ():Enumerate () do
227227 local tag
228- if GOSSIP_BUTTON_TYPE_OPTION == data .buttonType then
228+ if GOSSIP_BUTTON_TYPE_OPTION == elementData .buttonType then
229229 tag = " name"
230- elseif GOSSIP_BUTTON_TYPE_AVAILABLE_QUEST == data .buttonType then
230+ elseif GOSSIP_BUTTON_TYPE_AVAILABLE_QUEST == elementData .buttonType then
231231 tag = " title"
232- elseif GOSSIP_BUTTON_TYPE_ACTIVE_QUEST == data .buttonType and (data .info .isComplete or not self .db .ignoreInProgressQuests ) then
232+ elseif GOSSIP_BUTTON_TYPE_ACTIVE_QUEST == elementData .buttonType and (elementData .info .isComplete or not self .db .ignoreInProgressQuests ) then
233233 tag = " title"
234234 end
235235 if tag then
236- if self .db .numKeysForGossip then
237- local oldText = data .info [tag ]
238- if data .info .flags and FlagsUtil .IsSet (data .info .flags , Enum .GossipOptionRecFlags .QuestLabelPrepend ) then
236+ self .orderedGossipFrames [elementData ] = n
237+ if n <= 10 then
238+ local info = elementData .info
239+ local oldText = info [tag ]
240+ if info .flags and FlagsUtil .IsSet (info .flags , Enum .GossipOptionRecFlags .QuestLabelPrepend ) then
239241 oldText = GOSSIP_QUEST_OPTION_PREPEND :format (oldText );
240242 end
241- local newText = (n % 10 ) .. " . " .. (oldText :match (" ^%d. (.+)$" ) or oldText )
242- if self .db .riskyNumKeysForGossip then
243- data .info [tag ] = newText -- this may not be safe, but it looks like the only somewhat reliable way to ensure the scrollbar is enabled when needed
243+ if info .isIgnored then
244+ oldText = IGNORED_QUEST_DISPLAY :format (oldText );
245+ elseif info .isTrivial then
246+ oldText = TRIVIAL_QUEST_DISPLAY :format (oldText );
244247 end
245- frame :SetText (newText )
246- frame :SetHeight (frame :GetFontString ():GetHeight () + 2 )
248+ local newText = (n % 10 ) .. " . " .. (oldText :match (" ^%d. (.+)$" ) or oldText )
249+
250+ elementData .info .DialogKeyNumy_Text = newText
247251 end
248- self . frames [ n ] = frame
252+
249253 n = n + 1
250254 end
251- if n > 10 then break end
255+
256+ local calculatorFrame
257+ if elementData .titleOptionButton then
258+ calculatorFrame = elementData .titleOptionButton
259+ elseif elementData .availableQuestButton then
260+ calculatorFrame = elementData .availableQuestButton
261+ elseif elementData .activeQuestButton then
262+ calculatorFrame = elementData .activeQuestButton
263+ end
264+ if calculatorFrame and not calculatorFrame .DialogKeyNumy_Hooked then
265+ hooksecurefunc (calculatorFrame , ' Setup' , function (_ , info )
266+ if info .DialogKeyNumy_Text then
267+ calculatorFrame :SetTextAndResize (info .DialogKeyNumy_Text )
268+ end
269+ end )
270+ calculatorFrame .DialogKeyNumy_Hooked = true
271+ end
252272 end
253- --- @type ScrollBoxListLinearViewMixin
254- local view = scrollbox :GetView ()
255- view :Layout ()
256- if self .db .riskyNumKeysForGossip then
257- scrollbox :ScrollIncrease () -- force the scrollbar to show if needed
273+ end
274+
275+ --- @param frame GossipTitleButtonTemplate
276+ --- @param elementData table
277+ function DialogKey :OnGossipFrameAcquired (frame , elementData )
278+ if not self .db .numKeysForGossip then return ; end
279+
280+ local n = self .orderedGossipFrames [elementData ]
281+ local newText = elementData .info and elementData .info .DialogKeyNumy_Text
282+
283+ if not n or n > 10 or not newText then return end
284+
285+ self .frames [n ] = frame
286+ frame :SetTextAndResize (newText )
287+
288+ if not frame .DialogKeyNumy_Text then
289+ --- @param f GossipTitleButtonTemplate
290+ local function onSetText (f , text )
291+ local savedText = f .DialogKeyNumy_Text
292+ if text == savedText or not savedText or savedText == " " then return end
293+
294+ f :SetTextAndResize (savedText )
295+ end
296+ hooksecurefunc (frame , ' SetText' , onSetText )
297+ hooksecurefunc (frame , ' SetFormattedText' , function (f , format , ...)
298+ local text = format :format (... )
299+ onSetText (f , text )
300+ end )
301+ end
302+ frame .DialogKeyNumy_Text = newText
303+ end
304+
305+ function DialogKey :OnGossipFrameReleased (frame )
306+ if frame .DialogKeyNumy_Text then
307+ frame .DialogKeyNumy_Text = " "
258308 end
259309end
260310
@@ -455,7 +505,10 @@ function DialogKey:HandleKey(key)
455505 if not InCombatLockdown () then self .frame :SetPropagateKeyboardInput (true ) end
456506 local doAction = (key == self .db .keys [1 ] or key == self .db .keys [2 ])
457507 local keynum = doAction and 1 or tonumber (key )
458- if key == " 0" then
508+ if key :match (" ^NUMPAD" ) then
509+ keynum = tonumber ((key :gsub (" NUMPAD" , " " )))
510+ end
511+ if key == " 0" or key == " NUMPAD0" then
459512 keynum = 10
460513 end
461514 if not doAction and not keynum then return end
0 commit comments