IceDragon200

FRV-ItemMenu

Jun 3rd, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.40 KB | None | 0 0
  1. # // Last Modified :06/08/2011
  2. #==============================================================================#
  3. # FRV::ITEM_SYSTEM
  4. #==============================================================================#
  5. module FRV
  6.   module ITEM_SYSTEM
  7.    
  8.     ITEM_GROUPS = [
  9.       "Items",
  10.       "Equipment",
  11.       "Key Items",
  12.     ]
  13.    
  14.   end
  15. end
  16.  
  17. #==============================================================================#
  18. # RPG::BaseItem
  19. #==============================================================================#
  20. class RPG::BaseItem
  21.  
  22.   #--------------------------------------------------------------------------#
  23.   # * Public Instance Variables
  24.   #--------------------------------------------------------------------------#  
  25.   attr_accessor :sort_group
  26.  
  27.   #--------------------------------------------------------------------------#
  28.   # * new method :frv_ite_baseitem_cache
  29.   #--------------------------------------------------------------------------#  
  30.   def frv_ite_baseitem_cache()
  31.     @sort_group = []
  32.     case self
  33.     when RPG::Armor
  34.       @sort_group << "Armors".upcase()
  35.       @sort_group << "Equipment".upcase()
  36.     when RPG::Item
  37.       if @price > 0
  38.         @sort_group << "Items".upcase()
  39.       else
  40.         @sort_group << "Key Items".upcase()
  41.       end  
  42.     when RPG::Weapon
  43.       @sort_group << "Weapons".upcase()
  44.       @sort_group << "Equipment".upcase()
  45.     when RPG::Skill
  46.       @sort_group << "Skill".upcase()
  47.     end
  48.   end
  49.  
  50. end  
  51.  
  52. #==============================================================================#
  53. # Game_System
  54. #==============================================================================#
  55. class Game_System
  56.  
  57.   #--------------------------------------------------------------------------#
  58.   # * Public Instance Variables
  59.   #--------------------------------------------------------------------------#  
  60.   attr_accessor :item_groups
  61.  
  62.   #--------------------------------------------------------------------------#
  63.   # * alias method :initialize
  64.   #--------------------------------------------------------------------------#  
  65.   alias :ieo_frv_gs_initialize :initialize unless $@
  66.   def initialize()
  67.     ieo_frv_gs_initialize()
  68.     @item_groups = ::FRV::ITEM_SYSTEM::ITEM_GROUPS
  69.   end
  70.  
  71. end
  72.  
  73. #==============================================================================#
  74. # Window_ItemHelp
  75. #==============================================================================#
  76. class Window_ItemHelp < IRS::Sprite_Help ; end
  77.  
  78. #==============================================================================#
  79. # Window_ItemCommand
  80. #==============================================================================#
  81. class Window_ItemCommand < Window_Command ; end
  82.  
  83. #==============================================================================#
  84. # Window_ItemSorted
  85. #==============================================================================#
  86. class Window_ItemSorted < Window_Item
  87.  
  88.   #--------------------------------------------------------------------------#
  89.   # * Public Instance Variables
  90.   #--------------------------------------------------------------------------#  
  91.   attr_accessor :sort_group
  92.  
  93.   #--------------------------------------------------------------------------#
  94.   # * overwrite method :initialize
  95.   #--------------------------------------------------------------------------#  
  96.   def include?( item )
  97.     @sort_group = $game_system.item_groups[0] if @sort_group.nil?()
  98.     return false if item == nil
  99.     return unless item.sort_group.include?( @sort_group.upcase )
  100.     if $game_temp.in_battle
  101.       return false unless item.is_a?(RPG::Item)
  102.     end
  103.     return true
  104.   end
  105.  
  106. end  
  107.  
  108. #==============================================================================#
  109. # Scene_Title
  110. #==============================================================================#
  111. class Scene_Title < Scene_Base
  112.  
  113.   #--------------------------------------------------------------------------#
  114.   # * alias method :load_database
  115.   #--------------------------------------------------------------------------#
  116.   alias :frv_ite_sct_load_database :load_database unless $@
  117.   def load_database()
  118.     frv_ite_sct_load_database()
  119.     load_frv_ite_cache()
  120.   end
  121.  
  122.   #--------------------------------------------------------------------------#
  123.   # * alias method :load_bt_database
  124.   #--------------------------------------------------------------------------#
  125.   alias :frv_ite_sct_load_bt_database :load_database unless $@
  126.   def load_bt_database()
  127.     frv_ite_sct_load_bt_database()
  128.     load_frv_ite_cache()
  129.   end  
  130.  
  131.   #--------------------------------------------------------------------------#
  132.   # * new method :load_ieo003_cache
  133.   #--------------------------------------------------------------------------#
  134.   def load_frv_ite_cache()
  135.     objs = [$data_items, $data_weapons, $data_armors]
  136.     objs.each { |group| group.each { |obj|
  137.       next if obj.nil?() ; obj.frv_ite_baseitem_cache() } }
  138.   end
  139.  
  140. end
  141.  
  142. #==============================================================================#
  143. # Scene_Item
  144. #==============================================================================#
  145. class Scene_Item < Scene_Base
  146.  
  147.   #--------------------------------------------------------------------------#
  148.   # * overwrite method :start
  149.   #--------------------------------------------------------------------------#
  150.   def start()
  151.     super()
  152.     create_menu_background()
  153.     @viewport = Viewport.new( 0, 0, Graphics.width, Graphics.height )
  154.     @help_window = Window_ItemHelp.new( 0, 0, Graphics.width, 32 )
  155.     @help_window.viewport = @viewport
  156.     @group_window = Window_ItemCommand.new( Graphics.width,
  157.      $game_system.item_groups, $game_system.item_groups.size )
  158.     @group_window.y = @help_window.height
  159.     @group_window.active = false
  160.     @item_window = Window_ItemSorted.new( 0, 32+56,
  161.      Graphics.width, Graphics.height-32-56-32 )
  162.     @item_window.viewport = @viewport
  163.     @item_window.help_window = @help_window
  164.     @item_window.active = false
  165.     @target_window = Window_MenuStatus.new(0, 0)
  166.     @inputhelp_window = Window_ItemHelp.new( 0, Graphics.height-32, Graphics.width, 32 )
  167.     @inputhelp_window.align = 1
  168.     @inputhelp_window.set_text("Use A and S to switch Catergories")
  169.     hide_target_window()
  170.     # // ----------------------------------------------------------------- // #
  171.     @menuback_sprite.bitmap = Cache.system( "Menu_background" )
  172.     @menuback_sprite.opacity= 255
  173.   end
  174.  
  175.   #--------------------------------------------------------------------------#
  176.   # * overwrite method :terminate
  177.   #--------------------------------------------------------------------------#
  178.   def terminate()
  179.     super()
  180.     dispose_menu_background()
  181.     @viewport.dispose()
  182.     @help_window.dispose()
  183.     @item_window.dispose()
  184.     @target_window.dispose()
  185.     @group_window.dispose()
  186.     @inputhelp_window.dispose()
  187.   end
  188.  
  189.   #--------------------------------------------------------------------------#
  190.   # * overwrite method :update
  191.   #--------------------------------------------------------------------------#  
  192.   def update
  193.     super
  194.     update_menu_background()
  195.     @help_window.update()
  196.     @item_window.update()
  197.     @target_window.update()
  198.     if @item_window.active
  199.       update_group_selection()
  200.       update_item_selection()
  201.     elsif @target_window.active
  202.       update_target_selection()
  203.     end
  204.   end
  205.  
  206.   #--------------------------------------------------------------------------#
  207.   # * new method :update_group_selection
  208.   #--------------------------------------------------------------------------#  
  209.   def update_group_selection()
  210.     @group_window.update()
  211.     if Input.trigger?(Input::X)
  212.       Sound.play_cursor()
  213.       @group_window.index = (@group_window.index - 1) % @group_window.item_max
  214.       @item_window.sort_group = @group_window.commands[@group_window.index]
  215.       @item_window.refresh()
  216.       @item_window.index = 0
  217.     elsif Input.trigger?(Input::Y)
  218.       Sound.play_cursor()
  219.       @group_window.index = (@group_window.index + 1) % @group_window.item_max
  220.       @item_window.sort_group = @group_window.commands[@group_window.index]
  221.       @item_window.refresh()
  222.       @item_window.index = 0
  223.     end  
  224.   end
  225.  
  226. end  
  227.    
  228. #=*==========================================================================*=#
  229. # ** END OF FILE
  230. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment