Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Frame Templates #15

Open
Jinxit opened this issue Jul 26, 2021 · 10 comments
Open

Frame Templates #15

Jinxit opened this issue Jul 26, 2021 · 10 comments
Labels
enhancement New feature or request

Comments

@Jinxit
Copy link

Jinxit commented Jul 26, 2021

Thanks for this amazing extension, it makes addon development so much easier.

Is there some way to handle the typing of Frame templates such as BackdropTemplate that I'm missing, or is that currently not supported?

image

@Ketho
Copy link
Owner

Ketho commented Jul 26, 2021

I have no idea how this would be implemented in EmmyLua or if it's even possible. Not to mention it can accept multiple, comma-delimited templates. But it's indeed an inconvenience templates are not supported at all by this extension.

@Ketho Ketho added the enhancement New feature or request label Jul 26, 2021
@Jinxit
Copy link
Author

Jinxit commented Jul 27, 2021

Thanks for taking a look! I don't see this as a high priority feature or anything, I was mostly just wondering if I missed something obvious.

You're right, it seems like EmmyLua can't pick the correct overload return value based on string literals:

image

So I guess the only option would be to export the templates as types that can be used manually with @type assignments, or having CreateFrame return multiple types as above, or both at the same time.

@ChrisKader
Copy link
Collaborator

I have been messing with this a bit this weekend.

image
Basically the template param is used to look up an alias for known template types. Then the value returned is a merged version of the frame type specified and template type specified (if found.). Below shows what would happen if the template type is not found.
image

@ChrisKader
Copy link
Collaborator

ChrisKader commented Oct 11, 2021

I am currently working on a parser parse all XML files from the default UI.

Currently it will:

  • Determine what fields the frame template has and also what templets/mixins it may be inheriting
  • This includes any Frames, Scripts, Layers, Key Values, along with the defaults set by things like Size, Color, Anchors, ect.
  • Create the proper types that will also inherit other types/mixins as needed.

All thats left really is generating the LUA files.

@Ketho
Copy link
Owner

Ketho commented Oct 11, 2021

I can confirm this works, thank you for finding this solution.

There is indeed still the problem of comma-separated templates and having to parse XML to convert templates to EmmyLua but it's something 😃

@ChrisKader
Copy link
Collaborator

I am unsure what you mean by comma-separated templates.

@Ketho
Copy link
Owner

Ketho commented Oct 11, 2021

For example

CreateFrame("Frame", nil, nil, "VerticalLayoutFrame, TooltipBackdropTemplate")

But those don't appear to be used in FrameXML and I suppose for only very few addon authors. So it's a moot point, never mind 😅

@ChrisKader
Copy link
Collaborator

Do you have a prefered format? I have gotten through most of the parsing and just need to clean a few things up.
image

@ChrisKader
Copy link
Collaborator

So I have built the lua files for EmmyLUA to use. After breaking them up into 100kb files, there are 11.
image
I can submit a PR with the code for parsing the XML if needed.

@Ketho
Copy link
Owner

Ketho commented Oct 13, 2021

I don't really have a preferred format but it's neat that you first parsed the templates to Lua before converting it to EmmyLua. I'd like to have the code (Lua/Python?) for parsing the XML otherwise I'll have to write my own one. But this is looking nice 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants