Project1

标题: 关于呼出对话框脚本 [打印本页]

作者: zdc223658    时间: 2011-8-20 20:50
标题: 关于呼出对话框脚本
[attach]71646[/attach]
用这个脚本会出现,要么有名字没头像 ,有么有头像没名字   如何让它有头像又有名字呢? 事件该怎么写?
  1. #
  2. #    呼出对话框 ver. 1.31 By パラ犬(日)
  3. #  来自 http://rpg.para.s3p.net/
  4. #
  5. #  汉化修改 66RPG bbschat(2006.1.5)
  6. #    来自 http://www.66RPG.com/
  7. #
  8. #    ●准备工作-窗口Skin
  9. #
  10. #    首先,确认自己使用的对话框窗口Skin,(数据库-系统-窗口外观图形)
  11. #    然后根据该窗口Skin制作对话框尾部使用的两个箭头图形
  12. #    尾部箭头图形命名方式:“窗口skin名-top”,“窗口skin名-under”
  13. #    将该图形文件存放在“Graphics/Windowskins”文件夹下。
  14. #
  15. #    本演示游戏内置2套窗口和箭头图形,
  16. #    一套是游戏默认的“001-Blue01”,一套是定制的“fk”
  17. #    玩家可以根据自己的需要参照样本定制自己的呼出对话框窗口Skin。
  18. #
  19. #    ●呼出对话框使用方法
  20. #
  21. #    在事件命令行使用[脚本]将事件ID代入[$mes_id]
  22. #    该事件就可以使用呼出对话框了。
  23. #   (举例:$mes_id=4)
  24. #
  25. #    ID 代入 -1 表示玩家,代入 0 表示事件自身。
  26. #    代入 nil 或者 "" 则返回成通常的信息窗口。
  27. #    对话框的表示位置可以通过事件的“更改文章选项”来设定(上、中、下)。
  28. #    表示位置为“中央”的话,不管事件位置在哪里,对话框都将显示在画面中央。
  29. #
  30. #    ●角色名字窗口的使用文字的方法
  31. #
  32. #    在事件命令行使用[脚本]将文字列代入[$mes_name]
  33. #    对话框就会显示角色名字窗口
  34. #   (举例:$mes_name="阿尔西斯")
  35. #    代入 nil 或者 "" 则不显示角色名字窗口。
  36. #
  37. #    以上两个机能是独立的,所以可以单独使用
  38. #
  39. #   $mes_id=(ID) + $mes_name="名字"  :呼出对话框显示 + 角色名字窗口
  40. #   $mes_id=(ID) + $mes_name=""      :呼出对话框显示(没有角色名字)
  41. #   $mes_id=nil  + $mes_name="名字"  :默认信息窗口 + 角色名字窗口
  42. #   $mes_id=nil  + $mes_name=""      :默认信息窗口(没有角色名字)
  43. #
  44. #    ●角色名字窗口使用角色图片的方法(汉化特别追加功能,原脚本只能使用文字)
  45. #   
  46. #    如果能在对应文件夹中找到文件名和角色名字相同的图片,   
  47. #    则角色名字窗口显示角色头像图片,角色图片最好能包括角色的名字。
  48. #    默认头像图片保存目录为“Graphics/Heads/”,玩家可自行修改。
  49. #
  50. #    如果不想使用角色名字直接作为头像文件名。
  51. #    可以使用下面在 Game_Temp 类里增加的namebmp属性。
  52. #    重新设定角色名字与文件名的对应关系。
  53. #
  54. #    ●信息表示速度的变更方法
  55. #
  56. #    在事件命令行使用[脚本]将数值代入[$mes_speed]
  57. #    速度为 0 即瞬间显示全部信息,数字越大,信息表示速度越慢。
  58. #   (举例:$mes_speed=1)
  59. #
  60. #    ●其他设置
  61. #
  62. #    请参照下面的注释
  63. #==============================================================================

  64. module FUKI

  65.   # 头像图片保存目录的设定
  66.   HEAD_PIC_DIR = "Graphics/Heads/"

  67.   # 是否显示尾部图标
  68.   TAIL_SHOW = true
  69.   
  70.   # Skin的设定
  71.   # 使用数据库默认窗口Skin情况下这里使用[""]
  72.   FUKI_SKIN_NAME = ""   # 呼出对话框用Skin
  73.   NAME_SKIN_NAME = ""   # 角色名字窗口用Skin
  74.   
  75.   # 字体大小
  76.   MES_FONT_SIZE = 22    # 呼出对话框
  77.   NAME_FONT_SIZE = 16   # 角色名字窗口
  78.   
  79.   # 字体颜色
  80.   #(设定为 Color.new(0, 0, 0, 0) 表示使用普通文字色)
  81.   FUKI_COLOR = Color.new(255, 255, 255, 255)  # 呼出对话框
  82.   NAME_COLOR = Color.new(0, 0, 0, 0)  # 角色名字窗口
  83.   
  84.   # 窗口透明度
  85.   # 如修改窗口透明度请同时修改尾部箭头图形内部的透明度
  86.   FUKI_OPACITY = 160    # 呼出对话框
  87.   MES_OPACITY = 160     # 默认信息窗口
  88.   NAME_OPACITY = 160    # 角色名字窗口
  89.   
  90.   # 角色名字窗口的相对位置
  91.   NAME_SHIFT_X = 0      # 横坐标
  92.   NAME_SHIFT_Y = 16     # 纵坐标
  93.   
  94.   # 窗口表示时是否根据画面大小自动检查窗口出现的位置,
  95.   # 自动改变位置( true / false )
  96.   # 设置成 true 可能出现箭头图标颠倒的问题 <- bbschat
  97.   POS_FIX = false

  98.   # 在画面最边缘表示时的稍微挪动
  99.   # 使用圆形Skin的角和方框的角重合的情况下为 true
  100.   CORNER_SHIFT = false
  101.   SHIFT_PIXEL = 4   # true 时挪动的象素
  102.   
  103.   # 角色高度尺寸
  104.   CHARACTOR_HEIGHT = 48
  105.   # 呼出对话框的相对位置(纵坐标)
  106.   POP_SHIFT_TOP = 0         # 表示位置为上的时候
  107.   POP_SHIFT_UNDER = 0       # 表示位置为下的时候
  108.   
  109.   # 信息的表示速度(数字越小速度越快,0为瞬间表示)
  110.   # 游戏中 可随时用数字代入 $mes_speed 来改变消息表示速度。
  111.   MES_SPEED = 1

  112. end

  113. #==============================================================================
  114. # 方便用户同时设置2个常用参数而使用的函数
  115. #==============================================================================
  116. def chat(id = 0,name = "")
  117.   $mes_id = id
  118.   if name==-1
  119.     $mes_name=$game_party.actors[0].name
  120.   else
  121.     $mes_name = name
  122.   end
  123. end


  124. #==============================================================================
  125. # □ Game_Temp
  126. #==============================================================================

  127. class Game_Temp
  128.   attr_accessor  :namebmp              #保存头像图片的Hash表
  129.   alias initialize_fuki initialize
  130.   def initialize
  131.     initialize_fuki
  132.     # 如果不想使用角色名字直接作为头像文件名
  133.     # 可在这里重新设定角色名字与文件名的对应关系
  134.     @namebmp ={"玩家"=>"001", "维斯特"=>"002-Player-Face"}
  135.   end
  136. end

  137. #==============================================================================
  138. # □ Window_FukiMessage
  139. #==============================================================================

  140. class Window_FukiMessage < Window_Selectable

  141.   #--------------------------------------------------------------------------
  142.   # ● 初始化状态
  143.   #--------------------------------------------------------------------------
  144.   def initialize
  145.     super(80, 304, 480, 160)
  146.     self.contents = Bitmap.new(width - 32, height - 32)
  147.     self.visible = false
  148.     self.z = 9998
  149.     @fade_in = false
  150.     @fade_out = false
  151.     @contents_showing = false
  152.     @cursor_width = 0
  153.     self.active = false
  154.     self.index = -1
  155.     @w = 0
  156.     @h = 0
  157.     @wait = 0
  158.     @dx = 0
  159.     @dy = 0
  160.     $mes_speed = FUKI::MES_SPEED
  161.   end
  162.   
  163.   #--------------------------------------------------------------------------
  164.   # ○ 决定窗口尺寸并生成窗口
  165.   #--------------------------------------------------------------------------
  166.   def refresh_create
  167.     self.contents.clear
  168.     self.contents.font.color = normal_color
  169.     self.contents.font.size = FUKI::MES_FONT_SIZE
  170.     # 取得窗口尺寸
  171.     get_windowsize
  172.     w = @w + 32 + 8
  173.     h = @h * (self.contents.font.size + 10) + 26
  174.     # 生成呼出窗口
  175.     set_fukidasi(self.x, self.y, w, h)
  176.     # 生成角色名字窗口
  177.     set_namewindow
  178.     # 初始化信息表示使用的变量
  179.     @dx = @dy = 0
  180.     @cursor_width = 0
  181.     @contents_drawing = true
  182.     # 瞬间表示的情况下
  183.     if $mes_speed == 0
  184.       # 循环信息描绘处理
  185.       while $game_temp.message_text != ""
  186.         draw_massage
  187.       end
  188.       draw_opt_text
  189.       @contents_showing_end = true
  190.       @contents_drawing = false
  191.     else
  192.       # 一个一个描绘文字
  193.       refresh_drawtext
  194.     end
  195.   end
  196.   
  197.   #--------------------------------------------------------------------------
  198.   # ○ 一个一个描绘文字
  199.   #--------------------------------------------------------------------------
  200.   def refresh_drawtext
  201.     if $game_temp.message_text != nil
  202.       if @wait > 0
  203.         @wait -= 1
  204.       elsif @wait == 0
  205.         # 描绘处理
  206.         draw_massage
  207.         @wait = $mes_speed
  208.       end
  209.     end
  210.     # 描绘结束
  211.     if $game_temp.message_text == ""
  212.       draw_opt_text
  213.       @contents_showing_end = true
  214.       @contents_drawing = false
  215.     end
  216.   end
  217.   
  218.   #--------------------------------------------------------------------------
  219.   # ○ 取得窗口尺寸
  220.   #--------------------------------------------------------------------------
  221.   def get_windowsize
  222.     x = y = 0
  223.     @h = @w = 0
  224.     @cursor_width = 0
  225.     # 有选择项的话,处理字的缩进
  226.     if $game_temp.choice_start == 0
  227.       x = 16
  228.     end
  229.     # 有等待显示的文字的情况下
  230.     if $game_temp.message_text != nil
  231.     text = $game_temp.message_text.clone
  232.       # 限制文字处理
  233.       begin
  234.         last_text = text.clone
  235.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  236.       end until text == last_text
  237.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  238.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  239.       end
  240.       # 为了方便、将 "\\\\" 变换为 "\000"
  241.       text.gsub!(/\\\\/) { "\000" }
  242.       # "\\C" 变为 "\001" 、"\\G" 变为 "\002"
  243.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001" }
  244.       text.gsub!(/\\[Gg]/) { "\002" }
  245.       # c 获取 1 个字 (如果不能取得文字就循环)
  246.       while ((c = text.slice!(/./m)) != nil)
  247.         # \\ 的情况下
  248.         if c == "\000"
  249.           # 还原为本来的文字
  250.           c = "\\"
  251.         end
  252.         # \C[n] 或者 \G 的情况下
  253.         if c == "\001" or c == "\002"
  254.           # 下面的文字
  255.           next
  256.         end
  257.         # 另起一行文字的情况下
  258.         if c == "\n"
  259.           # y 累加 1
  260.           y += 1
  261.           # 取得纵横尺寸
  262.           @h = y
  263.           @w = x > @w ? x : @w
  264.           if y >= $game_temp.choice_start
  265.             @w = x + 8 > @w ? x + 8 : @w
  266.           end
  267.           x = 0
  268.           # 移动到选择项的下一行
  269.           if y >= $game_temp.choice_start
  270.             x = 8
  271.           end
  272.           # 下面的文字
  273.           next
  274.         end
  275.         # x 为要描绘文字的宽度加法运算
  276.         x += self.contents.text_size(c).width
  277.       end
  278.     end
  279.     # 输入数值的情况
  280.     if $game_temp.num_input_variable_id > 0
  281.       digits_max = $game_temp.num_input_digits_max
  282.       number = $game_variables[$game_temp.num_input_variable_id]
  283.       @h += 1
  284.       x = digits_max * self.contents.font.size + 16
  285.       @w = x > @w ? x : @w
  286.     end
  287.   end
  288.   
  289.   #--------------------------------------------------------------------------
  290.   # ○ 描绘信息处理
  291.   #--------------------------------------------------------------------------
  292.   def draw_massage
  293.     # 有等待显示的文字的情况下
  294.     if $game_temp.message_text != nil
  295.       text = $game_temp.message_text
  296.       # 限制文字处理
  297.       begin
  298.         last_text = text.clone
  299.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  300.       end until text == last_text
  301.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  302.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  303.       end
  304.       # 为了方便、将 "\\\\" 变换为 "\000"
  305.       text.gsub!(/\\\\/) { "\000" }
  306.       # "\\C" 变为 "\001"、"\\G" 变为 "\002"
  307.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  308.       text.gsub!(/\\[Gg]/) { "\002" }
  309.       # c 获取 1 个字
  310.       if ((c = text.slice!(/./m)) != nil)
  311.         # 选择项的情况
  312.         if @dy >= $game_temp.choice_start
  313.           # 处理字的缩进
  314.           @dx = 8
  315.           # 描绘文字
  316.           self.contents.draw_text(4 + @dx, 32 * @dy, 40, 32, c)
  317.           # x 为要描绘文字宽度的加法运算
  318.           @dx += self.contents.text_size(c).width
  319.           # 循环
  320.           while ((c = text.slice!(/./m)) != "\n")
  321.             # 描绘文字
  322.             self.contents.draw_text(4 + @dx, 32 * @dy, 40, 32, c)
  323.             # x 为要描绘文字宽度的加法运算
  324.             @dx += self.contents.text_size(c).width
  325.           end
  326.           if c == "\n"
  327.             # 更新光标宽度
  328.             @cursor_width = [@cursor_width, @dx].max
  329.             # dy 累加 1
  330.             @dy += 1
  331.             @dx = 0
  332.           end
  333.           return
  334.         end
  335.         # \\ 的情况下
  336.         if c == "\000"
  337.           # 还原为本来的文字
  338.           c = "\\"
  339.         end
  340.         #\C[n] 的情况下
  341.         if c == "\001"
  342.           # 更改文字色
  343.           text.sub!(/\[([0-9]+)\]/, "")
  344.           color = $1.to_i
  345.           if color >= 0 and color <= 7
  346.             self.contents.font.color = text_color(color)
  347.           end
  348.         end
  349.         # \G 的情况下
  350.         if c == "\002"
  351.           # 生成金钱窗口
  352.           if @gold_window == nil
  353.             @gold_window = Window_Gold.new
  354.             @gold_window.x = 560 - @gold_window.width
  355.             if $game_temp.in_battle
  356.               @gold_window.y = 192
  357.             else
  358.               @gold_window.y = self.y >= 128 ? 32 : 384
  359.             end
  360.             @gold_window.opacity = self.opacity
  361.             @gold_window.back_opacity = self.back_opacity
  362.           end
  363.         end
  364.         # 另起一行文字的情况下
  365.         if c == "\n"
  366.           # dy 累加 1
  367.           @dy += 1
  368.           @dx = 0
  369.         end
  370.         # 描绘文字
  371.         self.contents.font.size = FUKI::MES_FONT_SIZE
  372.         font_size = self.contents.font.size
  373.              if c == "\001" or c == "\002" or c == "\003" or c == "\n"
  374.         c = ""
  375.       else
  376.         self.contents.draw_text(4+@dx, (font_size+10)*@dy, font_size, font_size, c)
  377.       end
  378.         # dx 为要描绘文字的宽度加法运算
  379.         @dx += self.contents.text_size(c).width
  380.       end
  381.     end
  382.   end
  383.   
  384.   #--------------------------------------------------------------------------
  385.   # ○ 选择项和输入数值的情况下
  386.   #--------------------------------------------------------------------------
  387.   def draw_opt_text
  388.     # 选择项的情况下
  389.     if $game_temp.choice_max > 0
  390.       @item_max = $game_temp.choice_max
  391.       self.active = true
  392.       self.index = 0
  393.     end
  394.     # 输入数值的情况下
  395.     if $game_temp.num_input_variable_id > 0
  396.       digits_max = $game_temp.num_input_digits_max
  397.       number = $game_variables[$game_temp.num_input_variable_id]
  398.       @input_number_window = Window_InputNumber.new(digits_max)
  399.       @input_number_window.number = number
  400.       @input_number_window.x = self.x + 8
  401.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  402.     end
  403.   end
  404.   
  405.   #--------------------------------------------------------------------------
  406.   # ○ 设置呼出对话框
  407.   #--------------------------------------------------------------------------
  408.   def set_fukidasi(x, y, width, height)
  409.     # $mes_id 为空的时候,不显示呼出对话框
  410.     if $mes_id == nil or $mes_id == ""
  411.       del_fukidasi
  412.       reset_window
  413.     else
  414.       # 不显示暂停标志
  415.       self.pause = false
  416.       # 取得对话框位置
  417.       pos = get_fuki_pos(width, height)
  418.       x = pos[0]
  419.       y = pos[1]
  420.       skin = FUKI::FUKI_SKIN_NAME != "" ? FUKI::FUKI_SKIN_NAME : $game_system.windowskin_name
  421.       # 生成呼出对话框
  422.       self.windowskin = RPG::Cache.windowskin(skin)
  423.       self.x = x
  424.       self.y = y
  425.       self.height = height
  426.       self.width = width
  427.       self.contents.dispose
  428.       self.contents = Bitmap.new(width - 32, height - 32)
  429.       self.back_opacity = FUKI::FUKI_OPACITY
  430.       self.contents.clear
  431.       self.contents.font.color = normal_color
  432.       self.contents.font.size = FUKI::MES_FONT_SIZE
  433.       # 描绘尾部图标
  434.       if $game_system.message_frame == 0
  435.         # 取得位置
  436.         tale_pos = get_tale_pos
  437.         @tale = Sprite.new
  438.         # 是否显示尾部图标 <- bbschat
  439.         if FUKI::TAIL_SHOW == true
  440.           case @message_position
  441.             when 0  # 上
  442.               @tale.bitmap = RPG::Cache.windowskin(skin + "-top")
  443.               @tale.x = tale_pos[0]
  444.               @tale.y = tale_pos[1]
  445.               @tale.z = self.z + 1
  446.             when 1  # 中
  447.               @tale.dispose
  448.               @tale = nil
  449.             when 2  # 下
  450.               @tale.bitmap = RPG::Cache.windowskin(skin + "-under")
  451.               @tale.x = tale_pos[0]
  452.               @tale.y = tale_pos[1]
  453.               @tale.z = self.z + 1
  454.           end
  455.         end
  456.       end
  457.     end
  458.   end
  459.   
  460.   #--------------------------------------------------------------------------
  461.   # ○ 计算呼出对话框的位置
  462.   #--------------------------------------------------------------------------
  463.   def get_fuki_pos(width, height)
  464.    
  465.     # 取得角色
  466.     @character = get_character($mes_id)
  467.     if @character == nil
  468.       # 角色不存在的情况下使用默认信息框
  469.       del_fukidasi
  470.       reset_window
  471.       return
  472.     end
  473.     # 处理坐标
  474.     x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - (width / 2)
  475.     # 为尽量显示在画面内而移动横坐标
  476.     if x + width > 640
  477.       x = 640 - width
  478.     elsif x < 0
  479.       x = 0
  480.     end
  481.     # 决定窗口位置
  482.     case $game_system.message_position
  483.       when 0  # 上
  484.         y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - FUKI::CHARACTOR_HEIGHT + FUKI::POP_SHIFT_TOP
  485.       when 1  # 中
  486.         y = (480 - height) / 2
  487.         x = (640 - width) / 2
  488.       when 2  # 下
  489.         y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + FUKI::POP_SHIFT_UNDER
  490.     end
  491.     # 纪录文章显示位置
  492.     @message_position = $game_system.message_position
  493.     # 如果选择自动修正,则如果文章会显示到画面外则自动改变窗口的尺寸(高度)
  494.     if FUKI::POS_FIX
  495.       case @message_position
  496.         when 0  # 上
  497.           if y <= 0
  498.             @message_position = 2
  499.             y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + FUKI::POP_SHIFT_UNDER
  500.           end
  501.         when 2  # 下
  502.           if y + height >= 480
  503.             p "上"
  504.             @message_position = 0
  505.             y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - FUKI::CHARACTOR_HEIGHT + FUKI::POP_SHIFT_TOP
  506.           end
  507.       end
  508.     end
  509.     return [x,y]
  510.    
  511.   end
  512.   
  513.   #--------------------------------------------------------------------------
  514.   # ○ 计算尾部图标的位置
  515.   #--------------------------------------------------------------------------
  516.   def get_tale_pos
  517.     case @message_position
  518.       when 0  # 上
  519.         # 处理坐标
  520.         x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 16
  521.         # 画面边缘的话则移动位置
  522.         if FUKI::CORNER_SHIFT
  523.           if x == 0
  524.             x = FUKI::SHIFT_PIXEL
  525.           elsif x == 640 - 32
  526.             x = 640 - 32 - FUKI::SHIFT_PIXEL
  527.           end
  528.         end
  529.         y = self.y + self.height - 16
  530.       when 1  # 中
  531.         x = nil
  532.         y = nil
  533.       when 2  # 下
  534.         # 处理坐标
  535.         x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 16
  536.         # 画面边缘的话则移动位置
  537.         if FUKI::CORNER_SHIFT
  538.           if x == 0
  539.             x = FUKI::SHIFT_PIXEL
  540.           elsif @tale.x == 640 - 32
  541.             x = 640 - 32 - FUKI::SHIFT_PIXEL
  542.           end
  543.         end
  544.         y = self.y - 16
  545.     end
  546.     return [x,y]
  547.   end

  548.   #--------------------------------------------------------------------------
  549.   # ○ 计算名字窗口的位置
  550.   #--------------------------------------------------------------------------
  551.   def get_name_pos
  552.     case @face_pic_txt
  553.       when 0  # 文字
  554.         x = self.x + FUKI::NAME_SHIFT_X
  555.         y = self.y - FUKI::NAME_FONT_SIZE - 16 + FUKI::NAME_SHIFT_Y
  556.       when 1  # 图片
  557.         if self.x >= @pic_width + 5
  558.           # 默认头像显示在对话框左边
  559.           x = self.x-@pic_width-5
  560.         else
  561.           # 对话框左边放不下时头像显示在右边
  562.           x = self.x + self.width
  563.         end
  564.         y = self.y+self.height/2 - (@pic_height + 5)/2
  565.       end

  566.     return [x,y]
  567.   end
  568.   
  569.   #--------------------------------------------------------------------------
  570.   # ○ 设置角色名字窗口
  571.   #--------------------------------------------------------------------------
  572.   def set_namewindow
  573.    
  574.     # $mes_name为空时不显示角色名字窗口
  575.     if $mes_name == nil or $mes_name == ""
  576.       return
  577.     else
  578.       # 设定变量
  579.       mes_name = $mes_name
  580.       skin = FUKI::NAME_SKIN_NAME != "" ? FUKI::NAME_SKIN_NAME : $game_system.windowskin_name
  581.       
  582.       #判断名称是否有对应的图片"Graphics/heads/" +
  583.       if $game_temp.namebmp[mes_name] == nil then
  584.         sFile = "Graphics/Heads/" + mes_name + ".png"
  585.       else
  586.         sFile = "Graphics/Heads/" + $game_temp.namebmp[mes_name] + ".png"
  587.       end
  588.       
  589.       if FileTest.exist?(sFile) == true then
  590.         
  591.         @face_pic_txt = 1                       #名字窗口使用头像<- bbschat
  592.         
  593.         # 生成头像
  594.         bmp = Bitmap.new(sFile)
  595.         @pic_width = bmp.width
  596.         @pic_height = bmp.height
  597.         
  598.         if self.x >= @pic_width + 5
  599.           # 默认头像显示在对话框左边
  600.           name_x = self.x-@pic_width-5
  601.         else
  602.           # 对话框左边放不下时头像显示在右边
  603.           name_x = self.x + self.width
  604.         end
  605.         name_y = self.y+self.height/2 - (@pic_height + 5)/2
  606.         
  607.         # 生成角色头像窗口
  608.         @name_win = Window_Base.new(name_x, name_y, @pic_width + 5, @pic_height + 5)
  609.         @name_win.windowskin = RPG::Cache.windowskin(skin)
  610.         @name_win.back_opacity =0     
  611.         @name_win.z = self.z + 1
  612.         
  613.         @name_contents = Sprite.new
  614.         @name_contents.x = name_x + 2
  615.         @name_contents.y = name_y + 2
  616.         @name_contents.bitmap = bmp
  617.         #@name_contents.z = @name_win.z + 2     #这个用了似乎效果不好<- bbschat
  618.         
  619.       else
  620.         
  621.         @face_pic_txt = 0                       #名字窗口使用文字<- bbschat

  622.         # 生成名字
  623.         name_width = mes_name.size / 2 * FUKI::NAME_FONT_SIZE
  624.         name_height = FUKI::NAME_FONT_SIZE
  625.         name_x = self.x + FUKI::NAME_SHIFT_X
  626.         name_y = self.y - name_height - 16 + FUKI::NAME_SHIFT_Y

  627.         # 生成角色名字窗口(只有边框)
  628.         @name_win = Window_Base.new(name_x, name_y, name_width + 16, name_height + 16)
  629.         @name_win.windowskin = RPG::Cache.windowskin(skin)
  630.         @name_win.back_opacity = FUKI::NAME_OPACITY
  631.         @name_win.z = self.z + 1
  632.         
  633.         # 为了使空白比Windows类限定的更小使用双重结构
  634.         @name_contents = Sprite.new
  635.         @name_contents.x = name_x + 12
  636.         @name_contents.y = name_y + 8
  637.         @name_contents.bitmap = Bitmap.new(name_width, name_height)
  638.         @name_contents.z = @name_win.z + 2
  639.         
  640.         # 设定文字色
  641.         nil_color = Color.new(0,0,0,0)
  642.         if FUKI::NAME_COLOR != nil_color
  643.           @name_contents.bitmap.font.color = FUKI::NAME_COLOR
  644.         else
  645.           @name_contents.bitmap.font.color = normal_color
  646.         end
  647.         @name_contents.bitmap.font.size = FUKI::NAME_FONT_SIZE
  648.         # 调整窗口尺寸
  649.         rect = @name_contents.bitmap.text_size(mes_name)
  650.         @name_win.width = rect.width + 32
  651.         # 描画名字
  652.         @name_contents.bitmap.draw_text(rect, mes_name)
  653.       end
  654.     end

  655.   end
  656.   
  657.   #--------------------------------------------------------------------------
  658.   # ○ 释放呼出对话框和角色名字窗口
  659.   #--------------------------------------------------------------------------
  660.   def del_fukidasi
  661.     if @tale != nil
  662.       @tale.dispose
  663.       @tale = nil
  664.     end
  665.     if @name_win != nil
  666.       @name_win.dispose
  667.       @name_win = nil
  668.       @name_contents.dispose
  669.       @name_contents = nil
  670.     end
  671.     self.opacity = 0
  672.     self.x = 80
  673.     self.width = 480
  674.     self.height = 160
  675.     self.contents.dispose
  676.     self.contents = Bitmap.new(width - 32, height - 32)
  677.     self.pause = true
  678.   end
  679.   
  680.   #-------------------------------------------------------------------
  681.   # ○ 取得角色
  682.   #     parameter : 参数
  683.   #-------------------------------------------------------------------
  684.   def get_character(parameter)
  685.     # 参数分歧
  686.     case parameter
  687.     when -1  # 玩家
  688.       return $game_player
  689.     when 0   # 该事件
  690.       events = $game_map.events
  691.       return events == nil ? nil : events[$active_event_id]
  692.     else     # 特定事件
  693.       if parameter >0
  694.         events = $game_map.events
  695.         return events == nil ? nil : events[parameter]
  696.       else
  697.         $game_party.return_char(-parameter-2)
  698.       end
  699.     end
  700.   end

  701.   
  702.   #--------------------------------------------------------------------------
  703.   # ● 设定窗口位置和不透明度
  704.   #--------------------------------------------------------------------------
  705.   def reset_window
  706.     if $game_temp.in_battle
  707.       self.y = 16
  708.     else
  709.       case $game_system.message_position
  710.       when 0  # 上
  711.         self.y = 16
  712.       when 1  # 中
  713.         self.y = 160
  714.       when 2  # 下
  715.         self.y = 304
  716.       end
  717.     end
  718.     if $game_system.message_frame == 0
  719.       self.opacity = 255
  720.     else
  721.       self.opacity = 0
  722.     end
  723.     self.back_opacity = FUKI::MES_OPACITY
  724.   end
  725.   
  726.   #--------------------------------------------------------------------------
  727.   # ● 刷新画面
  728.   #--------------------------------------------------------------------------
  729.   def update
  730.     super
  731.     # 呼出模式下跟随事件移动
  732.     if @tale != nil
  733.       pos = get_fuki_pos(self.width, self.height)
  734.       self.x = pos[0]
  735.       self.y = pos[1]

  736.       tale_pos = get_tale_pos
  737.       @tale.x = tale_pos[0]
  738.       @tale.y = tale_pos[1]
  739.       
  740.       if @name_win != nil
  741.         name_pos = get_name_pos
  742.         @name_win.x = name_pos[0]
  743.         @name_win.y = name_pos[1]
  744.         case @face_pic_txt
  745.           when 0  # 文字
  746.             @name_contents.x = @name_win.x + 12
  747.             @name_contents.y = @name_win.y + 8
  748.           when 1  # 图片
  749.             @name_contents.x = @name_win.x + 2
  750.             @name_contents.y = @name_win.y + 2
  751.           end
  752.       end
  753.     end
  754.    
  755.     # 渐变的情况下
  756.     if @fade_in
  757.       self.contents_opacity += 24
  758.       if @name_win != nil
  759.         @name_win.opacity += 24
  760.       end
  761.       if @tale != nil
  762.         @tale.opacity += 24
  763.       end
  764.       if @input_number_window != nil
  765.         @input_number_window.contents_opacity += 24
  766.       end
  767.       if self.contents_opacity == 255
  768.         @fade_in = false
  769.       end
  770.       return
  771.     end
  772.     # 显示信息中的情况下
  773.     if @contents_drawing
  774.       refresh_drawtext
  775.       if Input.trigger?(Input::C)
  776.         while $game_temp.message_text != ""
  777.           draw_massage
  778.         end
  779.         draw_opt_text
  780.         @contents_showing_end = true
  781.         @contents_drawing = false
  782.       end
  783.       return
  784.     end
  785.     # 输入数值的情况下
  786.     if @input_number_window != nil
  787.       @input_number_window.update
  788.       # 确定
  789.       if Input.trigger?(Input::C)
  790.         $game_system.se_play($data_system.decision_se)
  791.         $game_variables[$game_temp.num_input_variable_id] =
  792.           @input_number_window.number
  793.         $game_map.need_refresh = true
  794.         # 释放输入数值窗口
  795.         @input_number_window.dispose
  796.         @input_number_window = nil
  797.         terminate_message
  798.       end
  799.       return
  800.     end
  801.     # 显示信息结束的情况下
  802.     if @contents_showing_end
  803.       # 不是显示选择项且不是呼出对话模式则显示暂停标志
  804.       if $game_temp.choice_max == 0 and @tale == nil
  805.         self.pause = true
  806.       else
  807.         self.pause = false
  808.       end
  809.       # 取消
  810.       if Input.trigger?(Input::B)
  811.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  812.           $game_system.se_play($data_system.cancel_se)
  813.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  814.           terminate_message
  815.         end
  816.       end
  817.       # 确定
  818.       if Input.trigger?(Input::C)
  819.         if $game_temp.choice_max > 0
  820.           $game_system.se_play($data_system.decision_se)
  821.           $game_temp.choice_proc.call(self.index)
  822.         end
  823.         terminate_message
  824.         # 释放呼出窗口
  825.         del_fukidasi
  826.       end
  827.       return
  828.     end
  829.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  830.     if @fade_out == false and $game_temp.message_text != nil
  831.       @contents_showing = true
  832.       $game_temp.message_window_showing = true
  833.       reset_window
  834.       refresh_create
  835.       if @name_win != nil
  836.         @name_win.opacity = 0
  837.       end
  838.       if @tale != nil
  839.         @tale.opacity = 0
  840.       end
  841.       Graphics.frame_reset
  842.       self.visible = true
  843.       self.contents_opacity = 0
  844.       if @input_number_window != nil
  845.         @input_number_window.contents_opacity = 0
  846.       end
  847.       @fade_in = true
  848.       return
  849.     end
  850.     # 没有可以显示的信息、但是窗口为可见的情况下
  851.     if self.visible
  852.       @fade_out = true
  853.       self.opacity -= 48
  854.       if @name_win != nil
  855.         @name_win.opacity -= 48
  856.       end
  857.       if @tale != nil
  858.         @tale.opacity -= 48
  859.       end
  860.       if self.opacity == 0
  861.         self.visible = false
  862.         @fade_out = false
  863.         $game_temp.message_window_showing = false
  864.         del_fukidasi
  865.       end
  866.       return
  867.     end
  868.   end
  869.   
  870.   #--------------------------------------------------------------------------
  871.   # ● 释放
  872.   #--------------------------------------------------------------------------
  873.   def dispose
  874.     terminate_message
  875.     $game_temp.message_window_showing = false
  876.     if @input_number_window != nil
  877.       @input_number_window.dispose
  878.     end
  879.     super
  880.   end
  881.   
  882.   #--------------------------------------------------------------------------
  883.   # ● 信息结束处理
  884.   #--------------------------------------------------------------------------
  885.   def terminate_message
  886.     self.active = false
  887.     self.pause = false
  888.     self.index = -1
  889.     self.contents.clear
  890.     # 清除显示中标志
  891.     @contents_showing = false
  892.     @contents_showing_end = false
  893.     # 呼叫信息调用
  894.     if $game_temp.message_proc != nil
  895.       $game_temp.message_proc.call
  896.     end
  897.     # 清除文章、选择项、输入数值的相关变量
  898.     $game_temp.message_text = nil
  899.     $game_temp.message_proc = nil
  900.     $game_temp.choice_start = 99
  901.     $game_temp.choice_max = 0
  902.     $game_temp.choice_cancel_type = 0
  903.     $game_temp.choice_proc = nil
  904.     $game_temp.num_input_start = 99
  905.     $game_temp.num_input_variable_id = 0
  906.     $game_temp.num_input_digits_max = 0
  907.     # 释放金钱窗口
  908.     if @gold_window != nil
  909.       @gold_window.dispose
  910.       @gold_window = nil
  911.     end
  912.   end
  913.   
  914.   #--------------------------------------------------------------------------
  915.   # ● 刷新光标矩形
  916.   #--------------------------------------------------------------------------
  917.   def update_cursor_rect
  918.     if @index >= 0
  919.       n = $game_temp.choice_start + @index
  920.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  921.     else
  922.       self.cursor_rect.empty
  923.     end
  924.   end
  925.   #--------------------------------------------------------------------------
  926.   # ● 取得普通文字色
  927.   #--------------------------------------------------------------------------
  928.   def normal_color
  929.     nil_color = Color.new(0,0,0,0)
  930.     if FUKI::FUKI_COLOR != nil_color
  931.       color = FUKI::FUKI_COLOR
  932.     else
  933.       color = super
  934.     end
  935.     return color
  936.   end
  937. end

  938. #==============================================================================
  939. # ■ Interpreter
  940. #==============================================================================

  941. class Interpreter
  942.   #--------------------------------------------------------------------------
  943.   # ● 设置事件
  944.   #     event_id : 事件 ID
  945.   #--------------------------------------------------------------------------
  946.   alias setup_fuki setup
  947.   def setup(list, event_id)
  948.     setup_fuki(list, event_id)
  949.     # 如果不是战斗中
  950.     if !($game_temp.in_battle)
  951.       # 记录事件 ID
  952.       $active_event_id = event_id
  953.     end
  954.   end
  955. end

  956. #==============================================================================
  957. # ■ Scene_Map
  958. #==============================================================================

  959. class Scene_Map
  960.   #--------------------------------------------------------------------------
  961.   # ● 主处理
  962.   #--------------------------------------------------------------------------
  963.   def main
  964.     # 生成活动块
  965.     @spriteset = Spriteset_Map.new
  966.     # 生成信息窗口
  967.     @message_window = Window_FukiMessage.new
  968.     # 执行过渡
  969.     Graphics.transition
  970.     # 主循环
  971.     loop do
  972.       # 刷新游戏画面
  973.       Graphics.update
  974.       # 刷新输入信息
  975.       Input.update
  976.       # 刷新画面
  977.       update
  978.       # 如果画面切换的话就中断循环
  979.       if $scene != self
  980.         break
  981.       end
  982.     end
  983.     # 准备过渡
  984.     Graphics.freeze
  985.     # 释放活动块
  986.     @spriteset.dispose
  987.     # 释放信息窗口
  988.     @message_window.dispose
  989.     # 标题画面切换中的情况下
  990.     if $scene.is_a?(Scene_Title)
  991.       # 淡入淡出画面
  992.       Graphics.transition
  993.       Graphics.freeze
  994.     end
  995.   end
  996. end

  997. #==============================================================================
  998. # ■ Window_InputNumber
  999. #==============================================================================

  1000. class Window_InputNumber < Window_Base
  1001.   #--------------------------------------------------------------------------
  1002.   # ● 初始化对像
  1003.   #     digits_max : 位数
  1004.   #--------------------------------------------------------------------------
  1005.   def initialize(digits_max)
  1006.     @digits_max = digits_max
  1007.     @number = 0
  1008.     # 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
  1009.     dummy_bitmap = Bitmap.new(32, 32)
  1010.     dummy_bitmap.font.size = FUKI::MES_FONT_SIZE
  1011.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  1012.     dummy_bitmap.dispose
  1013.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  1014.     self.contents = Bitmap.new(width - 32, height - 32)
  1015.     self.contents.font.size = FUKI::MES_FONT_SIZE
  1016.     self.z += 9999
  1017.     self.opacity = 0
  1018.     @index = 0
  1019.     refresh
  1020.     update_cursor_rect
  1021.   end
  1022. end
复制代码
dsu_plus_rewardpost_czw
作者: 2578699    时间: 2011-8-21 11:30
呼出对话框.rar (408.78 KB, 下载次数: 218) 用这里面的脚本试试吧
作者: zdc223658    时间: 2011-8-21 12:12
2578699 发表于 2011-8-21 11:30
用这里面的脚本试试吧

一样的脚本啊,我想同时出现头像和名字 需要怎么弄?


zdc223658于2011-8-21 12:21补充以下内容:
[attachimg]71646[/attachimg]           我要的是图片上面也显示带名字的那个框框    你说的那种是在图片上ps上名字 不一样额...
作者: 钢铁列兵    时间: 2011-8-21 12:28
本帖最后由 钢铁列兵 于 2011-8-21 12:30 编辑

chat(A,"XXX")
其中A为事件角色的号码,主角的话用-1;XXX就是你在143行设置的与head下图片对应的名称

例如:chat(-1,"玩家")
顺便说一下,以上操作在事件指令第三页最后一项的脚本中操作




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