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

Add word wrapping option for Text Object #658

Merged
merged 3 commits into from
Sep 23, 2018
Merged

Conversation

Lizard-13
Copy link
Contributor

It's just a graphical feature, you can't get the number of wrapped lines.

@4ian
Copy link
Owner

4ian commented Sep 22, 2018

Looks good for the code! Great job 👍
I wonder if there is something to be done when an instance of a text object on the scene has a custom size: should we detect this and make the object to have the same wrapping width as the instance custom width? (let's forget about height)

Technically, this could be implemented with extraInitializationFromInitialInstance for gdjs.TextRuntimeObject (see example in gdjs.TiledSpriteRuntimeObject and other objects) where we can call setWrappingWidth if there is a custom size). For the IDE instance renderer, an extra check on this._instance to see if there is a custom size and then set the wrapping width as well.

Could be useful I think and seems feasible - what do you think?

@Lizard-13
Copy link
Contributor Author

I had the same idea, you know?, but then realized that custom size is not passed to the text object, and I was fearing to mix non-related things. But if you think it's ok I could do it, and then just remove the "Wrapping width" option from the editor, it looks ugly.

Also, I was thinking on adding a small graphic line in the instance renderer to show the wrapping width, but right now you're using a single PIXI objet to render each instance. Using the custom width would be cool here too, because the text wrapping width would be displayed in the editor through the collision mask (we have to store the custom size in the text object json too, I think it isn't saved right now).

@4ian
Copy link
Owner

4ian commented Sep 22, 2018

then just remove the "Wrapping width" option from the editor

I think we can remove it in this case, if we're considering that wrapping will be set by the instance width :) (or by using events).

Also, I was thinking on adding a small graphic line in the instance renderer to show the wrapping width, but right now you're using a single PIXI objet to render each instance

If needed you can change the object to be a PIXI.Container, which can contain multiple PIXI objects inside.
But I think it's not necessary if we use the instance width :)

the text wrapping width would be displayed in the editor through the collision mask

Yes that's the good part! :)

(we have to store the custom size in the text object json too, I think it isn't saved right now).

What do you mean?
In any case, we can keep the wrappingWidth and wrapping attributes that you added to TextObject. If we don't display them in the editor, we consider that all text objects are not wrapped by default (which is fine :)). Then it's up to the user to modify the width of instances of the text object if he/she wants the text to be wrapping (or use events if this need to be changed in the game, even if it's less likely :))

@Lizard-13
Copy link
Contributor Author

What do you mean?

Oh, I don't know why I thought the custom size was not serialized nor passed to the instances if it was a text object, that's why I not implemented it in the first place :P

I'm on it

@Lizard-13
Copy link
Contributor Author

Wait, @4ian, if we use the custom size and custom width as wrapping in the editor, and convert this data to wrapping in the runtime object, we could just remove the wrapping properties set in TextObject.h/cpp files and don't serialize it at all...
I guess we can close the GDevelop.js pull request, no?

@4ian
Copy link
Owner

4ian commented Sep 22, 2018

That's true! GDevelop.js pull request is then not useful. That will keep things simple!
At least know you're able to compile it, can be useful for other things in the future 👍

@Lizard-13
Copy link
Contributor Author

selfdisappoint

@Lizard-13
Copy link
Contributor Author

Ok, it should use the custom size now, I've updated the text instance renderer on the IDE so the position is updated after changing the object size.

@4ian
Copy link
Owner

4ian commented Sep 22, 2018

Sorry about this I know it's frustrating to spend time like this when it's to remove the code then :/
But that looks good though now! :) Let me double check and merge this tomorrow! :)

@Lizard-13
Copy link
Contributor Author

Don't worry man, just kidding, supper happy to make it to work actually :D

@4ian
Copy link
Owner

4ian commented Sep 23, 2018

Merging this now as it looks good! Thanks for working on this 👍

@4ian 4ian merged commit 5665401 into 4ian:master Sep 23, 2018
@blurymind
Copy link
Contributor

Thank you @Lizard-13 awesome feature :D 👍

@zatsme
Copy link
Contributor

zatsme commented Sep 23, 2018

Great work! What next.... Skeleton? 🤔

@blurymind
Copy link
Contributor

skeleton in gd5 would be amazing! :D

@Lizard-13
Copy link
Contributor Author

Mmmmh, now I can compile libGD.js, so why not?, not sure how much time it will take but skeleton is next :)

@Lizard-13 Lizard-13 deleted the word-wrapping branch September 23, 2018 13:19
@blurymind
Copy link
Contributor

@Lizard-13 this is literally the most exciting feature for me to have in gd5.
Thank you for doing this.

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

Successfully merging this pull request may close these issues.

4 participants