查看: 2614|回复: 2

[已经过期] 关于光标换行的问题

[复制链接]
梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

发表于 2017-2-18 23:25:43 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 戴迪 于 2017-2-19 00:54 编辑

自己调了装备界面item的列数,改成5行,然后在最后添加了一个移动光标矩形的间距,但是好像不能换行阿- -[pre lang="ruby" line="1" file="Window_EquipItem"]#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
#  装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor      : 角色
  #     equip_type : 装备部位 (0~3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(160, 256, 640, 224)
    @actor = actor
    @equip_type = equip_type
    @column_max = 5
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 添加可以装备的武器
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons)
        end
      end
    end
    # 添加可以装备的防具
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors.kind == @equip_type-1
            @data.push($data_armors)
          end
        end
      end
    end
    # 添加空白
    @data.push(nil)
    # 生成位图、描绘全部项目
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目的描绘
  #     index : 项目符号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 5 * (32)
    y = index / 5 * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
#    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
#   self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
    self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
      self.cursor_rect.set(@index * 32,0 , 32, 32)
    end
end
[/pre]

==============(第一次更新)===================================
后来自己又弄了下,成了这样,不知道怎么弄才能把光标移动到第25个装备上时.就不能再往下移动!不然多出来一个位置不美观
[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
#  装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor      : 角色
  #     equip_type : 装备部位 (0~3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(160, 256, 640, 224)
    @actor = actor
    @equip_type = equip_type
    @column_max = 5
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 添加可以装备的武器
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...50
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons)
        end
      end
    end
    # 添加可以装备的防具
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors.kind == @equip_type-1
            @data.push($data_armors)
          end
        end
      end
    end
    # 添加空白
    @data.push(nil)
    # 生成位图、描绘全部项目
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目的描绘
  #     index : 项目符号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 5 * (32)
    y = index / 5 * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
#    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
#   self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
    self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(@index * 32,0 , 32, 32)
    if @index > 4
      self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32)
    end
    if @index > 9
      self.cursor_rect.set( (@index - 10 )* 32,64 , 32, 32)
    end
    if @index > 14
      self.cursor_rect.set( (@index - 15 )* 32,96 , 32, 32)
    end
    if @index > 19
      self.cursor_rect.set( (@index - 20 )* 32,128 , 32, 32)
    end
  end
end
[/pre]
20170218232057.png
QQ截图20170219005008.png
梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2017-2-19 12:48:23 | 显示全部楼层
[pre lang="ruby"]#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
#  装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     actor      : 角色
  #     equip_type : 装备部位 (0~3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(160, 256, 640, 224)
    @actor = actor
    @equip_type = equip_type
    @column_max = 5
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # 添加可以装备的武器
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...50
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons)
        end
      end
    end
    # 添加可以装备的防具
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors.kind == @equip_type-1
            @data.push($data_armors)
          end
        end
      end
    end
    # 添加空白
    @data.push(nil)
    # 生成位图、描绘全部项目
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目的描绘
  #     index : 项目符号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 5 * (32)
    y = index / 5 * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    #self.contents.draw_text(x +32 , y, 16, 32, ":", 1)
    self.contents.draw_text(x  , y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(@index * 32,0 , 32, 32)
    if @index == -1
         self.cursor_rect.set(0,0, 0, 0)
    elsif @index > 4 and @index <= 9
     self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32)
   elsif @index > 9 and @index <= 14
      self.cursor_rect.set( (@index- 10 )* 32,64 , 32, 32)
    elsif @index > 14 and @index <= 19
      self.cursor_rect.set( (@index- 15 )* 32,96 , 32, 32)
    elsif @index > 19 and @index <= 24
      self.cursor_rect.set( (@index- 20 )* 32,128 , 32, 32)
    elsif @index > 24
      self.cursor_rect.set( 24 * 32,128 , 32, 32)
      @index -= 1
      end
  end
end[/pre]

评分

参与人数 1星屑 +90 收起 理由
RyanBern + 90 塞糖

查看全部评分

Vanyogin
回复 1 0

使用道具 举报

梦石
0
星屑
1090
在线时间
324 小时
注册时间
2017-1-24
回帖
105

开拓者

 楼主| 发表于 2017-2-19 13:16:53 | 显示全部楼层
2357691704 发表于 2017-2-19 12:48
#==============================================================================
# ■ Window_EquipIte ...


谢谢啊!虽然还没试验过,但单看脚本好像没什么问题了。有时间就弄弄
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部