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

Project1

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

[已经解决] 关于苹果梨的对话脚本头像问题!

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
162 小时
注册时间
2010-7-19
帖子
205
跳转到指定楼层
1
发表于 2010-12-21 13:53:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 蓝泪红霜 于 2010-12-21 21:43 编辑

   我在用苹果梨的脚本,可是由于默认的头像显示是在右边,看起来不是很方便,所以想请教一下坛子里会修改脚本的亲们。
    其实我有联系过苹果梨,可是他貌似已经忘记脚本的编制方法了……
    有哪位好心人能帮我把这个脚本修改成\h[头像]默认在对话框左边的呢?
  1. #==============================================================================
  2. # ◎ GPRA_Window_Message
  3. #------------------------------------------------------------------------------
  4. # ◎ 显示文章的信息窗口加强。
  5. #------------------------------------------------------------------------------
  6. # 制作者:绿梨子红苹果
  7. # 个人主页:vbgm.9126.com
  8. # E-Mail:[email protected]
  9. # QQ:42378361
  10. #==============================================================================

  11. class Window_Message < Window_Selectable
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化状态
  14.   #--------------------------------------------------------------------------
  15.   def initialize
  16.     super(80, 304, 480, 160)
  17.     self.contents = Bitmap.new(width - 32, height - 32)
  18.     self.visible = false
  19.     self.z = 9998
  20.     @fade_in = false
  21.     @fade_out = false
  22.     @contents_showing = false
  23.     @cursor_width = 0
  24.     @op = 255 # 不透明度
  25.     @head_bmp = nil # 装载头像用
  26.     @head_file = nil # 头像文件名
  27.     @text = nil # 记录所处理文字
  28.     @skip = false # 记录是否跳过此次对话
  29.     @auto_close = -1 # 默认不打开自动关闭
  30.     @show_head = false # 记录是否显示头像了
  31.     @type_mode=-1 # 打字模式
  32.     @auto_newline=false # 默认不开启自动换行功能
  33.     @delay=-1 # 等待n帧标志
  34.     @finish=false # 记录文字处理是否结束
  35.     @ts = TextStream.new # 创建一个新的TXT读取流
  36.     @is_read_txt =false # 默认不是在读取txt文件
  37.     @pic = nil # 显示图片用
  38.     @pic_x = 0 # 显示图片的X坐标
  39.     @pic_y = 0 # 显示图片的Y坐标
  40.     self.active = false
  41.     self.index = -1
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 释放
  45.   #--------------------------------------------------------------------------
  46.   def dispose
  47.     terminate_message
  48.     $game_temp.message_window_showing = false
  49.     if @input_number_window != nil
  50.       @input_number_window.dispose
  51.     end
  52.     super
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 处理信息结束
  56.   #--------------------------------------------------------------------------
  57.   def terminate_message
  58.     self.active = false
  59.     self.pause = false
  60.     self.index = -1
  61.     self.contents.clear
  62.     # 清除显示中标志
  63.     @contents_showing = false
  64.     # 呼叫信息调用
  65.     if $game_temp.message_proc != nil
  66.       $game_temp.message_proc.call
  67.     end
  68.     # 清除文章、选择项、输入数值的相关变量
  69.     $game_temp.message_text = nil
  70.     $game_temp.message_proc = nil
  71.     $game_temp.choice_start = 99
  72.     $game_temp.choice_max = 0
  73.     $game_temp.choice_cancel_type = 0
  74.     $game_temp.choice_proc = nil
  75.     $game_temp.num_input_start = 99
  76.     $game_temp.num_input_variable_id = 0
  77.     $game_temp.num_input_digits_max = 0
  78.     # 开放金钱窗口
  79.     if @gold_window != nil
  80.       @gold_window.dispose
  81.       @gold_window = nil
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 刷新
  86.   #--------------------------------------------------------------------------
  87.   def refresh
  88.     # 清空原先内容
  89.     self.contents.clear
  90.     # 恢复一般字色
  91.     self.contents.font.color = normal_color
  92.     # 恢复字体大小
  93.     self.contents.font.size = 20
  94.     # 绘制文字位置初始化
  95.     @x = @y = 0
  96.     # 字体高度记录
  97.     @height = 32
  98.     # 文字不透明度设定为255
  99.     @op = 255
  100.     # 默认不显示头像
  101.     @show_head = false
  102.     # 头像默认显示在右边
  103.     @right = true
  104.     # 头像默认显示一般表情
  105.     @face = nil
  106.     # 默认显示角色姓名
  107.     @name = nil
  108.     # 默认是不显示图片的
  109.     @pic = nil
  110.     # 默认不跳过此次对话
  111.     @skip = false
  112.     # 从变量读取自动关闭设置
  113.     @auto_close = $game_variables[2]
  114.     # 从变量读取打字模式设置
  115.     @type_mode=$game_variables[3]
  116.     # 从变量读取自动换行设置
  117.     @auto_newline= ($game_variables[6]==0 ? false : true)
  118.     # 默认不等待
  119.     @delay=-1
  120.     # 设定文字没有处理结束
  121.     @finish=false
  122.     # 光标宽度初始化为零
  123.     @cursor_width = 0
  124.     # 到选择项的下一行字
  125.     if $game_temp.choice_start == 0
  126.       @x = 16
  127.     end
  128.     # 有等待显示的文字的情况下
  129.     # (注:因为一旦文字非空就处理,所以可以设定 $game_temp.message_text 达到显示文章的效果)
  130.     if $game_temp.message_text != nil
  131.       # @text 功能改进
  132.       if @text==nil or @text==""
  133.         @text = $game_temp.message_text.dup
  134.       else
  135.         @text = @text + $game_temp.message_text
  136.       end
  137.       
  138.       # 最先必须要将 "\\\\" 变换为 "\000"
  139.       @text.gsub!(/\\\\/)                { "\000" }
  140.       
  141.       # 在TXT模式还没有打开的时候
  142.       if !@is_read_txt
  143.         # TXT读取模式打开
  144.         if @text.slice!(/\\[Tt][Xx][Tt]\[(\w+)\]\[(\w+)\]/)!=nil
  145.           # 打开文件,成功打开后再进入后面部分
  146.           if @ts.open($1,$2)
  147.             if @auto_newline==true
  148.               #自动换行时只打开一行文字
  149.               @text =  @ts.get_text(1)
  150.             else
  151.               # 根据显示模式确定需要打开行数
  152.               case $game_variables[4]
  153.               when 0 # 正常模式
  154.                 @text =  @ts.get_text(4)
  155.               when 1 # 图书模式
  156.                 @text =  @ts.get_text(12)
  157.               when 2 # 全屏模式
  158.                 @text =  @ts.get_text(15)
  159.               end
  160.             end
  161.             # 如果包含[END]
  162.             if @text.gsub!(/\[END\]/){""}!=nil
  163.               #退出TXT读取模式
  164.               @is_read_txt=false
  165.             else
  166.               #否则设置正在读取标志
  167.               @is_read_txt=true
  168.             end
  169.           end
  170.         else
  171.           if @text.slice!(/\\[Tt][Xx][Tt]\[(\w+)\]/)!=nil
  172.             # 打开文件,成功打开后再进入后面部分
  173.             if @ts.open($1,"")
  174.               if @auto_newline==true
  175.                 #自动换行时只打开一行文字
  176.                 @text =  @ts.get_text(1)
  177.               else
  178.                 # 根据显示模式确定需要打开行数
  179.                 case $game_variables[4]
  180.                 when 0 # 正常模式
  181.                   @text =  @ts.get_text(4)
  182.                 when 1 # 图书模式
  183.                   @text =  @ts.get_text(12)
  184.                 when 2 # 全屏模式
  185.                   @text =  @ts.get_text(15)
  186.                 end
  187.               end
  188.               # 如果包含[END]
  189.               if @text.gsub!(/\[END\]/){""}!=nil
  190.                 #退出TXT读取模式
  191.                 @is_read_txt=false
  192.               else
  193.                 #否则设置正在读取标志
  194.                 @is_read_txt=true
  195.               end
  196.             end
  197.           end
  198.         end
  199.       end
  200.         
  201.       # 如果取得的字符含"\\~"时
  202.       if @text.slice!(/\\~/)!=nil
  203.         # 跳过此次对话
  204.         terminate_message
  205.         # 设置跳过此次对话标志
  206.         @skip = true
  207.         # 直接返回等待连接后面部分
  208.         return
  209.       end
  210.       
  211.       # 限制文字处理(注:这里是默认功能。)
  212.       begin
  213.         last_text = @text.clone
  214.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  215.       end until @text == last_text
  216.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  217.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  218.       end
  219.       #(注:后面将单个字符循环判断,所以这里将控制符全部换成单个字符)
  220.       # 为了方便将 "\\C" 变为 "\001"
  221.       @text.gsub!(/\\[Cc]\[([0-9#a-zA-Z]+)\]/)  { "\001[#{$1}]" }
  222.       # "\\G" 变为 "\002"
  223.       @text.gsub!(/\\[Gg]/)              { "\002" }
  224.       
  225.       # ========================增强功能========================
  226.       
  227.       # 在自动换行模式下,首先删除所有换行符号,然后"\/"用于强制换行
  228.       if @auto_newline
  229.         # 删除原来的所有换行。
  230.         @text.gsub!(/\n/) {""}
  231.         # 然后"\/"替换成强制换行
  232.         @text.gsub!(/\\\//) {"\n"}
  233.       # 在非自动换行模式下,"\/"用于删除多于的换行符号
  234.       else
  235.         # "\\/" 删除行尾换行符号
  236.         @text.gsub!(/\\\/\n/) {""}
  237.         # 去掉不在行尾的"\\/"符号,防止出错
  238.         @text.gsub!(/\\\//) {""}
  239.       end
  240.         
  241.       # "\\I" 物品图标+名称显示
  242.       @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\003[#{$1}]"+$data_items[$1.to_i].name }
  243.       # "\\K" 技能图标+名称显示
  244.       @text.gsub!(/\\[Kk]\[([0-9]+)\]/) { "\004[#{$1}]"+$data_skills[$1.to_i].name }
  245.       # "\\W" 武器图标+名称显示
  246.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]"+$data_weapons[$1.to_i].name }
  247.       # "\\A" 防具图标+名称显示
  248.       @text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\006[#{$1}]"+$data_armors[$1.to_i].name }
  249.       
  250.       # 注:大量显示图片将是游戏的速度大大减慢
  251.       # "\\I1" 物品图标显示
  252.       @text.gsub!(/\\[Ii]1\[([0-9]+)\]/) { "\003[#{$1}]" }
  253.       # "\\K1" 技能图标显示
  254.       @text.gsub!(/\\[Kk]1\[([0-9]+)\]/) { "\004[#{$1}]" }
  255.       # "\\W1" 武器图标显示
  256.       @text.gsub!(/\\[Ww]1\[([0-9]+)\]/) { "\005[#{$1}]" }
  257.       # "\\A1" 防具图标显示
  258.       @text.gsub!(/\\[Dd]1\[([0-9]+)\]/) { "\006[#{$1}]" }
  259.       
  260.       # "\\I2" 物品名称显示
  261.       @text.gsub!(/\\[Ii]2\[([0-9]+)\]/) { $data_items[$1.to_i].name }
  262.       # "\\K2" 技能名称显示
  263.       @text.gsub!(/\\[Kk]2\[([0-9]+)\]/) { $data_skills[$1.to_i].name }
  264.       # "\\W2" 武器名称显示
  265.       @text.gsub!(/\\[Ww]2\[([0-9]+)\]/) { $data_weapons[$1.to_i].name }
  266.       # "\\A2" 防具名称显示
  267.       @text.gsub!(/\\[Dd]2\[([0-9]+)\]/) { $data_armors[$1.to_i].name }
  268.       
  269.       # "\\S" 字体大小(只修改第一个"\\S")
  270.       # 这里首先删掉能找到的第一个"\\S"
  271.       if @text.slice!(/\\[Ss]\[([0-9]+)\]/)!=nil
  272.         # 当找了"\\S"时满足上述条件,就设置文字大小
  273.         self.set_font_size($1.to_i)
  274.       end
  275.       # "\\O" 文字透明度(使用注意同上,模拟声音变小……)
  276.       if @text.slice!(/\\[Oo]\[([0-9]+)\]/)!=nil
  277.         self.set_font_op($1.to_i)
  278.       end

  279.       # "\\=" 停顿固定帧(延时)
  280.       @text.gsub!(/\\=\[([0-9]+)\]/)    { "\024[#{$1}]" }
  281.       # "\\." 停顿3帧
  282.       @text.gsub!(/\\\./)               { "\024[3]" }
  283.       # "\\_" 停顿1秒(30帧)
  284.       @text.gsub!(/\\_/)                { "\024[30]" }
  285.       
  286.       # "\\L" 指定头像左边显示
  287.       if @text.slice!(/\\[Ll]/)!=nil
  288.         # 设定头像居右标志为假
  289.         @right=false
  290.         # 顺便要设置@x=104,文字在右边显示
  291.         @x=104
  292.       end
  293.       # "\\X" 指定不要显示姓名,带参数就是指定显示姓名(可内部使用"\\N[]")
  294.       # 首先是寻找有没有带参数的"\\X"
  295.       if @text.slice!(/\\[Xx]\[(\w+)\]/)!=nil
  296.         # 找到的话将参数赋予@name
  297.         @name=$1
  298.       # 没有找到的话
  299.       else
  300.         # 再去寻找有没有不带参数的"\\X"
  301.         if @text.slice!(/\\[Xx]/)!=nil
  302.           # 找到的话就将姓名变成"???"
  303.           @name="???"
  304.         end
  305.       end
  306.       # "\\F" 指定表情(Face 用来指定表情啦)
  307.       # 这里"\w"表示匹配字母+数字还有下划线,同样支持中文
  308.       if @text.slice!(/\\[Ff]\[(\w+)\]/)!=nil
  309.         # 找到的话就设定表情
  310.         @face=$1
  311.       end
  312.       # "\\H" 显示头像(不明白大家为什么都喜欢用 Face 表示头像……)
  313.       # 这里我将把显示头像放到字串的最前面,因为头像应该先显示出来
  314.       if @text.slice!(/\\[Hh]\[([0-9]+)\]/)!=nil
  315.         # 显示了头像,将标记记录为真
  316.         @show_head = true
  317.         # 找到的话就提到字符串最前面
  318.         @text="\030[#{$1}]"+@text
  319.       end
  320.       # "\\Pic" 显示图片,用来在报刊等场合添加图片
  321.       if @text.slice!(/\\[Pp][Ii][Cc]\[([0-9]+)\]\[([0-9]+)\]\[(\w+)\]/)!=nil
  322.         # 找到的话就提到字符串最前面
  323.         @text="\031"+@text
  324.         # 载入要显示的图片
  325.         @pic = RPG::Cache.picture($3)
  326.         # 然后要记录显示图片的坐标
  327.         @pic_x=$1.to_i
  328.         @pic_y=$2.to_i
  329.       end
  330.       
  331.       # ================ 分析部分结束,下面是显示部分 ================
  332.    
  333.       # 在此调用过程完成,因为在update部分也会有相同代码
  334.       self.refresh_

  335.     end
  336.     # 选择项的情况
  337.     if $game_temp.choice_max > 0
  338.       @item_max = $game_temp.choice_max
  339.       self.active = true
  340.       self.index = 0
  341.     end
  342.     # 输入数值的情况
  343.     if $game_temp.num_input_variable_id > 0
  344.       digits_max = $game_temp.num_input_digits_max
  345.       number = $game_variables[$game_temp.num_input_variable_id]
  346.       @input_number_window = Window_InputNumber.new(digits_max)
  347.       @input_number_window.number = number
  348.       @input_number_window.x = self.x + 8
  349.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  350.     end
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 设置窗口位置与不透明度
  354.   #--------------------------------------------------------------------------
  355.   def reset_window
  356.     # 判断现在的显示模式
  357.     case $game_variables[4]
  358.     when 0 # 普通模式
  359.       self.width=480
  360.       self.height=160
  361.       self.contents = Bitmap.new(width - 32, height - 32)
  362.       self.x = 80
  363.       if $game_temp.in_battle
  364.         self.y = 16
  365.       else
  366.         case $game_system.message_position
  367.         when 0  # 上
  368.           self.y = 16
  369.         when 1  # 中
  370.           self.y = 160
  371.         when 2  # 下
  372.           self.y = 304
  373.         end
  374.       end
  375.     when 1 # 图书模式
  376.       self.width=532
  377.       self.height=416
  378.       self.contents = Bitmap.new(width - 32, height - 32)
  379.       self.x = 54
  380.       self.y = 32
  381.     when 2 # 全屏模式
  382.       self.width=672
  383.       self.height=512
  384.       self.contents = Bitmap.new(width - 32, height - 32)
  385.       self.x = -16
  386.       self.y = -16
  387.     end
  388.     if $game_system.message_frame == 0
  389.       self.opacity = 255
  390.     else
  391.       self.opacity = 0
  392.     end
  393.     self.back_opacity = 192
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 刷新画面
  397.   #--------------------------------------------------------------------------
  398.   def update
  399.     super
  400.     # 渐变的情况下
  401.     if @fade_in
  402.       # 脚本在这里设定透明度
  403.       self.contents_opacity += @op/8
  404.       if @input_number_window != nil
  405.         @input_number_window.contents_opacity += 32
  406.       end
  407.       if self.contents_opacity >= @op
  408.         @fade_in = false
  409.       end
  410.       return
  411.     end
  412.     # 输入数值的情况下
  413.     if @input_number_window != nil
  414.       @input_number_window.update
  415.       # 确定
  416.       if Input.trigger?(Input::C)
  417.         $game_system.se_play($data_system.decision_se)
  418.         $game_variables[$game_temp.num_input_variable_id] =
  419.           @input_number_window.number
  420.         $game_map.need_refresh = true
  421.         # 释放输入数值窗口
  422.         @input_number_window.dispose
  423.         @input_number_window = nil
  424.         terminate_message
  425.       end
  426.       return
  427.     end
  428.     # 显示信息中的情况下
  429.     if @contents_showing
  430.       # 刷新文本
  431.       self.refresh_
  432.       # 如果不是在显示选择项中就显示暂停标志
  433.       if $game_temp.choice_max == 0
  434.         self.pause = true
  435.       end
  436.       # 取消
  437.       if Input.trigger?(Input::B)
  438.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  439.           $game_system.se_play($data_system.cancel_se)
  440.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  441.           terminate_message
  442.         end
  443.       end
  444.       # @auto_close自减计数
  445.       @auto_close-=1
  446.       # 确定或者自动关闭
  447.       if Input.trigger?(Input::C) or @auto_close==0 # @auto_close为0自动关闭,所以一开始为负数或0就不会自动关闭
  448.         # 文字还没有处理完的时候
  449.         if !@finish and @auto_close!=0
  450.           # 删除所有停顿效果
  451.           @text.gsub!(/\024\[([0-9]+)\]/) { "" }
  452.           # 删除当前延迟效果
  453.           @delay = 0
  454.           # 关闭打字效果
  455.           @type_mode=-1
  456.           # 一次处理完所有的字
  457.           self.refresh_
  458.         else
  459.           # 有选择项的情况
  460.           if $game_temp.choice_max > 0
  461.             $game_system.se_play($data_system.decision_se)
  462.             $game_temp.choice_proc.call(self.index)
  463.           end
  464.           # 清空文字
  465.           terminate_message
  466.           # 在读取TXT的模式下,需要继续打开文字
  467.           if @is_read_txt
  468.             if @auto_newline==true
  469.               #自动换行时只打开一行文字
  470.               $game_temp.message_text =  @ts.get_text(1)
  471.             else
  472.               # 根据显示模式确定需要打开行数
  473.               case $game_variables[4]
  474.               when 0 # 正常模式
  475.                 $game_temp.message_text =  @ts.get_text(4)
  476.               when 1 # 图书模式
  477.                 $game_temp.message_text =  @ts.get_text(12)
  478.               when 2 # 全屏模式
  479.                 $game_temp.message_text =  @ts.get_text(15)
  480.               end
  481.             end
  482.             # 如果包含[END]则退出TXT读取模式
  483.             if $game_temp.message_text.gsub!(/\[END\]/){""}!=nil
  484.               @is_read_txt=false
  485.             end
  486.           end
  487.         end
  488.       end
  489.       return
  490.     end
  491.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  492.     if @fade_out == false and !($game_temp.message_text == nil or $game_temp.message_text == "")
  493.       @contents_showing = true
  494.       $game_temp.message_window_showing = true
  495.       reset_window
  496.       refresh
  497.       Graphics.frame_reset
  498.       # 当不跳过对话时才进行淡入操作
  499.       if !@skip
  500.         self.visible = true
  501.         self.contents_opacity = 0
  502.         if @input_number_window != nil
  503.           @input_number_window.contents_opacity = 0
  504.         end
  505.         @fade_in = true
  506.       end
  507.       return
  508.     end
  509.     # 没有可以显示的信息、但是窗口为可见的情况下
  510.     if self.visible
  511.       @fade_out = true
  512.       self.opacity -= 48
  513.       if self.opacity == 0
  514.         self.visible = false
  515.         @fade_out = false
  516.         $game_temp.message_window_showing = false
  517.       end
  518.       return
  519.     end
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ● 刷新光标矩形
  523.   #--------------------------------------------------------------------------
  524.   def update_cursor_rect
  525.     if @index >= 0
  526.       n = $game_temp.choice_start + @index
  527.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  528.     else
  529.       self.cursor_rect.empty
  530.     end
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● 设定字体大小
  534.   #--------------------------------------------------------------------------
  535.   def set_font_size(size=20)
  536.     # 最大字96号,再大就超过文字栏了,而且Ruby本来有限制……
  537.     if size>96
  538.       size=96
  539.     end
  540.     # 设定字的大小
  541.     self.contents.font.size = size
  542.     # 如果字太大了就要加高每行文字高度。
  543.     if size > 28
  544.       @height=size+4
  545.     else
  546.       @height=32
  547.     end
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● 设定文字透明
  551.   #--------------------------------------------------------------------------
  552.   def set_font_op(op=255)
  553.     # 限制透明度为0-255
  554.     if op>255
  555.       op=255
  556.     elsif op<0
  557.       op=0
  558.     end
  559.     # 这里设定文字透明是没有用的,设定透明在update过程开始
  560.     @op = op
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 显示文字/头像过程
  564.   #--------------------------------------------------------------------------
  565.   def refresh_
  566.     # 处理已经结束的情况下直接return
  567.     if @finish
  568.       return
  569.     end
  570.     # 延时处理
  571.     @delay-=1
  572.     if @delay<=0
  573.       # 每次处理i个标志,这里i就设置为@type_mode了
  574.       i=@type_mode
  575.       # c 获取 1 个字 (如果不能取得文字就循环)
  576.       while ((c = @text.slice!(/./m)) != nil)
  577.         # ======================== 默认功能 ========================
  578.         # \\ 的情况下
  579.         if c == "\000"
  580.           # 还原为本来的文字
  581.           c = "\\"
  582.         end
  583.         # \C[n] 的情况下
  584.         if c == "\001"
  585.           # 取得字色编码
  586.           @text.sub!(/\[([0-9#a-zA-Z]+)\]/, "")
  587.           # 如果是设定RGB颜色
  588.           if $1[0,1]=="#"
  589.             # 先拷贝一下文字
  590.             c=$1.dup
  591.             # 分3段分别取出R,G,B颜色
  592.             c.sub!(/#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "")
  593.             # 设定文字颜色
  594.             self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16),@op)
  595.             next
  596.           else
  597.             # 记录到变量 color
  598.             color = $1.to_i
  599.             # 字色0~7是有效的
  600.             if color >= 0 and color <= 7
  601.               # 设置文字颜色
  602.               self.contents.font.color = text_color(color)
  603.             end
  604.           end
  605.           # 进行下次循环
  606.           next
  607.         end
  608.         # 显示金钱窗口,这个……不用说了吧……
  609.         if c == "\002"
  610.           if @gold_window == nil
  611.             @gold_window = Window_Gold.new
  612.             @gold_window.x = 560 - @gold_window.width
  613.             if $game_temp.in_battle
  614.               @gold_window.y = 192
  615.             else
  616.               @gold_window.y = self.y >= 128 ? 32 : 384
  617.             end
  618.             @gold_window.opacity = self.opacity
  619.             @gold_window.back_opacity = self.back_opacity
  620.           end
  621.           next
  622.         end
  623.         # 另起一行文字的情况下
  624.         if c == "\n"
  625.           # 刷新选择项及光标的高
  626.           if @y >= $game_temp.choice_start
  627.             @cursor_width = [@cursor_width, @x>440 ? 448 : @x+8].max
  628.           end
  629.           # y 加 1
  630.           @y += 1
  631.           # 因为字体大小会变化,这里添加判断语句,超出就不显示了
  632.           if @y>=self.contents.height/@height
  633.             # 删除@text剩余的所有内容
  634.             @text=nil
  635.             # 然后返回
  636.             break
  637.           end
  638.           # 因为头像的缘故,这里需要改写
  639.           if @right
  640.             # 头像右边显示的时候是0
  641.             @x=0
  642.           else
  643.             # 头像靠左显示时@x要留出绘制头像空间
  644.             @x=104
  645.           end
  646.           # 移动到选择项的下一行
  647.           if @y >= $game_temp.choice_start
  648.             @x=16
  649.           end
  650.           # 下面的文字
  651.           next
  652.         end
  653.         
  654.         # ======================== 加强功能 ========================
  655.         
  656.         # 显示物品图标
  657.         if c == "\003"
  658.           # 取得物品ID
  659.           @text.sub!(/\[([0-9]+)\]/, "")
  660.           # 这里的 RPG::Cache 是高速缓存,不明白的看看帮助文档吧……
  661.           icon = RPG::Cache.icon($data_items[$1.to_i].icon_name)
  662.           # 绘制这个图标
  663.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  664.           # 将x值增加24
  665.           @x+=24
  666.           # 执行下一次循环
  667.           next
  668.         end
  669.         # 显示技能图标(因为类似物品图标显示,所以省略注释)
  670.         if c == "\004"
  671.           @text.sub!(/\[([0-9]+)\]/, "")
  672.           icon = RPG::Cache.icon($data_skills[$1.to_i].icon_name)
  673.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  674.           @x+=24
  675.           next
  676.         end
  677.         # 显示武器图标(因为类似物品图标显示,所以省略注释)
  678.         if c == "\005"
  679.           @text.sub!(/\[([0-9]+)\]/, "")
  680.           icon = RPG::Cache.icon($data_weapons[$1.to_i].icon_name)
  681.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  682.           @x+=24
  683.           next
  684.         end
  685.         # 显示防具图标(因为类似物品图标显示,所以省略注释)
  686.         if c == "\006"
  687.           @text.sub!(/\[([0-9]+)\]/, "")
  688.           icon = RPG::Cache.icon($data_armors[$1.to_i].icon_name)
  689.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  690.           @x+=24
  691.           next
  692.         end
  693.         
  694.         # 等待n帧
  695.         if c == "\024"
  696.           # 取得参数(需要等待多少帧)
  697.           @text.sub!(/\[([0-9]+)\]/, "")
  698.           # 设定@delay标志
  699.           @delay = $1.to_i
  700.           # 退出此次循环
  701.           break
  702.         end
  703.         
  704.         # 显示头像
  705.         if c == "\030"
  706.           #暂时记录文字大小,用于显示完头像恢复
  707.           size=self.contents.font.size
  708.           # 设定为正常的20号字
  709.           self.contents.font.size=20
  710.           # 设定系统字色,为写名字做准备的
  711.           self.contents.font.color = system_color
  712.           # 取得"[]"内的字符并从原字串中删除这一部分
  713.           @text.sub!(/\[([0-9]+)\]/, "")
  714.           # 记录到head变量
  715.           head=$1
  716.           # 判断头像和原来的是不是一样的
  717.           if @face == nil
  718.             # 不一样
  719.             if @head_file != head
  720.               # 改变成现在的头像文件名
  721.               @head_file = head
  722.               # 不一样的话再重新载入头像
  723.               @head_bmp=RPG::Cache.character("head/gpra_"+@head_file, 0)
  724.             end
  725.           else
  726.             # 当表情不是空的时候需要考虑表情的
  727.             if @head_file != head + "_" + @face
  728.               # 改变成现在的头像文件名
  729.               @head_file = head + "_" + @face
  730.               # 不一样的话再重新载入头像
  731.               @head_bmp=RPG::Cache.character("head/gpra_"+@head_file, 0)
  732.             end
  733.           end
  734.           # 显示头像,分左右两种情况
  735.           if @right
  736.             # 绘制头像图片
  737.             self.contents.blt(348,0,@head_bmp,Rect.new(0,0,100,100))
  738.             # 显示角色姓名
  739.             if @name==nil
  740.               # 取得角色姓名到变量 c
  741.               c = $game_actors[head.to_i].name
  742.               # 描绘角色的姓名
  743.               self.contents.draw_text_s(348,104,100,24,c,1)
  744.             else
  745.               # 取得"???"到变量 c,当然这个"???"可以改为其他的默认值
  746.               c = @name
  747.               # 描绘角色的姓名
  748.               self.contents.draw_text_s(348,104,100,24,c,1)
  749.             end
  750.           else
  751.             # 绘制头像图片
  752.             self.contents.blt(0,0,@head_bmp,Rect.new(0,0,100,100))
  753.             # 显示角色姓名
  754.             if @name==nil
  755.               # 取得角色姓名到变量 c
  756.               c = $game_actors[head.to_i].name
  757.               # 描绘角色的姓名
  758.               self.contents.draw_text_s(0,104,100,24,c,1)
  759.             else
  760.               # 取得"???"到变量 c,当然这个"???"可以改为其他的默认值
  761.               c = @name
  762.               # 描绘角色的姓名
  763.               self.contents.draw_text_s(0,104,100,24,c,1)
  764.             end
  765.           end
  766.           # 恢复默认字色
  767.           self.contents.font.color = normal_color
  768.           # 恢复字体大小
  769.           self.contents.font.size=size
  770.           # 进行下一次循环
  771.           next
  772.         end
  773.         
  774.         # 显示图片!只需要绘图而已。
  775.         if c == "\031"
  776.           self.contents.blt(@pic_x,@pic_y,@pic,@pic.rect)
  777.           next
  778.         end
  779.         
  780.         # ======================== 以上加强部分 ========================
  781.         
  782.         # 自动换行模式
  783.         if @auto_newline
  784.           # 计算应该换行的最大X坐标
  785.           max_x = self.contents.width - 4
  786.           # 在右侧显示头像的时候,坐标应该左移让出头像的位置
  787.           if @right&&@show_head
  788.             max_x -= 104
  789.           end
  790.           # 并且文字已经超出了显示宽度
  791.           if @x+self.contents.text_size(c).width+4 > max_x
  792.             # 增加一个换行符号,并且将本次准备显示的字符放到下一行
  793.             @text = "\n" + c + @text
  794.             # 跳过这次绘制文字
  795.             next
  796.           end
  797.         end
  798.         
  799.         # 描绘文字
  800.         self.contents.draw_text_s(4+@x,@height*@y, @height, @height, c)
  801.         # x 为描绘文字宽度进行自增运算,计算下一个文字起始位置
  802.         @x += self.contents.text_size(c).width
  803.          
  804.         # 操作了@type_mode个字符后就退出循环了,@type_mode为负则操作一次完成
  805.         i-=1
  806.         if i==0
  807.           break
  808.         end
  809.       
  810.       end
  811.     end
  812.    
  813.     # 如果@text处理结束了
  814.     if @text==nil or @text==""
  815.       # 设置结束标志
  816.       @finish=true
  817.     end
  818.   end
  819. end
复制代码
纤尘镜大整改,全游戏重置中

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-8-10
帖子
170
2
发表于 2010-12-21 14:24:39 | 只看该作者
“# 头像默认显示在右边
    @right = true  ”上面脚本第104行,改为
“@right = false”

点评

感谢你的帮助!问题圆满解决!  发表于 2010-12-21 21:12

评分

参与人数 1星屑 +376 收起 理由
fux2 + 376 认可答案

查看全部评分

……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
162 小时
注册时间
2010-7-19
帖子
205
3
 楼主| 发表于 2010-12-21 14:34:19 | 只看该作者
谢谢沙发亲的回答,可是这样改的话字会到头像的位置上去。我希望能吧\l\h[头像]和\h[头像]交换下位置,让\h[头像]变成左边显示头像。
纤尘镜大整改,全游戏重置中
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-8-10
帖子
170
4
发表于 2010-12-21 14:47:56 | 只看该作者
本帖最后由 0飘絮0 于 2010-12-21 14:53 编辑

咦,是这样子的嘛?
可我看的第737~768行中的 IF~else~句子应该是可以自动识别的啊。
嗯……,你试试把738行的那个IF句子与else部分对调一下,前面的 @right = true 不变,看看【对不起,这个方法不行。后面还有用到@right的句子】
不行的话,我就没办法了,毕竟好久没看脚本了
……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
162 小时
注册时间
2010-7-19
帖子
205
5
 楼主| 发表于 2010-12-21 15:02:20 | 只看该作者
本帖最后由 蓝泪红霜 于 2010-12-21 15:06 编辑

发生了脚本错误……貌似不能对调。
按照你说的第一个方法该了,我再对默认的那个脚本进行了相应的修改,貌似显示头像的时候字可以自动排列而不与头像重叠了,可是没有头像的时候从第二行开始就自动留下了头像的空位……
纤尘镜大整改,全游戏重置中
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-8-10
帖子
170
6
发表于 2010-12-21 15:15:58 | 只看该作者
第104 行:@right = true
第289行:if ~ end句子间修改应该可以改出你想要的效果
搜 "@right ”就能搜出所有相关头像左右的句子

……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
162 小时
注册时间
2010-7-19
帖子
205
7
 楼主| 发表于 2010-12-21 15:21:17 | 只看该作者
只修改289行以后的那一小段只能改字的位置,图片依旧在右边
纤尘镜大整改,全游戏重置中
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
34 小时
注册时间
2010-10-7
帖子
58
8
发表于 2010-12-21 15:23:42 | 只看该作者
你看这样可以么?
  1. #==============================================================================
  2. # ◎ GPRA_Window_Message
  3. #------------------------------------------------------------------------------
  4. # ◎ 显示文章的信息窗口加强。
  5. #------------------------------------------------------------------------------
  6. # 制作者:绿梨子红苹果
  7. # 个人主页:vbgm.9126.com
  8. # E-Mail:[email protected]
  9. # QQ:42378361
  10. #==============================================================================

  11. class Window_Message < Window_Selectable
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化状态
  14.   #--------------------------------------------------------------------------
  15.   def initialize
  16.     super(80, 304, 480, 160)
  17.     self.contents = Bitmap.new(width - 32, height - 32)
  18.     self.visible = false
  19.     self.z = 9998
  20.     @fade_in = false
  21.     @fade_out = false
  22.     @contents_showing = false
  23.     @cursor_width = 0
  24.     @op = 255 # 不透明度
  25.     @head_bmp = nil # 装载头像用
  26.     @head_file = nil # 头像文件名
  27.     @text = nil # 记录所处理文字
  28.     @skip = false # 记录是否跳过此次对话
  29.     @auto_close = -1 # 默认不打开自动关闭
  30.     @show_head = false # 记录是否显示头像了
  31.     @type_mode=-1 # 打字模式
  32.     @auto_newline=false # 默认不开启自动换行功能
  33.     @delay=-1 # 等待n帧标志
  34.     @finish=false # 记录文字处理是否结束
  35.     @ts = TextStream.new # 创建一个新的TXT读取流
  36.     @is_read_txt =false # 默认不是在读取txt文件
  37.     @pic = nil # 显示图片用
  38.     @pic_x = 0 # 显示图片的X坐标
  39.     @pic_y = 0 # 显示图片的Y坐标
  40.     self.active = false
  41.     self.index = -1
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 释放
  45.   #--------------------------------------------------------------------------
  46.   def dispose
  47.     terminate_message
  48.     $game_temp.message_window_showing = false
  49.     if @input_number_window != nil
  50.       @input_number_window.dispose
  51.     end
  52.     super
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 处理信息结束
  56.   #--------------------------------------------------------------------------
  57.   def terminate_message
  58.     self.active = false
  59.     self.pause = false
  60.     self.index = -1
  61.     self.contents.clear
  62.     # 清除显示中标志
  63.     @contents_showing = false
  64.     # 呼叫信息调用
  65.     if $game_temp.message_proc != nil
  66.       $game_temp.message_proc.call
  67.     end
  68.     # 清除文章、选择项、输入数值的相关变量
  69.     $game_temp.message_text = nil
  70.     $game_temp.message_proc = nil
  71.     $game_temp.choice_start = 99
  72.     $game_temp.choice_max = 0
  73.     $game_temp.choice_cancel_type = 0
  74.     $game_temp.choice_proc = nil
  75.     $game_temp.num_input_start = 99
  76.     $game_temp.num_input_variable_id = 0
  77.     $game_temp.num_input_digits_max = 0
  78.     # 开放金钱窗口
  79.     if @gold_window != nil
  80.       @gold_window.dispose
  81.       @gold_window = nil
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 刷新
  86.   #--------------------------------------------------------------------------
  87.   def refresh
  88.     # 清空原先内容
  89.     self.contents.clear
  90.     # 恢复一般字色
  91.     self.contents.font.color = normal_color
  92.     # 恢复字体大小
  93.     self.contents.font.size = 20
  94.     # 绘制文字位置初始化
  95.     @x = @y = 0
  96.     # 字体高度记录
  97.     @height = 32
  98.     # 文字不透明度设定为255
  99.     @op = 255
  100.     # 默认不显示头像
  101.     @show_head = false
  102.     # 头像默认显示在右边
  103.     @right = true
  104.     # 头像默认显示一般表情
  105.     @face = nil
  106.     # 默认显示角色姓名
  107.     @name = nil
  108.     # 默认是不显示图片的
  109.     @pic = nil
  110.     # 默认不跳过此次对话
  111.     @skip = false
  112.     # 从变量读取自动关闭设置
  113.     @auto_close = $game_variables[2]
  114.     # 从变量读取打字模式设置
  115.     @type_mode=$game_variables[3]
  116.     # 从变量读取自动换行设置
  117.     @auto_newline= ($game_variables[6]==0 ? false : true)
  118.     # 默认不等待
  119.     @delay=-1
  120.     # 设定文字没有处理结束
  121.     @finish=false
  122.     # 光标宽度初始化为零
  123.     @cursor_width = 0
  124.     # 到选择项的下一行字
  125.     if $game_temp.choice_start == 0
  126.       @x = 16
  127.     end
  128.     # 有等待显示的文字的情况下
  129.     # (注:因为一旦文字非空就处理,所以可以设定 $game_temp.message_text 达到显示文章的效果)
  130.     if $game_temp.message_text != nil
  131.       # @text 功能改进
  132.       if @text==nil or @text==""
  133.         @text = $game_temp.message_text.dup
  134.       else
  135.         @text = @text + $game_temp.message_text
  136.       end
  137.       
  138.       # 最先必须要将 "\\\\" 变换为 "\000"
  139.       @text.gsub!(/\\\\/)                { "\000" }
  140.       
  141.       # 在TXT模式还没有打开的时候
  142.       if !@is_read_txt
  143.         # TXT读取模式打开
  144.         if @text.slice!(/\\[Tt][Xx][Tt]\[(\w+)\]\[(\w+)\]/)!=nil
  145.           # 打开文件,成功打开后再进入后面部分
  146.           if @ts.open($1,$2)
  147.             if @auto_newline==true
  148.               #自动换行时只打开一行文字
  149.               @text =  @ts.get_text(1)
  150.             else
  151.               # 根据显示模式确定需要打开行数
  152.               case $game_variables[4]
  153.               when 0 # 正常模式
  154.                 @text =  @ts.get_text(4)
  155.               when 1 # 图书模式
  156.                 @text =  @ts.get_text(12)
  157.               when 2 # 全屏模式
  158.                 @text =  @ts.get_text(15)
  159.               end
  160.             end
  161.             # 如果包含[END]
  162.             if @text.gsub!(/\[END\]/){""}!=nil
  163.               #退出TXT读取模式
  164.               @is_read_txt=false
  165.             else
  166.               #否则设置正在读取标志
  167.               @is_read_txt=true
  168.             end
  169.           end
  170.         else
  171.           if @text.slice!(/\\[Tt][Xx][Tt]\[(\w+)\]/)!=nil
  172.             # 打开文件,成功打开后再进入后面部分
  173.             if @ts.open($1,"")
  174.               if @auto_newline==true
  175.                 #自动换行时只打开一行文字
  176.                 @text =  @ts.get_text(1)
  177.               else
  178.                 # 根据显示模式确定需要打开行数
  179.                 case $game_variables[4]
  180.                 when 0 # 正常模式
  181.                   @text =  @ts.get_text(4)
  182.                 when 1 # 图书模式
  183.                   @text =  @ts.get_text(12)
  184.                 when 2 # 全屏模式
  185.                   @text =  @ts.get_text(15)
  186.                 end
  187.               end
  188.               # 如果包含[END]
  189.               if @text.gsub!(/\[END\]/){""}!=nil
  190.                 #退出TXT读取模式
  191.                 @is_read_txt=false
  192.               else
  193.                 #否则设置正在读取标志
  194.                 @is_read_txt=true
  195.               end
  196.             end
  197.           end
  198.         end
  199.       end
  200.         
  201.       # 如果取得的字符含"\\~"时
  202.       if @text.slice!(/\\~/)!=nil
  203.         # 跳过此次对话
  204.         terminate_message
  205.         # 设置跳过此次对话标志
  206.         @skip = true
  207.         # 直接返回等待连接后面部分
  208.         return
  209.       end
  210.       
  211.       # 限制文字处理(注:这里是默认功能。)
  212.       begin
  213.         last_text = @text.clone
  214.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  215.       end until @text == last_text
  216.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  217.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  218.       end
  219.       #(注:后面将单个字符循环判断,所以这里将控制符全部换成单个字符)
  220.       # 为了方便将 "\\C" 变为 "\001"
  221.       @text.gsub!(/\\[Cc]\[([0-9#a-zA-Z]+)\]/)  { "\001[#{$1}]" }
  222.       # "\\G" 变为 "\002"
  223.       @text.gsub!(/\\[Gg]/)              { "\002" }
  224.       
  225.       # ========================增强功能========================
  226.       
  227.       # 在自动换行模式下,首先删除所有换行符号,然后"\/"用于强制换行
  228.       if @auto_newline
  229.         # 删除原来的所有换行。
  230.         @text.gsub!(/\n/) {""}
  231.         # 然后"\/"替换成强制换行
  232.         @text.gsub!(/\\\//) {"\n"}
  233.       # 在非自动换行模式下,"\/"用于删除多于的换行符号
  234.       else
  235.         # "\\/" 删除行尾换行符号
  236.         @text.gsub!(/\\\/\n/) {""}
  237.         # 去掉不在行尾的"\\/"符号,防止出错
  238.         @text.gsub!(/\\\//) {""}
  239.       end
  240.         
  241.       # "\\I" 物品图标+名称显示
  242.       @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\003[#{$1}]"+$data_items[$1.to_i].name }
  243.       # "\\K" 技能图标+名称显示
  244.       @text.gsub!(/\\[Kk]\[([0-9]+)\]/) { "\004[#{$1}]"+$data_skills[$1.to_i].name }
  245.       # "\\W" 武器图标+名称显示
  246.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]"+$data_weapons[$1.to_i].name }
  247.       # "\\A" 防具图标+名称显示
  248.       @text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\006[#{$1}]"+$data_armors[$1.to_i].name }
  249.       
  250.       # 注:大量显示图片将是游戏的速度大大减慢
  251.       # "\\I1" 物品图标显示
  252.       @text.gsub!(/\\[Ii]1\[([0-9]+)\]/) { "\003[#{$1}]" }
  253.       # "\\K1" 技能图标显示
  254.       @text.gsub!(/\\[Kk]1\[([0-9]+)\]/) { "\004[#{$1}]" }
  255.       # "\\W1" 武器图标显示
  256.       @text.gsub!(/\\[Ww]1\[([0-9]+)\]/) { "\005[#{$1}]" }
  257.       # "\\A1" 防具图标显示
  258.       @text.gsub!(/\\[Dd]1\[([0-9]+)\]/) { "\006[#{$1}]" }
  259.       
  260.       # "\\I2" 物品名称显示
  261.       @text.gsub!(/\\[Ii]2\[([0-9]+)\]/) { $data_items[$1.to_i].name }
  262.       # "\\K2" 技能名称显示
  263.       @text.gsub!(/\\[Kk]2\[([0-9]+)\]/) { $data_skills[$1.to_i].name }
  264.       # "\\W2" 武器名称显示
  265.       @text.gsub!(/\\[Ww]2\[([0-9]+)\]/) { $data_weapons[$1.to_i].name }
  266.       # "\\A2" 防具名称显示
  267.       @text.gsub!(/\\[Dd]2\[([0-9]+)\]/) { $data_armors[$1.to_i].name }
  268.       
  269.       # "\\S" 字体大小(只修改第一个"\\S")
  270.       # 这里首先删掉能找到的第一个"\\S"
  271.       if @text.slice!(/\\[Ss]\[([0-9]+)\]/)!=nil
  272.         # 当找了"\\S"时满足上述条件,就设置文字大小
  273.         self.set_font_size($1.to_i)
  274.       end
  275.       # "\\O" 文字透明度(使用注意同上,模拟声音变小……)
  276.       if @text.slice!(/\\[Oo]\[([0-9]+)\]/)!=nil
  277.         self.set_font_op($1.to_i)
  278.       end

  279.       # "\\=" 停顿固定帧(延时)
  280.       @text.gsub!(/\\=\[([0-9]+)\]/)    { "\024[#{$1}]" }
  281.       # "\\." 停顿3帧
  282.       @text.gsub!(/\\\./)               { "\024[3]" }
  283.       # "\\_" 停顿1秒(30帧)
  284.       @text.gsub!(/\\_/)                { "\024[30]" }
  285.       
  286.       # "\\L" 指定头像左边显示
  287.       if @text.slice!(/\\[Ll]/)!=nil
  288.         # 设定头像居右标志为假
  289.         @right=true
  290.         # 顺便要设置@x=104,文字在右边显示
  291.         @x=104
  292.       end
  293.       # "\\X" 指定不要显示姓名,带参数就是指定显示姓名(可内部使用"\\N[]")
  294.       # 首先是寻找有没有带参数的"\\X"
  295.       if @text.slice!(/\\[Xx]\[(\w+)\]/)!=nil
  296.         # 找到的话将参数赋予@name
  297.         @name=$1
  298.       # 没有找到的话
  299.       else
  300.         # 再去寻找有没有不带参数的"\\X"
  301.         if @text.slice!(/\\[Xx]/)!=nil
  302.           # 找到的话就将姓名变成"???"
  303.           @name="???"
  304.         end
  305.       end
  306.       # "\\F" 指定表情(Face 用来指定表情啦)
  307.       # 这里"\w"表示匹配字母+数字还有下划线,同样支持中文
  308.       if @text.slice!(/\\[Ff]\[(\w+)\]/)!=nil
  309.         # 找到的话就设定表情
  310.         @face=$1
  311.       end
  312.       # "\\H" 显示头像(不明白大家为什么都喜欢用 Face 表示头像……)
  313.       # 这里我将把显示头像放到字串的最前面,因为头像应该先显示出来
  314.       if @text.slice!(/\\[Hh]\[([0-9]+)\]/)!=nil
  315.         # 显示了头像,将标记记录为真
  316.         @show_head = true
  317.         @right=false
  318.         # 顺便要设置@x=104,文字在右边显示
  319.         @x=104
  320.         # 找到的话就提到字符串最前面
  321.         @text="\030[#{$1}]"+@text
  322.       end
  323.       # "\\Pic" 显示图片,用来在报刊等场合添加图片
  324.       if @text.slice!(/\\[Pp][Ii][Cc]\[([0-9]+)\]\[([0-9]+)\]\[(\w+)\]/)!=nil
  325.         # 找到的话就提到字符串最前面
  326.         @text="\031"+@text
  327.         # 载入要显示的图片
  328.         @pic = RPG::Cache.picture($3)
  329.         # 然后要记录显示图片的坐标
  330.         @pic_x=$1.to_i
  331.         @pic_y=$2.to_i
  332.       end
  333.       
  334.       # ================ 分析部分结束,下面是显示部分 ================
  335.    
  336.       # 在此调用过程完成,因为在update部分也会有相同代码
  337.       self.refresh_

  338.     end
  339.     # 选择项的情况
  340.     if $game_temp.choice_max > 0
  341.       @item_max = $game_temp.choice_max
  342.       self.active = true
  343.       self.index = 0
  344.     end
  345.     # 输入数值的情况
  346.     if $game_temp.num_input_variable_id > 0
  347.       digits_max = $game_temp.num_input_digits_max
  348.       number = $game_variables[$game_temp.num_input_variable_id]
  349.       @input_number_window = Window_InputNumber.new(digits_max)
  350.       @input_number_window.number = number
  351.       @input_number_window.x = self.x + 8
  352.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  353.     end
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● 设置窗口位置与不透明度
  357.   #--------------------------------------------------------------------------
  358.   def reset_window
  359.     # 判断现在的显示模式
  360.     case $game_variables[4]
  361.     when 0 # 普通模式
  362.       self.width=480
  363.       self.height=160
  364.       self.contents = Bitmap.new(width - 32, height - 32)
  365.       self.x = 80
  366.       if $game_temp.in_battle
  367.         self.y = 16
  368.       else
  369.         case $game_system.message_position
  370.         when 0  # 上
  371.           self.y = 16
  372.         when 1  # 中
  373.           self.y = 160
  374.         when 2  # 下
  375.           self.y = 304
  376.         end
  377.       end
  378.     when 1 # 图书模式
  379.       self.width=532
  380.       self.height=416
  381.       self.contents = Bitmap.new(width - 32, height - 32)
  382.       self.x = 54
  383.       self.y = 32
  384.     when 2 # 全屏模式
  385.       self.width=672
  386.       self.height=512
  387.       self.contents = Bitmap.new(width - 32, height - 32)
  388.       self.x = -16
  389.       self.y = -16
  390.     end
  391.     if $game_system.message_frame == 0
  392.       self.opacity = 255
  393.     else
  394.       self.opacity = 0
  395.     end
  396.     self.back_opacity = 192
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 刷新画面
  400.   #--------------------------------------------------------------------------
  401.   def update
  402.     super
  403.     # 渐变的情况下
  404.     if @fade_in
  405.       # 脚本在这里设定透明度
  406.       self.contents_opacity += @op/8
  407.       if @input_number_window != nil
  408.         @input_number_window.contents_opacity += 32
  409.       end
  410.       if self.contents_opacity >= @op
  411.         @fade_in = false
  412.       end
  413.       return
  414.     end
  415.     # 输入数值的情况下
  416.     if @input_number_window != nil
  417.       @input_number_window.update
  418.       # 确定
  419.       if Input.trigger?(Input::C)
  420.         $game_system.se_play($data_system.decision_se)
  421.         $game_variables[$game_temp.num_input_variable_id] =
  422.           @input_number_window.number
  423.         $game_map.need_refresh = true
  424.         # 释放输入数值窗口
  425.         @input_number_window.dispose
  426.         @input_number_window = nil
  427.         terminate_message
  428.       end
  429.       return
  430.     end
  431.     # 显示信息中的情况下
  432.     if @contents_showing
  433.       # 刷新文本
  434.       self.refresh_
  435.       # 如果不是在显示选择项中就显示暂停标志
  436.       if $game_temp.choice_max == 0
  437.         self.pause = true
  438.       end
  439.       # 取消
  440.       if Input.trigger?(Input::B)
  441.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  442.           $game_system.se_play($data_system.cancel_se)
  443.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  444.           terminate_message
  445.         end
  446.       end
  447.       # @auto_close自减计数
  448.       @auto_close-=1
  449.       # 确定或者自动关闭
  450.       if Input.trigger?(Input::C) or @auto_close==0 # @auto_close为0自动关闭,所以一开始为负数或0就不会自动关闭
  451.         # 文字还没有处理完的时候
  452.         if !@finish and @auto_close!=0
  453.           # 删除所有停顿效果
  454.           @text.gsub!(/\024\[([0-9]+)\]/) { "" }
  455.           # 删除当前延迟效果
  456.           @delay = 0
  457.           # 关闭打字效果
  458.           @type_mode=-1
  459.           # 一次处理完所有的字
  460.           self.refresh_
  461.         else
  462.           # 有选择项的情况
  463.           if $game_temp.choice_max > 0
  464.             $game_system.se_play($data_system.decision_se)
  465.             $game_temp.choice_proc.call(self.index)
  466.           end
  467.           # 清空文字
  468.           terminate_message
  469.           # 在读取TXT的模式下,需要继续打开文字
  470.           if @is_read_txt
  471.             if @auto_newline==true
  472.               #自动换行时只打开一行文字
  473.               $game_temp.message_text =  @ts.get_text(1)
  474.             else
  475.               # 根据显示模式确定需要打开行数
  476.               case $game_variables[4]
  477.               when 0 # 正常模式
  478.                 $game_temp.message_text =  @ts.get_text(4)
  479.               when 1 # 图书模式
  480.                 $game_temp.message_text =  @ts.get_text(12)
  481.               when 2 # 全屏模式
  482.                 $game_temp.message_text =  @ts.get_text(15)
  483.               end
  484.             end
  485.             # 如果包含[END]则退出TXT读取模式
  486.             if $game_temp.message_text.gsub!(/\[END\]/){""}!=nil
  487.               @is_read_txt=false
  488.             end
  489.           end
  490.         end
  491.       end
  492.       return
  493.     end
  494.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  495.     if @fade_out == false and !($game_temp.message_text == nil or $game_temp.message_text == "")
  496.       @contents_showing = true
  497.       $game_temp.message_window_showing = true
  498.       reset_window
  499.       refresh
  500.       Graphics.frame_reset
  501.       # 当不跳过对话时才进行淡入操作
  502.       if !@skip
  503.         self.visible = true
  504.         self.contents_opacity = 0
  505.         if @input_number_window != nil
  506.           @input_number_window.contents_opacity = 0
  507.         end
  508.         @fade_in = true
  509.       end
  510.       return
  511.     end
  512.     # 没有可以显示的信息、但是窗口为可见的情况下
  513.     if self.visible
  514.       @fade_out = true
  515.       self.opacity -= 48
  516.       if self.opacity == 0
  517.         self.visible = false
  518.         @fade_out = false
  519.         $game_temp.message_window_showing = false
  520.       end
  521.       return
  522.     end
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● 刷新光标矩形
  526.   #--------------------------------------------------------------------------
  527.   def update_cursor_rect
  528.     if @index >= 0
  529.       n = $game_temp.choice_start + @index
  530.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  531.     else
  532.       self.cursor_rect.empty
  533.     end
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # ● 设定字体大小
  537.   #--------------------------------------------------------------------------
  538.   def set_font_size(size=20)
  539.     # 最大字96号,再大就超过文字栏了,而且Ruby本来有限制……
  540.     if size>96
  541.       size=96
  542.     end
  543.     # 设定字的大小
  544.     self.contents.font.size = size
  545.     # 如果字太大了就要加高每行文字高度。
  546.     if size > 28
  547.       @height=size+4
  548.     else
  549.       @height=32
  550.     end
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # ● 设定文字透明
  554.   #--------------------------------------------------------------------------
  555.   def set_font_op(op=255)
  556.     # 限制透明度为0-255
  557.     if op>255
  558.       op=255
  559.     elsif op<0
  560.       op=0
  561.     end
  562.     # 这里设定文字透明是没有用的,设定透明在update过程开始
  563.     @op = op
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # ● 显示文字/头像过程
  567.   #--------------------------------------------------------------------------
  568.   def refresh_
  569.     # 处理已经结束的情况下直接return
  570.     if @finish
  571.       return
  572.     end
  573.     # 延时处理
  574.     @delay-=1
  575.     if @delay<=0
  576.       # 每次处理i个标志,这里i就设置为@type_mode了
  577.       i=@type_mode
  578.       # c 获取 1 个字 (如果不能取得文字就循环)
  579.       while ((c = @text.slice!(/./m)) != nil)
  580.         # ======================== 默认功能 ========================
  581.         # \\ 的情况下
  582.         if c == "\000"
  583.           # 还原为本来的文字
  584.           c = "\\"
  585.         end
  586.         # \C[n] 的情况下
  587.         if c == "\001"
  588.           # 取得字色编码
  589.           @text.sub!(/\[([0-9#a-zA-Z]+)\]/, "")
  590.           # 如果是设定RGB颜色
  591.           if $1[0,1]=="#"
  592.             # 先拷贝一下文字
  593.             c=$1.dup
  594.             # 分3段分别取出R,G,B颜色
  595.             c.sub!(/#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "")
  596.             # 设定文字颜色
  597.             self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16),@op)
  598.             next
  599.           else
  600.             # 记录到变量 color
  601.             color = $1.to_i
  602.             # 字色0~7是有效的
  603.             if color >= 0 and color <= 7
  604.               # 设置文字颜色
  605.               self.contents.font.color = text_color(color)
  606.             end
  607.           end
  608.           # 进行下次循环
  609.           next
  610.         end
  611.         # 显示金钱窗口,这个……不用说了吧……
  612.         if c == "\002"
  613.           if @gold_window == nil
  614.             @gold_window = Window_Gold.new
  615.             @gold_window.x = 560 - @gold_window.width
  616.             if $game_temp.in_battle
  617.               @gold_window.y = 192
  618.             else
  619.               @gold_window.y = self.y >= 128 ? 32 : 384
  620.             end
  621.             @gold_window.opacity = self.opacity
  622.             @gold_window.back_opacity = self.back_opacity
  623.           end
  624.           next
  625.         end
  626.         # 另起一行文字的情况下
  627.         if c == "\n"
  628.           # 刷新选择项及光标的高
  629.           if @y >= $game_temp.choice_start
  630.             @cursor_width = [@cursor_width, @x>440 ? 448 : @x+8].max
  631.           end
  632.           # y 加 1
  633.           @y += 1
  634.           # 因为字体大小会变化,这里添加判断语句,超出就不显示了
  635.           if @y>=self.contents.height/@height
  636.             # 删除@text剩余的所有内容
  637.             @text=nil
  638.             # 然后返回
  639.             break
  640.           end
  641.           # 因为头像的缘故,这里需要改写
  642.           if @right
  643.             # 头像右边显示的时候是0
  644.             @x=0
  645.           else
  646.             # 头像靠左显示时@x要留出绘制头像空间
  647.             @x=104
  648.           end
  649.           # 移动到选择项的下一行
  650.           if @y >= $game_temp.choice_start
  651.             @x=16
  652.           end
  653.           # 下面的文字
  654.           next
  655.         end
  656.         
  657.         # ======================== 加强功能 ========================
  658.         
  659.         # 显示物品图标
  660.         if c == "\003"
  661.           # 取得物品ID
  662.           @text.sub!(/\[([0-9]+)\]/, "")
  663.           # 这里的 RPG::Cache 是高速缓存,不明白的看看帮助文档吧……
  664.           icon = RPG::Cache.icon($data_items[$1.to_i].icon_name)
  665.           # 绘制这个图标
  666.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  667.           # 将x值增加24
  668.           @x+=24
  669.           # 执行下一次循环
  670.           next
  671.         end
  672.         # 显示技能图标(因为类似物品图标显示,所以省略注释)
  673.         if c == "\004"
  674.           @text.sub!(/\[([0-9]+)\]/, "")
  675.           icon = RPG::Cache.icon($data_skills[$1.to_i].icon_name)
  676.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  677.           @x+=24
  678.           next
  679.         end
  680.         # 显示武器图标(因为类似物品图标显示,所以省略注释)
  681.         if c == "\005"
  682.           @text.sub!(/\[([0-9]+)\]/, "")
  683.           icon = RPG::Cache.icon($data_weapons[$1.to_i].icon_name)
  684.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  685.           @x+=24
  686.           next
  687.         end
  688.         # 显示防具图标(因为类似物品图标显示,所以省略注释)
  689.         if c == "\006"
  690.           @text.sub!(/\[([0-9]+)\]/, "")
  691.           icon = RPG::Cache.icon($data_armors[$1.to_i].icon_name)
  692.           self.contents.blt(@x+4,@y*@height+(@height-24)/2,icon,Rect.new(0, 0, 24, 24))
  693.           @x+=24
  694.           next
  695.         end
  696.         
  697.         # 等待n帧
  698.         if c == "\024"
  699.           # 取得参数(需要等待多少帧)
  700.           @text.sub!(/\[([0-9]+)\]/, "")
  701.           # 设定@delay标志
  702.           @delay = $1.to_i
  703.           # 退出此次循环
  704.           break
  705.         end
  706.         
  707.         # 显示头像
  708.         if c == "\030"
  709.           #暂时记录文字大小,用于显示完头像恢复
  710.           size=self.contents.font.size
  711.           # 设定为正常的20号字
  712.           self.contents.font.size=20
  713.           # 设定系统字色,为写名字做准备的
  714.           self.contents.font.color = system_color
  715.           # 取得"[]"内的字符并从原字串中删除这一部分
  716.           @text.sub!(/\[([0-9]+)\]/, "")
  717.           # 记录到head变量
  718.           head=$1
  719.           # 判断头像和原来的是不是一样的
  720.           if @face == nil
  721.             # 不一样
  722.             if @head_file != head
  723.               # 改变成现在的头像文件名
  724.               @head_file = head
  725.               # 不一样的话再重新载入头像
  726.               @head_bmp=RPG::Cache.character("head/gpra_"+@head_file, 0)
  727.             end
  728.           else
  729.             # 当表情不是空的时候需要考虑表情的
  730.             if @head_file != head + "_" + @face
  731.               # 改变成现在的头像文件名
  732.               @head_file = head + "_" + @face
  733.               # 不一样的话再重新载入头像
  734.               @head_bmp=RPG::Cache.character("head/gpra_"+@head_file, 0)
  735.             end
  736.           end
  737.           # 显示头像,分左右两种情况
  738.           if @right
  739.             # 绘制头像图片
  740.             self.contents.blt(348,0,@head_bmp,Rect.new(0,0,100,100))
  741.             # 显示角色姓名
  742.             if @name==nil
  743.               # 取得角色姓名到变量 c
  744.               c = $game_actors[head.to_i].name
  745.               # 描绘角色的姓名
  746.               self.contents.draw_text_s(348,104,100,24,c,1)
  747.             else
  748.               # 取得"???"到变量 c,当然这个"???"可以改为其他的默认值
  749.               c = @name
  750.               # 描绘角色的姓名
  751.               self.contents.draw_text_s(348,104,100,24,c,1)
  752.             end
  753.           else
  754.             # 绘制头像图片
  755.             self.contents.blt(0,0,@head_bmp,Rect.new(0,0,100,100))
  756.             # 显示角色姓名
  757.             if @name==nil
  758.               # 取得角色姓名到变量 c
  759.               c = $game_actors[head.to_i].name
  760.               # 描绘角色的姓名
  761.               self.contents.draw_text_s(0,104,100,24,c,1)
  762.             else
  763.               # 取得"???"到变量 c,当然这个"???"可以改为其他的默认值
  764.               c = @name
  765.               # 描绘角色的姓名
  766.               self.contents.draw_text_s(0,104,100,24,c,1)
  767.             end
  768.           end
  769.           # 恢复默认字色
  770.           self.contents.font.color = normal_color
  771.           # 恢复字体大小
  772.           self.contents.font.size=size
  773.           # 进行下一次循环
  774.           next
  775.         end
  776.         
  777.         # 显示图片!只需要绘图而已。
  778.         if c == "\031"
  779.           self.contents.blt(@pic_x,@pic_y,@pic,@pic.rect)
  780.           next
  781.         end
  782.         
  783.         # ======================== 以上加强部分 ========================
  784.         
  785.         # 自动换行模式
  786.         if @auto_newline
  787.           # 计算应该换行的最大X坐标
  788.           max_x = self.contents.width - 4
  789.           # 在右侧显示头像的时候,坐标应该左移让出头像的位置
  790.           if @right&&@show_head
  791.             max_x -= 104
  792.           end
  793.           # 并且文字已经超出了显示宽度
  794.           if @x+self.contents.text_size(c).width+4 > max_x
  795.             # 增加一个换行符号,并且将本次准备显示的字符放到下一行
  796.             @text = "\n" + c + @text
  797.             # 跳过这次绘制文字
  798.             next
  799.           end
  800.         end
  801.         
  802.         # 描绘文字
  803.         self.contents.draw_text_s(4+@x,@height*@y, @height, @height, c)
  804.         # x 为描绘文字宽度进行自增运算,计算下一个文字起始位置
  805.         @x += self.contents.text_size(c).width
  806.          
  807.         # 操作了@type_mode个字符后就退出循环了,@type_mode为负则操作一次完成
  808.         i-=1
  809.         if i==0
  810.           break
  811.         end
  812.       
  813.       end
  814.     end
  815.    
  816.     # 如果@text处理结束了
  817.     if @text==nil or @text==""
  818.       # 设置结束标志
  819.       @finish=true
  820.     end
  821.   end
  822. end
复制代码

点评

恩,我确实是忘记考虑没有头像的这个问题了  发表于 2010-12-21 15:59
飘絮添加的句子会让没有头像的文章第一行默认空出104  发表于 2010-12-21 15:49
第289行 : if @text.slice!(/\\[Ll]/)!=nil # 设定头像居右标志为假 @right=true else @x=104 end  发表于 2010-12-21 15:30
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
162 小时
注册时间
2010-7-19
帖子
205
9
 楼主| 发表于 2010-12-21 15:32:56 | 只看该作者
8楼的好强悍:funk: 所有的头像都显示在了左边……
只不过还是有点小问题,出现选项的时候字会叠加在头像上

点评

苹果梨有考虑到这个问题的原脚本641行有提到过,可是貌似没起到作用。  发表于 2010-12-21 16:08
其实是gpra在写换行的时候忘了考虑头像左右了……  发表于 2010-12-21 15:56
纤尘镜大整改,全游戏重置中
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
34 小时
注册时间
2010-10-7
帖子
58
10
发表于 2010-12-21 15:51:12 | 只看该作者
本帖最后由 月冷心 于 2010-12-21 15:51 编辑

楼主给的脚本上写了选项空格的问题,可是苹果梨原来的脚本就有这个问题,貌似没办法解决的。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-1 23:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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