I picked up a script that works perfectly, but I was toying around with making adjustments in the body of the script. I'm not familiar with Ruby/RGSS but I've had a little play in C++ so I'm able to understand some of what is going on. Anyways, I came up on this little bit of code I want to rework a little, but I just can't seem to get it to work. Just for everyone's info, I'm not claiming this is my own script, I'm allowed to use and modify the script for my game, and I'm giving the original author full credit. Here's the snippet of code I'm working on:
def refresh
contents.clear
change_color(normal_color)
unless $game_map.display_name.empty?
# draw_text(0, 0, 100, 20, PAC::MM::Loc_a, 2) GS84 <--this is the line I'm adding in (GS84 = GreyStone84)
draw_text(contents.rect, $game_map.display_name, 1)
end
end
end
My issue comes regarding the content.rect and centering. The contents.rect does a good job centering the map name in the middle of the rectangle, but it was designed for only one line of text. I extended the height of the map name window, no problem, but I also wanted to add in a line of text above the map name to simply say "Location", or "Location", which is the line of code I commented out. Looking around, I found out that I can place a number from 0-2 after the text and it is supposed to be the alignment, but it doesn't center it properly. It's almost like the 0-2 are referring to tabs instead of alignment. I tried to manually switch the x coordinate; window_width returns 160, so I assumed that since text_length = 100, I should adjust it so x=30 (word starts at 30, is 100 long, should leave 30 at the end to = 160) but that doesn't work, it started the word at 30, but "Map" isn't as long as "Location".
Basically I'm looking to center any text in the Map Name Window. Any help would be appreciated and I hope this is the right posting spot since I'm trying to learn how to do this properly.
def refresh
contents.clear
change_color(normal_color)
unless $game_map.display_name.empty?
# draw_text(0, 0, 100, 20, PAC::MM::Loc_a, 2) GS84 <--this is the line I'm adding in (GS84 = GreyStone84)
draw_text(contents.rect, $game_map.display_name, 1)
end
end
end
My issue comes regarding the content.rect and centering. The contents.rect does a good job centering the map name in the middle of the rectangle, but it was designed for only one line of text. I extended the height of the map name window, no problem, but I also wanted to add in a line of text above the map name to simply say "Location", or "Location", which is the line of code I commented out. Looking around, I found out that I can place a number from 0-2 after the text and it is supposed to be the alignment, but it doesn't center it properly. It's almost like the 0-2 are referring to tabs instead of alignment. I tried to manually switch the x coordinate; window_width returns 160, so I assumed that since text_length = 100, I should adjust it so x=30 (word starts at 30, is 100 long, should leave 30 at the end to = 160) but that doesn't work, it started the word at 30, but "Map" isn't as long as "Location".
Basically I'm looking to center any text in the Map Name Window. Any help would be appreciated and I hope this is the right posting spot since I'm trying to learn how to do this properly.