设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1144|回复: 7
打印 上一主题 下一主题

[已经解决] 【已解决】我想要做一个4*3最大值12的页面包裹

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6286
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
跳转到指定楼层
1
发表于 2023-4-14 13:12:45 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 金芒芒 于 2023-4-17 13:29 编辑

if @item.scope == 4 || @item.scope == 6 这句话代表什么呢

RUBY 代码复制
  1. if @item.scope >= 3
  2.         # 激活目标窗口
  3.         @item_window.active = false
  4.         @target_window.x = (@item_window.index + 1) % 2 * 304
  5.         @target_window.visible = true
  6.         @target_window.active = true
  7.         # 设置效果范围 (单体/全体) 的对应光标位置
  8.         if @item.scope == 4 || @item.scope == 6
  9.           @target_window.index = -1
  10.         else
  11.           @target_window.index = 0
  12.         end




Lv5.捕梦者

梦石
24
星屑
7017
在线时间
247 小时
注册时间
2020-12-4
帖子
306

极短24获奖极短23获奖极短22获奖

2
发表于 2023-4-14 13:56:15 | 只看该作者
本帖最后由 纯属小虫 于 2023-4-14 13:58 编辑

首先得知道这个 @item 在这个类中被定义成了什么,得把整个class的代码,或者这个class的名称发上来
如果是原版的@item.scope,应该是指的物品作用范围  敌单体,敌群体,我单体....之类

另外,想做 4*3 的选项页面是比较简单的,用Window类直接就能做出来

具体可以参照 class Window_Selectable < Window_Base
基于这个框架几乎能做出所有的需要光标的窗口


  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1
    @column_max = 1
    @index = -1
  end


@item_max 是指总量,你这里是12的话,那就是12
@column_max 是指列数,你的4*3如果4是指的是横排一排中的个数,这里填4即可

  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = self.width / @column_max - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, 32)
  end

这个定义了每个光标的大小,根据需求按照备注所写修改即可
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6286
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
3
 楼主| 发表于 2023-4-14 14:54:31 | 只看该作者
本帖最后由 金芒芒 于 2023-4-14 17:03 编辑
纯属小虫 发表于 2023-4-14 13:56
首先得知道这个 @item 在这个类中被定义成了什么,得把整个class的代码,或者这个class的名称发上来
如果是 ...


我是想包裹人物大于等于13的时候第十三人顶置到第一人的位置第1-12个包裹人物在上一页了
现在是我添加再多人。人物和光标多是无限下排

if @item_max >= 13的 #人物包裹的下一页面
   13item,x=原点x  y=原点  1-12的翻页面了
end
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  显示可以装备的回路。
  5. #==============================================================================
  6. class Window_Troops_List< Window_Base
  7.   def blue_color
  8.     return Color.new(141,157,180)
  9.   end
  10.   #--------------------------------------------------------------------------
  11.   # ● 定义实例变量
  12.   #--------------------------------------------------------------------------
  13.   attr_reader   :index                    # 光标位置
  14.   attr_reader   :help_window              # 帮助窗口
  15.   attr_reader   :type                     # 种类
  16.   attr_reader   :able                     # 暗色
  17.     #  for i in 0...$party_items[type].size
  18.     #  next if $party_items[type][i].nil?
  19.     #  x = i%4*66 + 25
  20.     #  y = i/2*80 + 102
  21.     #  case $party_items[type][i].type
  22.   def type=(type)#类型
  23.     @type = type
  24.   end
  25.   def type
  26.     return @type
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 设置光标的位置
  30.   #     index : 新的光标位置
  31.   #--------------------------------------------------------------------------
  32.   def index=(index)#定义索引=(索引)
  33.     @index = index#@索引=(索引)
  34.     # 刷新帮助文本 (update_help 定义了继承目标)
  35.     #如果是自己。活动和@help窗口!=无
  36.     if self.active and @help_window != nil
  37.       update_help#更新帮助
  38.     end
  39.     # 刷新光标矩形
  40.     update_cursor_rect#更新游标矩形
  41.   end
  42. #--------------------------------------------------------------------------
  43.   # ● 获取行数
  44.   #--------------------------------------------------------------------------
  45.   def column_max #定义行最大值
  46.     # 由项目数和列数计算出行数
  47.     return @item_max #返回@项目最大值
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 获取开头行
  51.   #--------------------------------------------------------------------------
  52.   def top_column
  53.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  54.     return self.ox / 32
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 设置开头行
  58.   #     row : 显示开头的行
  59.   #--------------------------------------------------------------------------
  60.   def top_column=(column)#定义首行=(行)
  61.     # row 未满 0 的场合更正为 0
  62.     if column < 0
  63.       column = 0
  64.     end
  65.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  66.     if column > column_max - 1
  67.       column = column_max - 1
  68.     end
  69.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  70.     self.ox = column * 32
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 获取 1 页可以显示的行数
  74.   #--------------------------------------------------------------------------
  75.  
  76.   def page_column_max  #@column_max = 2
  77.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  78.     return 16  #头像行数
  79.   end  
  80.   #--------------------------------------------------------------------------
  81.   # ● 初始化对像
  82.   #     actor : 角色
  83.   #--------------------------------------------------------------------------
  84.   def initialize(type = 0,player_or_enermy = 0)
  85.    @all_fighters = Figter_data::ALL_SOLDIER   #所有人物英雄
  86.   #----------------------------------------------------------------------------
  87.   #                 所有人物英雄添加处
  88.   #----------------------------------------------------------------------------
  89.   # @all_fighters = [5]
  90.   #   if $game_switches[20] == true#(开关 关 )
  91.    #   @all_fighters.push(4)  # => true
  92.   #   end
  93.    #  if $game_switches[21] == true#(开关 关 )
  94.    #  @all_fighters.push(2)   # => true
  95.   #   end
  96.   #-----------------------------------------------------------------------------
  97.  
  98.     #右侧滚动条
  99.     @right_back = Bar_Right.new("right_back", origin_x+172, origin_y+12, 20*14)
  100.     @right_back.visible = false
  101.     @right = Bar_Right.new("right", origin_x+170, origin_y+12, 0)
  102.     @right.visible = false
  103.  
  104.  
  105.     #变量更新
  106.     @type = 0
  107.     @index = 0
  108.     #背景
  109.     @back = Sprite.new
  110.     @back.bitmap = RPG::Cache.menu("troopList-base") #总部队背景图
  111.   #  @back.x = origin_x
  112.    # @back.y = origin_y
  113.     @help_window = Window_Troop_Info.new
  114.  
  115.  
  116.     @item_icon = []
  117.     @item_icon[0] = Sprite.new
  118.     #初始化
  119.    # super(origin_x,origin_y,128/2*4+32,87*4+32)
  120.     #超级的(原始_x,原始_y,287/2+32,14*20+32)
  121.     super(origin_x,origin_y,1200,600)
  122.     #自己窗花= RPG::Cache.menu("Blue")
  123.     self.windowskin  = RPG::Cache.menu("Blue")#光标窗口颜色
  124. #    self.windowskin.z=1100
  125.     self.opacity = 0
  126.     self.active = false
  127.     #刷新
  128.     refresh(type)
  129.     refresh(type)
  130.     update_help
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 活动窗口用原始x y坐标
  134.   #--------------------------------------------------------------------------  
  135.   def origin_x
  136.     return 16 #光标和头像,名字的原始x标
  137.   end
  138.   def origin_y
  139.     return 93#光标和头像,名字的原始y标
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 定义用选择状态决定窗口颜色
  143.   #--------------------------------------------------------------------------  
  144.   def able=(able)
  145.     @able=able
  146.     @right_back.able = able
  147.     @right.able = able
  148.     if active
  149.       @back.color = Color.new(255,255,255,0)
  150.     else
  151.       @back.color = Color.new(0,0,0,128)
  152.     end
  153.     refresh
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● 一些方法的重载
  157.   #--------------------------------------------------------------------------  
  158.   def active=(active)
  159.     if active
  160.       if @item_max <=  0
  161.         self.index = -1
  162.       else
  163.         self.index = 0
  164.       end
  165.     else
  166.       self.index = -1
  167.     end
  168.     @ajsdgfshfajklshfa = nil
  169.     @help_window.set_text( nil ) if @help_window != nil
  170.     super(active)
  171.   end
  172.   def dispose
  173.     @back.dispose
  174.     @right_back.dispose
  175.     @right.dispose
  176.     for i in 0...@item_icon.size
  177.       @item_icon[i].dispose
  178.     end
  179.     @help_window.dispose
  180.     super
  181.   end
  182.   def x=(x)
  183.     @back.x = x-origin_x #+ 15
  184.     @right_back.x = x+172 #+30
  185.     @right.x = x+170 #+30
  186.     for i in 0...@item_icon.size
  187.       @item_icon[i].x = 25+ i%4 * (54 + 32)#  +60        #14
  188.     end
  189.     super(x-16)
  190.   end
  191.   def x
  192.     return super+16
  193.   end
  194.   def y=(y)
  195.     @back.y = y-origin_y# + 60
  196.     @right_back.y = y+12 #+ origin_y
  197.     @right.y = y+12 #+ origin_y
  198.     for i in 0...@item_icon.size
  199.       @item_icon[i].y=115+i/ 4 * 122  # + origin_y #+ 25   #14
  200.     end
  201.     super(y)
  202.   end
  203.   def z=(z)
  204.     @back.z=300
  205.     @right_back.z=z+3
  206.     @right.z=z+4
  207.     for i in 0...@item_icon.size
  208.       @item_icon[i].z=z+2
  209.     end
  210.     super(z)
  211.   end
  212.   def visible=(visible)
  213.     @back.visible=visible
  214.     @right_back.visible=visible
  215.     @right.visible=visible
  216.   #  @help_window.visible=visible
  217.     super(visible)
  218.   end
  219.   def contents_opacity=(opacity)
  220.     @back.opacity=opacity
  221.     @right_back.opacity=0#opacity
  222.     @right.opacity=0 #opacity
  223.    # @help_window.opacity=opacity
  224.     super(opacity)
  225.   end
  226.   def oy=(oy)
  227.     #缩放图标时只显示当前页的项目
  228.     for i in 0...@item_icon.size
  229.       @item_icon[i].y = 16+18*i+self.y-oy
  230.       if @item_icon[i].y < self.x or @item_icon[i].y > self.x+20*self.page_row_max
  231.         @item_icon[i].visible = false
  232.       else
  233.         @item_icon[i].visible = true
  234.       end
  235.     end
  236.     super(oy)
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 获取物品
  240.   #--------------------------------------------------------------------------  
  241.   def item
  242.     return @all_fighters[self.index]
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 刷新
  246.   #--------------------------------------------------------------------------  
  247.   def refresh(type=@type)#all,1,2,3,4,5,6,7 RPPG::ARMOR_BEGIN
  248.     if self.contents != nil
  249.       self.contents.dispose
  250.       self.contents = nil
  251.     end
  252.  
  253.     for i in 0...@item_icon.size
  254.       @item_icon[i].dispose
  255.     end
  256.     @item_icon = []
  257.     @item_icon[0] = Sprite.new
  258.  
  259.  
  260.  
  261.     for i in 0...@all_fighters.size
  262.      @item_icon[i] = Sprite.new
  263.  
  264.      name = Figter_data::CHARACTER_NAME[@all_fighters[i]]
  265.      @item_icon[i].bitmap = RPG::Cache.icon(name) if name != nil
  266.  
  267.     end
  268.  
  269.     @item_max = @all_fighters.size
  270.     #下标超过范围的时候往回退一格
  271.     if self.top_column > @item_max-self.page_column_max
  272.        self.top_column = @item_max-self.page_column_max
  273.     end
  274. #  if self.index >= @item_column
  275. #     self.index = @item_column-1
  276.   #  end
  277.  
  278.     #右侧滚动条显示
  279.   #  if @item_max > self.page_column_max
  280.    #   @right_back.visible = true
  281.   #    @right.visible = true
  282.   #  else
  283.    #   @right_back.visible = false
  284.    #   @right.visible = false
  285.   #  end
  286.     #滚动条的更新
  287. #   if @right.visible
  288.   #    @right.height = (14*66)*(14*66)/(@item_max.to_f*66)-24.0 > 0 ? (14*66)*(14*66)/(@item_max.to_f*66)-24.0 : 0
  289.   #  end
  290. #---------------------------------------------- 1   
  291.     # 如果项目数不是 0 就生成位图、描绘全部项目
  292.   #  if @item_max > 0
  293.   #    self.contents = Bitmap.new(width - 32, @item_max*20)
  294.   #    for i in 0...@item_max
  295.   #      draw_item(i, 12, i*66)
  296.   #    end
  297.    # else
  298.   #    self.contents = Bitmap.new(width - 32, 20)
  299.   #  end
  300.     #缩放图标时只显示当前页的项目
  301.     for i in 0...@item_icon.size
  302.          # x =16 +@index% 4 * (66 + 5)
  303.          # y = @index/ 4 * 88
  304.          @item_icon[i].x = 25 +i%4 * (54 + 32)
  305.          @item_icon[i].y = i/ 4 * 123
  306.          #@item_icon[i].x = 66*i+self.x-ox+16 #14+16*i
  307.  
  308. #     if @item_icon[i].x < self.x or @item_icon[i].x > self.x+80*self.page_column_max
  309. #       @item_icon[i].visible = false
  310. #     else
  311. #       @item_icon[i].visible = true
  312.   #    end
  313.     end
  314.    #update_help
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 描绘物品
  318.   #--------------------------------------------------------------------------  
  319.   def draw_item(index, x, y)
  320.  
  321.     item = @all_fighters[index]
  322.  
  323.  
  324.  
  325.  
  326.     self.contents.font.size =12 #自己目录字体。尺寸=12
  327.  
  328.  
  329.     #图标缩放显示专用
  330.     icon_size = 100#84#18#图片缩放大小
  331.  
  332.     @item_icon[index].x = self.x+x - self.index%4 * (66 + 5)#self%4*18 + 25         #
  333.     @item_icon[index].y = self.y+y+16 - self.index/ 4 * 88#/2*18 + 102
  334.  
  335.     @item_icon[index].zoom_x = icon_size.to_f/@item_icon[index].bitmap.width
  336.     @item_icon[index].zoom_y = icon_size.to_f/@item_icon[index].bitmap.height
  337.   #  @item_icon[index].z = 200#self.z+2
  338.     @item_icon[index].color = self.contents.font.color==normal_color ? Color.new(255,255,255,0):Color.new(0,0,0,128)
  339.     #self.contents.font.color = Color.new(128,193,125,0)
  340.     name = Figter_data::THE_NAME[item]
  341.     self.contents.draw_text(x%4 * (66 + 5) + icon_size.to_f, y/ 4 * 88, 184, self.contents.font.size, name)
  342.    # self.contents.draw_text(x + icon_size.to_f, y + 4, 184, self.contents.font.size, name)
  343.  
  344.  
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 帮助窗口的设置
  348.   #     help_window : 新的帮助窗口
  349.   #--------------------------------------------------------------------------
  350.   def help_window=(help_window)
  351.     @help_window = help_window
  352.     # 刷新帮助文本 (update_help 定义了继承目标)
  353.     if self.active and @help_window != nil
  354.       update_help
  355.     end
  356.   end
  357.  
  358.  
  359.   #--------------------------------------------------------------------------
  360.   # ● 更新光标矩形
  361.   #--------------------------------------------------------------------------
  362.   def update_cursor_rect
  363.     #@back.bitmap = RPG::Cache.menu("item_command"+type.to_s)
  364.     # 光标位置不满 0 的情况下
  365.     if @index < 0
  366.       self.cursor_rect.empty
  367.       return
  368.     end
  369.  
  370.     # 获取当前的行
  371.     column = @index
  372.     # 当前行被显示开头行前面的情况下
  373.     if column < self.top_column
  374.       # 从当前行向开头行滚动
  375.       self.top_column = column
  376.     end
  377.     # 当前行被显示末尾行之后的情况下
  378.     if column > self.top_column + (self.page_column_max - 1)
  379.       # 从当前行向末尾滚动
  380.       self.top_column = column - (self.page_column_max - 1)
  381.     end
  382.  
  383. #   row = @index
  384.     # 当前行被显示开头行前面的情况下
  385. #    if row < self.top_row
  386.       # 从当前行向开头行滚动
  387. #      self.top_row = row
  388. #    end
  389.     # 当前行被显示末尾行之后的情况下
  390. #    if row > self.top_row + (self.page_row_max - 1)
  391.       # 从当前行向末尾滚动
  392. #     self.top_row = row - (self.page_row_max - 1)
  393. #   end
  394.  
  395. #   @right.x = self.x+72+self.top_column.to_f*66.0*(4*66)/(@item_max.to_f*66)
  396.  
  397.     # 计算光标的宽度
  398.     cursor_width = 1200
  399.     # 计算光标坐标
  400. #   x = 4 + index % 2 * (288 + 32)
  401.   #  y = index / 2 * 32
  402.   #x =32+ @index*66 - self.ox-1# 8 #
  403.      x =10 +@index% 4 * (84 + 1)
  404.      y =5+ @index/ 4 * 120
  405.      z = 1999
  406.     #y = 14 #@index*20 - self.oy-1
  407.     # 更新光标矩形
  408.     self.cursor_rect.set(x, y, 84 ,120)
  409.   end
  410. #--------------------------------------------------------------------------
  411.   # ● 刷新画面
  412.   #--------------------------------------------------------------------------
  413.   def update
  414.     super
  415.    # (Input::UP)  (Input::DOWN)  (Input::RIGHT) (Input::LEFT)
  416.     # 可以移动光标的情况下
  417.     if self.active and @item_max >= 0 and @index >= 0
  418.       # 方向键下被按下的情况下
  419.       if Input.repeat?(Input::RIGHT)
  420.         # 光标向左移动
  421.         $game_system.se_play($data_system.cursor_se)
  422.         @index = (@index+1+@item_max) % @item_max if @item_max != 0
  423.         update_help
  424.       end
  425.       # 方向键上被按下的情况下
  426.       if Input.repeat?(Input::LEFT)
  427.         # 光标向右移动
  428.         $game_system.se_play($data_system.cursor_se)
  429.         @index = (@index-1+@item_max) % @item_max if @item_max != 0
  430.         update_help
  431.       end
  432.     end  
  433. #-------------------------------------------------------------------------
  434.     if self.active and @item_max >= 0 and @index >= 0
  435.       # 方向键下被按下的情况下
  436.       if Input.repeat?(Input::UP)
  437.         # 光标向左移动
  438.         $game_system.se_play($data_system.cursor_se)
  439.         @index = (@index-1+@item_max) / @item_max if @item_max != 0
  440.         update_help
  441.       end
  442.  
  443.       # 方向键上被按下的情况下
  444.       if Input.repeat?(Input::DOWN)
  445.         # 光标向右移动
  446.         $game_system.se_play($data_system.cursor_se)
  447.         @index = (@index+1+@item_max) / @item_max if @item_max != 0
  448.         update_help
  449.       end
  450. #-------------------------------------------------------------------------      
  451.     end
  452.  
  453.     # 刷新帮助文本 (update_help 定义了继承目标)
  454.     if @help_window != nil and @ajsdgfshfajklshfa == nil
  455.       update_help
  456.       update_help
  457.       @ajsdgfshfajklshfa = true
  458.     end
  459.  
  460.     # 刷新光标矩形
  461.     update_cursor_rect
  462.   end
  463.  
  464.  
  465.  
  466.   def now_selected_troop
  467.     return @all_fighters[@index]
  468.   end
  469.  
  470.   #--------------------------------------------------------------------------
  471.   # ● 刷新帮助文本
  472.   #--------------------------------------------------------------------------
  473.   def update_help
  474.     #鲜辣煎鱼
  475.     @help_window.set_text( @index>-1 ? self.item : nil )
  476.  
  477.   end
  478. end

1下一页.png (648.68 KB, 下载次数: 4)

1下一页.png
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
24
星屑
7017
在线时间
247 小时
注册时间
2020-12-4
帖子
306

极短24获奖极短23获奖极短22获奖

4
发表于 2023-4-14 22:32:31 | 只看该作者
金芒芒 发表于 2023-4-14 14:54
我是想包裹人物大于等于13的时候第十三人顶置到第一人的位置第1-12个包裹人物在上一页了
现在是我添加再 ...


哦,要翻页啊,那也还是参考 Window_Selectable

Window_Selectable


你看170-189行怎么操作的,那么就让光标在页面最下方按↓ 或光标在页面最上方按↑ 的时候,仿造它写就行了
      # R 键被按下的情况下
      if Input.repeat?(Input::R)
        # 显示的最后行在数据中最后行上方的情况下
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          # 光标向后移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
        end
      end
      # L 键被按下的情况下
      if Input.repeat?(Input::L)
        # 显示的开头行在位置 0 之后的情况下
        if self.top_row > 0
          # 光标向前移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6286
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
5
 楼主| 发表于 2023-4-15 08:17:25 | 只看该作者
本帖最后由 金芒芒 于 2023-4-15 08:22 编辑
纯属小虫 发表于 2023-4-14 22:32
哦,要翻页啊,那也还是参考 Window_Selectable

