Fixed newline bug
This commit is contained in:
parent
1fd808d0af
commit
7c622769ad
|
|
@ -107,22 +107,10 @@ class Window_Message < Window_Selectable
|
||||||
x = y = 0
|
x = y = 0
|
||||||
maxwidth = self.contents.width - 4 - ($game_temp.message_face == nil ? 0 : 96)
|
maxwidth = self.contents.width - 4 - ($game_temp.message_face == nil ? 0 : 96)
|
||||||
spacewidth = self.contents.text_size(' ').width
|
spacewidth = self.contents.text_size(' ').width
|
||||||
for i in text.split(' ')
|
text.split("\n").each do |line|
|
||||||
# Split each word around newlines
|
line.split(' ').each do |word|
|
||||||
newline = false
|
# Get width of this word and insert a newline if it goes out of bounds
|
||||||
for j in i.split("\n")
|
width = self.contents.text_size(word.gsub(/(\000\[[0-9]+\]|\001|\002)/, '')).width
|
||||||
# Handle newline
|
|
||||||
if newline
|
|
||||||
@text << "\n"
|
|
||||||
x = 0
|
|
||||||
y += 1
|
|
||||||
break if y >= 4
|
|
||||||
else
|
|
||||||
newline = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get width of this word and see if it goes out of bounds
|
|
||||||
width = self.contents.text_size(j.gsub(/(\000\[[0-9]+\]|\001|\002)/, '')).width
|
|
||||||
if x + width > maxwidth
|
if x + width > maxwidth
|
||||||
@text << "\n"
|
@text << "\n"
|
||||||
x = 0
|
x = 0
|
||||||
|
|
@ -132,12 +120,17 @@ class Window_Message < Window_Selectable
|
||||||
|
|
||||||
# Append word to list
|
# Append word to list
|
||||||
if x == 0
|
if x == 0
|
||||||
@text << j
|
@text << word
|
||||||
else
|
else
|
||||||
@text << ' ' << j
|
@text << ' ' << word
|
||||||
end
|
end
|
||||||
x += width + spacewidth
|
x += width + spacewidth
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Newline
|
||||||
|
@text << "\n"
|
||||||
|
x = 0
|
||||||
|
y += 1
|
||||||
break if y >= 4
|
break if y >= 4
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue