查看: 3203|回复: 2

[原创发布] TyStatus - 可交互式状态页面

[复制链接]
梦石
2
星屑
6777
在线时间
501 小时
注册时间
2018-3-23
回帖
487

R考场第七期银奖

发表于 2020-3-20 22:39:19 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 MCCF 于 2020-3-20 23:13 编辑

TyStatus和TyPath一样,都是作者突发奇想作出的玩意儿,大概兼容性和用途还是不错的吧……(保命)

前言
众所周知,RMVA自带的状态窗口仅仅能够让玩家查看数据,而不能交互式地点击查看详情。
TyStatus重构了状态页面,使得玩家可以自由地选择指定内容,并查看详细信息。
目前的效果是,可以左右移动光标来查看角色附着的状态信息了。

截图

回车键查看状态信息

回车键查看状态信息

左右移动光标选择状态

左右移动光标选择状态


脚本
  1. #==============================================================================
  2. # TyPath寻路 V1.0
  3. #    by MCCF
  4. #------------------------------------------------------------------------------
  5. # [说明]
  6. #    - RMVA自带的状态窗口仅仅能够让玩家查看数据,而不能交互式地点击查看详情。
  7. #    - TyStatus重构了状态页面,使得玩家可以自由地选择指定内容,并查看详细信息。
  8. #
  9. #    - 目前提供了快速查看角色附着的状态信息的功能,玩家就不会因不知道状态的具体效果
  10. #      而不知所措了。
  11. #    - 注意状态和BUFF的区别:BUFF是可能并非由状态导致的强化 / 弱化效果(例如技能
  12. #      效果),但是也可以在状态页面中显示。
  13. #------------------------------------------------------------------------------
  14. # [使用方法]
  15. #    - 复制到Main之前
  16. #    - 在状态-备注中添加<desc>内容</desc>格式的备注,可以设置在状态页面显示的说明
  17. #      信息(支持换行和转义符)。例如"<desc>该状态可大幅提升\I[116]攻击力</desc>"。
  18. #    - <desc>默认支持最多两行,每行约10个中文全角字符。
  19. #------------------------------------------------------------------------------
  20. # [使用条款]
  21. #    - 只要署名MCCF即可。只要不以自己的名义发布,您可以自由修改此脚本。
  22. #------------------------------------------------------------------------------
  23. # [兼容性]
  24. #    - 对状态页面的修改是基于原生状态页面的,如需要支持在非原生状态页面上制作交互式
  25. #      功能,则需要调整Window_Status#item_rect的内容。
  26. #    - 由于对状态界面进行了部分重构,可能与少数的魔改状态页面的脚本不兼容。
  27. #------------------------------------------------------------------------------
  28. #  通用配置模块  
  29. #==============================================================================
  30. module TyStatus_Config

  31.   # 基本设置 ------------------------------------------------------------------
  32.   
  33.   # 指示是否启用TyStatus的开关ID
  34.   # 为0则不使用开关控制,始终启用
  35.   TYSTATUS_SWITCH_ID = 0
  36.   
  37.   # 用语 ------------------------------------------------------------------
  38.   
  39.   # 状态/BUFF详情的标题用语
  40.   TYSTATUS_TITLE = "状态详情"
  41.   
  42.   # 正面BUFF详情的内容用语
  43.   # %s将分别被替换为BUFF的效果及BUFF的效果倍率(百分数)
  44.   TYSTATUS_BUFF_VOCAB = "%s 增加 %s% 效果"
  45.   
  46.   # 负面BUFF详情的内容用语
  47.   TYSTATUS_DEBUFF_VOCAB = "%s 减少 %s% 效果"
  48.   
  49. end
  50. #==============================================================================
  51. #  设定结束
  52. #==============================================================================

  53. #==============================================================================
  54. # ■ RPG::State
  55. #------------------------------------------------------------------------------
  56. #  状态的数据类。
  57. #==============================================================================

  58. class RPG::State
  59.   #--------------------------------------------------------------------------
  60.   # ● 获取说明信息
  61.   #--------------------------------------------------------------------------
  62.   def state_desc
  63.     return /<desc>([\s\S]*)<\/desc>/i =~ @note ? $1 : ""
  64.   end
  65. end

  66. #==============================================================================
  67. # ■ Game_BattlerBase
  68. #------------------------------------------------------------------------------
  69. #  管理战斗者的类。主要含有能力值计算的方法。Game_Battler 类的父类。
  70. #==============================================================================

  71. class Game_BattlerBase
  72.   #--------------------------------------------------------------------------
  73.   # ● 定义实例变量
  74.   #--------------------------------------------------------------------------
  75.   attr_reader   :buffs                    # 强化 / 弱化列表
  76. end

  77. #==============================================================================
  78. # ■ Scene_Status
  79. #------------------------------------------------------------------------------
  80. #  状态画面
  81. #==============================================================================

  82. class Scene_Status < Scene_MenuBase
  83.   #--------------------------------------------------------------------------
  84.   # ● 开始处理
  85.   #--------------------------------------------------------------------------
  86.   alias tystatus_start start
  87.   def start
  88.     tystatus_start
  89.     @detail_window = Window_StatusDetail.new
  90.     @detail_window.hide
  91.     @status_window.activate
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 打开详情窗口
  95.   #--------------------------------------------------------------------------
  96.   def call_detail
  97.     return close_detail if @detail_window.visible
  98.     return unless @status_window.current_data
  99.     data = @status_window.current_data
  100.     @detail_window.set_title(TyStatus_Config::TYSTATUS_TITLE)
  101.     if data.is_a?(RPG::State)
  102.       @detail_window.set_text(data.state_desc)
  103.     else
  104.       text = sprintf(TyStatus_Config::TYSTATUS_BUFF_VOCAB,
  105.         Vocab::param(@status_window.index - @actor.states.size), data * 100)
  106.       @detail_window.set_text(text)
  107.     end
  108.     @detail_window.show.open
  109.     @status_window.deactivate
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 关闭详情窗口
  113.   #--------------------------------------------------------------------------
  114.   def close_detail
  115.     if @detail_window.visible
  116.       @detail_window.close.hide
  117.       @status_window.activate
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 关闭详情窗口
  122.   #--------------------------------------------------------------------------
  123.   alias tystatus_update update
  124.   def update
  125.     tystatus_update
  126.     call_detail  if Input.trigger?(:C)
  127.     close_detail if Input.trigger?(:B)
  128.   end
  129. end

  130. #==============================================================================
  131. # ■ Window_StatusDetail
  132. #------------------------------------------------------------------------------
  133. #  技能画面中,显示详情的窗口。
  134. #==============================================================================

  135. class Window_StatusDetail < Window_Base
  136.   #--------------------------------------------------------------------------
  137.   # ● 初始化对象
  138.   #--------------------------------------------------------------------------
  139.   def initialize
  140.     super(window_x, window_y, window_width, window_height)
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 获取窗口的 X 坐标
  144.   #--------------------------------------------------------------------------
  145.   def window_x
  146.     Graphics.width / 2 - window_width / 2
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 获取窗口的 Y 坐标
  150.   #--------------------------------------------------------------------------
  151.   def window_y
  152.     Graphics.height / 2 - window_height / 2
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 获取窗口的宽度
  156.   #--------------------------------------------------------------------------
  157.   def window_width
  158.     Graphics.width / 2
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 获取窗口的高度
  162.   #--------------------------------------------------------------------------
  163.   def window_height
  164.     fitting_height(4.2)
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 设置标题
  168.   #--------------------------------------------------------------------------
  169.   def set_title(title)
  170.     if title != @title
  171.       @title = title
  172.       refresh
  173.     end
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 设置内容
  177.   #--------------------------------------------------------------------------
  178.   def set_text(text, line_number = 2)
  179.     if text != @text
  180.       @text = text
  181.       refresh
  182.     end
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 刷新
  186.   #--------------------------------------------------------------------------
  187.   def refresh
  188.     contents.clear
  189.     draw_text_ex(4, line_height * 0, @title)
  190.     draw_horz_line(line_height * 1)
  191.     draw_text_ex(4, line_height * 2, @text)
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 绘制水平线
  195.   #--------------------------------------------------------------------------
  196.   def draw_horz_line(y)
  197.     line_y = y + line_height / 2 - 1
  198.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 获取水平线的颜色
  202.   #--------------------------------------------------------------------------
  203.   def line_color
  204.     color = normal_color
  205.     color.alpha = 48
  206.     color
  207.   end
  208. end

  209. #==============================================================================
  210. # ■ Window_Status
  211. #------------------------------------------------------------------------------
  212. #  状态画面中,显示角色基本信息的窗口。
  213. #==============================================================================

  214. class Window_Status < Window_Selectable
  215.   #--------------------------------------------------------------------------
  216.   # ● 初始化对象
  217.   #--------------------------------------------------------------------------
  218.   alias tystatus_initialize initialize
  219.   def initialize(actor)
  220.     @data = actor.states + actor.buffs.reject {|buff| buff == 0 }
  221.     tystatus_initialize(actor)
  222.     @index = 0
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 获取显示行数
  226.   #--------------------------------------------------------------------------
  227.   def visible_line_number
  228.     return 1
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 获取列数
  232.   #--------------------------------------------------------------------------
  233.   def col_max
  234.     item_max
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 获取项目数
  238.   #--------------------------------------------------------------------------
  239.   def item_max
  240.     @actor ? [[@data.size, 4].min, 1].max : 1
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 获取项目的宽度
  244.   #--------------------------------------------------------------------------
  245.   def item_width
  246.     return 24
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 获取项目的绘制矩形
  250.   #--------------------------------------------------------------------------
  251.   def item_rect(index)
  252.     rect = Rect.new
  253.     rect.width = item_width
  254.     rect.height = item_height
  255.     rect.x = 136 + index * 24
  256.     rect.y = line_height * 3
  257.     rect
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 获取指定选项的图标ID
  261.   #--------------------------------------------------------------------------
  262.   def icon_index(index)
  263.     return unless @data && @data[index]
  264.     state = @data[index]
  265.     if state.is_a?(RPG::State)
  266.       state.icon_index
  267.     else
  268.       @actor.buff_icon_index(state, index - @actor.states.size)
  269.     end
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 获取选项的指令数据
  273.   #--------------------------------------------------------------------------
  274.   def current_data
  275.     return nil unless @actor
  276.     return @data[index]
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 绘制项目
  280.   #--------------------------------------------------------------------------
  281.   def draw_item(index)
  282.     return unless @data[index]
  283.     rect = item_rect(index)
  284.     icon = icon_index(index)
  285.     draw_icon(icon, rect.x, rect.y)
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 刷新
  289.   #--------------------------------------------------------------------------
  290.   alias tystatus_refresh refresh
  291.   def refresh
  292.     tystatus_refresh
  293.     draw_all_items
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 绘制强化/弱化状态的图标
  297.   #--------------------------------------------------------------------------
  298.   def draw_actor_icons(actor, x, y, width = 96)
  299.   end
  300. end
复制代码

说明
由于目前仍是测试版,并且找不到能够保留BUFF到状态页面的方法,希望有dalao告知。
由于用法简单所以暂时不提供范例工程,如有BUG还请反馈。
祝好。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部