Advertisement
AlliedG

Quasi Item Scene

Jan 11th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. #==============================================================================
  2. # ** Quasi Scene_Item
  3. #==============================================================================
  4. # Scene with custom categories.
  5. #==============================================================================
  6. module Quasi
  7. module Scene_Item
  8. #--------------------------------------------------------------------------
  9. # TYPE hash is used to create the categories and notetag
  10. # :tag => vocab
  11. # tag(without colon) is used for the notetag in the item surrounded by <>'s
  12. # vocab is used as the name to display in the menu
  13. #
  14. # In the setup below :mats becomes a notetag of <mats> and displays
  15. # Materials in the menu.
  16. #--------------------------------------------------------------------------
  17. TYPE = {
  18. :mats => "Materials",
  19. :shards => "Shards",
  20. :runes => "Runes",
  21. }
  22. #--------------------------------------------------------------------------
  23. # The width of the category window (X values of other windows are
  24. # automatically adjusted)
  25. #--------------------------------------------------------------------------
  26. WIN_CAT_WIDTH = 125
  27. end
  28. end
  29. #==============================================================================#
  30. # By Quasi (http://quasixi.com/)
  31. # - 12/21/14
  32. #==============================================================================#
  33.  
  34. #==============================================================================
  35. # ** Scene_Item
  36. #------------------------------------------------------------------------------
  37. # This class performs the item screen processing.
  38. #==============================================================================
  39.  
  40. class Scene_Item < Scene_ItemBase
  41. #--------------------------------------------------------------------------
  42. # * Fix so it works with YanFly
  43. #--------------------------------------------------------------------------
  44. def relocate_windows
  45. return
  46. end
  47. #--------------------------------------------------------------------------
  48. # * Create Category Window
  49. #--------------------------------------------------------------------------
  50. def create_category_window
  51. @category_window = Window_QItemCategory.new
  52. @category_window.viewport = @viewport
  53. @category_window.help_window = @help_window
  54. @category_window.y = @help_window.height
  55. @category_window.height = Graphics.height - @help_window.height
  56. @category_window.set_handler(:ok, method(:on_category_ok))
  57. @category_window.set_handler(:cancel, method(:return_scene))
  58. end
  59. #--------------------------------------------------------------------------
  60. # * Create Item Window
  61. #--------------------------------------------------------------------------
  62. def create_item_window
  63. wy = @help_window.height
  64. wx = @category_window.width
  65. ww = Graphics.width - wx
  66. wh = Graphics.height - wy
  67. @item_window = Window_ItemList.new(wx, wy, ww, wh)
  68. @item_window.viewport = @viewport
  69. @item_window.help_window = @help_window
  70. @item_window.set_handler(:ok, method(:on_item_ok))
  71. @item_window.set_handler(:cancel, method(:on_item_cancel))
  72. @category_window.item_window = @item_window
  73. end
  74. end
  75.  
  76. #==============================================================================
  77. # ** Window_QItemCategory
  78. #------------------------------------------------------------------------------
  79. # This window is for selecting a category of normal items and equipment
  80. # on the item screen or shop screen.
  81. #==============================================================================
  82.  
  83. class Window_QItemCategory < Window_Command
  84. #--------------------------------------------------------------------------
  85. # * Public Instance Variables
  86. #--------------------------------------------------------------------------
  87. attr_reader :item_window
  88. #--------------------------------------------------------------------------
  89. # * Object Initialization
  90. #--------------------------------------------------------------------------
  91. def initialize
  92. super(0, 0)
  93. end
  94. #--------------------------------------------------------------------------
  95. # * Get Window Width
  96. #--------------------------------------------------------------------------
  97. def window_width
  98. Quasi::Scene_Item::WIN_CAT_WIDTH
  99. end
  100. #--------------------------------------------------------------------------
  101. # * Frame Update
  102. #--------------------------------------------------------------------------
  103. def update
  104. super
  105. @item_window.category = current_symbol if @item_window
  106. end
  107. #--------------------------------------------------------------------------
  108. # * Create Command List
  109. #--------------------------------------------------------------------------
  110. def make_command_list
  111. add_command(Vocab::item, :item)
  112. #add_command(Vocab::weapon, :weapon)
  113. add_command(Vocab::armor, :armor)
  114. Quasi::Scene_Item::TYPE.each do |key, value|
  115. add_command(value, key)
  116. end
  117. add_command(Vocab::key_item, :key_item)
  118. end
  119. #--------------------------------------------------------------------------
  120. # * Set Item Window
  121. #--------------------------------------------------------------------------
  122. def item_window=(item_window)
  123. @item_window = item_window
  124. update
  125. end
  126. end
  127.  
  128. #==============================================================================
  129. # ** Window_ItemList
  130. #------------------------------------------------------------------------------
  131. # This window displays a list of party items on the item screen.
  132. #==============================================================================
  133.  
  134. class Window_ItemList < Window_Selectable
  135. #--------------------------------------------------------------------------
  136. # * Include in Item List?
  137. #--------------------------------------------------------------------------
  138. def include?(item)
  139. case @category
  140. when :item
  141. item.is_a?(RPG::Item) && !item.key_item? && !item.qtype
  142. #when :weapon
  143. #item.is_a?(RPG::Weapon) && !item.qtype
  144. when :armor
  145. item.is_a?(RPG::Armor) && !item.qtype
  146. when :key_item
  147. item.is_a?(RPG::Item) && item.key_item? && !item.qtype
  148. else
  149. return false unless item
  150. if Quasi::Scene_Item::TYPE.keys.include?(@category)
  151. return item.qtype == @category
  152. end
  153. false
  154. end
  155. end
  156. end
  157.  
  158. #==============================================================================
  159. # ** RPG::Item
  160. #==============================================================================
  161.  
  162. class RPG::BaseItem
  163. def qtype
  164. if @qtype.nil?
  165. @qtype = false
  166. Quasi::Scene_Item::TYPE.each_key do |key|
  167. regex = /<(?i:#{key.to_s})>/
  168. @qtype = key if @note =~ regex
  169. end
  170. end
  171. return @qtype
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement