#encoding:utf-8
#==============================================================================
# ■ 带有大图标,推展线索的物品栏
#------------------------------------------------------------------------------
# 适合解密类游戏的菜单,
# 脚本:VIPArcher
# 美工 && 创意:断电
#  -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。
#==============================================================================
# 使用说明:
# 物品备注栏备注 <image:文件名> 显示大图
# 物品备注栏备注 <no se> 使用不播放使用道具音效
# 物品备注栏备注 <clue:内容> 显示线索,支持控制符。
#==============================================================================
# ■ 设定部分
#==============================================================================
module VIPArcher
  BACKGROUND = "itembackground"   #背景图片文件名
  module Item_Help   #物品栏的帮助窗口
    X = 40                        # 窗口x坐标
    Y = 50                        # 窗口y坐标
    Width = 240                   # 窗口宽度
    Height = 72                   # 窗口高度
    Font_Outline = false          # 描边
    Font_Bold = false             # 粗体
    Font_Color = Color.new(0,0,0) # 字体颜色
    Font_Size = 14                # 字体大小
    Font_Name = "黑体"        # 字体名称
  end
  module Item_Name  #物品的名称窗口
    X = 52                        # 窗口x坐标
    Y = 10                        # 窗口y坐标
    Width = 220                   # 窗口宽度
    Height = 52                   # 窗口高度
    Font_Outline = false          # 描边
    Font_Bold = false             # 粗体
    Font_Color = Color.new(0,0,0) # 字体颜色
    Font_Size = 22                # 字体大小
    Font_Name = "黑体"        # 字体名称
  end
  module Item_List  #物品栏的列表窗口
    X = 282                       # 窗口x坐标
    Y = 100                       # 窗口y坐标
    Width = 220                   # 窗口宽度
    Height = 300                  # 窗口高度
    Font_Outline = false          # 描边
    Font_Bold = false             # 粗体
    Font_Color = Color.new(0,0,0) # 字体颜色
    Font_Size = 20                # 字体大小
    Font_Name = "黑体"        # 字体名称
    No_Number = false             #是否描绘物品个数
  end
  module Item_Note  #物品的备注信息窗口
    X = 40                        # 窗口x坐标
    Y = 116                       # 窗口y坐标
    Width = 240                   # 窗口宽度
    Height = 100                  # 窗口高度
    Regex = /<Clue:\s*(.*)>/im    # 正则匹配式
    Font_Outline = false          # 描边
    Font_Bold = false             # 粗体
    Font_Color = Color.new(0,0,0) # 字体颜色
    Font_Size = 14               # 字体大小
    Font_Name = "黑体"        # 字体名称
  end
  module Item_Image  #物品的大图窗口
    X = 0                         # 窗口x坐标
    Y = 240                       # 窗口y坐标
    Width = 175                   # 窗口宽度
    Height = 175                  # 窗口高度
    Regex = /<Image:\s*(\S*)>/i   # 正则匹配式
  end
  module Item_Category  #物品的分类窗口 !!!!
#    X = Graphics.width - 255      # 窗口x坐标
    X = -12
#    Y = 0                         # 窗口y坐标
    Y = -8
 #   Width = 255                   # 窗口宽度
 #   Height = 100                  # 窗口高度
    Width = 544 + 12
    Height = 416
    #各分类的对应的图标文件名(分别对应着[道具,武器,贵重物品,防具])
    #这里有几项就有几个分类
    Category_Name = ["道具","藏品","花卉","配方"]
  end
end
module Cache
  #--------------------------------------------------------------------------
  # ● 获取物品栏图片
  #--------------------------------------------------------------------------  
  def self.ItemImage(filename) 
    load_bitmap("Graphics/Pictures/", filename) #!!
  end
end
class Window_Base < Window
  #----------------------------------------------------------------------
  # ● 绘制物品栏图片
  #--------------------------------------------------------------------------
   def draw_itemimage(x, y, itemimage)
    bitmap = Cache.ItemImage(itemimage)
    contents.blt(x, y, bitmap, bitmap.rect)
    bitmap.dispose
  end
end
class Window_Selectable < Window_Base
  attr_reader   :item_image_window           # 图片窗口
  attr_reader   :item_name_window            # 名字窗口
  attr_reader   :item_note_window            # 名字窗口
  #--------------------------------------------------------------------------
  # ● 设置图片帮助窗口
  #--------------------------------------------------------------------------
  def item_image_window=(item_image_window)
    @item_image_window = item_image_window
  end
  #--------------------------------------------------------------------------
  # ● 设置名称帮助窗口
  #--------------------------------------------------------------------------
  def item_name_window=(item_name_window)
    @item_name_window = item_name_window
  end
  #--------------------------------------------------------------------------
  # ● 设置备注帮助窗口
  #--------------------------------------------------------------------------
  def item_note_window=(item_note_window)
    @item_note_window = item_note_window
  end
