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

Project1

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

[已经解决] 对话脚本求助

 关闭 [复制链接]

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
跳转到指定楼层
1
发表于 2011-8-30 19:13:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下面的脚本只要改成对话框里不透明就可以了,固定的,所有对话框都不透明
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————
  4. #——说明
  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7. # 其他在对话中可以使用的功能:

  8. # \n[1]:显示1号角色的姓名
  9. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  10. # \name[\n[1]]:显示1号主角的姓名方框
  11. # \p[1]:对话框出现在1号事件的上方
  12. # \p[0]:主人公上方出现对话框
  13. #——————————————————使用\p功能后可以自动调整对话框大小
  14. # \>   :文字不用打字方式
  15. # \<   :文字使用打字方式
  16. # \\:显示"\"这个符号
  17. # \g:显示金钱窗口
  18. # \t: 显示游戏时间窗口
  19. # \v[7]:显示7号变量的值
  20. # \v[a7]:显示7号防具的名称
  21. # \v[s7]:显示7号特技的名称
  22. # \v[w7]:显示7号武器的名称
  23. # \v[i7]:显示7号道具的名称
  24. # \I   :下一行从这个位置开始
  25. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  26. # \h[12]:改用12号字
  27. # \b[50]:空50象素
  28. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  29. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  30. # \Lk:清除左边的图像
  31. # \Rk:清除右边的图像
  32. # \A:头像及姓名框靠左排列
  33. # \a:头像及姓名框靠右排列
  34. # \M[60]:等待60帧文字直接消失
  35. #颜色自定义设定范围0-255
  36. #使用方法:在文章前输入如下脚本定义颜色
  37. #          $color0 = 数值
  38. #          $color1 = 数值
  39. #          $color2 = 数值
  40. #\name参数的颜色自定义设定范围0-255
  41. #使用方法:在文章前输入如下脚本定义颜色
  42. #          $ncolor0 = 数值
  43. #          $ncolor1 = 数值
  44. #          $ncolor2 = 数值
  45. # \!   :等待玩家按回车再继续
  46. #$speed :文字的打字速度设置用的,数字越大速度越慢。

  47. #============================
  48. class Game_System
  49. attr_accessor :typing
  50. alias carol3_ini initialize
  51. def initialize
  52. carol3_ini
  53. @typing = true
  54. end
  55. end
  56. #=================================#==============================================================================
  57. # ■ Window_Message
  58. #------------------------------------------------------------------------------
  59. class Window_Message < Window_Selectable
  60. #颜色自定义用的全局变量定义
  61. $color0 = 255
  62. $color1 = 255
  63. $color2 = 255
  64. #颜色自定义用的全局变量定义

  65. #说话速度设置用的全局变量

  66. $speed = 3

  67. #--------------------------------------------------------------------------
  68. # ● 初始化状态
  69. #--------------------------------------------------------------------------
  70. def initialize
  71. super(80, 304, 480, 160)
  72. self.contents = Bitmap.new(width - 32, height - 32)
  73. self.visible = false
  74. self.z = 9998
  75. @fade_in = false
  76. @fade_out = false
  77. @contents_showing = false
  78. @cursor_width = 0
  79. @autoclosetime = -1
  80. self.active = false
  81. self.index = -1
  82. @opacity_text_buf = Bitmap.new(32, 32)
  83. end
  84. #--------------------------------------------------------------------------
  85. # ● 释放
  86. #--------------------------------------------------------------------------
  87. def dispose
  88. terminate_message
  89. $game_temp.message_window_showing = false
  90. if @input_number_window != nil
  91.    @input_number_window.dispose
  92. end
  93. super
  94. end
  95. #--------------------------------------------------------------------------
  96. # ● 处理信息结束
  97. #--------------------------------------------------------------------------
  98. def terminate_message
  99. self.active = false
  100. self.pause = false
  101. self.index = -1
  102. self.contents.clear
  103. # 清除显示中标志
  104. @contents_showing = false
  105. # 呼叫信息调用
  106. if $game_temp.message_proc != nil
  107.    $game_temp.message_proc.call
  108. end
  109. # 清除文章、选择项、输入数值的相关变量
  110. $game_temp.message_text = nil
  111. $game_temp.message_proc = nil
  112. $game_temp.choice_start = 99
  113. $game_temp.choice_max = 0
  114. $game_temp.choice_cancel_type = 0
  115. $game_temp.choice_proc = nil
  116. $game_temp.num_input_start = 99
  117. $game_temp.num_input_variable_id = 0
  118. $game_temp.num_input_digits_max = 0
  119. # 开放金钱窗口
  120. if @gold_window != nil
  121.    @gold_window.dispose
  122.    @gold_window = nil
  123. end
  124. # 开放时间窗口
  125. if @playtime_window != nil
  126.    @playtime_window.dispose
  127.    @playtime_window = nil
  128. end
  129. if @name_window_frame != nil
  130.    @name_window_frame.dispose
  131.    @name_window_frame = nil
  132. end
  133. if @name_window_text != nil
  134.    @name_window_text.dispose
  135.    @name_window_text = nil
  136. end
  137. if @right_picture != nil and @right_keep == true
  138.    @right_picture.dispose
  139. end   
  140. if @left_picture != nil and @left_keep == true
  141.    @left_picture.dispose
  142. end
  143. @face_bitmap = nil
  144. end
  145. def refresh
  146. # 初期化
  147. self.contents.clear
  148. self.contents.font.color = normal_color
  149. self.contents.font.size = Font.default_size
  150. @x = @y = @max_x = @max_y = @indent = @lines = 0
  151. @left_keep = @right_keep = false
  152. @face_indent = 0
  153. @opacity = 255
  154. @cursor_width = 0
  155. @autoclosetime = -1
  156. @write_speed = $speed
  157. @write_wait = 0
  158. @mid_stop = false
  159. face = nil
  160. @popchar = -2
  161. @alignment = true
  162. if $game_temp.choice_start == 0
  163.    @x = 8
  164. end
  165. if $game_temp.message_text != nil
  166.    @now_text = $game_temp.message_text
  167.    #——对齐设置
  168.    if (/\\([Aa])/.match(@now_text))!=nil then
  169.      if $1 == "A"
  170.        @alignment = true
  171.      else
  172.        @alignment = false
  173.      end
  174.      @now_text.gsub!(/\\([Aa])/) { "" }
  175.    end
  176.    #——头像设置
  177.     if (/\\([Ff])\[(.+?)\]/.match(@now_text))!=nil then
  178.       @face = $2 + "_f.png"
  179.       if $1 == "f" and $game_actors[$2.to_i] != nil
  180.         face = $game_actors[$2.to_i].battler_name + "_f.png"
  181.       end
  182.       if FileTest.exist?("Graphics/Pictures/#{face}")
  183.         @face_bitmap = Bitmap.new("Graphics/Pictures/#{face}")
  184.         if @alignment
  185.           @x = @face_indent = 128
  186.           self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  187.         else
  188.           self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  189.             Rect.new(0, 0, 96, 96))
  190.         end
  191.       else
  192.         face = nil
  193.         @face_bitmap = nil
  194.       end
  195.       @now_text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
  196.     end
  197.    #——左半身像设置
  198.    if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  199.      @face = "66rpg_" + $1 + "_h.png"
  200.      if $加密 == true
  201.        if @left_picture != nil
  202.          @left_picture.dispose
  203.        end
  204.        @left_picture = Sprite.new
  205.        @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  206.        @left_picture.y = 480-@left_picture.bitmap.height
  207.        @left_picture.x = 0
  208.        @left_picture.mirror = true
  209.        @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  210.      else         
  211.        if FileTest.exist?("Graphics/battlers/#{@face}")
  212.          if @left_picture != nil
  213.            @left_picture.dispose
  214.          end
  215.          @left_picture = Sprite.new
  216.          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  217.          @left_picture.y = 480-@left_picture.bitmap.height
  218.          @left_picture.x = 0
  219.          @left_picture.mirror = true
  220.          @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  221.        end
  222.      end        
  223.    end
  224.    #——右半身像设置
  225.    if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  226.      @face = "66rpg_" + $1 + "_h.png"
  227.      if $加密 == true
  228.        if @right_picture != nil
  229.          @right_picture.dispose
  230.        end
  231.        @right_picture = Sprite.new
  232.        @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  233.        @right_picture.y = 480-@right_picture.bitmap.height
  234.        @right_picture.x = 640-@right_picture.bitmap.width
  235.        @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  236.      else
  237.        if FileTest.exist?("Graphics/battlers/#{@face}")
  238.          if @right_picture != nil
  239.            @right_picture.dispose
  240.          end
  241.          @right_picture = Sprite.new
  242.          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  243.          @right_picture.y = 480-@right_picture.bitmap.height
  244.          @right_picture.x = 640-@right_picture.bitmap.width
  245.          @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  246.        end
  247.      end
  248.    end
  249.    if (/\\[Rr]k/.match(@now_text)) != nil
  250.      @right_keep = true
  251.      @now_text.sub!(/\\[Rr]k/) { "" }
  252.    end
  253.    if (/\\[Ll]k/.match(@now_text)) != nil
  254.      @left_keep = true
  255.      @now_text.sub!(/\\[Ll]k/) { "" }
  256.    end
  257.    # 替换人物姓名
  258.    @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  259.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  260.    end
  261.    # 显示人物姓名
  262.    name_window_set = false
  263.    if (/\\[Nn][Aa][Mm][Ee](.*?)\[(.+?)\]/.match(@now_text)) != nil
  264.      name_window_set = true
  265.      name_text = $2
  266.      @now_text.sub!(/\\[Nn][Aa][Mm][Ee](.*?)\[(.*?)\]/) { "" }
  267.    end
  268.    # 文字位置的判定
  269.    if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  270.      @popchar = $1.to_i
  271.      if @popchar == -1
  272.        @x = @indent = 48
  273.        @y = 4
  274.      end
  275.      @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  276.    end
  277.    
  278.    # 开始
  279.    begin
  280.      last_text = @now_text.clone
  281.      @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  282.    end until @now_text == last_text
  283. @now_text.gsub!(/\\\\/) { "\000" }
  284. @now_text.gsub!(/\\[Gg]/) { "\002" }
  285. @now_text.gsub!(/\\[Tt]/) { "\004" }
  286. @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  287. @now_text.gsub!(/\\[Ii]/) { "\023" }
  288. @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  289. @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  290. @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  291. @now_text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
  292. @now_text.gsub!(/\\[!]/) { "\020" }
  293. @now_text.gsub!(/\\[>]/) { "\016" }
  294. @now_text.gsub!(/\\[<]/) { "\017" }


  295. if @popchar >= 0
  296.    @text_save = @now_text.clone
  297.    @max_x = 0
  298.    @max_y = 4
  299.    for i in 0..3
  300.      line = @now_text.split(/\n/)[3-i]
  301.      @max_y -= 1 if line == nil and @max_y <= 4-i
  302.      next if line == nil
  303.      cx = contents.text_size(line).width
  304.      @max_x = cx if cx > @max_x
  305.    end
  306.    self.width = @max_x + 48 + @face_indent
  307.    self.height = (@max_y - 1) * 32 + 64
  308. else
  309.    @max_x = self.width - 32 - @face_indent
  310. end
  311. reset_window
  312.    if name_window_set
  313.      off_x = 0
  314.      off_y = -40
  315.      space = 2
  316.      w = self.contents.text_size(name_text).width + 26 + space
  317.      x = @alignment ? self.x + off_x - space / 2 : self.x + off_x - space / 2 + self.width - w
  318.      y = self.y + off_y - space / 2
  319.      h = 40 + space
  320.      @name_window_frame = Window_Frame.new(x, y, w, h)
  321.      @name_window_frame.z = self.z + 1
  322.      x = @alignment ? self.x + off_x - space / 2 + 4 : self.x + off_x - space / 2 + 4 + self.width - w
  323.      y = self.y + off_y - space / 2
  324.      @name_window_text = Air_Text.new(x+4, y+6, name_text)
  325.      @name_window_text.z = self.z + 2
  326.    end
  327. end
  328. reset_window
  329. if $game_temp.choice_max > 0
  330.    @item_max = $game_temp.choice_max
  331.    self.active = true
  332.    self.index = 0
  333. end
  334. if $game_temp.num_input_variable_id > 0
  335.    digits_max = $game_temp.num_input_digits_max
  336.    number = $game_variables[$game_temp.num_input_variable_id]
  337.    @input_number_window = Window_InputNumber.new(digits_max)
  338.    @input_number_window.number = number
  339.    @input_number_window.x = self.x + 8
  340.    @input_number_window.y = self.y + $game_temp.num_input_start * 32
  341. end
  342. end
  343. #--------------------------------------------------------------------------
  344. # ● 更新
  345. #--------------------------------------------------------------------------
  346. def update
  347. super



  348.   #颜色自定义设定范围0-255
  349.   self.contents.font.color = Color.new($color0, $color1, $color2)
  350.   #颜色自定义设定范围0-255
  351.   
  352.   
  353.   
  354.    if @autoclosetime == 0
  355.    @autoclosetime = -1
  356.    terminate_message
  357. end
  358. if @autoclosetime >= 1
  359.    @autoclosetime -= 1
  360. end
  361. if @fade_in
  362.    self.contents_opacity += 24
  363.    if @input_number_window != nil
  364.      @input_number_window.contents_opacity += 24
  365.    end
  366.    if self.contents_opacity == 255
  367.      @fade_in = false
  368.    end
  369.    return
  370. end
  371. @now_text = nil if @now_text == ""
  372. if @now_text != nil and @mid_stop == false
  373.    if @write_wait > 0
  374.      @write_wait -= 1
  375.      return
  376.    end
  377.    while true
  378.      @max_x = @x if @max_x < @x
  379.      @max_y = @y if @max_y < @y
  380.      if (c = @now_text.slice!(/./m)) != nil
  381.        if c == "\000"
  382.          c = "\\"
  383.        end
  384.        if c == "\002"
  385.          if @gold_window == nil and @popchar <= 0
  386.            @gold_window = Window_Gold.new
  387.            @gold_window.x = 560 - @gold_window.width
  388.            if $game_temp.in_battle
  389.              @gold_window.y = 192
  390.            else
  391.              @gold_window.y = self.y >= 128 ? 32 : 384
  392.            end
  393.            @gold_window.opacity = self.opacity
  394.            @gold_window.back_opacity = self.back_opacity
  395.          end
  396.          c = ""
  397.        end
  398.      if c == "\004"
  399.        if @playtime_window == nil and @popchar <=0
  400.          @playtime_window = Window_PlayTime.new
  401.          @playtime_window.x = 80
  402.          if $game_temp.in_battle
  403.            @playtime_window.y = 192
  404.          else
  405.            @playtime_window.y = self.y >= 128 ? 32 : 384
  406.          end
  407.          @playtime_window.opacity = self.opacity
  408.          @playtime_window.back_opacity = self.back_opacity
  409.        end
  410.      end
  411.       if c == "\016"
  412.         $game_system.typing = false
  413.         c = ""
  414.       end
  415.       if c == "\017"
  416.         $game_system.typing = true
  417.         c = ""
  418.       end
  419.       if c == "\020"
  420.         @mid_stop = true
  421.         c = ""
  422.       end        
  423.        if c == "\023"
  424.          @indent = @x
  425.          c = ""
  426.        end
  427.        if c == "\024"
  428.          @now_text.sub!(/\[([0-9]+)\]/, "")
  429.          @opacity = $1.to_i
  430.          c = ""
  431.        end
  432.        if c == "\025"
  433.          @now_text.sub!(/\[([0-9]+)\]/, "")
  434.          self.contents.font.size = [[$1.to_i, 6].max, 32].min
  435.          c = ""
  436.        end
  437.        if c == "\026"
  438.          @now_text.sub!(/\[([0-9]+)\]/, "")
  439.          @x += $1.to_i
  440.          c = ""
  441.        end
  442.      if c == "\027"
  443.        @now_text.sub!(/\[([0-9]+)\]/, "")
  444.        @x += $1.to_i * self.contents.font.size / 2
  445.        next
  446.      end
  447.        if c == "\030"
  448.          @now_text.sub!(/\[(.*?)\]/, "")
  449.          self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  450.          @x += 24
  451.          c = ""
  452.        end
  453.        if c == "\050"
  454.        @now_text.sub!(/\[([0-9]+)\]/, "")
  455.        @autoclosetime = $1.to_i
  456.        next
  457.      end
  458.        if c == "\n"
  459.          if @lines >= $game_temp.choice_start
  460.            @cursor_width = [@cursor_width, @max_x - @face_indent].max
  461.          end
  462.          @lines += 1
  463.          @y += 1
  464.          @x = 0 + @indent + @face_indent
  465.          if @lines >= $game_temp.choice_start
  466.            @x = 8 + @indent + @face_indent
  467.          end
  468.          c = ""
  469.        end
  470.        if c != ""
  471.          # 文字描画
  472.          @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  473.        end
  474.        if Input.press?(Input::B)
  475.          $game_system.typing = false
  476.        end
  477.      else
  478.        $game_system.typing = true
  479.        break
  480.      end
  481.      # 終了判定
  482.      if $game_system.typing
  483.        break
  484.      end
  485.    end
  486.    @write_wait += @write_speed
  487.    return
  488. end
  489. if @input_number_window != nil
  490.    @input_number_window.update
  491.    # 決定
  492.    if Input.trigger?(Input::C)
  493.      $game_system.se_play($data_system.decision_se)
  494.      $game_variables[$game_temp.num_input_variable_id] =
  495.      @input_number_window.number
  496.      $game_map.need_refresh = true
  497.      @input_number_window.dispose
  498.      @input_number_window = nil
  499.      terminate_message
  500.    end
  501.    return
  502. end
  503. if @contents_showing
  504.    if $game_temp.choice_max == 0
  505.      self.pause = true
  506.    end
  507.    # 取消
  508.    if Input.trigger?(Input::B)
  509.      if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  510.        $game_system.se_play($data_system.cancel_se)
  511.        $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  512.        terminate_message
  513.      end
  514.    end
  515.    # 決定
  516.    if Input.trigger?(Input::C)
  517.      if $game_temp.choice_max > 0
  518.        $game_system.se_play($data_system.decision_se)
  519.        $game_temp.choice_proc.call(self.index)
  520.      end
  521.      if @mid_stop
  522.        @mid_stop = false
  523.        return
  524.      else
  525.        terminate_message
  526.      end
  527.    end
  528.    return
  529. end
  530. if @fade_out == false and $game_temp.message_text != nil
  531.    @contents_showing = true
  532.    $game_temp.message_window_showing = true
  533.    refresh
  534.    Graphics.frame_reset
  535.    self.visible = true
  536.    self.contents_opacity = 0
  537. if @input_number_window != nil
  538.    @input_number_window.contents_opacity = 0
  539. end
  540.    @fade_in = true
  541.    return
  542. end
  543. if self.visible
  544.    @fade_out = true
  545.    self.opacity -= 48
  546.    if self.opacity == 0
  547.      self.visible = false
  548.      @fade_out = false
  549.      $game_temp.message_window_showing = false
  550.    end
  551.    return
  552. end
  553. end
  554. #--------------------------------------------------------------------------
  555. # ● 获得字符
  556. #--------------------------------------------------------------------------
  557. def get_character(parameter)
  558. case parameter
  559. when 0
  560.    return $game_player
  561. else
  562.    events = $game_map.events
  563.    return events == nil ? nil : events[parameter]
  564. end
  565. end
  566. #--------------------------------------------------------------------------
  567. # ● ウィンドウの位置と不透明度の設定
  568. #--------------------------------------------------------------------------
  569. def reset_window
  570. # 判定
  571. if @popchar >= 0
  572.    events = $game_map.events
  573.    if events != nil
  574.      character = get_character(@popchar)
  575.      x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  576.      y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  577.      self.x = x
  578.      self.y = y
  579.    end
  580. elsif @popchar == -1
  581.    self.x = -4
  582.    self.y = -4
  583.    self.width = 648
  584.    self.height = 488
  585. else
  586.    if $game_temp.in_battle
  587.       self.y = 48
  588.    else
  589.      case $game_system.message_position
  590.      when 0 # 上
  591.        self.y = 16
  592.      when 1 # 中
  593.        self.y = 160
  594.      when 2 # 下
  595.        self.y = 304
  596.      end
  597.      self.x = 80
  598.       if @face_bitmap == nil
  599.         self.width = 480
  600.       else
  601.         self.width = 600
  602.         self.x -= 60
  603.       end
  604.       self.height = 160
  605.     end
  606.   end
  607. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  608.   if @face_bitmap != nil
  609.     if @alignment
  610.       self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  611.     else
  612.       self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  613.         Rect.new(0, 0, 96, 96))
  614.     end
  615.   end
  616.   if @popchar == -1
  617.    self.opacity = 255
  618.    self.back_opacity = 0
  619. elsif $game_system.message_frame == 0
  620.    self.opacity = 255
  621.    self.back_opacity = 100
  622. else
  623.    self.opacity = 0
  624.    self.back_opacity = 100
  625. end
  626. end
  627. #--------------------------------------------------------------------------
  628. # ● line_height
  629. #--------------------------------------------------------------------------
  630. # 返回値:行高
  631. #--------------------------------------------------------------------------
  632. def line_height
  633. return 32
  634. if self.contents.font.size >= 20 and self.contents.font.size <= 24
  635.    return 32
  636. else
  637.    return self.contents.font.size * 15 / 10
  638. end
  639. end
  640. #--------------------------------------------------------------------------
  641. # ● \V 变换
  642. #--------------------------------------------------------------------------
  643. def convart_value(option, index)
  644. option == nil ? option = "" : nil
  645. option.downcase!
  646. case option
  647.    when "i"
  648.      unless $data_items[index].name == nil
  649.        r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  650.      end
  651.    when "w"
  652.      unless $data_weapons[index].name == nil
  653.        r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  654.      end
  655.    when "a"
  656.      unless $data_armors[index].name == nil
  657.        r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  658.      end
  659.    when "s"
  660.      unless $data_skills[index].name == nil
  661.        r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  662.      end
  663.    else
  664.    r = $game_variables[index]
  665. end
  666. r == nil ? r = "" : nil
  667. return r
  668. end
  669. #--------------------------------------------------------------------------
  670. # ● 透過文字描画
  671. #--------------------------------------------------------------------------
  672. # target :描画対象。Bitmapクラスを指定。
  673. # x :x座標
  674. # y :y座標
  675. # str  :描画文字列
  676. # opacity:透過率(0~255)
  677. # 返回値 :文字幅(@x増加値)。
  678. #--------------------------------------------------------------------------
  679. def opacity_draw_text(target, x, y, str,opacity)
  680. height = target.font.size
  681. width = target.text_size(str).width
  682. opacity = [[opacity, 0].max, 255].min
  683. if opacity == 255
  684.    target.draw_text(x, y, width, height, str)
  685.    return width
  686. else
  687.    if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  688.      @opacity_text_buf.dispose
  689.      @opacity_text_buf = Bitmap.new(width, height)
  690.    else
  691.      @opacity_text_buf.clear
  692.    end
  693.    @opacity_text_buf.font.size = target.font.size
  694.    @opacity_text_buf.draw_text(0, 0, width, height, str)
  695.    target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  696. return width
  697. end
  698. end
  699. def ruby_draw_text(target, x, y, str,opacity)
  700. sizeback = target.font.size
  701. target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  702. rubysize = [rubysize, 6].max

  703. opacity = [[opacity, 0].max, 255].min
  704. split_s = str.split(/,/)

  705. split_s[0] == nil ? split_s[0] = "" : nil
  706. split_s[1] == nil ? split_s[1] = "" : nil

  707. height = sizeback + rubysize
  708. width = target.text_size(split_s[0]).width

  709. target.font.size = rubysize
  710. ruby_width = target.text_size(split_s[1]).width
  711. target.font.size = sizeback

  712. buf_width = [target.text_size(split_s[0]).width, ruby_width].max

  713. width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0

  714. if opacity == 255
  715.    target.font.size = rubysize
  716.    target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  717.    target.font.size = sizeback
  718.    target.draw_text(x, y, width, target.font.size, split_s[0])
  719.    return width
  720. else
  721.    if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  722.      @opacity_text_buf.dispose
  723.      @opacity_text_buf = Bitmap.new(buf_width, height)
  724.    else
  725.      @opacity_text_buf.clear
  726.    end
  727.    @opacity_text_buf.font.size = rubysize
  728.    @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  729.    @opacity_text_buf.font.size = sizeback
  730.    @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  731.    if sub_x >= 0
  732.      target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  733.    else
  734.      target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  735.    end
  736.    return width
  737. end
  738. end
  739. #--------------------------------------------------------------------------
  740. # ● 解放
  741. #--------------------------------------------------------------------------
  742. def dispose
  743. terminate_message
  744. if @gaiji_cache != nil
  745.    unless @gaiji_cache.disposed?
  746.      @gaiji_cache.dispose
  747.    end
  748. end
  749. unless @opacity_text_buf.disposed?
  750.    @opacity_text_buf.dispose
  751. end
  752. $game_temp.message_window_showing = false
  753. if @input_number_window != nil
  754.    @input_number_window.dispose
  755. end
  756. super
  757. end
  758. #--------------------------------------------------------------------------
  759. # ● 矩形更新
  760. #--------------------------------------------------------------------------
  761. def update_cursor_rect
  762. if @index >= 0
  763.    n = $game_temp.choice_start + @index
  764.    self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  765. else
  766.    self.cursor_rect.empty
  767. end
  768. end
  769. end
  770. #==============================================================================
  771. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  772. #==============================================================================
  773. class Window_Frame < Window_Base
  774. #--------------------------------------------------------------------------
  775. # ● オブジェクト初期化
  776. #--------------------------------------------------------------------------
  777. def initialize(x, y, width, height)
  778. super(x, y, width, height)
  779. self.contents = nil
  780. self.back_opacity = 100
  781. end
  782. #--------------------------------------------------------------------------
  783. # ● 解放
  784. #--------------------------------------------------------------------------
  785. def dispose
  786. super
  787. end
  788. end
  789. #==============================================================================
  790. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  791. #==============================================================================
  792. class Air_Text < Window_Base


  793. #参数的颜色自定义设定范围0-255
  794. $ncolor0 = 255
  795. $ncolor1 = 255
  796. $ncolor2 = 255
  797. #参数的颜色自定义设定范围0-255

  798. #--------------------------------------------------------------------------
  799. # ● オブジェクト初期化
  800. #--------------------------------------------------------------------------
  801. def initialize(x, y, designate_text)
  802. super(x-16, y-16, 32 + designate_text.size * 12, 56)
  803. self.opacity = 0
  804. self.back_opacity = 0
  805. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  806. w = self.contents.width
  807. h = self.contents.height


  808.    #颜色自定义设定范围0-255
  809.    self.contents.font.color = Color.new($ncolor0, $ncolor1, $ncolor2)
  810.    #颜色自定义设定范围0-255

  811.    
  812.    
  813. #    self.contents.font.color = text_color(color)
  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
复制代码
roguelike求生RPG研发中....

Lv1.梦旅人

梦石
0
星屑
49
在线时间
486 小时
注册时间
2009-7-23
帖子
449
2
发表于 2011-8-30 19:34:12 | 只看该作者
改好了
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————
  4. #——说明
  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7. # 其他在对话中可以使用的功能:

  8. # \n[1]:显示1号角色的姓名
  9. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  10. # \name[\n[1]]:显示1号主角的姓名方框
  11. # \p[1]:对话框出现在1号事件的上方
  12. # \p[0]:主人公上方出现对话框
  13. #——————————————————使用\p功能后可以自动调整对话框大小
  14. # \>   :文字不用打字方式
  15. # \<   :文字使用打字方式
  16. # \\:显示"\"这个符号
  17. # \g:显示金钱窗口
  18. # \t: 显示游戏时间窗口
  19. # \v[7]:显示7号变量的值
  20. # \v[a7]:显示7号防具的名称
  21. # \v[s7]:显示7号特技的名称
  22. # \v[w7]:显示7号武器的名称
  23. # \v[i7]:显示7号道具的名称
  24. # \I   :下一行从这个位置开始
  25. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  26. # \h[12]:改用12号字
  27. # \b[50]:空50象素
  28. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  29. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  30. # \Lk:清除左边的图像
  31. # \Rk:清除右边的图像
  32. # \A:头像及姓名框靠左排列
  33. # \a:头像及姓名框靠右排列
  34. # \M[60]:等待60帧文字直接消失
  35. #颜色自定义设定范围0-255
  36. #使用方法:在文章前输入如下脚本定义颜色
  37. #          $color0 = 数值
  38. #          $color1 = 数值
  39. #          $color2 = 数值
  40. #\name参数的颜色自定义设定范围0-255
  41. #使用方法:在文章前输入如下脚本定义颜色
  42. #          $ncolor0 = 数值
  43. #          $ncolor1 = 数值
  44. #          $ncolor2 = 数值
  45. # \!   :等待玩家按回车再继续
  46. #$speed :文字的打字速度设置用的,数字越大速度越慢。

  47. #============================
  48. class Game_System
  49. attr_accessor :typing
  50. alias carol3_ini initialize
  51. def initialize
  52. carol3_ini
  53. @typing = true
  54. end
  55. end
  56. #=================================#==============================================================================
  57. # ■ Window_Message
  58. #------------------------------------------------------------------------------
  59. class Window_Message < Window_Selectable
  60. #颜色自定义用的全局变量定义
  61. $color0 = 255
  62. $color1 = 255
  63. $color2 = 255
  64. #颜色自定义用的全局变量定义

  65. #说话速度设置用的全局变量

  66. $speed = 3

  67. #--------------------------------------------------------------------------
  68. # ● 初始化状态
  69. #--------------------------------------------------------------------------
  70. def initialize
  71. super(80, 304, 480, 160)
  72. self.contents = Bitmap.new(width - 32, height - 32)
  73. self.visible = false
  74. self.z = 9998
  75. @fade_in = false
  76. @fade_out = false
  77. @contents_showing = false
  78. @cursor_width = 0
  79. @autoclosetime = -1
  80. self.active = false
  81. self.index = -1
  82. @opacity_text_buf = Bitmap.new(32, 32)
  83. end
  84. #--------------------------------------------------------------------------
  85. # ● 释放
  86. #--------------------------------------------------------------------------
  87. def dispose
  88. terminate_message
  89. $game_temp.message_window_showing = false
  90. if @input_number_window != nil
  91.    @input_number_window.dispose
  92. end
  93. super
  94. end
  95. #--------------------------------------------------------------------------
  96. # ● 处理信息结束
  97. #--------------------------------------------------------------------------
  98. def terminate_message
  99. self.active = false
  100. self.pause = false
  101. self.index = -1
  102. self.contents.clear
  103. # 清除显示中标志
  104. @contents_showing = false
  105. # 呼叫信息调用
  106. if $game_temp.message_proc != nil
  107.    $game_temp.message_proc.call
  108. end
  109. # 清除文章、选择项、输入数值的相关变量
  110. $game_temp.message_text = nil
  111. $game_temp.message_proc = nil
  112. $game_temp.choice_start = 99
  113. $game_temp.choice_max = 0
  114. $game_temp.choice_cancel_type = 0
  115. $game_temp.choice_proc = nil
  116. $game_temp.num_input_start = 99
  117. $game_temp.num_input_variable_id = 0
  118. $game_temp.num_input_digits_max = 0
  119. # 开放金钱窗口
  120. if @gold_window != nil
  121.    @gold_window.dispose
  122.    @gold_window = nil
  123. end
  124. # 开放时间窗口
  125. if @playtime_window != nil
  126.    @playtime_window.dispose
  127.    @playtime_window = nil
  128. end
  129. if @name_window_frame != nil
  130.    @name_window_frame.dispose
  131.    @name_window_frame = nil
  132. end
  133. if @name_window_text != nil
  134.    @name_window_text.dispose
  135.    @name_window_text = nil
  136. end
  137. if @right_picture != nil and @right_keep == true
  138.    @right_picture.dispose
  139. end   
  140. if @left_picture != nil and @left_keep == true
  141.    @left_picture.dispose
  142. end
  143. @face_bitmap = nil
  144. end
  145. def refresh
  146. # 初期化
  147. self.contents.clear
  148. self.contents.font.color = normal_color
  149. self.contents.font.size = Font.default_size
  150. @x = @y = @max_x = @max_y = @indent = @lines = 0
  151. @left_keep = @right_keep = false
  152. @face_indent = 0
  153. @opacity = 255
  154. @cursor_width = 0
  155. @autoclosetime = -1
  156. @write_speed = $speed
  157. @write_wait = 0
  158. @mid_stop = false
  159. face = nil
  160. @popchar = -2
  161. @alignment = true
  162. if $game_temp.choice_start == 0
  163.    @x = 8
  164. end
  165. if $game_temp.message_text != nil
  166.    @now_text = $game_temp.message_text
  167.    #——对齐设置
  168.    if (/\\([Aa])/.match(@now_text))!=nil then
  169.      if $1 == "A"
  170.        @alignment = true
  171.      else
  172.        @alignment = false
  173.      end
  174.      @now_text.gsub!(/\\([Aa])/) { "" }
  175.    end
  176.    #——头像设置
  177.     if (/\\([Ff])\[(.+?)\]/.match(@now_text))!=nil then
  178.       @face = $2 + "_f.png"
  179.       if $1 == "f" and $game_actors[$2.to_i] != nil
  180.         face = $game_actors[$2.to_i].battler_name + "_f.png"
  181.       end
  182.       if FileTest.exist?("Graphics/Pictures/#{face}")
  183.         @face_bitmap = Bitmap.new("Graphics/Pictures/#{face}")
  184.         if @alignment
  185.           @x = @face_indent = 128
  186.           self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  187.         else
  188.           self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  189.             Rect.new(0, 0, 96, 96))
  190.         end
  191.       else
  192.         face = nil
  193.         @face_bitmap = nil
  194.       end
  195.       @now_text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
  196.     end
  197.    #——左半身像设置
  198.    if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  199.      @face = "66rpg_" + $1 + "_h.png"
  200.      if $加密 == true
  201.        if @left_picture != nil
  202.          @left_picture.dispose
  203.        end
  204.        @left_picture = Sprite.new
  205.        @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  206.        @left_picture.y = 480-@left_picture.bitmap.height
  207.        @left_picture.x = 0
  208.        @left_picture.mirror = true
  209.        @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  210.      else         
  211.        if FileTest.exist?("Graphics/battlers/#{@face}")
  212.          if @left_picture != nil
  213.            @left_picture.dispose
  214.          end
  215.          @left_picture = Sprite.new
  216.          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  217.          @left_picture.y = 480-@left_picture.bitmap.height
  218.          @left_picture.x = 0
  219.          @left_picture.mirror = true
  220.          @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  221.        end
  222.      end        
  223.    end
  224.    #——右半身像设置
  225.    if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  226.      @face = "66rpg_" + $1 + "_h.png"
  227.      if $加密 == true
  228.        if @right_picture != nil
  229.          @right_picture.dispose
  230.        end
  231.        @right_picture = Sprite.new
  232.        @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  233.        @right_picture.y = 480-@right_picture.bitmap.height
  234.        @right_picture.x = 640-@right_picture.bitmap.width
  235.        @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  236.      else
  237.        if FileTest.exist?("Graphics/battlers/#{@face}")
  238.          if @right_picture != nil
  239.            @right_picture.dispose
  240.          end
  241.          @right_picture = Sprite.new
  242.          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  243.          @right_picture.y = 480-@right_picture.bitmap.height
  244.          @right_picture.x = 640-@right_picture.bitmap.width
  245.          @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  246.        end
  247.      end
  248.    end
  249.    if (/\\[Rr]k/.match(@now_text)) != nil
  250.      @right_keep = true
  251.      @now_text.sub!(/\\[Rr]k/) { "" }
  252.    end
  253.    if (/\\[Ll]k/.match(@now_text)) != nil
  254.      @left_keep = true
  255.      @now_text.sub!(/\\[Ll]k/) { "" }
  256.    end
  257.    # 替换人物姓名
  258.    @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  259.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  260.    end
  261.    # 显示人物姓名
  262.    name_window_set = false
  263.    if (/\\[Nn][Aa][Mm][Ee](.*?)\[(.+?)\]/.match(@now_text)) != nil
  264.      name_window_set = true
  265.      name_text = $2
  266.      @now_text.sub!(/\\[Nn][Aa][Mm][Ee](.*?)\[(.*?)\]/) { "" }
  267.    end
  268.    # 文字位置的判定
  269.    if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  270.      @popchar = $1.to_i
  271.      if @popchar == -1
  272.        @x = @indent = 48
  273.        @y = 4
  274.      end
  275.      @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  276.    end
  277.    
  278.    # 开始
  279.    begin
  280.      last_text = @now_text.clone
  281.      @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  282.    end until @now_text == last_text
  283. @now_text.gsub!(/\\\\/) { "\000" }
  284. @now_text.gsub!(/\\[Gg]/) { "\002" }
  285. @now_text.gsub!(/\\[Tt]/) { "\004" }
  286. @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  287. @now_text.gsub!(/\\[Ii]/) { "\023" }
  288. @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  289. @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  290. @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  291. @now_text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
  292. @now_text.gsub!(/\\[!]/) { "\020" }
  293. @now_text.gsub!(/\\[>]/) { "\016" }
  294. @now_text.gsub!(/\\[<]/) { "\017" }


  295. if @popchar >= 0
  296.    @text_save = @now_text.clone
  297.    @max_x = 0
  298.    @max_y = 4
  299.    for i in 0..3
  300.      line = @now_text.split(/\n/)[3-i]
  301.      @max_y -= 1 if line == nil and @max_y <= 4-i
  302.      next if line == nil
  303.      cx = contents.text_size(line).width
  304.      @max_x = cx if cx > @max_x
  305.    end
  306.    self.width = @max_x + 48 + @face_indent
  307.    self.height = (@max_y - 1) * 32 + 64
  308. else
  309.    @max_x = self.width - 32 - @face_indent
  310. end
  311. reset_window
  312.    if name_window_set
  313.      off_x = 0
  314.      off_y = -40
  315.      space = 2
  316.      w = self.contents.text_size(name_text).width + 26 + space
  317.      x = @alignment ? self.x + off_x - space / 2 : self.x + off_x - space / 2 + self.width - w
  318.      y = self.y + off_y - space / 2
  319.      h = 40 + space
  320.      @name_window_frame = Window_Frame.new(x, y, w, h)
  321.      @name_window_frame.z = self.z + 1
  322.      x = @alignment ? self.x + off_x - space / 2 + 4 : self.x + off_x - space / 2 + 4 + self.width - w
  323.      y = self.y + off_y - space / 2
  324.      @name_window_text = Air_Text.new(x+4, y+6, name_text)
  325.      @name_window_text.z = self.z + 2
  326.    end
  327. end
  328. reset_window
  329. if $game_temp.choice_max > 0
  330.    @item_max = $game_temp.choice_max
  331.    self.active = true
  332.    self.index = 0
  333. end
  334. if $game_temp.num_input_variable_id > 0
  335.    digits_max = $game_temp.num_input_digits_max
  336.    number = $game_variables[$game_temp.num_input_variable_id]
  337.    @input_number_window = Window_InputNumber.new(digits_max)
  338.    @input_number_window.number = number
  339.    @input_number_window.x = self.x + 8
  340.    @input_number_window.y = self.y + $game_temp.num_input_start * 32
  341. end
  342. end
  343. #--------------------------------------------------------------------------
  344. # ● 更新
  345. #--------------------------------------------------------------------------
  346. def update
  347. super



  348.   #颜色自定义设定范围0-255
  349.   self.contents.font.color = Color.new($color0, $color1, $color2)
  350.   #颜色自定义设定范围0-255
  351.   
  352.   
  353.   
  354.    if @autoclosetime == 0
  355.    @autoclosetime = -1
  356.    terminate_message
  357. end
  358. if @autoclosetime >= 1
  359.    @autoclosetime -= 1
  360. end
  361. if @fade_in
  362.    self.contents_opacity += 24
  363.    if @input_number_window != nil
  364.      @input_number_window.contents_opacity += 24
  365.    end
  366.    if self.contents_opacity == 255
  367.      @fade_in = false
  368.    end
  369.    return
  370. end
  371. @now_text = nil if @now_text == ""
  372. if @now_text != nil and @mid_stop == false
  373.    if @write_wait > 0
  374.      @write_wait -= 1
  375.      return
  376.    end
  377.    while true
  378.      @max_x = @x if @max_x < @x
  379.      @max_y = @y if @max_y < @y
  380.      if (c = @now_text.slice!(/./m)) != nil
  381.        if c == "\000"
  382.          c = "\\"
  383.        end
  384.        if c == "\002"
  385.          if @gold_window == nil and @popchar <= 0
  386.            @gold_window = Window_Gold.new
  387.            @gold_window.x = 560 - @gold_window.width
  388.            if $game_temp.in_battle
  389.              @gold_window.y = 192
  390.            else
  391.              @gold_window.y = self.y >= 128 ? 32 : 384
  392.            end
  393.            @gold_window.opacity = self.opacity
  394.            @gold_window.back_opacity = self.back_opacity
  395.          end
  396.          c = ""
  397.        end
  398.      if c == "\004"
  399.        if @playtime_window == nil and @popchar <=0
  400.          @playtime_window = Window_PlayTime.new
  401.          @playtime_window.x = 80
  402.          if $game_temp.in_battle
  403.            @playtime_window.y = 192
  404.          else
  405.            @playtime_window.y = self.y >= 128 ? 32 : 384
  406.          end
  407.          @playtime_window.opacity = self.opacity
  408.          @playtime_window.back_opacity = self.back_opacity
  409.        end
  410.      end
  411.       if c == "\016"
  412.         $game_system.typing = false
  413.         c = ""
  414.       end
  415.       if c == "\017"
  416.         $game_system.typing = true
  417.         c = ""
  418.       end
  419.       if c == "\020"
  420.         @mid_stop = true
  421.         c = ""
  422.       end        
  423.        if c == "\023"
  424.          @indent = @x
  425.          c = ""
  426.        end
  427.        if c == "\024"
  428.          @now_text.sub!(/\[([0-9]+)\]/, "")
  429.          @opacity = $1.to_i
  430.          c = ""
  431.        end
  432.        if c == "\025"
  433.          @now_text.sub!(/\[([0-9]+)\]/, "")
  434.          self.contents.font.size = [[$1.to_i, 6].max, 32].min
  435.          c = ""
  436.        end
  437.        if c == "\026"
  438.          @now_text.sub!(/\[([0-9]+)\]/, "")
  439.          @x += $1.to_i
  440.          c = ""
  441.        end
  442.      if c == "\027"
  443.        @now_text.sub!(/\[([0-9]+)\]/, "")
  444.        @x += $1.to_i * self.contents.font.size / 2
  445.        next
  446.      end
  447.        if c == "\030"
  448.          @now_text.sub!(/\[(.*?)\]/, "")
  449.          self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  450.          @x += 24
  451.          c = ""
  452.        end
  453.        if c == "\050"
  454.        @now_text.sub!(/\[([0-9]+)\]/, "")
  455.        @autoclosetime = $1.to_i
  456.        next
  457.      end
  458.        if c == "\n"
  459.          if @lines >= $game_temp.choice_start
  460.            @cursor_width = [@cursor_width, @max_x - @face_indent].max
  461.          end
  462.          @lines += 1
  463.          @y += 1
  464.          @x = 0 + @indent + @face_indent
  465.          if @lines >= $game_temp.choice_start
  466.            @x = 8 + @indent + @face_indent
  467.          end
  468.          c = ""
  469.        end
  470.        if c != ""
  471.          # 文字描画
  472.          @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  473.        end
  474.        if Input.press?(Input::B)
  475.          $game_system.typing = false
  476.        end
  477.      else
  478.        $game_system.typing = true
  479.        break
  480.      end
  481.      # 終了判定
  482.      if $game_system.typing
  483.        break
  484.      end
  485.    end
  486.    @write_wait += @write_speed
  487.    return
  488. end
  489. if @input_number_window != nil
  490.    @input_number_window.update
  491.    # 決定
  492.    if Input.trigger?(Input::C)
  493.      $game_system.se_play($data_system.decision_se)
  494.      $game_variables[$game_temp.num_input_variable_id] =
  495.      @input_number_window.number
  496.      $game_map.need_refresh = true
  497.      @input_number_window.dispose
  498.      @input_number_window = nil
  499.      terminate_message
  500.    end
  501.    return
  502. end
  503. if @contents_showing
  504.    if $game_temp.choice_max == 0
  505.      self.pause = true
  506.    end
  507.    # 取消
  508.    if Input.trigger?(Input::B)
  509.      if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  510.        $game_system.se_play($data_system.cancel_se)
  511.        $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  512.        terminate_message
  513.      end
  514.    end
  515.    # 決定
  516.    if Input.trigger?(Input::C)
  517.      if $game_temp.choice_max > 0
  518.        $game_system.se_play($data_system.decision_se)
  519.        $game_temp.choice_proc.call(self.index)
  520.      end
  521.      if @mid_stop
  522.        @mid_stop = false
  523.        return
  524.      else
  525.        terminate_message
  526.      end
  527.    end
  528.    return
  529. end
  530. if @fade_out == false and $game_temp.message_text != nil
  531.    @contents_showing = true
  532.    $game_temp.message_window_showing = true
  533.    refresh
  534.    Graphics.frame_reset
  535.    self.visible = true
  536.    self.contents_opacity = 0
  537. if @input_number_window != nil
  538.    @input_number_window.contents_opacity = 0
  539. end
  540.    @fade_in = true
  541.    return
  542. end
  543. if self.visible
  544.    @fade_out = true
  545.    self.opacity -= 48
  546.    if self.opacity == 0
  547.      self.visible = false
  548.      @fade_out = false
  549.      $game_temp.message_window_showing = false
  550.    end
  551.    return
  552. end
  553. end
  554. #--------------------------------------------------------------------------
  555. # ● 获得字符
  556. #--------------------------------------------------------------------------
  557. def get_character(parameter)
  558. case parameter
  559. when 0
  560.    return $game_player
  561. else
  562.    events = $game_map.events
  563.    return events == nil ? nil : events[parameter]
  564. end
  565. end
  566. #--------------------------------------------------------------------------
  567. # ● ウィンドウの位置と不透明度の設定
  568. #--------------------------------------------------------------------------
  569. def reset_window
  570. # 判定
  571. if @popchar >= 0
  572.    events = $game_map.events
  573.    if events != nil
  574.      character = get_character(@popchar)
  575.      x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  576.      y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  577.      self.x = x
  578.      self.y = y
  579.    end
  580. elsif @popchar == -1
  581.    self.x = -4
  582.    self.y = -4
  583.    self.width = 648
  584.    self.height = 488
  585. else
  586.    if $game_temp.in_battle
  587.       self.y = 48
  588.    else
  589.      case $game_system.message_position
  590.      when 0 # 上
  591.        self.y = 16
  592.      when 1 # 中
  593.        self.y = 160
  594.      when 2 # 下
  595.        self.y = 304
  596.      end
  597.      self.x = 80
  598.       if @face_bitmap == nil
  599.         self.width = 480
  600.       else
  601.         self.width = 600
  602.         self.x -= 60
  603.       end
  604.       self.height = 160
  605.     end
  606.   end
  607. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  608.   if @face_bitmap != nil
  609.     if @alignment
  610.       self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  611.     else
  612.       self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  613.         Rect.new(0, 0, 96, 96))
  614.     end
  615.   end
  616.   if @popchar == -1
  617.    self.opacity = 255
  618.    self.back_opacity = 0
  619. elsif $game_system.message_frame == 0
  620.    self.opacity = 255
  621.    self.back_opacity = 255
  622. else
  623.    self.opacity = 0
  624.    self.back_opacity = 100
  625. end
  626. end
  627. #--------------------------------------------------------------------------
  628. # ● line_height
  629. #--------------------------------------------------------------------------
  630. # 返回値:行高
  631. #--------------------------------------------------------------------------
  632. def line_height
  633. return 32
  634. if self.contents.font.size >= 20 and self.contents.font.size <= 24
  635.    return 32
  636. else
  637.    return self.contents.font.size * 15 / 10
  638. end
  639. end
  640. #--------------------------------------------------------------------------
  641. # ● \V 变换
  642. #--------------------------------------------------------------------------
  643. def convart_value(option, index)
  644. option == nil ? option = "" : nil
  645. option.downcase!
  646. case option
  647.    when "i"
  648.      unless $data_items[index].name == nil
  649.        r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  650.      end
  651.    when "w"
  652.      unless $data_weapons[index].name == nil
  653.        r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  654.      end
  655.    when "a"
  656.      unless $data_armors[index].name == nil
  657.        r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  658.      end
  659.    when "s"
  660.      unless $data_skills[index].name == nil
  661.        r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  662.      end
  663.    else
  664.    r = $game_variables[index]
  665. end
  666. r == nil ? r = "" : nil
  667. return r
  668. end
  669. #--------------------------------------------------------------------------
  670. # ● 透過文字描画
  671. #--------------------------------------------------------------------------
  672. # target :描画対象。Bitmapクラスを指定。
  673. # x :x座標
  674. # y :y座標
  675. # str  :描画文字列
  676. # opacity:透過率(0~255)
  677. # 返回値 :文字幅(@x増加値)。
  678. #--------------------------------------------------------------------------
  679. def opacity_draw_text(target, x, y, str,opacity)
  680. height = target.font.size
  681. width = target.text_size(str).width
  682. opacity = [[opacity, 0].max, 255].min
  683. if opacity == 255
  684.    target.draw_text(x, y, width, height, str)
  685.    return width
  686. else
  687.    if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  688.      @opacity_text_buf.dispose
  689.      @opacity_text_buf = Bitmap.new(width, height)
  690.    else
  691.      @opacity_text_buf.clear
  692.    end
  693.    @opacity_text_buf.font.size = target.font.size
  694.    @opacity_text_buf.draw_text(0, 0, width, height, str)
  695.    target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  696. return width
  697. end
  698. end
  699. def ruby_draw_text(target, x, y, str,opacity)
  700. sizeback = target.font.size
  701. target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  702. rubysize = [rubysize, 6].max

  703. opacity = [[opacity, 0].max, 255].min
  704. split_s = str.split(/,/)

  705. split_s[0] == nil ? split_s[0] = "" : nil
  706. split_s[1] == nil ? split_s[1] = "" : nil

  707. height = sizeback + rubysize
  708. width = target.text_size(split_s[0]).width

  709. target.font.size = rubysize
  710. ruby_width = target.text_size(split_s[1]).width
  711. target.font.size = sizeback

  712. buf_width = [target.text_size(split_s[0]).width, ruby_width].max

  713. width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0

  714. if opacity == 255
  715.    target.font.size = rubysize
  716.    target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  717.    target.font.size = sizeback
  718.    target.draw_text(x, y, width, target.font.size, split_s[0])
  719.    return width
  720. else
  721.    if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  722.      @opacity_text_buf.dispose
  723.      @opacity_text_buf = Bitmap.new(buf_width, height)
  724.    else
  725.      @opacity_text_buf.clear
  726.    end
  727.    @opacity_text_buf.font.size = rubysize
  728.    @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  729.    @opacity_text_buf.font.size = sizeback
  730.    @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  731.    if sub_x >= 0
  732.      target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  733.    else
  734.      target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  735.    end
  736.    return width
  737. end
  738. end
  739. #--------------------------------------------------------------------------
  740. # ● 解放
  741. #--------------------------------------------------------------------------
  742. def dispose
  743. terminate_message
  744. if @gaiji_cache != nil
  745.    unless @gaiji_cache.disposed?
  746.      @gaiji_cache.dispose
  747.    end
  748. end
  749. unless @opacity_text_buf.disposed?
  750.    @opacity_text_buf.dispose
  751. end
  752. $game_temp.message_window_showing = false
  753. if @input_number_window != nil
  754.    @input_number_window.dispose
  755. end
  756. super
  757. end
  758. #--------------------------------------------------------------------------
  759. # ● 矩形更新
  760. #--------------------------------------------------------------------------
  761. def update_cursor_rect
  762. if @index >= 0
  763.    n = $game_temp.choice_start + @index
  764.    self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  765. else
  766.    self.cursor_rect.empty
  767. end
  768. end
  769. end
  770. #==============================================================================
  771. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  772. #==============================================================================
  773. class Window_Frame < Window_Base
  774. #--------------------------------------------------------------------------
  775. # ● オブジェクト初期化
  776. #--------------------------------------------------------------------------
  777. def initialize(x, y, width, height)
  778. super(x, y, width, height)
  779. self.contents = nil
  780. self.back_opacity = 100
  781. end
  782. #--------------------------------------------------------------------------
  783. # ● 解放
  784. #--------------------------------------------------------------------------
  785. def dispose
  786. super
  787. end
  788. end
  789. #==============================================================================
  790. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  791. #==============================================================================
  792. class Air_Text < Window_Base


  793. #参数的颜色自定义设定范围0-255
  794. $ncolor0 = 255
  795. $ncolor1 = 255
  796. $ncolor2 = 255
  797. #参数的颜色自定义设定范围0-255

  798. #--------------------------------------------------------------------------
  799. # ● オブジェクト初期化
  800. #--------------------------------------------------------------------------
  801. def initialize(x, y, designate_text)
  802. super(x-16, y-16, 32 + designate_text.size * 12, 56)
  803. self.opacity = 0
  804. self.back_opacity = 0
  805. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  806. w = self.contents.width
  807. h = self.contents.height


  808.    #颜色自定义设定范围0-255
  809.    self.contents.font.color = Color.new($ncolor0, $ncolor1, $ncolor2)
  810.    #颜色自定义设定范围0-255

  811.    
  812.    
  813. #    self.contents.font.color = text_color(color)
  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
复制代码
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1433
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
3
 楼主| 发表于 2011-8-30 19:37:28 | 只看该作者
2578699 发表于 2011-8-30 19:34
改好了

能补充下改的哪里么

点评

631行 self.back_opacity = 255 255表示完全不透明 自己调就好了。  发表于 2011-8-30 19:39
roguelike求生RPG研发中....
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-23 09:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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