User Tag List

Results 1 to 6 of 6

Thread: A little help with string object and dialogue system.

  1. #1
    Clicker Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    A little help with string object and dialogue system.

    Hey guys,

    Feels like I'm back to basics lately, awesome!
    Anyways, I noticed String object can properly wrap these days, when did this happen?

    So, I'm using "Left$(string$( "dialogue_temp" ), Len(string$( "dialogue" )) + 1)" in order to feed one letter at a time.
    It works, but in some situations is starts typing the word, and once the word is typed it moves it to another line when I hope it could type to the other line straight away.

    For example:
    "Hello, this is template text, how is it going?"

    Appears like this:
    "Hello, this is template text, how
    is it going?"

    But before it looks like this:
    "Hello, this is template text how is
    is it going?"

    (I typed "is" twice there to show what I mean!)

    So basically it writes the word, in this case "is" to first line, and only moves it to the new line after the word is written. Needless to say it looks a bit dump.

    Anyway, is there a way around with the String object? I load dialogues from ini file, and later on translations, so the system should be automated.

    Any help would be appreciated, thanks!

    EDIT: I was thinking I could look for space after certain amount of characters and add newline$ there, could work, not sure.
    However, I'm thinking if in certain languages spaces are used differently, then it could break with translations, any idea?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,155
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Hey Jesse!

    Since you use a string object, I guess you will be embedding a specific font with your project?

    Wonder if you are using a fixed length font...
    this could make things easier, knowing how much space each character takes,
    you could calculate when to put a newline and prevent wrapping

    Otherwise, this may be a little bit trickier to setup but theorically more flexible:

    1) trim the string object height to minimum (one line) at start

    2) after each full word (every blank space you meet) do the following things:

    - set a value to current Oheight of the string object
    - add the next whole word (with a loop, char by char until you meet another blank space, or with a string tokenizer, splitting at " " and picking next element)
    - test if the current OHeight of the string object is > than the stored Oheight
    - if so, remove the word you just added and add a newline
    - if not, keep the word you just added


    should theorically work...

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have the right idea. I made a quick example where one string is copied letter-by-letter from a source. If a space (" ") is encountered, it assumes a new word will follow and retrieves the number of letters in this word. If it exceeds the allowed line length, it will insert a line break.

    File: exampleStringFunctions.mfa


    It's very basic, and doesn't acount for "-" between words nor line-breaks when retrieving the word length. Can be added with too much effort I guess.

    If you want full control of strings, line lengths and stuff like that, it's probably better to build your own text system using actives. That way you can easily determine the total length of a line by retrieving the total width of all the actives in a line. If you use the String object, you'd have to store the size of every letter in a font in a database somewhere. Of course, you can always use monospace fonts, where are letters are the same size.

  4. #4
    Clicker Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I should've mentioned I'm indeed using fixed length font, this will make things easier.

    Thanks for the replies, I'll play around with the ideas and will check your example Chrille, I'll let you guys know if I can make it work or encounter any problems.

    Thanks again!

  5. #5
    Clicker Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey Chrille, I played around with your example, took me a good amount of time to figure how on earth you're doing it. I haven't used string functions too much in the past.
    Anyway, I think I finally figured out. I was able to re-create the system in my project and it seems to work perfectly fine with quick testing.

    That said, thanks! And thanks to schrodinger as well!

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad it worked out


    I just had a look at my example again and it was probably a bad idea to modify the source string. Not that it matters in my example, but it might make it less applicable to a different setup.

Similar Threads

  1. Graphic adventure dialogue system
    By Boba Fonts in forum Multimedia Fusion 2 - Technical Support
    Replies: 27
    Last Post: 5th May 2018, 09:15 AM
  2. Dialogue problem : make a dialogue with animations
    By esp in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 21st December 2015, 08:04 PM
  3. Replies: 3
    Last Post: 26th January 2015, 11:54 PM
  4. Dialogue using string
    By Panchos in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 16th May 2013, 10:00 PM
  5. Help making Text Blitter do dialogue with a String
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th January 2010, 05:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •