幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1479|回复: 5

[RM2K&2K3] [求助]菜单中加入金钱显示

[复制链接]

9

主题

42

帖子

553

积分

⑤进阶

积分
553
发表于 2007-1-1 11:26:01 | 显示全部楼层 |阅读模式
以下是夏娜菜单中的 物品子菜单
如何加入金钱显示框呢??

PS 我系统乱七八糟的整合了好久 加一个金钱显示应该不会出冲突吧=_=?



#==============================================================================
# 分类物品的命令窗口
#==============================================================================
class Window_ItemCommand < Window_Selectable
#———— 初始化 ————
  def initialize
    super(453, 190, 142, 192)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 5
    @commands = ["药物类", "武器类", "防具类", "装饰类", "特殊类"]
    refresh
    self.index = 0
  end   
#———— 刷新 ————
  def refresh  
    self.contents.clear
    for i in 0...@item_max
    draw_item(i, normal_color)
    end
  end
#—— 描绘项目 ——| index:编号,color:颜色——————
  def draw_item(index, color)
    self.contents.font.color = color
    y = index * 32
    self.contents.draw_text(4, y, 128, 32, @commands[index])
  end
#—— 帮助部分更新 ————
  def update_help
    @help_window.set_text(@commands[self.index])
  end   
end
#==============================================================================
# 物品清单窗口
#==============================================================================
class Window_ItemList < Window_Selectable
#———— 初始化 ————
  def initialize
    super(30, 20, 378, 362)
#   @column_max = 2
    refresh
    self.index = 0
  end
#—— 取得现在选择的物品 ——
  def item
    return @data[self.index]
  end
#—— 刷新 ———
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
  end
#—— 设置不同类别的物品 ———
  def set_item(command)
    refresh
    #—— 根据现在的选项决定物品 ——
    case command  
    when 0            #药品类
      for i in 1...$data_items.size
        if ($data_items.type == "药物" and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    when 1            #武器类
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons)
        end
      end
    when 2            #防具类
      for i in 1...$data_armors.size
        if $data_armors.kind == 0 and $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
      for i in 1...$data_armors.size
        if $data_armors.kind == 1 and $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
       for i in 1...$data_armors.size
        if $data_armors.kind == 2 and $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
    when 3            #装饰类
      for i in 1...$data_armors.size
        if $data_armors.kind == 3 and $game_party.armor_number(i) > 0
          @data.push($data_armors)
        end
      end
    when 4            #特殊类
      for i in 1...$data_items.size
        if ($data_items.type == "特殊" and $game_party.item_number(i) > 0)
          @data.push($data_items)
        end
      end
    end
    @item_max = @data.size  
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.clear
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
#——— 单类物品的个数 ————
  def item_number
    return @item_max
  end
#——— 项目内容的描画 ————
  def draw_item(index)
    item = @data[index]  
    #—— 取得具体物品数量 ——
    case item   
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    #—— 给出物品的颜色 ——
    if item.is_a?(RPG::Item)
      if $game_party.item_can_use?(item.id)
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
    else
      self.contents.font.color = normal_color
    end
   
    #—— 描绘物体图标、物体名、数量 ——
#   x = 4 + index % 2 * 173
#   y = index / 2 * 32
    x = 4
    y = index*32
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 300, y, 16, 32, "×", 1)
    self.contents.draw_text(x + 314, y, 24, 32, number.to_s, 2)
  end
#——— 更新帮助窗口 ————
  def update_help
    @help_window.set_text(make_description(self.item))
  end
end
#############################################################################
#############################################################################
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#  处理物品画面的类。
#==============================================================================
#############################################################################
#############################################################################
class Scene_Item
#——— 主处理 ————
  def main

    # 右边命令窗口
    @itemcommand_window = Window_ItemCommand.new
    @itemcommand_window.opacity = HS::OPACITY
    @itemcommand_window.y = 672

    @item_command_index = @itemcommand_window.index
    # 物品窗口
    @itemlist_window = Window_ItemList.new
    @itemlist_window.opacity = HS::OPACITY
    @itemlist_window.active = false
    @itemlist_window.set_item(@item_command_index)
    @itemlist_window.x = -378
    # 帮助窗口
    @item_help_window = Window_Help_New.new
    @item_help_window.x = -580
    @item_help_window.y = 396
    @item_help_window.opacity = HS::OPACITY

    # 关联帮助窗口
    @itemcommand_window.help_window = @item_help_window
    @itemlist_window.help_window = @item_help_window
    # 目标窗口
    @item_target_window = Window_Target.new
    @item_target_window.y = 480
    @item_target_window.opacity = HS::OPACITY
    @item_target_window.visible = false
    @item_target_window.active = false
    # 目标装备窗口
    @item_target_window_equip = Window_Target_Equip.new
    @item_target_window_equip.y = 480
    @item_target_window_equip.opacity = HS::OPACITY
    @item_target_window_equip.visible = false
    @item_target_window_equip.active = false
    #—— 主循环 ——
    Graphics.transition
    # 窗口的滑动
    for i in 1..8
      @item_help_window.x += 76
      @itemcommand_window.y -= 60
      @itemlist_window.x += 51
      if i == 8
        @item_help_window.x = 30
        @itemcommand_window.y = 190
        @itemlist_window.x = 30
      end
      Graphics.update
    end
   
    loop do
      Graphics.update
      Input.update

      # 更新item
      update_item_scene
      if $scene != self
        break
      end
    end
    #—— 释放窗口 ——
   
    # 窗口的滑动
    for i in 1..9
      @item_help_window.x -= 76
      @itemcommand_window.y += 60
      @itemlist_window.x -= 51
      Graphics.update
    end
   
    Graphics.freeze

    @itemcommand_window.dispose
    @itemlist_window.dispose
    @item_help_window.dispose
    @item_target_window.dispose
    @item_target_window_equip.dispose
  end

  #—— update的定义 ——
  def update_item_scene
    @itemcommand_window.update
    @itemlist_window.update
    @item_help_window.update
    @item_target_window.update
    @item_target_window_equip.update
   
    if @item_command_index != @itemcommand_window.index
      @item_command_index = @itemcommand_window.index
      @itemlist_window.set_item(@item_command_index)
    end
   
    #—— 当某窗体在active的时候,更新之 ——
    if @itemcommand_window.active
      item_update_itemcommand
      return
    end
    if @itemlist_window.active
      item_update_itemlist
      return
    end
    if @item_target_window.active
      item_update_target
      return
    end
    if @item_target_window_equip.active
      item_update_target_equip
      return
    end
  end  # update的

#————具体更新定义————
  def item_update_itemcommand
  
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到菜单画面
      $scene = Scene_Map.new
      return
    end
   
    if Input.trigger?(Input::C)
      if @itemlist_window.item_number == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @itemcommand_window.active = false
      @itemlist_window.active = true
      @itemlist_window.index = 0
      return
    end
  end