[fold=Window_Selectable][/fold]


  def page_row_max  #@column_max = 2
    # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
    return 3  #头像行数
  end
头像图片
     x =10 +@index% 4 * (84 + 1)
     y =5+ @index/ 4 * 120
  @right.y = self.y+12+self.top_row.to_f*120.0*(3*120)/(@item_max.to_f*120)#3就是限制的高度

光标
     x =10 +@index% 4 * (84 + 1)
     y =5+ @index/ 4 * 120
  @right.y = self.y+12+self.top_row.to_f*120.0*(3*120)/(@item_max.to_f*120)
  

一个4的倍数 一个3行的限制 有点跑偏 真的不行我就也来个4行限制把头像改小拉伸一下背景图片
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6286
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
6
 楼主| 发表于 2023-4-17 13:27:57 | 只看该作者
纯属小虫 发表于 2023-4-14 22:32
哦,要翻页啊,那也还是参考 Window_Selectable

[fold=Window_Selectable][/fold]

弄了3天终于搞定了,不动脚本的我跟瞎子摸路爬着过来了


  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  显示可以装备的回路。
  5. #==============================================================================
  6. class Window_Troops_List< Window_Base
  7.   def blue_color
  8.     return Color.new(141,157,180)
  9.   end
  10.   #--------------------------------------------------------------------------
  11.   # ● 定义实例变量
  12.   #--------------------------------------------------------------------------
  13.   attr_reader   :index                    # 光标位置
  14.   attr_reader   :help_window              # 帮助窗口
  15.   attr_reader   :type                     # 种类
  16.   attr_reader   :able                     # 暗色
  17.   
  18.   def type=(type)
  19.     @type = type
  20.   end
  21.   def type
  22.     return @type
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 设置光标的位置
  26.   #     index : 新的光标位置
  27.   #--------------------------------------------------------------------------
  28.   def index=(index)
  29.     @index = index
  30.     @column_max = 4
  31.     # 刷新帮助文本 (update_help 定义了继承目标)
  32.     if self.active and @help_window != nil
  33.       update_help
  34.     end
  35.     # 刷新光标矩形
  36.     update_cursor_rect
  37.   end
  38. #--------------------------------------------------------------------------
  39.   # ● 获取行数
  40.   #--------------------------------------------------------------------------
  41.   def row_max
  42.     # 由项目数和列数计算出行数
  43.     return @item_max
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 获取开头行
  47.   #--------------------------------------------------------------------------
  48.   def top_row
  49.     # 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
  50.     return self.oy / 120
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # ● 设置开头行
  54.   #     row : 显示开头的行
  55.   #--------------------------------------------------------------------------
  56.   def top_row=(row)
  57.     # row 未满 0 的场合更正为 0
  58.     if row < 0
  59.       row = 0
  60.     end
  61.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  62.     if row > row_max - 1
  63.       row = row_max - 1
  64.     end
  65.     # row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
  66.     self.oy = row * 120
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 获取 1 页可以显示的行数
  70.   #--------------------------------------------------------------------------
  71.   def page_row_max
  72.     # 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
  73.     return 3
  74.   end  
  75.   #--------------------------------------------------------------------------
  76.   # ● 初始化对像
  77.   #     actor : 角色
  78.   #--------------------------------------------------------------------------
  79.   def initialize(type = 0,player_or_enermy = 0)
  80.    
  81.     @all_fighters = Figter_data::ALL_SOLDIER   
  82.    
  83.     #右侧滚动条
  84.     @right_back = Bar_Right.new("right_back", origin_x+344, origin_y+12, 120*3)
  85.     @right_back.visible = false
  86.     @right = Bar_Right.new("right", origin_x+342, origin_y+12, 0)
  87.     @right.visible = false
  88.     #变量更新
  89.     @type = 0
  90.     @index = 0
  91.     #背景
  92.     @back = Sprite.new
  93.     @back.bitmap = RPG::Cache.menu("troopList-base")
  94.   #  @back.x = origin_x
  95.    # @back.y = origin_y
  96.     @help_window = Window_Troop_Info.new
  97.    
  98.    
  99.     @item_icon = []
  100.     @item_icon[0] = Sprite.new
  101.     #初始化
  102.     super(origin_x,origin_y,344+32,3*120+120)
  103.     self.windowskin  = RPG::Cache.menu("Blue")
  104.     self.opacity = 0
  105.     self.active = false
  106.     #刷新
  107.     refresh(type)
  108.     refresh(type)
  109.     update_help
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 活动窗口用原始x y坐标
  113.   #--------------------------------------------------------------------------  
  114.   def origin_x
  115.     return 25
  116.   end
  117.   def origin_y
  118.     return 100
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 定义用选择状态决定窗口颜色
  122.   #--------------------------------------------------------------------------  
  123.   def able=(able)
  124.     @able=able
  125.     @right_back.able = able
  126.     @right.able = able
  127.     if active
  128.       @back.color = Color.new(255,255,255,0)
  129.     else
  130.       @back.color = Color.new(0,0,0,128)
  131.     end
  132.     refresh
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 一些方法的重载
  136.   #--------------------------------------------------------------------------  
  137.   def active=(active)
  138.     if active
  139.       if @item_max <= 0
  140.         self.index = -1
  141.       else
  142.         self.index = 0
  143.       end
  144.     else
  145.       self.index = -1
  146.     end
  147.     @ajsdgfshfajklshfa = nil
  148.     @help_window.set_text( nil ) if @help_window != nil
  149.     super(active)
  150.   end
  151.   def dispose
  152.     @back.dispose
  153.     @right_back.dispose
  154.     @right.dispose
  155.     for i in 0...@item_icon.size
  156.       @item_icon[i].dispose
  157.     end
  158.     @help_window.dispose
  159.     super
  160.   end
  161.   def x=(x)
  162.     @back.x = x-origin_x #+ 15
  163.     @right_back.x = x+344 #+30
  164.     @right.x = x+342 #+30
  165.     for i in 0...@item_icon.size
  166.       @item_icon[i].x = 5+ i%4 *86 #  +60        #14
  167.     end
  168.     super(x-16)
  169.   end
  170.   def x
  171.     return super+16
  172.   end
  173.   def y=(y)
  174.     @back.y = y-origin_y# + 60
  175.     @right_back.y = y+12 #+ origin_y
  176.     @right.y = y+12 #+ origin_y
  177.     for i in 0...@item_icon.size
  178.       @item_icon[i].y=  y+16+ i/ 4 * 122 # + origin_y #+ 25   #14
  179.     end
  180.     super(y)
  181.   end
  182.   def z=(z)
  183.     @back.z=z-5
  184.     @right_back.z=z+3
  185.     @right.z=z+4
  186.     for i in 0...@item_icon.size
  187.       @item_icon[i].z=z+2
  188.     end
  189.     super(z)
  190.   end
  191.   def visible=(visible)
  192.     @back.visible=visible
  193.     @right_back.visible=visible
  194.     @right.visible=visible
  195.   #  @help_window.visible=visible
  196.     super(visible)
  197.   end
  198.   def contents_opacity=(opacity)
  199.     @back.opacity=opacity
  200.     @right_back.opacity=opacity
  201.     @right.opacity=opacity
  202.    # @help_window.opacity=opacity
  203.     super(opacity)
  204.   end
  205.   def oy=(oy)
  206.     #缩放图标时只显示当前页的项目
  207.     for i in 0...@item_icon.size
  208.       @item_icon[i].x= 25+i%4 *84
  209.      # @item_icon[i].y = i/4*120
  210.       @item_icon[i].y = i/ 4 * 120+self.y-oy+16#120*i+self.y-oy+16
  211.       if @item_icon[i].y < self.y or @item_icon[i].y > self.y+120*self.page_row_max
  212.         @item_icon[i].visible = false
  213.       else
  214.         @item_icon[i].visible = true
  215.       end
  216.     end
  217.     super(oy)
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 获取物品
  221.   #--------------------------------------------------------------------------  
  222.   def item
  223.     return @all_fighters[self.index]
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 刷新
  227.   #--------------------------------------------------------------------------  
  228.   def refresh(type=@type)#all,1,2,3,4,5,6,7 RPPG::ARMOR_BEGIN
  229.     if self.contents != nil
  230.       self.contents.dispose
  231.       self.contents = nil
  232.     end
  233.    
  234.     for i in 0...@item_icon.size
  235.       @item_icon[i].dispose
  236.     end
  237.     @item_icon = []
  238.     @item_icon[0] = Sprite.new

  239.    

  240.     for i in 0...@all_fighters.size
  241.      @item_icon[i] = Sprite.new
  242.      
  243.      name = Figter_data::CHARACTER_NAME[@all_fighters[i]]
  244.      @item_icon[i].bitmap = RPG::Cache.icon(name) if name != nil
  245.      
  246.     end
  247.    
  248.     @item_max = @all_fighters.size
  249.     #下标超过范围的时候往回退一格
  250.     if self.top_row > @item_max-self.page_row_max
  251.       self.top_row = @item_max-self.page_row_max
  252.     end
  253.     if self.index >= @item_max
  254.       self.index = @item_max-1
  255.     end
  256.       
  257.     #右侧滚动条显示
  258.     if @item_max > self.page_row_max
  259.       @right_back.visible = true
  260.       @right.visible = true
  261.     else
  262.       @right_back.visible = false
  263.       @right.visible = false
  264.     end
  265.     #滚动条的更新
  266.     if @right.visible
  267.       @right.height = (3*120)*(3*120)/(@item_max.to_f*120)-24.0 > 0 ? (3*120)*(3*120)/(@item_max.to_f*120)-24.0 : 0
  268.     end
  269.    
  270.     # 如果项目数不是 0 就生成位图、描绘全部项目
  271.     if @item_max > 0
  272.       self.contents = Bitmap.new(width - 32, @item_max*20)
  273.       for i in 0...@item_max
  274.         draw_item(i, 12, i*120)
  275.       end
  276.     else
  277.       self.contents = Bitmap.new(width - 32, 20)
  278.     end
  279.     #缩放图标时只显示当前页的项目
  280.     for i in 0...@item_icon.size
  281.       @item_icon[i].x = 25+ i%4 *84
  282.       @item_icon[i].y =  i/ 4 * 120+self.y-oy+16#120*i+self.y-oy+16
  283.       
  284.     #  @item_icon[i].y = i/4*120
  285.       if @item_icon[i].y < self.y or @item_icon[i].y > self.y+120*self.page_row_max
  286.         @item_icon[i].visible = false
  287.       else
  288.         @item_icon[i].visible = true
  289.       end
  290.     end
  291.    #update_help
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 描绘物品
  295.   #--------------------------------------------------------------------------  
  296.   def draw_item(index, x, y)

  297.     item = @all_fighters[index]
  298.    
  299.    
  300.    
  301.    
  302.     self.contents.font.size = 12
  303.      
  304.       
  305.     #图标缩放显示专用
  306.     icon_size = 100#图片缩放大小self.index%4 * (66 + 5)
  307.     @item_icon[index].x = self.index%4 *86
  308.     @item_icon[index].y = self.index/ 4 * 120
  309. #   @item_icon[index].zoom_x = icon_size.to_f/@item_icon[index].bitmap.width
  310.   #  @item_icon[index].zoom_y = icon_size.to_f/@item_icon[index].bitmap.height
  311.     @item_icon[index].z = self.z+2
  312.     @item_icon[index].color = self.contents.font.color==normal_color ? Color.new(255,255,255,0):Color.new(0,0,0,128)
  313.     #self.contents.font.color = Color.new(128,193,125,0)
  314.     name = Figter_data::THE_NAME[item]
  315.     self.contents.draw_text(x + icon_size.to_f, y + 4, 184, self.contents.font.size, name)
  316.       
  317.    
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 帮助窗口的设置
  321.   #     help_window : 新的帮助窗口
  322.   #--------------------------------------------------------------------------
  323.   def help_window=(help_window)
  324.     @help_window = help_window
  325.     # 刷新帮助文本 (update_help 定义了继承目标)
  326.     if self.active and @help_window != nil
  327.       update_help
  328.     end
  329.   end


  330.   #--------------------------------------------------------------------------
  331.   # ● 更新光标矩形
  332.   #--------------------------------------------------------------------------
  333.   def update_cursor_rect
  334.     #@back.bitmap = RPG::Cache.menu("item_command"+type.to_s)
  335.     # 光标位置不满 0 的情况下
  336.     if @index < 0
  337.       self.cursor_rect.empty
  338.       return
  339.     end
  340.    
  341.     # 获取当前的行
  342.     row = @index/@column_max
  343.     # 当前行被显示开头行前面的情况下
  344.     if row < self.top_row
  345.       # 从当前行向开头行滚动
  346.       self.top_row = row
  347.     end
  348.     # 当前行被显示末尾行之后的情况下
  349.     if row > self.top_row + (self.page_row_max - 1)
  350.       # 从当前行向末尾滚动
  351.       self.top_row = row - (self.page_row_max - 1)
  352.     end
  353.    
  354.     @right.y = self.y+12+self.top_row.to_f*120.0*(3*120)/(@item_max.to_f*120)
  355.    
  356.     # 计算光标的宽度
  357.     cursor_width = 240
  358.     # 计算光标坐标
  359.     x = @index%4*86+2
  360.     y = @index/4-self.oy/120
  361.     # 更新光标矩形
  362.     self.cursor_rect.set(@index%4*84+2,(@index/4-self.oy/120)*120-1,85,120)
  363.     #self.cursor_rect.set(x, y, 86, 120)
  364.   end
  365. #--------------------------------------------------------------------------
  366.   # ● 刷新画面
  367.   #--------------------------------------------------------------------------
  368.   def update
  369.     super

  370.     # 可以移动光标的情况下
  371.     if self.active and @item_max >= 0 and @index >= 0
  372.       # 方向键下被按下的情况下
  373.       if Input.repeat?(Input::DOWN)
  374.         # 光标向下移动
  375.         $game_system.se_play($data_system.cursor_se)
  376.         @index = (@index+1+@item_max) % @item_max if @item_max != 0
  377.         update_help
  378.       end
  379.       # 方向键上被按下的情况下
  380.       if Input.repeat?(Input::UP)
  381.         # 光标向上移动
  382.         $game_system.se_play($data_system.cursor_se)
  383.         @index = (@index-1+@item_max) % @item_max if @item_max != 0
  384.         update_help
  385.       end

  386.       
  387.     end
  388.    
  389.     # 刷新帮助文本 (update_help 定义了继承目标)
  390.     if @help_window != nil and @ajsdgfshfajklshfa == nil
  391.       update_help
  392.       update_help
  393.       @ajsdgfshfajklshfa = true
  394.     end

  395.     # 刷新光标矩形
  396.     update_cursor_rect
  397.   end
  398.   

  399.   
  400.   def now_selected_troop
  401.     return @all_fighters[@index]
  402.   end
  403.   
  404.   #--------------------------------------------------------------------------
  405.   # ● 刷新帮助文本
  406.   #--------------------------------------------------------------------------
  407.   def update_help
  408.     #鲜辣煎鱼
  409.     @help_window.set_text( @index>-1 ? self.item : nil )
  410.    
  411.   end
  412. end
复制代码
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
24
星屑
7017
在线时间
247 小时
注册时间
2020-12-4
帖子
306

极短24获奖极短23获奖极短22获奖

7
发表于 2023-4-17 13:56:22 | 只看该作者
金芒芒 发表于 2023-4-17 13:27
弄了3天终于搞定了,不动脚本的我跟瞎子摸路爬着过来了



恭喜,一旦上路就会上瘾~~~
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6286
在线时间
1103 小时
注册时间
2015-8-15
帖子
658
8
 楼主| 发表于 2023-4-17 18:24:54 | 只看该作者
纯属小虫 发表于 2023-4-17 13:56
恭喜,一旦上路就会上瘾~~~

那你要多来客串啊
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 04:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表