IceDragon200

ScrollingWindowHelp(Cozziekuns) Ice Edit

Nov 12th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.41 KB | None | 0 0
  1. #===============================================================================
  2. # Scrolling Window_Help
  3. #-------------------------------------------------------------------------------
  4. # Version: 1.1a
  5. # Author: Cozziekuns (rmrk)
  6. # Last Date Updated: 12/6/2011
  7. #===============================================================================
  8. # Description:
  9. #-------------------------------------------------------------------------------
  10. # This script allows you to auto scroll the text in Window_Help if it becomes
  11. # too long for the window to hold. Originally, RPG Maker would auto resize the
  12. # text to make it thin and aesthetically displeasing to the eye.
  13. #===============================================================================
  14. # Updates
  15. # ------------------------------------------------------------------------------
  16. # o 12/06/2011 - Started Script
  17. # o 09/07/2011 - Updated script with a bugfix.
  18. #===============================================================================
  19. # Instructions
  20. # ------------------------------------------------------------------------------
  21. # Copy and paste this script above ? Main Process but below ? Materials, and
  22. # edit the modules to your liking.
  23. #===============================================================================
  24.  
  25. module COZZIEKUNS
  26.   module SCROLLING_WINDOW_HELP
  27.     SCROLL_SPEED = 1 # The higher the scroll speed, the faster the text will scroll.
  28.     SCROLL_REFRESH_RATE = 1 # The lower the refresh rate, the faster the text will scroll.
  29.     SCROLL_INITIAL_WAIT = 60 # The amount of time before the text starts to scroll (in milliseconds)
  30.   end
  31. end
  32.  
  33. #==============================================================================
  34. # ** Window_Help
  35. #------------------------------------------------------------------------------
  36. #  This window shows skill and item explanations along with actor status.
  37. #==============================================================================
  38.  
  39. class Window_Help < Window_Base
  40.   #--------------------------------------------------------------------------
  41.   # * Object Initialization
  42.   #--------------------------------------------------------------------------
  43.   alias coz_scrolltxt_wh_14199_initialize initialize
  44.   def initialize(*args)
  45.     coz_scrolltxt_wh_14199_initialize
  46.     @relative_contents = Bitmap.new( self.width-32, self.height-32 )
  47.     @relative_contents.font = self.contents.font
  48.     @scroll = false
  49.     @frames = 0
  50.   end
  51.  
  52.   def dispose()
  53.     @relative_contents.dispose() ; @relative_contents = nil
  54.     super()
  55.   end
  56.  
  57.   #--------------------------------------------------------------------------
  58.   # * Set Text
  59.   #  text  : character string displayed in window
  60.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  61.   #--------------------------------------------------------------------------
  62.   def set_text(text, align = 0)
  63.     if text != @text or align != @align
  64.       #//@relative_contents.dispose() unless @relative_contents.nil?()
  65.       self.contents.dispose()
  66.       text_width = @relative_contents.text_size(text).width + 40 > @relative_contents.width - 40
  67.       text_width = false if align != 0
  68.       self.contents.dispose()
  69.       if text_width
  70.         self.contents = Bitmap.new(self.width + @relative_contents.text_size(text).width + 8, self.height - 32)
  71.         @scroll = true
  72.       else
  73.         self.contents = Bitmap.new(self.width - 32, self.height - 32)
  74.         @scroll = false
  75.       end
  76.       self.ox = 0
  77.       #//self.contents.clear
  78.       self.contents.font.color = normal_color
  79.       self.contents.draw_text(4, 0, text_width ? self.contents.text_size(text).width : self.width - 40, WLH, text, align)
  80.       @text = text
  81.       @align = align
  82.       @frames = 0
  83.     end
  84.   end
  85.  
  86.   #--------------------------------------------------------------------------
  87.   # * Frame Update
  88.   #--------------------------------------------------------------------------
  89.   def update
  90.     @frames += 1
  91.     f_refresh = COZZIEKUNS::SCROLLING_WINDOW_HELP::SCROLL_REFRESH_RATE
  92.     f_wait = COZZIEKUNS::SCROLLING_WINDOW_HELP::SCROLL_INITIAL_WAIT
  93.     speed = COZZIEKUNS::SCROLLING_WINDOW_HELP::SCROLL_SPEED
  94.     if @scroll == true
  95.       if (Graphics.frame_count % f_refresh == 0) and @frames >= f_wait
  96.         self.ox += speed
  97.       end
  98.       if self.ox >= self.contents.text_size(@text).width
  99.         self.ox = -self.contents.text_size(@text).width / 2
  100.       end
  101.     end
  102.   end
  103.  
  104. end
  105.  
Advertisement
Add Comment
Please, Sign In to add comment