查看: 3485|回复: 2

[已经解决] 请问贵重物品、武器等界面可以直接用脚本调用吗?

[复制链接]
梦石
0
星屑
1290
在线时间
52 小时
注册时间
2017-2-2
回帖
25
发表于 2019-8-17 04:48:40 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 吉吉阿茶 于 2019-8-17 04:49 编辑

大家好,是这样的,我用了这个物品栏的脚本,但是发现pgup和pgdn不是很方便按,所以用事件分成了四个入口,想分别对应成道具、线索、装备、其他类四种,
但是在论坛找了很久也没发现应该怎样用脚本直接调用到对应的物品、贵重物品、武器、防具这样的界面,所以来打扰一下大家了>.<……

脚本折叠
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 带有大图标,推展线索的物品栏
  4. #------------------------------------------------------------------------------
  5. # 适合解密类游戏的菜单,
  6. # 脚本:VIPArcher
  7. # 美工 && 创意:断电
  8. #  -- 本脚本来自 http://rm.66rpg.com 使用或转载请保留以上信息。
  9. #==============================================================================
  10. # 使用说明:
  11. # 物品备注栏备注 <image:文件名> 显示大图
  12. # 物品备注栏备注 <no se> 使用不播放使用道具音效
  13. # 物品备注栏备注 <clue:内容> 显示线索,支持控制符。
  14. #==============================================================================
  15. # ■ 设定部分
  16. #==============================================================================
  17. module VIPArcher
  18.   BACKGROUND = "itembackground"   #背景图片文件名
  19.   module Item_Help   #物品栏的帮助窗口
  20.     X = 40                        # 窗口x坐标
  21.     Y = 50                        # 窗口y坐标
  22.     Width = 240                   # 窗口宽度
  23.     Height = 72                   # 窗口高度
  24.     Font_Outline = false          # 描边
  25.     Font_Bold = false             # 粗体
  26.     Font_Color = Color.new(0,0,0) # 字体颜色
  27.     Font_Size = 20                # 字体大小
  28.     Font_Name = "微软雅黑"        # 字体名称
  29.   end
  30.   module Item_Name  #物品的名称窗口
  31.     X = 52                        # 窗口x坐标
  32.     Y = 10                        # 窗口y坐标
  33.     Width = 220                   # 窗口宽度
  34.     Height = 52                   # 窗口高度
  35.     Font_Outline = false          # 描边
  36.     Font_Bold = false             # 粗体
  37.     Font_Color = Color.new(0,0,0) # 字体颜色
  38.     Font_Size = 28                # 字体大小
  39.     Font_Name = "微软雅黑"        # 字体名称
  40.   end
  41.   module Item_List  #物品栏的列表窗口
  42.     X = 282                       # 窗口x坐标
  43.     Y = 100                       # 窗口y坐标
  44.     Width = 220                   # 窗口宽度
  45.     Height = 300                  # 窗口高度
  46.     Font_Outline = false          # 描边
  47.     Font_Bold = false             # 粗体
  48.     Font_Color = Color.new(0,0,0) # 字体颜色
  49.     Font_Size = 28                # 字体大小
  50.     Font_Name = "微软雅黑"        # 字体名称
  51.     No_Number = false             #是否描绘物品个数
  52.   end
  53.   module Item_Note  #物品的备注信息窗口
  54.     X = 40                        # 窗口x坐标
  55.     Y = 116                       # 窗口y坐标
  56.     Width = 240                   # 窗口宽度
  57.     Height = 100                  # 窗口高度
  58.     Regex = /<Clue:\s*(.*)>/im    # 正则匹配式
  59.     Font_Outline = false          # 描边
  60.     Font_Bold = false             # 粗体
  61.     Font_Color = Color.new(0,0,0) # 字体颜色
  62.     Font_Size = 20                # 字体大小
  63.     Font_Name = "微软雅黑"        # 字体名称
  64.   end
  65.   module Item_Image  #物品的大图窗口
  66.     X = 0                         # 窗口x坐标
  67.     Y = 240                       # 窗口y坐标
  68.     Width = 175                   # 窗口宽度
  69.     Height = 175                  # 窗口高度
  70.     Regex = /<Image:\s*(\S*)>/i   # 正则匹配式
  71.   end
  72.   module Item_Category  #物品的分类窗口
  73.     X = Graphics.width - 255      # 窗口x坐标
  74.     Y = 0                         # 窗口y坐标
  75.     Width = 255                   # 窗口宽度
  76.     Height = 100                  # 窗口高度
  77.     #各分类的对应的图标文件名(分别对应着[道具,武器,贵重物品,防具])
  78.     #这里有几项就有几个分类
  79.     Category_Name = ["道具","收藏","线索"]
  80.   end
  81. end
  82. module Cache
  83.   #--------------------------------------------------------------------------
  84.   # ● 获取物品栏图片
  85.   #--------------------------------------------------------------------------  
  86.   def self.ItemImage(filename)
  87.     load_bitmap("Graphics/itemimage/", filename)
  88.   end
  89. end
  90. class Window_Base < Window
  91.   #----------------------------------------------------------------------
  92.   # ● 绘制物品栏图片  
  93.   #--------------------------------------------------------------------------
  94.    def draw_itemimage(x, y, itemimage)
  95.     bitmap = Cache.ItemImage(itemimage)
  96.     contents.blt(x, y, bitmap, bitmap.rect)
  97.     bitmap.dispose
  98.   end
  99. end
  100. class Window_Selectable < Window_Base
  101.   attr_reader   :item_image_window           # 图片窗口
  102.   attr_reader   :item_name_window            # 名字窗口
  103.   attr_reader   :item_note_window            # 名字窗口
  104.   #--------------------------------------------------------------------------
  105.   # ● 设置图片帮助窗口
  106.   #--------------------------------------------------------------------------
  107.   def item_image_window=(item_image_window)
  108.     @item_image_window = item_image_window
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 设置名称帮助窗口
  112.   #--------------------------------------------------------------------------
  113.   def item_name_window=(item_name_window)
  114.     @item_name_window = item_name_window
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 设置备注帮助窗口
  118.   #--------------------------------------------------------------------------
  119.   def item_note_window=(item_note_window)
  120.     @item_note_window = item_note_window
  121.   end
  122. end
  123. class Window_Help < Window_Base
  124.   include VIPArcher::Item_Help
  125.   #--------------------------------------------------------------------------
  126.   # ● 初始化对象
  127.   #--------------------------------------------------------------------------
  128.   def initialize(line_number = 2,width = Graphics.width)
  129.     super(0, 0,width, fitting_height(line_number))
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # ● 重置字体设置
  133.   #--------------------------------------------------------------------------
  134.   alias vip_20140921_rfs reset_font_settings
  135.   def reset_font_settings
  136.     vip_20140921_rfs
  137.     if SceneManager.scene_is?(Scene_Item)
  138.       contents.font.name = Font_Name
  139.       contents.font.outline = Font_Outline
  140.       contents.font.color.set(Font_Color)
  141.       contents.font.size = Font_Size
  142.       contents.font.bold = Font_Bold
  143.     end
  144.   end
  145. end
  146. #显示物品备注信息的窗口
  147. class Window_Item_Note < Window_Base
  148.   include VIPArcher::Item_Note
  149.   #--------------------------------------------------------------------------
  150.   # ● 设置内容
  151.   #--------------------------------------------------------------------------
  152.   def set_text(text)
  153.     if text != @text
  154.       @text = text
  155.       refresh
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 清除
  160.   #--------------------------------------------------------------------------
  161.   def clear
  162.     set_text("")
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 设置物品
  166.   #     item : 技能、物品等
  167.   #--------------------------------------------------------------------------
  168.   def set_item(item)
  169.     item.note =~ Regex if item
  170.     $1 == nil ? set_text("") : set_text($1)
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● 刷新
  174.   #--------------------------------------------------------------------------
  175.   def refresh
  176.     contents.clear
  177.     draw_text_ex(0, 0, @text)
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 重置字体设置
  181.   #--------------------------------------------------------------------------
  182.   alias vip_20140921_rfs reset_font_settings
  183.   def reset_font_settings
  184.     vip_20140921_rfs
  185.     if SceneManager.scene_is?(Scene_Item)
  186.       contents.font.name = Font_Name
  187.       contents.font.outline = Font_Outline
  188.       contents.font.color.set(Font_Color)
  189.       contents.font.size = Font_Size
  190.       contents.font.bold = Font_Bold
  191.     end
  192.   end
  193. end
  194. #显示物品名称的窗口
  195. class Window_Item_Name < Window_Base
  196.   include VIPArcher::Item_Name
  197.   #--------------------------------------------------------------------------
  198.   # ● 设置内容
  199.   #--------------------------------------------------------------------------
  200.   def set_text(text)
  201.     if text != @text
  202.       @text = text
  203.       refresh
  204.     end
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   # ● 清除
  208.   #--------------------------------------------------------------------------
  209.   def clear
  210.     set_text("")
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 设置物品
  214.   #     item : 技能、物品等
  215.   #--------------------------------------------------------------------------
  216.   def set_item(item)
  217.     set_text(item ? item.name : "")
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 刷新
  221.   #--------------------------------------------------------------------------
  222.   def refresh
  223.     contents.clear
  224.     contents.font.name = Font_Name
  225.     contents.font.outline = Font_Outline
  226.     contents.font.color.set(Font_Color)
  227.     contents.font.size = Font_Size
  228.     contents.font.bold = Font_Bold
  229.     draw_text(4, 0, 220, line_height, @text, 0)
  230.   end
  231. end
  232. #显示物品详细图片的窗口
  233. class Window_Item_Image < Window_Base
  234.   include VIPArcher::Item_Image
  235.   #--------------------------------------------------------------------------
  236.   # ● 设置内容
  237.   #--------------------------------------------------------------------------
  238.   def set_text(text)
  239.     if text != @text
  240.       @text = text
  241.       refresh
  242.     end
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 清除
  246.   #--------------------------------------------------------------------------
  247.   def clear
  248.     set_text("")
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 设置物品
  252.   #     item : 技能、物品等
  253.   #--------------------------------------------------------------------------
  254.   def set_item(item)
  255.     item.note =~ Regex if item
  256.     $1 == nil ? set_text("") : set_text($1)
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 刷新
  260.   #--------------------------------------------------------------------------
  261.   def refresh
  262.     contents.clear
  263.     draw_itemimage(0,0,@text) if @text != ""
  264.   end
  265. end
  266. #显示分类名字图片的窗口
  267. class Window_Item_Category < Window_Base
  268.   include VIPArcher::Item_Category
  269.   def initialize(x, y, width, height)
  270.     super
  271.     @category_name = Category_Name[0]
  272.     refresh
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 设置分类图片
  276.   #--------------------------------------------------------------------------
  277.   def category_name=(category)
  278.     return if @category_name == category
  279.     @category_name = category
  280.     refresh
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ● 刷新窗口
  284.   #--------------------------------------------------------------------------
  285.   def refresh
  286.     contents.clear
  287.     draw_itemimage(0,0,@category_name)
  288.   end
  289. end
  290. class Window_ItemList < Window_Selectable
  291.   include VIPArcher::Item_List
  292.   alias vip20140921_update_help update_help
  293.   attr_accessor :category_id
  294.   #--------------------------------------------------------------------------
  295.   # ● 初始化对象
  296.   #--------------------------------------------------------------------------
  297.   def initialize(x, y, width, height)
  298.     super
  299.     @category_id = 0
  300.     @category = :item #VIP
  301.     @data = []
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 获取列数
  305.   #--------------------------------------------------------------------------
  306.   def col_max
  307.     return scene_im? ? 1 : 2
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 获取行高
  311.   #--------------------------------------------------------------------------
  312.   def line_height
  313.     return scene_im? ? 33 : 24
  314.   end
  315.   def scene_im?
  316.     SceneManager.scene_is?(Scene_Item) ||
  317.     SceneManager.scene_is?(Scene_Map)
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 绘制物品(取消半透明图标的y+4)
  321.   #--------------------------------------------------------------------------
  322.   def draw_item_name(item, x, y, enabled = true, width = 172)
  323.     return unless item
  324.     draw_icon(item.icon_index, x, y + 4)
  325.     change_color(normal_color)
  326.     if SceneManager.scene_is?(Scene_Item) ||
  327.       SceneManager.scene_is?(Scene_Map)
  328.       contents.font.name = Font_Name
  329.       contents.font.outline = Font_Outline
  330.       contents.font.color.set(Font_Color)
  331.       contents.font.size = Font_Size
  332.       contents.font.bold = Font_Bold
  333.     end
  334.     draw_text(x + 24, y, width, line_height, item.name)
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 绘制物品个数
  338.   #--------------------------------------------------------------------------
  339.   def draw_item_number(rect, item);end unless No_Number
  340.   #--------------------------------------------------------------------------
  341.   # ● 更新帮助内容
  342.   #--------------------------------------------------------------------------
  343.   def update_help
  344.     vip20140921_update_help
  345.     @item_image_window.set_item(item) if @item_image_window
  346.     @item_name_window.set_item(item) if @item_name_window
  347.     @item_note_window.set_item(item) if @item_note_window
  348.   end
  349. end
  350. #==============================================================================
  351. # ■ Scene_Item
  352. #------------------------------------------------------------------------------
  353. #  物品画面
  354. #==============================================================================

  355. class Scene_Item < Scene_ItemBase
  356.   include VIPArcher
  357.   #--------------------------------------------------------------------------
  358.   # ● 开始处理
  359.   #--------------------------------------------------------------------------
  360.   def start
  361.     super
  362.     create_help_window
  363.     create_item_window
  364.     create_item_image_window
  365.     create_item_name_window
  366.     create_category_window
  367.     create_item_note_window
  368.     on_category_ok
  369.     window_opacity
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 生成物品窗口
  373.   #--------------------------------------------------------------------------
  374.   def create_item_window
  375.     x = Item_List::X
  376.     y = Item_List::Y
  377.     w = Item_List::Width
  378.     h = Item_List::Height
  379.     @item_window = Window_ItemList.new(x,y,w,h)
  380.     @item_window.viewport = @viewport
  381.     @item_window.help_window = @help_window
  382.     @item_window.set_handler(:ok,     method(:on_item_ok))
  383.     @item_window.set_handler(:cancel, method(:return_scene))
  384.     @item_window.set_handler(:pagedown, method(:next_category))
  385.     @item_window.set_handler(:pageup,   method(:prev_category))
  386.   end
  387.   #分类窗口
  388.   def create_category_window
  389.     x = Item_Category::X
  390.     y = Item_Category::Y
  391.     w = Item_Category::Width
  392.     h = Item_Category::Height
  393.     @category_window = Window_Item_Category.new(x,y,w,h)
  394.     @category_window.viewport = @viewport
  395.   end
  396.   #上一分类
  397.   def prev_category
  398.     size = Item_Category::Category_Name.size - 1
  399.     @item_window.category_id == 0 ? @item_window.category_id = size : @item_window.category_id -= 1
  400.     on_category_change
  401.     @item_window.activate
  402.     @item_window.index = 0
  403.   end
  404.   #下一分类
  405.   def next_category
  406.     size = Item_Category::Category_Name.size - 1
  407.     @item_window.category_id == size ? @item_window.category_id = 0 : @item_window.category_id += 1
  408.     on_category_change
  409.     @item_window.activate
  410.     @item_window.index = 0
  411.   end
  412.   #切换分类
  413.   def on_category_change
  414.     case @item_window.category_id
  415.     when 0
  416.       @item_window.category = :item
  417.       @category_window.category_name = Item_Category::Category_Name[0]
  418.     when 1
  419.       @item_window.category = :weapon
  420.       @category_window.category_name = Item_Category::Category_Name[1]
  421.     when 2
  422.       @item_window.category = :key_item
  423.       @category_window.category_name = Item_Category::Category_Name[2]
  424.     when 3
  425.       @item_window.category = :armor
  426.       @category_window.category_name = Item_Category::Category_Name[3]
  427.     end
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 生成帮助窗口
  431.   #--------------------------------------------------------------------------
  432.   def create_help_window
  433.     @help_window = Window_Help.new(2,Item_Help::Width)
  434.     @help_window.viewport = @viewport
  435.     @help_window.x = Item_Help::X
  436.     @help_window.y = Item_Help::Y
  437.     @help_window.height = Item_Help::Height
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ● 生成物品图片窗口
  441.   #--------------------------------------------------------------------------
  442.   def create_item_image_window
  443.     x = Item_Image::X
  444.     y = Item_Image::Y
  445.     w = Item_Image::Width
  446.     h = Item_Image::Height
  447.     @item_image_window = Window_Item_Image.new(x,y,w,h)
  448.     @item_image_window.viewport = @viewport
  449.     @item_window.item_image_window = @item_image_window
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 生成名称窗口
  453.   #--------------------------------------------------------------------------
  454.   def create_item_name_window
  455.     x = Item_Name::X
  456.     y = Item_Name::Y
  457.     w = Item_Name::Width
  458.     h = Item_Name::Height
  459.     @item_name_window = Window_Item_Name.new(x,y,w,h)
  460.     @item_name_window.viewport = @viewport
  461.     @item_window.item_name_window = @item_name_window
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 备注信息窗口
  465.   #--------------------------------------------------------------------------
  466.   def create_item_note_window
  467.     x = Item_Note::X
  468.     y = Item_Note::Y
  469.     w = Item_Note::Width
  470.     h = Item_Note::Height
  471.     @item_note_window = Window_Item_Note.new(x,y,w,h)
  472.     @item_note_window.viewport = @viewport
  473.     @item_window.item_note_window = @item_note_window
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # ● 背景透明
  477.   #--------------------------------------------------------------------------
  478.   def window_opacity
  479.     @item_window.opacity = 0
  480.     @help_window.opacity = 0
  481.     @item_image_window.opacity = 0
  482.     @category_window.opacity = 0
  483.     @item_name_window.opacity = 0
  484.     @item_note_window.opacity = 0
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● 生成背景
  488.   #--------------------------------------------------------------------------
  489.   def create_background
  490.     @background_sprite = Sprite.new
  491.     @background_sprite.bitmap = Cache.ItemImage(BACKGROUND)
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 释放背景
  495.   #--------------------------------------------------------------------------
  496.   def dispose_background
  497.     @background_sprite.dispose
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● 分类“确定”
  501.   #--------------------------------------------------------------------------
  502.   def on_category_ok
  503.     @item_window.activate
  504.     @item_window.select_last
  505.     @item_window.refresh
  506.     @help_window.set_item(item)  #VIP
  507.     @item_image_window.set_item(item) #VIP
  508.     @item_name_window.set_item(item) #VIP
  509.     @item_note_window.set_item(item) #VIP
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● 播放使用物品声效  SION
  513.   #--------------------------------------------------------------------------
  514.   def play_se_for_item
  515.     Sound.play_use_item unless item.note.include? "<no se>"
  516.   end
  517. end
复制代码

老黄鸡

梦石
4
星屑
45700
在线时间
7948 小时
注册时间
2009-7-6
回帖
13338

MZ评测员RM创作大赛01组委会开拓者贵宾

发表于 2019-8-17 07:14:06 | 显示全部楼层
在大约368行
start方法中,往create_item_note_window和on_category_ok中间添加两行
  1. @item_window.category_id = $game_variables[33]
  2. on_category_change
复制代码


即可让分类的初始状态为变量33号的值,0,1,2分别代表道具,收藏,线索

点评

!!非常感谢!  发表于 2019-8-17 11:05

评分

参与人数 2星屑 +50 赞 +1 收起 理由
VIPArcher + 50 黄鸡叔叔来分类
吉吉阿茶 + 1 我很赞同

查看全部评分

RGDirect - DirectX驱动的RGSS,点我了解.
(排满,暂停)RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部