• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Multiboard Text Parsing

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
Hello Hivers,

I am making a system, and I was wondering if there was a way to parse the text in a multiboard. For example if there is too much text in the rows, instead of running off the board into nothing, a system detects if there is too many characters and takes it to the next row?

Thanks,
Forsakener
 
Last edited:
I think this will be more complex and complicated to do..

But here's the main idea:
- Create a new variable that stores the maximum number of letters/signs/etc that can be reached. (like only 100 letters allowed per column/row)
-- you should add an array to it and choose your settings for it.. for which rows/columns it shall work and stuff like that.
- After you've used a trigger for checking each X seconds of Game time, wether the letters are too much or not, you need to create a new line or colum or use a existing one.
- Then just simply delete the too much letters and place them in the new column (you can use some TempVariable to delete and create the letters in that new column/row)

So the System checks each x seconds, if there are too much characters in that column/row and then stores the overfilled characters in an tempvariable and places them into a new column. You have to work with strings and set the range of 1-100 for example, so you only store each character after that 100 mark. Also you can use this to check, if there are too many letters in it.

Sry, but I can't open the WE right now to make some correct triggers for this..
So Good Luck trying this, should be some work to do and make it work properly.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243

  • Untitled Trigger 070
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set columns = 4
      • Set mb_max_length = 8
      • Multiboard - Create a multiboard with columns columns and 1 rows, titled This is a multiboard
      • Set mb = (Last created multiboard)
      • For each (Integer A) from 1 to columns, do (Actions)
        • Loop - Actions
          • Multiboard - Set the display style for mb item in column (Integer A), row 1 to Show text and Hide icons
          • Multiboard - Set the width for mb item in column (Integer A), row 1 to 4.00% of the total screen width
      • Multiboard - Set the text for mb item in column 1, row 1 to TYPE
      • Multiboard - Set the text for mb item in column 2, row 1 to SOME
      • Multiboard - Set the text for mb item in column 3, row 1 to CHAT
      • Multiboard - Set the text for mb item in column 4, row 1 to MESSAGE
      • Multiboard - Minimize mb
      • Multiboard - Maximize mb
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
    • Conditions
    • Actions
      • Set s1 = (Entered chat string)
      • Set i1 = (Length of s1)
      • For each (Integer A) from 1 to columns, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i1 Greater than 0
            • Then - Actions
              • Multiboard - Set the text for mb item in column (Integer A), row 1 to (Substring(s1, 1, mb_max_length))
              • Set i1 = (i1 - mb_max_length)
              • Set s1 = (Substring(s1, (mb_max_length + 1), (Length of s1)))
            • Else - Actions
              • Multiboard - Set the text for mb item in column (Integer A), row 1 to <Empty String>
 

Attachments

  • Multiboard_Text.w3x
    17.3 KB · Views: 88
Level 11
Joined
Jun 30, 2008
Messages
580
Mistake: I meant Rows, not columns, but this is what I changed with your code:


  • Untitled Trigger 070
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Rows = 1
      • Set mb_max_length = 24
      • Multiboard - Create a multiboard with 1 columns and Rows rows, titled This is a multiboar...
      • Set mb = (Last created multiboard)
      • Multiboard - Set the display style for mb item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the width for mb item in column 1, row 1 to 20.00% of the total screen width
      • Multiboard - Minimize mb
      • Multiboard - Maximize mb
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
    • Conditions
    • Actions
      • Set s1 = (Entered chat string)
      • Set i1 = (Length of s1)
      • Set Rows = (1 + (i1 / mb_max_length))
      • Multiboard - Change the number of rows for mb to Rows
      • For each (Integer A) from 0 to (Rows - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i1 Greater than 0
            • Then - Actions
              • Multiboard - Set the text for mb item in column 1, row ((Integer A) + 1) to (Substring(s1, (1 + ((Integer A) x mb_max_length)), (mb_max_length x ((Integer A) + 1))))
              • Multiboard - Set the display style for mb item in column 1, row ((Integer A) + 1) to Show text and Hide icons
              • Multiboard - Set the width for mb item in column 1, row ((Integer A) + 1) to 20.00% of the total screen width
            • Else - Actions
              • Multiboard - Set the text for mb item in column 1, row (Integer A) to <Empty String>


And this works perfect. It adds a new row when needed. The only thing that I don't like is that it cuts the words. Is there a way to detect that if there is a word and it doesn't fit in the current row without cutting it, and put it to the next row?

If so how?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
Such a system is possible but is not simple.
There are 2 main parts to solving this.

1. Break text appart into separate lines (and how many lines are needed).
2. Allocate the needed lines onto the board (algerthim is your choice but they may need resizing the board or discarding overflowing lines).

The problem with 1 is that the character maps WC3 use are not square, so W is wider than i and such you can get more or less characters per line depending on which ones are used. Thus you will need a system mapping single characters to an integer of their width. You loop through the whole string and create new lines once the width of the current 1 is going to exceede maximum of the space it can be allocated into.

I would strongly advise JASS, atleast for the first part as the execution time is directly dependant on string length and GUI may not be able to program a solution efficently.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I suggest you set max number of characters per row base on how many of the widest characters fit on one row.

For example "w" might be the widest character. Check how many "w"s fit on one row.

Then you loop through the characters and find spaces. Add the characters to the row. If the next space is too far away, jump to next row.

One trouble is that the width of the columns depend on resolution used, so they will be of different width for different resolutions.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
If he goes through the effort to make a system like that, then why not take it all the way and do what I described and just create lines of certain width.

Hashtables are suprizingly useful for maping stuff like this. You could use 1 where the parent is the character and the child is 0 for small letters and 1 for capitals and then simply store the integer/real of how wide it is.
 
Level 11
Joined
Jun 30, 2008
Messages
580
I have created a system that uses an algorithm like you suggested.

Now I can't figure out why exactly it isn't working correctly.

It takes the length of the text then divides it by the max characters to find the rows.
Then it takes max characters of length of the each section. Tells if the last word needs to wrap but checking if the max character and the max character + 1 are both not spaces. Then a separate loop finds how many spaces are in that section of characters, and the next part of the system takes the last space and subtract it from the Max Characters to figure out the length of characters that need to be wrapped to the next line. Takes that and adds it into "wrap" and goes through the system again till all rows are complete.

Here is the pastebin of the system: http://www.hiveworkshop.com/forums/pastebin.php?id=2tr8k9
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
If he goes through the effort to make a system like that, then why not take it all the way and do what I described and just create lines of certain width.

Perhaps for simlicity's sake. The system you suggested would be optimal however.

I have created a system that uses an algorithm like you suggested.

Post it in a map.
 
Status
Not open for further replies.
Top