From 154681d8539e770e041372a665b9f3ef333c882a Mon Sep 17 00:00:00 2001 From: Michael Shirt Date: Mon, 26 Sep 2016 08:55:01 -0600 Subject: [PATCH] Added Message box functionality This adds 2 new things to the vanilla text box. "\>" will now make the script wait for user input before continuing to display text. "\@facepic_name" will change the face graphic to facepic_name without needing to reopen the message window. --- scripts/Window_Message.rb | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/scripts/Window_Message.rb b/scripts/Window_Message.rb index e266fdf..cc22346 100644 --- a/scripts/Window_Message.rb +++ b/scripts/Window_Message.rb @@ -105,6 +105,10 @@ class Window_Message < Window_Selectable text.gsub!(/\\c\[([0-9]+)\]/, "\0[\\1]") text.gsub!("\\.", "\001") text.gsub!("\\|", "\002") + text.gsub!("\\>", "\004") + + + text.gsub!("\\@", "\003") # Finally convert the backslash back text.gsub!("\\\\", "\\") @@ -114,6 +118,10 @@ class Window_Message < Window_Selectable spacewidth = self.contents.text_size(' ').width text.split("\n").each do |line| line.split(' ').each do |word| + if word.start_with?('\003') + #ignore new facepics + next + end # Get width of this word and insert a newline if it goes out of bounds width = self.contents.text_size(word.gsub(/(\000\[[0-9]+\]|\001|\002)/, '')).width if x + width > maxwidth @@ -211,6 +219,24 @@ class Window_Message < Window_Selectable @text_pause = 10*4 return end + if c == "\003" + # new facepic + face_name = "" + c2 = @text.slice!(0) + while c2 != " " + face_name += c2 + c2 = @text.slice!(0) + end + self.contents.fill_rect(self.contents.width - 96, 0, 96, 96, Color.new(0,0,0,0)) + $game_temp.message_face = face_name + face = RPG::Cache.face($game_temp.message_face) + self.contents.blt(self.contents.width - 96, 0, face, Rect.new(0, 0, 96, 96)) + return + end + if c == "\004" + @drawing_text = false + return + end # Draw text self.contents.draw_text(4 + @text_x, 24 * @text_y, 40, 24, c) # Add x to drawn text width @@ -373,7 +399,11 @@ class Window_Message < Window_Selectable # Advance/Close message if Input.trigger?(Input::ACTION) || Input.trigger?(Input::CANCEL) - terminate_message + if @text.length <= 0 + terminate_message + else + @drawing_text = true + end end end end