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

Project1

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

[已发主站] 【XP】超级打字对话框高度精简版

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
跳转到指定楼层
1
发表于 2012-7-23 21:54:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 Sion 于 2013-12-16 23:17 编辑

工作了几个小时,终于完成了,忍不住发出来跟大家分享。
这个对话框是在RMXP默认对话框的基础上参考众多对话框修改而成的高度精简版,加入了打字、阴影显示等的功能。因为保留了默认脚本的70%(包括注释),所以基本上与其他脚本没冲突,字体颜色显示的问题已经解决请主站更新代码


参考的脚本:1、黑暗圣剑传说的阴影显示
            2、真对话加强脚本(柳柳加强)的打字效果
            3、系统默认脚本

主要功能:
#按下空格键会跳过打字
# \n[1]:显示1号角色的姓名
# \\:显示"\"这个符号
# \c[1-8]:更改颜色
# \g:显示金钱窗口
# \s[n]:(n的取值为1-19)更改弹字的速度
#\i[n] : 显示第n号物品的图标和名称.
#\k[n] : 显示第n号特技的图标和名称.
#\m[n] : 显示第n号防具的图标和名称.
#\w[n] : 显示第n号武器的图标和名称.

另外此脚本的扩展性能非常强,可以直接添加其他功能。

使用方法简介:
1、打字功能:在第177行,text_not_skip=true为打字功能,等于false为直接显示文字。如果想在事件中控制,则可以在Game_System类的前面添加一个属性attr_accessor :typing
             再更改185行的text_not_skip=$game_system.typing,然后在事件中用脚本编辑改变$game_system.typing的值控制打字效果。(呵呵,这个是很基本的修改方法了)
             打字速度可以用\s[n(1-19)]在编辑对话时修改,也可以在脚本第85行修改,数值从0-19.

2、阴影效果:在事件中用脚本编辑$showing_main_message==1,就是阴影效果,其他为默认显示。
阴影的颜色在328行修改,字体的颜色在334行修改(PS:运用阴影效果与\C[序号]改变颜色的方式有冲突,\C[序号]会失效,这样可以把334行代码去掉,这样就可以用\C[序号]改            变颜色,但是可能颜色会比较雷人,另外阴影的颜色默认是黑色,也329行或者修改,可以在倒数第三行修改)。
4、另外在事件脚本中可以用$game_system.message_position来改变窗口的显示位置,具体情况请看134行,当然可以自己多加一些when,呵呵。
5、更多的功能请大家自己去发掘。
6、如果转载此脚本,请标注出处。

示范工程里的脚本有几个BUG,请用直接复制下面的最新脚本。
示范:http://115.com/file/e7c5ravu
补充附件: Project8.zip (289.43 KB, 下载次数: 143)


  1. # 在对话中可以使用的功能:
  2.   
  3. # \n[1]:显示1号角色的姓名
  4. # \\:显示"\"这个符号
  5. # \c[1-8]:更改颜色
  6. # \g:显示金钱窗口
  7. # \s[n(1-19)]:更改弹字的速度
  8. #\i[n] : 显示第n号物品的图标和名称.
  9. #\k[n] : 显示第n号特技的图标和名称.
  10. #\m[n] : 显示第n号防具的图标和名称.
  11. #\w[n] : 显示第n号武器的图标和名称.

  12. #==============================================================================
  13. # ■ Window_Message
  14. #------------------------------------------------------------------------------
  15. #  显示文章的信息窗口。
  16. #==============================================================================
  17. # 转载请注明出处————666RPG-盛尘恋-修改制作———————————————
  18. #——————————————————————————————————————
  19. class Window_Message < Window_Selectable
  20.   #--------------------------------------------------------------------------
  21.   # ● 初始化状态
  22.   #--------------------------------------------------------------------------
  23.   def initialize
  24.     super(80, 304, 480, 160)
  25.     self.contents = Bitmap.new(width - 32, height - 32)
  26.     self.visible = false
  27.     self.z = 9998
  28.     @fade_in = false
  29.     @fade_out = false
  30.     @contents_showing = false
  31.     @cursor_width = 0
  32.     self.active = false
  33.     self.index = -1
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 释放
  37.   #--------------------------------------------------------------------------
  38.   def dispose
  39.     terminate_message
  40.     $game_temp.message_window_showing = false
  41.     if @input_number_window != nil
  42.       @input_number_window.dispose
  43.     end
  44.     super
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 处理信息结束
  48.   #--------------------------------------------------------------------------
  49.   def terminate_message
  50.     self.active = false
  51.     self.pause = false
  52.     self.index = -1
  53.     self.contents.clear
  54.     # 清除显示中标志
  55.     @contents_showing = false
  56.     # 呼叫信息调用
  57.     if $game_temp.message_proc != nil
  58.       $game_temp.message_proc.call
  59.     end
  60.     # 清除文章、选择项、输入数值的相关变量
  61.     $game_temp.message_text = nil
  62.     $game_temp.message_proc = nil
  63.     $game_temp.choice_start = 99
  64.     $game_temp.choice_max = 0
  65.     $game_temp.choice_cancel_type = 0
  66.     $game_temp.choice_proc = nil
  67.     $game_temp.num_input_start = 99
  68.     $game_temp.num_input_variable_id = 0
  69.     $game_temp.num_input_digits_max = 0
  70.     # 开放金钱窗口
  71.     if @gold_window != nil
  72.       @gold_window.dispose
  73.       @gold_window = nil
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 刷新
  78.   #--------------------------------------------------------------------------
  79.   def refresh
  80.     self.contents.clear
  81.     self.contents.font.color = normal_color
  82.     @x = @y = 0
  83.     @cursor_width = 0
  84.     @write_speed = 2                               # 设置打字速度
  85.     @write_wait = 0
  86.     # 到选择项的下一行字
  87.     if $game_temp.choice_start == 0
  88.       @x = 8
  89.     end
  90.     # 有等待显示的文字的情况下
  91.     if $game_temp.message_text != nil
  92.       @text = $game_temp.message_text
  93.       # 限制文字处理
  94.       begin
  95.         last_text = @text.clone
  96.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  97.       end until @text == last_text
  98.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  99.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  100.       end
  101.       # 为了方便、将 "\\\\" 变换为 "\000"
  102.       @text.gsub!(/\\\\/) { "\000" }
  103.       # "\\C" 变为 "\001" 、"\\G" 变为 "\002"
  104.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  105.       @text.gsub!(/\\[Gg]/) { "\002" }
  106.       @text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  107.       @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\004[#{$1}]" }
  108.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]" }
  109.       @text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\006[#{$1}]" }
  110.       @text.gsub!(/\\[Kk]\[([0-9]+)\]/) { "\007[#{$1}]" }
  111.     end
  112.       reset_window
  113.     # 选择项的情况
  114.     if $game_temp.choice_max > 0
  115.       @item_max = $game_temp.choice_max
  116.       self.active = true
  117.       self.index = 0
  118.     end
  119.     # 输入数值的情况
  120.     if $game_temp.num_input_variable_id > 0
  121.       digits_max = $game_temp.num_input_digits_max
  122.       number = $game_variables[$game_temp.num_input_variable_id]
  123.       @input_number_window = Window_InputNumber.new(digits_max)
  124.       @input_number_window.number = number
  125.       @input_number_window.x = self.x + 8
  126.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  127.     end
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 设置窗口位置与不透明度
  131.   #--------------------------------------------------------------------------
  132.   def reset_window
  133.     if $game_temp.in_battle
  134.       self.y = 16
  135.     else
  136.       case $game_system.message_position
  137.       when 0  # 上
  138.         self.y = 16
  139.       when 1  # 中
  140.         self.y = 160
  141.       when 2  # 下
  142.         self.y = 304
  143.       end
  144.     end
  145.     if $game_system.message_frame == 0
  146.       self.opacity = 255
  147.     else
  148.       self.opacity = 0
  149.     end
  150.     self.back_opacity = 160
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 刷新画面
  154.   #--------------------------------------------------------------------------
  155.   def update
  156.     super
  157.     # 渐变的情况下
  158.     if @fade_in
  159.       self.contents_opacity += 24
  160.       if @input_number_window != nil
  161.         @input_number_window.contents_opacity += 24
  162.       end
  163.       if self.contents_opacity == 255
  164.         @fade_in = false
  165.       end
  166.       return
  167.     end
  168.    
  169.      # c 获取 1 个字 (如果不能取得文字就循环)
  170.      @text = nil if @text == ""
  171.     if @text != nil
  172.       if @write_wait > 0
  173.         @write_wait -= 1
  174.         return
  175.       end
  176.     text_not_skip = true
  177.      while true
  178.       if (c = @text.slice!(/./m)) != nil
  179.         # \\ 的情况下
  180.         if c == "\000"
  181.           # 还原为本来的文字
  182.           c = "\\"
  183.         end
  184.         # \C[n] 的情况下
  185.         if c == "\001"
  186.           # 更改文字色
  187.           @text.sub!(/\[([0-9]+)\]/, "")
  188.           color = $1.to_i
  189.           if color >= 0 and color <= 7
  190.             self.contents.font.color = text_color(color)
  191.           end
  192.           # 下面的文字
  193.           c = ""
  194.         end
  195.         # \G 的情况下
  196.         if c == "\002"
  197.           # 生成金钱窗口
  198.           if @gold_window == nil
  199.             @gold_window = Window_Gold.new
  200.             @gold_window.x = 560 - @gold_window.width
  201.             if $game_temp.in_battle
  202.               @gold_window.y = 192
  203.             else
  204.               @gold_window.y = self.y >= 128 ? 32 : 384
  205.             end
  206.             @gold_window.opacity = self.opacity
  207.             @gold_window.back_opacity = self.back_opacity
  208.           end
  209.           # 下面的文字
  210.           c = ""
  211.         end
  212.         if c == "\003"
  213.             @text.gsub!(/\[([0-9]+)\]/, "")
  214.             speed = $1.to_i
  215.             if speed >= 0 and speed <= 19
  216.               @write_speed = speed
  217.             end
  218.             c = ""
  219.           end
  220.           if c == "\004"
  221.             @text.sub!(/\[([0-9]+)\]/, "")
  222.             item_sub = $1.to_i
  223.             c = $data_items[item_sub].name
  224.             l = self.contents.text_size(c).width
  225.             bitmap = RPG::Cache.icon($data_items[item_sub].icon_name)
  226.             self.contents.blt(@x+4, @y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  227.             @x += 28
  228.             if $showing_main_message==1
  229.               self.contents.font.color = outline_color
  230.               self.contents.draw_text(4 + @x-1+2, 32 * @y+2, 40, 32, c)
  231.               self.contents.draw_text(4 + @x+1+2, 32 * @y+2, 40, 32, c)
  232.               self.contents.draw_text(4 + @x+2, 32 * @y+1+2, 40, 32, c)
  233.               self.contents.draw_text(4 + @x+2, 32 * @y-1+2, 40, 32, c)
  234.               self.contents.font.color = text_color(3)
  235.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  236.             else
  237.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  238.             end
  239.             @x = @x + l + 24
  240.             c = ""
  241.           end
  242.           if c == "\005"
  243.             @text.sub!(/\[([0-9]+)\]/, "")
  244.             w_sub = $1.to_i
  245.             c = $data_weapons[w_sub].name
  246.             l = self.contents.text_size(c).width
  247.             bitmap = RPG::Cache.icon($data_weapons[w_sub].icon_name)
  248.             self.contents.blt(@x+4, @y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  249.             @x += 28
  250.              if $showing_main_message==1
  251.               self.contents.font.color = outline_color
  252.               self.contents.draw_text(4 + @x-1+2, 32 * @y+2, 40, 32, c)
  253.               self.contents.draw_text(4 + @x+1+2, 32 * @y+2, 40, 32, c)
  254.               self.contents.draw_text(4 + @x+2, 32 * @y+1+2, 40, 32, c)
  255.               self.contents.draw_text(4 + @x+2, 32 * @y-1+2, 40, 32, c)
  256.               self.contents.font.color = text_color(4)
  257.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  258.             else
  259.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  260.             end
  261.             @x = @x + l
  262.             c = ""
  263.           end
  264.           if c == "\006"
  265.             @text.sub!(/\[([0-9]+)\]/, "")
  266.             a_sub = $1.to_i
  267.             c = $data_armors[a_sub].name
  268.             l = self.contents.text_size(c).width
  269.             bitmap = RPG::Cache.icon($data_armors[a_sub].icon_name)
  270.             self.contents.blt(@x+4, @y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  271.             @x += 28
  272.               if $showing_main_message==1
  273.               self.contents.font.color = outline_color
  274.               self.contents.draw_text(4 + @x-1+2, 32 * @y+2, 40, 32, c)
  275.               self.contents.draw_text(4 + @x+1+2, 32 * @y+2, 40, 32, c)
  276.               self.contents.draw_text(4 + @x+2, 32 * @y+1+2, 40, 32, c)
  277.               self.contents.draw_text(4 + @x+2, 32 * @y-1+2, 40, 32, c)
  278.               self.contents.font.color = text_color(5)
  279.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  280.             else
  281.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  282.             end
  283.             @x = @x + l
  284.             c = ""
  285.           end
  286.           if c == "\007"
  287.             @text.sub!(/\[([0-9]+)\]/, "")
  288.             skill_sub = $1.to_i
  289.             c = $data_skills[skill_sub].name
  290.             l = self.contents.text_size(c).width
  291.             bitmap = RPG::Cache.icon($data_skills[skill_sub].icon_name)
  292.             self.contents.blt(@x+4, @y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  293.             @x += 28
  294.               if $showing_main_message==1
  295.               self.contents.font.color = outline_color
  296.               self.contents.draw_text(4 + @x-1+2, 32 * @y+2, 40, 32, c)
  297.               self.contents.draw_text(4 + @x+1+2, 32 * @y+2, 40, 32, c)
  298.               self.contents.draw_text(4 + @x+2, 32 * @y+1+2, 40, 32, c)
  299.               self.contents.draw_text(4 + @x+2, 32 * @y-1+2, 40, 32, c)
  300.               self.contents.font.color = text_color(6)
  301.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  302.             else
  303.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  304.             end
  305.             @x = @x + l
  306.             c = ""
  307.           end
  308.         # 另起一行文字的情况下
  309.         if c == "\n"
  310.           # 刷新选择项及光标的高
  311.           if @y >= $game_temp.choice_start
  312.             @cursor_width = [@cursor_width, @x].max
  313.           end
  314.           # y 加 1
  315.           @y += 1
  316.           @x = 0
  317.           # 移动到选择项的下一行
  318.           if @y >= $game_temp.choice_start
  319.             @x = 8
  320.           end
  321.           # 下面的文字
  322.           c = ""
  323.           end
  324.         # 描绘文字
  325.         if c != ""
  326.   # 描绘文字,此处是阴影效果的描述,在事件中用脚本编辑$showing_main_message==1
  327.           if $showing_main_message==1
  328.               self.contents.font.color = outline_color
  329.               self.contents.draw_text(4 + @x-1+2, 32 * @y+2, 40, 32, c)
  330.               self.contents.draw_text(4 + @x+1+2, 32 * @y+2, 40, 32, c)
  331.               self.contents.draw_text(4 + @x+2, 32 * @y+1+2, 40, 32, c)
  332.               self.contents.draw_text(4 + @x+2, 32 * @y-1+2, 40, 32, c)
  333.               self.contents.font.color = normal_color
  334.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  335.           else
  336.               self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  337.           end
  338.         # x 为要描绘文字的加法运算
  339.         @x += self.contents.text_size(c).width
  340.       end
  341.     if Input.press?(Input::C)
  342.       text_not_skip = false
  343.     end
  344.     if Input.press?(Input::B)
  345.       text_not_skip = false
  346.     end
  347.   else
  348.     text_not_skip = true
  349.     break
  350.   end
  351.         # 終了判定
  352.   if text_not_skip
  353.     break
  354.   end
  355. end
  356.     @write_wait += @write_speed
  357.     return
  358.   end
  359.     # 输入数值的情况下
  360.     if @input_number_window != nil
  361.       @input_number_window.update
  362.       # 确定
  363.       if Input.trigger?(Input::C)
  364.         $game_system.se_play($data_system.decision_se)
  365.         $game_variables[$game_temp.num_input_variable_id] =
  366.           @input_number_window.number
  367.         $game_map.need_refresh = true
  368.         # 释放输入数值窗口
  369.         @input_number_window.dispose
  370.         @input_number_window = nil
  371.         terminate_message
  372.       end
  373.       return
  374.     end
  375.     # 显示信息中的情况下
  376.     if @contents_showing
  377.       # 如果不是在显示选择项中就显示暂停标志
  378.       if $game_temp.choice_max == 0
  379.         self.pause = true
  380.       end
  381.       # 取消
  382.       if Input.trigger?(Input::B)
  383.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  384.           $game_system.se_play($data_system.cancel_se)
  385.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  386.           terminate_message
  387.         end
  388.       end
  389.       # 确定
  390.       if Input.trigger?(Input::C)
  391.         if $game_temp.choice_max > 0
  392.           $game_system.se_play($data_system.decision_se)
  393.           $game_temp.choice_proc.call(self.index)
  394.         end
  395.         terminate_message
  396.       end
  397.       return
  398.     end
  399.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  400.     if @fade_out == false and $game_temp.message_text != nil
  401.       @contents_showing = true
  402.       $game_temp.message_window_showing = true
  403.       reset_window
  404.       refresh
  405.       Graphics.frame_reset
  406.       self.visible = true
  407.       self.contents_opacity = 0
  408.       if @input_number_window != nil
  409.         @input_number_window.contents_opacity = 0
  410.       end
  411.       @fade_in = true
  412.       return
  413.     end
  414.     # 没有可以显示的信息、但是窗口为可见的情况下
  415.     if self.visible
  416.       @fade_out = true
  417.       self.opacity -= 48
  418.       if self.opacity == 0
  419.         self.visible = false
  420.         @fade_out = false
  421.         $game_temp.message_window_showing = false
  422.       end
  423.       return
  424.     end
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 刷新光标矩形
  428.   #--------------------------------------------------------------------------
  429.   def update_cursor_rect
  430.     if [url=home.php?mod=space&uid=370741]@Index[/url] >= 0
  431.       n = $game_temp.choice_start + @index
  432.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  433.     else
  434.       self.cursor_rect.empty
  435.     end
  436.   end
  437.   def outline_color
  438.     return Color.new(12, 12, 12)
  439.   end
  440. end
  441. # 转载请注明出处————666RPG-盛尘恋-修改制作———————————————
  442. #——————————————————————————————————————
复制代码

评分

参与人数 1+6 收起 理由
Shy07 + 6 主站收录

查看全部评分

Lv2.观梦者

梦石
0
星屑
294
在线时间
371 小时
注册时间
2010-8-23
帖子
418
2
发表于 2012-8-31 20:15:32 | 只看该作者
抱歉,挖坟了啊,有个BUG,/c[序号] 颜色失效啊

点评

呵呵,谢谢哦,其实我也发现了,现在已经解决,我上传了新的脚本  发表于 2012-9-1 17:04
真正做游戏的游戏人是不会整天发帖灌水的!!!
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
294
在线时间
371 小时
注册时间
2010-8-23
帖子
418
3
发表于 2012-9-1 20:40:56 | 只看该作者

RE: 超级打字对话框高度精简版 [修改]

测试成功,完美!
另外补充一点,播放速度直接 /s[n] 即可,n的范围是1-19
/s[n(5)] 这样的是无效的

点评

提醒下:你连贴了,小心哦~  发表于 2012-9-2 11:16
真正做游戏的游戏人是不会整天发帖灌水的!!!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 15:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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