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

Project1

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

[已经过期] 问一个有关对话框脚本的问题。。。

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
跳转到指定楼层
1
发表于 2014-12-10 21:58:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
这个脚本如果使用了\p让对话框显示在事件上方的话,那么不用\p[-2]他是不会变回系统默认的对话框,,,
怎么能让他只有在用了\p的控制符才会显示在事件上方,如果什么控制符都没有就是系统默认的对话框。。?
谢谢,
  1. #==============================================================================
  2. # ■ Window_Message
  3. #------------------------------------------------------------------------------
  4. #  显示文章、选择项等信息的窗口。
  5. #==============================================================================
  6. #
  7. # 系统默认控制符:
  8. # \|   :停顿片刻(20帧)
  9. # \~   :文字直接消失
  10. # \\:显示"\"这个符号
  11. # \c[0-7]:更改颜色
  12. # \g:显示金钱窗口
  13. # \name[1]:显示1号角色的姓名
  14. # \v[7]:显示7号变量的值
  15. #
  16. # 加强控制符(除非含义不同,否则命令不区分大小写):
  17. # \A:头像及姓名框靠左排列
  18. # \a:头像及姓名框靠右排列
  19. #
  20. # \b[50]:空50象素
  21. #
  22. # \d[4]:空4个字节(2个汉字)的位置
  23. #
  24. # \F[001]:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
  25. # \f[1]:在对话中显示1号角色的头像,没有的话同\F[1]效果
  26. #
  27. # \h[12]:改用12号字
  28. #
  29. # \i:下一行从这个位置开始
  30. #
  31. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  32. # \l[1]:在左边显示1号角色的半身像,没有的话同\L[1]效果
  33. # \Lk:清除左边的图像
  34. # 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
  35. #
  36. # \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
  37. # \m2[\n[1]]:用颜色2显示1号主角的姓名方框
  38. #
  39. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  40. #
  41. # 地图画面
  42. # \p[-1]:对话框全屏显示
  43. # \p:本事件上方出现对话框,如果上方空间不够则出现在下方
  44. # \p[0]:主人公上方(或下方)出现对话框
  45. # \p[1]:对话框出现在1号事件的上方(或下方)
  46. # \p[-2]:恢复系统的对话框位置
  47. # 用正数参数使用\p功能时,会自动调整对话框的大小和位置
  48. #
  49. # 战斗画面
  50. # \p[-1]:对话框最小化并居中显示
  51. # \p[0-3]:我方战斗者上方出现对话框
  52. # \p[4-11]:敌方战斗者上方出现对话框
  53. # \p[-2]:恢复系统的对话框位置
  54. # 用不是-2的参数使用\p功能时,会自动调整对话框的大小和位置
  55. #
  56. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  57. # \r[1]:在右边显示1号角色的半身像,没有的话同\R[1]效果
  58. # \Rk:清除右边的图像
  59. # 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
  60. #
  61. # \s:关闭打字效果
  62. # \s[0-9]:打字速度设定,越大越慢
  63. #
  64. # \t:显示游戏时间窗口
  65. #
  66. # \u[rrggbb]:直接以十六进制指定颜色,注意这里会把透明度重设为255
  67. #
  68. # \v[7:3]:显示7号变量的值,不足3位的话补零
  69. # \v[a7]:显示7号防具的图标和名称
  70. # \v[c7]:显示7号职业的名称
  71. # \v[e7]:显示7号属性的名称
  72. # \v[i7]:显示7号道具的图标和名称
  73. # \v[m7]:显示7号地图的名称
  74. #         (注:需配合$data_maps加载使用)
  75. # \v[n7]:显示7号角色的名称(和\n[7]重复,主要功能在下面)
  76. # \v[n7:7]:显示7号角色的灵巧,参数0-13分别表示等级、EXP、HP、SP、MaxHP、MaxSP
  77. #           力量、灵巧、速度、魔力、攻击、防御、魔防、回避
  78. # \v[s7]:显示7号特技的图标和名称
  79. # \v[t7]:显示7号状态的名称
  80. # \v[v7]:显示7号事件的名称,v0为显示本事件名称
  81. # \v[w7]:显示7号武器的图标和名称
  82. #
  83. # \w[20]:等待20帧(1秒)后自动关闭窗口
  84. #
  85. # \x[20]:本行之后文字定位到第20列,已超宽的话忽略
  86. #
  87. # \z[20]:打字到这里时停顿20帧,关闭打字效果的话忽略
  88. #
  89. #==============================================================================
  90. # 如果游戏加密请将以下内容解除注释
  91. # $encrypted = true
  92. # 如果要使用地图名显示功能请将以下内容解除注释
  93.   $data_maps = load_data("Data/MapInfos.rxdata")
  94. #==============================================================================

  95. class Window_Message < Window_Selectable
  96.   #--------------------------------------------------------------------------
  97.   # ● 初始化状态
  98.   #--------------------------------------------------------------------------
  99.   def initialize
  100.     super(40, 304, 560, 160)
  101.     self.contents = Bitmap.new(width - 32, height - 32)
  102.     self.visible = false
  103.     self.z = 9998
  104.     @fade_in = false
  105.     @fade_out = false
  106.     @contents_showing = false
  107.     @cursor_width = 0
  108.     self.active = false
  109.     self.index = -1
  110.     @popchar =  -2
  111.     @alignment = true
  112.     @wait_count = 0
  113.     @type_speed = 0
  114.     @type_wait = 0
  115.     @text_buffer = []
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 释放
  119.   #--------------------------------------------------------------------------
  120.   def dispose
  121.     terminate_message
  122.     $game_temp.message_window_showing = false
  123.     if @input_number_window != nil
  124.       @input_number_window.dispose
  125.     end
  126.     super
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 处理信息结束
  130.   #--------------------------------------------------------------------------
  131.   def terminate_message
  132.     self.active = false
  133.     self.pause = false
  134.     self.index = -1
  135.     self.contents.clear
  136.     # 清除显示中标志
  137.     @contents_showing = false
  138.     # 呼叫信息调用
  139.     if $game_temp.message_proc != nil
  140.       $game_temp.message_proc.call
  141.     end
  142.     # 清除文章、选择项、输入数值的相关变量
  143.     $game_temp.message_text = nil
  144.     $game_temp.message_proc = nil
  145.     $game_temp.choice_start = 99
  146.     $game_temp.choice_max = 0
  147.     $game_temp.choice_cancel_type = 0
  148.     $game_temp.choice_proc = nil
  149.     $game_temp.num_input_start = 99
  150.     $game_temp.num_input_variable_id = 0
  151.     $game_temp.num_input_digits_max = 0
  152.     # 开放金钱窗口
  153.     if @gold_window != nil
  154.       @gold_window.dispose
  155.       @gold_window = nil
  156.     end
  157.     # 开放时间窗口
  158.     if @playtime_window != nil
  159.       @playtime_window.dispose
  160.       @playtime_window = nil
  161.     end
  162.     # 开放姓名窗口
  163.     if @name_window != nil
  164.       @name_window.dispose
  165.       @name_window = nil
  166.     end
  167.     if @name_airtext != nil
  168.       @name_airtext.dispose
  169.       @name_airtext = nil
  170.     end
  171.     # 开放角色图片
  172.     if @right_picture != nil and @right_keep == true
  173.       @right_picture.dispose
  174.     end
  175.     if @left_picture != nil and @left_keep == true
  176.       @left_picture.dispose
  177.     end
  178.     @face_bitmap = nil
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 刷新
  182.   #--------------------------------------------------------------------------
  183.   def refresh
  184.     # 初期化
  185.     self.contents.clear
  186.     self.contents.font.color = normal_color
  187.     self.contents.font.size = Font.default_size
  188.     x = y = max_x = max_y = @indent = lines = 0
  189.     @left_keep = @right_keep = false
  190.     @face_indent = 0
  191.     @opacity = 255
  192.     @cursor_width = 0
  193.     @wait_set = 0
  194.     face = nil
  195.     if $game_temp.choice_start == 0
  196.       x = 8
  197.     end
  198.     if $game_temp.message_text != nil
  199.       text = $game_temp.message_text
  200.       
  201.       # 变量的替换
  202.       begin
  203.         last_text = text.clone
  204.         text.gsub!(/\\[Vv]\[([ACEIMNSTVWaceimnstvw]?)([0-9]+)[:]?([0-9]*)\]/) {
  205.           convert_value($1, $2.to_i, $3)
  206.         }
  207.       end until text == last_text
  208.       
  209.       # 显示后等待的判定
  210.       if (/\\[Ww]\[([0-9]+)\]/.match(text)) != nil
  211.         @wait_set = $1.to_i * 2 - 1
  212.         text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "" }
  213.       end
  214.       
  215.       # 文字位置的判定
  216.       if (/\\[Pp]\[([-0-9]+)\]/.match(text))!=nil then
  217.         @popchar = $1.to_i
  218.         if @popchar == -1 and not $game_temp.in_battle
  219.           x = @indent = 48
  220.           y = 4
  221.         end
  222.         text.gsub!(/\\[Pp]\[([-0-9]+)\]/) { "" }
  223.         if $game_temp.in_battle
  224.           if @popchar >= 4
  225.             @alignment = true
  226.           else
  227.             @alignment = false
  228.           end
  229.         end
  230.       elsif (/\\[Pp]/.match(text))!=nil then
  231.         @popchar = 1000
  232.         text.gsub!(/\\[Pp]/) { "" }
  233.       end
  234.       
  235.       #——对齐设置
  236.       if (/\\([Aa])/.match(text))!=nil then
  237.         if $1 == "A"
  238.           @alignment = true
  239.         else
  240.           @alignment = false
  241.         end
  242.         text.gsub!(/\\([Aa])/) { "" }
  243.       end
  244.       
  245.       #——头像设置
  246.       if (/\\([Ff])\[(.+?)\]/.match(text))!=nil then
  247.         face = "66rpg_" + $2 + "_f.png"
  248.         if $1 == "f" and $game_actors[$2.to_i] != nil
  249.           face = $game_actors[$2.to_i].battler_name + "_f.png"
  250.         end
  251.         if $encrypted or FileTest.exist?("Graphics/Battlers/#{face}")
  252.           @face_bitmap = Bitmap.new("Graphics/Battlers/#{face}")
  253.           if @alignment
  254.             @face_indent = 128
  255.             x += @face_indent
  256.           end
  257.         else
  258.           @face_bitmap = nil
  259.         end
  260.         text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
  261.       end
  262.       
  263.       #——左半身像设置
  264.       if (/\\([Ll])\[(.+?)\]/.match(text))!=nil then
  265.         face = "66rpg_" + $2 + "_h.png"
  266.         if $1 == "l" and $game_actors[$2.to_i] != nil
  267.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  268.         end
  269.         if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
  270.           if @left_picture != nil
  271.             @left_picture.dispose
  272.           end
  273.           @left_picture = Sprite.new
  274.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  275.           @left_picture.y = 480-@left_picture.bitmap.height
  276.           @left_picture.x = 0
  277.           @left_picture.mirror = true
  278.           @popchar = -2
  279.           text.gsub!(/\\([Ll])\[(.*?)\]/) { "" }
  280.         end        
  281.       end
  282.       
  283.       #——右半身像设置
  284.       if (/\\([Rr])\[(.+?)\]/.match(text))!=nil then
  285.         face = "66rpg_" + $2 + "_h.png"
  286.         if $1 == "r" and $game_actors[$2.to_i] != nil
  287.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  288.         end
  289.         if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
  290.           if @right_picture != nil
  291.             @right_picture.dispose
  292.           end
  293.           @right_picture = Sprite.new
  294.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  295.           @right_picture.y = 480-@right_picture.bitmap.height
  296.           @right_picture.x = 640-@right_picture.bitmap.width
  297.           @popchar = -2
  298.           text.gsub!(/\\([Rr])\[(.*?)\]/) { "" }
  299.         end
  300.       end
  301.       if (/\\[Rr][Kk]/.match(text)) != nil
  302.         @right_keep = true
  303.         text.sub!(/\\[Rr]k/) { "" }
  304.       end
  305.       if (/\\[Ll][Kk]/.match(text)) != nil
  306.         @left_keep = true
  307.         text.sub!(/\\[Ll]k/) { "" }
  308.       end
  309.       
  310.       # 替换人物姓名
  311.       text.gsub!(/\\[Nn]ame\[([0-9]+)\]/) do
  312.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  313.       end
  314.       
  315.       # 显示人物姓名
  316.       name_window_set = false
  317.       if (/\\[Nn]ame([0-9]*?)\[(.+?)\]/.match(text)) != nil
  318.         name_window_set = true
  319.         if $1 == ""
  320.           color = 0
  321.         else
  322.           color = $1.to_i
  323.         end
  324.         if color >= 0 and color <= 7
  325.           name_color = color
  326.         end
  327.         name_text = $2
  328.         text.gsub!(/\\[Nn]ame([0-9]*?)\[(.*?)\]/) { "" }
  329.       end
  330.       
  331.       # 打字效果设定
  332.       if (/\\[Ss]\[([0-9]+)\]/.match(text)) != nil
  333.         @type_speed = [$1.to_i, 9].min
  334.         text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "" }
  335.       # 关闭打字效果
  336.       elsif (/\\[Ss]/.match(text))!=nil then
  337.         @type_speed = -1
  338.         text.gsub!(/\\[Ss]/) { "" }
  339.       end
  340.       
  341.       # 窗口位置计算
  342.       if @popchar >= 0 or (@popchar == -1 and $game_temp.in_battle)
  343.         # 浮于事件上方的情况
  344.         max_x = 16
  345.         # 获得行数
  346.         textlines = text.split(/\n/)
  347.         cy = max_y = textlines.size
  348.         for i in 0..max_y - 1
  349.           line = plain_text(textlines[i])
  350.           if line == ""
  351.             cy -= 1
  352.             next
  353.           end
  354.           cx = contents.text_size(line).width
  355.           if i >= $game_temp.choice_start and $game_temp.choice_start > 0
  356.             cx += 16
  357.           end
  358.           # 获得最大宽度
  359.           max_x = cx if cx > max_x
  360.         end
  361.         # 计算宽度和高度
  362.         max_y = cy if cy < max_y
  363.         max_y = [max_y, 1].max
  364.         self.width = max_x + 32 + @face_indent
  365.         self.width += 16 if $game_temp.choice_start == 0
  366.         # 右边有头像的情况宽度再加 128
  367.         self.width += 128 if @face_bitmap != nil and not @alignment
  368.         max_x += 8 if $game_temp.choice_start == 0
  369.         # 有输入数值的情况下增加一行并调整宽度
  370.         if $game_temp.num_input_variable_id > 0
  371.           max_y += 1
  372.           dummy_bitmap = Bitmap.new(32, 32)
  373.           cursor_width = dummy_bitmap.text_size("0").width + 8
  374.           dummy_bitmap.dispose
  375.           cx = cursor_width * $game_temp.num_input_digits_max + 16
  376.           max_x = cx if cx > max_x
  377.         end
  378.         self.height = max_y * 32 + 32
  379.         # 有头像的情况高度定为 160
  380.         self.height = [self.height, 160].max if @face_bitmap != nil
  381.       # 不是浮于事件上方的情况
  382.       else
  383.         max_x = self.width - 12 - @face_indent
  384.         self.height = [text.split(/\n/).size * 32 + 32, 160].max
  385.       end
  386.       
  387.       # 绘制窗体样式
  388.       reset_window
  389.       
  390.       # 姓名框
  391.       if name_window_set
  392.         w = self.contents.text_size(name_text).width + 16
  393.         xn = @alignment ? self.x : self.x + self.width - w
  394.         if self.y < 20
  395.           if @popchar >= 0
  396.             self.y += self.height + 48 if @popchar >= 0
  397.           else
  398.             self.y = 36
  399.           end
  400.         end
  401.         yn = self.y - 20
  402.         @name_window = Window_Name.new(xn, yn, w)
  403.         @name_window.z = self.z + 1
  404.         @name_airtext = Window_AirText.new(xn + 8, yn + 8, name_text, name_color)
  405.         @name_airtext.z = self.z + 2
  406.         @name_window.back_opacity = self.back_opacity
  407.       end
  408.       
  409.       # 逐字打印文本
  410.       text.gsub!(/\\\\/) { "\000" }
  411.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  412.       text.gsub!(/\\[Gg]/) { "\002" }
  413.       text.gsub!(/\\[Tt]/) { "\003" }
  414.       text.gsub!(/\\[Uu]\[([0-9A-Fa-f]{6})\]/) { "\004[#{$1}]" }
  415.       text.gsub!(/\\[Xx]\[([0-9]+)\]/) { "\005[#{$1}]" }
  416.       text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\022[#{$1}]" }
  417.       text.gsub!(/\\[Ii]/) { "\023" }
  418.       text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  419.       text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  420.       text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  421.       text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
  422.       text.gsub!(/\\[~]/) { "\031" }
  423.       text.gsub!(/\\[|]/) { "\032" }
  424.       start_x = @indent + @face_indent
  425.       @text_buffer = []
  426.       c_wait = 0

  427.       while ((c = text.slice!(/./m)) != nil)
  428.         if c == "\000"
  429.           c = "\\"
  430.         end
  431.         if c == "\001"
  432.           text.sub!(/\[([0-9]+)\]/, "")
  433.           color = $1.to_i
  434.           if color >= 0 and color <= 7
  435.             if @type_speed < 0
  436.               self.contents.font.color = text_color(color)
  437.             else
  438.               @text_buffer.push([nil, -1, text_color(color)])
  439.             end
  440.           end
  441.           next
  442.         end
  443.         if c == "\002"
  444.           if @gold_window == nil
  445.             @gold_window = Window_Gold.new
  446.             @gold_window.x = 560 - @gold_window.width
  447.             if $game_temp.in_battle
  448.               @gold_window.y = 192
  449.             else
  450.               @gold_window.y = self.y >= 128 ? 32 : 384
  451.             end
  452.             @gold_window.opacity = self.opacity
  453.             @gold_window.back_opacity = self.back_opacity
  454.           end
  455.           next
  456.         end
  457.         if c == "\003"
  458.           if @playtime_window == nil
  459.             @playtime_window = Window_PlayTime.new
  460.             @playtime_window.x = 80
  461.             if $game_temp.in_battle
  462.               @playtime_window.y = 192
  463.             else
  464.               @playtime_window.y = self.y >= 128 ? 32 : 384
  465.             end
  466.             @playtime_window.opacity = self.opacity
  467.             @playtime_window.back_opacity = self.back_opacity
  468.           end
  469.           next
  470.         end
  471.         if c == "\004"
  472.           text.sub!(/\[([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\]/, "")
  473.           if @type_speed < 0
  474.             self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)
  475.           else
  476.             @text_buffer.push([nil, -1, Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)])
  477.           end
  478.           next
  479.         end
  480.         if c == "\005"
  481.           text.sub!(/\[([0-9]+)\]/, "")
  482.           tab = ($1.to_i - 1) * self.contents.text_size("0").width
  483.           x = start_x + tab if x < start_x + tab
  484.           next
  485.         end
  486.         
  487.         if c == "\022"
  488.           text.sub!(/\[([0-9]+)\]/, "")
  489.           c_wait += $1.to_i
  490.           next
  491.         end
  492.       
  493.         if c == "\023"
  494.           @indent = x
  495.           next
  496.         end
  497.         if c == "\024"
  498.           text.sub!(/\[([0-9]+)\]/, "")
  499.           if @type_speed < 0
  500.             self.contents.font.color.alpha = [[0, $1.to_i].max, 255].min
  501.           else
  502.             color = self.contents.font.color.clone
  503.             color.alpha = [[0, $1.to_i].max, 255].min
  504.             @text_buffer.push([nil, -1, color])
  505.           end
  506.           next
  507.         end
  508.         if c == "\025"
  509.           text.sub!(/\[([0-9]+)\]/, "")
  510.           self.contents.font.size = [[$1.to_i, 6].max, 32].min
  511.           if @type_speed >= 0
  512.             @text_buffer.push([nil, -1, self.contents.font.size])
  513.           end
  514.           next
  515.         end
  516.         if c == "\026"
  517.           text.sub!(/\[([0-9]+)\]/, "")
  518.           x += $1.to_i
  519.           next
  520.         end
  521.         if c == "\027"
  522.           text.sub!(/\[([0-9]+)\]/, "")
  523.           x += $1.to_i * self.contents.text_size("0").width
  524.           next
  525.         end

  526.         if c == "\030"
  527.           text.sub!(/\[(.*?)\]/, "")
  528.           if @type_speed < 0
  529.             self.contents.blt(x , y * line_height + 4, RPG::Cache.icon($1),
  530.               Rect.new(0, 0, 24, 24))
  531.           else
  532.             @text_buffer.push([Rect.new(x, y * line_height + 4, 24, 24),
  533.               c_wait, RPG::Cache.icon($1)])
  534.             c_wait = @type_speed
  535.           end
  536.           x += 24
  537.           next
  538.         end
  539.         if c == "\031"
  540.             terminate_message
  541.             return
  542.         end
  543.         if c == "\032"
  544.             c_wait +=  20
  545.             c = ""
  546.         end
  547.         if c == "\n"
  548.           if x == start_x and (@popchar != -2 and not $game_temp.in_battle)
  549.             $game_temp.choice_start -= 1
  550.             lines -= 1
  551.             y -= 1
  552.           end
  553.           if lines >= $game_temp.choice_start
  554.             @cursor_width = [@cursor_width, x - @face_indent].max
  555.           end
  556.           lines += 1
  557.           y += 1
  558.           start_x = @face_indent + @indent
  559.           x = start_x
  560.           if lines >= $game_temp.choice_start
  561.             x += 8
  562.           end
  563.           next
  564.         end
  565.         # 描绘文字
  566.         c_width = self.contents.text_size(c).width
  567.         c_height = line_height
  568.         if @type_speed < 0
  569.           self.contents.draw_text(x, c_height * y, c_width, c_height, c)
  570.         else
  571.           @text_buffer.push([Rect.new(x, c_height * y, c_width, c_height),
  572.             c_wait, c])
  573.           c_wait = @type_speed
  574.         end
  575.         x += c_width
  576.       end
  577.       @type_wait = @text_buffer[0][1] if @text_buffer.size > 0
  578.     end
  579.     if @type_speed < 0 and $game_temp.choice_max > 0
  580.       @item_max = $game_temp.choice_max
  581.       self.active = true
  582.       self.index = 0
  583.     end
  584.     if $game_temp.num_input_variable_id > 0
  585.       digits_max = $game_temp.num_input_digits_max
  586.       number = $game_variables[$game_temp.num_input_variable_id]
  587.       @input_number_window = Window_InputNumber.new(digits_max)
  588.       @input_number_window.number = number
  589.       @input_number_window.x = self.x + 8
  590.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  591.     end
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 更新
  595.   #--------------------------------------------------------------------------
  596.   def update
  597.     super
  598.     # 渐变的情况下
  599.     if @fade_in
  600.       self.contents_opacity += 24
  601.       if @input_number_window != nil
  602.         @input_number_window.contents_opacity += 24
  603.       end
  604.       if self.contents_opacity == 255
  605.         @fade_in = false
  606.       end
  607.       return
  608.     end
  609.     # 打字的情况下
  610.     if @text_buffer.size > 0
  611.       # 按键跳过打字
  612.       if Input.trigger?(Input::C) or Input.trigger?(Input::B)
  613.         type_next_char until @text_buffer.size == 0
  614.         return
  615.       end
  616.       # 等待打字延时
  617.       if @type_wait > 0
  618.         @type_wait -= 1
  619.       end
  620.       # 传送位图
  621.       if @type_wait <= 0
  622.         type_next_char
  623.       end
  624.       return
  625.     end
  626.     # 输入数值的情况下
  627.     if @input_number_window != nil
  628.       if @input_number_window.contents_opacity < 255
  629.         @input_number_window.contents_opacity += 24
  630.         return
  631.       end
  632.       @input_number_window.update
  633.       # 确定
  634.       if Input.trigger?(Input::C)
  635.         $game_system.se_play($data_system.decision_se)
  636.         $game_variables[$game_temp.num_input_variable_id] =
  637.           @input_number_window.number
  638.         $game_map.need_refresh = true
  639.         # 释放输入数值窗口
  640.         @input_number_window.dispose
  641.         @input_number_window = nil
  642.         terminate_message
  643.       end
  644.       return
  645.     end
  646.     # 显示信息中的情况下
  647.     if @contents_showing
  648.       # 如果不是在显示选择项中就显示暂停标志
  649.       if $game_temp.choice_max == 0
  650.         self.pause = true
  651.       end
  652.       # 取消
  653.       if Input.trigger?(Input::B)
  654.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  655.           $game_system.se_play($data_system.cancel_se)
  656.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  657.           terminate_message
  658.         end
  659.       end
  660.       # 确定
  661.       if Input.trigger?(Input::C)
  662.         if $game_temp.choice_max > 0
  663.           $game_system.se_play($data_system.decision_se)
  664.           $game_temp.choice_proc.call(self.index)
  665.         end
  666.         terminate_message
  667.       end
  668.       # 时间窗口可见的情况下
  669.       if @playtime_window != nil
  670.         @playtime_window.update
  671.       end
  672.       # 等待中的情况下
  673.       if @wait_count > 0
  674.         @wait_count -= 1
  675.         if @wait_count == 0
  676.           terminate_message
  677.         end
  678.       end
  679.       return
  680.     end
  681.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  682.     if @fade_out == false and $game_temp.message_text != nil
  683.       @contents_showing = true
  684.       $game_temp.message_window_showing = true
  685.       refresh
  686.       Graphics.frame_reset
  687.       @wait_count = 0
  688.       if @wait_set != 0
  689.         @wait_count = @wait_set
  690.       end
  691.       self.visible = true
  692.       if @type_speed < 0
  693.         self.contents_opacity = 0
  694.         @fade_in = true
  695.       else
  696.         self.contents_opacity = 255
  697.       end
  698.       if @input_number_window != nil
  699.         @input_number_window.contents_opacity = 0
  700.       end
  701.       return
  702.     end
  703.     # 没有可以显示的信息、但是窗口为可见的情况下
  704.     if self.visible
  705.       @fade_out = true
  706.       self.opacity -= 48
  707.       if self.opacity == 0
  708.         self.visible = false
  709.         @fade_out = false
  710.         $game_temp.message_window_showing = false
  711.       end
  712.       return
  713.     end
  714.   end
  715.   #--------------------------------------------------------------------------
  716.   # ● 获得角色
  717.   #--------------------------------------------------------------------------
  718.   def get_character(parameter)
  719.     case parameter
  720.     when 1000 # 本事件
  721.       return $game_system.map_interpreter.get_character(0)
  722.     when 0 # 角色
  723.       return $game_player
  724.     else # 其他事件
  725.       return $game_system.map_interpreter.get_character(parameter)
  726.     end
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 设置窗口位置与不透明度
  730.   #--------------------------------------------------------------------------
  731.   def reset_window
  732.     # 位置判定
  733.     if $game_temp.in_battle
  734.       if @popchar >= 4
  735.         x = $game_troop.enemies[@popchar - 4].screen_x - self.width / 2
  736.         y = $game_troop.enemies[@popchar - 4].screen_y - self.height - 100
  737.         self.x = [[x, 0].max, 640 - self.width].min
  738.         self.y = [y, 16].max
  739.       elsif @popchar >= 0
  740.         x = $game_party.actors[@popchar].screen_x - self.width / 2
  741.         y = $game_party.actors[@popchar].screen_y - self.height - 100
  742.         self.x = [[x, 0].max, 640 - self.width].min
  743.         self.y = [y, 16].max
  744.       elsif @popchar == -1
  745.         self.x = 320 - self.width / 2
  746.         self.y = 192 - self.height / 2
  747.       elsif @popchar == -2
  748.         self.y = 16
  749.       end
  750.     else
  751.       if @popchar >= 0
  752.         events = $game_map.events
  753.         if events != nil
  754.           character = get_character(@popchar)
  755.           if character != nil
  756.             x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
  757.             y = character.screen_y - 48 - self.height
  758.             y = character.screen_y if y < 4
  759.             y = [y, 476 - self.height].min
  760.             self.x = x
  761.             self.y = y
  762.           else
  763.             @popchar = -2
  764.           end
  765.         end
  766.       elsif @popchar == -1
  767.         self.x = -4
  768.         self.y = -4
  769.         self.width = 648
  770.         self.height = 488
  771.       else
  772.         case $game_system.message_position
  773.         when 0 # 上
  774.           self.y = 16
  775.         when 1 # 中
  776.           self.y = [240 - self.height / 2, 16].max
  777.         when 2 # 下
  778.           self.y = [[304, 464 - self.height].min, 16].max
  779.         end
  780.         if (@left_picture != nil and not @left_keep) or
  781.           (@right_picture != nil and not @right_keep)
  782.           self.y = [[304, 464 - self.height].min, 16].max
  783.         end
  784.         self.x = 60
  785.         if @face_bitmap == nil
  786.           self.width = 520
  787.         else
  788.           self.width = 600
  789.           self.x -= 60
  790.         end
  791.       end
  792.     end
  793.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  794.     if @face_bitmap != nil
  795.       if @alignment
  796.         self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  797.       else
  798.         self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  799.           Rect.new(0, 0, 96, 96))
  800.       end
  801.       @face_bitmap.dispose
  802.       @face_bitmap = nil
  803.     end
  804.     if @popchar == -1 and not $game_temp.in_battle
  805.       self.opacity = 255
  806.       self.back_opacity = 0
  807.     elsif $game_system.message_frame == 0
  808.       self.opacity = 255
  809.       self.back_opacity = 224
  810.     else
  811.       self.opacity = 0
  812.       self.back_opacity = 160
  813.     end
  814.   end
  815.   #--------------------------------------------------------------------------
  816.   # ● 行高
  817.   #--------------------------------------------------------------------------
  818.   def line_height
  819.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  820.       return 32
  821.     else
  822.       return self.contents.font.size * 15 / 10
  823.     end
  824.   end
  825.   #--------------------------------------------------------------------------
  826.   # ● 纯文本变换
  827.   #--------------------------------------------------------------------------
  828.   def plain_text(text)
  829.     plain = text.clone
  830.     plain.gsub!(/\\\\/) { "\\" }
  831.     plain.gsub!(/\\[CcGgTtUuOoHhIiZz]+(\[([0-9A-Fa-f]+)\])*/) { "" }
  832.     plain.gsub!(/\030\[(.*?)\]/) { " " * (24.0 / self.contents.font.size * 2).ceil }
  833.     plain.gsub!(/\\[Bb]\[([0-9]+)\]/) { " " * ($1.to_f / self.contents.font.size * 2).ceil }
  834.     plain.gsub!(/\\[Dd]\[([0-9]+)\]/) { " " * $1.to_i}
  835.     plain.gsub!(/^.*?\\[Xx]\[([0-9]+)\]/) { " " * ($1.to_i - 1)}
  836.     return plain
  837.   end  
  838.   #--------------------------------------------------------------------------
  839.   # ● \V 变换
  840.   #--------------------------------------------------------------------------
  841.   def convert_value(option, index, width)
  842.     option == nil ? option = "" : nil
  843.     option.downcase!
  844.     case option
  845.       when "a"
  846.         unless $data_armors[index].name == nil
  847.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  848.         end
  849.       when "c"
  850.         unless $data_classes[index] == nil
  851.           r = $data_classes[index].name
  852.         end
  853.       when "e"
  854.         unless $data_system.elements[index] == nil
  855.           r = $data_system.elements[index]
  856.         end
  857.       when "i"
  858.         unless $data_items[index].name == nil
  859.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  860.         end
  861.       when "m"
  862.         unless $data_maps == nil or $data_maps[index].name == nil
  863.           r = $data_maps[index].name
  864.         end
  865.       when "n"
  866.         unless $game_actors[index] == nil
  867.           case width
  868.           when "0"
  869.             r = $game_actors[index].level
  870.           when "1"
  871.             r = $game_actors[index].exp
  872.           when "2"
  873.             r = $game_actors[index].hp
  874.           when "3"
  875.             r = $game_actors[index].sp
  876.           when "4"
  877.             r = $game_actors[index].maxhp
  878.           when "5"
  879.             r = $game_actors[index].maxsp
  880.           when "6"
  881.             r = $game_actors[index].str
  882.           when "7"
  883.             r = $game_actors[index].dex
  884.           when "8"
  885.             r = $game_actors[index].agi
  886.           when "9"
  887.             r = $game_actors[index].int
  888.           when "10"
  889.             r = $game_actors[index].atk
  890.           when "11"
  891.             r = $game_actors[index].pdef
  892.           when "12"
  893.             r = $game_actors[index].mdef
  894.           when "13"
  895.             r = $game_actors[index].eva
  896.           else
  897.             r = $game_actors[index].name
  898.           end
  899.         end
  900.       when "s"
  901.         unless $data_skills[index].name == nil
  902.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  903.         end
  904.       when "t"
  905.         unless $data_states[index] == nil
  906.           r = $data_states[index].name
  907.         end
  908.       when "v"
  909.         unless $game_map == nil or index < 0 or
  910.           $game_system.map_interpreter.get_character(index) == nil
  911.           r = $game_system.map_interpreter.get_character(index).name
  912.         end
  913.       when "w"
  914.         unless $data_weapons[index].name == nil
  915.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  916.         end
  917.       else
  918.         if width != ""
  919.           r = sprintf("%0#{width}d", $game_variables[index])
  920.         else
  921.           r = $game_variables[index]
  922.         end
  923.     end
  924.     r == nil ? r = "" : nil
  925.     return r
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # ● 更新光标矩形
  929.   #--------------------------------------------------------------------------
  930.   def update_cursor_rect
  931.     if @index >= 0
  932.       n = $game_temp.choice_start + @index
  933.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  934.     else
  935.       self.cursor_rect.empty
  936.     end
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● 打印下一个字
  940.   #--------------------------------------------------------------------------
  941.   def type_next_char
  942.     c = @text_buffer.shift
  943.     rc = c[0]
  944.     case c[2]
  945.     when Bitmap
  946.       self.contents.blt(rc.x, rc.y, c[2], c[2].rect)
  947.     when Color
  948.       self.contents.font.color = c[2]
  949.     when Integer
  950.       self.contents.font.size = c[2]
  951.     else
  952.       self.contents.draw_text(rc, c[2])
  953.     end
  954.     if @text_buffer.size > 0
  955.       @type_wait = @text_buffer[0][1]
  956.       type_next_char if @type_wait == -1
  957.     else
  958.       if $game_temp.choice_max > 0
  959.         @item_max = $game_temp.choice_max
  960.         self.active = true
  961.         self.index = 0
  962.       end
  963.     end
  964.   end
  965. end

  966. #==============================================================================
  967. # ■ Window_Name
  968. #------------------------------------------------------------------------------
  969. #  显示对话人姓名的窗口。
  970. #==============================================================================

  971. class Window_Name < Window_Base
  972.   #--------------------------------------------------------------------------
  973.   # ● 初始化窗口
  974.   #--------------------------------------------------------------------------
  975.   def initialize(x, y, width)
  976.     super(x, y, width, 40)
  977.     self.contents = nil
  978.     self.back_opacity = 160
  979.   end
  980. end

  981. #==============================================================================
  982. # ■ Window_AirText
  983. #------------------------------------------------------------------------------
  984. #  显示对话人姓名的文字。
  985. #==============================================================================

  986. class Window_AirText < Window_Base
  987.   #--------------------------------------------------------------------------
  988.   # ● 初始化窗口
  989.   #--------------------------------------------------------------------------
  990.   def initialize(x, y, designate_text, color)
  991.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  992.     self.opacity = 0
  993.     self.back_opacity = 0
  994.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  995.     w = self.contents.width
  996.     h = self.contents.height
  997.     if color.is_a?(Integer)
  998.       self.contents.font.color = text_color(color)
  999.     else
  1000.       self.contents.font.color = color
  1001.     end
  1002.     self.contents.draw_text(0, 0, w, h, designate_text)
  1003.   end
  1004. end

  1005. #==============================================================================
  1006. # ■ Game_Event
  1007. #------------------------------------------------------------------------------
  1008. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  1009. # 在 Game_Map 类的内部使用。
  1010. #==============================================================================

  1011. class Game_Event < Game_Character
  1012.   #--------------------------------------------------------------------------
  1013.   # ● 事件名字
  1014.   #--------------------------------------------------------------------------
  1015.   def name
  1016.     return @event.name
  1017.   end
  1018. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-20 21:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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