Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.60 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - On-Map Item Menu
  4. # Last Date Updated: 2010.06.20
  5. # Level: Normal
  6. #
  7. # This script allows the player to access the on-map item menu by pressing the
  8. # A button on the keyboard. The items that show up on the on-map item menu are
  9. # only items that will begin common events.
  10. #===============================================================================
  11. # Instructions
  12. # -----------------------------------------------------------------------------
  13. # To install this script, open up your script editor and copy/paste this script
  14. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  15. #===============================================================================
  16.  
  17. $imported = {} if $imported == nil
  18. $imported["On-MapItemMenu"] = true
  19.  
  20. #==============================================================================
  21. # ** Window_Map_Item
  22. #==============================================================================
  23.  
  24. class Window_Map_Item < Window_Item
  25.   #--------------------------------------------------------------------------
  26.   # * Object Initialization
  27.   #--------------------------------------------------------------------------
  28.   def initialize
  29.     super(0, 0, 240, 128)
  30.     self.openness = 0
  31.     self.active = false
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # * Refresh
  35.   #--------------------------------------------------------------------------
  36.   def refresh
  37.     @column_max = 1
  38.     self.index = 0 unless @starting
  39.     @starting = true
  40.     @data = []
  41.     for item in $game_party.items
  42.       next unless include?(item)
  43.       @data.push(item)
  44.     end
  45.     @item_max = @data.size
  46.     self.index = [[self.index, @item_max-1].min, 0].max
  47.     self.height = [[128, @item_max*24+32].min, 56].max
  48.     self.y = Graphics.height-self.height
  49.     create_contents
  50.     for i in 0...@item_max
  51.       draw_item(i)
  52.     end
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # * Whether or not to include in item list
  56.   #--------------------------------------------------------------------------
  57.   def include?(item)
  58.     return false if item.nil?
  59.     return false unless item.is_a?(RPG::Item)
  60.     return false if item.common_event_id == 0
  61.     return true
  62.   end
  63. end
  64.  
  65. #==============================================================================
  66. # ** Scene_Map
  67. #==============================================================================
  68.  
  69. class Scene_Map < Scene_Base
  70.   #--------------------------------------------------------------------------
  71.   # * Start processing
  72.   #--------------------------------------------------------------------------
  73.   alias start_sss_on_map_item_menu start unless $@
  74.   def start
  75.     start_sss_on_map_item_menu
  76.     @on_map_help_window = Window_Help.new
  77.     @on_map_item_window = Window_Map_Item.new
  78.     @on_map_item_window.help_window = @on_map_help_window
  79.     @on_map_help_window.opacity = 0
  80.     @on_map_help_window.openness = 0
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Termination Processing
  84.   #--------------------------------------------------------------------------
  85.   alias terminate_sss_on_map_item_menu terminate unless $@
  86.   def terminate
  87.     unless @on_map_item_window.nil?
  88.       @on_map_item_window.dispose
  89.       @on_map_item_window = nil
  90.       @on_map_help_window.dispose
  91.       @on_map_help_window = nil
  92.     end
  93.     terminate_sss_on_map_item_menu
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # * Frame Update
  97.   #--------------------------------------------------------------------------
  98.   alias update_on_map_item_menu update unless $@
  99.   def update
  100.     update_on_map_item_menu
  101.     if not $game_message.visible and not $game_map.interpreter.running?
  102.       map_item_window if Input.trigger?(Input::X)
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # * Update Map Item Window
  107.   #--------------------------------------------------------------------------
  108.   def map_item_window
  109.     disabled = true
  110.     for item in $game_party.items
  111.       next unless item.is_a?(RPG::Item)
  112.       next unless item.common_event_id >= 0
  113.       disabled = false
  114.       break
  115.     end
  116.     return if disabled
  117.     if $imported["LocationName"]
  118.       hidden_location_name = $game_system.hide_location_name
  119.       $game_system.hide_location_name = true
  120.     end
  121.     Sound.play_decision
  122.     @on_map_item_window.refresh
  123.     @on_map_item_window.open
  124.     @on_map_help_window.open
  125.     @on_map_item_window.active = true
  126.     loop do
  127.       update_basic
  128.       @on_map_help_window.update
  129.       @on_map_item_window.update
  130.       if Input.trigger?(Input::C)
  131.         Sound.play_decision
  132.         item = @on_map_item_window.item
  133.         $game_temp.common_event_id = item.common_event_id
  134.         $game_party.consume_item(item)
  135.         break
  136.       elsif Input.trigger?(Input::B)
  137.         Sound.play_cancel
  138.         break
  139.       end
  140.     end
  141.     @on_map_item_window.close
  142.     @on_map_help_window.close
  143.     loop do
  144.       break if @on_map_item_window.openness < 1
  145.       update_basic
  146.       @on_map_help_window.update
  147.       @on_map_item_window.update
  148.     end
  149.     if $imported["LocationName"]
  150.       $game_system.hide_location_name = hidden_location_name
  151.     end
  152.   end
  153. end
  154.  
  155. #===============================================================================
  156. #
  157. # END OF FILE
  158. #
  159. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement