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

Project1

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

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

[复制链接]

Lv3.寻梦者

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

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

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

x
用过了\p的命令以后,,,对话框的位置就一直在这个事件的上方。。。
比如
显示文章:\p 啊啊啊啊啊啊
显示文章:啊啊啊啊啊
第二行的对话框的位置不是RMXP默认的,也变成在该事件的上方了。。。怎么能弄回默认的对话框位置。。。

RUBY 代码复制
  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.  
  96. class Window_Message < Window_Selectable
  97.   #--------------------------------------------------------------------------
  98.   # ● 初始化状态
  99.   #--------------------------------------------------------------------------
  100.   def initialize
  101.     super(40, 304, 560, 160)
  102.     self.contents = Bitmap.new(width - 32, height - 32)
  103.     self.visible = false
  104.     self.z = 9998
  105.     @fade_in = false
  106.     @fade_out = false
  107.     @contents_showing = false
  108.     @cursor_width = 0
  109.     self.active = false
  110.     self.index = -1
  111.     @popchar = -2
  112.     @alignment = true
  113.     @wait_count = 0
  114.     @type_speed = 0
  115.     @type_wait = 0
  116.     @text_buffer = []
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 释放
  120.   #--------------------------------------------------------------------------
  121.   def dispose
  122.     terminate_message
  123.     $game_temp.message_window_showing = false
  124.     if @input_number_window != nil
  125.       @input_number_window.dispose
  126.     end
  127.     super
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 处理信息结束
  131.   #--------------------------------------------------------------------------
  132.   def terminate_message
  133.     self.active = false
  134.     self.pause = false
  135.     self.index = -1
  136.     self.contents.clear
  137.     # 清除显示中标志
  138.     @contents_showing = false
  139.     # 呼叫信息调用
  140.     if $game_temp.message_proc != nil
  141.       $game_temp.message_proc.call
  142.     end
  143.     # 清除文章、选择项、输入数值的相关变量
  144.     $game_temp.message_text = nil
  145.     $game_temp.message_proc = nil
  146.     $game_temp.choice_start = 99
  147.     $game_temp.choice_max = 0
  148.     $game_temp.choice_cancel_type = 0
  149.     $game_temp.choice_proc = nil
  150.     $game_temp.num_input_start = 99
  151.     $game_temp.num_input_variable_id = 0
  152.     $game_temp.num_input_digits_max = 0
  153.     # 开放金钱窗口
  154.     if @gold_window != nil
  155.       @gold_window.dispose
  156.       @gold_window = nil
  157.     end
  158.     # 开放时间窗口
  159.     if @playtime_window != nil
  160.       @playtime_window.dispose
  161.       @playtime_window = nil
  162.     end
  163.     # 开放姓名窗口
  164.     if @name_window != nil
  165.       @name_window.dispose
  166.       @name_window = nil
  167.     end
  168.     if @name_airtext != nil
  169.       @name_airtext.dispose
  170.       @name_airtext = nil
  171.     end
  172.     # 开放角色图片
  173.     if @right_picture != nil and @right_keep == true
  174.       @right_picture.dispose
  175.     end
  176.     if @left_picture != nil and @left_keep == true
  177.       @left_picture.dispose
  178.     end
  179.     @face_bitmap = nil
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 刷新
  183.   #--------------------------------------------------------------------------
  184.   def refresh
  185.     # 初期化
  186.     self.contents.clear
  187.     self.contents.font.color = normal_color
  188.     self.contents.font.size = Font.default_size
  189.     x = y = max_x = max_y = @indent = lines = 0
  190.     @left_keep = @right_keep = false
  191.     @face_indent = 0
  192.     @opacity = 255
  193.     @cursor_width = 0
  194.     @wait_set = 0
  195.     face = nil
  196.     if $game_temp.choice_start == 0
  197.       x = 8
  198.     end
  199.     if $game_temp.message_text != nil
  200.       text = $game_temp.message_text
  201.  
  202.       # 变量的替换
  203.       begin
  204.         last_text = text.clone
  205.         text.gsub!(/\\[Vv]\[([ACEIMNSTVWaceimnstvw]?)([0-9]+)[:]?([0-9]*)\]/) {
  206.           convert_value($1, $2.to_i, $3)
  207.         }
  208.       end until text == last_text
  209.  
  210.       # 显示后等待的判定
  211.       if (/\\[Ww]\[([0-9]+)\]/.match(text)) != nil
  212.         @wait_set = $1.to_i * 2 - 1
  213.         text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "" }
  214.       end
  215.  
  216.       # 文字位置的判定
  217.       if (/\\[Pp]\[([-0-9]+)\]/.match(text))!=nil then
  218.         @popchar = $1.to_i
  219.         if @popchar == -1 and not $game_temp.in_battle
  220.           x = @indent = 48
  221.           y = 4
  222.         end
  223.         text.gsub!(/\\[Pp]\[([-0-9]+)\]/) { "" }
  224.         if $game_temp.in_battle
  225.           if @popchar >= 4
  226.             @alignment = true
  227.           else
  228.             @alignment = false
  229.           end
  230.         end
  231.       elsif (/\\[Pp]/.match(text))!=nil then
  232.         @popchar = 1000
  233.         text.gsub!(/\\[Pp]/) { "" }
  234.       end
  235.  
  236.       #——对齐设置
  237.       if (/\\([Aa])/.match(text))!=nil then
  238.         if $1 == "A"
  239.           @alignment = true
  240.         else
  241.           @alignment = false
  242.         end
  243.         text.gsub!(/\\([Aa])/) { "" }
  244.       end
  245.  
  246.       #——头像设置
  247.       if (/\\([Ff])\[(.+?)\]/.match(text))!=nil then
  248.         face = "66rpg_" + $2 + "_f.png"
  249.         if $1 == "f" and $game_actors[$2.to_i] != nil
  250.           face = $game_actors[$2.to_i].battler_name + "_f.png"
  251.         end
  252.         if $encrypted or FileTest.exist?("Graphics/Battlers/#{face}")
  253.           @face_bitmap = Bitmap.new("Graphics/Battlers/#{face}")
  254.           if @alignment
  255.             @face_indent = 128
  256.             x += @face_indent
  257.           end
  258.         else
  259.           @face_bitmap = nil
  260.         end
  261.         text.gsub!(/\\([Ff])\[(.*?)\]/) { "" }
  262.       end
  263.  
  264.       #——左半身像设置
  265.       if (/\\([Ll])\[(.+?)\]/.match(text))!=nil then
  266.         face = "66rpg_" + $2 + "_h.png"
  267.         if $1 == "l" and $game_actors[$2.to_i] != nil
  268.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  269.         end
  270.         if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
  271.           if @left_picture != nil
  272.             @left_picture.dispose
  273.           end
  274.           @left_picture = Sprite.new
  275.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  276.           @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  277.           @left_picture.x = 0
  278.           @left_picture.mirror = true
  279.           @popchar = -2
  280.           text.gsub!(/\\([Ll])\[(.*?)\]/) { "" }
  281.         end        
  282.       end
  283.  
  284.       #——右半身像设置
  285.       if (/\\([Rr])\[(.+?)\]/.match(text))!=nil then
  286.         face = "66rpg_" + $2 + "_h.png"
  287.         if $1 == "r" and $game_actors[$2.to_i] != nil
  288.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  289.         end
  290.         if $encrypted or FileTest.exist?("Graphics/battlers/#{face}")
  291.           if @right_picture != nil
  292.             @right_picture.dispose
  293.           end
  294.           @right_picture = Sprite.new
  295.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  296.           @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  297.           @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  298.           @popchar = -2
  299.           text.gsub!(/\\([Rr])\[(.*?)\]/) { "" }
  300.         end
  301.       end
  302.       if (/\\[Rr][Kk]/.match(text)) != nil
  303.         @right_keep = true
  304.         text.sub!(/\\[Rr]k/) { "" }
  305.       end
  306.       if (/\\[Ll][Kk]/.match(text)) != nil
  307.         @left_keep = true
  308.         text.sub!(/\\[Ll]k/) { "" }
  309.       end
  310.  
  311.       # 替换人物姓名
  312.       text.gsub!(/\\[Nn]ame\[([0-9]+)\]/) do
  313.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  314.       end
  315.  
  316.       # 显示人物姓名
  317.       name_window_set = false
  318.       if (/\\[Nn]ame([0-9]*?)\[(.+?)\]/.match(text)) != nil
  319.         name_window_set = true
  320.         if $1 == ""
  321.           color = 0
  322.         else
  323.           color = $1.to_i
  324.         end
  325.         if color >= 0 and color <= 7
  326.           name_color = color
  327.         end
  328.         name_text = $2
  329.         text.gsub!(/\\[Nn]ame([0-9]*?)\[(.*?)\]/) { "" }
  330.       end
  331.  
  332.       # 打字效果设定
  333.       if (/\\[Ss]\[([0-9]+)\]/.match(text)) != nil
  334.         @type_speed = [$1.to_i, 9].min
  335.         text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "" }
  336.       # 关闭打字效果
  337.       elsif (/\\[Ss]/.match(text))!=nil then
  338.         @type_speed = -1
  339.         text.gsub!(/\\[Ss]/) { "" }
  340.       end
  341.  
  342.       # 窗口位置计算
  343.       if @popchar >= 0 or (@popchar == -1 and $game_temp.in_battle)
  344.         # 浮于事件上方的情况
  345.         max_x = 16
  346.         # 获得行数
  347.         textlines = text.split(/\n/)
  348.         cy = max_y = textlines.size
  349.         for i in 0..max_y - 1
  350.           line = plain_text(textlines[i])
  351.           if line == ""
  352.             cy -= 1
  353.             next
  354.           end
  355.           cx = contents.text_size(line).width
  356.           if i >= $game_temp.choice_start and $game_temp.choice_start > 0
  357.             cx += 16
  358.           end
  359.           # 获得最大宽度
  360.           max_x = cx if cx > max_x
  361.         end
  362.         # 计算宽度和高度
  363.         max_y = cy if cy < max_y
  364.         max_y = [max_y, 1].max
  365.         self.width = max_x + 32 + @face_indent
  366.         self.width += 16 if $game_temp.choice_start == 0
  367.         # 右边有头像的情况宽度再加 128
  368.         self.width += 128 if @face_bitmap != nil and not @alignment
  369.         max_x += 8 if $game_temp.choice_start == 0
  370.         # 有输入数值的情况下增加一行并调整宽度
  371.         if $game_temp.num_input_variable_id > 0
  372.           max_y += 1
  373.           dummy_bitmap = Bitmap.new(32, 32)
  374.           cursor_width = dummy_bitmap.text_size("0").width + 8
  375.           dummy_bitmap.dispose
  376.           cx = cursor_width * $game_temp.num_input_digits_max + 16
  377.           max_x = cx if cx > max_x
  378.         end
  379.         self.height = max_y * 32 + 32
  380.         # 有头像的情况高度定为 160
  381.         self.height = [self.height, 160].max if @face_bitmap != nil
  382.       # 不是浮于事件上方的情况
  383.       else
  384.         max_x = self.width - 12 - @face_indent
  385.         self.height = [text.split(/\n/).size * 32 + 32, 160].max
  386.       end
  387.  
  388.       # 绘制窗体样式
  389.       reset_window
  390.  
  391.       # 姓名框
  392.       if name_window_set
  393.         w = self.contents.text_size(name_text).width + 16
  394.         xn = @alignment ? self.x : self.x + self.width - w
  395.         if self.y < 20
  396.           if @popchar >= 0
  397.             self.y += self.height + 48 if @popchar >= 0
  398.           else
  399.             self.y = 36
  400.           end
  401.         end
  402.         yn = self.y - 20
  403.         @name_window = Window_Name.new(xn, yn, w)
  404.         @name_window.z = self.z + 1
  405.         @name_airtext = Window_AirText.new(xn + 8, yn + 8, name_text, name_color)
  406.         @name_airtext.z = self.z + 2
  407.         @name_window.back_opacity = self.back_opacity
  408.       end
  409.  
  410.       # 逐字打印文本
  411.       text.gsub!(/\\\\/) { "\000" }
  412.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  413.       text.gsub!(/\\[Gg]/) { "\002" }
  414.       text.gsub!(/\\[Tt]/) { "\003" }
  415.       text.gsub!(/\\[Uu]\[([0-9A-Fa-f]{6})\]/) { "\004[#{$1}]" }
  416.       text.gsub!(/\\[Xx]\[([0-9]+)\]/) { "\005[#{$1}]" }
  417.       text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\022[#{$1}]" }
  418.       text.gsub!(/\\[Ii]/) { "\023" }
  419.       text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  420.       text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  421.       text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  422.       text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\027[#{$1}]" }
  423.       text.gsub!(/\\[~]/) { "\031" }
  424.       text.gsub!(/\\[|]/) { "\032" }
  425.       start_x = @indent + @face_indent
  426.       @text_buffer = []
  427.       c_wait = 0
  428.  
  429.       while ((c = text.slice!(/./m)) != nil)
  430.         if c == "\000"
  431.           c = "\\"
  432.         end
  433.         if c == "\001"
  434.           text.sub!(/\[([0-9]+)\]/, "")
  435.           color = $1.to_i
  436.           if color >= 0 and color <= 7
  437.             if @type_speed < 0
  438.               self.contents.font.color = text_color(color)
  439.             else
  440.               @text_buffer.push([nil, -1, text_color(color)])
  441.             end
  442.           end
  443.           next
  444.         end
  445.         if c == "\002"
  446.           if @gold_window == nil
  447.             @gold_window = Window_Gold.new
  448.             @gold_window.x = 560 - @gold_window.width
  449.             if $game_temp.in_battle
  450.               @gold_window.y = 192
  451.             else
  452.               @gold_window.y = self.y >= 128 ? 32 : 384
  453.             end
  454.             @gold_window.opacity = self.opacity
  455.             @gold_window.back_opacity = self.back_opacity
  456.           end
  457.           next
  458.         end
  459.         if c == "\003"
  460.           if @playtime_window == nil
  461.             @playtime_window = Window_PlayTime.new
  462.             @playtime_window.x = 80
  463.             if $game_temp.in_battle
  464.               @playtime_window.y = 192
  465.             else
  466.               @playtime_window.y = self.y >= 128 ? 32 : 384
  467.             end
  468.             @playtime_window.opacity = self.opacity
  469.             @playtime_window.back_opacity = self.back_opacity
  470.           end
  471.           next
  472.         end
  473.         if c == "\004"
  474.           text.sub!(/\[([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\]/, "")
  475.           if @type_speed < 0
  476.             self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)
  477.           else
  478.             @text_buffer.push([nil, -1, Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)])
  479.           end
  480.           next
  481.         end
  482.         if c == "\005"
  483.           text.sub!(/\[([0-9]+)\]/, "")
  484.           tab = ($1.to_i - 1) * self.contents.text_size("0").width
  485.           x = start_x + tab if x < start_x + tab
  486.           next
  487.         end
  488.  
  489.         if c == "\022"
  490.           text.sub!(/\[([0-9]+)\]/, "")
  491.           c_wait += $1.to_i
  492.           next
  493.         end
  494.  
  495.         if c == "\023"
  496.           @indent = x
  497.           next
  498.         end
  499.         if c == "\024"
  500.           text.sub!(/\[([0-9]+)\]/, "")
  501.           if @type_speed < 0
  502.             self.contents.font.color.alpha = [[0, $1.to_i].max, 255].min
  503.           else
  504.             color = self.contents.font.color.clone
  505.             color.alpha = [[0, $1.to_i].max, 255].min
  506.             @text_buffer.push([nil, -1, color])
  507.           end
  508.           next
  509.         end
  510.         if c == "\025"
  511.           text.sub!(/\[([0-9]+)\]/, "")
  512.           self.contents.font.size = [[$1.to_i, 6].max, 32].min
  513.           if @type_speed >= 0
  514.             @text_buffer.push([nil, -1, self.contents.font.size])
  515.           end
  516.           next
  517.         end
  518.         if c == "\026"
  519.           text.sub!(/\[([0-9]+)\]/, "")
  520.           x += $1.to_i
  521.           next
  522.         end
  523.         if c == "\027"
  524.           text.sub!(/\[([0-9]+)\]/, "")
  525.           x += $1.to_i * self.contents.text_size("0").width
  526.           next
  527.         end
  528.  
  529.         if c == "\030"
  530.           text.sub!(/\[(.*?)\]/, "")
  531.           if @type_speed < 0
  532.             self.contents.blt(x , y * line_height + 4, RPG::Cache.icon($1),
  533.               Rect.new(0, 0, 24, 24))
  534.           else
  535.             @text_buffer.push([Rect.new(x, y * line_height + 4, 24, 24),
  536.               c_wait, RPG::Cache.icon($1)])
  537.             c_wait = @type_speed
  538.           end
  539.           x += 24
  540.           next
  541.         end
  542.         if c == "\031"
  543.             terminate_message
  544.             return
  545.         end
  546.         if c == "\032"
  547.             c_wait +=  20
  548.             c = ""
  549.         end
  550.         if c == "\n"
  551.           if x == start_x and (@popchar != -2 and not $game_temp.in_battle)
  552.             $game_temp.choice_start -= 1
  553.             lines -= 1
  554.             y -= 1
  555.           end
  556.           if lines >= $game_temp.choice_start
  557.             @cursor_width = [@cursor_width, x - @face_indent].max
  558.           end
  559.           lines += 1
  560.           y += 1
  561.           start_x = @face_indent + @indent
  562.           x = start_x
  563.           if lines >= $game_temp.choice_start
  564.             x += 8
  565.           end
  566.           next
  567.         end
  568.         # 描绘文字
  569.         c_width = self.contents.text_size(c).width
  570.         c_height = line_height
  571.         if @type_speed < 0
  572.           self.contents.draw_text(x, c_height * y, c_width, c_height, c)
  573.         else
  574.           @text_buffer.push([Rect.new(x, c_height * y, c_width, c_height),
  575.             c_wait, c])
  576.           c_wait = @type_speed
  577.         end
  578.         x += c_width
  579.       end
  580.       @type_wait = @text_buffer[0][1] if @text_buffer.size > 0
  581.     end
  582.     if @type_speed < 0 and $game_temp.choice_max > 0
  583.       @item_max = $game_temp.choice_max
  584.       self.active = true
  585.       self.index = 0
  586.     end
  587.     if $game_temp.num_input_variable_id > 0
  588.       digits_max = $game_temp.num_input_digits_max
  589.       number = $game_variables[$game_temp.num_input_variable_id]
  590.       @input_number_window = Window_InputNumber.new(digits_max)
  591.       @input_number_window.number = number
  592.       @input_number_window.x = self.x + 8
  593.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  594.     end
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   # ● 更新
  598.   #--------------------------------------------------------------------------
  599.   def update
  600.     super
  601.     # 渐变的情况下
  602.     if @fade_in
  603.       self.contents_opacity += 24
  604.       if @input_number_window != nil
  605.         @input_number_window.contents_opacity += 24
  606.       end
  607.       if self.contents_opacity == 255
  608.         @fade_in = false
  609.       end
  610.       return
  611.     end
  612.     # 打字的情况下
  613.     if @text_buffer.size > 0
  614.       # 按键跳过打字
  615.       if Input.trigger?(Input::C) or Input.trigger?(Input::B)
  616.         type_next_char until @text_buffer.size == 0
  617.         return
  618.       end
  619.       # 等待打字延时
  620.       if @type_wait > 0
  621.         @type_wait -= 1
  622.       end
  623.       # 传送位图
  624.       if @type_wait <= 0
  625.         type_next_char
  626.       end
  627.       return
  628.     end
  629.     # 输入数值的情况下
  630.     if @input_number_window != nil
  631.       if @input_number_window.contents_opacity < 255
  632.         @input_number_window.contents_opacity += 24
  633.         return
  634.       end
  635.       @input_number_window.update
  636.       # 确定
  637.       if Input.trigger?(Input::C)
  638.         $game_system.se_play($data_system.decision_se)
  639.         $game_variables[$game_temp.num_input_variable_id] =
  640.           @input_number_window.number
  641.         $game_map.need_refresh = true
  642.         # 释放输入数值窗口
  643.         @input_number_window.dispose
  644.         @input_number_window = nil
  645.         terminate_message
  646.       end
  647.       return
  648.     end
  649.     # 显示信息中的情况下
  650.     if @contents_showing
  651.       # 如果不是在显示选择项中就显示暂停标志
  652.       if $game_temp.choice_max == 0
  653.         self.pause = true
  654.       end
  655.       # 取消
  656.       if Input.trigger?(Input::B)
  657.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  658.           $game_system.se_play($data_system.cancel_se)
  659.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  660.           terminate_message
  661.         end
  662.       end
  663.       # 确定
  664.       if Input.trigger?(Input::C)
  665.         if $game_temp.choice_max > 0
  666.           $game_system.se_play($data_system.decision_se)
  667.           $game_temp.choice_proc.call(self.index)
  668.         end
  669.         terminate_message
  670.       end
  671.       # 时间窗口可见的情况下
  672.       if @playtime_window != nil
  673.         @playtime_window.update
  674.       end
  675.       # 等待中的情况下
  676.       if @wait_count > 0
  677.         @wait_count -= 1
  678.         if @wait_count == 0
  679.           terminate_message
  680.         end
  681.       end
  682.       return
  683.     end
  684.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  685.     if @fade_out == false and $game_temp.message_text != nil
  686.       @contents_showing = true
  687.       $game_temp.message_window_showing = true
  688.       refresh
  689.       Graphics.frame_reset
  690.       @wait_count = 0
  691.       if @wait_set != 0
  692.         @wait_count = @wait_set
  693.       end
  694.       self.visible = true
  695.       if @type_speed < 0
  696.         self.contents_opacity = 0
  697.         @fade_in = true
  698.       else
  699.         self.contents_opacity = 255
  700.       end
  701.       if @input_number_window != nil
  702.         @input_number_window.contents_opacity = 0
  703.       end
  704.       return
  705.     end
  706.     # 没有可以显示的信息、但是窗口为可见的情况下
  707.     if self.visible
  708.       @fade_out = true
  709.       self.opacity -= 48
  710.       if self.opacity == 0
  711.         self.visible = false
  712.         @fade_out = false
  713.         $game_temp.message_window_showing = false
  714.       end
  715.       return
  716.     end
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # ● 获得角色
  720.   #--------------------------------------------------------------------------
  721.   def get_character(parameter)
  722.     case parameter
  723.     when 1000 # 本事件
  724.       return $game_system.map_interpreter.get_character(0)
  725.     when 0 # 角色
  726.       return $game_player
  727.     else # 其他事件
  728.       return $game_system.map_interpreter.get_character(parameter)
  729.     end
  730.   end
  731.   #--------------------------------------------------------------------------
  732.   # ● 设置窗口位置与不透明度
  733.   #--------------------------------------------------------------------------
  734.   def reset_window
  735.     # 位置判定
  736.     if $game_temp.in_battle
  737.       if @popchar >= 4
  738.         x = $game_troop.enemies[@popchar - 4].screen_x - self.width / 2
  739.         y = $game_troop.enemies[@popchar - 4].screen_y - self.height - 100
  740.         self.x = [[x, 0].max, 640 - self.width].min
  741.         self.y = [y, 16].max
  742.       elsif @popchar >= 0
  743.         x = $game_party.actors[@popchar].screen_x - self.width / 2
  744.         y = $game_party.actors[@popchar].screen_y - self.height - 100
  745.         self.x = [[x, 0].max, 640 - self.width].min
  746.         self.y = [y, 16].max
  747.       elsif @popchar == -1
  748.         self.x = 320 - self.width / 2
  749.         self.y = 192 - self.height / 2
  750.       elsif @popchar == -2
  751.         self.y = 16
  752.       end
  753.     else
  754.       if @popchar >= 0
  755.         events = $game_map.events
  756.         if events != nil
  757.           character = get_character(@popchar)
  758.           if character != nil
  759.             x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
  760.             y = character.screen_y - 48 - self.height
  761.             y = character.screen_y if y < 4
  762.             y = [y, 476 - self.height].min
  763.             self.x = x
  764.             self.y = y
  765.           else
  766.             @popchar = -2
  767.           end
  768.         end
  769.       elsif @popchar == -1
  770.         self.x = -4
  771.         self.y = -4
  772.         self.width = 648
  773.         self.height = 488
  774.       else
  775.         case $game_system.message_position
  776.         when 0 # 上
  777.           self.y = 16
  778.         when 1 # 中
  779.           self.y = [240 - self.height / 2, 16].max
  780.         when 2 # 下
  781.           self.y = [[304, 464 - self.height].min, 16].max
  782.         end
  783.         if (@left_picture != nil and not @left_keep) or
  784.           (@right_picture != nil and not @right_keep)
  785.           self.y = [[304, 464 - self.height].min, 16].max
  786.         end
  787.         self.x = 60
  788.         if @face_bitmap == nil
  789.           self.width = 520
  790.         else
  791.           self.width = 600
  792.           self.x -= 60
  793.         end
  794.       end
  795.     end
  796.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  797.     if @face_bitmap != nil
  798.       if @alignment
  799.         self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  800.       else
  801.         self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  802.           Rect.new(0, 0, 96, 96))
  803.       end
  804.       @face_bitmap.dispose
  805.       @face_bitmap = nil
  806.     end
  807.     if @popchar == -1 and not $game_temp.in_battle
  808.       self.opacity = 255
  809.       self.back_opacity = 0
  810.     elsif $game_system.message_frame == 0
  811.       self.opacity = 255
  812.       self.back_opacity = 224
  813.     else
  814.       self.opacity = 0
  815.       self.back_opacity = 160
  816.     end
  817.   end
  818.   #--------------------------------------------------------------------------
  819.   # ● 行高
  820.   #--------------------------------------------------------------------------
  821.   def line_height
  822.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  823.       return 32
  824.     else
  825.       return self.contents.font.size * 15 / 10
  826.     end
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 纯文本变换
  830.   #--------------------------------------------------------------------------
  831.   def plain_text(text)
  832.     plain = text.clone
  833.     plain.gsub!(/\\\\/) { "\\" }
  834.     plain.gsub!(/\\[CcGgTtUuOoHhIiZz]+(\[([0-9A-Fa-f]+)\])*/) { "" }
  835.     plain.gsub!(/\030\[(.*?)\]/) { " " * (24.0 / self.contents.font.size * 2).ceil }
  836.     plain.gsub!(/\\[Bb]\[([0-9]+)\]/) { " " * ($1.to_f / self.contents.font.size * 2).ceil }
  837.     plain.gsub!(/\\[Dd]\[([0-9]+)\]/) { " " * $1.to_i}
  838.     plain.gsub!(/^.*?\\[Xx]\[([0-9]+)\]/) { " " * ($1.to_i - 1)}
  839.     return plain
  840.   end  
  841.   #--------------------------------------------------------------------------
  842.   # ● \V 变换
  843.   #--------------------------------------------------------------------------
  844.   def convert_value(option, index, width)
  845.     option == nil ? option = "" : nil
  846.     option.downcase!
  847.     case option
  848.       when "a"
  849.         unless $data_armors[index].name == nil
  850.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  851.         end
  852.       when "c"
  853.         unless $data_classes[index] == nil
  854.           r = $data_classes[index].name
  855.         end
  856.       when "e"
  857.         unless $data_system.elements[index] == nil
  858.           r = $data_system.elements[index]
  859.         end
  860.       when "i"
  861.         unless $data_items[index].name == nil
  862.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  863.         end
  864.       when "m"
  865.         unless $data_maps == nil or $data_maps[index].name == nil
  866.           r = $data_maps[index].name
  867.         end
  868.       when "n"
  869.         unless $game_actors[index] == nil
  870.           case width
  871.           when "0"
  872.             r = $game_actors[index].level
  873.           when "1"
  874.             r = $game_actors[index].exp
  875.           when "2"
  876.             r = $game_actors[index].hp
  877.           when "3"
  878.             r = $game_actors[index].sp
  879.           when "4"
  880.             r = $game_actors[index].maxhp
  881.           when "5"
  882.             r = $game_actors[index].maxsp
  883.           when "6"
  884.             r = $game_actors[index].str
  885.           when "7"
  886.             r = $game_actors[index].dex
  887.           when "8"
  888.             r = $game_actors[index].agi
  889.           when "9"
  890.             r = $game_actors[index].int
  891.           when "10"
  892.             r = $game_actors[index].atk
  893.           when "11"
  894.             r = $game_actors[index].pdef
  895.           when "12"
  896.             r = $game_actors[index].mdef
  897.           when "13"
  898.             r = $game_actors[index].eva
  899.           else
  900.             r = $game_actors[index].name
  901.           end
  902.         end
  903.       when "s"
  904.         unless $data_skills[index].name == nil
  905.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  906.         end
  907.       when "t"
  908.         unless $data_states[index] == nil
  909.           r = $data_states[index].name
  910.         end
  911.       when "v"
  912.         unless $game_map == nil or index < 0 or
  913.           $game_system.map_interpreter.get_character(index) == nil
  914.           r = $game_system.map_interpreter.get_character(index).name
  915.         end
  916.       when "w"
  917.         unless $data_weapons[index].name == nil
  918.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  919.         end
  920.       else
  921.         if width != ""
  922.           r = sprintf("%0#{width}d", $game_variables[index])
  923.         else
  924.           r = $game_variables[index]
  925.         end
  926.     end
  927.     r == nil ? r = "" : nil
  928.     return r
  929.   end
  930.   #--------------------------------------------------------------------------
  931.   # ● 更新光标矩形
  932.   #--------------------------------------------------------------------------
  933.   def update_cursor_rect
  934.     if @index >= 0
  935.       n = $game_temp.choice_start + @index
  936.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  937.     else
  938.       self.cursor_rect.empty
  939.     end
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # ● 打印下一个字
  943.   #--------------------------------------------------------------------------
  944.   def type_next_char
  945.     c = @text_buffer.shift
  946.     rc = c[0]
  947.     case c[2]
  948.     when Bitmap
  949.       self.contents.blt(rc.x, rc.y, c[2], c[2].rect)
  950.     when Color
  951.       self.contents.font.color = c[2]
  952.     when Integer
  953.       self.contents.font.size = c[2]
  954.     else
  955.       self.contents.draw_text(rc, c[2])
  956.     end
  957.     if @text_buffer.size > 0
  958.       @type_wait = @text_buffer[0][1]
  959.       type_next_char if @type_wait == -1
  960.     else
  961.       if $game_temp.choice_max > 0
  962.         @item_max = $game_temp.choice_max
  963.         self.active = true
  964.         self.index = 0
  965.       end
  966.     end
  967.   end
  968. end
  969.  
  970. #==============================================================================
  971. # ■ Window_Name
  972. #------------------------------------------------------------------------------
  973. #  显示对话人姓名的窗口。
  974. #==============================================================================
  975.  
  976. class Window_Name < Window_Base
  977.   #--------------------------------------------------------------------------
  978.   # ● 初始化窗口
  979.   #--------------------------------------------------------------------------
  980.   def initialize(x, y, width)
  981.     super(x, y, width, 40)
  982.     self.contents = nil
  983.     self.back_opacity = 160
  984.   end
  985. end
  986.  
  987. #==============================================================================
  988. # ■ Window_AirText
  989. #------------------------------------------------------------------------------
  990. #  显示对话人姓名的文字。
  991. #==============================================================================
  992.  
  993. class Window_AirText < Window_Base
  994.   #--------------------------------------------------------------------------
  995.   # ● 初始化窗口
  996.   #--------------------------------------------------------------------------
  997.   def initialize(x, y, designate_text, color)
  998.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  999.     self.opacity = 0
  1000.     self.back_opacity = 0
  1001.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  1002.     w = self.contents.width
  1003.     h = self.contents.height
  1004.     if color.is_a?(Integer)
  1005.       self.contents.font.color = text_color(color)
  1006.     else
  1007.       self.contents.font.color = color
  1008.     end
  1009.     self.contents.draw_text(0, 0, w, h, designate_text)
  1010.   end
  1011. end
  1012.  
  1013. #==============================================================================
  1014. # ■ Game_Event
  1015. #------------------------------------------------------------------------------
  1016. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  1017. # 在 Game_Map 类的内部使用。
  1018. #==============================================================================
  1019.  
  1020. class Game_Event < Game_Character
  1021.   #--------------------------------------------------------------------------
  1022.   # ● 事件名字
  1023.   #--------------------------------------------------------------------------
  1024.   def name
  1025.     return @event.name
  1026.   end
  1027. end

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
2
 楼主| 发表于 2014-12-4 22:18:16 | 只看该作者
我仔细看了一下介绍,,,
\p[-2]是恢复系统的对话框位置
怎么能让他在文章前面什么都不加就是恢复系统的对话框位置?
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
3
 楼主| 发表于 2014-12-5 21:44:59 | 只看该作者
求大神解答。。。。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1288
在线时间
354 小时
注册时间
2009-9-14
帖子
328
4
 楼主| 发表于 2014-12-7 21:55:25 | 只看该作者
@芯☆淡茹水 {:2_276:}
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 12:54

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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