Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # // Face Frames
- # Author: Rikifive
- # Engine: RPG Maker VX Ace
- # Version: 1.1 (2020-10-03)
- #
- #===============================================================================
- # DESCRIPTION
- #===============================================================================
- # This script draws frames on top of faces displayed in message boxes, menus etc.
- #
- # No work required, the frames are drawn using windowskin.
- # ("Window" image in the Graphics\System folder, that is)
- #
- # You can also make your own custom 96x96 frame images and switch between these
- # on the fly by adjusting in-game variable.
- #
- # Also, by adding this script you'll be able to draw window frames wherever
- # you want. To draw a frame in window contents, use this draw method:
- #
- # > draw_window_frame(x, y, width, height)
- #
- # This will draw window frame in specified coordinates and dimensions,
- # using current windowskin.
- #
- #===============================================================================
- # INSTRUCTIONS
- #===============================================================================
- # ► SCRIPT DIFFICULTY: ★☆☆☆☆
- # This script is basically Plug & Play if you intend to use the windowskin.
- #
- # -=> Place script(s) below ▼ Materials; above ▼ Main Process
- #
- # If you want to use custom images for frames:
- # - Draw a frame with the same dimensions as a single face (96x96)
- # - Name the file: "frame" OR "frame0", "frame1", "frame2"...(see configuration)
- # - Put it/these in PROJECT_NAME\Graphics\Faces
- # - Configure the script below to your needs
- #
- #===============================================================================
- # TERMS OF USE
- #===============================================================================
- # > You ARE allowed to use this script in non-commercial projects.
- # > You ARE allowed to use this script in commercial projects.
- # It's just a little script, so let's not paniK lmao
- # If you'd like to support my works nevertheless, donating any amount
- # would be greatly appreciated. Thank you. c:
- # ( https://paypal.me/rikifive )
- # > You ARE allowed to edit this script to your needs.
- # > You ARE NOT allowed to repost or post modified versions of this script
- # without my permission.
- # > You ARE DEFINITELY NOT allowed to claim this script as your own lmao
- #
- # How to credit me: Just include my name "Rikifive" somewhere in the credits.
- #
- # Good luck!
- #
- #===============================================================================
- # VERSION HISTORY
- #===============================================================================
- # YYYY-MM-DD | Ver
- #------------------
- # 2020-10-03 | 1.1 - Frames from windowskins can handle faces in any size
- # (for better compatibility)
- # 2020-10-02 | 1.0 - Initial Release
- #
- #===============================================================================
- # COMPATIBILITY INFORMATION
- #===============================================================================
- # Overwritten Methods (1)
- # Window_Base - draw_face
- #
- # New Methods (2)
- # Window_Base - draw_window_frame
- # Window_Base - draw_face_bg
- #
- #===============================================================================
- #===============================================================================
- # CONFIGURATION
- #===============================================================================
- module RK5_FRAMES
- # PIXELS to cut out from each side of the face, so that it doesn't leak
- # through the frame (default windowskin's borders are 6px thick)
- FACE_OFFSET = 6
- # Whether to use a special image or automatically draw from the Windowskin
- # true: Requires a 96x96 image titled "frame" in [ Graphics\Faces ]
- # false: No images required, windowskin will be used.
- USE_IMAGE = false
- # Whether you want to use more than one frame image (when above is true)
- # true: /!\ Requires 96x96 images titled "frame0", "frame1" and so on instead.
- # The number after "frame" will correspond to the in-game variable.
- # Example: Setting $game_variables[ID] to 15 will draw "frame15".
- # false: Leave default and use "frame" only.
- USE_VARIANTS = false
- # The variable to use for specifying the frame image (only if above is true).
- # Otherwise set it to whatever number, as it won't impact the game in any way.
- VARIABLE = 77 # ID
- end
- #===============================================================================
- # END OF CONFIGURATION
- #===============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ::: OVERWRITE METHOD
- #--------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, enabled = true)
- fo = RK5_FRAMES::FACE_OFFSET
- bitmap = Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96+fo, face_index / 4 * 96+fo, 96-fo*2, 96-fo*2)
- contents.blt(x+fo, y+fo, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- unless $game_message.busy? && $game_message.face_name.empty?
- if RK5_FRAMES::USE_IMAGE
- draw_face_bg(x, y)
- else
- draw_window_frame(x,y,96,96)
- end
- end
- end
- #--------------------------------------------------------------------------
- # +++ NEW METHOD
- # Draws window frame w/o background (using Windowskin) with specified size
- #--------------------------------------------------------------------------
- def draw_window_frame(x, y, w, h)
- contents.blt(x, y, windowskin, Rect.new(64,0,16,16))
- contents.blt(x+w-16, y, windowskin, Rect.new(112,0,16,16))
- contents.blt(x, y+h-16, windowskin, Rect.new(64,48,16,16))
- contents.blt(x+w-16, y+h-16, windowskin, Rect.new(112,48,16,16))
- i=0
- while i < w-32 do
- contents.blt(x+16+i, y, windowskin, Rect.new(80,0,[w-32-i,32].min,16))
- contents.blt(x+16+i, y+h-16, windowskin, Rect.new(80,48,[w-32-i,32].min,16))
- i+=32
- end
- i=0
- while i < h-32 do
- contents.blt(x, y+16+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min))
- contents.blt(x+w-16, y+16+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min))
- i+=32
- end
- end
- #--------------------------------------------------------------------------
- # +++ NEW METHOD
- # Draws face background from "frame" image(s)
- #--------------------------------------------------------------------------
- def draw_face_bg(x, y)
- s = RK5_FRAMES::USE_VARIANTS ? $game_variables[RK5_FRAMES::VARIABLE].to_s : ""
- bitmap = Cache.face("frame" + s)
- contents.blt(x, y, bitmap, Rect.new(0,0,bitmap.width,bitmap.height))
- bitmap.dispose
- end
- end
Add Comment
Please, Sign In to add comment