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

Project1

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

怎样让对话框显示更多的字?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
9 小时
注册时间
2006-9-7
帖子
303
跳转到指定楼层
1
发表于 2009-1-8 03:41:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x

   我想实现的效果图:

   


  
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # ----------------------------
  5. class Window_Message < Window_Selectable
  6.   attr_accessor :autoclosetime
  7.   attr_accessor :op
  8. # ----------------------------
  9.   def initialize
  10.     super(80, 304, 480, 160)
  11.     self.contents = Bitmap.new(width - 32, height - 32)
  12.     self.visible = false
  13.     self.z = 9998
  14.     @fade_in = false
  15.     @fade_out = false
  16.     @contents_showing = false
  17.     @cursor_width = 0
  18.     @autoclosetime = -1
  19.     @op = 255
  20.     @refreshflag = false
  21.     $game_system.message_position = 1  # 1 对话框居中
  22.     self.active = false
  23.     self.index = -1
  24.   end
  25. # ----------------------------
  26.   def dispose
  27.     terminate_message
  28.     $game_temp.message_window_showing = false
  29.     if @input_number_window != nil
  30.       @input_number_window.dispose
  31.     end
  32.     super
  33.   end
  34. # ----------------------------
  35.   def terminate_message
  36.     self.active = false
  37.     self.pause = false
  38.     self.index = -1
  39.     self.contents.clear
  40.     @contents_showing = false
  41.     if $game_temp.message_proc != nil
  42.       $game_temp.message_proc.call
  43.     end
  44.     $game_temp.message_text = nil
  45.     $game_temp.message_proc = nil
  46.     $game_temp.choice_start = 99
  47.     $game_temp.choice_max = 0
  48.     $game_temp.choice_cancel_type = 0
  49.     $game_temp.choice_proc = nil
  50.     $game_temp.num_input_start = 99
  51.     $game_temp.num_input_variable_id = 0
  52.     $game_temp.num_input_digits_max = 0
  53.     if @gold_window != nil
  54.       @gold_window.dispose
  55.       @gold_window = nil
  56.     end
  57.   end
  58. # ----------------------------
  59.   def refresh
  60.     self.contents.clear
  61.     self.contents.font.color = normal_color
  62.     self.contents.font.name = "黑体"
  63.     self.contents.font.size = 17
  64.     x = y = 0
  65.     @cursor_width = 0
  66.     @autoclosetime = -1
  67.     @refreshflag = true
  68.     lineheight = 20
  69.     active = ""
  70.     a = ""
  71.     centerflag = false
  72.     rightflag = false
  73.     bannerflag = false
  74.     if $game_temp.choice_start == 0
  75.       x = 8
  76.     end
  77.     if $game_temp.message_text != nil
  78.       text = $game_temp.message_text
  79.       begin
  80.       last_text = text.clone
  81.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  82.       end until text == last_text
  83.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  84.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  85.       end
  86.       text.gsub!(/\\\\/) { "\000" }
  87.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  88.       text.gsub!(/\\[Gg]/) { "\002" }
  89.        text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\003[#{$1}]" }
  90.       text.gsub!(/\\[Ff]\[([0-9]+)\]/) { "\004[#{$1}]" }
  91.       text.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\005[#{$1}]" }
  92.       text.gsub!(/\\[Xx]/) { "\006" }
  93.       text.gsub!(/\\[Rr]/) { "\007" }
  94.       text.gsub!(/\\[Dd]/) { "\011" }
  95.       text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\023[#{$1}]" }
  96.       text.gsub!(/\\[Bb]/) { "\017" }
  97.       text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\014[#{$1}]" }
  98.       text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\015[#{$1}]" }
  99.       text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\016[#{$1}]" }
  100.       text.gsub!(/\\[Jj]\[([0-9]+)\]/) { "\013[#{$1}]" }
  101.       text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\021[#{$1}]" }
  102.       text.gsub!(/\\[Kk]\[([0-9]+)\]/) { "\022[#{$1}]" }
  103.       while ((c = text.slice!(/./m)) != nil)
  104.         if c == "\000"
  105.           c = "\\"
  106.         end
  107.         if c == "\001"
  108.           text.sub!(/\[([0-9]+)\]/, "")
  109.           color = $1.to_i
  110.           if color >= 0 and color <= 7
  111.             self.contents.font.color = text_color(color)
  112.           end
  113.           next
  114.         end
  115.         if c == "\002"
  116.           if @gold_window == nil
  117.             @gold_window = Window_Gold.new
  118.             @gold_window.x = 560 - @gold_window.width
  119.             if $game_temp.in_battle
  120.               @gold_window.y = 192
  121.             else
  122.               @gold_window.y = self.y >= 128 ? 32 : 384
  123.             end
  124.             @gold_window.opacity = self.opacity
  125.             @gold_window.back_opacity = self.back_opacity
  126.           end
  127.           next
  128.         end
  129.           if c == "\003"
  130.           text.sub!(/\[([0-9]+)\]/, "")
  131.           item_sub = $1.to_i
  132.           c = $data_items[item_sub].name
  133.           l = self.contents.text_size(c).width
  134.           draw_item_name($data_items[item_sub], x, y * 32 + 1)
  135.           x = x + l + 24
  136.           next
  137.         end
  138.          if c == "\004"
  139.           text.sub!(/\[([0-9]+)\]/, "")
  140.           fontize = $1.to_i
  141.           case fontize
  142.             when 1
  143.               self.contents.font.name = "黑体"
  144.             when 2
  145.               self.contents.font.name = "High Tower Text"
  146.             when 3
  147.               self.contents.font.name = "Tw Cen MT"
  148.             when 4
  149.               self.contents.font.name = "Tahoma"
  150.           end
  151.           next
  152.         end
  153.          if c == "\005"
  154.           text.sub!(/\[([0-9]+)\]/, "")
  155.           @autoclosetime = $1.to_i
  156.           next
  157.         end
  158.         if c == "\006"
  159.           centerflag = true
  160.           next
  161.         end
  162.         if c == "\007"
  163.           rightflag = true
  164.           next
  165.         end
  166.         if c == "\011"
  167.           self.contents.font.name = "黑体"
  168.           self.contents.font.size = 18
  169.           self.contents.font.color = normal_color
  170.           lineheight = 32
  171.           next
  172.         end
  173.         if c == "\014"
  174.           text.sub!(/\[([0-9]+)\]/, "")
  175.           w_sub = $1.to_i
  176.           c = $data_weapons[w_sub].name
  177.           l = self.contents.text_size(c).width
  178.           bitmap = RPG::Cache.icon($data_weapons[w_sub].icon_name)
  179.           self.contents.blt(x+4, y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  180.           x += 28
  181.           self.contents.draw_text(x+4, 32 * y, l+32, lineheight, c)
  182.           x = x + l
  183.           next
  184.         end
  185.           if c == "\015"
  186.           text.sub!(/\[([0-9]+)\]/, "")
  187.           a_sub = $1.to_i
  188.           c = $data_armors[a_sub].name
  189.           l = self.contents.text_size(c).width
  190.           bitmap = RPG::Cache.icon($data_armors[a_sub].icon_name)
  191.           self.contents.blt(x+4, y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  192.           x += 28
  193.           self.contents.draw_text(x+4, 32 * y, l+32, lineheight, c)
  194.           x = x + l
  195.           next
  196.         end
  197.           if c == "\016"
  198.           text.sub!(/\[([0-9]+)\]/, "")
  199.           @op = $1.to_i
  200.           next
  201.         end
  202.          if c == "\017"
  203.           bannerflag = true
  204.           next
  205.         end
  206.         if c == "\018"
  207.           text.sub!(/\[([0-9]+)\]/, "")
  208.           jump = $1.to_i
  209.           x += jump
  210.           next
  211.         end
  212.           if c == "\021"
  213.           text.sub!(/\[([0-9]+)\]/, "")
  214.           lineheight = $1.to_i
  215.           next
  216.         end
  217.         if c == "\022"
  218.           text.sub!(/\[([0-9]+)\]/, "")
  219.           skill_sub = $1.to_i
  220.           c = $data_skills[skill_sub].name
  221.           l = self.contents.text_size(c).width
  222.           bitmap = RPG::Cache.icon($data_skills[skill_sub].icon_name)
  223.           self.contents.blt(x+4, y * 32+ 4, bitmap, Rect.new(0, 0, 24, 24))
  224.           x += 28
  225.           self.contents.draw_text(x+4, 32 * y, l+32, lineheight, c)
  226.           x = x + l
  227.           next
  228.         end
  229.          if c == "\023"
  230.           text.sub!(/\[([0-9]+)\]/, "")
  231.           bigness = $1.to_i
  232.           self.contents.font.size = bigness
  233.           next
  234.         end
  235.         if c == "\n"
  236.           if centerflag == true
  237.             x = 448 - x
  238.             x = x / 2
  239.             self.contents.draw_text(x, 32 * y, 448-x, lineheight, a)
  240.           end
  241.           if rightflag == true
  242.             x = 448 - x
  243.             self.contents.draw_text(x, 32 * y, 448-x, lineheight, a)
  244.           end
  245.           if bannerflag == true
  246.             x = 448 - x
  247.             x = x / 2
  248.             self.contents.draw_text(x, 44, 448-x, lineheight, a)
  249.           end
  250.           a = ""
  251.           centerflag = false
  252.           rightflag = false
  253.           bannerflag = false
  254.           if y >= $game_temp.choice_start
  255.             @cursor_width = [@cursor_width, x].max
  256.           end
  257.           y += 1
  258.           x = 0
  259.           if y >= $game_temp.choice_start
  260.             x = 8
  261.           end
  262.           next
  263.         end
  264.         if centerflag == false && rightflag == false && bannerflag == false
  265.         self.contents.draw_text(4 + x, 32 * y, 40, lineheight, c)
  266.         x += self.contents.text_size(c).width
  267.       else
  268.         a += c
  269.         x += self.contents.text_size(c).width
  270.         end
  271.       end
  272.     end
  273.     if $game_temp.choice_max > 0
  274.       @item_max = $game_temp.choice_max
  275.       self.active = true
  276.       self.index = 0
  277.     end
  278.     if $game_temp.num_input_variable_id > 0
  279.       digits_max = $game_temp.num_input_digits_max
  280.       number = $game_variables[$game_temp.num_input_variable_id]
  281.       @input_number_window = Window_InputNumber.new(digits_max)
  282.       @input_number_window.number = number
  283.       @input_number_window.x = self.x + 8
  284.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  285.     end
  286.   end
  287. # ----------------------------
  288.   def reset_window
  289.     if $game_temp.in_battle
  290.       self.y = 16
  291.     else
  292.       case $game_system.message_position
  293.       when 0
  294.         self.y = 16
  295.       when 1
  296.         self.y = 160
  297.       when 2
  298.         self.y = 304
  299.       end
  300.     end
  301.     if $game_system.message_frame == 0
  302.       self.opacity = 255
  303.     else
  304.       self.opacity = 0
  305.     end
  306.     self.back_opacity = 255 # 背景不透明
  307.   end
  308. # ----------------------------  
  309.   def update
  310.     super
  311.     if @refreshflag && @fade_in == false
  312.       self.contents_opacity = @op
  313.      end
  314.     if @autoclosetime == 0
  315.     @autoclosetime = -1
  316.      terminate_message
  317.    end
  318.     if @autoclosetime >= 1
  319.     @autoclosetime -= 1
  320.     end
  321.     if @fade_in
  322.       self.contents_opacity += 24
  323.       if @input_number_window != nil
  324.         @input_number_window.contents_opacity += 24
  325.       end
  326.       if self.contents_opacity >= @op
  327.         @fade_in = false
  328.       end
  329.       return
  330.     end
  331.     if @input_number_window != nil
  332.       @input_number_window.update
  333.       if Input.trigger?(Input::C)
  334.         $game_system.se_play($data_system.decision_se)
  335.         $game_variables[$game_temp.num_input_variable_id] =
  336.           @input_number_window.number
  337.         $game_map.need_refresh = true
  338.         @input_number_window.dispose
  339.         @input_number_window = nil
  340.         terminate_message
  341.       end
  342.       return
  343.     end
  344.     if @contents_showing
  345.       if $game_temp.choice_max == 0
  346.         self.pause = true
  347.       end
  348.       if Input.trigger?(Input::B)
  349.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  350.           $game_system.se_play($data_system.cancel_se)
  351.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  352.           terminate_message
  353.         end
  354.       end
  355.       if Input.trigger?(Input::C)
  356.         if $game_temp.choice_max > 0
  357.           $game_system.se_play($data_system.decision_se)
  358.           $game_temp.choice_proc.call(self.index)
  359.         end
  360.         @op = 255
  361.         terminate_message
  362.       end
  363.       return
  364.     end
  365.     if @fade_out == false and $game_temp.message_text != nil
  366.       @contents_showing = true
  367.       $game_temp.message_window_showing = true
  368.       reset_window
  369.       refresh
  370.       Graphics.frame_reset
  371.       self.visible = true
  372.       self.contents_opacity = 0
  373.       if @input_number_window != nil
  374.         @input_number_window.contents_opacity = 0
  375.       end
  376.       @fade_in = true
  377.       return
  378.     end
  379.     if self.visible
  380.       @fade_out = true
  381.       self.opacity -= 48
  382.       if self.opacity == 0
  383.         self.visible = false
  384.         @fade_out = false
  385.         $game_temp.message_window_showing = false
  386.       end
  387.       return
  388.     end
  389.   end
  390. # ----------------------------
  391.   def update_cursor_rect
  392.     if @index >= 0
  393.       n = $game_temp.choice_start + @index
  394.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  395.     else
  396.       self.cursor_rect.empty
  397.     end
  398.   end
  399. end

  400. #==============================================================================
  401. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  402. #==============================================================================
复制代码
十年磨一剑,蓦然回首,年华如水,青春如歌。
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2009-1-6
帖子
413
2
发表于 2009-1-8 04:16:16 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-9-24
帖子
409
3
发表于 2009-1-8 20:30:46 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
9 小时
注册时间
2006-9-7
帖子
303
4
 楼主| 发表于 2009-1-8 21:28:12 | 只看该作者
我记得论坛有人解决了,但是没有说出方法来啊,我不知道怎么弄.
十年磨一剑,蓦然回首,年华如水,青春如歌。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

随缘

梦石
0
星屑
55
在线时间
12 小时
注册时间
2007-12-16
帖子
671
5
发表于 2009-1-9 06:37:25 | 只看该作者
主站搜索"长文章"
论坛:
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

七仙女

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-1-15
帖子
559
6
发表于 2009-1-9 06:49:19 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6645
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

7
发表于 2009-1-9 10:42:13 | 只看该作者
就你的图而言,一共用了8行
建议使用续行符

http://rpg.blue/web/htm/news827.htm

续行符可以解决行数
至于横着的就是LS说的那样给变量赋值,然后显示变量的值
系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~











你知道得太多了

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
9 小时
注册时间
2006-9-7
帖子
303
8
 楼主| 发表于 2009-1-9 20:09:20 | 只看该作者
请问怎么把“长文章”赋值给变量,然后显示变量?
十年磨一剑,蓦然回首,年华如水,青春如歌。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2009-1-7
帖子
89
9
发表于 2009-1-9 20:23:29 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6645
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

10
发表于 2009-1-9 20:57:32 | 只看该作者
比如拿数据库变量1号来说吧
事件脚本里编写如下内容

$game_variables[1] = "请问楼上的你是在说谁在灌水呢,是说你自己吗?"

就是这样,给变量1号赋值一个字符串,
要注意的是 事件脚本里一行是固定了宽度的,如果一句很长的话无法在一行里打完的话就要像这样写
比如上面那句话
比如我们打到这里就已经用完一行了
$game_variables[1] = "请问楼上的你是在说谁在灌水呢,
那么怎么办呢?
在第一行的最后加上一个"和一个+
然后在第2行继续写后面的内容,记得双引号别掉了
"是说你自己吗?"

总体就是这样的
$game_variables[1] = "请问楼上的你是在说谁在灌水呢," +
"是说你自己吗?"

如果第2行也用完了那就接着同样的格式第3行
还有就是默认的对话框的宽度是不够的要改宽一点点
为什么呢?
你用显示文章随便打满第一排字
然后运行看看第一排的最后那点点就明白了!

补充一点,我不记得显示变量的字符串是否有自动换行功能
如果没有自动换行的话 换行的代码是 \n
系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~











你知道得太多了

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-12 05:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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