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

Project1

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

[已经解决] 如何使66经典增强对话框与这个多字体脚本一同使用?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
69 小时
注册时间
2011-5-31
帖子
8
跳转到指定楼层
1
发表于 2011-7-21 13:19:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Fengxwu 于 2011-7-21 13:32 编辑

http://www.66rpg.com/htm/news725.htm
这是那个字体脚本的地址
想同66rpg的那个增强对话框一同使用,但貌似不兼容
而且那个\f[]与增强对话框的显示头像冲突了
本人标准脚本盲~

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
2
发表于 2011-7-21 20:21:34 | 只看该作者
本帖最后由 英顺的马甲 于 2011-7-21 20:25 编辑

将增添修改的部分插入对话框脚本。
若你不会的话将66增强对话框附上,
我帮你整合,因为我找不到那个脚本。
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
69 小时
注册时间
2011-5-31
帖子
8
3
 楼主| 发表于 2011-7-22 01:00:59 | 只看该作者
本帖最后由 Fengxwu 于 2011-7-22 01:01 编辑
英顺的马甲 发表于 2011-7-21 20:21
将增添修改的部分插入对话框脚本。
若你不会的话将66增强对话框附上,
我帮你整合,因为我找不到那个脚本。 ...


http://www.66rpg.com/htm/news100.htm
大概是这个,感谢万分
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
4
发表于 2011-7-22 17:04:00 | 只看该作者
整合了,请用“\font[字体名称]”来改变字体
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. #——说明

  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7.    
  8. #默认对话字没有声音,如果需要声音,
  9. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  10. #我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  11. # 其他在对话中可以使用的功能:

  12. # \n[1]:显示1号角色的姓名

  13. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

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

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

  18. # \c[1-8]:更改颜色

  19. # \g:显示金钱窗口

  20. # \a[SE文件名]:对话的时候播放SE

  21. # \s[1-19]:更改弹字的速度

  22. # \.   :停顿一刹那(1、2帧)
  23. # \|   :停顿片刻(20帧)

  24. # \>   :文字不用打字方式
  25. # \<   :文字使用打字方式

  26. # \!   :等待玩家按回车再继续
  27. # \~   :文字直接消失

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

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

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

  31. # \b[50]:空50象素

  32. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

  33. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  34. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”

  35. # \Lk:清除左边的图像
  36. # \Rk:清除右边的图像
  37. # \M[60]:等待60帧文字直接消失

  38. #脚本冲突可能:
  39. #不用说了。因为改了分辨率所有原有窗口需要自己定义,基本上可以算是和所有脚本冲突。

  40. #============================
  41. class Game_System
  42. attr_accessor :typing
  43. attr_accessor :soundname_on_speak
  44. alias carol3_ini initialize
  45. def initialize
  46.    carol3_ini
  47.    @typing = true
  48.    @soundname_on_speak = nil
  49. end
  50. end
  51. #=================================
  52. #==============================================================================
  53. # ■ Window_Message
  54. #------------------------------------------------------------------------------
  55. class Window_Message < Window_Selectable
  56. #--------------------------------------------------------------------------
  57. # ● 初始化状态
  58. #--------------------------------------------------------------------------
  59. def initialize
  60.    super(80, 304, 480, 160)
  61.    self.contents = Bitmap.new(width - 32, height - 32)
  62.    self.visible = false
  63.    self.z = 9998
  64.    @fade_in = false
  65.    @fade_out = false
  66.    @contents_showing = false
  67.    @cursor_width = 0
  68.    @autoclosetime = -1
  69.    self.active = false
  70.    self.index = -1
  71.    if $game_system.soundname_on_speak == nil then
  72.      $game_system.soundname_on_speak = ""
  73.    end
  74.    @opacity_text_buf = Bitmap.new(32, 32)
  75. end
  76. #--------------------------------------------------------------------------
  77. # ● 释放
  78. #--------------------------------------------------------------------------
  79. def dispose
  80.    terminate_message
  81.    $game_temp.message_window_showing = false
  82.    if @input_number_window != nil
  83.      @input_number_window.dispose
  84.    end
  85.    super
  86. end
  87. #--------------------------------------------------------------------------
  88. # ● 处理信息结束
  89. #--------------------------------------------------------------------------
  90. def terminate_message
  91.    self.active = false
  92.    self.pause = false
  93.    self.index = -1
  94.    self.contents.clear
  95.    # 清除显示中标志
  96.    @contents_showing = false
  97.    # 呼叫信息调用
  98.    if $game_temp.message_proc != nil
  99.      $game_temp.message_proc.call
  100.    end
  101.    # 清除文章、选择项、输入数值的相关变量
  102.    $game_temp.message_text = nil
  103.    $game_temp.message_proc = nil
  104.    $game_temp.choice_start = 99
  105.    $game_temp.choice_max = 0
  106.    $game_temp.choice_cancel_type = 0
  107.    $game_temp.choice_proc = nil
  108.    $game_temp.num_input_start = 99
  109.    $game_temp.num_input_variable_id = 0
  110.    $game_temp.num_input_digits_max = 0
  111.    # 开放金钱窗口
  112.    if @gold_window != nil
  113.      @gold_window.dispose
  114.      @gold_window = nil
  115.    end
  116.    if @name_window_frame != nil
  117.      @name_window_frame.dispose
  118.      @name_window_frame = nil
  119.    end
  120.    if @name_window_text != nil
  121.      @name_window_text.dispose
  122.      @name_window_text = nil
  123.    end
  124.    if @right_picture != nil and @right_keep == true
  125.      @right_picture.dispose
  126.    end   
  127.    if @left_picture != nil and @left_keep == true
  128.      @left_picture.dispose
  129.    end
  130. end
  131. def refresh
  132.    # 初期化
  133.    self.contents.clear
  134.    self.contents.font.color = normal_color
  135.    self.contents.font.size = Font.default_size
  136.    @x = @y = @max_x = @max_y = @indent = @lines = 0
  137.    @left_keep = @right_keep = false
  138.    @face_indent = 0
  139.    @opacity = 255
  140.    @cursor_width = 0
  141.    @autoclosetime = -1
  142.    @write_speed = 0
  143.    @write_wait = 0
  144.    @mid_stop = false
  145.    @face_file = nil
  146.    @popchar = -2
  147.    if $game_temp.choice_start == 0
  148.      @x = 8
  149.    end
  150.    if $game_temp.message_text != nil
  151.      @now_text = $game_temp.message_text
  152.      #——头像设置
  153.      if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  154.        @face_file = $1 + ".png"
  155.        @x = @face_indent = 128
  156.        if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  157.          self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  158.        end
  159.        @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  160.      end
  161.      #——左半身像设置
  162.      if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  163.        @face = "66rpg_" + $1 + "_h.png"
  164.        if $加密 == true
  165.          if @left_picture != nil
  166.            @left_picture.dispose
  167.          end
  168.          @left_picture = Sprite.new
  169.          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  170.          @left_picture.y = 480-@left_picture.bitmap.height
  171.          @left_picture.x = 0
  172.          @left_picture.mirror = true
  173.          @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  174.        else         
  175.          if FileTest.exist?("Graphics/battlers/#{@face}")
  176.            if @left_picture != nil
  177.              @left_picture.dispose
  178.            end
  179.            @left_picture = Sprite.new
  180.            @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  181.            @left_picture.y = 480-@left_picture.bitmap.height
  182.            @left_picture.x = 0
  183.            @left_picture.mirror = true
  184.            @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  185.          end
  186.        end      
  187.      end
  188.      #——右半身像设置
  189.      if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  190.        @face = "66rpg_" + $1 + "_h.png"
  191.        if $加密 == true
  192.          if @right_picture != nil
  193.            @right_picture.dispose
  194.          end
  195.          @right_picture = Sprite.new
  196.          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  197.          @right_picture.y = 480-@right_picture.bitmap.height
  198.          @right_picture.x = 640-@right_picture.bitmap.width
  199.          @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  200.        else
  201.          if FileTest.exist?("Graphics/battlers/#{@face}")
  202.            if @right_picture != nil
  203.              @right_picture.dispose
  204.            end
  205.            @right_picture = Sprite.new
  206.            @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  207.            @right_picture.y = 480-@right_picture.bitmap.height
  208.            @right_picture.x = 640-@right_picture.bitmap.width
  209.            @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  210.          end
  211.        end
  212.      end
  213.      if (/\\[Rr]k/.match(@now_text)) != nil
  214.        @right_keep = true
  215.        @now_text.sub!(/\\[Rr]k/) { "" }
  216.      end
  217.      if (/\\[Ll]k/.match(@now_text)) != nil
  218.        @left_keep = true
  219.        @now_text.sub!(/\\[Ll]k/) { "" }
  220.      end
  221.      # 显示人物姓名
  222.      name_window_set = false
  223.      if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  224.        name_window_set = true
  225.        name_text = $1
  226.        @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  227.      end
  228.    
  229.      # 文字位置的判定
  230.      if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  231.        @popchar = $1.to_i
  232.        if @popchar == -1
  233.          @x = @indent = 48
  234.          @y = 4
  235.        end
  236.        @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  237.      end
  238.    
  239.      # 开始
  240.      begin
  241.        last_text = @now_text.clone
  242.        @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  243.      end until @now_text == last_text
  244.      @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  245.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  246.    end
  247.    @now_text.gsub!(/\\\\/) { "\000" }
  248.    @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  249.    @now_text.gsub!(/\\[Gg]/) { "\002" }
  250.    @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  251.    @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  252.    @now_text.gsub!(/\\[.]/) { "\005" }
  253.    @now_text.gsub!(/\\[|]/) { "\006" }
  254.    @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  255.   
  256.    @now_text.gsub!(/\\[>]/) { "\016" }
  257.    @now_text.gsub!(/\\[<]/) { "\017" }
  258.    @now_text.gsub!(/\\[!]/) { "\020" }
  259.    @now_text.gsub!(/\\[~]/) { "\021" }
  260.   
  261.    @now_text.gsub!(/\\[Ii]/) { "\023" }
  262.    @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  263.    @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  264.    @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  265.    @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  266.    @now_text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\051[#{$1}]" }
  267.    if @popchar >= 0
  268.      @text_save = @now_text.clone
  269.      @max_x = 0
  270.      @max_y = 4
  271.      for i in 0..3
  272.        line = @now_text.split(/\n/)[3-i]
  273.        @max_y -= 1 if line == nil and @max_y <= 4-i
  274.        next if line == nil
  275.        cx = contents.text_size(line).width
  276.        @max_x = cx if cx > @max_x
  277.      end
  278.      self.width = @max_x + 48 + @face_indent
  279.      self.height = (@max_y - 1) * 32 + 64
  280.    else
  281.      @max_x = self.width - 32 - @face_indent
  282.    end
  283.    reset_window
  284.      if name_window_set
  285.        off_x = 0
  286.        off_y = -40
  287.        space = 2
  288.        x = self.x + off_x - space / 2
  289.        y = self.y + off_y - space / 2
  290.        w = self.contents.text_size(name_text).width + 26 + space
  291.        h = 40 + space
  292.        @name_window_frame = Window_Frame.new(x, y, w, h)
  293.        @name_window_frame.z = self.z + 1
  294.        x = self.x + off_x + 4
  295.        y = self.y + off_y
  296.        @name_window_text = Air_Text.new(x+4, y+6, name_text)
  297.        @name_window_text.z = self.z + 2
  298.      end
  299.    end
  300.    reset_window
  301.    if $game_temp.choice_max > 0
  302.      @item_max = $game_temp.choice_max
  303.      self.active = true
  304.      self.index = 0
  305.    end
  306.    if $game_temp.num_input_variable_id > 0
  307.      digits_max = $game_temp.num_input_digits_max
  308.      number = $game_variables[$game_temp.num_input_variable_id]
  309.      @input_number_window = Window_InputNumber.new(digits_max)
  310.      @input_number_window.number = number
  311.      @input_number_window.x = self.x + 8
  312.      @input_number_window.y = self.y + $game_temp.num_input_start * 32
  313.    end
  314. end
  315. #--------------------------------------------------------------------------
  316. # ● 更新
  317. #--------------------------------------------------------------------------
  318. def update
  319.    super
  320.    if @autoclosetime == 0
  321.      @autoclosetime = -1
  322.      terminate_message
  323.   end
  324.    if @autoclosetime >= 1
  325.      @autoclosetime -= 1
  326.    end
  327.    if @fade_in
  328.      self.contents_opacity += 24
  329.      if @input_number_window != nil
  330.        @input_number_window.contents_opacity += 24
  331.      end
  332.      if self.contents_opacity == 255
  333.        @fade_in = false
  334.      end
  335.      return
  336.    end
  337.    @now_text = nil if @now_text == ""
  338.   
  339.    if @now_text != nil and @mid_stop == false
  340.      if @write_wait > 0
  341.        @write_wait -= 1
  342.        return
  343.      end
  344.      text_not_skip = $game_system.typing
  345.      while true
  346.        @max_x = @x if @max_x < @x
  347.        @max_y = @y if @max_y < @y
  348.        if (c = @now_text.slice!(/./m)) != nil
  349.          if c == "\000"
  350.            c = "\\"
  351.          end
  352.          if c == "\001"
  353.            @now_text.sub!(/\[([0-9]+)\]/, "")
  354.            color = $1.to_i
  355.            if color >= 0 and color <= 7
  356.              self.contents.font.color = text_color(color)
  357.            end
  358.            c = ""
  359.          end
  360.          if c == "\002"
  361.            if @gold_window == nil and @popchar <= 0
  362.              @gold_window = Window_Gold.new
  363.              @gold_window.x = 560 - @gold_window.width
  364.              if $game_temp.in_battle
  365.                @gold_window.y = 192
  366.              else
  367.                @gold_window.y = self.y >= 128 ? 32 : 384
  368.              end
  369.              @gold_window.opacity = self.opacity
  370.              @gold_window.back_opacity = self.back_opacity
  371.            end
  372.            c = ""
  373.          end
  374.          if c == "\003"
  375.            @now_text.sub!(/\[([0-9]+)\]/, "")
  376.            speed = $1.to_i
  377.            if speed >= 0 and speed <= 19
  378.              @write_speed = speed
  379.            end
  380.            c = ""
  381.          end
  382.          if c == "\004"
  383.            @now_text.sub!(/\[(.*?)\]/, "")
  384.            buftxt = $1.dup.to_s
  385.            if buftxt.match(/\//) == nil and buftxt != "" then
  386.              $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  387.            else
  388.              $game_system.soundname_on_speak = buftxt.dup
  389.            end
  390.            c = ""
  391.          elsif c == "\004"
  392.            c = ""
  393.          end
  394.          if c == "\005"
  395.            @write_wait += 5
  396.            c = ""
  397.          end
  398.          if c == "\006"
  399.            @write_wait += 20
  400.            c = ""
  401.          end
  402.          if c == "\016"
  403.            text_not_skip = false
  404.            c = ""
  405.          end
  406.          if c == "\017"
  407.            text_not_skip = true
  408.            c = ""
  409.          end
  410.          if c == "\020"
  411.            @mid_stop = true
  412.            c = ""
  413.          end
  414.          if c == "\021"
  415.            terminate_message
  416.            return
  417.          end
  418.          if c == "\023"
  419.            @indent = @x
  420.            c = ""
  421.          end
  422.          if c == "\024"
  423.            @now_text.sub!(/\[([0-9]+)\]/, "")
  424.            @opacity = $1.to_i
  425.            c = ""
  426.          end
  427.          if c == "\025"
  428.            @now_text.sub!(/\[([0-9]+)\]/, "")
  429.            self.contents.font.size = [[$1.to_i, 6].max, 32].min
  430.            c = ""
  431.          end
  432.          if c == "\026"
  433.            @now_text.sub!(/\[([0-9]+)\]/, "")
  434.            @x += $1.to_i
  435.            c = ""
  436.          end
  437.          if c == "\027"
  438.            @now_text.sub!(/\[(.*?)\]/, "")
  439.            @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  440.            if $game_system.soundname_on_speak != ""
  441.              Audio.se_play($game_system.soundname_on_speak)
  442.            end
  443.            c = ""
  444.          end
  445.          if c == "\030"
  446.            @now_text.sub!(/\[(.*?)\]/, "")
  447.            self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  448.           if $game_system.soundname_on_speak != ""
  449.              Audio.se_play($game_system.soundname_on_speak)
  450.            end
  451.            @x += 24
  452.            c = ""
  453.          end
  454.          if c == "\050"

  455.          @now_text.sub!(/\[([0-9]+)\]/, "")

  456.          @autoclosetime = $1.to_i

  457.          next

  458.          end
  459.          if c == "\051"
  460.            @now_text.sub!(/\[(.*?)\]/, "")
  461.            self.contents.font.name = $1
  462.            next
  463.          end
  464.          if c == "\n"
  465.            if @lines >= $game_temp.choice_start
  466.              @cursor_width = [@cursor_width, @max_x - @face_indent].max
  467.            end
  468.            @lines += 1
  469.            @y += 1
  470.            @x = 0 + @indent + @face_indent
  471.            if @lines >= $game_temp.choice_start
  472.              @x = 8 + @indent + @face_indent
  473.            end
  474.            c = ""
  475.          end
  476.          if c != ""
  477.            # 文字描画
  478.            @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  479.            if $game_system.soundname_on_speak != "" then
  480.            Audio.se_play($game_system.soundname_on_speak)
  481.            end
  482.          end
  483.          if Input.press?(Input::B)
  484.            text_not_skip = false
  485.          end
  486.        else
  487.          text_not_skip = true
  488.          break
  489.        end
  490.        # 終了判定
  491.        if text_not_skip
  492.          break
  493.        end
  494.      end
  495.      @write_wait += @write_speed
  496.      return
  497.    end
  498.    if @input_number_window != nil
  499.      @input_number_window.update
  500.      # 決定
  501.      if Input.trigger?(Input::C)
  502.        $game_system.se_play($data_system.decision_se)
  503.        $game_variables[$game_temp.num_input_variable_id] =
  504.        @input_number_window.number
  505.        $game_map.need_refresh = true
  506.        @input_number_window.dispose
  507.        @input_number_window = nil
  508.        terminate_message
  509.      end
  510.      return
  511.    end
  512.    if @contents_showing
  513.      if $game_temp.choice_max == 0
  514.        self.pause = true
  515.      end
  516.      # 取消
  517.      if Input.trigger?(Input::B)
  518.        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  519.          $game_system.se_play($data_system.cancel_se)
  520.          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  521.          terminate_message
  522.        end
  523.      end
  524.      # 決定
  525.      if Input.trigger?(Input::C)
  526.        if $game_temp.choice_max > 0
  527.          $game_system.se_play($data_system.decision_se)
  528.          $game_temp.choice_proc.call(self.index)
  529.        end
  530.        if @mid_stop
  531.          @mid_stop = false
  532.          return
  533.        else
  534.          terminate_message
  535.        end
  536.      end
  537.      return
  538.    end
  539.    if @fade_out == false and $game_temp.message_text != nil
  540.      @contents_showing = true
  541.      $game_temp.message_window_showing = true
  542.      refresh
  543.      Graphics.frame_reset
  544.      self.visible = true
  545.      self.contents_opacity = 0
  546.    if @input_number_window != nil
  547.      @input_number_window.contents_opacity = 0
  548.    end
  549.      @fade_in = true
  550.      return
  551.    end
  552.    if self.visible
  553.      @fade_out = true
  554.      self.opacity -= 48
  555.      if self.opacity == 0
  556.        self.visible = false
  557.        @fade_out = false
  558.        $game_temp.message_window_showing = false
  559.      end
  560.      return
  561.    end
  562. end
  563. #--------------------------------------------------------------------------
  564. # ● 获得字符
  565. #--------------------------------------------------------------------------
  566. def get_character(parameter)
  567.    case parameter
  568.    when 0
  569.      return $game_player
  570.    else
  571.      events = $game_map.events
  572.      return events == nil ? nil : events[parameter]
  573.    end
  574. end
  575. #--------------------------------------------------------------------------
  576. # ● ウィンドウの位置と不透明度の設定
  577. #--------------------------------------------------------------------------
  578. def reset_window
  579.    # 判定
  580.    if @popchar >= 0
  581.      events = $game_map.events
  582.      if events != nil
  583.        character = get_character(@popchar)
  584.        x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  585.        y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  586.        self.x = x
  587.        self.y = y
  588.      end
  589.    elsif @popchar == -1
  590.      self.x = -4
  591.      self.y = -4
  592.      self.width = 648
  593.      self.height = 488
  594.    else
  595.      if $game_temp.in_battle
  596.        self.y = 16
  597.      else
  598.        case $game_system.message_position
  599.        when 0 # 上
  600.          self.y = 16
  601.        when 1 # 中
  602.          self.y = 160
  603.        when 2 # 下
  604.          self.y = 304
  605.        end
  606.        self.x = 80
  607.        if @face_file == nil
  608.          self.width = 480
  609.        else
  610.          self.width = 600
  611.          self.x -= 60
  612.        end
  613.        self.height = 160
  614.      end
  615.    end
  616.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  617.    if @face_file != nil
  618.      self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  619.    end
  620.    if @popchar == -1
  621.      self.opacity = 255
  622.      self.back_opacity = 0
  623.    elsif $game_system.message_frame == 0
  624.      self.opacity = 255
  625.      self.back_opacity = 100
  626.    else
  627.      self.opacity = 0
  628.      self.back_opacity = 100
  629.    end
  630. end
  631. #--------------------------------------------------------------------------
  632. # ● line_height
  633. #--------------------------------------------------------------------------
  634. # 返回値:行高
  635. #--------------------------------------------------------------------------
  636. def line_height
  637.    return 32
  638.    if self.contents.font.size >= 20 and self.contents.font.size <= 24
  639.      return 32
  640.    else
  641.      return self.contents.font.size * 15 / 10
  642.    end
  643. end
  644. #--------------------------------------------------------------------------
  645. # ● 透過文字描画
  646. #--------------------------------------------------------------------------
  647. # target :描画対象。Bitmapクラスを指定。
  648. # x :x座標
  649. # y :y座標
  650. # str  :描画文字列
  651. # opacity:透過率(0~255)
  652. # 返回値 :文字幅(@x増加値)。
  653. #--------------------------------------------------------------------------
  654. def opacity_draw_text(target, x, y, str,opacity)
  655.    height = target.font.size
  656.    width = target.text_size(str).width
  657.    opacity = [[opacity, 0].max, 255].min
  658.    if opacity == 255
  659.      target.draw_text(x, y, width, height, str)
  660.      return width
  661.    else
  662.      if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  663.        @opacity_text_buf.dispose
  664.        @opacity_text_buf = Bitmap.new(width, height)
  665.      else
  666.        @opacity_text_buf.clear
  667.      end
  668.      @opacity_text_buf.font.size = target.font.size
  669.      @opacity_text_buf.draw_text(0, 0, width, height, str)
  670.      target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  671.    return width
  672.    end
  673. end
  674. def ruby_draw_text(target, x, y, str,opacity)
  675.    sizeback = target.font.size
  676.    target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  677.    rubysize = [rubysize, 6].max
  678.   
  679.    opacity = [[opacity, 0].max, 255].min
  680.    split_s = str.split(/,/)
  681.   
  682.    split_s[0] == nil ? split_s[0] = "" : nil
  683.    split_s[1] == nil ? split_s[1] = "" : nil
  684.   
  685.    height = sizeback + rubysize
  686.    width = target.text_size(split_s[0]).width
  687.   
  688.    target.font.size = rubysize
  689.    ruby_width = target.text_size(split_s[1]).width
  690.    target.font.size = sizeback
  691.   
  692.    buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  693.   
  694.    width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  695.   
  696.    if opacity == 255
  697.      target.font.size = rubysize
  698.      target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  699.      target.font.size = sizeback
  700.      target.draw_text(x, y, width, target.font.size, split_s[0])
  701.      return width
  702.    else
  703.      if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  704.        @opacity_text_buf.dispose
  705.        @opacity_text_buf = Bitmap.new(buf_width, height)
  706.      else
  707.        @opacity_text_buf.clear
  708.      end
  709.      @opacity_text_buf.font.size = rubysize
  710.      @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  711.      @opacity_text_buf.font.size = sizeback
  712.      @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  713.      if sub_x >= 0
  714.        target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  715.      else
  716.        target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  717.      end
  718.      return width
  719.    end
  720. end
  721. #--------------------------------------------------------------------------
  722. # ● \V 变换
  723. #--------------------------------------------------------------------------
  724. def convart_value(option, index)
  725.    option == nil ? option = "" : nil
  726.    option.downcase!
  727.    case option
  728.      when "i"
  729.        unless $data_items[index].name == nil
  730.          r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  731.        end
  732.      when "w"
  733.        unless $data_weapons[index].name == nil
  734.          r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  735.        end
  736.      when "a"
  737.        unless $data_armors[index].name == nil
  738.          r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  739.        end
  740.      when "s"
  741.        unless $data_skills[index].name == nil
  742.          r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  743.        end
  744.      else
  745.      r = $game_variables[index]
  746.    end
  747.    r == nil ? r = "" : nil
  748.    return r
  749. end
  750. #--------------------------------------------------------------------------
  751. # ● 解放
  752. #--------------------------------------------------------------------------
  753. def dispose
  754.    terminate_message
  755.    if @gaiji_cache != nil
  756.      unless @gaiji_cache.disposed?
  757.        @gaiji_cache.dispose
  758.      end
  759.    end
  760.    unless @opacity_text_buf.disposed?
  761.      @opacity_text_buf.dispose
  762.    end
  763.    $game_temp.message_window_showing = false
  764.    if @input_number_window != nil
  765.      @input_number_window.dispose
  766.    end
  767.    super
  768. end
  769. #--------------------------------------------------------------------------
  770. # ● 矩形更新
  771. #--------------------------------------------------------------------------
  772. def update_cursor_rect
  773.    if @index >= 0
  774.      n = $game_temp.choice_start + @index
  775.      self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  776.    else
  777.      self.cursor_rect.empty
  778.    end
  779. end
  780. end
  781. #==============================================================================
  782. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  783. #==============================================================================
  784. class Window_Frame < Window_Base
  785. #--------------------------------------------------------------------------
  786. # ● オブジェクト初期化
  787. #--------------------------------------------------------------------------
  788. def initialize(x, y, width, height)
  789.    super(x, y, width, height)
  790.    self.contents = nil
  791.    self.back_opacity = 100
  792. end
  793. #--------------------------------------------------------------------------
  794. # ● 解放
  795. #--------------------------------------------------------------------------
  796. def dispose
  797.    super
  798.    end
  799. end
  800. #==============================================================================
  801. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  802. #==============================================================================
  803. class Air_Text < Window_Base
  804. #--------------------------------------------------------------------------
  805. # ● オブジェクト初期化
  806. #--------------------------------------------------------------------------
  807. def initialize(x, y, designate_text)
  808.    super(x-16, y-16, 32 + designate_text.size * 12, 56)
  809.    self.opacity = 0
  810.    self.back_opacity = 0
  811.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  812.    w = self.contents.width
  813.    h = self.contents.height
  814.    self.contents.draw_text(0, 0, w, h, designate_text)
  815. end
  816. #--------------------------------------------------------------------------
  817. # ● 解放
  818. #--------------------------------------------------------------------------
  819. def dispose
  820.    self.contents.clear
  821.    super
  822. end
  823. end



  824. #==============================================================================
  825. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  826. #==============================================================================
复制代码
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
5
发表于 2011-7-22 21:23:50 | 只看该作者
请使用\style[号码]
另外附加\font[字体]和\size[字体大小]
module Style 下面进行设置
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. #——说明

  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7.    
  8. #默认对话字没有声音,如果需要声音,
  9. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  10. #我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  11. # 其他在对话中可以使用的功能:

  12. # \n[1]:显示1号角色的姓名

  13. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

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

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

  18. # \c[1-8]:更改颜色

  19. # \g:显示金钱窗口

  20. # \a[SE文件名]:对话的时候播放SE

  21. # \s[1-19]:更改弹字的速度

  22. # \.   :停顿一刹那(1、2帧)
  23. # \|   :停顿片刻(20帧)

  24. # \>   :文字不用打字方式
  25. # \<   :文字使用打字方式

  26. # \!   :等待玩家按回车再继续
  27. # \~   :文字直接消失

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

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

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

  31. # \b[50]:空50象素

  32. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

  33. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  34. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”

  35. # \Lk:清除左边的图像
  36. # \Rk:清除右边的图像
  37. # \M[60]:等待60帧文字直接消失

  38. #脚本冲突可能:
  39. #不用说了。因为改了分辨率所有原有窗口需要自己定义,基本上可以算是和所有脚本冲突。
  40. module Style
  41.   Font = []
  42.   Size = []
  43.   Color = []
  44.   
  45.   Font[1] = "微软雅黑"
  46.   Color[1] = ::Color.new(128,128,128)
  47.   Size[1] = 24
  48.   
  49. end
  50. #============================
  51. class Game_System
  52. attr_accessor :typing
  53. attr_accessor :soundname_on_speak
  54. alias carol3_ini initialize
  55. def initialize
  56.    carol3_ini
  57.    @typing = true
  58.    @soundname_on_speak = nil
  59. end
  60. end
  61. #=================================
  62. #==============================================================================
  63. # ■ Window_Message
  64. #------------------------------------------------------------------------------
  65. class Window_Message < Window_Selectable
  66. #--------------------------------------------------------------------------
  67. # ● 初始化状态
  68. #--------------------------------------------------------------------------
  69. def initialize
  70.    super(80, 304, 480, 160)
  71.    self.contents = Bitmap.new(width - 32, height - 32)
  72.    self.visible = false
  73.    self.z = 9998
  74.    @fade_in = false
  75.    @fade_out = false
  76.    @contents_showing = false
  77.    @cursor_width = 0
  78.    @autoclosetime = -1
  79.    self.active = false
  80.    self.index = -1
  81.    if $game_system.soundname_on_speak == nil then
  82.      $game_system.soundname_on_speak = ""
  83.    end
  84.    @opacity_text_buf = Bitmap.new(32, 32)
  85. end
  86. #--------------------------------------------------------------------------
  87. # ● 释放
  88. #--------------------------------------------------------------------------
  89. def dispose
  90.    terminate_message
  91.    $game_temp.message_window_showing = false
  92.    if @input_number_window != nil
  93.      @input_number_window.dispose
  94.    end
  95.    super
  96. end
  97. #--------------------------------------------------------------------------
  98. # ● 处理信息结束
  99. #--------------------------------------------------------------------------
  100. def terminate_message
  101.    self.active = false
  102.    self.pause = false
  103.    self.index = -1
  104.    self.contents.clear
  105.    # 清除显示中标志
  106.    @contents_showing = false
  107.    # 呼叫信息调用
  108.    if $game_temp.message_proc != nil
  109.      $game_temp.message_proc.call
  110.    end
  111.    # 清除文章、选择项、输入数值的相关变量
  112.    $game_temp.message_text = nil
  113.    $game_temp.message_proc = nil
  114.    $game_temp.choice_start = 99
  115.    $game_temp.choice_max = 0
  116.    $game_temp.choice_cancel_type = 0
  117.    $game_temp.choice_proc = nil
  118.    $game_temp.num_input_start = 99
  119.    $game_temp.num_input_variable_id = 0
  120.    $game_temp.num_input_digits_max = 0
  121.    # 开放金钱窗口
  122.    if @gold_window != nil
  123.      @gold_window.dispose
  124.      @gold_window = nil
  125.    end
  126.    if @name_window_frame != nil
  127.      @name_window_frame.dispose
  128.      @name_window_frame = nil
  129.    end
  130.    if @name_window_text != nil
  131.      @name_window_text.dispose
  132.      @name_window_text = nil
  133.    end
  134.    if @right_picture != nil and @right_keep == true
  135.      @right_picture.dispose
  136.    end   
  137.    if @left_picture != nil and @left_keep == true
  138.      @left_picture.dispose
  139.    end
  140. end
  141. def refresh
  142.    # 初期化
  143.    self.contents.clear
  144.    self.contents.font.color = normal_color
  145.    self.contents.font.size = Font.default_size
  146.    @x = @y = @max_x = @max_y = @indent = @lines = 0
  147.    @left_keep = @right_keep = false
  148.    @face_indent = 0
  149.    @opacity = 255
  150.    @cursor_width = 0
  151.    @autoclosetime = -1
  152.    @write_speed = 0
  153.    @write_wait = 0
  154.    @mid_stop = false
  155.    @face_file = nil
  156.    @popchar = -2
  157.    if $game_temp.choice_start == 0
  158.      @x = 8
  159.    end
  160.    if $game_temp.message_text != nil
  161.      @now_text = $game_temp.message_text
  162.      #——头像设置
  163.      if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  164.        @face_file = $1 + ".png"
  165.        @x = @face_indent = 128
  166.        if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  167.          self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  168.        end
  169.        @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  170.      end
  171.      #——左半身像设置
  172.      if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  173.        @face = "66rpg_" + $1 + "_h.png"
  174.        if $加密 == true
  175.          if @left_picture != nil
  176.            @left_picture.dispose
  177.          end
  178.          @left_picture = Sprite.new
  179.          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  180.          @left_picture.y = 480-@left_picture.bitmap.height
  181.          @left_picture.x = 0
  182.          @left_picture.mirror = true
  183.          @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  184.        else         
  185.          if FileTest.exist?("Graphics/battlers/#{@face}")
  186.            if @left_picture != nil
  187.              @left_picture.dispose
  188.            end
  189.            @left_picture = Sprite.new
  190.            @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  191.            @left_picture.y = 480-@left_picture.bitmap.height
  192.            @left_picture.x = 0
  193.            @left_picture.mirror = true
  194.            @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  195.          end
  196.        end      
  197.      end
  198.      #——右半身像设置
  199.      if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  200.        @face = "66rpg_" + $1 + "_h.png"
  201.        if $加密 == true
  202.          if @right_picture != nil
  203.            @right_picture.dispose
  204.          end
  205.          @right_picture = Sprite.new
  206.          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  207.          @right_picture.y = 480-@right_picture.bitmap.height
  208.          @right_picture.x = 640-@right_picture.bitmap.width
  209.          @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  210.        else
  211.          if FileTest.exist?("Graphics/battlers/#{@face}")
  212.            if @right_picture != nil
  213.              @right_picture.dispose
  214.            end
  215.            @right_picture = Sprite.new
  216.            @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  217.            @right_picture.y = 480-@right_picture.bitmap.height
  218.            @right_picture.x = 640-@right_picture.bitmap.width
  219.            @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  220.          end
  221.        end
  222.      end
  223.      if (/\\[Rr]k/.match(@now_text)) != nil
  224.        @right_keep = true
  225.        @now_text.sub!(/\\[Rr]k/) { "" }
  226.      end
  227.      if (/\\[Ll]k/.match(@now_text)) != nil
  228.        @left_keep = true
  229.        @now_text.sub!(/\\[Ll]k/) { "" }
  230.      end
  231.      # 显示人物姓名
  232.      name_window_set = false
  233.      if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  234.        name_window_set = true
  235.        name_text = $1
  236.        @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  237.      end
  238.    
  239.      # 文字位置的判定
  240.      if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  241.        @popchar = $1.to_i
  242.        if @popchar == -1
  243.          @x = @indent = 48
  244.          @y = 4
  245.        end
  246.        @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  247.      end
  248.    
  249.      # 开始
  250.      begin
  251.        last_text = @now_text.clone
  252.        @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  253.      end until @now_text == last_text
  254.      @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  255.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  256.    end
  257.    @now_text.gsub!(/\\\\/) { "\000" }
  258.    @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  259.    @now_text.gsub!(/\\[Gg]/) { "\002" }
  260.    @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  261.    @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  262.    @now_text.gsub!(/\\[.]/) { "\005" }
  263.    @now_text.gsub!(/\\[|]/) { "\006" }
  264.    @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  265.   
  266.    @now_text.gsub!(/\\[>]/) { "\016" }
  267.    @now_text.gsub!(/\\[<]/) { "\017" }
  268.    @now_text.gsub!(/\\[!]/) { "\020" }
  269.    @now_text.gsub!(/\\[~]/) { "\021" }
  270.   
  271.    @now_text.gsub!(/\\[Ii]/) { "\023" }
  272.    @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  273.    @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  274.    @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  275.    @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  276.    @now_text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\051[#{$1}]" }
  277.    @now_text.gsub!(/\\[Ss][Tt][Yy][Ll][Ee]\[([0-9]+)\]/) { "\052[#{$1}]" }
  278.    @now_text.gsub!(/\\[Ss][Ii][Zz][Ee]\[([0-9]+)\]/) { "\053[#{$1}]" }
  279.    if @popchar >= 0
  280.      @text_save = @now_text.clone
  281.      @max_x = 0
  282.      @max_y = 4
  283.      for i in 0..3
  284.        line = @now_text.split(/\n/)[3-i]
  285.        @max_y -= 1 if line == nil and @max_y <= 4-i
  286.        next if line == nil
  287.        cx = contents.text_size(line).width
  288.        @max_x = cx if cx > @max_x
  289.      end
  290.      self.width = @max_x + 48 + @face_indent
  291.      self.height = (@max_y - 1) * 32 + 64
  292.    else
  293.      @max_x = self.width - 32 - @face_indent
  294.    end
  295.    reset_window
  296.      if name_window_set
  297.        off_x = 0
  298.        off_y = -40
  299.        space = 2
  300.        x = self.x + off_x - space / 2
  301.        y = self.y + off_y - space / 2
  302.        w = self.contents.text_size(name_text).width + 26 + space
  303.        h = 40 + space
  304.        @name_window_frame = Window_Frame.new(x, y, w, h)
  305.        @name_window_frame.z = self.z + 1
  306.        x = self.x + off_x + 4
  307.        y = self.y + off_y
  308.        @name_window_text = Air_Text.new(x+4, y+6, name_text)
  309.        @name_window_text.z = self.z + 2
  310.      end
  311.    end
  312.    reset_window
  313.    if $game_temp.choice_max > 0
  314.      @item_max = $game_temp.choice_max
  315.      self.active = true
  316.      self.index = 0
  317.    end
  318.    if $game_temp.num_input_variable_id > 0
  319.      digits_max = $game_temp.num_input_digits_max
  320.      number = $game_variables[$game_temp.num_input_variable_id]
  321.      @input_number_window = Window_InputNumber.new(digits_max)
  322.      @input_number_window.number = number
  323.      @input_number_window.x = self.x + 8
  324.      @input_number_window.y = self.y + $game_temp.num_input_start * 32
  325.    end
  326. end
  327. #--------------------------------------------------------------------------
  328. # ● 更新
  329. #--------------------------------------------------------------------------
  330. def update
  331.    super
  332.    if @autoclosetime == 0
  333.      @autoclosetime = -1
  334.      terminate_message
  335.   end
  336.    if @autoclosetime >= 1
  337.      @autoclosetime -= 1
  338.    end
  339.    if @fade_in
  340.      self.contents_opacity += 24
  341.      if @input_number_window != nil
  342.        @input_number_window.contents_opacity += 24
  343.      end
  344.      if self.contents_opacity == 255
  345.        @fade_in = false
  346.      end
  347.      return
  348.    end
  349.    @now_text = nil if @now_text == ""
  350.   
  351.    if @now_text != nil and @mid_stop == false
  352.      if @write_wait > 0
  353.        @write_wait -= 1
  354.        return
  355.      end
  356.      text_not_skip = $game_system.typing
  357.      while true
  358.        @max_x = @x if @max_x < @x
  359.        @max_y = @y if @max_y < @y
  360.        if (c = @now_text.slice!(/./m)) != nil
  361.          if c == "\000"
  362.            c = "\\"
  363.          end
  364.          if c == "\001"
  365.            @now_text.sub!(/\[([0-9]+)\]/, "")
  366.            color = $1.to_i
  367.            if color >= 0 and color <= 7
  368.              self.contents.font.color = text_color(color)
  369.            end
  370.            c = ""
  371.          end
  372.          if c == "\002"
  373.            if @gold_window == nil and @popchar <= 0
  374.              @gold_window = Window_Gold.new
  375.              @gold_window.x = 560 - @gold_window.width
  376.              if $game_temp.in_battle
  377.                @gold_window.y = 192
  378.              else
  379.                @gold_window.y = self.y >= 128 ? 32 : 384
  380.              end
  381.              @gold_window.opacity = self.opacity
  382.              @gold_window.back_opacity = self.back_opacity
  383.            end
  384.            c = ""
  385.          end
  386.          if c == "\003"
  387.            @now_text.sub!(/\[([0-9]+)\]/, "")
  388.            speed = $1.to_i
  389.            if speed >= 0 and speed <= 19
  390.              @write_speed = speed
  391.            end
  392.            c = ""
  393.          end
  394.          if c == "\004"
  395.            @now_text.sub!(/\[(.*?)\]/, "")
  396.            buftxt = $1.dup.to_s
  397.            if buftxt.match(/\//) == nil and buftxt != "" then
  398.              $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  399.            else
  400.              $game_system.soundname_on_speak = buftxt.dup
  401.            end
  402.            c = ""
  403.          elsif c == "\004"
  404.            c = ""
  405.          end
  406.          if c == "\005"
  407.            @write_wait += 5
  408.            c = ""
  409.          end
  410.          if c == "\006"
  411.            @write_wait += 20
  412.            c = ""
  413.          end
  414.          if c == "\016"
  415.            text_not_skip = false
  416.            c = ""
  417.          end
  418.          if c == "\017"
  419.            text_not_skip = true
  420.            c = ""
  421.          end
  422.          if c == "\020"
  423.            @mid_stop = true
  424.            c = ""
  425.          end
  426.          if c == "\021"
  427.            terminate_message
  428.            return
  429.          end
  430.          if c == "\023"
  431.            @indent = @x
  432.            c = ""
  433.          end
  434.          if c == "\024"
  435.            @now_text.sub!(/\[([0-9]+)\]/, "")
  436.            @opacity = $1.to_i
  437.            c = ""
  438.          end
  439.          if c == "\025"
  440.            @now_text.sub!(/\[([0-9]+)\]/, "")
  441.            self.contents.font.size = [[$1.to_i, 6].max, 32].min
  442.            c = ""
  443.          end
  444.          if c == "\026"
  445.            @now_text.sub!(/\[([0-9]+)\]/, "")
  446.            @x += $1.to_i
  447.            c = ""
  448.          end
  449.          if c == "\027"
  450.            @now_text.sub!(/\[(.*?)\]/, "")
  451.            @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  452.            if $game_system.soundname_on_speak != ""
  453.              Audio.se_play($game_system.soundname_on_speak)
  454.            end
  455.            c = ""
  456.          end
  457.          if c == "\030"
  458.            @now_text.sub!(/\[(.*?)\]/, "")
  459.            self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  460.           if $game_system.soundname_on_speak != ""
  461.              Audio.se_play($game_system.soundname_on_speak)
  462.            end
  463.            @x += 24
  464.            c = ""
  465.          end
  466.          if c == "\050"

  467.          @now_text.sub!(/\[([0-9]+)\]/, "")

  468.          @autoclosetime = $1.to_i

  469.          next

  470.          end
  471.          if c == "\051"
  472.            @now_text.sub!(/\[(.*?)\]/, "")
  473.            self.contents.font.name = $1
  474.            next
  475.          end
  476.          if c == "\052"
  477.            @now_text.sub!(/\[([0-9]+)\]/, "")
  478.            self.contents.font.name = Style::Font[$1.to_i]
  479.            self.contents.font.color = Style::Color[$1.to_i]
  480.            self.contents.font.size = Style::Size[$1.to_i]
  481.            next
  482.          end
  483.          if c == "\053"
  484.            @now_text.sub!(/\[([0-9]+)\]/, "")
  485.            self.contents.font.size = $1.to_i
  486.            next
  487.          end
  488.          if c == "\n"
  489.            if @lines >= $game_temp.choice_start
  490.              @cursor_width = [@cursor_width, @max_x - @face_indent].max
  491.            end
  492.            @lines += 1
  493.            @y += 1
  494.            @x = 0 + @indent + @face_indent
  495.            if @lines >= $game_temp.choice_start
  496.              @x = 8 + @indent + @face_indent
  497.            end
  498.            c = ""
  499.          end
  500.          if c != ""
  501.            # 文字描画
  502.            @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  503.            if $game_system.soundname_on_speak != "" then
  504.            Audio.se_play($game_system.soundname_on_speak)
  505.            end
  506.          end
  507.          if Input.press?(Input::B)
  508.            text_not_skip = false
  509.          end
  510.        else
  511.          text_not_skip = true
  512.          break
  513.        end
  514.        # 終了判定
  515.        if text_not_skip
  516.          break
  517.        end
  518.      end
  519.      @write_wait += @write_speed
  520.      return
  521.    end
  522.    if @input_number_window != nil
  523.      @input_number_window.update
  524.      # 決定
  525.      if Input.trigger?(Input::C)
  526.        $game_system.se_play($data_system.decision_se)
  527.        $game_variables[$game_temp.num_input_variable_id] =
  528.        @input_number_window.number
  529.        $game_map.need_refresh = true
  530.        @input_number_window.dispose
  531.        @input_number_window = nil
  532.        terminate_message
  533.      end
  534.      return
  535.    end
  536.    if @contents_showing
  537.      if $game_temp.choice_max == 0
  538.        self.pause = true
  539.      end
  540.      # 取消
  541.      if Input.trigger?(Input::B)
  542.        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  543.          $game_system.se_play($data_system.cancel_se)
  544.          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  545.          terminate_message
  546.        end
  547.      end
  548.      # 決定
  549.      if Input.trigger?(Input::C)
  550.        if $game_temp.choice_max > 0
  551.          $game_system.se_play($data_system.decision_se)
  552.          $game_temp.choice_proc.call(self.index)
  553.        end
  554.        if @mid_stop
  555.          @mid_stop = false
  556.          return
  557.        else
  558.          terminate_message
  559.        end
  560.      end
  561.      return
  562.    end
  563.    if @fade_out == false and $game_temp.message_text != nil
  564.      @contents_showing = true
  565.      $game_temp.message_window_showing = true
  566.      refresh
  567.      Graphics.frame_reset
  568.      self.visible = true
  569.      self.contents_opacity = 0
  570.    if @input_number_window != nil
  571.      @input_number_window.contents_opacity = 0
  572.    end
  573.      @fade_in = true
  574.      return
  575.    end
  576.    if self.visible
  577.      @fade_out = true
  578.      self.opacity -= 48
  579.      if self.opacity == 0
  580.        self.visible = false
  581.        @fade_out = false
  582.        $game_temp.message_window_showing = false
  583.      end
  584.      return
  585.    end
  586. end
  587. #--------------------------------------------------------------------------
  588. # ● 获得字符
  589. #--------------------------------------------------------------------------
  590. def get_character(parameter)
  591.    case parameter
  592.    when 0
  593.      return $game_player
  594.    else
  595.      events = $game_map.events
  596.      return events == nil ? nil : events[parameter]
  597.    end
  598. end
  599. #--------------------------------------------------------------------------
  600. # ● ウィンドウの位置と不透明度の設定
  601. #--------------------------------------------------------------------------
  602. def reset_window
  603.    # 判定
  604.    if @popchar >= 0
  605.      events = $game_map.events
  606.      if events != nil
  607.        character = get_character(@popchar)
  608.        x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  609.        y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  610.        self.x = x
  611.        self.y = y
  612.      end
  613.    elsif @popchar == -1
  614.      self.x = -4
  615.      self.y = -4
  616.      self.width = 648
  617.      self.height = 488
  618.    else
  619.      if $game_temp.in_battle
  620.        self.y = 16
  621.      else
  622.        case $game_system.message_position
  623.        when 0 # 上
  624.          self.y = 16
  625.        when 1 # 中
  626.          self.y = 160
  627.        when 2 # 下
  628.          self.y = 304
  629.        end
  630.        self.x = 80
  631.        if @face_file == nil
  632.          self.width = 480
  633.        else
  634.          self.width = 600
  635.          self.x -= 60
  636.        end
  637.        self.height = 160
  638.      end
  639.    end
  640.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  641.    if @face_file != nil
  642.      self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  643.    end
  644.    if @popchar == -1
  645.      self.opacity = 255
  646.      self.back_opacity = 0
  647.    elsif $game_system.message_frame == 0
  648.      self.opacity = 255
  649.      self.back_opacity = 100
  650.    else
  651.      self.opacity = 0
  652.      self.back_opacity = 100
  653.    end
  654. end
  655. #--------------------------------------------------------------------------
  656. # ● line_height
  657. #--------------------------------------------------------------------------
  658. # 返回値:行高
  659. #--------------------------------------------------------------------------
  660. def line_height
  661.    return 32
  662.    if self.contents.font.size >= 20 and self.contents.font.size <= 24
  663.      return 32
  664.    else
  665.      return self.contents.font.size * 15 / 10
  666.    end
  667. end
  668. #--------------------------------------------------------------------------
  669. # ● 透過文字描画
  670. #--------------------------------------------------------------------------
  671. # target :描画対象。Bitmapクラスを指定。
  672. # x :x座標
  673. # y :y座標
  674. # str  :描画文字列
  675. # opacity:透過率(0~255)
  676. # 返回値 :文字幅(@x増加値)。
  677. #--------------------------------------------------------------------------
  678. def opacity_draw_text(target, x, y, str,opacity)
  679.    height = target.font.size
  680.    width = target.text_size(str).width
  681.    opacity = [[opacity, 0].max, 255].min
  682.    if opacity == 255
  683.      target.draw_text(x, y, width, height, str)
  684.      return width
  685.    else
  686.      if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  687.        @opacity_text_buf.dispose
  688.        @opacity_text_buf = Bitmap.new(width, height)
  689.      else
  690.        @opacity_text_buf.clear
  691.      end
  692.      @opacity_text_buf.font.size = target.font.size
  693.      @opacity_text_buf.draw_text(0, 0, width, height, str)
  694.      target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  695.    return width
  696.    end
  697. end
  698. def ruby_draw_text(target, x, y, str,opacity)
  699.    sizeback = target.font.size
  700.    target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  701.    rubysize = [rubysize, 6].max
  702.   
  703.    opacity = [[opacity, 0].max, 255].min
  704.    split_s = str.split(/,/)
  705.   
  706.    split_s[0] == nil ? split_s[0] = "" : nil
  707.    split_s[1] == nil ? split_s[1] = "" : nil
  708.   
  709.    height = sizeback + rubysize
  710.    width = target.text_size(split_s[0]).width
  711.   
  712.    target.font.size = rubysize
  713.    ruby_width = target.text_size(split_s[1]).width
  714.    target.font.size = sizeback
  715.   
  716.    buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  717.   
  718.    width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  719.   
  720.    if opacity == 255
  721.      target.font.size = rubysize
  722.      target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  723.      target.font.size = sizeback
  724.      target.draw_text(x, y, width, target.font.size, split_s[0])
  725.      return width
  726.    else
  727.      if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  728.        @opacity_text_buf.dispose
  729.        @opacity_text_buf = Bitmap.new(buf_width, height)
  730.      else
  731.        @opacity_text_buf.clear
  732.      end
  733.      @opacity_text_buf.font.size = rubysize
  734.      @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  735.      @opacity_text_buf.font.size = sizeback
  736.      @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  737.      if sub_x >= 0
  738.        target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  739.      else
  740.        target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  741.      end
  742.      return width
  743.    end
  744. end
  745. #--------------------------------------------------------------------------
  746. # ● \V 变换
  747. #--------------------------------------------------------------------------
  748. def convart_value(option, index)
  749.    option == nil ? option = "" : nil
  750.    option.downcase!
  751.    case option
  752.      when "i"
  753.        unless $data_items[index].name == nil
  754.          r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  755.        end
  756.      when "w"
  757.        unless $data_weapons[index].name == nil
  758.          r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  759.        end
  760.      when "a"
  761.        unless $data_armors[index].name == nil
  762.          r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  763.        end
  764.      when "s"
  765.        unless $data_skills[index].name == nil
  766.          r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  767.        end
  768.      else
  769.      r = $game_variables[index]
  770.    end
  771.    r == nil ? r = "" : nil
  772.    return r
  773. end
  774. #--------------------------------------------------------------------------
  775. # ● 解放
  776. #--------------------------------------------------------------------------
  777. def dispose
  778.    terminate_message
  779.    if @gaiji_cache != nil
  780.      unless @gaiji_cache.disposed?
  781.        @gaiji_cache.dispose
  782.      end
  783.    end
  784.    unless @opacity_text_buf.disposed?
  785.      @opacity_text_buf.dispose
  786.    end
  787.    $game_temp.message_window_showing = false
  788.    if @input_number_window != nil
  789.      @input_number_window.dispose
  790.    end
  791.    super
  792. end
  793. #--------------------------------------------------------------------------
  794. # ● 矩形更新
  795. #--------------------------------------------------------------------------
  796. def update_cursor_rect
  797.    if @index >= 0
  798.      n = $game_temp.choice_start + @index
  799.      self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  800.    else
  801.      self.cursor_rect.empty
  802.    end
  803. end
  804. end
  805. #==============================================================================
  806. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  807. #==============================================================================
  808. class Window_Frame < Window_Base
  809. #--------------------------------------------------------------------------
  810. # ● オブジェクト初期化
  811. #--------------------------------------------------------------------------
  812. def initialize(x, y, width, height)
  813.    super(x, y, width, height)
  814.    self.contents = nil
  815.    self.back_opacity = 100
  816. end
  817. #--------------------------------------------------------------------------
  818. # ● 解放
  819. #--------------------------------------------------------------------------
  820. def dispose
  821.    super
  822.    end
  823. end
  824. #==============================================================================
  825. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  826. #==============================================================================
  827. class Air_Text < Window_Base
  828. #--------------------------------------------------------------------------
  829. # ● オブジェクト初期化
  830. #--------------------------------------------------------------------------
  831. def initialize(x, y, designate_text)
  832.    super(x-16, y-16, 32 + designate_text.size * 12, 56)
  833.    self.opacity = 0
  834.    self.back_opacity = 0
  835.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  836.    w = self.contents.width
  837.    h = self.contents.height
  838.    self.contents.draw_text(0, 0, w, h, designate_text)
  839. end
  840. #--------------------------------------------------------------------------
  841. # ● 解放
  842. #--------------------------------------------------------------------------
  843. def dispose
  844.    self.contents.clear
  845.    super
  846. end
  847. end



  848. #==============================================================================
  849. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  850. #==============================================================================
复制代码

点评

可以了耶,太感动了,同时太感激您了~~  发表于 2011-7-22 22:06
本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 15:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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