搜索附件  
同能RPG制作大师 附件中心 同能RM技术讨论区 RPG Maker XP 讨论区 6R增强对话框升级版: 6R_Dialog.zip

6R增强对话框升级版: 6R_Dialog.zip

 

6R增强对话框升级版:
这个对话框多久没人维护了……是不是大家都用fuki去了
小日本写的东西,6R翻译了一遍。原来的刷新机制给搞的一塌糊涂,用了一大堆临时变量去保存状态……

姐抽空维护了一下这个玩意
1)增加了一堆\v变换内容
2)去掉了打字声效,win7下调midi格式的se和me伤不起
3)附带按C键或B键跳过打字效果
4)打字效果关掉或改速度是长时生效的
5)部分命令字修改(如\name,全部字母化),说话人姓名支持颜色表记

以后姐有空整合一下fuki吧,看心情,这个对素材要求还是有一些的,当然可以切窗口的角当sprite后angel=45/225来搞……太山寨……

其他看注释,姐不想多说,累……

RUBY 代码
  1. #==============================================================================
  2. # ■ Window_Message
  3. #------------------------------------------------------------------------------
  4. #  显示文章、选择项等信息的窗口。
  5. #==============================================================================
  6. #
  7. # 系统默认控制符:
  8. # \\:显示""这个符号
  9. # \c[0-7]:更改颜色
  10. # \g:显示金钱窗口
  11. # \n[1]:显示1号角色的姓名
  12. # \v[7]:显示7号变量的值
  13. #
  14. # 加强控制符(除非含义不同,否则命令不区分大小写):
  15. # \A:头像及姓名框靠左排列
  16. # \a:头像及姓名框靠右排列
  17. #
  18. # \b[50]:空50象素
  19. #
  20. # \d[4]:空4个字节(2个汉字)的位置
  21. #
  22. # \F[001]:在对话显示头像“Graphics/battlers/66rpg_001_f.png”
  23. # \f[1]:在对话中显示1号角色的头像,没有的话同\F[1]效果
  24. #
  25. # \h[12]:改用12号字
  26. #
  27. # \i:下一行从这个位置开始
  28. #
  29. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  30. # \l[1]:在左边显示1号角色的半身像,没有的话同\L[1]效果
  31. # \Lk:清除左边的图像
  32. # 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
  33. #
  34. # \m[李逍遥]:用默认颜色(颜色0)显示一个“李逍遥”方框,表示说话人姓名
  35. # \m2[\n[1]]:用颜色2显示1号主角的姓名方框
  36. #
  37. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  38. #
  39. # 地图画面
  40. # \p[-1]:对话框全屏显示
  41. # \p:本事件上方出现对话框,如果上方空间不够则出现在下方
  42. # \p[0]:主人公上方(或下方)出现对话框
  43. # \p[1]:对话框出现在1号事件的上方(或下方)
  44. # \p[-2]:恢复系统的对话框位置
  45. # 用正数参数使用\p功能时,会自动调整对话框的大小和位置
  46. #
  47. # 战斗画面
  48. # \p[-1]:对话框最小化并居中显示
  49. # \p[0-3]:我方战斗者上方出现对话框
  50. # \p[4-11]:敌方战斗者上方出现对话框
  51. # \p[-2]:恢复系统的对话框位置
  52. # 用不是-2的参数使用\p功能时,会自动调整对话框的大小和位置
  53. #
  54. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”
  55. # \r[1]:在右边显示1号角色的半身像,没有的话同\R[1]效果
  56. # \Rk:清除右边的图像
  57. # 使用半身像功能将把对话框固定在屏幕下方,无视\p和[显示文章选项]的设定
  58. #
  59. # \s:关闭打字效果
  60. # \s[0-9]:打字速度设定,越大越慢
  61. #
  62. # \t:显示游戏时间窗口
  63. #
  64. # \u[rrggbb]:直接以十六进制指定颜色,注意这里会把透明度重设为255
  65. #
  66. # \v[7:3]:显示7号变量的值,不足3位的话补零
  67. # \v[a7]:显示7号防具的图标和名称
  68. # \v[c7]:显示7号职业的名称
  69. # \v[e7]:显示7号属性的名称
  70. # \v[i7]:显示7号道具的图标和名称
  71. # \v[m7]:显示7号地图的名称
  72. #         (注:需配合$data_maps加载使用)
  73. # \v[n7]:显示7号角色的名称(和\n[7]重复,主要功能在下面)
  74. # \v[n7:7]:显示7号角色的灵巧,参数0-13分别表示等级、EXP、HP、SP、MaxHP、MaxSP
  75. #           力量、灵巧、速度、魔力、攻击、防御、魔防、回避
  76. # \v[s7]:显示7号特技的图标和名称
  77. # \v[t7]:显示7号状态的名称
  78. # \v[v7]:显示7号事件的名称,v0为显示本事件名称
  79. # \v[w7]:显示7号武器的图标和名称
  80. #
  81. # \w[20]:等待20帧(1秒)后自动关闭窗口
  82. #
  83. # \x[20]:本行之后文字定位到第20列,已超宽的话忽略
  84. #
  85. # \z[20]:打字到这里时停顿20帧,关闭打字效果的话忽略
  86. #
  87. #==============================================================================
  88. # 如果游戏加密请将以下内容解除注释
  89. # $encrypted = true
  90. # 如果要使用地图名显示功能请将以下内容解除注释
  91.   $data_maps = load_data("Data/MapInfos.rxdata")
  92. #==============================================================================
  93. class Window_Message < Window_Selectable
  94.   #--------------------------------------------------------------------------
  95.   # ● 初始化状态
  96.   #--------------------------------------------------------------------------
  97.   def initialize
  98.     super(80, 304, 480, 160)
  99.     self.contents = Bitmap.new(width - 32, height - 32)
  100.     self.visible = false
  101.     self.z = 9998
  102.     @fade_in = false
  103.     @fade_out = false
  104.     @contents_showing = false
  105.     @cursor_width = 0
  106.     self.active = false
  107.     self.index = -1
  108.     @popchar = -2
  109.     @alignment = true
  110.     @wait_count = 0
  111.     @type_speed = 0
  112.     @type_wait = 0
  113.     @text_buffer = []
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 释放
  117.   #--------------------------------------------------------------------------
  118.   def dispose
  119.     terminate_message
  120.     $game_temp.message_window_showing = false
  121.     if@input_number_window != nil
  122.       @input_number_window.dispose
  123.     end
  124.     super
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 处理信息结束
  128.   #--------------------------------------------------------------------------
  129.   def terminate_message
  130.     self.active = false
  131.     self.pause = false
  132.     self.index = -1
  133.     self.contents.clear
  134.     # 清除显示中标志
  135.     @contents_showing = false
  136.     # 呼叫信息调用
  137.     if$game_temp.message_proc != nil
  138.       $game_temp.message_proc.call
  139.     end
  140.     # 清除文章、选择项、输入数值的相关变量
  141.     $game_temp.message_text = nil
  142.     $game_temp.message_proc = nil
  143.     $game_temp.choice_start = 99
  144.     $game_temp.choice_max = 0
  145.     $game_temp.choice_cancel_type = 0
  146.     $game_temp.choice_proc = nil
  147.     $game_temp.num_input_start = 99
  148.     $game_temp.num_input_variable_id = 0
  149.     $game_temp.num_input_digits_max = 0
  150.     # 开放金钱窗口
  151.     if@gold_window != nil
  152.       @gold_window.dispose
  153.       @gold_window = nil
  154.     end
  155.     # 开放时间窗口
  156.     if@playtime_window != nil
  157.       @playtime_window.dispose
  158.       @playtime_window = nil
  159.     end
  160.     # 开放姓名窗口
  161.     if@name_window != nil
  162.       @name_window.dispose
  163.       @name_window = nil
  164.     end
  165.     if@name_airtext != nil
  166.       @name_airtext.dispose
  167.       @name_airtext = nil
  168.     end
  169.     # 开放角色图片
  170.     if@right_picture != niland@right_keep == true
  171.       @right_picture.dispose
  172.     end
  173.     if@left_picture != niland@left_keep == true
  174.       @left_picture.dispose
  175.     end
  176.     @face_bitmap = nil
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 刷新
  180.   #--------------------------------------------------------------------------
  181.   def refresh
  182.     # 初期化
  183.     self.contents.clear
  184.     self.contents.font.color = normal_color
  185.     self.contents.font.size = Font.default_size
  186.     x = y = max_x = max_y = @indent = lines = 0
  187.     @left_keep = @right_keep = false
  188.     @face_indent = 0
  189.     @opacity = 255
  190.     @cursor_width = 0
  191.     @wait_set = 0
  192.     face = nil
  193.     if$game_temp.choice_start == 0
  194.       x = 8
  195.     end
  196.     if$game_temp.message_text != nil
  197.       text = $game_temp.message_text
  198.       # 变量的替换
  199.       begin
  200.         last_text = text.clone
  201.         text.gsub!(/\\[Vv]\[([ACEIMNSTVWaceimnstvw]?)([0-9]+)[:]?([0-9]*)\]/){
  202.           convert_value($1, $2.to_i, $3)
  203.         }
  204.       enduntil text == last_text
  205.       # 显示后等待的判定
  206.       if(/\\[Ww]\[([0-9]+)\]/.match(text)) != nil
  207.         @wait_set = $1.to_i * 2 - 1
  208.         text.gsub!(/\\[Ww]\[([0-9]+)\]/){""}
  209.       end
  210.       # 文字位置的判定
  211.       if(/\\[Pp]\[([-0-9]+)\]/.match(text))!=nilthen
  212.         @popchar = $1.to_i
  213.         if@popchar == -1andnot$game_temp.in_battle
  214.           x = @indent = 48
  215.           y = 4
  216.         end
  217.         text.gsub!(/\\[Pp]\[([-0-9]+)\]/){""}
  218.         if$game_temp.in_battle
  219.           if@popchar >= 4
  220.             @alignment = true
  221.           else
  222.             @alignment = false
  223.           end
  224.         end
  225.       elsif(/\\[Pp]/.match(text))!=nilthen
  226.         @popchar = 1000
  227.         text.gsub!(/\\[Pp]/){""}
  228.       end
  229.       #——对齐设置
  230.       if(/\\([Aa])/.match(text))!=nilthen
  231.         if $1 == "A"
  232.           @alignment = true
  233.         else
  234.           @alignment = false
  235.         end
  236.         text.gsub!(/\\([Aa])/){""}
  237.       end
  238.       #——头像设置
  239.       if(/\\([Ff])\[(.+?)\]/.match(text))!=nilthen
  240.         face = "66rpg_" + $2 + "_f.png"
  241.         if $1 == "f"and$game_actors[$2.to_i] != nil
  242.           face = $game_actors[$2.to_i].battler_name + "_f.png"
  243.         end
  244.         if$encryptedorFileTest.exist?("Graphics/Battlers/#{face}")
  245.           @face_bitmap = Bitmap.new("Graphics/Battlers/#{face}")
  246.           if@alignment
  247.             @face_indent = 128
  248.             x += @face_indent
  249.           end
  250.         else
  251.           @face_bitmap = nil
  252.         end
  253.         text.gsub!(/\\([Ff])\[(.*?)\]/){""}
  254.       end
  255.       #——左半身像设置
  256.       if(/\\([Ll])\[(.+?)\]/.match(text))!=nilthen
  257.         face = "66rpg_" + $2 + "_h.png"
  258.         if $1 == "l"and$game_actors[$2.to_i] != nil
  259.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  260.         end
  261.         if$encryptedorFileTest.exist?("Graphics/battlers/#{face}")
  262.           if@left_picture != nil
  263.             @left_picture.dispose
  264.           end
  265.           @left_picture = Sprite.new
  266.           @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  267.           @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  268.           @left_picture.x = 0
  269.           @left_picture.mirror = true
  270.           @popchar = -2
  271.           text.gsub!(/\\([Ll])\[(.*?)\]/){""}
  272.         end        
  273.       end
  274.       #——右半身像设置
  275.       if(/\\([Rr])\[(.+?)\]/.match(text))!=nilthen
  276.         face = "66rpg_" + $2 + "_h.png"
  277.         if $1 == "r"and$game_actors[$2.to_i] != nil
  278.           face = $game_actors[$2.to_i].battler_name + "_h.png"
  279.         end
  280.         if$encryptedorFileTest.exist?("Graphics/battlers/#{face}")
  281.           if@right_picture != nil
  282.             @right_picture.dispose
  283.           end
  284.           @right_picture = Sprite.new
  285.           @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{face}")
  286.           @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  287.           @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  288.           @popchar = -2
  289.           text.gsub!(/\\([Rr])\[(.*?)\]/){""}
  290.         end
  291.       end
  292.       if(/\\[Rr][Kk]/.match(text)) != nil
  293.         @right_keep = true
  294.         text.sub!(/\\[Rr]k/){""}
  295.       end
  296.       if(/\\[Ll][Kk]/.match(text)) != nil
  297.         @left_keep = true
  298.         text.sub!(/\\[Ll]k/){""}
  299.       end
  300.       # 替换人物姓名
  301.       text.gsub!(/\\[Nn]\[([0-9]+)\]/)do
  302.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  303.       end
  304.       # 显示人物姓名
  305.       name_window_set = false
  306.       if(/\\[Mm]([0-9]*?)\[(.+?)\]/.match(text)) != nil
  307.         name_window_set = true
  308.         if $1 == ""
  309.           color = 0
  310.         else
  311.           color = $1.to_i
  312.         end
  313.         if color >= 0and color = 0or(@popchar == -1and$game_temp.in_battle)
  314.         # 浮于事件上方的情况
  315.         max_x = 16
  316.         # 获得行数
  317.         textlines = text.split(/\n/)
  318.         cy = max_y = textlines.size
  319.         for i in0..max_y - 1
  320.           line = plain_text(textlines[i])
  321.           if line == ""
  322.             cy -= 1
  323.             next
  324.           end
  325.           cx = contents.text_size(line).width
  326.           if i >= $game_temp.choice_startand$game_temp.choice_start > 0
  327.             cx += 16
  328.           end
  329.           # 获得最大宽度
  330.           max_x = cx if cx > max_x
  331.         end
  332.         # 计算宽度和高度
  333.         max_y = cy if cy < max_y
  334.         max_y = [max_y, 1].max
  335.         self.width = max_x + 32 + @face_indent
  336.         self.width += 16if$game_temp.choice_start == 0
  337.         # 右边有头像的情况宽度再加 128
  338.         self.width += 128if@face_bitmap != nilandnot@alignment
  339.         max_x += 8if$game_temp.choice_start == 0
  340.         # 有输入数值的情况下增加一行并调整宽度
  341.         if$game_temp.num_input_variable_id > 0
  342.           max_y += 1
  343.           dummy_bitmap = Bitmap.new(32, 32)
  344.           cursor_width = dummy_bitmap.text_size("0").width + 8
  345.           dummy_bitmap.dispose
  346.           cx = cursor_width * $game_temp.num_input_digits_max + 16
  347.           max_x = cx if cx > max_x
  348.         end
  349.         self.height = max_y * 32 + 32
  350.         # 有头像的情况高度定为 160
  351.         self.height = [self.height, 160].maxif@face_bitmap != nil
  352.       # 不是浮于事件上方的情况
  353.       else
  354.         max_x = self.width - 32 - @face_indent
  355.         self.height = [text.split(/\n/).size * 32 + 32, 160].max
  356.       end
  357.       # 绘制窗体样式
  358.       reset_window
  359.       # 姓名框
  360.       if name_window_set
  361.         w = self.contents.text_size(name_text).width + 16
  362.         xn = @alignment ? self.x : self.x + self.width - w
  363.         ifself.y < 20
  364.           if@popchar >= 0
  365.             self.y += self.height + 48if@popchar >= 0
  366.           else
  367.             self.y = 36
  368.           end
  369.         end
  370.         yn = self.y - 20
  371.         @name_window = Window_Name.new(xn, yn, w)
  372.         @name_window.z = self.z + 1
  373.         @name_airtext = Window_AirText.new(xn + 8, yn + 8, name_text, name_color)
  374.         @name_airtext.z = self.z + 2
  375.         @name_window.back_opacity = self.back_opacity
  376.       end
  377.       # 逐字打印文本
  378.       text.gsub!(/\\\\/){"\000"}
  379.       text.gsub!(/\\[Cc]\[([0-9]+)\]/){"\001[#{$1}]"}
  380.       text.gsub!(/\\[Gg]/){"\002"}
  381.       text.gsub!(/\\[Tt]/){"\003"}
  382.       text.gsub!(/\\[Uu]\[([0-9A-Fa-f]{6})\]/){"\004[#{$1}]"}
  383.       text.gsub!(/\\[Xx]\[([0-9]+)\]/){"\005[#{$1}]"}
  384.       text.gsub!(/\\[Zz]\[([0-9]+)\]/){"\022[#{$1}]"}
  385.       text.gsub!(/\\[Ii]/){"\023"}
  386.       text.gsub!(/\\[Oo]\[([0-9]+)\]/){"\024[#{$1}]"}
  387.       text.gsub!(/\\[Hh]\[([0-9]+)\]/){"\025[#{$1}]"}
  388.       text.gsub!(/\\[Bb]\[([0-9]+)\]/){"\026[#{$1}]"}
  389.       text.gsub!(/\\[Dd]\[([0-9]+)\]/){"\027[#{$1}]"}
  390.       start_x = @indent + @face_indent
  391.       @text_buffer = []
  392.       c_wait = 0
  393.       while((c = text.slice!(/./m)) != nil)
  394.         if c == "\000"
  395.           c = "\"
  396.         end
  397.         if c == "\001"
  398.           text.sub!(/\[([0-9]+)\]/, "")
  399.           color = $1.to_i
  400.           if color >= 0and color = 128 ? 32 : 384
  401.             end
  402.             @gold_window.opacity = self.opacity
  403.             @gold_window.back_opacity = self.back_opacity
  404.           end
  405.           next
  406.         end
  407.         if c == "\003"
  408.           if@playtime_window == nil
  409.             @playtime_window = Window_PlayTime.new
  410.             @playtime_window.x = 80
  411.             if$game_temp.in_battle
  412.               @playtime_window.y = 192
  413.             else
  414.               @playtime_window.y = self.y >= 128 ? 32 : 384
  415.             end
  416.             @playtime_window.opacity = self.opacity
  417.             @playtime_window.back_opacity = self.back_opacity
  418.           end
  419.           next
  420.         end
  421.         if c == "\004"
  422.           text.sub!(/\[([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})\]/, "")
  423.           if@type_speed < 0
  424.             self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)
  425.           else
  426.             @text_buffer.push([nil, -1, Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16), 255)])
  427.           end
  428.           next
  429.         end
  430.         if c == "\005"
  431.           text.sub!(/\[([0-9]+)\]/, "")
  432.           tab = ($1.to_i - 1) * self.contents.text_size("0").width
  433.           x = start_x + tab if x < start_x + tab
  434.           next
  435.         end
  436.         if c == "\022"
  437.           text.sub!(/\[([0-9]+)\]/, "")
  438.           c_wait += $1.to_i
  439.           next
  440.         end
  441.         if c == "\023"
  442.           @indent = x
  443.           next
  444.         end
  445.         if c == "\024"
  446.           text.sub!(/\[([0-9]+)\]/, "")
  447.           if@type_speed < 0
  448.             self.contents.font.color.alpha = [[0, $1.to_i].max, 255].min
  449.           else
  450.             color = self.contents.font.color.clone
  451.             color.alpha = [[0, $1.to_i].max, 255].min
  452.             @text_buffer.push([nil, -1, color])
  453.           end
  454.           next
  455.         end
  456.         if c == "\025"
  457.           text.sub!(/\[([0-9]+)\]/, "")
  458.           self.contents.font.size = [[$1.to_i, 6].max, 32].min
  459.           if@type_speed >= 0
  460.             @text_buffer.push([nil, -1, self.contents.font.size])
  461.           end
  462.           next
  463.         end
  464.         if c == "\026"
  465.           text.sub!(/\[([0-9]+)\]/, "")
  466.           x += $1.to_i
  467.           next
  468.         end
  469.         if c == "\027"
  470.           text.sub!(/\[([0-9]+)\]/, "")
  471.           x += $1.to_i * self.contents.text_size("0").width
  472.           next
  473.         end
  474.         if c == "\030"
  475.           text.sub!(/\[(.*?)\]/, "")
  476.           if@type_speed < 0
  477.             self.contents.blt(x , y * line_height + 4, RPG::Cache.icon($1),
  478.               Rect.new(0, 0, 24, 24))
  479.           else
  480.             @text_buffer.push([Rect.new(x, y * line_height + 4, 24, 24),
  481.               c_wait, RPG::Cache.icon($1)])
  482.             c_wait = @type_speed
  483.           end
  484.           x += 24
  485.           next
  486.         end
  487.         if c == "\n"
  488.           if x == start_x and(@popchar != -2andnot$game_temp.in_battle)
  489.             $game_temp.choice_start -= 1
  490.             lines -= 1
  491.             y -= 1
  492.           end
  493.           if lines >= $game_temp.choice_start
  494.             @cursor_width = [@cursor_width, x - @face_indent].max
  495.           end
  496.           lines += 1
  497.           y += 1
  498.           start_x = @face_indent + @indent
  499.           x = start_x
  500.           if lines >= $game_temp.choice_start
  501.             x += 8
  502.           end
  503.           next
  504.         end
  505.         # 描绘文字
  506.         c_width = self.contents.text_size(c).width
  507.         c_height = line_height
  508.         if@type_speed < 0
  509.           self.contents.draw_text(x, c_height * y, c_width, c_height, c)
  510.         else
  511.           @text_buffer.push([Rect.new(x, c_height * y, c_width, c_height),
  512.             c_wait, c])
  513.           c_wait = @type_speed
  514.         end
  515.         x += c_width
  516.       end
  517.       @type_wait = @text_buffer[0][1]if@text_buffer.size > 0
  518.     end
  519.     if@type_speed < 0and$game_temp.choice_max > 0
  520.       @item_max = $game_temp.choice_max
  521.       self.active = true
  522.       self.index = 0
  523.     end
  524.     if$game_temp.num_input_variable_id > 0
  525.       digits_max = $game_temp.num_input_digits_max
  526.       number = $game_variables[$game_temp.num_input_variable_id]
  527.       @input_number_window = Window_InputNumber.new(digits_max)
  528.       @input_number_window.number = number
  529.       @input_number_window.x = self.x + 8
  530.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  531.     end
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ● 更新
  535.   #--------------------------------------------------------------------------
  536.   def update
  537.     super
  538.     # 渐变的情况下
  539.     if@fade_in
  540.       self.contents_opacity += 24
  541.       if@input_number_window != nil
  542.         @input_number_window.contents_opacity += 24
  543.       end
  544.       ifself.contents_opacity == 255
  545.         @fade_in = false
  546.       end
  547.       return
  548.     end
  549.     # 打字的情况下
  550.     if@text_buffer.size > 0
  551.       # 按键跳过打字
  552.       if Input.trigger?(Input::C)or Input.trigger?(Input::B)
  553.         type_next_char until@text_buffer.size == 0
  554.         return
  555.       end
  556.       # 等待打字延时
  557.       if@type_wait > 0
  558.         @type_wait -= 1
  559.       end
  560.       # 传送位图
  561.       if@type_wait  0and$game_temp.choice_cancel_type > 0
  562.           $game_system.se_play($data_system.cancel_se)
  563.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  564.           terminate_message
  565.         end
  566.       end
  567.       # 确定
  568.       if Input.trigger?(Input::C)
  569.         if$game_temp.choice_max > 0
  570.           $game_system.se_play($data_system.decision_se)
  571.           $game_temp.choice_proc.call(self.index)
  572.         end
  573.         terminate_message
  574.       end
  575.       # 时间窗口可见的情况下
  576.       if@playtime_window != nil
  577.         @playtime_window.update
  578.       end
  579.       # 等待中的情况下
  580.       if@wait_count > 0
  581.         @wait_count -= 1
  582.         if@wait_count == 0
  583.           terminate_message
  584.         end
  585.       end
  586.       return
  587.     end
  588.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  589.     if@fade_out == falseand$game_temp.message_text != nil
  590.       @contents_showing = true
  591.       $game_temp.message_window_showing = true
  592.       refresh
  593.       Graphics.frame_reset
  594.       @wait_count = 0
  595.       if@wait_set != 0
  596.         @wait_count = @wait_set
  597.       end
  598.       self.visible = true
  599.       if@type_speed < 0
  600.         self.contents_opacity = 0
  601.         @fade_in = true
  602.       else
  603.         self.contents_opacity = 255
  604.       end
  605.       if@input_number_window != nil
  606.         @input_number_window.contents_opacity = 0
  607.       end
  608.       return
  609.     end
  610.     # 没有可以显示的信息、但是窗口为可见的情况下
  611.     ifself.visible
  612.       @fade_out = true
  613.       self.opacity -= 48
  614.       ifself.opacity == 0
  615.         self.visible = false
  616.         @fade_out = false
  617.         $game_temp.message_window_showing = false
  618.       end
  619.       return
  620.     end
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 获得角色
  624.   #--------------------------------------------------------------------------
  625.   def get_character(parameter)
  626.     case parameter
  627.     when1000# 本事件
  628.       return$game_system.map_interpreter.get_character(0)
  629.     when0# 角色
  630.       return$game_player
  631.     else# 其他事件
  632.       return$game_system.map_interpreter.get_character(parameter)
  633.     end
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ● 设置窗口位置与不透明度
  637.   #--------------------------------------------------------------------------
  638.   def reset_window
  639.     # 位置判定
  640.     if$game_temp.in_battle
  641.       if@popchar >= 4
  642.         x = $game_troop.enemies[@popchar - 4].screen_x - self.width / 2
  643.         y = $game_troop.enemies[@popchar - 4].screen_y - self.height - 100
  644.         self.x = [[x, 0].max, 640 - self.width].min
  645.         self.y = [y, 16].max
  646.       elsif@popchar >= 0
  647.         x = $game_party.actors[@popchar].screen_x - self.width / 2
  648.         y = $game_party.actors[@popchar].screen_y - self.height - 100
  649.         self.x = [[x, 0].max, 640 - self.width].min
  650.         self.y = [y, 16].max
  651.       elsif@popchar == -1
  652.         self.x = 320 - self.width / 2
  653.         self.y = 192 - self.height / 2
  654.       elsif@popchar == -2
  655.         self.y = 16
  656.       end
  657.     else
  658.       if@popchar >= 0
  659.         events = $game_map.events
  660.         if events != nil
  661.           character = get_character(@popchar)
  662.           if character != nil
  663.             x = [[character.screen_x - self.width / 2, 4].max, 636 - self.width].min
  664.             y = character.screen_y - 48 - self.height
  665.             y = character.screen_yif y < 4
  666.             y = [y, 476 - self.height].min
  667.             self.x = x
  668.             self.y = y
  669.           else
  670.             @popchar = -2
  671.           end
  672.         end
  673.       elsif@popchar == -1
  674.         self.x = -4
  675.         self.y = -4
  676.         self.width = 648
  677.         self.height = 488
  678.       else
  679.         case$game_system.message_position
  680.         when0# 上
  681.           self.y = 16
  682.         when1# 中
  683.           self.y = [240 - self.height / 2, 16].max
  684.         when2# 下
  685.           self.y = [[304, 464 - self.height].min, 16].max
  686.         end
  687.         if(@left_picture != nilandnot@left_keep)or
  688.           (@right_picture != nilandnot@right_keep)
  689.           self.y = [[304, 464 - self.height].min, 16].max
  690.         end
  691.         self.x = 80
  692.         if@face_bitmap == nil
  693.           self.width = 480
  694.         else
  695.           self.width = 600
  696.           self.x -= 60
  697.         end
  698.       end
  699.     end
  700.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  701.     if@face_bitmap != nil
  702.       if@alignment
  703.         self.contents.blt(16, 16, @face_bitmap, Rect.new(0, 0, 96, 96))
  704.       else
  705.         self.contents.blt(self.contents.width - 112, 16, @face_bitmap,
  706.           Rect.new(0, 0, 96, 96))
  707.       end
  708.       @face_bitmap.dispose
  709.       @face_bitmap = nil
  710.     end
  711.     if@popchar == -1andnot$game_temp.in_battle
  712.       self.opacity = 255
  713.       self.back_opacity = 0
  714.     elsif$game_system.message_frame == 0
  715.       self.opacity = 255
  716.       self.back_opacity = 224
  717.     else
  718.       self.opacity = 0
  719.       self.back_opacity = 160
  720.     end
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # ● 行高
  724.   #--------------------------------------------------------------------------
  725.   def line_height
  726.     ifself.contents.font.size >= 20andself.contents.font.size = 0
  727.       n = $game_temp.choice_start + @index
  728.       self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  729.     else
  730.       self.cursor_rect.empty
  731.     end
  732.   end
  733.   #--------------------------------------------------------------------------
  734.   # ● 打印下一个字
  735.   #--------------------------------------------------------------------------
  736.   def type_next_char
  737.     c = @text_buffer.shift
  738.     rc = c[0]
  739.     case c[2]
  740.     when Bitmap
  741.       self.contents.blt(rc.x, rc.y, c[2], c[2].rect)
  742.     when Color
  743.       self.contents.font.color = c[2]
  744.     whenInteger
  745.       self.contents.font.size = c[2]
  746.     else
  747.       self.contents.draw_text(rc, c[2])
  748.     end
  749.     if@text_buffer.size > 0
  750.       @type_wait = @text_buffer[0][1]
  751.       type_next_char if@type_wait == -1
  752.     else
  753.       if$game_temp.choice_max > 0
  754.         @item_max = $game_temp.choice_max
  755.         self.active = true
  756.         self.index = 0
  757.       end
  758.     end
  759.   end
  760. end
  761. #==============================================================================
  762. # ■ Window_Name
  763. #------------------------------------------------------------------------------
  764. #  显示对话人姓名的窗口。
  765. #==============================================================================
  766. class Window_Name < Window_Base
  767.   #--------------------------------------------------------------------------
  768.   # ● 初始化窗口
  769.   #--------------------------------------------------------------------------
  770.   def initialize(x, y, width)
  771.     super(x, y, width, 40)
  772.     self.contents = nil
  773.     self.back_opacity = 160
  774.   end
  775. end
  776. #==============================================================================
  777. # ■ Window_AirText
  778. #------------------------------------------------------------------------------
  779. #  显示对话人姓名的文字。
  780. #==============================================================================
  781. class Window_AirText < Window_Base
  782.   #--------------------------------------------------------------------------
  783.   # ● 初始化窗口
  784.   #--------------------------------------------------------------------------
  785.   def initialize(x, y, designate_text, color)
  786.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  787.     self.opacity = 0
  788.     self.back_opacity = 0
  789.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  790.     w = self.contents.width
  791.     h = self.contents.height
  792.     if color.is_a?(Integer)
  793.       self.contents.font.color = text_color(color)
  794.     else
  795.       self.contents.font.color = color
  796.     end
  797.     self.contents.draw_text(0, 0, w, h, designate_text)
  798.   end
  799. end
  800. #==============================================================================
  801. # ■ Game_Event
  802. #------------------------------------------------------------------------------
  803. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  804. # 在 Game_Map 类的内部使用。
  805. #==============================================================================
  806. class Game_Event < Game_Character
  807.   #--------------------------------------------------------------------------
  808.   # ● 事件名字
  809.   #--------------------------------------------------------------------------
  810.   def name
  811.     return@event.name
  812.   end
  813. end
复制代码



附件是范例工程。老规矩,姐一般不提供范例工程,避免伸手党,所以收20G意思下,范例中不含配套的半身像和头像素材。

             本帖来自P1论坛作者卓越大白痴,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=249914  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-5-20 14:24 , Processed in 0.033920 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部