end
class Window_Help < Window_Base
  include VIPArcher::Item_Help
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(line_number = 2,width = Graphics.width)
    super(0, 0,width, fitting_height(line_number))
  end
  #--------------------------------------------------------------------------
  # ● 重置字体设置
  #--------------------------------------------------------------------------
  alias vip_20140921_rfs reset_font_settings
  def reset_font_settings
    vip_20140921_rfs
    if SceneManager.scene_is?(Scene_Item)
      contents.font.name = Font_Name
      contents.font.outline = Font_Outline
      contents.font.color.set(Font_Color)
      contents.font.size = Font_Size
      contents.font.bold = Font_Bold
    end
  end
end
#显示物品备注信息的窗口
class Window_Item_Note < Window_Base
  include VIPArcher::Item_Note
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 设置物品
  #     item : 技能、物品等
  #--------------------------------------------------------------------------
  def set_item(item)
    item.note =~ Regex if item
    $1 == nil ? set_text("") : set_text($1)
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(0, 0, @text)
  end
  #--------------------------------------------------------------------------
  # ● 重置字体设置
  #--------------------------------------------------------------------------
  alias vip_20140921_rfs reset_font_settings
  def reset_font_settings
    vip_20140921_rfs
    if SceneManager.scene_is?(Scene_Item)
      contents.font.name = Font_Name
      contents.font.outline = Font_Outline
      contents.font.color.set(Font_Color)
      contents.font.size = Font_Size
      contents.font.bold = Font_Bold
    end
  end
end
#显示物品名称的窗口
class Window_Item_Name < Window_Base
  include VIPArcher::Item_Name
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 设置物品
  #     item : 技能、物品等
  #--------------------------------------------------------------------------
  def set_item(item)
    set_text(item ? item.name : "")
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    contents.font.name = Font_Name
    contents.font.outline = Font_Outline
    contents.font.color.set(Font_Color)
    contents.font.size = Font_Size
    contents.font.bold = Font_Bold
    draw_text(4, 0, 220, line_height, @text, 0)
  end
end
#显示物品详细图片的窗口
class Window_Item_Image < Window_Base
  include VIPArcher::Item_Image
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 设置物品
  #     item : 技能、物品等
  #--------------------------------------------------------------------------
  def set_item(item)
    item.note =~ Regex if item
    $1 == nil ? set_text("") : set_text($1)
  end
  #--------------------------------------------------------------------------
  # ● 刷新!!!
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
 
    bitmap = Cache.ItemImage(@text)
 
    a = 76 - bitmap.width / 2
    b = 76 - bitmap.height / 2
 
   # draw_itemimage(0,0,@text) if @text != ""
   draw_itemimage(a,b,@text) if @text != ""
 
  end
end
#显示分类名字图片的窗口
class Window_Item_Category < Window_Base
  include VIPArcher::Item_Category
  def initialize(x, y, width, height)
    super
    @category_name = Category_Name[0]
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 设置分类图片
  #--------------------------------------------------------------------------
  def category_name=(category)
    return if @category_name == category
    @category_name = category
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 刷新窗口
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_itemimage(0,0,@category_name)
  end
end
class Window_ItemList < Window_Selectable
  include VIPArcher::Item_List
  alias vip20140921_update_help update_help
  attr_accessor :category_id
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    @category_id = 0
    @category = :item #VIP
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return scene_im? ? 1 : 2
  end
  #--------------------------------------------------------------------------
  # ● 获取行高
  #--------------------------------------------------------------------------
  def line_height
    return scene_im? ? 33 : 24
  end
  def scene_im?
    SceneManager.scene_is?(Scene_Item) ||
    SceneManager.scene_is?(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # ● 绘制物品(取消半透明图标的y+4) !!!!!!
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
 #   draw_icon(item.icon_index, x, y + 4)
    change_color(normal_color)
    if SceneManager.scene_is?(Scene_Item) ||
      SceneManager.scene_is?(Scene_Map)
      contents.font.name = Font_Name
      contents.font.outline = Font_Outline
      contents.font.color.set(Font_Color)
      contents.font.size = Font_Size
      contents.font.bold = Font_Bold
    end