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

Project1

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

见不到Fuki对话框的朋友请在这里看

[复制链接]

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
跳转到指定楼层
1
发表于 2013-5-15 20:29:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  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 = "001-Blue01"   # 呼出对话框用Skin
  73.   NAME_SKIN_NAME = "001-Blue01"   # 角色名字窗口用Skin
  74.   
  75.   # 字体大小
  76.   MES_FONT_SIZE = 22    # 呼出对话框
  77.   NAME_FONT_SIZE = 14   # 角色名字窗口
  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 = 255    # 呼出对话框
  87.   MES_OPACITY = 255     # 默认信息窗口
  88.   NAME_OPACITY = 255    # 角色名字窗口
  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.   $mes_name = name
  119. end

  120. #==============================================================================
  121. # □ Game_Temp
  122. #==============================================================================

  123. class Game_Temp
  124.   attr_accessor  :namebmp              #保存头像图片的Hash表
  125.   alias initialize_fuki initialize
  126.   def initialize
  127.     initialize_fuki
  128.     # 如果不想使用角色名字直接作为头像文件名
  129.     # 可在这里重新设定角色名字与文件名的对应关系
  130.     @namebmp ={"大雄."=>"daxiongxiangshou", "老师"=>"laoshi","大雄,"=>
  131.     "daxiongnanguo","静香."=>"jingxiangdanxin","胖虎."=>"panghuxiao",
  132.     "小夫."=>"xiaofuxiao","大雄`"=>"daxiongxiao","静香,"=>"jingxiangxiao",
  133.     "大雄/"=>"daxiongsikao","大雄妈妈."=>"daxiongmamashengqi","多啦A梦."=>"duolaguanxin",
  134.     "多啦A梦,"=>"duolawuliao","大雄-"=>"daxiongdaxiao","多啦A梦/"=>"duolanadaojv",
  135.     "大雄="=>"daxiongoutu","多啦A梦`"=>"duolagaoxing",
  136.     "静香-"=>"jingxiangxiangqi","多啦A梦-"=>"duoladanxin","老爷爷"=>"044",
  137.     "静香/"=>"jingxiangshangxin","胖虎/"=>"panghuaoman",
  138.     "小夫/"=>"xiaofuchibuxiao","小夫="=>"xiaofugaoxing",
  139.     "小夫,"=>"xiaofushengqi","胖虎="=>"panghuxionghen","胖虎`"=>"panghusikao",
  140.     "胖虎-"=>"panghuchibuxiao","多啦A梦="=>"duolafaxian","大雄'"=>"daxiongyonggan",
  141.     "大雄]"=>"daxiongjingya","小夫]"=>"xiaofujiaotan","多啦A梦]"=>"duolaguaiyi"}
  142.   end
  143. end

  144. #==============================================================================
  145. # □ Window_FukiMessage
  146. #==============================================================================

  147. class Window_FukiMessage < Window_Selectable

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

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

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

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

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

  658.   end
  659.   
  660.   #--------------------------------------------------------------------------
  661.   # ○ 释放呼出对话框和角色名字窗口
  662.   #--------------------------------------------------------------------------
  663.   def del_fukidasi
  664.     if @tale != nil
  665.       @tale.dispose
  666.       @tale = nil
  667.     end
  668.     if @name_win != nil
  669.       @name_win.dispose
  670.       @name_win = nil
  671.       @name_contents.dispose
  672.       @name_contents = nil
  673.     end
  674.     self.opacity = 0
  675.     self.x = 80
  676.     self.width = 480
  677.     self.height = 160
  678.     self.contents.dispose
  679.     self.contents = Bitmap.new(width - 32, height - 32)
  680.     self.pause = true
  681.   end
  682.   
  683.   #--------------------------------------------------------------------------
  684.   # ○ 取得角色
  685.   #     parameter : 参数
  686.   #--------------------------------------------------------------------------
  687.   def get_character(parameter)
  688.     # 参数分歧
  689.     case parameter
  690.     when -1  # 玩家
  691.       return $game_player
  692.     when 0   # 该事件
  693.       events = $game_map.events
  694.       return events == nil ? nil : events[$active_event_id]
  695.     else     # 特定事件
  696.       events = $game_map.events
  697.       return events == nil ? nil : events[parameter]
  698.     end
  699.   end
  700.   
  701.   #--------------------------------------------------------------------------
  702.   # ● 设定窗口位置和不透明度
  703.   #--------------------------------------------------------------------------
  704.   def reset_window
  705.     if $game_temp.in_battle
  706.       self.y = 16
  707.     else
  708.       case $game_system.message_position
  709.       when 0  # 上
  710.         self.y = 16
  711.       when 1  # 中
  712.         self.y = 160
  713.       when 2  # 下
  714.         self.y = 304
  715.       end
  716.     end
  717.     if $game_system.message_frame == 0
  718.       self.opacity = 255
  719.     else
  720.       self.opacity = 0
  721.     end
  722.     self.back_opacity = FUKI::MES_OPACITY
  723.   end
  724.   
  725.   #--------------------------------------------------------------------------
  726.   # ● 刷新画面
  727.   #--------------------------------------------------------------------------
  728.   def update
  729.     super
  730.     # 呼出模式下跟随事件移动
  731.     if @tale != nil
  732.       pos = get_fuki_pos(self.width, self.height)
  733.       self.x = pos[0]
  734.       self.y = pos[1]

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

  929. #==============================================================================
  930. # ■ Interpreter
  931. #==============================================================================

  932. class Interpreter
  933.   #--------------------------------------------------------------------------
  934.   # ● 设置事件
  935.   #     event_id : 事件 ID
  936.   #--------------------------------------------------------------------------
  937.   alias setup_fuki setup
  938.   def setup(list, event_id)
  939.     setup_fuki(list, event_id)
  940.     # 如果不是战斗中
  941.     if !($game_temp.in_battle)
  942.       # 记录事件 ID
  943.       $active_event_id = event_id
  944.     end
  945.   end
  946. end

  947. #==============================================================================
  948. # ■ Scene_Map
  949. #==============================================================================

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

  988. #==============================================================================
  989. # ■ Window_InputNumber
  990. #==============================================================================

  991. class Window_InputNumber < Window_Base
  992.   #--------------------------------------------------------------------------
  993.   # ● 初始化对像
  994.   #     digits_max : 位数
  995.   #--------------------------------------------------------------------------
  996.   def initialize(digits_max)
  997.     @digits_max = digits_max
  998.     [url=home.php?mod=space&uid=27178]@Number[/url] = 0
  999.     # 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
  1000.     dummy_bitmap = Bitmap.new(32, 32)
  1001.     dummy_bitmap.font.size = FUKI::MES_FONT_SIZE
  1002.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  1003.     dummy_bitmap.dispose
  1004.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  1005.     self.contents = Bitmap.new(width - 32, height - 32)
  1006.     self.contents.font.size = FUKI::MES_FONT_SIZE
  1007.     self.z += 9999
  1008.     self.opacity = 0
  1009.     @index = 0
  1010.     refresh
  1011.     update_cursor_rect
  1012.   end
  1013. end
复制代码
使用方法:
  1. $mes_id = #这里填事件ID,0代表本事件,-1代表玩家,使用时把此注释删除,换成事件号。
  2. $mes_name = ""#这里填姓名,用时把注释删除,换成姓名。
复制代码
+文章
呃,发糖贴好冷清呀!
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-5-9 20:04

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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