Posts: 449
Threads: 18
Joined: Sep 2015
09-23-2018, 04:21 PM
(This post was last modified: 09-23-2018, 04:23 PM by Mel.)
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:
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.
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.^^)
Posts: 4,634
Threads: 554
Joined: Dec 2009
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.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest &
Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE,
RandomEnkounters XP,
KSkillShop XP,
Kolloseum States XP,
KEvents XP,
KScenario XP & Gosu,
KyoPrizeShop XP Mangostan,
Kuests XP,
KyoDiscounts XP VX, ACE & MV,
KChest XP VX & ACE 2016,
KTelePort XP,
KSkillMax XP & VX & ACE,
Gem Roulette XP VX & VX Ace,
KRespawnPoint XP, VX & VX Ace,
GiveAway XP VX & ACE,
Klearance XP VX & ACE,
KUnits XP VX, ACE & Gosu 2017,
KLevel XP,
KRumors XP & ACE,
KMonsterPals XP VX & ACE,
KStatsRefill XP VX & ACE,
KLotto XP VX & ACE,
KItemDesc XP & VX,
KPocket XP & VX,
OpenChest XP VX & ACE
Posts: 449
Threads: 18
Joined: Sep 2015
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?
Posts: 11,261
Threads: 651
Joined: May 2009
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.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links
Posts: 449
Threads: 18
Joined: Sep 2015
09-24-2018, 06:37 PM
(This post was last modified: 09-24-2018, 09:45 PM by Mel.)
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.