#————具体更新定义————
  def item_update_itemlist
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @itemcommand_window.active = true
      @itemlist_window.active = false
      @itemlist_window.index = 0
      @itemcommand_window.index = @item_command_index
      return
    end
   
    if Input.trigger?(Input::C)
      @item = @itemlist_window.item
      if @item.is_a?(RPG::Item)
        unless $game_party.item_can_use?(@item.id)
          $game_system.se_play($data_system.buzzer_se)
          return
        end   
        $game_system.se_play($data_system.decision_se)
        if @item.scope >= 3
          @itemlist_window.active = false
          # 先打开目标窗口的显示,才开始滑动
          @item_target_window.visible = true
          @item_target_window.active = true
          for i in 1..8
            @item_target_window.y -= 39
            if i==8
              @item_target_window.y = 164
            end
            Graphics.update
          end
          if @item.scope == 4 || @item.scope == 6
            @item_target_window.index = -1
          else
            @item_target_window.index = 0
          end
        else
          if @item.common_event_id > 0
            $game_temp.common_event_id = @item.common_event_id
            $game_system.se_play(@item.menu_se)
            if @item.consumable  
              $game_party.lose_item(@item.id, 1)
              @itemlist_window.draw_item(@itemlist_window.index)  
            end
            $scene = Scene_Map.new
            return
          end
        end
        return
      else
        $game_system.se_play($data_system.decision_se)
        @itemlist_window.active = false
        @item_target_window_equip.set_item(@item)
        @item_target_window_equip.visible = true
        @item_target_window_equip.active = true
        for i in 1..8
          @item_target_window_equip.y -= 39
          if i==8
            @item_target_window_equip.y = 164
          end
          Graphics.update
        end
        @item_target_window_equip.index = 0
        return
      end
        
        
        
        
        
    end
  end

  def item_update_target_equip
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @itemlist_window.active = true
      # 目标窗口滑动,滑动结束后才关闭显示
      for i in 1..9
        @item_target_window_equip.y += 39
        Graphics.update
      end
      @item_target_window_equip.visible = false
      @item_target_window_equip.active = false
      @itemlist_window.set_item(@item_command_index)
      return
    end
    if Input.trigger?(Input::C)
      target_actor = $game_party.actors[@item_target_window_equip.index]
      if target_actor.equippable?(@item) and $game_party.item_can_equip?(target_actor,@item)
        # 演奏装备 SE
        $game_system.se_play($data_system.equip_se)
        if @item.is_a?(RPG::Weapon)
          equip_position = 0
        elsif @item.kind == 0
          equip_position = 1
        elsif @item.kind == 1
          equip_position = 2
        elsif @item.kind == 2
          equip_position = 3
        elsif @item.kind == 3
          equip_position = 4
        end
        
        # 固定装备的情况下
        if target_actor.equip_fix?(equip_position)
          # 演奏冻结 SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        
        target_actor.equip(equip_position,@item.id)
        
        @itemlist_window.active = true
        # 目标窗口滑动,滑动结束后才关闭显示
        for i in 1..9
          @item_target_window_equip.y += 39
          Graphics.update
        end
        @item_target_window_equip.visible = false
        @item_target_window_equip.active = false

        @itemlist_window.draw_item(@itemlist_window.index)
        @itemlist_window.set_item(@item_command_index)

      else
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)  
      end
      

      
    end
  
  end
  
#———— 更新target窗口————
  def item_update_target
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      unless $game_party.item_can_use?(@item.id)
        @itemlist_window.refresh
      end
      @itemlist_window.active = true
      # 目标窗口滑动,滑动结束后才关闭显示
      for i in 1..9
        @item_target_window.y += 39
        Graphics.update
      end
      @item_target_window.visible = false
      @item_target_window.active = false
      @itemlist_window.set_item(@item_command_index)
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.item_number(@item.id) == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @item_target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      if @item_target_window.index >= 0
        target = $game_party.actors[@item_target_window.index]
        used = target.item_effect(@item)
      end
      
      if used
        $game_system.se_play(@item.menu_se)
        if @item.consumable
          $game_party.lose_item(@item.id, 1)
          @itemlist_window.draw_item(@itemlist_window.index)
          @itemlist_window.set_item(@item_command_index)
        end
        @item_target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $scene = Scene_Map.new
          return
        end  
      end
   
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
    return
    end
  end   
end
回复

使用道具 举报

88

主题

5419

帖子

214748万

积分

版主

S素世上最伟大最华丽

Rank: 7Rank: 7Rank: 7

积分
2147483647
QQ
发表于 2007-1-1 11:56:38 | 显示全部楼层
不会,只是你这样贴代码是不行的...Orz
回复 支持 反对

使用道具 举报

9

主题

42

帖子

553

积分

⑤进阶

积分
553
 楼主| 发表于 2007-1-1 14:57:14 | 显示全部楼层
因为找不到工程地址了

其实应该够的啊.这个是子物品分类菜单窗口

应该可以加入显示金钱的框啊

如果是因为没办法取得坐标 没关系 这个我会调 [s:6]

我只是不懂怎么加入和释放窗口
回复 支持 反对

使用道具 举报

88

主题

5419

帖子

214748万

积分

版主

S素世上最伟大最华丽

Rank: 7Rank: 7Rank: 7

积分
2147483647
QQ
发表于 2007-1-1 15:05:40 | 显示全部楼层
发帖时应用 # 粘贴代码...否则会有很多[ i ] 失踪...
加入和释放窗口具体看,Scene_XXX这些脚本你就能明白了~~
回复 支持 反对

使用道具 举报

好人卡的 该用户已被删除
发表于 2007-1-1 19:03:39 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

9

主题

42

帖子

553

积分

⑤进阶

积分
553
 楼主| 发表于 2007-1-2 11:45:31 | 显示全部楼层
恩 谢谢大家 我明白了... [s:1]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-27 06:25 , Processed in 0.012482 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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