@@ -2737,217 +2737,254 @@ local function createPopupCloseButton(parent)
27372737 return close
27382738end
27392739
2740+ local getUniversalPromptAceGUI
2741+
27402742local function ensureGameObjectPopupFrame ()
27412743 if MultiBot .GameObjPopup then
27422744 return MultiBot .GameObjPopup
27432745 end
27442746
2745- local popup = CreateFrame (" Frame" , " MB_GameObjPopup" , UIParent )
2746- popup :SetSize (340 , 340 )
2747- popup :SetPoint (" CENTER" )
2748- applyDialogBackdrop (popup )
2749- popup :EnableMouse (true )
2750- popup :SetMovable (true )
2751- popup :RegisterForDrag (" LeftButton" )
2752- popup :SetScript (" OnDragStart" , popup .StartMoving )
2753- popup :SetScript (" OnDragStop" , popup .StopMovingOrSizing )
2754-
2755- createPopupCloseButton (popup )
2756-
2757- local title = popup :CreateFontString (nil , " ARTWORK" , " GameFontNormalLarge" )
2758- title :SetPoint (" TOP" , 0 , - 10 )
2759- title :SetText (MultiBot .L (" tips.quests.gobsfound" ))
2747+ local aceGUI = getUniversalPromptAceGUI and getUniversalPromptAceGUI ()
2748+ if not aceGUI then
2749+ UIErrorsFrame :AddMessage (" AceGUI-3.0 is required for MB_GameObjPopup" , 1 , 0.2 , 0.2 , 1 )
2750+ return nil
2751+ end
27602752
2761- local scrollFrame = CreateFrame (" ScrollFrame" , " MB_GameObjScroll" , popup , " UIPanelScrollFrameTemplate" )
2762- scrollFrame :SetPoint (" TOPLEFT" , 14 , - 38 )
2763- scrollFrame :SetPoint (" BOTTOMRIGHT" , - 30 , 14 )
2753+ local window = aceGUI :Create (" Window" )
2754+ if not window then
2755+ return nil
2756+ end
27642757
2765- local content = CreateFrame (" Frame" , nil , scrollFrame )
2766- content :SetWidth (1 )
2767- scrollFrame :SetScrollChild (content )
2758+ window :SetTitle (MultiBot .L (" tips.quests.gobsfound" ))
2759+ window :SetWidth (420 )
2760+ window :SetHeight (380 )
2761+ window :EnableResize (false )
2762+ window :SetLayout (" Flow" )
2763+ window .frame :SetFrameStrata (" DIALOG" )
27682764
2769- popup .content = content
2770- popup .scrollFrame = scrollFrame
2765+ local scroll = aceGUI :Create (" ScrollFrame" )
2766+ scroll :SetFullWidth (true )
2767+ scroll :SetHeight (300 )
2768+ scroll :SetLayout (" List" )
2769+ window :AddChild (scroll )
27712770
2772- local copyBtn = CreateFrame (" Button" , nil , popup , " UIPanelButtonTemplate" )
2773- copyBtn :SetSize (120 , 20 )
2774- copyBtn :SetPoint (" BOTTOMRIGHT" , - 40 , 12 )
2771+ local copyBtn = aceGUI :Create (" Button" )
27752772 copyBtn :SetText (MultiBot .L (" tips.quests.gobselectall" ))
2776- copyBtn :SetScript (" OnClick" , function ()
2773+ copyBtn :SetWidth (150 )
2774+ copyBtn :SetCallback (" OnClick" , function ()
27772775 MultiBot .ShowGameObjectCopyBox ()
27782776 end )
2779- popup . copyBtn = copyBtn
2777+ window : AddChild ( copyBtn )
27802778
2781- MultiBot .GameObjPopup = popup
2782- return popup
2779+ MultiBot .GameObjPopup = {
2780+ window = window ,
2781+ scroll = scroll ,
2782+ copyBtn = copyBtn ,
2783+ }
2784+
2785+ return MultiBot .GameObjPopup
27832786end
27842787
27852788local function ensureGameObjectCopyBoxFrame ()
27862789 if MultiBot .GameObjCopyBox then
27872790 return MultiBot .GameObjCopyBox
27882791 end
2789- local box = CreateFrame (" Frame" , " MB_GameObjCopyBox" , UIParent )
2790- box :SetSize (380 , 240 )
2791- box :SetPoint (" CENTER" )
2792- applyDialogBackdrop (box )
27932792
2794- local close = createPopupCloseButton (box )
2795- close :SetScript (" OnClick" , function ()
2796- box :Hide ()
2797- end )
2793+ local aceGUI = getUniversalPromptAceGUI and getUniversalPromptAceGUI ()
2794+ if not aceGUI then
2795+ UIErrorsFrame :AddMessage (" AceGUI-3.0 is required for MB_GameObjCopyBox" , 1 , 0.2 , 0.2 , 1 )
2796+ return nil
2797+ end
27982798
2799- local label = box :CreateFontString (nil , " ARTWORK" , " GameFontNormalLarge" )
2800- label :SetPoint (" TOP" , 0 , - 10 )
2801- label :SetText (MultiBot .L (" tips.quests.gobctrlctocopy" ))
2802-
2803- local edit = CreateFrame (" EditBox" , nil , box )
2804- edit :SetFontObject (" ChatFontNormal" )
2805- edit :SetWidth (340 )
2806- edit :SetHeight (180 )
2807- edit :SetMultiLine (true )
2808- edit :SetAutoFocus (true )
2809- edit :EnableMouse (true )
2810- edit :SetPoint (" TOP" , 0 , - 40 )
2811- edit :SetScript (" OnEscapePressed" , function ()
2812- box :Hide ()
2813- end )
2814- edit :SetScript (" OnEditFocusGained" , function (self )
2815- self :HighlightText ()
2816- end )
2799+ local window = aceGUI :Create (" Window" )
2800+ if not window then
2801+ return nil
2802+ end
2803+
2804+ window :SetTitle (MultiBot .L (" tips.quests.gobctrlctocopy" ))
2805+ window :SetWidth (420 )
2806+ window :SetHeight (300 )
2807+ window :EnableResize (false )
2808+ window :SetLayout (" Fill" )
2809+ window .frame :SetFrameStrata (" DIALOG" )
28172810
2818- box .edit = edit
2819- MultiBot .GameObjCopyBox = box
2820- return box
2811+ local editor = aceGUI :Create (" MultiLineEditBox" )
2812+ editor :SetLabel (" " )
2813+ editor :SetNumLines (14 )
2814+ editor :DisableButton (true )
2815+ window :AddChild (editor )
2816+
2817+ MultiBot .GameObjCopyBox = {
2818+ window = window ,
2819+ editor = editor ,
2820+ }
2821+
2822+ return MultiBot .GameObjCopyBox
28212823end
28222824
28232825function MultiBot .ShowGameObjectPopup ()
28242826
28252827 local popup = ensureGameObjectPopupFrame ()
2826- if popup :IsShown () then
2827- popup :Hide ()
2828+ if not popup then
2829+ return
2830+ end
2831+
2832+ if popup .window :IsShown () then
2833+ popup .window :Hide ()
28282834 end
28292835
28302836 -- Clear previous popup lines.
2831- local content = popup .content
2832- clearFrameChildren (content )
2837+ popup .scroll :ReleaseChildren ()
28332838
28342839 -- Render captured lines grouped by bot
2835- local y = - 4
2840+ local aceGUI = getUniversalPromptAceGUI and getUniversalPromptAceGUI ()
2841+ if not aceGUI then
2842+ UIErrorsFrame :AddMessage (" AceGUI-3.0 is required for MB_GameObjPopup" , 1 , 0.2 , 0.2 , 1 )
2843+ return
2844+ end
2845+
28362846 local bots = collectSortedGameObjectBots ()
28372847
28382848 for _ , bot in ipairs (bots ) do
28392849 local lines = getGameObjectEntries (bot ) or {}
2840- -- Bot title
2841- local botLine = content :CreateFontString (nil , " ARTWORK" , " GameFontHighlightSmall" )
2842- botLine :SetPoint (" TOPLEFT" , 8 , y )
2850+ local botLine = aceGUI :Create (" Label" )
2851+ botLine :SetFullWidth (true )
28432852 botLine :SetText (" Bot: |cff80ff80" .. bot .. " |r" )
2844- y = y - 18
2853+ popup . scroll : AddChild ( botLine )
28452854
2846- -- Grouped section output: headers are highlighted, entries are indented.
28472855 for _ , txt in ipairs (lines ) do
2848- local line = content :CreateFontString (nil , " ARTWORK" , " GameFontNormalSmall" )
2856+ local line = aceGUI :Create (" Label" )
2857+ line :SetFullWidth (true )
28492858 local isSectionHeader = isDashedSectionHeader (txt )
2850- line :SetPoint (" TOPLEFT" , isSectionHeader and 12 or 24 , y )
28512859 if isSectionHeader then
28522860 line :SetText (" |cffffff66" .. txt .. " |r" )
28532861 else
2854- line :SetText (txt )
2862+ line :SetText (" " .. txt )
28552863 end
2856- y = y - 16
2864+ popup . scroll : AddChild ( line )
28572865 end
2858- y = y - 8
2866+
2867+ local spacer = aceGUI :Create (" Label" )
2868+ spacer :SetFullWidth (true )
2869+ spacer :SetText (" " )
2870+ popup .scroll :AddChild (spacer )
28592871 end
28602872
28612873 if # bots == 0 then
2862- local noData = content : CreateFontString ( nil , " ARTWORK " , " GameFontNormalSmall " )
2863- noData :SetPoint ( " TOPLEFT " , 8 , y )
2874+ local noData = aceGUI : Create ( " Label " )
2875+ noData :SetFullWidth ( true )
28642876 noData :SetText (MultiBot .L (" tips.quests.gobnosearchdata" ))
2865- y = y - 16
2877+ popup . scroll : AddChild ( noData )
28662878 end
28672879
2868- content :SetHeight (- y + 4 )
2869- popup .scrollFrame :SetVerticalScroll (0 )
2870- popup :Show ()
2880+ popup .window :Show ()
28712881end
28722882
28732883function MultiBot .ShowGameObjectCopyBox ()
28742884 -- Close main popup if already visible
2875- if MultiBot .GameObjPopup and MultiBot .GameObjPopup :IsShown () then
2876- MultiBot .GameObjPopup :Hide ()
2885+ if MultiBot .GameObjPopup and MultiBot .GameObjPopup . window and MultiBot . GameObjPopup . window :IsShown () then
2886+ MultiBot .GameObjPopup . window :Hide ()
28772887 end
28782888
28792889 local box = ensureGameObjectCopyBoxFrame ()
2890+ if not box then
2891+ return
2892+ end
28802893
28812894 -- Build copy text from sorted game-object entries.
28822895 local bots = collectSortedGameObjectBots ()
28832896 local text = buildGameObjectCopyText (bots )
28842897
2885- box .edit :SetText (text )
2886- box .edit :HighlightText ()
2887- box :Show ()
2898+ box .editor :SetText (text )
2899+ box .window :Show ()
2900+
2901+ local editBox = box .editor and box .editor .editBox
2902+ if editBox and editBox .SetFocus then
2903+ editBox :SetFocus ()
2904+ end
2905+ if editBox and editBox .HighlightText then
2906+ editBox :HighlightText ()
2907+ end
28882908end
28892909
28902910local PROMPT
2891- function ShowPrompt (title , onOk , defaultText )
2892- if not PROMPT then
2893- PROMPT = CreateFrame (" Frame" , " MBUniversalPrompt" , UIParent )
2894- PROMPT :SetSize (260 , 90 )
2895- PROMPT :SetPoint (" CENTER" )
2896- PROMPT :SetBackdrop ({
2897- bgFile = " Interface\\ DialogFrame\\ UI-DialogBox-Background" ,
2898- edgeFile = " Interface\\ Tooltips\\ UI-Tooltip-Border" ,
2899- tile = true , tileSize = 32 , edgeSize = 16 ,
2900- insets = {left = 4 , right = 4 , top = 4 , bottom = 4 }
2901- })
2902- PROMPT :SetBackdropColor (0 ,0 ,0 ,0.9 )
2903- PROMPT :SetFrameStrata (" DIALOG" )
2904- PROMPT :SetMovable (true )
2905- PROMPT :EnableMouse (true )
2906- PROMPT :RegisterForDrag (" LeftButton" )
2907- PROMPT :SetScript (" OnDragStart" , PROMPT .StartMoving )
2908- PROMPT :SetScript (" OnDragStop" , PROMPT .StopMovingOrSizing )
2909-
2910- local btnClose = CreateFrame (" Button" , nil , PROMPT , " UIPanelCloseButton" )
2911- btnClose :SetPoint (" TOPRIGHT" , - 5 , - 5 )
2912- btnClose :SetScript (" OnClick" , function () PROMPT :Hide () end )
2913-
2914- local e = CreateFrame (" EditBox" , nil , PROMPT , " InputBoxTemplate" )
2915- e :SetAutoFocus (true )
2916- e :SetSize (200 , 20 )
2917- e :SetTextColor (1 ,1 ,1 )
2918- e :SetPoint (" TOP" , 0 , - 30 )
2919- PROMPT .EditBox = e
2920- e :SetScript (" OnEscapePressed" , function (self ) PROMPT :Hide () end )
2911+ local PROMPT_WINDOW_WIDTH = 280
2912+ local PROMPT_WINDOW_HEIGHT = 108
2913+ local PROMPT_OK_BUTTON_WIDTH = 100
2914+ getUniversalPromptAceGUI = function ()
2915+ if type (LibStub ) ~= " table" then
2916+ return nil
2917+ end
29212918
2922- local ok = CreateFrame (" Button" , nil , PROMPT , " UIPanelButtonTemplate" )
2923- ok :SetSize (60 , 20 )
2924- ok :SetPoint (" BOTTOM" , 0 , 10 )
2925- ok :SetText (OKAY )
2926- PROMPT .OkBtn = ok
2919+ local ok , aceGUI = pcall (LibStub .GetLibrary , LibStub , " AceGUI-3.0" , true )
2920+ if ok and type (aceGUI ) == " table" and type (aceGUI .Create ) == " function" then
2921+ return aceGUI
29272922 end
29282923
2929- if not PROMPT .Title then
2930- PROMPT .Title = PROMPT :CreateFontString (nil , " ARTWORK" , " GameFontNormal" )
2931- PROMPT .Title :SetPoint (" TOP" , 0 , - 10 )
2924+ return nil
2925+ end
2926+
2927+ function ShowPrompt (title , onOk , defaultText )
2928+ local aceGUI = getUniversalPromptAceGUI ()
2929+ if not aceGUI then
2930+ UIErrorsFrame :AddMessage (" AceGUI-3.0 is required for MBUniversalPrompt" , 1 , 0.2 , 0.2 , 1 )
2931+ return
29322932 end
29332933
2934- PROMPT .Title :SetText (title or " Enter Value" )
2935- PROMPT :Show ()
2936- PROMPT .EditBox :SetText (defaultText or " " )
2937- PROMPT .EditBox :SetFocus ()
2934+ if not PROMPT then
2935+ local window = aceGUI :Create (" Window" )
2936+ if not window then
2937+ return
2938+ end
29382939
2939- PROMPT .OkBtn :SetScript (" OnClick" , function ()
2940- local text = PROMPT .EditBox :GetText ()
2941- if text and text ~= " " then
2940+ window :SetTitle (title or " Enter Value" )
2941+ window :SetWidth (PROMPT_WINDOW_WIDTH )
2942+ window :SetHeight (PROMPT_WINDOW_HEIGHT )
2943+ window :EnableResize (false )
2944+ window :SetLayout (" Flow" )
2945+ window .frame :SetFrameStrata (" DIALOG" )
2946+
2947+ local edit = aceGUI :Create (" EditBox" )
2948+ edit :SetLabel (" " )
2949+ edit :SetFullWidth (true )
2950+ window :AddChild (edit )
2951+
2952+ local okButton = aceGUI :Create (" Button" )
2953+ okButton :SetText (OKAY )
2954+ okButton :SetWidth (PROMPT_OK_BUTTON_WIDTH )
2955+ window :AddChild (okButton )
2956+
2957+ PROMPT = {
2958+ window = window ,
2959+ edit = edit ,
2960+ okButton = okButton ,
2961+ }
2962+ end
2963+
2964+ PROMPT .window :SetTitle (title or " Enter Value" )
2965+ PROMPT .window :Show ()
2966+ PROMPT .edit :SetText (defaultText or " " )
2967+ local promptEditBox = PROMPT .edit and PROMPT .edit .editbox
2968+ if promptEditBox and promptEditBox .SetFocus then
2969+ promptEditBox :SetFocus ()
2970+ end
2971+
2972+ PROMPT .okButton :SetCallback (" OnClick" , function ()
2973+ local text = PROMPT .edit :GetText ()
2974+ if text and text ~= " " then
29422975 onOk (text )
29432976 else
29442977 UIErrorsFrame :AddMessage (MultiBot .L (" tips.quests.gobsnameerror" ), 1 , 0.2 , 0.2 , 1 )
29452978 return
29462979 end
2947- PROMPT :Hide ()
2980+
2981+ PROMPT .window :Hide ()
29482982 end )
2949- PROMPT .EditBox :SetScript (" OnEnterPressed" , function (self )
2950- PROMPT .OkBtn :Click ()
2983+ PROMPT .edit :SetCallback (" OnEnterPressed" , function ()
2984+ local button = PROMPT .okButton and PROMPT .okButton .button
2985+ if button and button .Click then
2986+ button :Click ()
2987+ end
29512988 end )
29522989end
29532990
0 commit comments