Dialog box by Ace3

Hi,

Is anybody familiar with AceAddon, AceGUI-3, AceComfig-3 etc.? I have made a very small addon as an exercise and need to open a message / dialog box to get response from a player. I read docs on Ace3 and found a page describing how to make InterfaceOptionFrame for an add on. It’s as simple as making an option table, which then has to be registered.

I was hoping that I could create another frame with text and buttons, a message box, by providing another similar option table. However, I can’t find anything about how to do that. I read we should not use AceGUI directly but via option table and AceConfig or another module.

Depending on how advanced you want the pop up to be you could probably just use the vanilla StaticPopupDialogs and skip Ace3 all together (unless you use it for other stuff ofc).

You can read more about it here:
wowwiki.wikia. com/wiki/Creating_simple_pop-up_dialog_boxes
(space inserted to post it on the forum)

Thanks for the link. I’ll have a look at the function. Also, yes, my addon is built based on Ace3.

If you want a standalone frame instead of an options frame, you’ll need to use AceGUI 3.0’s Widget API which sadly does not accept options tables.

Here’s the official doc for the widget API:
https://www.wowace.com/projects/ace3/pages/ace-gui-3-0-widgets

the widget API has the various kind of widgets (AceGUI lingo for elements) that you need, namely Button, Label, EditBox, and Frame.

The Widget API has a :Create function which you can use to create a widget. You then have to assign each property of the widget separately. Example for a Frame with one input:

local widgetAPI = LibStub("AceGUI-3.0");
local container = widgetAPI:Create("Frame");
container:SetTitle("Prompt Box");
container:SetFullWidth(true);
container:SetLayout("Fill");

local input = widgetAPI:Create("EditBox");
container:AddChild(input);
input:SetLabel("Enter Name");
input:SetMaxLetters(25);
input:OnEnterPressed = function(text)
   print(text);
end

And so forth. Because of the verbosity of this kind of code, i strongly recommend you to wrap code which creates a UI into a function and to put that function into a separate file. That keeps the main code clean and organized.

Hopefully this helps you on your way to create your own standalone UIs. If you have questions, do feel free to ask!

I have visited Ace3 for a couple of times, read its web pages, and I don’t know how I could possibly miss this link to its widgets … it’s right there -.- Anyway thanks for the code. It helped me to grasp the way custom frames are built.

As to the separate files, I have just started and did not try to include any other files. Currently, everything is in one file. It will be a good exercise :slight_smile: As I use Ace3, I guess each file should start with this line:

local addonCore = LibStub("AceAddon-3.0"):GetAddon("AddonName")

to have access to the core table. This is where I need to save handles to custom frames. Also, I am slightly confused how lua read separate files. Should additional files be places before or after the core file? I will work on it as soon as I can :stuck_out_tongue:

Thanks

To include additional files in your addon, you should edit your .toc file and add additional .lua entries there. For example, this is what the .toc file in one of my addons looks like:

TOC file example
## Interface: 80000
## Version: 3.0.7
## Title: Watcher
## Author: nothingsknower, Sparbanken, mpstark, Jordy141
## Notes: Rotation helper with timeline display.
## SavedVariablesPerCharacter: WatcherDB
## OptionalDeps: Ace3, LibSharedMedia-3.0, LibDispellable-1.0, LibSpellbook-1.0

embeds.xml
Locales\Locales.xml

Core.lua
Options.lua
Display.lua
Filters.lua

Notice the “Core.lua” - “Options.lua” - “Display.lua” - “Filters.lua”. When the WoW client loads this addon, it will read and parse each file in order. The client itself will actually just paste the code in each file in order to create one large file in memory. This also means you can run a function inside Core.lua from another function inside Display.lua. All that matters is the order in which you load each file because the lua environment is unaware of code that comes after it.

Libstub should really only be used when loading libraries, not parts of the same addon. Any files you add already have access to the core table since lua runs all code in one shared environment.

Lastly, please note that while edits to the lua code only need a /reload to be read, edits to the .toc file require a restart of the WoW client in order to be recognized.

1 Like

Thanks for this :slight_smile:

EDIT.
OK. I sort of managed do setup a new frame with a message but I did not like how it looked :stuck_out_tongue:. I decided to have a go with the StaticPopupDialogs and ended up having a proper dialog box.

If someone else is also interested in this topic, there is a way to setup up to four different StaticPopupDialogs. This is the link to WowWiki, API StaticPopup_Show, and API StaticPopup_Hide

Thanks

WoWWiki: http://wowwiki.wikia.com/wiki/Creating_simple_pop-up_dialog_boxes
API StaticPopup_Show: https://wow.gamepedia.com/API_StaticPopup_Show
API StaticPopup_Hide: https://wow.gamepedia.com/API_StaticPopup_Hide

PS1. Bloody hell. I have contributed to this forum so many times and still cannot post internet links. Stupid Blizzard rules!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.