Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Layout support #34

Open
minggo opened this issue Jun 27, 2017 · 17 comments
Open

Layout support #34

minggo opened this issue Jun 27, 2017 · 17 comments

Comments

@minggo
Copy link
Contributor

minggo commented Jun 27, 2017

No description provided.

@samge1988
Copy link

yes, layout support is very important

@tankorsmash
Copy link
Contributor

tankorsmash commented Feb 3, 2018

Is there a way to list out the limitations of implementing the Layout support, in such a way to maybe get someone else to help implement that?

After being parsed by the core/parsers, seems like flatbuffers generates some code, then it goes through it here. I'm not familiar with flatbuffers but the _generated file seems to need input files but I don't know enough to take the next step.

Is there a file that is supposed to be fed to flatbuffers that isn't in the repo? Seems like it should be some sort of IDL, but I don't see anything in the repo.

Seems like we'd need to

  • add a new parser to core/parser
  • add some sort of data to flatbuffer's source IDL file
  • add a createLayout & parseLayout to CreatorReader.cpp

I'm not familiar with much of this but maybe someone else can help guide me

@minggo
Copy link
Contributor Author

minggo commented Feb 5, 2018

I will write a doc about how it work, then other developers can join to develop it.

@tankorsmash
Copy link
Contributor

Great! Looking forward to learning more about how this plugin works.

@minggo
Copy link
Contributor Author

minggo commented Feb 5, 2018

@tankorsmash i added this wiki, please let me know if something is missed. And you are appreciated to improve it too.

@tankorsmash
Copy link
Contributor

@minggo Great thank you!

@tankorsmash
Copy link
Contributor

tankorsmash commented Feb 7, 2018

https://github.com/tankorsmash/creator_to_cocos2dx/tree/add_layout_support I've started a branch for this. I'll continue to investigate, but I wanted to write progress down as I could use some guidance.

I've modified the .fbs, I've added a placeholder Layout.js, I've hooked up the Util.js node guessing to use Layout.

The problem I'm running into now is that the cocos2d::ui:Layout* node child isn't being built at all by the getSceneGraph() call, whereas before I started working on this, it would be detected and parsed as a Node. In other words, instead of being parsed incorrectly as Node, it is now not being built at all among the children of the scene = reader->getSceneGraph().

The structure of the scene in my sample project and their names are:

  • Canvas ("Canvas")
  • Layout ("sample_layout")
  • Button ("sample_button")
    \-> Label ("sample_button_label")

My question is what am I doing wrong that's causing the Layout node, sample_layout, to not be generated by the reader instance? I suspected that it was because Layout.js was effectively empty, but I checked out Button.js and it doesn't really do much else besides set a few properties. I would expect that with how it's written now, the generated Layout node would have been missing a few properties rather than not parsed at all.

Thanks again for writing the wiki, I've also created an issue where I made a few changes to it too.

edit: Realized I missed the convert_fire_to_json, trying that now.

edit2: That didn't work and hasn't been edited in about a year, so maybe it's not used anymore. Am now trying to edit CreatorReader.cpp which is looking like that's the piece I missed.

@minggo
Copy link
Contributor Author

minggo commented Feb 8, 2018

Realized I missed the convert_fire_to_json, trying that now

Did you mean convert_fire_to_json.py? It is not used. I will remove it now.

@tankorsmash
Copy link
Contributor

Yeah, thanks!

@tankorsmash
Copy link
Contributor

I've updated CreatorReader.h/.cpp and I've got the nodes generating, I'll update the wiki to make sure that's covered, then add the support for the resizing and I think we'll be cool here, thanks for the help.

I'm not familiar with lua, so once I'm done, maybe someone else can come in afterwards and make sure I didn't mess any of that up.

@minggo
Copy link
Contributor Author

minggo commented Feb 8, 2018

Cool, waiting your for PR.

@tankorsmash
Copy link
Contributor

tankorsmash commented Feb 13, 2018

I've got my fork exporting Layouts now, which works well enough for the usecase I was trying to solve, but it doesn't support the padding/magin and layout options.

Basically mine just adds in a Layout and uses the background color from the editor, sort of how it worked in Cocos Studio, since I'm unfamiliar with the new stuff. Is that something you're still interested in getting a pull request for?

edit: hold on, doesn't seem to support children properly, I'll need to keep working on it.

@tankorsmash
Copy link
Contributor

tankorsmash commented Feb 14, 2018

The lack of children wasn't a problem in the plugin, I was cloning the widget and since Label isn't ui::Text (and therefore not a ui::Widget), it's not cloned by ui::Widget.clone, which I suppose is something a little more broad than this plugin, I think.

Seems like everything implemented is working as intended.

@drelaptop
Copy link
Contributor

Any progress for the Layout? @tankorsmash

@tankorsmash
Copy link
Contributor

tankorsmash commented Mar 27, 2018

@drelaptop My fork seems to be working, more or less, as of the latest Feb 21st commit. Some weirdness of the sprite background where I still need to set the background fill type to NONE sometimes (most of the time?), but otherwise it was enough for me to port from studio to creator

There's the two options that aren't supported, the Resize and Layout types, but I didn't use them in Studio. I didn't want to make a PR because it didnt have that, but I could if the half-baked support would be okay with people, I'll do it.

@drelaptop
Copy link
Contributor

This great job is meaningful for plugin users, even though two options not supported, so I suggest you to make a PR, just add comments into that PR what have been supported, what not supported. you can add the unfinished feature if you have free time recently, you don't have to if not.

@tankorsmash
Copy link
Contributor

tankorsmash commented Mar 29, 2018

@drelaptop Thanks for the thought.

Made a PR here that mentions the limitations, hopefully someone else can find a way to use it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants