Heirukichi

HSTC-VXAce

Jul 1st, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.06 KB | None | 0 0
  1. #===========================================================================
  2. # HEIRUKICHI SCROLL TEXT CONFIG
  3. #===========================================================================
  4. # - Version 1.1
  5. # Last update: 07-02-2018 [M-D-Y]
  6. #===========================================================================
  7. # TERMS OF USE
  8. #---------------------------------------------------------------------------
  9. # You are free to use this script for both commercial and non commercial
  10. # games as long as you give proper credit to me (Heirukichi).
  11. # I would like to be notified in case you decide to use this script for
  12. # commercial purposes and it would be nice if you could provide me a link to
  13. # the selling page (not a free copy of your game, just a link to its page).
  14. # It would be very appreciated if you could do the same for non-commercial
  15. # games too but that is not mandatory.
  16. #===========================================================================
  17. # DESCRIPTION
  18. #---------------------------------------------------------------------------
  19. # This script allows you to set a new starting coordinates and size for
  20. # Window_ScrollText. This way you can display a scrolling text in just a
  21. # portion of your game screen.
  22. #===========================================================================
  23. # INSTRUCTIONS
  24. #---------------------------------------------------------------------------
  25. # The script is plug and play, just copy/paste it in your materials and it
  26. # is ready to work. No configuration needed.
  27. #
  28. # Window_ScrollText will be untouched until you actually want to resize it.
  29. # When that happens you can use a script call and write
  30. #
  31. #   set_scroll_text_size(new_x, new_y, new_width, new_height)
  32. #
  33. # You have to pass all these parameters even if you want a few of them to be
  34. # the same as the default ones. For that reason you I decided to add the
  35. # default value for each parameter after their description below.
  36. #
  37. # new_x is your new starting x position (default value is 0).
  38. # new_y is your new starting y position (default value is 0).
  39. # new_width is your new window width (default is Graphics.width)
  40. # new_height is your new window height (default is Graphics.height)
  41. #
  42. # Since window width and height cannot be 0 if you set those values to 0
  43. # that change will have no effect at all and the default value is applied
  44. # instead.
  45. #
  46. # After using that in a script call you can just use your Show Scroll Text
  47. # event command as usual.
  48. #===========================================================================
  49. # COMPATIBILITY
  50. #---------------------------------------------------------------------------
  51. # In order to prevent compatibility issues with scripts that overwrite the
  52. # aliased methods place them ABOVE this one.
  53. #---------------------------------------------------------------------------
  54. # METHODS
  55. #---------------------------------------------------------------------------
  56. # Window_ScrollText
  57. #   * resize (new method)
  58. #
  59. # Game_Interpreter
  60. #   * command_105 (aliased method)
  61. #   * resize_scroll_text_window (new method)
  62. #   * set_scroll_text_size (new method)
  63. #===========================================================================
  64. # UPDATES
  65. #---------------------------------------------------------------------------
  66. # Update 1.1
  67. #   - New resize method for Window_ScrollText instead of the overwritten
  68. #     initialize method (Thanks to TheoAllen for pointing this out).
  69. #   - Improved performance when resizing window size.
  70. #===========================================================================
  71.  
  72. module HSTC
  73.  
  74.     STDEFAULT = [0, 0, Graphics.width, Graphics.height]
  75.  
  76.     def self.x
  77.         return value(0)
  78.     end
  79.  
  80.     def self.y
  81.         return value(1)
  82.     end
  83.  
  84.     def self.width
  85.         return value(2)
  86.     end
  87.  
  88.     def self.height
  89.         return value(3)
  90.     end
  91.    
  92.     def self.value(a)
  93.         @values = [] if (@values == nil)
  94.         return (@values[a] == nil ? STDEFAULT[a] : @values[a])
  95.     end
  96.    
  97.     def self.set_size(x, y, width, height)
  98.         @values = []
  99.         @values << x
  100.         @values << y
  101.         @values << (width > 0 ? width : STDEFAULT[2])
  102.         @values << (height > 0 ? height : STDEFAULT[3])
  103.     end
  104.  
  105.     def self.set_to_default
  106.         @values.each { |i| i = nil }
  107.         @values = nil
  108.     end
  109.  
  110.     def self.resized?
  111.         return false if @values == nil
  112.         (0..3).each do |i|
  113.             return true if value(i) != STDEFAULT[i]
  114.         end
  115.         return false
  116.     end
  117.  
  118. end
  119.  
  120. class Window_ScrollText < Window_Base
  121.  
  122.     def resize(x, y, width, height)
  123.         self.x = x
  124.         self.y = y
  125.         self.width = width
  126.         self.height = height
  127.         refresh
  128.     end
  129.  
  130. end
  131.  
  132. class Game_Interpreter
  133.  
  134.     alias hstc_command_105_old    command_105
  135.     def command_105
  136.         resz = HSTC.resized?
  137.         resize_scroll_text_window if resz
  138.         hstc_command_105_old
  139.         if resz
  140.             HSTC.set_to_default
  141.             resize_scroll_text_window
  142.         end
  143.     end
  144.      
  145.     def resize_scroll_text_window
  146.         SceneManager.scene.instance_eval do
  147.             @scroll_text_window.resize(HSTC.x, HSTC.y, HSTC.width, HSTC.height)
  148.         end
  149.     end
  150.    
  151.     def set_scroll_text_size(x, y, width, height)
  152.         HSTC.set_size(x, y, width, height)
  153.     end
  154.  
  155. end
Add Comment
Please, Sign In to add comment