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

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

66rpg增强型对话框之精简强化版

2005-10-14 00:00| 发布者: 柳柳| 查看: 13397| 评论: 0|原作者: 66RPG

摘要:    作者 SailCat(中国大陆)  版本与更新  2005年9月15日更新  相关网址    范例工程 不提供  脚本功能 这个精简版本去除了所有等待时间的操作(包括打字
 

 作者

SailCat(中国大陆)

 版本与更新

 2005年9月15日更新

 相关网址

 

 范例工程

不提供



 脚本功能

这个精简版本去除了所有等待时间的操作(包括打字效果、音效、等待N帧自动消失的效果等),使用系统默认进程描绘文字(速度比原来快多了)。保留原来所有的文字格式控制,并对显示头像等方面进行了增强。

 使用方法

替代windows_message(或你插入的66增强型对话框)全部内容。

 相关截图

无 


 

 脚本内容

# ————————————————————————————————————
# 本脚本来自www.66rpg.com,转载请保留此信息
# ————————————————————————————————————

#从此精简版本中去除的标记:
# \.   :停顿一刹那(1、2帧)
# \|   :停顿片刻(20帧)
# \>   :文字不用打字方式
# \<   :文字使用打字方式
# \!   :等待玩家按回车再继续
# \~   :文字直接消失
# \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

#新增的标记:
# \d[4]:空4个字节(2个汉字)的位置
# \t: 显示游戏时间窗口
# \v[7]:显示7号变量的值
# \v[a7]:显示7号防具的名称
# \v[s7]:显示7号特技的名称
# \v[w7]:显示7号武器的名称
# \v[i7]:显示7号道具的名称
# \A:头像及姓名框靠左排列
# \a:头像及姓名框靠右排列
# \u[rrggbb]:直接以RGB值十六进制指定颜色

#强化功能的标记:
# \F[001]:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
# \f[1]:在对话中显示1号角色的头像,没有的话同\F[1]效果
# \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
# \l[1]:在左边显示1号角色的半身像,没有的话同\L[1]效果
# \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
# \r[1]:在右边显示1号角色的半身像,没有的话同\R[1]效果
# \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
# \m2[\n[1]]:用颜色2显示1号主角的姓名方框 ----不知道有多少人盼这个功能盼了多久了呵呵

#下面是脚本:

#——说明

# 其他在对话中可以使用的功能:
  
# \n[1]:显示1号角色的姓名

# \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
# \m2[\n[1]]:用颜色2显示1号主角的姓名方框

# \p[1]:对话框出现在1号事件的上方
# \p[0]:主人公上方出现对话框
#——————————————————使用\p功能后可以自动调整对话框大小

# \\:显示"\"这个符号

# \c[0-7]:更改颜色

# \u[rrggbb]:直接以十六进制指定颜色,注意这里会把透明度重设为255

# \g:显示金钱窗口

# \t: 显示游戏时间窗口

# \I   :下一行从这个位置开始

# \o[123]:文字透明度改为123,模拟将死之人(汗)

# \h[12]:改用12号字

# \b[50]:空50象素

# \d[4]:空4个字节(2个汉字)的位置

# \F[001]:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
# \f[1]:在对话中显示1号角色的头像,没有的话同\F[1]效果
# \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
# \l[1]:在左边显示1号角色的半身像,没有的话同\L[1]效果
# \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
# \r[1]:在右边显示1号角色的半身像,没有的话同\R[1]效果

# \Lk:清除左边的图像
# \Rk:清除右边的图像

# \v[7]:显示7号变量的值
# \v[a7]:显示7号防具的名称
# \v[s7]:显示7号特技的名称
# \v[w7]:显示7号武器的名称
# \v[i7]:显示7号道具的名称

# \A:头像及姓名框靠左排列
# \a:头像及姓名框靠右排列

#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化状态
  #--------------------------------------------------------------------------
  def initialize
    super(80, 304, 480, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.visible = false
    self.z = 9998
    @fade_in = false
    @fade_out = false
    @contents_showing = false
    @cursor_width = 0
    self.active = false
    self.index = -1
    @popchar = -2
    @alignment = true
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    terminate_message
    $game_temp.message_window_showing = false
    if @input_number_window != nil
      @input_number_window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● 处理信息结束
  #--------------------------------------------------------------------------
  def terminate_message
    self.active = false
    self.pause = false
    self.index = -1
    self.contents.clear
    # 清除显示中标志
    @contents_showing = false
    # 呼叫信息调用
    if $game_temp.message_proc != nil
      $game_temp.message_proc.call
    end
    # 清除文章、选择项、输入数值的相关变量
    $game_temp.message_text = nil
    $game_temp.message_proc = nil
    $game_temp.choice_start = 99
    $game_temp.choice_max = 0
    $game_temp.choice_cancel_type = 0
    $game_temp.choice_proc = nil
    $game_temp.num_input_start = 99
    $game_temp.num_input_variable_id = 0
    $game_temp.num_input_digits_max = 0
    # 开放金钱窗口
    if @gold_window != nil
      @gold_window.dispose
      @gold_window = nil
    end
    # 开放时间窗口
    if @playtime_window != nil
      @playtime_window.dispose
      @playtime_window = nil
    end
    # 开放姓名窗口
    if @name_window != nil
      @name_window.dispose
      @name_window = nil
    end
    if @name_airtext != nil
      @name_airtext.dispose
      @name_airtext = nil
    end
    # 开放角色图片
    if @right_picture != nil and @right_keep == true
      @right_picture.dispose
    end
    if @left_picture != nil and @left_keep == true
      @left_picture.dispose
    end
    @face_bitmap = nil
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    # 初期化
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = Font.default_size
    x = y = max_x = max_y = @indent = lines = 0
    @left_keep = @right_keep = false
    @face_indent = 0
    @opacity = 255
    @cursor_width = 0
    face = nil
    if $game_temp.choice_start == 0
      x = 8
    end
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      #——对齐设置
      if (/\\([Aa])/.match(text))!=nil then
        if $1 == "A"
          @alignment = true
        else
          @alignment = false
        end
        text.gsub!(/\\([Aa])/) { "" }
      end
      #——头像设置
      if (/\\([Ff])\[(.+?)\]/.match(text))!=nil then
        face = "66rpg_" + $2 + "_f.png"
        if $1 == "f" and $game_actors[$2.to_i] != nil
          face = $game_actors[$2.to_i].battler_name + "_f.png"
        end
        if FileTest.exist?("Graphics/Battlers/#{face}")
          @face_bitmap = Bitmap.new("Graphics/Battlers/#{face}")
          if @alignment
            x = @face_indent = 128
            self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
          else
            self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
              Rect.new(0, 0, 96, 96))
          end
        else
          face = nil
          @face_bitmap = nil
        end
        text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
      end
      #——左半身像设置
      if (/\\([Ll])\[(.+?)\]/.match(text))!=nil then
        face = "66rpg_" + $2 + "_h.png"
        if $1 == "l" and $game_actors[$2.to_i] != nil
          face = $game_actors[$2.to_i].battler_name + "_h.png"
        end
        if $加密 == true
          if @left_picture != nil
            @left_picture.dispose
          end
          @left_picture = Sprite.new
          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
          @left_picture.y = 480-@left_picture.bitmap.height
          @left_picture.x = 0
          @left_picture.mirror = true
          text.gsub!(/\\([Ll])\[(.*?)\]/) { "" }
        else         
          if FileTest.exist?("Graphics/battlers/#{face}")
            if @left_picture != nil
              @left_picture.dispose
            end
            @left_picture = Sprite.new
            @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
            @left_picture.y = 480-@left_picture.bitmap.height
            @left_picture.x = 0
            @left_picture.mirror = true
            text.gsub!(/\\([Ll])\[(.*?)\]/) { "" }
          end
        end        
      end
      #——右半身像设置
      if (/\\([Rr])\[(.+?)\]/.match(text))!=nil then
        face = "66rpg_" + $2 + "_h.png"
        if $1 == "r" and $game_actors[$2.to_i] != nil
          face = $game_actors[$2.to_i].battler_name + "_h.png"
        end
        if $加密 == true
          if @right_picture != nil
            @right_picture.dispose
          end
          @right_picture = Sprite.new
          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
          @right_picture.y = 480-@right_picture.bitmap.height
          @right_picture.x = 640-@right_picture.bitmap.width
          text.gsub!(/\\([Rr])\[(.*?)\]/) { "" }
        else
          if FileTest.exist?("Graphics/battlers/#{face}")
            if @right_picture != nil
              @right_picture.dispose
            end
            @right_picture = Sprite.new
            @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
            @right_picture.y = 480-@right_picture.bitmap.height
            @right_picture.x = 640-@right_picture.bitmap.width
            text.gsub!(/\\([Rr])\[(.*?)\]/) { "" }
          end
        end
      end
      if (/\\[Rr]k/.match(text)) != nil
        @right_keep = true
        text.sub!(/\\[Rr]k/) { "" }
      end
      if (/\\[Ll]k/.match(text)) != nil
        @left_keep = true
        text.sub!(/\\[Ll]k/) { "" }
      end
      # 替换人物姓名
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # 显示人物姓名
      name_window_set = false
      if (/\\[Mm]([0-9]*?)\[(.+?)\]/.match(text)) != nil
        name_window_set = true
        if $1 == ""
          color = 0
        else
          color = $1.to_i
        end
        if color >= 0 and color <= 7
          name_color = color
        end
        name_text = $2
        text.sub!(/\\[Mm]([0-9]*?)\[(.*?)\]/) { "" }
      end
      # 文字位置的判定
      if (/\\[Pp]\[([-1,0-9]+)\]/.match(text))!=nil then
        @popchar = $1.to_i
        if @popchar == -1
          x = @indent = 48
          y = 4
        end
        text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
      end
      # 开始
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
      end until text == last_text
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
      text.gsub!(/\\[Tt]/) { "\003" }
      text.gsub!(/\\[Uu]\[([0-9A-Fa-f]{6})\]/) { "\004[#{$1}]" }
      text.gsub!(/\\[Ii]/) { "\023" }
      text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
      text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
      text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
      text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
      if @popchar >= 0
        max_x = 0
        max_y = 4
        for i in 0..3
          line = text.split(/\n/)[3-i]
          max_y -= 1 if line == nil and max_y <= 4-i
          next if line == nil
          cx = contents.text_size(line).width
          max_x = cx if cx > max_x
        end
        self.width = max_x + 48 + @face_indent
        self.height = (max_y - 1) * 32 + 64
      else
        max_x = self.width - 32 - @face_indent
      end
      reset_window
      if name_window_set
        w = self.contents.text_size(name_text).width + 16
        xn = @alignment ? self.x : self.x + self.width - w
        yn = self.y >= 40 ? self.y - 40 : self.y + self.height
        @name_window = Window_Name.new(xn, yn, w)
        @name_window.z = self.z + 1
        @name_airtext = Window_AirText.new(xn + 8, yn + 8, name_text, name_color)
        @name_airtext.z = self.z + 2
      end
      while ((c = text.slice!(/./m)) != nil)
        if c == "\000"
          c = "\\"
        end
        if c == "\001"
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          next
        end
        if c == "\002"
          if @gold_window == nil and @popchar <= 0
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          next
        end
        if c == "\003"
          if @playtime_window == nil and @popchar <=0
            @playtime_window = Window_PlayTime.new
            @playtime_window.x = 80
            if $game_temp.in_battle
              @playtime_window.y = 192
            else
              @playtime_window.y = self.y >= 128 ? 32 : 384
            end
            @playtime_window.opacity = self.opacity
            @playtime_window.back_opacity = self.back_opacity
          end
        end
        if c == "\004"
          text.sub!(/\[([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\]/, "")
          self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)
          next
        end
        if c == "\023"
          @indent = x
          next
        end
        if c == "\024"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.color.alpha = [[0, $1.to_i].max, 255].min
          next
        end
        if c == "\025"
          text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = [[$1.to_i, 6].max, 32].min
          next
        end
        if c == "\026"
          text.sub!(/\[([0-9]+)\]/, "")
          x += $1.to_i
          next
        end
        if c == "\027"
          text.sub!(/\[([0-9]+)\]/, "")
          x += $1.to_i * self.contents.font.size / 2
          next
        end
        if c == "\030"
          text.sub!(/\[(.*?)\]/, "")
          self.contents.blt(x , y * line_height + 4, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
          x += 24
          next
        end
        if c == "\n"
          if lines >= $game_temp.choice_start
            @cursor_width = [@cursor_width, max_x - @face_indent].max
          end
          lines += 1
          y += 1
          x = 0 + @indent + @face_indent
          if lines >= $game_temp.choice_start
            x = 8 + @indent + @face_indent
          end
          next
        end
        # 描绘文字
        self.contents.draw_text(x, line_height * y, 40, 32, c)
        # x 为要描绘文字的加法运算
        x += self.contents.text_size(c).width
      end
    end
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update
    super
    # 渐变的情况下
    if @fade_in
      self.contents_opacity += 24
      if @input_number_window != nil
        @input_number_window.contents_opacity += 24
      end
      if self.contents_opacity == 255
        @fade_in = false
      end
      return
    end
    # 输入数值的情况下
    if @input_number_window != nil
      @input_number_window.update
      # 确定
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        $game_variables[$game_temp.num_input_variable_id] =
          @input_number_window.number
        $game_map.need_refresh = true
        # 释放输入数值窗口
        @input_number_window.dispose
        @input_number_window = nil
        terminate_message
      end
      return
    end
    # 显示信息中的情况下
    if @contents_showing
      # 如果不是在显示选择项中就显示暂停标志
      if $game_temp.choice_max == 0
        self.pause = true
      end
      # 取消
      if Input.trigger?(Input::B)
        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
          $game_system.se_play($data_system.cancel_se)
          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
          terminate_message
        end
      end
      # 确定
      if Input.trigger?(Input::C)
        if $game_temp.choice_max > 0
          $game_system.se_play($data_system.decision_se)
          $game_temp.choice_proc.call(self.index)
        end
        terminate_message
      end
      return
    end
    # 在渐变以外的状态下有等待显示的信息与选择项的场合
    if @fade_out == false and $game_temp.message_text != nil
      @contents_showing = true
      $game_temp.message_window_showing = true
      reset_window
      refresh
      Graphics.frame_reset
      self.visible = true
      self.contents_opacity = 0
      if @input_number_window != nil
        @input_number_window.contents_opacity = 0
      end
      @fade_in = true
      return
    end
    # 没有可以显示的信息、但是窗口为可见的情况下
    if self.visible
      @fade_out = true
      self.opacity -= 48
      if self.opacity == 0
        self.visible = false
        @fade_out = false
        $game_temp.message_window_showing = false
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 获得字符
  #--------------------------------------------------------------------------
  def get_character(parameter)
    case parameter
    when 0
      return $game_player
    else
      events = $game_map.events
      return events == nil ? nil : events[parameter]
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置窗口位置与不透明度
  #--------------------------------------------------------------------------
  def reset_window
    # 判定
    if @popchar >= 0
      events = $game_map.events
      if events != nil
        character = get_character(@popchar)
        x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
        y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
        self.x = x
        self.y = y
      end
    elsif @popchar == -1
      self.x

1

鲜花

刚表态过的朋友 (1 人)

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