Guest User

Face Frames (for RPG Maker VX Ace)

a guest
Oct 3rd, 2020
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # // Face Frames
  3. # Author: Rikifive
  4. # Engine: RPG Maker VX Ace
  5. # Version: 1.1 (2020-10-03)
  6. #
  7. #===============================================================================
  8. # DESCRIPTION
  9. #===============================================================================
  10. # This script draws frames on top of faces displayed in message boxes, menus etc.
  11. #
  12. # No work required, the frames are drawn using windowskin.
  13. # ("Window" image in the Graphics\System folder, that is)
  14. #
  15. # You can also make your own custom 96x96 frame images and switch between these
  16. # on the fly by adjusting in-game variable.
  17. #
  18. # Also, by adding this script you'll be able to draw window frames wherever
  19. # you want. To draw a frame in window contents, use this draw method:
  20. #
  21. # > draw_window_frame(x, y, width, height)
  22. #
  23. # This will draw window frame in specified coordinates and dimensions,
  24. # using current windowskin.
  25. #
  26. #===============================================================================
  27. # INSTRUCTIONS
  28. #===============================================================================
  29. # ► SCRIPT DIFFICULTY: ★☆☆☆☆
  30. #   This script is basically Plug & Play if you intend to use the windowskin.
  31. #
  32. # -=> Place script(s) below ▼ Materials; above ▼ Main Process
  33. #
  34. # If you want to use custom images for frames:
  35. # - Draw a frame with the same dimensions as a single face (96x96)
  36. # - Name the file: "frame" OR "frame0", "frame1", "frame2"...(see configuration)
  37. # - Put it/these in PROJECT_NAME\Graphics\Faces
  38. # - Configure the script below to your needs
  39. #
  40. #===============================================================================
  41. # TERMS OF USE
  42. #===============================================================================
  43. # > You ARE allowed to use this script in non-commercial projects.
  44. # > You ARE allowed to use this script in commercial projects.
  45. #     It's just a little script, so let's not paniK lmao
  46. #     If you'd like to support my works nevertheless, donating any amount
  47. #     would be greatly appreciated. Thank you. c:
  48. #     ( https://paypal.me/rikifive )
  49. # > You ARE allowed to edit this script to your needs.
  50. # > You ARE NOT allowed to repost or post modified versions of this script
  51. #     without my permission.
  52. # > You ARE DEFINITELY NOT allowed to claim this script as your own lmao
  53. #
  54. # How to credit me: Just include my name "Rikifive" somewhere in the credits.
  55. #
  56. # Good luck!
  57. #
  58. #===============================================================================
  59. # VERSION HISTORY
  60. #===============================================================================
  61. # YYYY-MM-DD | Ver
  62. #------------------
  63. # 2020-10-03 | 1.1 - Frames from windowskins can handle faces in any size
  64. #                    (for better compatibility)
  65. # 2020-10-02 | 1.0 - Initial Release
  66. #
  67. #===============================================================================
  68. # COMPATIBILITY INFORMATION
  69. #===============================================================================
  70. # Overwritten Methods (1)
  71. #   Window_Base - draw_face
  72. #
  73. # New Methods (2)
  74. #   Window_Base - draw_window_frame
  75. #   Window_Base - draw_face_bg
  76. #
  77. #===============================================================================
  78.  
  79. #===============================================================================
  80. # CONFIGURATION
  81. #===============================================================================
  82. module RK5_FRAMES
  83.   # PIXELS to cut out from each side of the face, so that it doesn't leak
  84.   # through the frame (default windowskin's borders are 6px thick)
  85.   FACE_OFFSET = 6
  86.  
  87.   # Whether to use a special image or automatically draw from the Windowskin
  88.   # true: Requires a 96x96 image titled "frame" in [ Graphics\Faces ]
  89.   # false: No images required, windowskin will be used.
  90.   USE_IMAGE = false
  91.  
  92.   # Whether you want to use more than one frame image (when above is true)
  93.   # true: /!\ Requires 96x96 images titled "frame0", "frame1" and so on instead.
  94.   #       The number after "frame" will correspond to the in-game variable.
  95.   #       Example: Setting $game_variables[ID] to 15 will draw "frame15".
  96.   # false: Leave default and use "frame" only.
  97.   USE_VARIANTS = false
  98.  
  99.   # The variable to use for specifying the frame image (only if above is true).
  100.   # Otherwise set it to whatever number, as it won't impact the game in any way.
  101.   VARIABLE = 77 # ID
  102. end
  103. #===============================================================================
  104. # END OF CONFIGURATION
  105. #===============================================================================
  106.  
  107. class Window_Base < Window
  108.   #--------------------------------------------------------------------------
  109.   # ::: OVERWRITE METHOD
  110.   #--------------------------------------------------------------------------
  111.   def draw_face(face_name, face_index, x, y, enabled = true)
  112.     fo = RK5_FRAMES::FACE_OFFSET
  113.     bitmap = Cache.face(face_name)
  114.     rect = Rect.new(face_index % 4 * 96+fo, face_index / 4 * 96+fo, 96-fo*2, 96-fo*2)
  115.     contents.blt(x+fo, y+fo, bitmap, rect, enabled ? 255 : translucent_alpha)
  116.     bitmap.dispose
  117.     unless $game_message.busy? && $game_message.face_name.empty?
  118.       if RK5_FRAMES::USE_IMAGE
  119.         draw_face_bg(x, y)
  120.       else
  121.         draw_window_frame(x,y,96,96)
  122.       end
  123.     end
  124.   end
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # +++ NEW METHOD
  128.   # Draws window frame w/o background (using Windowskin) with specified size
  129.   #--------------------------------------------------------------------------
  130.   def draw_window_frame(x, y, w, h)
  131.     contents.blt(x, y, windowskin, Rect.new(64,0,16,16))
  132.     contents.blt(x+w-16, y, windowskin, Rect.new(112,0,16,16))
  133.     contents.blt(x, y+h-16, windowskin, Rect.new(64,48,16,16))
  134.     contents.blt(x+w-16, y+h-16, windowskin, Rect.new(112,48,16,16))
  135.     i=0
  136.     while i < w-32 do
  137.       contents.blt(x+16+i, y, windowskin, Rect.new(80,0,[w-32-i,32].min,16))
  138.       contents.blt(x+16+i, y+h-16, windowskin, Rect.new(80,48,[w-32-i,32].min,16))
  139.       i+=32
  140.     end
  141.     i=0
  142.     while i < h-32 do
  143.       contents.blt(x, y+16+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min))
  144.       contents.blt(x+w-16, y+16+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min))
  145.       i+=32
  146.     end
  147.    
  148.   end
  149.  
  150.   #--------------------------------------------------------------------------
  151.   # +++ NEW METHOD
  152.   # Draws face background from "frame" image(s)
  153.   #--------------------------------------------------------------------------
  154.   def draw_face_bg(x, y)
  155.     s = RK5_FRAMES::USE_VARIANTS ? $game_variables[RK5_FRAMES::VARIABLE].to_s : ""
  156.     bitmap = Cache.face("frame" + s)
  157.     contents.blt(x, y, bitmap, Rect.new(0,0,bitmap.width,bitmap.height))
  158.     bitmap.dispose
  159.   end
  160. end
RAW Paste Data