Advertisement
DrDhoom

[RGSS2] Center Message Align

Apr 5th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.36 KB | None | 0 0
  1. # [VX] Center Message Alignment with Fade In
  2. # Author: DrDhoom
  3. # Date: 06-04-2013
  4.  
  5. class Window_Message < Window_Selectable
  6.  
  7.   def update_message
  8.     loop do
  9.       c = @text.slice!(/./m)            # Get next text character
  10.       case c
  11.       when nil                          # There is no text that must be drawn
  12.         finish_message                  # Finish update
  13.         break
  14.       when "\x00"                       # New line
  15.         update_display_text        
  16.         @text_display = ""
  17.         new_line
  18.         if @line_count >= MAX_LINE      # If line count is maximum
  19.           unless @text.empty?           # If there is more
  20.             self.pause = true           # Insert number input
  21.             break
  22.           end
  23.         end
  24.       when "\x01"                       # \C[n]  (text character color change)
  25.         @text.sub!(/\[([0-9]+)\]/, "")
  26.         contents.font.color = text_color($1.to_i)
  27.         next
  28.       when "\x02"                       # \G  (gold display)
  29.         @gold_window.refresh
  30.         @gold_window.open
  31.       when "\x03"                       # \.  (wait 1/4 second)
  32.         @wait_count = 15
  33.         break
  34.       when "\x04"                       # \|  (wait 1 second)
  35.         @wait_count = 60
  36.         break
  37.       when "\x05"                       # \!  (Wait for input)
  38.         self.pause = true
  39.         break
  40.       when "\x06"                       # \>  (Fast display ON)
  41.         @line_show_fast = true
  42.       when "\x07"                       # \<  (Fast display OFF)
  43.         @line_show_fast = false
  44.       when "\x08"                       # \^  (No wait for input)
  45.         @pause_skip = true
  46.       else                              # Normal text character
  47.         @text_display = "" if @text_display == nil
  48.         @text_display += c
  49.       end
  50.     end
  51.   end
  52.  
  53.   def update_display_text
  54.     @color = contents.font.color.clone
  55.     @color.alpha = 0    
  56.     Sound.play_cursor
  57.     loop do
  58.       if @show_fast or @line_show_fast
  59.         @color.alpha = 255
  60.       end
  61.       Graphics.update
  62.       Input.update
  63.       update_show_fast
  64.       contents.clear_rect(0,@contents_y, contents.width, WLH)
  65.       @color.alpha += 16
  66.       contents.font.color = @color
  67.       contents.draw_text(0, @contents_y, contents.width, WLH, @text_display,1)
  68.       if @color.alpha == 255
  69.         break
  70.       end
  71.     end
  72.   end  
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement