Project1

标题: 名字上面有框框这是怎么实现的呢 [打印本页]

作者: 契约师Vi    时间: 2024-2-25 12:35
标题: 名字上面有框框这是怎么实现的呢
如图
作者: 纯属小虫    时间: 2024-3-4 16:30
用bitmap在窗口第一行画一个矩形就好了
作者: 无忧谷主幻    时间: 2024-3-12 06:07
插入脚本,然后在对话框中输入代码
我记得脚本中有注释吧

贴一个使用范例



作者: 纯属小虫    时间: 2024-3-23 16:25
纯属小虫 发表于 2024-3-4 16:30
用bitmap在窗口第一行画一个矩形就好了
  1.       if name_window_set
  2.         off_x = 0
  3.         off_y = -40
  4.         space = 2
  5.         x = self.x + off_x - space / 2
  6.         y = self.y + off_y - space / 2
  7.         w = self.contents.text_size(name_text).width + 26 + space
  8.         h = 40 + space
  9.         x = self.x + off_x + 4
  10.         y = self.y + off_y
  11.         @name_window_text = Air_Text.new(self.x + @face_indent+4+8, self.y+16, name_text, name_color)
  12.         @name_window_text.z = self.z + 2
  13.         @bar = Sprite.new
  14.         @bar.bitmap = Bitmap.new(self.width, 24)
  15.         face_cut = @face_bitmap == nil ? 0 : @face_indent + 2
  16.         @bar.x = self.x + 8 + face_cut
  17.         @bar.y = self.y + 16
  18.         @bar.z = self.z + 2
  19.         @bar.bitmap.fill_rect(0,0,self.width-16-face_cut,24, Name_Bar_Color)
  20.       end
复制代码


这个是从我的对话框的名字色背景矩形描绘的对应的一段的脚本
你试试看能不能插入你的脚本
【注意适配类变量的变量名,并在释放的窗口的时候释放对应的矩形框框】
作者: 契约师Vi    时间: 3 天前
纯属小虫 发表于 2024-3-23 16:25
这个是从我的对话框的名字色背景矩形描绘的对应的一段的脚本
你试试看能不能插入你的脚本
【注意适配类 ...

疯狂报错 这是我用的脚本 看能不能拯救一下感谢大佬
  1. #==============================================================================
  2. #
  3. #    呼出对话框 ver. 1.31 By パラ犬(日)
  4. #  来自 http://rpg.para.s3p.net/
  5. #
  6. #  汉化修改 66RPG bbschat(2006.1.5)
  7. #    来自 http://www.66RPG.com/
  8. #
  9. #    脚本更新:by KKME◎66RPG.com,2007年2月
  10. #
  11. #==============================================================================
  12. #    ●准备工作-窗口Skin
  13. #
  14. #    首先,确认自己使用的对话框窗口Skin,(数据库-系统-窗口外观图形)
  15. #    然后根据该窗口Skin制作对话框尾部使用的两个箭头图形
  16. #    尾部箭头图形命名方式:“窗口skin名-top”,“窗口skin名-under”
  17. #    将该图形文件存放在“Graphics/Windowskins”文件夹下。
  18. #
  19. #    本演示游戏内置2套窗口和箭头图形,
  20. #    一套是游戏默认的“001-Blue01”,一套是定制的“fk”
  21. #    玩家可以根据自己的需要参照样本定制自己的呼出对话框窗口Skin。
  22. #
  23. #  ★●使用方法 edit by KKME◎66RPG.com
  24. #
  25. #    方法一:传统方法:输入脚本:chat(事件编号, "角色姓名")。这样就可以正常显示。
  26. #            这种方法虽然使用麻烦,但是有时候也会用到(比如不显示姓名的对话)。这种方法比方法二优先度高。
  27. #            当不需要这种对话功能时候,直接输入一个脚本:chat,就能全部清空。
  28. #
  29. #    方法二:新方法:直接输入对话,会自动读取人名。
  30. #            举例:首先将事件NPC命名,比如命名为“王小二”
  31. #            则输入对话:
  32. #               王小二:
  33. #               今天天气真好啊。
  34. #    这样就能直接将对话显示在这个NPC头上。如果姓名是我方队员则可自动显示在主角头上。
  35. #    这种方法对于我方队员的情况支持 \n[1]这样的效果。如
  36. #               \n[1]:
  37. #               明天听说要下雨。
  38. #    也能正确显示。对于一般的游戏制作这样已经足够了,如果还有特殊需求——小生是
  39. #    知道有可能需要什么特殊需求的:),其实也设置了接口可以满足,不过需要你自己研究一下。
  40. #            
  41. #
  42. #  ★●角色名字窗口使用角色图片的方法(汉化特别追加功能,原脚本只能使用文字)
  43. #   
  44. #    如果能在对应文件夹中找到文件名和角色名字相同的图片,   
  45. #    则角色名字窗口显示角色头像图片,角色图片最好能包括角色的名字。
  46. #    默认头像图片保存目录为“Graphics/Heads/”,玩家可自行修改。
  47. #
  48. #    如果不想使用角色名字直接作为头像文件名。可以使用下面在 Game_Temp 类里增加的namebmp属性。
  49. #    重新设定角色名字与文件名的对应关系。
  50. #
  51. #  KKME注:这里修改了原有算法,可以支持中文名。小生以为不再需要Game_Temp类了。
  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 = 20  # 呼出对话框
  77.   NAME_FONT_SIZE = 23  # 角色名字窗口
  78.   
  79.   # 字体颜色
  80.   #(设定为 Color.new(0, 0, 0, 0) 表示使用普通文字色)
  81.   FUKI_COLOR = Color.new(255, 255, 255, 255)  # 呼出对话框
  82.   NAME_COLOR = Color.new(255, 255, 255, 255)  # 角色名字窗口
  83.   
  84.   # 窗口透明度
  85.   # 如修改窗口透明度请同时修改尾部箭头图形内部的透明度
  86.   FUKI_OPACITY = 210 # 210呼出对话框
  87.   MES_OPACITY = 210    # 210默认信息窗口
  88.   NAME_OPACITY = 210  # 210角色名字窗口
  89.   
  90.   # 角色名字窗口的相对位置
  91.   NAME_SHIFT_X =-10      # 横坐标
  92.   NAME_SHIFT_Y = 5    # 纵坐标
  93.   
  94.   # 窗口表示时是否根据画面大小自动检查窗口出现的位置,
  95.   # 自动改变位置( true / false )
  96.   # 设置成 true 在某些变态情况下可能出现箭头图标颠倒的问题 <- bbschat <= KKME
  97.   POS_FIX = true

  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. # 初始化两个变量,不要动(by KKME◎66RPG.com)
  115. #==============================================================================
  116. $mes_name = ""
  117. $mes_id   = nil


  118. #==============================================================================
  119. # 方便用户同时设置2个常用参数而使用的函数
  120. #==============================================================================
  121. def chat(id = nil,name = "")
  122.   $mes_id = id
  123.   $mes_name = name
  124. end

  125. #==============================================================================
  126. # □ Game_Temp
  127. #==============================================================================

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

  138. #==============================================================================
  139. # □ Window_Message
  140. #==============================================================================

  141. class Window_Message < Window_Selectable

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

  584.   #--------------------------------------------------------------------------
  585.   # ○ 计算名字窗口的位置
  586.   #--------------------------------------------------------------------------
  587.   def get_name_pos
  588.     case @face_pic_txt
  589.       when 0  # 文字
  590.         x = self.x + FUKI::NAME_SHIFT_X
  591.         y = self.y - FUKI::NAME_FONT_SIZE - 16 + FUKI::NAME_SHIFT_Y
  592.       when 1  # 图片
  593.         if self.x >= @pic_width + 5
  594.           # 默认头像显示在对话框左边
  595.           x = self.x-@pic_width-5
  596.         else
  597.           # 对话框左边放不下时头像显示在右边
  598.           x = self.x + self.width
  599.         end
  600.         y = self.y+self.height/2 - (@pic_height + 5)/2
  601.       end

  602.     return [x,y]
  603.   end
  604.   
  605.   #--------------------------------------------------------------------------
  606.   # ○ 设置角色名字窗口
  607.   #--------------------------------------------------------------------------
  608.   def set_namewindow
  609.    
  610.     # $mes_name为空时不显示角色名字窗口
  611.     if $mes_name == nil or $mes_name == ""
  612.       return
  613.     else
  614.       # 设定变量
  615.       mes_name = $mes_name
  616.       skin = FUKI::NAME_SKIN_NAME != "" ? FUKI::NAME_SKIN_NAME : $game_system.windowskin_name
  617.       
  618.       #判断名称是否有对应的图片"Graphics/heads/" +
  619.       if $game_temp.namebmp[mes_name] == nil then
  620.         sFile = "Graphics/heads/" + mes_name + ".png"
  621.       else
  622.         sFile = "Graphics/heads/" + $game_temp.namebmp[mes_name] + ".png"
  623.       end
  624.       
  625.       #if FileTest.exist?(sFile) == true then
  626.       begin
  627.         
  628.         @face_pic_txt = 1                       #名字窗口使用头像<- bbschat
  629.         
  630.         # 生成头像
  631.         bmp = Bitmap.new(sFile)
  632.         @pic_width = bmp.width
  633.         @pic_height = bmp.height
  634.         
  635.         if self.x >= @pic_width + 5
  636.           # 默认头像显示在对话框左边
  637.           name_x = self.x-@pic_width-5
  638.         else
  639.           # 对话框左边放不下时头像显示在右边
  640.           name_x = self.x + self.width
  641.         end
  642.         name_y = self.y+self.height/2 - (@pic_height + 5)/2
  643.         
  644.         # 生成角色头像窗口
  645.         @name_win = Window_Base.new(name_x, name_y, @pic_width + 5, @pic_height + 5)
  646.         @name_win.windowskin = RPG::Cache.windowskin(skin)
  647.         @name_win.back_opacity =0     
  648.         @name_win.z = self.z + 1
  649.         
  650.         @name_contents = Sprite.new
  651.         @name_contents.x = name_x + 2
  652.         @name_contents.y = name_y + 2
  653.         @name_contents.bitmap = bmp
  654.         @name_contents.z = @name_win.z + 2#窗口Z位置  #这个用了似乎效果不好<- bbschat
  655.         
  656.       rescue
  657.         
  658.         @face_pic_txt = 0                       #名字窗口使用文字<- bbschat

  659.         # 生成名字
  660.         name_width = mes_name.size / 2 * FUKI::NAME_FONT_SIZE
  661.         name_height = FUKI::NAME_FONT_SIZE
  662.         name_x = self.x + FUKI::NAME_SHIFT_X
  663.         name_y = self.y - name_height - 16 + FUKI::NAME_SHIFT_Y

  664.         # 生成角色名字窗口(只有边框)
  665.         @name_win = Window_Base.new(name_x, name_y, name_width + 16, name_height + 16)
  666.         @name_win.windowskin = RPG::Cache.windowskin(skin)
  667.         @name_win.back_opacity = FUKI::NAME_OPACITY
  668.         @name_win.z = self.z + 1
  669.         
  670.         # 为了使空白比Windows类限定的更小使用双重结构
  671.         @name_contents = Sprite.new
  672.         @name_contents.x = name_x + 12
  673.         @name_contents.y = name_y + 8
  674.         @name_contents.bitmap = Bitmap.new(name_width, name_height)
  675.         @name_contents.z = @name_win.z + 2
  676.         
  677.         # 设定文字色
  678.         nil_color = Color.new(0,0,0,0)
  679.         if FUKI::NAME_COLOR != nil_color
  680.           @name_contents.bitmap.font.color = FUKI::NAME_COLOR
  681.         else
  682.           @name_contents.bitmap.font.color = normal_color
  683.         end
  684.         @name_contents.bitmap.font.size = FUKI::NAME_FONT_SIZE
  685.         # 调整窗口尺寸
  686.         rect = @name_contents.bitmap.text_size(mes_name)
  687.         @name_win.width = rect.width + 32
  688.         # 描画名字
  689.         @name_contents.bitmap.draw_text(rect, mes_name)
  690.       end
  691.     end

  692.   end
  693.   
  694.   #--------------------------------------------------------------------------
  695.   # ○ 释放呼出对话框和角色名字窗口
  696.   #--------------------------------------------------------------------------
  697.   def del_fukidasi
  698.     if @tale != nil
  699.       @tale.dispose
  700.       @tale = nil
  701.     end
  702.     if @name_win != nil
  703.       @name_win.dispose
  704.       @name_win = nil
  705.       @name_contents.dispose
  706.       @name_contents = nil
  707.     end
  708.     self.opacity = 0
  709.     self.x = 140+150#------------------窗口X坐標位置
  710.     self.width = 580#------------------上下窗口宽度
  711.     self.height = 120#------------------上下窗口高度
  712.     self.contents.dispose
  713.     self.contents = Bitmap.new(width - 32, height - 32)
  714.     self.pause = true
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # ○ 取得角色
  718.   #     parameter : 参数
  719.   #--------------------------------------------------------------------------
  720.   def get_character(parameter)
  721.     # 参数分歧
  722.     case parameter
  723.     when -1  # 玩家
  724.       return $game_player
  725.     when 0   # 该事件
  726.       events = $game_map.events
  727.       return events == nil ? nil : events[$active_event_id]
  728.     else     # 特定事件
  729.       events = $game_map.events
  730.       return events == nil ? nil : events[parameter]
  731.     end
  732.   end
  733.   
  734.   #--------------------------------------------------------------------------
  735.   # ● 设定窗口位置和不透明度
  736.   #--------------------------------------------------------------------------
  737.   def reset_window(width = nil, height = nil)
  738.     if $game_temp.in_battle#----------------在战斗中文章显示-窗口y坐標位置
  739.       self.y = 32#+22
  740.       self.x = 270
  741.     else
  742.       case $game_system.message_position
  743.       when 0  # 上
  744.         self.y = 48#----------------上文章显示-窗口y坐標位置
  745.       when 1  # 中
  746.         if height != nil and width != nil
  747.           self.y = (576 - height) / 2 + 0#----------------中间文章显示-窗口y坐標位置
  748.           self.x = (1024 - width) / 2 + 64#----------------中间文章显示-窗口x坐標位置
  749.           self.width = width #----------------中间窗口宽度
  750.           self.height = height #----------------中间窗口高度
  751.           self.contents.dispose
  752.           self.contents = Bitmap.new(width - 32, height - 32)
  753.         else
  754.           self.y = 340#----------------中间文章显示-窗口Y坐標位置
  755.         end
  756.       when 2  # 下
  757.         self.y = 576-146-24#------------------下文章显示-窗口y坐標位置
  758.       end
  759.     end
  760.     if $game_system.message_frame == 0
  761.       self.opacity = 255
  762.     else
  763.       self.opacity = 0
  764.     end
  765.     self.back_opacity = FUKI::MES_OPACITY
  766.   end
  767.   
  768.   #--------------------------------------------------------------------------
  769.   # ● 刷新画面
  770.   #--------------------------------------------------------------------------
  771.   def update
  772.     super
  773.     # 呼出模式下跟随事件移动
  774.     if @tale != nil
  775.       pos = get_fuki_pos(self.width, self.height)
  776.       self.x = pos[0]
  777.       self.y = pos[1]

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


复制代码





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