IceDragon200

ICY-SceneItem (Old)

Jul 19th, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 36.07 KB | None | 0 0
  1. #------------------------------------------------------------------------------#
  2. # ** ICY Harvest Moon Style Inventory
  3. # ** Created by : IceDragon
  4. # ** Script-Status : ReWrite
  5. # ** Date Created : 7/16/2010
  6. # ** Date Modified : 7/17/2010
  7. # ** Version : 1.0
  8. #------------------------------------------------------------------------------#
  9. # INTRODUCTION
  10. # While going around the Resource Showcase. I stumbled upon a siggy which read.
  11. # "Give us a Harvest Moon Inventory", I decided to click it, and check it out.
  12. # And I made this!
  13. # The only problem the script request was for a LIMITED INVENTORY!
  14. # This is UNLIMITED!!
  15. # But is still nice as it is.
  16. # This is a Fully Customizable Item Scene (Unless I missed something!)
  17. #
  18. #------------------------------------------------------------------------------#
  19. # PLACEMENT
  20. # Above
  21. #   Main
  22. #   KGC_Catergorize_Items
  23. #
  24. # Below
  25. #  Materials
  26. #------------------------------------------------------------------------------#
  27. # CHANGES
  28. # This script overwrites the Scene_Item.
  29. # The Window_Item remains intact
  30. # The Window_Help remains intact
  31. # Instead Custom Classes were created for those.
  32. # This may cause Incompatability with other item scripts.
  33. #
  34. #------------------------------------------------------------------------------#
  35. # COMPATABILTIES
  36. # Patch for KGC_Catergorize_Items
  37. # If YERD_Custom_Menu_System is Installed it will get the :item Icon for the
  38. # Header
  39. #------------------------------------------------------------------------------#
  40. # KNOWN ISSUES
  41. # Non at the moment.
  42. #
  43. #------------------------------------------------------------------------------#
  44. # CHANGE LOG
  45. # 7/17/2010 Finished Script V_1.0
  46. #
  47. #------------------------------------------------------------------------------#
  48. # Importing script for compatabilities (So I know if the script is there or not)
  49. $imported = {} if $imported == nil
  50. $imported["ICY_HM_Style_Inventory"] = true
  51. #------------------------------------------------------------------------------#
  52. # ** Start Customization
  53. #------------------------------------------------------------------------------#
  54. module ICY
  55.   module HM_Style_Items
  56.     KGC_Catergorize = true #Are you using KGC_Catergorize_Item. false if you don't have the script.
  57. #---------------------------------------------------------------#
  58. # ** Window Setup
  59. #---------------------------------------------------------------#
  60.     WINDOW_SIZES = { # Don't touch this
  61. #Don't touch this side < edit the array to the > [x, y, width, height, opacity],
  62.     "Help" => [0, 280, 544, 80, 255], # This is the window which shows the description
  63.     "Item" => [0, 56, 544, 280, 255], # This is the window which shows the items
  64.     "Header" => [0, 0, 544, 56, 255], # This is the header window which shows the name
  65.     } # Don't touch this
  66.     NUM_OF_COLUMN = 10 # Number of Columns in Item Window
  67.     ITEM_SQ_SPACING = 48 # Item Spacing
  68.     SELECTION_SIZE = 40 # Selection Box size
  69. #---------------------------------------------------------------#
  70. # ** Rect
  71. #---------------------------------------------------------------#
  72.     RECT_SIZE = 32 # The Box's size Reccomend 32 and above anything less causes scrolling problems
  73.    
  74.     USE_BORDER_RECT = true # Should a box be shown around the items
  75.     # If use_border_rect = false Disregard everything below
  76.     RECT_IN_HELP = true # Should the box be shown around the item in the help.
  77.     RECT_COLOR = ICY::Colors::Gold # Default Box Color
  78.     BORDER_SIZE = 4 # Use Even Number PLEASE!!
  79.     # Custom Box Colors
  80.     USE_RECT_ITEM_COLOR = true # Use specific colors for item types? If false uses RECT_COLOR
  81.     RECT_ITEM_COLORS = { # Don't touch this
  82. #Don't touch this side < edit the > or Color.new(RED, GREEN, BLUE, ALPHA)
  83.     "Default"=> RECT_COLOR,
  84.     "Usable" => ICY::Colors::LightGreen,
  85.     "Weapon" => ICY::Colors::LightCoral,
  86.     "Armor"  => ICY::Colors::LightBlue,
  87.     } # Don't touch this
  88. # Specific Item Colors
  89.     RECT_VIP_ITEMS = [10] # Item Ids go here
  90.     RECT_VIP_ITEM_COLORS = { # Don't touch this
  91.     10 => ICY::Colors::Red,
  92.     } # Don't touch this
  93.    
  94.     RECT_VIP_WEAPONS = [] # Weapon Ids go here
  95.     RECT_VIP_WEAPON_COLORS = { # Don't touch this
  96.    
  97.     } # Don't touch this
  98.    
  99.     RECT_VIP_ARMORS = [] # Amror Ids Go here
  100.     RECT_VIP_ARMOR_COLORS = { # Don't touch this
  101.    
  102.     } # Don't touch this
  103. #----------------------------------------------------------------------#
  104. # ** Images
  105. #----------------------------------------------------------------------#
  106. # Images must be the same size as the RECT_SIZE to get desisred results
  107. #
  108.     USE_IMAGES = true
  109.     USE_WINDOW_IMAGES = false
  110.     WINDOW_IMAGES = { # Don't touch this
  111.     "Help" => "",
  112.     "Item" => "",
  113.     "Header" => "",
  114.     } # Don't touch this
  115.    
  116.     USE_IMG_RECT = false # Should and Image Rect be used
  117.     IMG_RECT = "Rect_Test_Img" # Default Image used.
  118.    
  119.     USE_SPECIFIC_IMG_RECTS = false
  120.     IMG_SPECIFIC_RECTS = {
  121.     "Default"=> "",
  122.     "Usable" => "",
  123.     "Weapon" => "",
  124.     "Armor"  => "",
  125.     }
  126.     # Specific Rect Images
  127.     IMG_RECT_VIP_ITEMS = [10] # Item Ids go here
  128.     IMG_RECT_VIP_ITEM_IMAGES = { # Don't touch this
  129.     10 => "",
  130.     } # Don't touch this
  131.    
  132.     IMG_RECT_VIP_WEAPONS = [] # Weapon Ids go here
  133.     IMG_RECT_VIP_WEAPON_IMAGES = { # Don't touch this
  134.    
  135.     } # Don't touch this
  136.    
  137.     IMG_RECT_VIP_ARMORS = [] # Amror Ids Go here
  138.     IMG_RECT_VIP_ARMOR_IMAGES = { # Don't touch this
  139.    
  140.     } # Don't touch this
  141. #---------------------------------------------------------------#
  142. # ** Draw_Item
  143. #---------------------------------------------------------------#    
  144.     DRAW_ITEM_ICON_IN_HELP = true # Should the items Icon be drawn in the help?
  145.     DRAW_AMOUNT_FOR_1 = false # If there is only one of the item should it write 1
  146.     UNUSABLE_OPACITY = 180 # The opacity for unusable items
  147.    
  148.     ITEM_NUM_POS = [16, 16] # [x, y] Position of Item Number
  149.     ITEM_NUM_ALIGN = 2 # 0 - Flush Left, 1 - Center, 2 - Flush Right
  150.     ITEM_NUM_IN_HELP = false # Should the items amount be shown in help.
  151.     ITEM_NUM_FORMAT = "x%2d" # Format "yourtext%2d" used when showing amount
  152.     ITEM_ICON_POS = [4, 4] # Items Icon Position
  153. #---------------------------------------------------------------#
  154. # ** Mini_Icons
  155. #---------------------------------------------------------------#    
  156.     USE_MINI_ICONS = true #These mini icons represent the item type
  157.     MINI_ICON_SET = "Mini_UseIcons" # This is in the System Folder
  158.     MINI_ICON_SIZE = 8 # Thats in Pixels for one Icon
  159.     MINI_ICON_COLUMNS = 4 # How many coloumns are in the image file
  160.     MINI_ICON_POS = [0, (RECT_SIZE - MINI_ICON_SIZE)] # Mini Icon position
  161.     MINI_ICON_IN_HELP = false # Should the mini Icon be shown in the help?
  162.    
  163.     MINI_ICON_ITEMS = { # Don't touch this
  164. #Don't touch this side < edit the > MiniIcon_ID,
  165.     "Default"=> 5,
  166.     "Usable" => 3,
  167.     "Weapon" => 4,
  168.     "Armor"  => 2,
  169.     }
  170.    
  171. # This is similar to the RECT BORDERS No explanation will be given.
  172.     MINI_VIP_ITEMS = [10]
  173.     MINI_VIP_ITEM_ICONS = {
  174.     10 => 6,
  175.     }
  176.     MINI_VIP_WEAPONS = []
  177.     MINI_VIP_WEAPON_ICONS = {
  178.     }
  179.     MINI_VIP_ARMORS = []
  180.     MINI_VIP_ARMOR_ICONS = {
  181.     }
  182.    
  183. #------------------------------------------------------------------------------#
  184. # ** End Customization
  185. #------------------------------------------------------------------------------#
  186. # DON'T TOUCH ANYTHING BEYOND THIS POINT!!!!
  187. # UNLESS YOU KNOW WHAT YOUR DOING!
  188. #------------------------------------------------------------------------------#
  189.   #--------------------------------------------------------------------------
  190.   # * Prep Mini Icon
  191.   #     icon_index : Icon number
  192.   #   This doesn't really draw the icon, it just sends the image and rect back.
  193.   #--------------------------------------------------------------------------
  194.   def self.prep_mini_icon(icon_index)
  195.     bitmap = Cache.system(MINI_ICON_SET)
  196.     rect = Rect.new(icon_index % MINI_ICON_COLUMNS * MINI_ICON_SIZE, icon_index / MINI_ICON_COLUMNS * MINI_ICON_SIZE, MINI_ICON_SIZE, MINI_ICON_SIZE)
  197.     return [bitmap, rect]
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # * Get Rect Image
  201.   #     item : Item
  202.   #   This is used to get the color for the border rect.
  203.   #--------------------------------------------------------------------------
  204.   def self.get_rect_image(item)
  205.       if USE_SPECIFIC_IMG_RECTS
  206.          if item.is_a?(RPG::UsableItem)
  207.            if IMG_RECT_VIP_ITEMS.include?(item.id)
  208.              srect_image = IMG_RECT_VIP_ITEM_IMAGES[item.id]
  209.               else
  210.              srect_image = IMG_SPECIFIC_RECTS["Usable"]
  211.           end
  212.         elsif item.is_a?(RPG::Weapon)
  213.            if IMG_RECT_VIP_WEAPONS.include?(item.id)
  214.              srect_image = IMG_RECT_VIP_WEAPON_IMAGES[item.id]
  215.               else
  216.              srect_image = IMG_SPECIFIC_RECTS["Weapon"]
  217.           end
  218.         elsif item.is_a?(RPG::Armor)
  219.            if IMG_RECT_VIP_ARMORS.include?(item.id)
  220.              srect_image = IMG_RECT_VIP_ARMOR_IMAGES[item.id]
  221.               else
  222.              srect_image = IMG_SPECIFIC_RECTS["Armor"]
  223.           end
  224.         else
  225.           if IMG_RECT_VIP_ITEMS.include?(item.id)
  226.            srect_image = IMG_RECT_VIP_ITEM_IMAGES[item.id]
  227.             else
  228.            srect_image = IMG_SPECIFIC_RECTS["Default"]
  229.           end
  230.          end
  231.         else
  232.          srect_image = IMG_RECT
  233.        end
  234.        return srect_image
  235.      end
  236.   #--------------------------------------------------------------------------
  237.   # * Get Rect Color
  238.   #     item : Item
  239.   #   This is used to get the color for the border rect.
  240.   #--------------------------------------------------------------------------
  241.   def self.get_rect_color(item)
  242.       if USE_RECT_ITEM_COLOR
  243.          if item.is_a?(RPG::UsableItem)
  244.            if RECT_VIP_ITEMS.include?(item.id)
  245.              srect_color = RECT_VIP_ITEM_COLORS[item.id]
  246.               else
  247.              srect_color = RECT_ITEM_COLORS["Usable"]
  248.           end
  249.         elsif item.is_a?(RPG::Weapon)
  250.            if RECT_VIP_WEAPONS.include?(item.id)
  251.              srect_color = RECT_VIP_WEAPON_COLORS[item.id]
  252.               else
  253.              srect_color = RECT_ITEM_COLORS["Weapon"]
  254.           end
  255.         elsif item.is_a?(RPG::Armor)
  256.            if RECT_VIP_ARMORS.include?(item.id)
  257.              srect_color = RECT_VIP_ARMOR_COLORS[item.id]
  258.               else
  259.              srect_color = RECT_ITEM_COLORS["Armor"]
  260.           end
  261.         else
  262.           if RECT_VIP_ITEMS.include?(item.id)
  263.            srect_color = RECT_VIP_ITEM_COLORS[item.id]
  264.             else
  265.            srect_color = RECT_ITEM_COLORS["Default"]
  266.           end
  267.          end
  268.         else
  269.          srect_color = RECT_COLOR
  270.        end
  271.        return srect_color
  272.      end
  273.   #--------------------------------------------------------------------------
  274.   # * Get Mini Icon
  275.   #     item : Item
  276.   #   This is used to get the mini icon displayed.
  277.   #--------------------------------------------------------------------------    
  278.      def self.get_mini_icon(item)
  279.        if item.is_a?(RPG::UsableItem)
  280.         if MINI_VIP_ITEMS.include?(item.id)
  281.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_VIP_ITEM_ICONS[item.id])
  282.           else
  283.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_ICON_ITEMS["Usable"])  
  284.         end
  285.       elsif item.is_a?(RPG::Weapon)
  286.         if MINI_VIP_WEAPONS.include?(item.id)
  287.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_VIP_WEAPON_ICONS[item.id])
  288.           else
  289.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_ICON_ITEMS["Weapon"])
  290.         end
  291.       elsif item.is_a?(RPG::Armor)
  292.         if MINI_VIP_ARMORS.include?(item.id)
  293.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_VIP_ARMOR_ICONS[item.id])
  294.           else
  295.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_ICON_ITEMS["Armor"])
  296.         end
  297.       else
  298.         if MINI_VIP_ITEMS.include?(item.id)
  299.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_VIP_ITEM_ICONS[item.id])
  300.           else
  301.            prep_minis = ICY::HM_Style_Items.prep_mini_icon(MINI_ICON_ITEMS["Default"])
  302.         end
  303.        end
  304.         return prep_minis
  305.     end
  306.      
  307.   end
  308. end
  309.  
  310. #==============================================================================
  311. # ** ICY_Item_Window_Help
  312. #------------------------------------------------------------------------------
  313. #  This a custom help window used with the HM_Style_Inventory
  314. #==============================================================================
  315.  
  316. class ICY_Item_Window_Help < Window_Base
  317.   include ICY::HM_Style_Items
  318.   #--------------------------------------------------------------------------
  319.   # * Object Initialization
  320.   #--------------------------------------------------------------------------
  321.   def initialize(x, y, width, height)
  322.     super(x, y, width, height)
  323.     @back_sprite = nil
  324.     if USE_WINDOW_IMAGES
  325.       if WINDOW_IMAGES["Help"] != nil or ""
  326.         self.opacity = 0
  327.         bitmap = Cache.system(WINDOW_IMAGES["Help"])
  328.         @back_sprite = Sprite.new
  329.         @back_sprite.bitmap = bitmap
  330.       end
  331.     end
  332.     @item = nil
  333.     @align = nil
  334.   end
  335.  
  336.   def dispose
  337.     super
  338.    if USE_WINDOW_IMAGES
  339.      if WINDOW_IMAGES["Help"] != nil or ""
  340.        @back_sprite.dispose if @back_sprite != nil
  341.      end
  342.    end
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # * Set Text
  346.   #  text  : character string displayed in window
  347.   #  align : alignment (0..flush left, 1..center, 2..flush right)
  348.   #--------------------------------------------------------------------------
  349.   def set_text(text, align = 0)
  350.     if text != @text or align != @align
  351.       self.contents.clear
  352.       self.contents.font.color = normal_color
  353.       self.contents.draw_text(48, 24, self.width - 90, WLH, text, align)
  354.       @text = text
  355.       @align = align
  356.     end
  357.   end
  358.  
  359.   def set_item(item)
  360.     if item != nil
  361.     self.contents.clear  
  362.     numberbox = Rect.new(ITEM_NUM_POS[0], ITEM_NUM_POS[1], RECT_SIZE, RECT_SIZE)
  363.     outline = Rect.new(0, 0, RECT_SIZE, RECT_SIZE)
  364.     sub_rect = Rect.new((BORDER_SIZE / 2), (BORDER_SIZE / 2),
  365.        (RECT_SIZE - BORDER_SIZE), (RECT_SIZE - BORDER_SIZE))
  366.    
  367.     if USE_IMAGES and USE_IMG_RECT
  368.       srect_image = ICY::HM_Style_Items.get_rect_image(item)
  369.       outline_sprite = Cache.system(srect_image)
  370.       self.contents.blt(0, 0, outline_sprite, outline)
  371.     end
  372.    
  373.     if USE_BORDER_RECT and RECT_IN_HELP
  374.       srect_color = ICY::HM_Style_Items.get_rect_color(item)
  375.       outline_sprite = Bitmap.new(RECT_SIZE, RECT_SIZE)
  376.       outline_sprite.fill_rect(outline, srect_color)
  377.       outline_sprite.clear_rect(sub_rect)
  378.       self.contents.blt(0, 0, outline_sprite, outline)
  379.     end
  380.    
  381.     if USE_MINI_ICONS and MINI_ICON_IN_HELP
  382.       prep_minis = ICY::HM_Style_Items.get_mini_icon(item)
  383.       self.contents.blt(MINI_ICON_POS[0], MINI_ICON_POS[1], prep_minis[0], prep_minis[1])
  384.     end
  385.    
  386.     draw_icon(item.icon_index, ITEM_ICON_POS[0], ITEM_ICON_POS[1]) if DRAW_ITEM_ICON_IN_HELP
  387.     number = $game_party.item_number(item)
  388.     self.contents.font.color = system_color
  389.     if DRAW_ITEM_ICON_IN_HELP
  390.       text_x = 48
  391.     else
  392.       text_x = 4
  393.     end
  394.     # Writes Item Name
  395.     self.contents.draw_text(text_x, 0, self.width - 90, WLH, item.name, 0)
  396.     self.contents.font.color = normal_color
  397.     # Writes Item Amount
  398.     old_font_size = self.contents.font.size
  399.     self.contents.font.size = 16
  400.     if DRAW_AMOUNT_FOR_1
  401.       self.contents.draw_text(numberbox, sprintf(ITEM_NUM_FORMAT, number), ITEM_NUM_ALIGN) if ITEM_NUM_IN_HELP
  402.     elsif DRAW_AMOUNT_FOR_1 == false and number > 1
  403.       self.contents.draw_text(numberbox, sprintf(ITEM_NUM_FORMAT, number), ITEM_NUM_ALIGN) if ITEM_NUM_IN_HELP
  404.     end
  405.     self.contents.font.size = old_font_size
  406.     # Writes Item Description
  407.     old_font_size = self.contents.font.size
  408.     self.contents.font.color = normal_color
  409.     self.contents.font.size = 18
  410.     self.contents.draw_text(text_x + 16, 24, self.width - 90, WLH, item.description, 0)
  411.     self.contents.font.size = old_font_size
  412.     end
  413.   end
  414.  
  415. end
  416.  
  417. #==============================================================================
  418. # ** ICY_Header_Window
  419. #------------------------------------------------------------------------------
  420. #  This window displays a header.
  421. #==============================================================================
  422. class ICY_Item_Header_Window < Window_Base
  423.   include ICY::HM_Style_Items
  424.   attr_accessor :font_size
  425.   #--------------------------------------------------------------------------
  426.   # * Object Initialization
  427.   #     x      : window x-coordinate
  428.   #     y      : window y-coordinate
  429.   #     width  : window width
  430.   #     height : window height
  431.   #--------------------------------------------------------------------------
  432.   def initialize(x, y, width, height)
  433.     super(x, y, width, height)
  434.     @back_sprite = nil
  435.     if USE_WINDOW_IMAGES
  436.       if WINDOW_IMAGES["Header"] != nil or ""
  437.         self.opacity = 0
  438.         bitmap = Cache.system(WINDOW_IMAGES["Header"])
  439.         @back_sprite = Sprite.new
  440.         @back_sprite.bitmap = bitmap
  441.       end
  442.     end
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ** Reset Font Size
  446.   #   Resets the font size to 26
  447.   #--------------------------------------------------------------------------
  448.   def reset_font_size
  449.     @font_size = 26
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ** Dispose
  453.   #--------------------------------------------------------------------------
  454.   def dispose
  455.     super
  456.     if USE_WINDOW_IMAGES
  457.       if WINDOW_IMAGES["Header"] != nil or ""
  458.         @back_sprite.dispose if @back_sprite != nil
  459.       end
  460.     end
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ** Set Header
  464.   #     text   : text
  465.   #     icon   : icon_index
  466.   #     align  : align
  467.   #--------------------------------------------------------------------------
  468.   def set_header(text = "", icon = nil, align = 0)
  469.     icon_offset = 32
  470.     if icon == nil
  471.       x = 0
  472.     else
  473.       x = icon_offset
  474.       draw_icon(icon, 0, 0)
  475.     end
  476.      y = 0
  477.      old_font_size = self.contents.font.size
  478.      self.contents.font.size = 26
  479.      self.contents.font.color = system_color
  480.      self.contents.draw_text(x, y, (self.width - x) - 48, WLH, text, align)
  481.      self.contents.font.color = normal_color
  482.      self.contents.font.size = old_font_size
  483.   end
  484.  
  485. end
  486.  
  487. #==============================================================================
  488. # ** ICY_SC_Window_Item
  489. #------------------------------------------------------------------------------
  490. #  This is a custom window used with the HM_Style_Inventory
  491. #==============================================================================
  492.  
  493. class ICY_SC_Window_Item < Window_Selectable
  494.   include ICY::HM_Style_Items
  495.   attr_accessor :column_max
  496.   #--------------------------------------------------------------------------
  497.   # * Object Initialization
  498.   #     x      : window x-coordinate
  499.   #     y      : window y-coordinate
  500.   #     width  : window width
  501.   #     height : window height
  502.   #--------------------------------------------------------------------------
  503.   def initialize(x, y, width, height)
  504.     super(x, y, width, height)
  505.     @back_sprite = nil
  506.     if USE_WINDOW_IMAGES
  507.       if WINDOW_IMAGES["Item"] != nil or ""
  508.         self.opacity = 0
  509.         bitmap = Cache.system(WINDOW_IMAGES["Item"])
  510.         @back_sprite = Sprite.new
  511.         @back_sprite.bitmap = bitmap
  512.       end
  513.     end
  514.     @column_max = NUM_OF_COLUMN
  515.     self.index = 0
  516.     @currentstore = 0
  517.     refresh
  518.   end
  519.  
  520.   def dispose
  521.     super
  522.    if USE_WINDOW_IMAGES
  523.      if WINDOW_IMAGES["Item"] != nil or ""
  524.        @back_sprite.dispose if @back_sprite != nil
  525.      end
  526.    end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # * Get Item
  530.   #--------------------------------------------------------------------------
  531.   def item
  532.     return @data[self.index]
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # * Whether or not to include in item list
  536.   #     item : item
  537.   #--------------------------------------------------------------------------
  538.   def include?(item)
  539.     return false if item == nil
  540.     if $game_temp.in_battle
  541.       return false unless item.is_a?(RPG::Item)
  542.     end
  543.     return true
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # * Whether or not to display in enabled state
  547.   #     item : item
  548.   #--------------------------------------------------------------------------
  549.   def enable?(item)
  550.     return $game_party.item_can_use?(item)
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # * Create Window Contents
  554.   #--------------------------------------------------------------------------
  555.   def create_contents
  556.     self.contents.dispose
  557.     self.contents = Bitmap.new(width - 32, [height - 32, row_max * ITEM_SQ_SPACING].max)
  558.   end
  559.  
  560.   def off_x
  561.     return (((self.width - 32) - (ITEM_SQ_SPACING * @column_max)) / 2)
  562.   end
  563.  
  564.   def off_y
  565.     return 0
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # * Refresh
  569.   #--------------------------------------------------------------------------
  570.   def refresh
  571.     @data = []
  572.     for item in $game_party.items
  573.       next unless include?(item)
  574.       @data.push(item)
  575.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  576.         self.index = @data.size - 1
  577.       end
  578.     end
  579.     @data.push(nil) if include?(nil)
  580.     @item_max = @data.size
  581.     create_contents
  582.     @reset = off_x
  583.     @nw_x = @reset
  584.     @nw_y = off_y
  585.     @coun = 0
  586.     self.contents.clear
  587.     for i in 0..@item_max
  588.     draw_item(i)
  589.     end
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # * Draw Icon
  593.   #     icon_index : Icon number
  594.   #     x     : draw spot x-coordinate
  595.   #     y     : draw spot y-coordinate
  596.   #     enabled    : Enabled flag. When false, draw semi-transparently.
  597.   #--------------------------------------------------------------------------
  598.   def draw_icon(icon_index, x, y, enabled = true)
  599.     bitmap = Cache.system("Iconset")
  600.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  601.     self.contents.blt(x, y, bitmap, rect, enabled ? 255 : UNUSABLE_OPACITY)
  602.   end
  603.   #--------------------------------------------------------------------------
  604.   # * Draw Item
  605.   #     index : item number
  606.   #--------------------------------------------------------------------------
  607.   def draw_item(itemz)
  608.     self.contents.font.color = normal_color
  609.     item = @data[itemz]
  610.     if item != nil
  611.     numberbox = Rect.new(@nw_x + ITEM_NUM_POS[0],@nw_y + ITEM_NUM_POS[1], RECT_SIZE, RECT_SIZE)
  612.     outline = Rect.new(0, 0, RECT_SIZE, RECT_SIZE)
  613.     sub_rect = Rect.new((BORDER_SIZE / 2), (BORDER_SIZE / 2),
  614.        (RECT_SIZE - BORDER_SIZE), (RECT_SIZE - BORDER_SIZE))
  615.       usable = $game_party.item_can_use?(item)  
  616.     if USE_IMAGES and USE_IMG_RECT
  617.       srect_image = ICY::HM_Style_Items.get_rect_image(item)
  618.       outline_sprite = Cache.system(srect_image)
  619.       self.contents.blt(@nw_x, @nw_y, outline_sprite, outline, usable ? 255 : UNUSABLE_OPACITY)
  620.     end
  621.        
  622.     if USE_BORDER_RECT  
  623.       srect_color = ICY::HM_Style_Items.get_rect_color(item)
  624.       outline_sprite = Bitmap.new(RECT_SIZE, RECT_SIZE)
  625.       outline_sprite.fill_rect(outline, srect_color)
  626.       outline_sprite.clear_rect(sub_rect)
  627.       self.contents.blt(@nw_x, @nw_y, outline_sprite, outline, usable ? 255 : UNUSABLE_OPACITY)
  628.     end
  629.    
  630.     if USE_MINI_ICONS
  631.       prep_minis = ICY::HM_Style_Items.get_mini_icon(item)
  632.       self.contents.blt(@nw_x + MINI_ICON_POS[0], @nw_y + MINI_ICON_POS[1], prep_minis[0], prep_minis[1], usable ? 255 : UNUSABLE_OPACITY)
  633.     end
  634.    
  635.     draw_icon(item.icon_index, @nw_x + ITEM_ICON_POS[0], @nw_y + ITEM_ICON_POS[1], usable) unless @data[itemz] == nil
  636.     number = $game_party.item_number(item)
  637.     # Writes Item Amount
  638.     old_font_size = self.contents.font.size
  639.     self.contents.font.size = 16
  640.     if DRAW_AMOUNT_FOR_1
  641.       self.contents.draw_text(numberbox, sprintf(ITEM_NUM_FORMAT, number), ITEM_NUM_ALIGN)
  642.     elsif DRAW_AMOUNT_FOR_1 == false and number > 1
  643.       self.contents.draw_text(numberbox, sprintf(ITEM_NUM_FORMAT, number), ITEM_NUM_ALIGN)
  644.     end
  645.     self.contents.font.size = old_font_size
  646.    
  647.     @coun += 1
  648.     @nw_x += ITEM_SQ_SPACING
  649.     end
  650.     if @coun == @column_max
  651.       @coun = 0
  652.       @nw_x = @reset
  653.       @nw_y += ITEM_SQ_SPACING
  654.     end
  655.   end
  656.  
  657.   #--------------------------------------------------------------------------
  658.   # * Get Top Row
  659.   #--------------------------------------------------------------------------
  660.   def top_row
  661.     return self.oy / ITEM_SQ_SPACING#WLH
  662.   end
  663.   #--------------------------------------------------------------------------
  664.   # * Set Top Row
  665.   #     row : row shown on top
  666.   #--------------------------------------------------------------------------
  667.   def top_row=(row)
  668.     row = 0 if row < 0
  669.     row = row_max - 1 if row > row_max - 1
  670.     self.oy = row * ITEM_SQ_SPACING#WLH
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # * Get Number of Rows Displayable on 1 Page
  674.   #--------------------------------------------------------------------------
  675.   def page_row_max
  676.     return (self.height / ITEM_SQ_SPACING)
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # * Get Number of Items Displayable on 1 Page
  680.   #--------------------------------------------------------------------------
  681.   def page_item_max
  682.     return page_row_max * @column_max #+ ITEM_SQ_SPACING
  683.   end
  684.   #--------------------------------------------------------------------------
  685.   # * Move cursor one page down
  686.   #--------------------------------------------------------------------------
  687.   def cursor_pagedown
  688.     if top_row + page_row_max < row_max
  689.       @index = [@index + page_item_max, @item_max - 1].min
  690.       self.top_row += page_row_max - ITEM_SQ_SPACING
  691.     end
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # * Move cursor one page up
  695.   #--------------------------------------------------------------------------
  696.   def cursor_pageup
  697.     if top_row > 0
  698.       @index = [@index - page_item_max, 0].max
  699.       self.top_row -= page_row_max - ITEM_SQ_SPACING
  700.     end
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # * Update cursor
  704.   #--------------------------------------------------------------------------
  705.   def update_cursor
  706.     if @index < 0                   # If the cursor position is less than 0
  707.       self.cursor_rect.empty        # Empty cursor
  708.     else                            # If the cursor position is 0 or more
  709.       row = @index / @column_max    # Get current row
  710.       if row < top_row              # If before the currently displayed
  711.         self.top_row = row          # Scroll up
  712.       end
  713.       if row > bottom_row           # If after the currently displayed
  714.         self.bottom_row = row       # Scroll down
  715.       end
  716.        y_l = @index / @column_max
  717.        y_pos = ((ITEM_SQ_SPACING * y_l)- self.oy) + off_y
  718.        x_l = self.index - (@column_max * y_l)
  719.        x_pos = (x_l * ITEM_SQ_SPACING) + off_x
  720.        if SELECTION_SIZE > RECT_SIZE
  721.          subitive = (SELECTION_SIZE - RECT_SIZE) / 2
  722.          self.cursor_rect.set(x_pos.to_i - subitive, y_pos.to_i - subitive, SELECTION_SIZE, SELECTION_SIZE)
  723.        elsif SELECTION_SIZE < RECT_SIZE
  724.          additive = (RECT_SIZE - SELECTION_SIZE) / 2
  725.          self.cursor_rect.set(x_pos.to_i + additive, y_pos.to_i + additive, SELECTION_SIZE, SELECTION_SIZE)
  726.         else
  727.         self.cursor_rect.set(x_pos.to_i, y_pos.to_i, SELECTION_SIZE, SELECTION_SIZE)
  728.        end
  729.     end
  730.   end
  731.   #--------------------------------------------------------------------------
  732.   # * Update Help Text
  733.   #--------------------------------------------------------------------------
  734.   def update_help
  735.     @help_window.set_text(item == nil ? "" : item.description)
  736.     @help_window.set_item(item)
  737.   end
  738. end
  739.  
  740. #==============================================================================
  741. # ** Scene_Item
  742. #------------------------------------------------------------------------------
  743. #  This class performs the item screen processing.
  744. #==============================================================================
  745.  
  746. class Scene_Item < Scene_Base
  747.   #--------------------------------------------------------------------------
  748.   # * Start processing
  749.   # ** Overwritten
  750.   #--------------------------------------------------------------------------
  751.   def start
  752.     super
  753.     window_sizes = ICY::HM_Style_Items::WINDOW_SIZES
  754.     create_menu_background
  755.     @viewport = Viewport.new(0, 0, 544, 416)
  756.     header_size = window_sizes["Header"]
  757.     @header_window = ICY_Item_Header_Window.new(header_size[0], header_size[1], header_size[2], header_size[3])
  758.     @header_window.opacity = header_size[4]
  759.     if $imported["MainMenuZealous"]
  760.      icon = YEZ::MENU::MENU_ICONS[:items]
  761.      else
  762.      icon = nil
  763.     end
  764.     @header_window.set_header(Vocab.item, icon, 0)
  765.     help_size = window_sizes["Help"]
  766.     @help_window = ICY_Item_Window_Help.new(help_size[0], help_size[1], help_size[2], help_size[3])
  767.     @help_window.viewport = @viewport
  768.     @help_window.opacity = help_size[4]
  769.     item_win_size = window_sizes["Item"]
  770.     @item_window = ICY_SC_Window_Item.new(item_win_size[0], item_win_size[1], item_win_size[2], item_win_size[3])
  771.     @item_window.viewport = @viewport
  772.     @item_window.opacity = item_win_size[4]
  773.     @item_window.help_window = @help_window
  774.     @item_window.active = false
  775.     @target_window = Window_MenuStatus.new(0, 0)
  776.     if $imported["ICY_HM_Style_Menu_Status"]
  777.       @target_win_help = ICY_Window_Menu_Status_Help.new(@target_window.x, @target_window.height)
  778.       @target_window.help_window = @target_win_help
  779.       @target_win_help.visible = false
  780.     end
  781.     hide_target_window
  782.   end
  783.   #--------------------------------------------------------------------------
  784.   # * Termination Processing
  785.   # ** Aliased
  786.   #--------------------------------------------------------------------------
  787.   alias icy_hm_style_inve_terminate terminate unless $@
  788.   def terminate
  789.     icy_hm_style_inve_terminate
  790.     @header_window.dispose
  791.     if $imported["ICY_HM_Style_Menu_Status"]
  792.       @target_win_help.dispose
  793.     end
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # * Show Target Window
  797.   #     right : Right justification flag (if false, left justification)
  798.   #--------------------------------------------------------------------------
  799.   alias icy_hm_item_show_target_window show_target_window unless $@
  800.   def show_target_window(*args)
  801.     icy_hm_item_show_target_window(*args)
  802.     if $imported["ICY_HM_Style_Menu_Status"]
  803.       @target_win_help.x = @target_window.x
  804.       @target_win_help.y = @target_window.height
  805.       @target_win_help.visible = true
  806.     end
  807.   end
  808.  
  809.   #--------------------------------------------------------------------------
  810.   # * Hide Target Window
  811.   #--------------------------------------------------------------------------
  812.   alias icy_hm_item_hide_target_window hide_target_window unless $@
  813.   def hide_target_window(*args)
  814.     icy_hm_item_hide_target_window(*args)
  815.     if $imported["ICY_HM_Style_Menu_Status"]
  816.       @target_win_help.visible = false
  817.     end
  818.   end
  819.   #--------------------------------------------------------------------------
  820.   # * Update Target Selection
  821.   #--------------------------------------------------------------------------
  822.   alias icy_hm_item_update_target_selection update_target_selection unless $@  
  823.   def update_target_selection(*args)
  824.     if $imported["ICY_HM_Style_Menu_Status"]
  825.       @target_win_help.update
  826.     end
  827.     icy_hm_item_update_target_selection(*args)
  828.   end
  829.   #--------------------------------------------------------------------------
  830.   # * Update Item Selection
  831.   #--------------------------------------------------------------------------
  832.   def update_item_selection
  833.     if Input.trigger?(Input::B)
  834.       Sound.play_cancel
  835.       return_scene
  836.     elsif Input.trigger?(Input::C)
  837.       @item = @item_window.item
  838.       if @item != nil
  839.         $game_party.last_item_id = @item.id
  840.       end
  841.       if $game_party.item_can_use?(@item)
  842.         Sound.play_decision
  843.         determine_item
  844.       else
  845.         Sound.play_buzzer
  846.       end
  847.     end
  848.   end
  849.  
  850.   #--------------------------------------------------------------------------
  851.   # * Use Item (apply effects to non-ally targets)
  852.   # ** Editted!
  853.   #--------------------------------------------------------------------------
  854.   def use_item_nontarget
  855.     Sound.play_use_item
  856.     $game_party.consume_item(@item)
  857.     @item_window.refresh #draw_item(@item_window.index)
  858.     @target_window.refresh
  859.     if $game_party.all_dead?
  860.       $scene = Scene_Gameover.new
  861.     elsif @item.common_event_id > 0
  862.       $game_temp.common_event_id = @item.common_event_id
  863.       $scene = Scene_Map.new
  864.     end
  865.   end
  866. end
  867.  
  868. #------------------------------------------------------------------------------#
  869. # ** KGC_Catergorize_Item Patch
  870. #------------------------------------------------------------------------------#
  871. if ICY::HM_Style_Items::KGC_Catergorize
  872. #==============================================================================
  873. # ■ Window_Item
  874. #==============================================================================
  875.  
  876. class ICY_SC_Window_Item < Window_Selectable # Made it apart of my Window_Item
  877.   #--------------------------------------------------------------------------
  878.   # ● 公開インスタンス変数
  879.   #--------------------------------------------------------------------------
  880.   attr_reader   :category                 # カテゴリ
  881.   #--------------------------------------------------------------------------
  882.   # ● オブジェクト初期化
  883.   #     x      : ウィンドウの X 座標
  884.   #     y      : ウィンドウの Y 座標
  885.   #     width  : ウィンドウの幅
  886.   #     height : ウィンドウの高さ
  887.   #--------------------------------------------------------------------------
  888.   alias initialize_KGC_CategorizeItem initialize
  889.   def initialize(x, y, width, height)
  890.     @category = 0
  891.  
  892.     initialize_KGC_CategorizeItem(x, y, width, height)
  893.     refresh
  894.   end
  895.   #--------------------------------------------------------------------------
  896.   # ○ カテゴリ設定
  897.   #--------------------------------------------------------------------------
  898.   def category=(value)
  899.     @category = value
  900.     self.index = 0 # Added this
  901.     refresh
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # ● アイテムをリストに含めるかどうか
  905.   #     item : アイテム
  906.   #--------------------------------------------------------------------------
  907.   alias include_KGC_CategorizeItem? include?
  908.   def include?(item)
  909.     return false if item == nil
  910.  
  911.     # 「全種」なら無条件で含める
  912.     if @category == KGC::CategorizeItem::RESERVED_CATEGORY_INDEX["All Items"]
  913.       return true
  914.     end
  915.  
  916.     result = include_KGC_CategorizeItem?(item)
  917.  
  918.     unless result
  919.       # 使用可能なら追加候補とする
  920.       if $imported["UsableEquipment"] && $game_party.item_can_use?(item)
  921.         result = true
  922.       end
  923.     end
  924.     # 戦闘外ならカテゴリ一致判定
  925.     unless $game_temp.in_battle
  926.       result &= (item.item_category.include?(@category))
  927.     end
  928.  
  929.     return result
  930.   end
  931. end
  932. end
  933. ################################################################################
  934. #------------------------------------------------------------------------------#
  935. #END\\\END\\\END\\\END\\\END\\\END\\\END///END///END///END///END///END///END///#
  936. #------------------------------------------------------------------------------#
  937. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment