Text in bubble or box

  • #1, by Simon_ASASunday, 24. July 2016, 11:46 8 years ago
    Hello,

    After thinking of it for several months, I am still wondering how I can obtain this result in Visionaire:

    I want to create a bubble (like in a comic), and I want that the size of this bubble changes according to the text displayed over a character.
    A bubble... or just a simple box.

    Example:
    http://zupimages.net/up/16/29/cpsg.jpg

    I think there is no such feature in Visionaire (right?), so I have been thinking of the following method:

    1. create pictures with 3 sizes of bubbles (or more): small, medium and large
    2. use the Character Text (action part) to show the text over the character of my choice
    3. find a method to count the length of the text (number of lines, or number of characters)
    4. find a method to know the position of the text on screen
    5. display the bubble at the coordinates found in 4
    6. choose the size of the bubble according to the quantity of text found in 3

    Can anyone tell me if it is possible in lua to do this (particularly parts 3 and 4), or if you know another method to obtain the same kind of result?

    Another idea was to put a single bubble in an active animation on an interface, and change the size (scale) of the bubble according to the quantity of text, but I still have the problems at parts 3 and 4.

    I hope anyone can come with a working solution!

    The result would be something like in Lumino City:

    http://images.pocketgamer.co.uk/images/featimgs/luminocity-guide-27.jpg

    Great Poster

    321 Posts


  • #2, by afrlmeSunday, 24. July 2016, 12:18 8 years ago
    The simplest solution would be to create each text complete with speech bubble as an image inside of your image editor of choice; at least that way you get to customize each text to your liking such as adding bold, italic, underline, or changing the color of important words, etc. Personally it's probably what I would do due to customization.

    In regards to 3 & 4... Yes it should be possible to count the length of a text via the string.len() Lua function. You would use this inside of a registerEventHandler("textStarted") event handler function or inside of the registerHookFunction("textPosition") event handler function. There are plenty of examples of both those kind of functions being used in various threads on here & there are also examples available on the wiki. Hook function one would be the one you used to return the text position.

    By the way, 2 other speech bubble topics already exist. I believe Uraal posted a working solution in this thread. I don't believe I 100% agreed with the script he wrote as it lacked character scaling calculation to correctly offset the speech bubble / texts, but that's an easy fix. wink

    Imperator

    7278 Posts

  • #3, by Simon_ASASunday, 24. July 2016, 12:27 8 years ago
    By the way, 2 other speech bubble topics already exist. I believe Uraal posted a working solution in this thread.


    Ah!!! I've been looking and reading for all threads talking of "text" and I never found this one twist
    Cool!

    Thanks for your help Lee, I can probably do something nice now.

    The simplest solution would be to create each text complete with speech bubble as an image inside of your image editor of choice


    Oh no, this is horrible to work on localization later! razz

    Great Poster

    321 Posts

  • #4, by afrlmeSunday, 24. July 2016, 12:44 8 years ago
    Indeed it would be horrible, but it's the only customizable option currently available for generating unique text styles. Hopefully that will change in the future.

    Creating a few speech bubbles of different size / shape also sounds like a plausible idea. You could try to calculate which one is needed based on the length of the text or you could manually tell it which one to use by setting a value or something before triggering each display text, so that the engine instantly knows which speech bubble to show. It would be a little more work, but it would be instantaneous rather than letting the engine work out which is needed after the text is already shown. You can try the text counting first & see if works ok mind, as I've no clue.

    Imperator

    7278 Posts

  • #5, by sebastianMonday, 25. July 2016, 08:41 8 years ago
    additionally to afrlme's suggestion with lua:

    the string-length you have to count should be TextCurrentText + TextRemainingText from the current activetext, so all text from the current "to be shown" text is calculated. then you can decide when using the different sizes of your speech bubble and start to show the interface (which has its different sizes inside and shows only one deoending on a value) .
    the interface itself should have an absolute position and its coordinates should also be calculated based on the position of the current speaking character - offset to display it correctly above the head.

    Thread Captain

    2346 Posts

  • #6, by Simon_ASAMonday, 25. July 2016, 11:20 8 years ago
    Wow thanks a lot Sebastian, with your help and Afrlme's, I should be able to do it!

    Having bubbles (or boxes) on my texts is something I really really wanted from a long time, so you did bring me some excellent info here.

    I'll try to let you know of my progresses here. However I might be a bit slow to reply and to test all of this: I'm still unsure of my next project and I have several different systems to try before I take a decision.
    That would be much easier if I could just focus on the graphics only, and let someone else work in VS lol

    Great Poster

    321 Posts

  • #7, by afrlmeMonday, 25. July 2016, 13:38 8 years ago
    @ Sebastian: you are talking about display texts where the person entered in multiple p tags inside of the same display or narration text block, yes?
    some text <p1000ms> some more text <p1500ms>, etc
    


    It's a shame we can't draw shapes with Lua itself - or can we? We have the Lua draw functions that Simon implemented into 4.2.5, but I don't know if we can create shapes with it or if they are just for drawing existing image files or text. Simon?

    Imperator

    7278 Posts

  • #8, by sebastianMonday, 25. July 2016, 14:05 8 years ago
    @afrlme
    yes, exactly. the current text is only the displayed text until the first p tag if present..

    Thread Captain

    2346 Posts

  • #9, by afrlmeMonday, 25. July 2016, 15:47 8 years ago
    Won't the next active text in the same display text update the current text when it changes to it? I'm not sure as I've not tested it out myself.

    Imperator

    7278 Posts

  • #10, by sebastianMonday, 25. July 2016, 16:27 8 years ago
    should be tested smile
    also:
    With simple if conditions the X/Y coordinates of the bubble should also be checked to prevent the bubble from going outside the screen while the text stays at the edge

    Thread Captain

    2346 Posts

  • #11, by afrlmeMonday, 25. July 2016, 16:48 8 years ago
    I guess the best way to prevent this in the first place would be to be careful where you trigger dialogs in general. Don't allow instant examine observation texts from wherever the character is currently standing - set a specific interaction position for each scene object or a general point at least for multiple scene objects.

    But, aye, you could simply check if character is x pixels away from the left or right of the screen edge to determine if text has probably been pushed to scene edge.

    Personally I think the best approach for texts is to force them into a bounding box at the bottom or top of the screen. At least that way, you know they are always going to be in the same position & displayed correctly.

    Imperator

    7278 Posts