Project1

标题: 让一句话快速闪过 [打印本页]

作者: 对数螺线    时间: 2015-8-12 15:17
标题: 让一句话快速闪过
如题,让剧情里一句话不用玩家操作直接闪过,且速度很快。
萌新一枚求各位dalao帮忙,这儿log spiral\对数螺线
作者: 无忧谷主幻    时间: 2015-8-12 17:32
具体用法请看前面的注释
RUBY 代码复制
  1. # ————————————————————————————————————
  2. # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息
  3. # ————————————————————————————————————
  4. #——说明
  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7. # 其他在对话中可以使用的功能:
  8.  
  9. # \n[1]:显示1号角色的姓名
  10. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  11. # \name[\n[1]]:显示1号主角的姓名方框
  12. # \p[1]:对话框出现在1号事件的上方
  13. # \p[0]:主人公上方出现对话框
  14. #——————————————————使用\p功能后可以自动调整对话框大小
  15. # \>   :文字不用打字方式
  16. # \<   :文字使用打字方式
  17. # \\:显示"\"这个符号
  18. # \c[1-8]:更改颜色
  19. # \g:显示金钱窗口
  20. # \t: 显示游戏时间窗口
  21. # \v[7]:显示7号变量的值
  22. # \v[a7]:显示7号防具的名称
  23. # \v[s7]:显示7号特技的名称
  24. # \v[w7]:显示7号武器的名称
  25. # \v[i7]:显示7号道具的名称
  26. # \I   :下一行从这个位置开始
  27. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  28. # \h[12]:改用12号字
  29. # \b[50]:空50象素
  30. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  31. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  32. # \Lk:清除左边的图像
  33. # \Rk:清除右边的图像
  34. # \A:头像及姓名框靠左排列
  35. # \a:头像及姓名框靠右排列
  36. # \M[60]:等待60帧文字直接消失
  37. # \MS[1-8]:更改文字背景颜色
  38. # \ME:恢复文字背景颜色
  39. #颜色自定义设定范围0-255
  40. #使用方法:在文章前输入如下脚本定义颜色
  41. #          $color0 = 数值
  42. #          $color1 = 数值
  43. #          $color2 = 数值
  44. #\name参数的颜色自定义设定范围0-255
  45. #使用方法:在文章前输入如下脚本定义颜色
  46. #          $ncolor0 = 数值
  47. #          $ncolor1 = 数值
  48. #          $ncolor2 = 数值
  49. # \!   :等待玩家按回车再继续
  50. #$speed :文字的打字速度设置用的,数字越大速度越慢。
  51.  
  52. #============================
  53. class Game_System
  54. attr_accessor :typing
  55. alias carol3_ini initialize
  56. def initialize
  57. carol3_ini
  58. @typing = true
  59. end
  60. end
  61. #=================================#==============================================================================
  62. # ■ Window_Message
  63. #------------------------------------------------------------------------------
  64. class Window_Message < Window_Selectable
  65.   #颜色自定义用的全局变量定义
  66.   $color0 = 255
  67.   $color1 = 255
  68.   $color2 = 255
  69.   #颜色自定义用的全局变量定义
  70.  
  71.   #说话速度设置用的全局变量
  72.  
  73.   $speed = 0.75
  74.  
  75. #--------------------------------------------------------------------------
  76. # ● 初始化状态
  77. #--------------------------------------------------------------------------
  78. def initialize
  79.   super(80, 304, 480, 160)
  80.   self.contents = Bitmap.new(width - 32, height - 32)
  81.   self.visible = false
  82.   self.z = 9998
  83.   @fade_in = false
  84.   @fade_out = false
  85.   @contents_showing = false
  86.   @cursor_width = 0
  87. # Start
  88.   @bflag = false
  89. # End
  90.   @autoclosetime = -1
  91.   self.active = false
  92.   self.index = -1
  93.   @opacity_text_buf = Bitmap.new(32, 32)
  94. end
  95. #--------------------------------------------------------------------------
  96. # ● 释放
  97. #--------------------------------------------------------------------------
  98. def dispose
  99.   terminate_message
  100.   $game_temp.message_window_showing = false
  101.   if @input_number_window != nil
  102.     @input_number_window.dispose
  103.   end
  104.   super
  105. end
  106. #--------------------------------------------------------------------------
  107. # ● 处理信息结束
  108. #--------------------------------------------------------------------------
  109. def terminate_message
  110.   self.active = false
  111.   self.pause = false
  112.   self.index = -1
  113.   self.contents.clear
  114.   # 清除显示中标志
  115.   @contents_showing = false
  116.   # 呼叫信息调用
  117.   if $game_temp.message_proc != nil
  118.     $game_temp.message_proc.call
  119.   end
  120.   # 清除文章、选择项、输入数值的相关变量
  121.   $game_temp.message_text = nil
  122.   $game_temp.message_proc = nil
  123.   $game_temp.choice_start = 99
  124.   $game_temp.choice_max = 0
  125.   $game_temp.choice_cancel_type = 0
  126.   $game_temp.choice_proc = nil
  127.   $game_temp.num_input_start = 99
  128.   $game_temp.num_input_variable_id = 0
  129.   $game_temp.num_input_digits_max = 0
  130.   # 开放金钱窗口
  131.   if @gold_window != nil
  132.     @gold_window.dispose
  133.     @gold_window = nil
  134.   end
  135. #Start
  136.   # ピクチャ廃棄処理
  137.   begin
  138. #      if @spgra.disposed? == false
  139.       @spgra.dispose
  140. #      end
  141. #      if @backgraphic.disposed? == false
  142.       @backgraphic.dispose
  143. #      end
  144.   rescue
  145. #      print "ピクチャが読み込めていません!"
  146.   end
  147. #End
  148.   # 开放时间窗口
  149.   if @playtime_window != nil
  150.     @playtime_window.dispose
  151.     @playtime_window = nil
  152.   end
  153.   if @name_window_frame != nil
  154.     @name_window_frame.dispose
  155.     @name_window_frame = nil
  156.   end
  157.   if @name_window_text != nil
  158.     @name_window_text.dispose
  159.     @name_window_text = nil
  160.   end
  161.   if @right_picture != nil and @right_keep == true
  162.     @right_picture.dispose
  163.   end   
  164.   if @left_picture != nil and @left_keep == true
  165.     @left_picture.dispose
  166.   end
  167.   @face_bitmap = nil
  168. end
  169. def refresh
  170.   # 初期化
  171.   self.contents.clear
  172.   self.contents.font.color = normal_color
  173.   self.contents.font.size = Font.default_size
  174.   @x = @y = @max_x = @max_y = @indent = @lines = 0
  175.   @left_keep = @right_keep = false
  176.   @face_indent = 0
  177.   @opacity = 255
  178.   @cursor_width = 0
  179.   @autoclosetime = -1
  180.   @write_speed = $speed
  181.   @write_wait = 0
  182.   @mid_stop = false
  183.   face = nil
  184.   @popchar = -2
  185.   @alignment = true
  186.   if $game_temp.choice_start == 0
  187.     @x = 8
  188.   end
  189.   if $game_temp.message_text != nil
  190.     @now_text = $game_temp.message_text
  191.     #——对齐设置
  192.     if (/\\([Aa])/.match(@now_text))!=nil then
  193.       if $1 == "A"
  194.         @alignment = true
  195.       else
  196.         @alignment = false
  197.       end
  198.       @now_text.gsub!(/\\([Aa])/) { "" }
  199.     end
  200.     #——头像设置
  201.      if (/\\([Ff])\[(.+?)\]/.match(@now_text))!=nil then
  202.        @face = $2 + "_f.png"
  203.        if $1 == "f" and $game_actors[$2.to_i] != nil
  204.          @face = $game_actors[$2.to_i].battler_name + "_f.png"
  205.        end
  206.        if FileTest.exist?("Graphics/Pictures/#{@face}")
  207.          @face_bitmap = Bitmap.new("Graphics/Pictures/#{@face}")
  208.          if @alignment
  209.            @x = @face_indent = 128
  210.            self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  211.          else
  212.            self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  213.              Rect.new(0, 0, 96, 96))
  214.          end
  215.        else
  216.          @face = nil
  217.          @face_bitmap = nil
  218.        end
  219.        @now_text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
  220.      end
  221.     #——左半身像设置
  222.     if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  223.       @face = "66rpg_" + $1 + "_h.png"
  224.       if $加密 == true
  225.         if @left_picture != nil
  226.           @left_picture.dispose
  227.         end
  228.         @left_picture = Sprite.new
  229.         @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  230.         @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  231.         @left_picture.x = 0
  232.         @left_picture.mirror = true
  233.         @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  234.       else         
  235.         if FileTest.exist?("Graphics/battlers/#{@face}")
  236.           if @left_picture != nil
  237.             @left_picture.dispose
  238.           end
  239.           @left_picture = Sprite.new
  240.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  241.           @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  242.           @left_picture.x = 0
  243.           @left_picture.mirror = true
  244.           @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  245.         end
  246.       end        
  247.     end
  248.     #——右半身像设置
  249.     if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  250.       @face = "66rpg_" + $1 + "_h.png"
  251.       if $加密 == true
  252.         if @right_picture != nil
  253.           @right_picture.dispose
  254.         end
  255.         @right_picture = Sprite.new
  256.         @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  257.         @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  258.         @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  259.         @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  260.       else
  261.         if FileTest.exist?("Graphics/battlers/#{@face}")
  262.           if @right_picture != nil
  263.             @right_picture.dispose
  264.           end
  265.           @right_picture = Sprite.new
  266.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  267.           @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  268.           @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  269.           @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  270.         end
  271.       end
  272.     end
  273.     if (/\\[Rr]k/.match(@now_text)) != nil
  274.       @right_keep = true
  275.       @now_text.sub!(/\\[Rr]k/) { "" }
  276.     end
  277.     if (/\\[Ll]k/.match(@now_text)) != nil
  278.       @left_keep = true
  279.       @now_text.sub!(/\\[Ll]k/) { "" }
  280.     end
  281.     # 替换人物姓名
  282.     @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  283.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  284.     end
  285.     # 显示人物姓名
  286.     name_window_set = false
  287.     if (/\\[Nn][Aa][Mm][Ee](.*?)\[(.+?)\]/.match(@now_text)) != nil
  288.       name_window_set = true
  289.       name_text = $2
  290.       @now_text.sub!(/\\[Nn][Aa][Mm][Ee](.*?)\[(.*?)\]/) { "" }
  291.     end
  292.     # 文字位置的判定
  293.     if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  294.       @popchar = $1.to_i
  295.       if @popchar == -1
  296.         @x = @indent = 48
  297.         @y = 4
  298.       end
  299.       @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  300.     end
  301.  
  302.     # 开始
  303.     begin
  304.       last_text = @now_text.clone
  305.       @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  306.     end until @now_text == last_text
  307.   @now_text.gsub!(/\\\\/) { "\000" }
  308.   @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  309.   @now_text.gsub!(/\\[Gg]/) { "\002" }
  310.   @now_text.gsub!(/\\[Tt]/) { "\004" }
  311.   @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  312.   @now_text.gsub!(/\\[Ii]/) { "\023" }
  313.   @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  314.   @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  315.   @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  316.   @now_text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
  317.   @now_text.gsub!(/\\[!]/) { "\020" }
  318. @now_text.gsub!(/\\[>]/) { "\016" }
  319. @now_text.gsub!(/\\[<]/) { "\017" }
  320.  
  321. # Start
  322. # ◎
  323.     # "\\MS" を "\052" に、 "\\ME" を "\053" に変更
  324.     @now_text.gsub!(/\\[Mm][Ss]\[([0-9]+)\]/) { "\052[#{$1}]" }
  325.     @now_text.gsub!(/\\[Mm][Ee]/) { "\053" }
  326. # ◎
  327. # End
  328.  
  329.   if @popchar >= 0
  330.     @text_save = @now_text.clone
  331.     @max_x = 0
  332.     @max_y = 4
  333.     for i in 0..3
  334.       line = @now_text.split(/\n/)[3-i]
  335.       @max_y -= 1 if line == nil and @max_y <= 4-i
  336.       next if line == nil
  337.       cx = contents.text_size(line).width
  338.       @max_x = cx if cx > @max_x
  339.     end
  340.     self.width = @max_x + 48 + @face_indent
  341.     self.height = (@max_y - 1) * 32 + 64
  342.   else
  343.     @max_x = self.width - 32 - @face_indent
  344.   end
  345.   reset_window
  346.     if name_window_set
  347.       off_x = 0
  348.       off_y = -40
  349.       space = 2
  350.       w = self.contents.text_size(name_text).width + 26 + space
  351.       x = @alignment ? self.x + off_x - space / 2 : self.x + off_x - space / 2 + self.width - w
  352.       y = self.y + off_y - space / 2
  353.       h = 40 + space
  354.       @name_window_frame = Window_Frame.new(x, y, w, h)
  355.       @name_window_frame.z = self.z + 1
  356.       x = @alignment ? self.x + off_x - space / 2 + 4 : self.x + off_x - space / 2 + 4 + self.width - w
  357.       y = self.y + off_y - space / 2
  358.       @name_window_text = Air_Text.new(x+4, y+6, name_text)
  359.       @name_window_text.z = self.z + 2
  360.     end
  361.   end
  362.   reset_window
  363.   if $game_temp.choice_max > 0
  364.     @item_max = $game_temp.choice_max
  365.     self.active = true
  366.     self.index = 0
  367.   end
  368.   if $game_temp.num_input_variable_id > 0
  369.     digits_max = $game_temp.num_input_digits_max
  370.     number = $game_variables[$game_temp.num_input_variable_id]
  371.     @input_number_window = Window_InputNumber.new(digits_max)
  372.     @input_number_window.number = number
  373.     @input_number_window.x = self.x + 8
  374.     @input_number_window.y = self.y + $game_temp.num_input_start * 32
  375.   end
  376. end
  377. #--------------------------------------------------------------------------
  378. # ● 更新
  379. #--------------------------------------------------------------------------
  380. def update
  381.   super
  382.  
  383.  
  384.     #颜色自定义设定范围0-255
  385.     self.contents.font.color = Color.new($color0, $color1, $color2)
  386.     #颜色自定义设定范围0-255
  387.  
  388.  
  389.     if @autoclosetime == 0
  390.     @autoclosetime = -1
  391.     terminate_message
  392. end
  393.   if @autoclosetime >= 1
  394.     @autoclosetime -= 1
  395.   end
  396.   if @fade_in
  397.     self.contents_opacity += 24
  398.     if @input_number_window != nil
  399.       @input_number_window.contents_opacity += 24
  400.     end
  401.     if self.contents_opacity == 255
  402.       @fade_in = false
  403.     end
  404.     return
  405.   end
  406.   @now_text = nil if @now_text == ""
  407.  
  408.   if @now_text != nil and @mid_stop == false
  409.     if @write_wait > 0
  410.       @write_wait -= 1
  411.       return
  412.     end
  413.     text_not_skip = $game_system.typing
  414.     while true
  415.       @max_x = @x if @max_x < @x
  416.       @max_y = @y if @max_y < @y
  417.       if (c = @now_text.slice!(/./m)) != nil
  418.         if c == "\000"
  419.           c = "\\"
  420.         end
  421.         if c == "\001"
  422.           @now_text.sub!(/\[([0-9]+)\]/, "")
  423.           color = $1.to_i
  424.           if color >= 0 and color <= 7
  425.             self.contents.font.color = text_color(color)
  426.           end
  427.           c = ""
  428.         end
  429.         if c == "\002"
  430.           if @gold_window == nil and @popchar <= 0
  431.             @gold_window = Window_Gold.new
  432.             @gold_window.x = 560 - @gold_window.width
  433.             if $game_temp.in_battle
  434.               @gold_window.y = 192
  435.             else
  436.               @gold_window.y = self.y >= 128 ? 32 : 384
  437.             end
  438.             @gold_window.opacity = self.opacity
  439.             @gold_window.back_opacity = self.back_opacity
  440.           end
  441.           c = ""
  442.         end
  443.       if c == "\004"
  444.         if @playtime_window == nil and @popchar <=0
  445.           @playtime_window = Window_PlayTime.new
  446.           @playtime_window.x = 80
  447.           if $game_temp.in_battle
  448.             @playtime_window.y = 192
  449.           else
  450.             @playtime_window.y = self.y >= 128 ? 32 : 384
  451.           end
  452.           @playtime_window.opacity = self.opacity
  453.           @playtime_window.back_opacity = self.back_opacity
  454.         end
  455.       end
  456.        if c == "\016"
  457.          text_not_skip = false
  458.          c = ""
  459.        end
  460.        if c == "\017"
  461.          text_not_skip = true
  462.          c = ""
  463.        end
  464.        if c == "\020"
  465.          @mid_stop = true
  466.          c = ""
  467.        end        
  468.         if c == "\023"
  469.           @indent = @x
  470.           c = ""
  471.         end
  472.         if c == "\024"
  473.           @now_text.sub!(/\[([0-9]+)\]/, "")
  474.           @opacity = $1.to_i
  475.           c = ""
  476.         end
  477.         if c == "\025"
  478.           @now_text.sub!(/\[([0-9]+)\]/, "")
  479.           self.contents.font.size = [[$1.to_i, 6].max, 32].min
  480.           c = ""
  481.         end
  482.         if c == "\026"
  483.           @now_text.sub!(/\[([0-9]+)\]/, "")
  484.           @x += $1.to_i
  485.           c = ""
  486.         end
  487.       if c == "\027"
  488.         @now_text.sub!(/\[([0-9]+)\]/, "")
  489.         @x += $1.to_i * self.contents.font.size / 2
  490.         next
  491.       end
  492.         if c == "\030"
  493.           @now_text.sub!(/\[(.*?)\]/, "")
  494.           self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  495.           @x += 24
  496.           c = ""
  497.         end
  498.         if c == "\050"
  499.         @now_text.sub!(/\[([0-9]+)\]/, "")
  500.         @autoclosetime = $1.to_i
  501.         next
  502.       end
  503. # Start
  504. # ◎
  505.       # \MSの場合
  506.       if c == "\052"
  507.         @now_text.sub!(/\[([0-9]+)\]/, "")
  508.         bcolor = $1.to_i
  509.         @bflag = true
  510.       end
  511.       # \MEの場合
  512.       if c == "\053"
  513.         @bflag = false
  514.         bcolor = 0
  515.       end
  516. # ◎
  517. # End
  518. # Start
  519. # ◎
  520.       if @bflag == true
  521.         if bcolor >= 0 and bcolor <= 7
  522.           bsize = self.contents.text_size(c).width
  523.           self.contents.fill_rect(4 + @x, 32 * @y, bsize, 32, text_color(bcolor))
  524.         end
  525.       end
  526. # ◎
  527. # End
  528.         if c == "\n"
  529.           if @lines >= $game_temp.choice_start
  530.             @cursor_width = [@cursor_width, @max_x - @face_indent].max
  531.           end
  532.           @lines += 1
  533.           @y += 1
  534.           @x = 0 + @indent + @face_indent
  535.           if @lines >= $game_temp.choice_start
  536.             @x = 8 + @indent + @face_indent
  537.           end
  538.           c = ""
  539.         end
  540.         if c != ""
  541.           # 文字描画
  542.           @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  543.         end
  544.         if Input.press?(Input::B)
  545.           text_not_skip = false
  546.         end
  547.       else
  548.         text_not_skip = true
  549.         break
  550.       end
  551.       # 終了判定
  552.       if text_not_skip
  553.         break
  554.       end
  555.     end
  556.     @write_wait += @write_speed
  557.     return
  558.   end
  559.   if @input_number_window != nil
  560.     @input_number_window.update
  561.     # 決定
  562.     if Input.trigger?(Input::C)
  563.       $game_system.se_play($data_system.decision_se)
  564.       $game_variables[$game_temp.num_input_variable_id] =
  565.       @input_number_window.number
  566.       $game_map.need_refresh = true
  567.       @input_number_window.dispose
  568.       @input_number_window = nil
  569.       terminate_message
  570.     end
  571.     return
  572.   end
  573.   if @contents_showing
  574.     if $game_temp.choice_max == 0
  575.       self.pause = true
  576.     end
  577.     # 取消
  578.     if Input.trigger?(Input::B)
  579.       if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  580.         $game_system.se_play($data_system.cancel_se)
  581.         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  582.         terminate_message
  583.       end
  584.     end
  585.     # 決定
  586.     if Input.trigger?(Input::C)
  587.       if $game_temp.choice_max > 0
  588.         $game_system.se_play($data_system.decision_se)
  589.         $game_temp.choice_proc.call(self.index)
  590.       end
  591.       if @mid_stop
  592.         @mid_stop = false
  593.         return
  594.       else
  595.         terminate_message
  596.       end
  597.     end
  598.     return
  599.   end
  600.   if @fade_out == false and $game_temp.message_text != nil
  601.     @contents_showing = true
  602.     $game_temp.message_window_showing = true
  603.     refresh
  604.     Graphics.frame_reset
  605.     self.visible = true
  606.     self.contents_opacity = 0
  607.   if @input_number_window != nil
  608.     @input_number_window.contents_opacity = 0
  609.   end
  610.     @fade_in = true
  611.     return
  612.   end
  613.   if self.visible
  614.     @fade_out = true
  615.     self.opacity -= 48
  616.     if self.opacity == 0
  617.       self.visible = false
  618.       @fade_out = false
  619.       $game_temp.message_window_showing = false
  620.     end
  621.     return
  622.   end
  623. end
  624. #--------------------------------------------------------------------------
  625. # ● 获得字符
  626. #--------------------------------------------------------------------------
  627. def get_character(parameter)
  628.   case parameter
  629.   when 0
  630.     return $game_player
  631.   else
  632.     events = $game_map.events
  633.     return events == nil ? nil : events[parameter]
  634.   end
  635. end
  636. #--------------------------------------------------------------------------
  637. # ● ウィンドウの位置と不透明度の設定
  638. #--------------------------------------------------------------------------
  639. def reset_window
  640.   # 判定
  641.   if @popchar >= 0
  642.     events = $game_map.events
  643.     if events != nil
  644.       character = get_character(@popchar)
  645.       x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  646.       y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  647.       self.x = x
  648.       self.y = y
  649.     end
  650.   elsif @popchar == -1
  651.     self.x = -4
  652.     self.y = -4
  653.     self.width = 648
  654.     self.height = 488
  655.   else
  656.     if $game_temp.in_battle
  657.        self.y = 48
  658.     else
  659.       case $game_system.message_position
  660.       when 0 # 上
  661.         self.y = 16
  662.       when 1 # 中
  663.         self.y = 160
  664.       when 2 # 下
  665.         self.y = 304
  666.       end
  667.       self.x = 80
  668.        if @face_bitmap == nil
  669.          self.width = 480
  670.        else
  671.          self.width = 600
  672.          self.x -= 60
  673.        end
  674.        self.height = 160
  675.      end
  676.    end
  677.   self.contents = Bitmap.new(self.width - 32, self.height - 32)
  678.    if @face_bitmap != nil
  679.      if @alignment
  680.        self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  681.      else
  682.        self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  683.          Rect.new(0, 0, 96, 96))
  684.      end
  685.    end
  686.    if @popchar == -1
  687.     self.opacity = 255
  688.     self.back_opacity = 0
  689.   elsif $game_system.message_frame == 0
  690.     self.opacity = 255
  691.     self.back_opacity = 100
  692.   else
  693.     self.opacity = 0
  694.     self.back_opacity = 100
  695.   end
  696. end
  697. #--------------------------------------------------------------------------
  698. # ● line_height
  699. #--------------------------------------------------------------------------
  700. # 返回値:行高
  701. #--------------------------------------------------------------------------
  702. def line_height
  703.   return 32
  704.   if self.contents.font.size >= 20 and self.contents.font.size <= 24
  705.     return 32
  706.   else
  707.     return self.contents.font.size * 15 / 10
  708.   end
  709. end
  710. #--------------------------------------------------------------------------
  711. # ● \V 变换
  712. #--------------------------------------------------------------------------
  713. def convart_value(option, index)
  714.   option == nil ? option = "" : nil
  715.   option.downcase!
  716.   case option
  717.     when "i"
  718.       unless $data_items[index].name == nil
  719.         r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  720.       end
  721.     when "w"
  722.       unless $data_weapons[index].name == nil
  723.         r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  724.       end
  725.     when "a"
  726.       unless $data_armors[index].name == nil
  727.         r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  728.       end
  729.     when "s"
  730.       unless $data_skills[index].name == nil
  731.         r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  732.       end
  733.     else
  734.     r = $game_variables[index]
  735.   end
  736.   r == nil ? r = "" : nil
  737.   return r
  738. end
  739. #--------------------------------------------------------------------------
  740. # ● 透過文字描画
  741. #--------------------------------------------------------------------------
  742. # target :描画対象。Bitmapクラスを指定。
  743. # x :x座標
  744. # y :y座標
  745. # str  :描画文字列
  746. # opacity:透過率(0~255)
  747. # 返回値 :文字幅(@x増加値)。
  748. #--------------------------------------------------------------------------
  749. def opacity_draw_text(target, x, y, str,opacity)
  750.   height = target.font.size
  751.   width = target.text_size(str).width
  752.   opacity = [[opacity, 0].max, 255].min
  753.   if opacity == 255
  754.     target.draw_text(x, y, width, height, str)
  755.     return width
  756.   else
  757.     if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  758.       @opacity_text_buf.dispose
  759.       @opacity_text_buf = Bitmap.new(width, height)
  760.     else
  761.       @opacity_text_buf.clear
  762.     end
  763.     @opacity_text_buf.font.size = target.font.size
  764.     @opacity_text_buf.draw_text(0, 0, width, height, str)
  765.     target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  766.   return width
  767.   end
  768. end
  769. def ruby_draw_text(target, x, y, str,opacity)
  770.   sizeback = target.font.size
  771.   target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  772.   rubysize = [rubysize, 6].max
  773.  
  774.   opacity = [[opacity, 0].max, 255].min
  775.   split_s = str.split(/,/)
  776.  
  777.   split_s[0] == nil ? split_s[0] = "" : nil
  778.   split_s[1] == nil ? split_s[1] = "" : nil
  779.  
  780.   height = sizeback + rubysize
  781.   width = target.text_size(split_s[0]).width
  782.  
  783.   target.font.size = rubysize
  784.   ruby_width = target.text_size(split_s[1]).width
  785.   target.font.size = sizeback
  786.  
  787.   buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  788.  
  789.   width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  790.  
  791.   if opacity == 255
  792.     target.font.size = rubysize
  793.     target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  794.     target.font.size = sizeback
  795.     target.draw_text(x, y, width, target.font.size, split_s[0])
  796.     return width
  797.   else
  798.     if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  799.       @opacity_text_buf.dispose
  800.       @opacity_text_buf = Bitmap.new(buf_width, height)
  801.     else
  802.       @opacity_text_buf.clear
  803.     end
  804.     @opacity_text_buf.font.size = rubysize
  805.     @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  806.     @opacity_text_buf.font.size = sizeback
  807.     @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  808.     if sub_x >= 0
  809.       target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  810.     else
  811.       target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  812.     end
  813.     return width
  814.   end
  815. end
  816. #--------------------------------------------------------------------------
  817. # ● 解放
  818. #--------------------------------------------------------------------------
  819. def dispose
  820.   terminate_message
  821.   if @gaiji_cache != nil
  822.     unless @gaiji_cache.disposed?
  823.       @gaiji_cache.dispose
  824.     end
  825.   end
  826.   unless @opacity_text_buf.disposed?
  827.     @opacity_text_buf.dispose
  828.   end
  829.   $game_temp.message_window_showing = false
  830.   if @input_number_window != nil
  831.     @input_number_window.dispose
  832.   end
  833.   super
  834. end
  835. #--------------------------------------------------------------------------
  836. # ● 矩形更新
  837. #--------------------------------------------------------------------------
  838. def update_cursor_rect
  839.   if @index >= 0
  840.     n = $game_temp.choice_start + @index
  841.     self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  842.   else
  843.     self.cursor_rect.empty
  844.   end
  845. end
  846. end
  847. #==============================================================================
  848. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  849. #==============================================================================
  850. class Window_Frame < Window_Base
  851. #--------------------------------------------------------------------------
  852. # ● オブジェクト初期化
  853. #--------------------------------------------------------------------------
  854. def initialize(x, y, width, height)
  855.   super(x, y, width, height)
  856.   self.contents = nil
  857.   self.back_opacity = 100
  858. end
  859. #--------------------------------------------------------------------------
  860. # ● 解放
  861. #--------------------------------------------------------------------------
  862. def dispose
  863.   super
  864.   end
  865. end
  866. #==============================================================================
  867. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  868. #==============================================================================
  869. class Air_Text < Window_Base
  870.  
  871.  
  872.   #参数的颜色自定义设定范围0-255
  873.   $ncolor0 = 255
  874.   $ncolor1 = 255
  875.   $ncolor2 = 255
  876.   #参数的颜色自定义设定范围0-255
  877.  
  878. #--------------------------------------------------------------------------
  879. # ● オブジェクト初期化
  880. #--------------------------------------------------------------------------
  881. def initialize(x, y, designate_text)
  882.   super(x-16, y-16, 32 + designate_text.size * 12, 56)
  883.   self.opacity = 0
  884.   self.back_opacity = 0
  885.   self.contents = Bitmap.new(self.width - 32, self.height - 32)
  886.   w = self.contents.width
  887.   h = self.contents.height
  888.  
  889.  
  890.     #颜色自定义设定范围0-255
  891.     self.contents.font.color = Color.new($ncolor0, $ncolor1, $ncolor2)
  892.     #颜色自定义设定范围0-255
  893.  
  894.  
  895.  
  896. #    self.contents.font.color = text_color(color)
  897.   self.contents.draw_text(0, 0, w, h, designate_text)
  898. end
  899. #--------------------------------------------------------------------------
  900. # ● 解放
  901. #--------------------------------------------------------------------------
  902. def dispose
  903.   self.contents.clear
  904.   super
  905. end
  906. end

作者: 小学生    时间: 2015-8-18 21:48
楼主可以把句子截图去底再显示图片




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1