Solistra

SES Time: Wait Extension

Dec 4th, 2012
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.05 KB | None | 0 0
  1. #═╦═════════════════════════════════════════════════════════════════════════════
  2. # ║ § SES - Time: Wait (v1.1) by Solistra                [License: CC BY-SA 3.0]
  3. # ║                                                            <RMVX Ace>
  4. #═╬═════════════════════════════════════════════════════════════════════════════
  5. # ║ § Change Log
  6. #─╫─────────────────────────────────────────────────────────────────────────────
  7. # ║ v1.1 (January 4th, 2013) - Compatibility fix to work with Dynamic Time v1.3.
  8. # ║ v1.0 (December 4th, 2012) - Initial release
  9. # ║
  10. #═╬═════════════════════════════════════════════════════════════════════════════
  11. # ║ § Summary
  12. #─╫─────────────────────────────────────────────────────────────────────────────
  13. # ║ This is a simple extension to the SES Dynamic Time script which allows the
  14. # ║ player to call a "wait" scene that will allow them to wait for an amount of
  15. # ║ time on the map.
  16. # ║
  17. #═╬═════════════════════════════════════════════════════════════════════════════
  18. # ║ § Required Scripts
  19. #─╫─────────────────────────────────────────────────────────────────────────────
  20. # ║ The SES Dynamic Time script (version 1.3 or higher) is required in order to
  21. # ║ use this script.
  22. # ║
  23. #═╬═════════════════════════════════════════════════════════════════════════════
  24. # ║ § Known Incompatibilities
  25. #─╫─────────────────────────────────────────────────────────────────────────────
  26. # ║ See the SES Dynamic Time script for known incompatibilities.
  27. # ║
  28. #═╬═════════════════════════════════════════════════════════════════════════════
  29. # ║ § Installation
  30. #─╫─────────────────────────────────────────────────────────────────────────────
  31. # ║ Place this script below the SES Dynamic Time script, above any other custom
  32. # ║ scripts, and above Main.
  33. # ║
  34. #═╬═════════════════════════════════════════════════════════════════════════════
  35. # ║ § Configuration
  36. #─╫─────────────────────────────────────────────────────────────────────────────
  37. # ║ This is a relatively simple scene. In the configuration area, simply set
  38. # ║ which unit of time you want the scene to use, the name of this unit as it
  39. # ║ will appear in the scene, the input key that players will use to call the
  40. # ║ scene from the map, and the maximum amount of time that the player is
  41. # ║ allowed to wait.
  42. # ║
  43. # ║ For those of you who are completely insane (or just like customizing things
  44. # ║ far too much for your own good), you can also change the x, y, width, and
  45. # ║ height values for the two windows used in the scene.
  46. # ║
  47. #═╬═════════════════════════════════════════════════════════════════════════════
  48. # ║ § Tags
  49. #─╫─────────────────────────────────────────────────────────────────────────────
  50. # ║ ● Map
  51. # ║   <time no_wait>
  52. # ║     Suppresses waiting on this map only.
  53. # ║
  54. #═╬═════════════════════════════════════════════════════════════════════════════
  55. # ║ § Aliased Methods
  56. #─╫─────────────────────────────────────────────────────────────────────────────
  57. # ║ ● Scene_Map
  58. # ║     update
  59. # ║
  60. #═╬═════════════════════════════════════════════════════════════════════════════
  61. # ║ § New Methods
  62. #─╫─────────────────────────────────────────────────────────────────────────────
  63. # ║ ● Game_Map
  64. # ║     no_wait?
  65. # ║ ● Scene_Map
  66. # ║     update_call_wait
  67. # ║     call_wait
  68. # ║
  69. #═╬═════════════════════════════════════════════════════════════════════════════
  70. # ║ ▼ module SES::Time::Wait
  71. #═╩═════════════════════════════════════════════════════════════════════════════
  72. module SES module Time module Wait
  73.   #═╦═══════════════════════════════════════════════════════════════════════════
  74.   # ║ α BEGIN CONFIGURATION
  75.   #═╩═══════════════════════════════════════════════════════════════════════════
  76.   # The unit of time (and its name) to use for waiting.
  77.   UNIT = :hour
  78.   UNIT_NAME = "hour"
  79.  
  80.   # The input key used to call the wait scene on the map.
  81.   KEY = :R
  82.  
  83.   # The maximum amount of time that the player may wait.
  84.   MAX = 24
  85.  
  86.   # The x, y, width, and height of the wait window and command window for the
  87.   # scene. (Note: the command window's height cannot be changed this way.)
  88.   WIN_ARGS = [Graphics.width / 2 - 100, Graphics.height / 2 - 48, 200, 48]
  89.   CMD_ARGS = [Graphics.width / 2 - 100, Graphics.height / 2, 200]
  90.   #═╦═══════════════════════════════════════════════════════════════════════════
  91.   # ║ Ω END CONFIGURATION
  92.   #─╫───────────────────────────────────────────────────────────────────────────
  93.   # ║ ▼ class Window_Wait
  94.   #═╩═══════════════════════════════════════════════════════════════════════════
  95.   class Window_Wait < Window_Base
  96.     attr_accessor :amount
  97.    
  98.     def initialize() @amount = 1; super(*WIN_ARGS); refresh end
  99.    
  100.     def refresh
  101.       self.contents.clear
  102.       text = "Wait #{@amount} " << (@amount > 1 ? "#{UNIT_NAME}s" : UNIT_NAME)
  103.       text << "?"
  104.       draw_text(self.contents.rect, text, 1)
  105.     end
  106.   end
  107.   #═╦═══════════════════════════════════════════════════════════════════════════
  108.   # ║ ▲ class Window_Wait
  109.   #─╫───────────────────────────────────────────────────────────────────────────
  110.   # ║ ▼ class Window_WaitCommand
  111.   #═╩═══════════════════════════════════════════════════════════════════════════
  112.   class Window_WaitCommand < Window_Command
  113.     def initialize() super(*CMD_ARGS[0..1]) end
  114.     def window_width() CMD_ARGS.last end
  115.    
  116.     def make_command_list
  117.       add_command("OK", :ok)
  118.       add_command(Vocab::cancel, :cancel)
  119.     end
  120.   end
  121.   #═╦═══════════════════════════════════════════════════════════════════════════
  122.   # ║ ▲ class Window_Wait
  123.   #─╫───────────────────────────────────────────────────────────────────────────
  124.   # ║ ▼ class Scene
  125.   #═╩═══════════════════════════════════════════════════════════════════════════
  126.   class Scene < Scene_MenuBase
  127.     def start() super; create_wait_windows end
  128.    
  129.     def create_wait_windows
  130.       @wait_window = Wait::Window_Wait.new
  131.       @command_window = Wait::Window_WaitCommand.new
  132.       @command_window.set_handler(:ok, method(:process_ok))
  133.       @command_window.set_handler(:cancel, method(:return_scene))
  134.     end
  135.    
  136.     def update
  137.       super
  138.       update_amount if Input.repeat?(:LEFT) || Input.repeat?(:RIGHT)
  139.     end
  140.    
  141.     def process_ok
  142.       $game_system.time.traverse(UNIT, @wait_window.amount)
  143.       return_scene
  144.     end
  145.    
  146.     def update_amount
  147.       return if @wait_window.amount <= 1 && Input.repeat?(:LEFT)
  148.       return if @wait_window.amount >= MAX && Input.repeat?(:RIGHT)
  149.       Sound.play_cursor
  150.       @wait_window.amount -= 1 if Input.repeat?(:LEFT)
  151.       @wait_window.amount += 1 if Input.repeat?(:RIGHT)
  152.       @wait_window.refresh
  153.     end
  154.   end
  155.   #═╦═══════════════════════════════════════════════════════════════════════════
  156.   # ║ ▲ class Scene
  157.   #═╩═══════════════════════════════════════════════════════════════════════════
  158. end end end
  159. #═╦═════════════════════════════════════════════════════════════════════════════
  160. # ║ ▲ module SES::Time::Wait
  161. #═╩═════════════════════════════════════════════════════════════════════════════
  162.                   ($imported ||= {})["SES - Time: Wait"] = 1.1
  163.         if $imported["SES - Time"].nil? || $imported["SES - Time"] < 1.3
  164.               raise("SES Wait requires SES Time v1.3 or greater.")
  165.                                       end
  166. #═╦═════════════════════════════════════════════════════════════════════════════
  167. # ║ ▼ class Game_Map
  168. #═╩═════════════════════════════════════════════════════════════════════════════
  169. class Game_Map
  170.   def no_wait?(map = @map)
  171.     (map.note =~ /\<time no\_wait\>/ ? true : false) unless map.nil?
  172.   end
  173. end
  174. #═╦═════════════════════════════════════════════════════════════════════════════
  175. # ║ ▲ class Game_Map
  176. #─╫─────────────────────────────────────────────────────────────────────────────
  177. # ║ ▼ class Scene_Map
  178. #═╩═════════════════════════════════════════════════════════════════════════════
  179. class Scene_Map < Scene_Base
  180.   alias :ses_time_wait_map_upd :update
  181.   def update(*args, &block)
  182.     ses_time_wait_map_upd(*args, &block)
  183.     update_call_wait unless $game_map.no_wait?
  184.   end
  185.  
  186.   def update_call_wait() call_wait if Input.trigger?(SES::Time::Wait::KEY) end
  187.   def call_wait() Sound.play_ok; SceneManager.call(SES::Time::Wait::Scene) end
  188. end
  189. #═╦═════════════════════════════════════════════════════════════════════════════
  190. # ║ ▲ class Scene_Map
  191. #═╩═════════════════════════════════════════════════════════════════════════════
Advertisement
Add Comment
Please, Sign In to add comment