IceDragon200

IEO031_LibraItem

Apr 13th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.80 KB | None | 0 0
  1. #==============================================================================#
  2. # ** IEO(Icy Engine Omega) - Libra Item
  3. #-*--------------------------------------------------------------------------*-#
  4. # ** Author        : IceDragon (http://www.rpgmakervx.net/)
  5. # ** Script-Status : Change (Item Scene)
  6. # ** Script Type   : Item Scene Mod
  7. # ** Date Created  : 04/09/2011
  8. # ** Date Modified : 04/12/2011
  9. # ** Script Tag    : IEO-031(Libra Item)
  10. # ** Difficulty    : Easy, Medium, Lunatic
  11. # ** Version       : 1.0
  12. # ** IEO ID        : 031
  13. #-*--------------------------------------------------------------------------*-#
  14. #==============================================================================#
  15. # ** CREDITS/USED STUFF/EDITING
  16. #-*--------------------------------------------------------------------------*-#
  17. # You may:
  18. # Edit and Adapt this script as long you credit aforementioned author(s).
  19. #
  20. # You may not:
  21. # Claim this as your own work, or redistribute without the consent of the author.
  22. #
  23. #------------------------------------------------------------------------------#
  24. #==============================================================================#
  25. # ** INTRODUCTION
  26. #-*--------------------------------------------------------------------------*-#
  27. # @.@ My head hurts...
  28. # Okay this here script is a rewrite of the Item Scene, it changes a few
  29. # things like the windows drawing methods, and adds some item catergorizing.
  30. #------------------------------------------------------------------------------#
  31. #==============================================================================#
  32. # ** COMPATABLITIES
  33. #-*--------------------------------------------------------------------------*-#
  34. #
  35. # Breaks a lot of the core methods in the Scene_Item, and Window_Item
  36. #
  37. #------------------------------------------------------------------------------#
  38. #==============================================================================#
  39. # ** INSTALLATION
  40. #-*--------------------------------------------------------------------------*-#
  41. # To install this script, open up your script editor and copy/paste this script
  42. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  43. #
  44. #-*--------------------------------------------------------------------------*-#
  45. # Below
  46. #   Materials
  47. #  
  48. # Above
  49. #   Main
  50. #   Everything else
  51. #
  52. #------------------------------------------------------------------------------#
  53. #==============================================================================#
  54. # ** CHANGES
  55. #-*--------------------------------------------------------------------------*-#
  56. # Classes
  57. #   RPG::BaseItem
  58. #     new-method   :ieo031_baseitemcache
  59. #   RPG::Weapon
  60. #     new-method   :ieo031_weaponcache
  61. #   RPG::Armor
  62. #     new-method   :ieo031_armorcache
  63. #   RPG::Item
  64. #     new-method   :ieo031_itemcache
  65. #   Game_System
  66. #     alias-method :initialize
  67. #   Window_Item
  68. #     overwrite    :initilaize
  69. #     overwrite    :include?
  70. #     overwrite    :refresh
  71. #     overwrite    :item_rect
  72. #     overwrite    :draw_item
  73. #     alias-method :update
  74. #   Scene_Title
  75. #     alias-method :load_database
  76. #     alias-method :load_bt_database
  77. #     new-method   :load_ieo031_cache
  78. #   Scene_Item
  79. #     overwrite    :initilaize
  80. #     overwrite    :start
  81. #     overwrite    :return_scene
  82. #     overwrite    :update
  83. #     overwrite    :update_item_selection
  84. #     alias-method :terminate
  85. #
  86. #------------------------------------------------------------------------------#
  87. #==============================================================================#
  88. # ** CHANGE LOG
  89. #-*--------------------------------------------------------------------------*-#
  90. # (DD/MM/YYYY)
  91. #  04/09/2011 - V1.0  Started Script
  92. #  04/12/2011 - V1.0  Finished Script
  93. #
  94. #------------------------------------------------------------------------------#
  95. #==============================================================================#
  96. # ** KNOWN ISSUES
  97. #------------------------------------------------------------------------------#  
  98. #
  99. #  Breaks stuff, lots of stuff with the item scene, and window
  100. #
  101. #------------------------------------------------------------------------------#
  102. #==============================================================================#
  103. # ** FAQ
  104. #-*--------------------------------------------------------------------------*-#  
  105. # Acronyms -
  106. #  BEM - Battle Engine Melody
  107. #  CBS - Custom Battle System
  108. #  DBS - Default Battle System
  109. #  GTBS- Gubid's Tactical Battle System
  110. #  IEO - Icy Engine Omega
  111. #  IEX - Icy Engine Xellion
  112. #  OHM - IEO-005(Ohmerion)
  113. #  SRN - IEX - Siren
  114. #  YGG - IEX - Yggdrasil
  115. #  ATB - Active Turn Battle
  116. #  DTB - Default Turn Battle
  117. #  PTB - Press Turn Battle
  118. #  CTB - Charge Turn Battle
  119. #
  120. # Q. Whats up with the IDs?
  121. # A. Well due to some naming issues, I ended up with 5 scripts in IEX
  122. #    all having similar names, this causes some issues for updating
  123. #    and sorting.
  124. #    I have decided to add some IDS so I can sort and find script with EASE.
  125. #
  126. # Q. Where is the name from?
  127. # A. Roman Alphabet, thanks to PentagonBuddy and Jalen by the way.
  128. #
  129. # Q. Where did you learn scripting?
  130. # A. Yanfly's scripts, read almost everyone of them, so my scripting style
  131. #    kinda looks like his.
  132. #
  133. #-*--------------------------------------------------------------------------*-#
  134. #==============================================================================#
  135. # $imported - Is mostly used by Japanese RPG Maker XP/VX scripters.
  136. #             This acts as a flag, or signal to show that "x" script is present.
  137. #             This is used for compatability with other future scripts.
  138. $imported = {} if $imported == nil
  139. $imported["IEO-LibraItem"] = true
  140. #==============================================================================#
  141. # $ieo_script - This is a hash specific to IEO scripts
  142. #               they work just like the $imported, but there key is slightly
  143. #               different, it is an array conatining an integer
  144. #               and a string, since IEO script all have an ID, the value
  145. #               is the scripts version number.
  146. #               A version number of nil, or 0 means the script isn't present
  147. # EG. $ieo_script[[ScriptID, "ScriptName"]]
  148. $ieo_script = {} if $ieo_script == nil
  149. $ieo_script[[31, "LibraItem"]] = 1.0
  150. #-*--------------------------------------------------------------------------*-#
  151. #==============================================================================#
  152. #==============================================================================#
  153. # IEO::ITEM_SYSTEM
  154. #==============================================================================#
  155. module IEO
  156.   module ITEM_SYSTEM
  157. #==============================================================================#
  158. #                      Start Primary Customization
  159. #------------------------------------------------------------------------------#
  160. #==============================================================================#    
  161.   #--------------------------------------------------------------------------#
  162.   # * SORT_LIST
  163.   #--------------------------------------------------------------------------#
  164.   # This is the default list sorting list for the items
  165.   # You can always change it, during the game.
  166.   # $game_system.item_sort_list
  167.   # In item, weapon or armor noteboxes, use the following tag
  168.   # <item group: phrase>
  169.   # NOTE* phrase is downcased and changed to a symbol (:phrase)
  170.   #--------------------------------------------------------------------------#
  171.     SORT_LIST = [:all, :item, :weapon, :armor] #[:all, :item, :equipment]
  172.   # // ------------------------------------------------------------------ // #  
  173.   # >.> Some auto catergorizing happens on start up
  174.   # :equipment - Weapons and Armor get this
  175.   # :weapon    - Weapons get this
  176.   # :armor     - Armors get this
  177.   # :item      - Items get this  
  178.   #--------------------------------------------------------------------------#
  179.   # * STYLES
  180.   #--------------------------------------------------------------------------#
  181.   # This controls the drawing style for the windows
  182.   #--------------------------------------------------------------------------#  
  183.   # // :normal, :hm_style, :hm_style_plus
  184.   # :normal, as the name states this will draw the items in its normal way
  185.   # :hm_style, draws the items icon and item number
  186.   # :hm_style_plus, in addition to the :hm_style, draws the items name
  187.   # (WARNING, use short names with _plus)
  188.     ITEM_WINDOW_STYLE = :normal
  189.   # // :normal, :normal_plus, :hm_style  
  190.   # :normal, draws only the name of the sort groups
  191.   # :normal_plus, draws the sort group name, and icon
  192.   # :hm_style, draws only the icon
  193.     TAB_WINDOW_STYLE  = :normal_plus
  194.    
  195. #==============================================================================#
  196. #                        End Primary Customization
  197. #------------------------------------------------------------------------------#
  198. #==============================================================================#    
  199.   end
  200. end
  201.  
  202. #==============================================================================#
  203. # IEO::Vocab
  204. #==============================================================================#
  205. module IEO
  206.   module Vocab
  207. #==============================================================================#
  208. #                      Start Secondary Customization
  209. #------------------------------------------------------------------------------#
  210. #==============================================================================#    
  211.     module_function # // Do Not Touch
  212.     def item_group(type)
  213.       case type
  214.       when :all       ; return "All"
  215.       when :item      ; return "Item"
  216.       when :equipment ; return ::Vocab.equip
  217.       when :weapon    ; return "Weapons"
  218.       when :armor     ; return "Armor"
  219.       end  
  220.     end  
  221. #==============================================================================#
  222. #                        End Secondary Customization
  223. #------------------------------------------------------------------------------#
  224. #==============================================================================#    
  225.   end
  226. end
  227.  
  228. #==============================================================================#
  229. # Sound
  230. #==============================================================================#
  231. module Sound
  232.   #--------------------------------------------------------------------------#
  233.   # * new method :play_itemtab
  234.   #--------------------------------------------------------------------------#
  235.   def self.play_itemtab ; self.play_cursor end
  236. end    
  237.  
  238. #==============================================================================#
  239. # IEO::REGEX::ITEM_SYSTEM
  240. #==============================================================================#
  241. module IEO
  242.   module REGEXP
  243.     module ITEM_SYSTEM
  244.       module BASE_ITEM
  245.         ITEM_GROUP = /<(ITEM_GROUP|item group|itemgroup|GROUP):[ ](.*)>/i
  246.       end
  247.     end
  248.   end
  249. end
  250.  
  251. #==============================================================================#
  252. # IEO::Icon
  253. #==============================================================================#
  254. module IEO
  255.   module Icon
  256.     module_function
  257.     def item_group(type) ; return 0 end
  258.   end
  259. end
  260.  
  261. #==============================================================================#
  262. # RPG::BaseItem
  263. #==============================================================================#
  264. class RPG::BaseItem
  265.  
  266.   #--------------------------------------------------------------------------#
  267.   # * Public Instance Variables
  268.   #--------------------------------------------------------------------------#
  269.   attr_accessor :sort_groups
  270.  
  271.   #--------------------------------------------------------------------------#
  272.   # * new method :ieo031_baseitemcache
  273.   #--------------------------------------------------------------------------#  
  274.   def ieo031_baseitemcache
  275.     @ieo031_baseitemcache_complete = false
  276.     @sort_groups = [:all]
  277.     self.note.split(/[\r\n]+/i).each { |line|
  278.       case line
  279.       when IEO::REGEXP::ITEM_SYSTEM::BASE_ITEM::ITEM_GROUP
  280.         @sort_groups |= [$1.downcase.to_sym]
  281.       end
  282.     }
  283.     @ieo031_baseitemcache_complete = true
  284.   end  
  285.  
  286. end  
  287.  
  288. #==============================================================================#
  289. # RPG::Weapon
  290. #==============================================================================#
  291. class RPG::Weapon
  292.  
  293.   #--------------------------------------------------------------------------#
  294.   # * new method :ieo031_weaponcache
  295.   #--------------------------------------------------------------------------#    
  296.   def ieo031_weaponcache
  297.     @sort_groups << :weapon
  298.     @sort_groups << :equipment
  299.   end
  300.  
  301. end  
  302.  
  303. #==============================================================================#
  304. # RPG::Armor
  305. #==============================================================================#
  306. class RPG::Armor
  307.  
  308.   #--------------------------------------------------------------------------#
  309.   # * new method :ieo031_armorcache
  310.   #--------------------------------------------------------------------------#  
  311.   def ieo031_armorcache
  312.     @sort_groups << :armor
  313.     @sort_groups << :equipment
  314.   end
  315.  
  316. end
  317.  
  318. #==============================================================================#
  319. # RPG::Item
  320. #==============================================================================#
  321. class RPG::Item
  322.  
  323.   #--------------------------------------------------------------------------#
  324.   # * new method :ieo031_itemcache
  325.   #--------------------------------------------------------------------------#
  326.   def ieo031_itemcache
  327.     @sort_groups << :item
  328.   end
  329.  
  330. end
  331.  
  332. #==============================================================================#
  333. # Game_System
  334. #==============================================================================#
  335. class Game_System
  336.  
  337.   #--------------------------------------------------------------------------#
  338.   # * Public Instance Variables
  339.   #--------------------------------------------------------------------------#
  340.   attr_accessor :item_sort_list
  341.   attr_accessor :item_lastindex_list
  342.   attr_accessor :item_display_style
  343.   attr_accessor :item_sort_style
  344.  
  345.   #--------------------------------------------------------------------------#
  346.   # * alias method :initialize
  347.   #--------------------------------------------------------------------------#
  348.   alias ieo031_initialize initialize unless $@
  349.   def initialize
  350.     ieo031_initialize
  351.     @item_sort_list      = IEO::ITEM_SYSTEM::SORT_LIST
  352.     @item_lastindex_list = {}
  353.     @item_sort_list.each { |t| @item_lastindex_list[t] = 0 }
  354.     @item_display_style  = IEO::ITEM_SYSTEM::ITEM_WINDOW_STYLE
  355.     @item_sort_style     = IEO::ITEM_SYSTEM::TAB_WINDOW_STYLE
  356.   end
  357.  
  358. end  
  359.  
  360. #==============================================================================#
  361. # Window_Item
  362. #==============================================================================#
  363. class Window_Item < Window_Selectable
  364.  
  365.   #--------------------------------------------------------------------------#
  366.   # * Public Instance Variables
  367.   #--------------------------------------------------------------------------#  
  368.   attr_accessor :active_filter
  369.  
  370.   #--------------------------------------------------------------------------#
  371.   # * overwrite method :initialize
  372.   #--------------------------------------------------------------------------#
  373.   def initialize(x, y, width, height)
  374.     @display_mode = $game_system.item_display_style
  375.     super(x, y, width, height)
  376.     @column_max    = 2
  377.     @active_filter = :all
  378.     @spacing       = 2
  379.     self.index     = 0
  380.     refresh
  381.   end
  382.  
  383.   #--------------------------------------------------------------------------#
  384.   # * overwrite method :include?
  385.   #--------------------------------------------------------------------------#
  386.   def include?(item)
  387.     return false if item == nil
  388.     if item.kind_of?(RPG::BaseItem)
  389.       return false unless item.sort_groups.include?(@active_filter)
  390.     end  
  391.     if $game_temp.in_battle
  392.       return false unless item.is_a?(RPG::Item)
  393.     end
  394.     return true
  395.   end
  396.  
  397.   #--------------------------------------------------------------------------#
  398.   # * overwrite method :refresh
  399.   #--------------------------------------------------------------------------#
  400.   def refresh
  401.     @data = []
  402.     for item in $game_party.items
  403.       next unless include?(item)
  404.       @data.push(item)
  405.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  406.         self.index = @data.size - 1
  407.       end
  408.     end
  409.     @data.push(nil) if include?(nil)
  410.     case @display_mode
  411.     when :normal                   ; @column_max = 2
  412.     when :hm_style, :hm_style_plus ; @column_max = 8
  413.     end  
  414.     @item_max = @data.size
  415.     create_contents
  416.     for i in 0...@item_max
  417.       draw_item(i)
  418.     end
  419.     if $game_system.item_lastindex_list[@active_filter] != nil
  420.       self.index = $game_system.item_lastindex_list[@active_filter]
  421.       while self.item.nil?
  422.         break if item != nil or self.index == 0
  423.         self.index -= 1
  424.       end
  425.     else
  426.       self.index = 0
  427.     end  
  428.   end
  429.  
  430.   #--------------------------------------------------------------------------#
  431.   # * overwrite method :item_rect
  432.   #--------------------------------------------------------------------------#
  433.   def item_rect(index)
  434.     rect = Rect.new(0, 0, 0, 0)
  435.     case @display_mode
  436.     when :normal
  437.       rect.width = (contents.width + @spacing) / @column_max - @spacing
  438.       rect.height = WLH
  439.       rect.x = index % @column_max * (rect.width + @spacing)
  440.       rect.y = index / @column_max * WLH
  441.     when :hm_style, :hm_style_plus  
  442.       rect.width = 42
  443.       rect.height = 42
  444.       offset = contents.width
  445.       offset-= (rect.width + @spacing) * @column_max
  446.       offset/= 2
  447.       rect.x = index % @column_max * (rect.width + @spacing) + offset
  448.       rect.y = index / @column_max * (rect.height + @spacing)
  449.     end  
  450.     return rect
  451.   end
  452.  
  453.   #--------------------------------------------------------------------------#
  454.   # * overwrite method :draw_item
  455.   #--------------------------------------------------------------------------#
  456.   def draw_item(index, enabled=true)
  457.     rect = item_rect(index)
  458.     self.contents.clear_rect(rect)
  459.     item = @data[index]
  460.     if item != nil
  461.       number = $game_party.item_number(item)
  462.       enabled = enable?(item)
  463.       case @display_mode
  464.       when :normal
  465.         rect.width -= 4
  466.         self.contents.font.size = Font.default_size
  467.         draw_item_name(item, rect.x, rect.y, enabled)
  468.         self.contents.font.size = 18
  469.         self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  470.       when :hm_style, :hm_style_plus
  471.         draw_icon(item.icon_index, rect.x+((rect.width-24) / 2), rect.y+((rect.height-24) / 2))
  472.         if @display_mode == :hm_style_plus
  473.           self.contents.font.size = 12
  474.           trect = rect.clone;trect.height = WLH;trect.y -= 4;trect.width -= 2
  475.           self.contents.draw_text(trect, item.name)
  476.         end  
  477.         self.contents.font.size = 14
  478.         rect.y += rect.height - WLH
  479.         rect.width -= 4 ; rect.height = WLH
  480.         self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  481.       end
  482.     end
  483.   end
  484.  
  485.   #--------------------------------------------------------------------------#
  486.   # * alias method :update
  487.   #--------------------------------------------------------------------------#
  488.   alias ieo031_wi_update update unless $@
  489.   def update
  490.     ieo031_wi_update
  491.     $game_system.item_lastindex_list[@active_filter] = self.index
  492.   end
  493.  
  494. end
  495.  
  496. #==============================================================================#
  497. # Window_ItemSortList
  498. #==============================================================================#
  499. class Window_ItemSortList < Window_Selectable
  500.  
  501.   #--------------------------------------------------------------------------#
  502.   # * Public Instance Variables
  503.   #--------------------------------------------------------------------------#
  504.   attr_accessor :sort_filter
  505.  
  506.   #--------------------------------------------------------------------------#
  507.   # * super method :initilaize
  508.   #--------------------------------------------------------------------------#
  509.   def initialize(x, y, width, height)
  510.     @display_mode= $game_system.item_sort_style
  511.     super(x, y, width, height)    
  512.     @sort_list   = $game_system.item_sort_list
  513.     @sort_filter = :all
  514.     @last_sort   = :nil
  515.     self.index   = 0
  516.     refresh
  517.   end
  518.  
  519.   #--------------------------------------------------------------------------#
  520.   # * new method :update_index
  521.   #--------------------------------------------------------------------------#
  522.   def update_index ; @last_sort = @sort_filter = @sort_list[self.index] end  
  523.   #--------------------------------------------------------------------------#
  524.   # * new method :set_sort_field
  525.   #--------------------------------------------------------------------------#  
  526.   def set_sort_field(new_sort) ; @sort_filter = new_sort end
  527.  
  528.   #--------------------------------------------------------------------------#
  529.   # * new method :refresh
  530.   #--------------------------------------------------------------------------#
  531.   def refresh
  532.     @item_max = @sort_list.size
  533.     @column_max = @item_max
  534.     create_contents
  535.     for i in 0...@item_max ; draw_item(i) end
  536.   end
  537.  
  538.   #--------------------------------------------------------------------------#
  539.   # * overwrite method :item_rect
  540.   #--------------------------------------------------------------------------#
  541.   def item_rect(index)
  542.     rect = Rect.new(0, 0, 0, 0)
  543.     case @display_mode
  544.     when :normal, :normal_plus
  545.       rect.width = (contents.width + @spacing) / @column_max - @spacing
  546.       rect.height = WLH
  547.       rect.x = index % @column_max * (rect.width + @spacing)
  548.       rect.y = index / @column_max * WLH
  549.     when :hm_style  
  550.       rect.width = 32  
  551.       rect.height = 32
  552.       offset = contents.width
  553.       offset-= (rect.width + @spacing) * @column_max
  554.       offset/= 2
  555.       rect.x = index % @column_max * (rect.width + @spacing) + offset
  556.       rect.y = index / @column_max * (rect.height + @spacing)
  557.       rect.y -= 4
  558.     end  
  559.     return rect
  560.   end
  561.  
  562.   #--------------------------------------------------------------------------#
  563.   # * new method :draw_item
  564.   #--------------------------------------------------------------------------#
  565.   def draw_item(index, enabled=true)
  566.     rect = item_rect(index)
  567.     self.contents.clear_rect(rect)
  568.     gro = @sort_list[index]
  569.     self.contents.font.size = 18
  570.     case @display_mode
  571.     when :normal
  572.       self.contents.draw_text(rect, IEO::Vocab.item_group(gro))
  573.     when :normal_plus  
  574.       xo = yo = 0
  575.       draw_icon(IEO::Icon.item_group(gro), rect.x+xo, rect.y+yo, enabled)
  576.       rect.x += 24
  577.       self.contents.draw_text(rect, IEO::Vocab.item_group(gro))
  578.     when :hm_style  
  579.       xo = (rect.width - 24) / 2
  580.       yo = (rect.height - 24) / 2
  581.       draw_icon(IEO::Icon.item_group(gro), rect.x+xo, rect.y+yo, enabled)
  582.     end  
  583.   end
  584.  
  585.   #--------------------------------------------------------------------------#
  586.   # * super method :update
  587.   #--------------------------------------------------------------------------#
  588.   def update
  589.     if @last_sort != @sort_filter
  590.       self.index = @sort_list.index(@sort_filter)
  591.       @last_sort = @sort_filter
  592.     end
  593.     super
  594.   end
  595.  
  596.   #--------------------------------------------------------------------------#
  597.   # * kill method :cursor_pageup
  598.   #--------------------------------------------------------------------------#  
  599.   def cursor_pageup   ; end
  600.   #--------------------------------------------------------------------------#
  601.   # * kill method :cursor_pagedown
  602.   #--------------------------------------------------------------------------#
  603.   def cursor_pagedown ; end
  604.    
  605. end
  606.  
  607. #==============================================================================#
  608. # Scene_Title
  609. #==============================================================================#
  610. class Scene_Title < Scene_Base
  611.  
  612.   #--------------------------------------------------------------------------#
  613.   # alias method :load_database
  614.   #--------------------------------------------------------------------------#
  615.   alias ieo031_load_database load_database unless $@
  616.   def load_database
  617.     ieo031_load_database
  618.     load_ieo031_cache
  619.   end
  620.  
  621.   #--------------------------------------------------------------------------#
  622.   # alias method :load_bt_database
  623.   #--------------------------------------------------------------------------#
  624.   alias ieo031_load_bt_database load_database unless $@
  625.   def load_bt_database
  626.     ieo031_load_bt_database
  627.     load_ieo031_cache
  628.   end  
  629.  
  630.   #--------------------------------------------------------------------------#
  631.   # new method :load_ieo031_cache
  632.   #--------------------------------------------------------------------------#
  633.   def load_ieo031_cache
  634.     objs = [$data_items, $data_weapons, $data_armors]
  635.     objs.each { |group| group.each { |obj|
  636.       next if obj.nil? ; obj.ieo031_baseitemcache
  637.       obj.ieo031_weaponcache if obj.is_a?(RPG::Weapon)
  638.       obj.ieo031_armorcache  if obj.is_a?(RPG::Armor)
  639.       obj.ieo031_itemcache   if obj.is_a?(RPG::Item) } }
  640.   end
  641.  
  642. end  
  643.  
  644. #==============================================================================#
  645. # Scene_Item
  646. #==============================================================================#
  647. class Scene_Item < Scene_Base
  648.  
  649.   include IEX::SCENE_ACTIONS if $imported["IEX_SceneActions"]
  650.  
  651.   #--------------------------------------------------------------------------#
  652.   # * Constants
  653.   #--------------------------------------------------------------------------#
  654.   SLIDY_WINDOWS = false
  655.   SLIDY_WINDOWS = ($imported["IEX_SceneActions"] && SLIDY_WINDOWS)
  656.  
  657.   #--------------------------------------------------------------------------#
  658.   # * overwrite method :initialize
  659.   #--------------------------------------------------------------------------#
  660.   def initialize(called = :menu, return_index=0)
  661.     super()
  662.     # ---------------------------------------------------- #
  663.     @calledfrom = called
  664.     @return_index = return_index
  665.     # ---------------------------------------------------- #
  666.   end
  667.  
  668.   #--------------------------------------------------------------------------#
  669.   # * overwrite method :start
  670.   #--------------------------------------------------------------------------#
  671.   def start
  672.     super
  673.     create_menu_background
  674.     @viewport             = Viewport.new(0, 0, Graphics.width, Graphics.height)
  675.     @help_window          = Window_Help.new
  676.     @help_window.viewport = @viewport
  677.     @item_window          = Window_Item.new(0, 112, Graphics.width, 304)
  678.     @item_window.viewport = @viewport
  679.     @item_window.help_window = @help_window
  680.     @item_window.active   = false
  681.     @itemgroup_window     = Window_ItemSortList.new(0, 56, Graphics.width, 56)
  682.     @itemgroup_window.active = false
  683.     @itemgroup_window.update
  684.     @target_window        = Window_MenuStatus.new(0, 0)
  685.     hide_target_window
  686.   end
  687.  
  688.   #--------------------------------------------------------------------------#
  689.   # * overwrite method :terminate
  690.   #--------------------------------------------------------------------------#
  691.   alias ieo031_terminate terminate unless $@
  692.   def terminate
  693.     ieo031_terminate
  694.     @itemgroup_window.dispose unless @itemgroup_window.nil?
  695.   end
  696.  
  697.   #--------------------------------------------------------------------------#
  698.   # * overwrite method :return_scene
  699.   #--------------------------------------------------------------------------#
  700.   def return_scene
  701.     if SLIDY_WINDOWS
  702.       # ---------------------------------------------------- #
  703.       #pull_windows_right(["SStat"], @windows["SStat"].width)
  704.       #pull_windows_left(["Level", "Skill"], @windows["Skill"].width)
  705.       #pull_windows_up(["Party"], @windows["Party"].height)
  706.       # ---------------------------------------------------- #
  707.     end
  708.     case @calledfrom
  709.     when :map
  710.       $scene = Scene_Map.new
  711.     when :menu
  712.       $scene = Scene_Menu.new(@return_index)
  713.     end  
  714.   end
  715.  
  716.   #--------------------------------------------------------------------------#
  717.   # * overwrite method :update
  718.   #--------------------------------------------------------------------------#
  719.   def update
  720.     super
  721.     update_menu_background
  722.     @help_window.update
  723.     @item_window.update
  724.     @target_window.update
  725.     @itemgroup_window.update
  726.     if @item_window.active_filter != @itemgroup_window.sort_filter
  727.       @item_window.active_filter = @itemgroup_window.sort_filter
  728.       @item_window.refresh
  729.     end  
  730.     if @item_window.active
  731.       update_item_selection
  732.     elsif @target_window.active
  733.       update_target_selection
  734.     end
  735.   end
  736.  
  737.   #--------------------------------------------------------------------------#
  738.   # * overwrite method :update_item_selection
  739.   #--------------------------------------------------------------------------#
  740.   def update_item_selection
  741.     if Input.trigger?(Input::B)
  742.       Sound.play_cancel
  743.       return_scene
  744.     elsif Input.trigger?(Input::C)
  745.       @item = @item_window.item
  746.       if @item != nil
  747.         $game_party.last_item_id = @item.id
  748.       end
  749.       if $game_party.item_can_use?(@item)
  750.         Sound.play_decision
  751.         determine_item
  752.       else
  753.         Sound.play_buzzer
  754.       end
  755.     elsif Input.trigger?(Input::L)
  756.       Sound.play_itemtab
  757.       @itemgroup_window.index -= 1
  758.       @itemgroup_window.index %= @itemgroup_window.item_max
  759.       @itemgroup_window.update_index()
  760.     elsif Input.trigger?(Input::R)  
  761.       Sound.play_itemtab
  762.       @itemgroup_window.index += 1
  763.       @itemgroup_window.index %= @itemgroup_window.item_max
  764.       @itemgroup_window.update_index()
  765.     end
  766.   end
  767.  
  768. end  
  769.  
  770. #=*==========================================================================*=#
  771. # ** END OF FILE
  772. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment