Advertisement
kurashi

Character instead of Faces

Jul 11th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.17 KB | None | 0 0
  1. # Character instead of Faces
  2. #
  3. # Do note that your Actor Face image and your Actor Sprite
  4. # image must be named the same and in the same order.
  5.  
  6. module Customization
  7.     module Window_Message
  8.         USE        = true
  9.         DIRECTION  = 0   # Default 0
  10.         ZOOM       = 2.5 # Default 2.5
  11.         X_OFFSET   = 50  # Default 50
  12.         Y_OFFSET   = 80  # Default 80
  13.     end
  14. end
  15.  
  16. # DO NOT EDIT BEYOND THIS POINT!
  17. class Window_Message
  18.     attr_reader   :frame
  19.     attr_reader   :frame_counter
  20.    
  21.     alias :kurashi_message_window_initialize :initialize
  22.     def initialize
  23.     kurashi_message_window_initialize    #(0, 0, window_width, window_height)
  24.     end
  25.  
  26.     def new_page(text, pos)
  27.         contents.clear
  28.         if Customization::Window_Message::USE
  29.       draw_character($game_message.face_name, $game_message.face_index,
  30.                      Customization::Window_Message::X_OFFSET,
  31.                      Customization::Window_Message::Y_OFFSET, 1)
  32.         else
  33.             draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  34.         end
  35.         reset_font_settings
  36.         pos[:x] = new_line_x
  37.         pos[:y] = 0
  38.         pos[:new_x] = new_line_x
  39.         pos[:height] = calc_line_height(text)
  40.         clear_flags
  41.     end
  42.  
  43. #~   def draw_face(face_name, face_index, x, y, enabled = true)
  44. #~     bitmap = Cache.face(face_name)
  45. #~     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  46. #~     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  47. #~     bitmap.dispose
  48. #~   end
  49.  
  50.     def draw_character(character_name, character_index, x, y, frame = 1)
  51.         return unless character_name
  52.         bitmap = Cache.character(character_name)
  53.         sign = character_name[/^[\!\$]./]
  54.         if sign && sign.include?('$')
  55.             cw = bitmap.width / 3
  56.             ch = bitmap.height / 4
  57.         else
  58.             cw = bitmap.width / 12
  59.             ch = bitmap.height / 8
  60.         end
  61.      
  62.         n = character_index
  63.         src_rect = Rect.new((n%4*3+frame)*cw,
  64.                             (ch * Customization::Window_Message::DIRECTION)+(n/4*4)*ch,
  65.                              cw, ch)
  66.         ret_rect = Rect.new(x - cw, y - ch * Customization::Window_Message::ZOOM,
  67.                             cw * Customization::Window_Message::ZOOM,
  68.                             ch * Customization::Window_Message::ZOOM)
  69.         contents.stretch_blt(ret_rect, bitmap, src_rect)
  70.     end
  71.  
  72. end # Window_Message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement