查看: 2429|回复: 7

[已经解决] 为什么无法换行

[复制链接]
梦石
0
星屑
219
在线时间
104 小时
注册时间
2014-2-23
回帖
29
发表于 2014-2-27 17:14:01 | 显示全部楼层 |阅读模式

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

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

×
我在文本里加了 “\n” 但是没有显示换行
难道不是  “\n”  ?
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2014-2-27 17:29:45 | 显示全部楼层
本帖最后由 Sion 于 2014-2-27 17:33 编辑

因为n被当做控制符 \n[x] 被置换为 x号角色的名字
  1. class Window_Base
  2.   def convert_escape_characters(text)
  3.     result = text.to_s.clone
  4.     result.gsub!(/\\/)            { "\e" }
  5.     result.gsub!(/\e\e/)          { "\" }
  6.     result.gsub!(/\en/)           { "\n" } # 加这个
  7.     result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  8.     result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
  9.     result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
  10.     result.gsub!(/\eG/i)          { Vocab::currency_unit }
  11.     result
  12.   end
  13. end
复制代码
这样改的话 \n  还是 \n; \N[x] 是置换名字。
回复

使用道具 举报

梦石
0
星屑
219
在线时间
104 小时
注册时间
2014-2-23
回帖
29
 楼主| 发表于 2014-2-27 18:39:15 | 显示全部楼层
Sion 发表于 2014-2-27 17:29
因为n被当做控制符 \n[x] 被置换为 x号角色的名字这样改的话 \n  还是 \n; \N[x] 是置换名字。 ...

[pre lang="ruby" line="1"]
class Window_Base
  
  alias :iisnow_convert_escape_characters :convert_escape_characters
  def convert_escape_characters(text)
    result = iisnow_convert_escape_characters(text)
    result.gsub!(/\ek/)          { "\k" }
    result
  end

  def process_character(c, text, pos)
    case c
    when "\r"  
      return
    when "\n"  
      process_new_line(text, pos) if !@auto_n
    when "\k"
      @auto_n = false
    when "\f"   
      process_new_page(text, pos)
    when "\e"   
      process_escape_character(obtain_escape_code(text), text, pos)
    else      
      process_normal_character(c,text,pos)
    end
  end
  
  def process_normal_character(c,text,pos)
    @auto_n = true
    text_width = text_size(c).width
    if real_width - pos[:x] > text_width
      draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
      pos[:x] += text_width
    else
      process_new_line(text,pos)
      process_normal_character(c,text,pos)
    end
  end
  
  def real_width
    return self.width - 2 * standard_padding
  end
  
end

class Window_Message
  
  def process_normal_character(c,text,pos)
    super
    wait_for_one_character
  end

end
[/pre]

与这个脚本冲突了,大神帮忙看看{:2_249:}

点评

你把这个放在我那个下面就行了。  发表于 2014-2-27 20:25
回复

使用道具 举报

梦石
0
星屑
219
在线时间
104 小时
注册时间
2014-2-23
回帖
29
 楼主| 发表于 2014-2-27 21:24:27 | 显示全部楼层
Sion 发表于 2014-2-27 17:29
因为n被当做控制符 \n[x] 被置换为 x号角色的名字这样改的话 \n  还是 \n; \N[x] 是置换名字。 ...

我就是这么放的{:2_271:}
回复

使用道具 举报

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2014-2-27 22:15:10 | 显示全部楼层
本帖最后由 Sion 于 2014-2-27 22:19 编辑
huct08 发表于 2014-2-27 21:24
我就是这么放的


我靠,你这个是自动换行的嘛,你都自动换行了,还要手动换行干毛 - -b

这个脚本读到 \k 会关闭自动换行,你不会不知道巴?

嗯.....它这个写得不对{:2_254:} 我都无语了。
回复

使用道具 举报

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2014-2-27 22:22:27 | 显示全部楼层
你用这个吧,直接输入 \k 换行

[pre lang="ruby" line="1"]class Window_Base

  def process_character(c, text, pos)
    case c
    when "\r"  
      return
    when "\n"  
      process_new_line(text, pos) if !@auto_n
    when "\f"   
      process_new_page(text, pos)
    when "\e"   
      process_escape_character(obtain_escape_code(text), text, pos)
    else      
      process_normal_character(c,text,pos)
    end
  end
  
  def process_escape_character(code, text, pos)
    case code.upcase
    when 'C'
      change_color(text_color(obtain_escape_param(text)))
    when 'I'
      process_draw_icon(obtain_escape_param(text), pos)
    when '{'
      make_font_bigger
    when '}'
      make_font_smaller
    when 'K'
      process_new_line(text, pos)
    end
  end
  
  def process_normal_character(c,text,pos)
    @auto_n = true
    text_width = text_size(c).width
    if real_width - pos[:x] > text_width
      draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
      pos[:x] += text_width
    else
      process_new_line(text,pos)
      process_normal_character(c,text,pos)
    end
  end

  def real_width
    return self.width - 2 * standard_padding
  end

end

class Window_Message

  def process_normal_character(c,text,pos)
    super
    wait_for_one_character
  end

end[/pre]
回复

使用道具 举报

梦石
1
星屑
23241
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2014-2-27 22:28:09 | 显示全部楼层
少年不试着换一个自动换行脚本...?
http://rpg.blue/home.php?mod=spa ... o=blog&id=11571
回复

使用道具 举报

梦石
0
星屑
219
在线时间
104 小时
注册时间
2014-2-23
回帖
29
 楼主| 发表于 2014-2-28 09:42:12 | 显示全部楼层
Sion 发表于 2014-2-27 22:22
你用这个吧,直接输入 \k 换行

class Window_Base

问题解决 谢谢{:2_249:}
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部