Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===========================================================================
- # HEIRUKICHI SCROLL TEXT CONFIG
- #===========================================================================
- # - Version 1.1
- # Last update: 07-02-2018 [M-D-Y]
- #===========================================================================
- # TERMS OF USE
- #---------------------------------------------------------------------------
- # You are free to use this script for both commercial and non commercial
- # games as long as you give proper credit to me (Heirukichi).
- # I would like to be notified in case you decide to use this script for
- # commercial purposes and it would be nice if you could provide me a link to
- # the selling page (not a free copy of your game, just a link to its page).
- # It would be very appreciated if you could do the same for non-commercial
- # games too but that is not mandatory.
- #===========================================================================
- # DESCRIPTION
- #---------------------------------------------------------------------------
- # This script allows you to set a new starting coordinates and size for
- # Window_ScrollText. This way you can display a scrolling text in just a
- # portion of your game screen.
- #===========================================================================
- # INSTRUCTIONS
- #---------------------------------------------------------------------------
- # The script is plug and play, just copy/paste it in your materials and it
- # is ready to work. No configuration needed.
- #
- # Window_ScrollText will be untouched until you actually want to resize it.
- # When that happens you can use a script call and write
- #
- # set_scroll_text_size(new_x, new_y, new_width, new_height)
- #
- # You have to pass all these parameters even if you want a few of them to be
- # the same as the default ones. For that reason you I decided to add the
- # default value for each parameter after their description below.
- #
- # new_x is your new starting x position (default value is 0).
- # new_y is your new starting y position (default value is 0).
- # new_width is your new window width (default is Graphics.width)
- # new_height is your new window height (default is Graphics.height)
- #
- # Since window width and height cannot be 0 if you set those values to 0
- # that change will have no effect at all and the default value is applied
- # instead.
- #
- # After using that in a script call you can just use your Show Scroll Text
- # event command as usual.
- #===========================================================================
- # COMPATIBILITY
- #---------------------------------------------------------------------------
- # In order to prevent compatibility issues with scripts that overwrite the
- # aliased methods place them ABOVE this one.
- #---------------------------------------------------------------------------
- # METHODS
- #---------------------------------------------------------------------------
- # Window_ScrollText
- # * resize (new method)
- #
- # Game_Interpreter
- # * command_105 (aliased method)
- # * resize_scroll_text_window (new method)
- # * set_scroll_text_size (new method)
- #===========================================================================
- # UPDATES
- #---------------------------------------------------------------------------
- # Update 1.1
- # - New resize method for Window_ScrollText instead of the overwritten
- # initialize method (Thanks to TheoAllen for pointing this out).
- # - Improved performance when resizing window size.
- #===========================================================================
- module HSTC
- STDEFAULT = [0, 0, Graphics.width, Graphics.height]
- def self.x
- return value(0)
- end
- def self.y
- return value(1)
- end
- def self.width
- return value(2)
- end
- def self.height
- return value(3)
- end
- def self.value(a)
- @values = [] if (@values == nil)
- return (@values[a] == nil ? STDEFAULT[a] : @values[a])
- end
- def self.set_size(x, y, width, height)
- @values = []
- @values << x
- @values << y
- @values << (width > 0 ? width : STDEFAULT[2])
- @values << (height > 0 ? height : STDEFAULT[3])
- end
- def self.set_to_default
- @values.each { |i| i = nil }
- @values = nil
- end
- def self.resized?
- return false if @values == nil
- (0..3).each do |i|
- return true if value(i) != STDEFAULT[i]
- end
- return false
- end
- end
- class Window_ScrollText < Window_Base
- def resize(x, y, width, height)
- self.x = x
- self.y = y
- self.width = width
- self.height = height
- refresh
- end
- end
- class Game_Interpreter
- alias hstc_command_105_old command_105
- def command_105
- resz = HSTC.resized?
- resize_scroll_text_window if resz
- hstc_command_105_old
- if resz
- HSTC.set_to_default
- resize_scroll_text_window
- end
- end
- def resize_scroll_text_window
- SceneManager.scene.instance_eval do
- @scroll_text_window.resize(HSTC.x, HSTC.y, HSTC.width, HSTC.height)
- end
- end
- def set_scroll_text_size(x, y, width, height)
- HSTC.set_size(x, y, width, height)
- end
- end
Add Comment
Please, Sign In to add comment