Advertisement
LiTTleDRAgo

[RGSS/2/3] Custom Picture Path

Mar 14th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.38 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Custom Picture Path
  3. # Version: 1.40
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. ($imported ||= {})[:drg_custom_pic_path] = 1.40
  7. #==============================================================================
  8. # ** Interpreter
  9. #------------------------------------------------------------------------------
  10. #  This interpreter runs event commands. This class is used within the
  11. #  Game_System class and the Game_Event class.
  12. #==============================================================================
  13. VX = defined?(Window_ActorCommand)
  14. Klass = VX ? Game_Interpreter : Interpreter
  15. class Klass
  16.   #--------------------------------------------------------------------------
  17.   # * Alias Listing
  18.   #--------------------------------------------------------------------------
  19.   alias custom_pict_command231 command_231 if method_defined?(:command_231)
  20.   #--------------------------------------------------------------------------
  21.   # * Custom Pict
  22.   #--------------------------------------------------------------------------
  23.   def custom_pict(folder='Graphics/Pictures',file='',hue=0)
  24.     @custom_pict = ['custom',folder,file,hue]
  25.     return true
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # * command_231 (Show Picture)
  29.   #--------------------------------------------------------------------------
  30.   def command_231(*args)
  31.     (@parameters||=[])[1] = @custom_pict if !@custom_pict.nil?
  32.     (@params    ||=[])[1] = @custom_pict if !@custom_pict.nil?
  33.     custom_pict_command231(*args)
  34.     @custom_pict = nil
  35.     return true
  36.   end
  37. end
  38. #==============================================================================
  39. # ** Sprite_Picture
  40. #------------------------------------------------------------------------------
  41. #  This sprite is used to display the picture.It observes the Game_Character
  42. #  class and automatically changes sprite conditions.
  43. #==============================================================================
  44. class Sprite_Picture < Sprite
  45.   #--------------------------------------------------------------------------
  46.   # * Alias Listing
  47.   #--------------------------------------------------------------------------
  48.   alias custom_pict_update update  
  49.   #--------------------------------------------------------------------------
  50.   # * Frame Update
  51.   #--------------------------------------------------------------------------
  52.   def update(*args)
  53.     cache = VX ? Cache : RPG::Cache
  54.     if @picture_name != @picture.name and @picture.name[0] == 'custom'
  55.       pic1 = @picture.name[1].to_s
  56.       pic2 = @picture.name[2].to_s
  57.       pic3 = @picture.name[3].to_i
  58.       self.bitmap = cache.load_bitmap(pic1,pic2,pic3) if pic2 != ''
  59.       @picture_name = pic2
  60.       @picture.instance_variable_set(:@name, pic2)
  61.     end
  62.     custom_pict_update(*args)
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Update_Bitmap
  66.   #--------------------------------------------------------------------------
  67.   if method_defined?(:update_bitmap)
  68.     alias custom_pict_update_bitmap update_bitmap  
  69.     def update_bitmap(*args)
  70.       if @picture_name != @picture.name
  71.         custom_pict_update_bitmap(*args)
  72.         @picture_name = @picture.name
  73.       end
  74.     end
  75.   end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement