查看: 2340|回复: 2

[已经解决] 请大神改进下我这个简单的人物手册的脚本

[复制链接]
梦石
0
星屑
2019
在线时间
940 小时
注册时间
2015-10-26
回帖
293

开拓者

发表于 2022-9-30 22:02:25 | 显示全部楼层 |阅读模式
悬赏20星屑已解决
本帖最后由 踢腿水上飘 于 2022-10-4 08:35 编辑

这个脚本是模仿着改的,目前用是能用但是有两个地方希望改进但能力不够,求大神帮忙看看
如图,这个脚本效果是左边人物名字,右边人物信息,根据剧情推进用变量控制信息的显示,主要有两个想动的地方,一个是左边的名字(黄色框),希望也能用变量控制显示,不然还没遇到的人也挂着名字很违和,第二个是右边红框的位置想显示个图片放人物的图片,显示picture文件夹里的图片,最后一个就是右边的信息能在内容过多的时候能上下滚动就更好了,当然最后这个无所谓了,主要是前面2个。

我电脑上不了论坛是用手机上的,代码不知道粘全了没有 ,谁知道怎么回事啊,同一个样,手机能上,电脑就不能上论坛,要哭了。

mmexport1664545998891.png


[pre lang="ruby"]
module RWSC
  # 这里设定人物名称
  Rwmc = ["小明",   "小红", "小黄", "大狗",]
end

class Window_rwxx < Window_Base
  #----------------------------------------------------------------------------
  # * 初始化
  #----------------------------------------------------------------------------
  def initialize
    super(120, 0, Graphics.width - 120, Graphics.height)
    deactivate
  end
  #----------------------------------------------------------------------------
  # * 更新内容
  #----------------------------------------------------------------------------
  def refresh(command_index = 0)
    contents.clear
    rwxx_list = rwxx_detal(command_index)
    rwxx_list.each_with_index do |text, i|
      cx = 0
      cy = line_height * i
      draw_text(cx, cy, contents.width, line_height, text, 0)
    end
  end
  # 设置词条明细内容
  def rwxx_detal(command_index = 0)
    list = []
    case command_index
    when 0
      # 明细1--------------------------------------
      if $game_variables[1] < 30
        list.push("                          --未解锁---")
      else
        list.push("手段sad发送到方式打发沙发上打发斯蒂阿斯顿发送")
        list.push("芬阿斯蒂芬sad发送到发达发达但是发多少")
      end      
      list.push(" ")
      if $game_variables[1] < 80
        list.push("                          --未解锁---")
      else
        list.push("士大夫十大发收到")
      end

    when 1
      list.push("123123123")
      
    when 2
      list.push("123123123123")
  when 3
      list.push("123123123")      
      #...以此格式往下添加
    end # 明细设定结束
    return list
  end
end



class Window_Rwmcleft < Window_Selectable
  # 设定公开变量
  attr_accessor :old_index
  # 初始化
  def initialize
    super(0, 0, 120, Graphics.height)#Graphics.width, 48)
    refresh
    self.activate.select(0)
  end  
  # 高度
  def window_height
    fitting_height(visible_line_number)#return 48#
  end
  # 最大项目数
  def item_max
    command_list.size#return 8#
  end
  # 可见列数
  def visible_line_number
    command_list.size#return 8#
  end
  # 获取选项列表
  def command_list
       return RWSC::Rwmc
  end
  # 绘制项目
  def draw_item(index)
    rect = item_rect_for_text(index)
    draw_text(rect, command_list[index])
  end
end





class Rwsc < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 场景开始
  #--------------------------------------------------------------------------
  def start
    super
    create_list_window
    create_right_window
  end
  #--------------------------------------------------------------------------
  # ● 创建列表
  #--------------------------------------------------------------------------
  def create_list_window
    @list_window = Window_Rwmcleft.new
    @list_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 创建内容窗口
  #--------------------------------------------------------------------------
  def create_right_window
    @right_window = Window_rwxx.new
  end
  # 更新所有窗口
  def update_all_windows
    super
    update_left_right
  end
  # 更新左右窗口关联
  def update_left_right
    return unless @list_window.old_index != @list_window.index
    @list_window.old_index = @list_window.index
    @right_window.refresh(@list_window.index)
  end
end[/pre]

最佳答案

查看完整内容

稍微弄了一下,应该勉强能行(……?) 首先是更改了人名列表的设置样式: 【资料ID => ["人名", 对应的进度变量ID]】 其中【资料ID】需要保证一人一个ID,它将影响获取人物的各项对应资料以及在左边人名窗口中的上下排序位置。 【人名】就是显示在左边窗口的选项名字, 【对应的进度变量ID】就是影响解锁内容的变量ID,该变量为0时则对应的人物不会出现在人名列表中。 顺便就是我稍微更改了一下【rwxx_detal】方法的内容,让它自 ...

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2022-9-30 22:02:26 | 显示全部楼层
稍微弄了一下,应该勉强能行(……?)
首先是更改了人名列表的设置样式:
【资料ID => ["人名", 对应的进度变量ID]】
其中【资料ID】需要保证一人一个ID,它将影响获取人物的各项对应资料以及在左边人名窗口中的上下排序位置。
【人名】就是显示在左边窗口的选项名字,
【对应的进度变量ID】就是影响解锁内容的变量ID,该变量为0时则对应的人物不会出现在人名列表中。

顺便就是我稍微更改了一下【rwxx_detal】方法的内容,让它自动兼容上述的【对应的进度变量ID】,而不需要在这里给每个角色都手动填一个变量ID。

然后是人物图像,我设定成图像使用【RWSC_ + 人物名字】作为图片命名,比如【RWSC_小明.png】,它会在人物解锁之后自动显示在右侧资料窗的右上角。

代码如下
  1. module RWSC
  2.   # 这里设定人物名称
  3.   CharaList = {
  4.   # 格式参考:
  5.   # 资料ID => ["人名", 对应的进度变量ID]
  6.   1 => ["小明", 1],
  7.   2 => ["小红", 2],
  8.   3 => ["小黄", 3],
  9.   4 => ["大狗", 4],
  10.   } # CharaList
  11.   
  12. end

  13. class Window_rwxx < Window_Base
  14.   #----------------------------------------------------------------------------
  15.   # * 初始化
  16.   #----------------------------------------------------------------------------
  17.   def initialize
  18.     super(120, 0, Graphics.width - 120, Graphics.height)
  19.     deactivate
  20.   end
  21.   #----------------------------------------------------------------------------
  22.   # * 更新内容
  23.   #----------------------------------------------------------------------------
  24.   def refresh(chara_data = nil)
  25.     contents.clear
  26.     return unless chara_data
  27.     # 获取人物数据ID
  28.     chara_data_id = chara_data[0]
  29.     # 绘制人物图像(右上角)
  30.     draw_char_image(chara_data_id)
  31.     # 显示人物资料
  32.     rwxx_list = rwxx_detal(chara_data_id)
  33.     rwxx_list.each_with_index do |text, i|
  34.       cx = 0
  35.       cy = line_height * i
  36.       draw_text(cx, cy, contents.width, line_height, text, 0)
  37.     end
  38.   end
  39.   #------------------------------------------
  40.   # ○ 在窗口右上角绘制人物图像
  41.   #------------------------------------------
  42.   def draw_char_image(chara_data_id)
  43.     chara_name = RWSC::CharaList[chara_data_id][0]
  44.     filename = "RWSC_" + chara_name
  45.     bitmap = (Cache.picture(filename) rescue nil)
  46.     return unless bitmap
  47.     cx = contents.width - bitmap.width
  48.     contents.blt(cx, 0, bitmap, bitmap.rect)
  49.   end
  50.   #------------------------------------------
  51.   # ○ 设置词条明细内容
  52.   #------------------------------------------
  53.   def rwxx_detal(chara_data_id)
  54.     # 根据人物资料ID获取对应的变量ID
  55.     chara_var_id = RWSC::CharaList[chara_data_id][1]
  56.    
  57.     list = []
  58.     case chara_data_id
  59.     when 1
  60.       # 明细1--------------------------------------
  61.       if $game_variables[chara_var_id] < 30
  62.         list.push("                          --未解锁---")
  63.       else
  64.         list.push("手段sad发送到方式打发沙发上打发斯蒂阿斯顿发送")
  65.         list.push("芬阿斯蒂芬sad发送到发达发达但是发多少")
  66.       end      
  67.       list.push(" ")
  68.       if $game_variables[chara_var_id] < 80
  69.         list.push("                          --未解锁---")
  70.       else
  71.         list.push("士大夫十大发收到")
  72.       end
  73.     when 2
  74.       list.push("123123123")
  75.     when 3
  76.       list.push("123123123123")
  77.     when 4
  78.       list.push("123123123")      
  79.       #...以此格式往下添加
  80.     end # 明细设定结束
  81.     return list
  82.   end
  83. end



  84. class Window_Rwmcleft < Window_Selectable
  85.   # 设定公开变量
  86.   attr_accessor :old_index
  87.   # 初始化
  88.   def initialize
  89.     make_list_data
  90.     super(0, 0, 120, Graphics.height)#Graphics.width, 48)
  91.     refresh
  92.     self.activate.select(0)
  93.   end  
  94.   # 高度
  95.   def window_height
  96.     fitting_height(visible_line_number)#return 48#
  97.   end
  98.   # 最大项目数
  99.   def item_max
  100.     command_list.size#return 8#
  101.   end
  102.   # 可见列数
  103.   def visible_line_number
  104.     command_list.size#return 8#
  105.   end
  106.   #------------------------------------------
  107.   # ○ 生成已解锁的人物资料列表  [资料ID,人名]
  108.   #------------------------------------------
  109.   def make_list_data
  110.     @data = []
  111.     for id in 1..RWSC::CharaList.size
  112.       data = RWSC::CharaList[id]
  113.       if data[1].nil? or data[1] <= 0
  114.         @data.push([id, data[0]])
  115.       else
  116.         if $game_variables[data[1]] > 0
  117.           @data.push([id, data[0]])
  118.         end
  119.       end
  120.     end
  121.   end
  122.   #------------------------------------------
  123.   # ○ 获取指定index位置的项目数据
  124.   #------------------------------------------
  125.   def item(index = self.index)
  126.     return (@data ? @data[index] : nil)
  127.   end
  128.   
  129.   #------------------------------------------
  130.   # ○ 获取选项列表(从资料表中提取人名)
  131.   #------------------------------------------
  132.   def command_list
  133.     list = @data.collect{|data| data[1]}
  134.     return list
  135.   end
  136.   # 绘制项目
  137.   def draw_item(index)
  138.     rect = item_rect_for_text(index)
  139.     draw_text(rect, command_list[index])
  140.   end
  141. end





  142. class Rwsc < Scene_MenuBase
  143.   #--------------------------------------------------------------------------
  144.   # ● 场景开始
  145.   #--------------------------------------------------------------------------
  146.   def start
  147.     super
  148.     create_list_window
  149.     create_right_window
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 创建列表
  153.   #--------------------------------------------------------------------------
  154.   def create_list_window
  155.     @list_window = Window_Rwmcleft.new
  156.     @list_window.set_handler(:cancel, method(:return_scene))
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 创建内容窗口
  160.   #--------------------------------------------------------------------------
  161.   def create_right_window
  162.     @right_window = Window_rwxx.new
  163.   end
  164.   # 更新所有窗口
  165.   def update_all_windows
  166.     super
  167.     update_left_right
  168.   end
  169.   # 更新左右窗口关联
  170.   def update_left_right
  171.     return unless @list_window.old_index != @list_window.index
  172.     @list_window.old_index = @list_window.index
  173.     @right_window.refresh(@list_window.item)
  174.   end
  175. end
复制代码

点评

试了下感觉没啥问题,谢谢啦  发表于 2022-10-4 17:47

评分

参与人数 2赞 +2 收起 理由
踢腿水上飘 + 1 认可答案
alexncf125 + 1 天下第一大好人~

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部