Save-Point
Handling very long Item Names - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Handling very long Item Names (/thread-7333.html)



Handling very long Item Names - Melana - 09-23-2018

While working in my game's interface I remembered something that annoys for a very long time.
It's how RMXP is handling too long Item names.

Usually it squeezes the name to fit into the window which looks in my personal opinion very ugly.

Example:

[Image: xrpDb4r.png]

So I thought about a second row for the words. I lowered the fontsize of the game to make it look better in general and put this example together in Paint.

[Image: lVN7ix5.png]

So my question is, would it be easy to change the draw_item method to display the names like that instead of the old behaviour?
I guess it would require something to split the string when it reaches the limit of the first row and put the rest of the string into the second row.
But what do I know... I'm really bad at RGSS.
I'm just curious how one would set this up.

(It was quite hard to find such a long name in english. With german names it's alot easier to reach the limit of the window.^^)


RE: Handling very long Item Names - kyonides - 09-23-2018

You would need to either count how many spaces fit the window or look for the last empty space and split the name right before that space. Or mix both ways...
  • This option would split words as well:
    This is a long na
    me for a sword
  • This one would attempt to keep it readable:
    This is a long
    name for a
    sword

In the former you would count how large is the string with string.size (and add a condition), while in the latter you would use self.contents.text_size(string) and a if statement or condition to determine when it should be split into two chunks. Here it would be measured in pixels not spaces.


RE: Handling very long Item Names - Melana - 09-23-2018

The second option seems to be the better one.
But how would you check if the word still fits in the first row or not. Would the script count the amount of characters of each word and calcute with the total amount of possible characters for each row if it fits or not?


RE: Handling very long Item Names - DerVVulfman - 09-23-2018

Or you could use the MACL addon, 'Draw Formatted Text' by Trickster. MACL stands for Method and Class Library, and is a collection of new methods you can use in RGSS scripts. And 'Draw Formatted Text' is an addition to the Bitmap class which lets you have text that wraps to the next line as you seem to want.

Rather than going into our Scripts Database board and hunt through the entire MACL system, you can just check LilyFrog's current/recent Code Support thread where I've been giving assistance. The last 'scripts.zip' file is a scripts.rxdata file which includes both Trickster's system, and a script by SephirothSpawn for scaled image blitting. Both are in the Bitmap class.


RE: Handling very long Item Names - Melana - 09-24-2018

That works really good.
Thank you for the tip.

I just had to make a check method to have the text centered if only one row is used.