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

Project1

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

[已经过期] 增强版对话中显示选择项的设置问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
30 小时
注册时间
2013-6-10
帖子
17
跳转到指定楼层
1
发表于 2013-7-17 16:02:46 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
用了增强版对话后,当出现选择想的时候,如图,是这样子的

选项后面的背景条是一长条的,我想让这个背景条随选项字数的变化进行长度变化,效果如下:

希望哪位大神路过帮忙指导一下!!!

QQ截图20130717153510.png (337.61 KB, 下载次数: 2)

QQ截图20130717153510.png

QQ截图20130717153823.png (185.38 KB, 下载次数: 3)

QQ截图20130717153823.png

QQ截图20130717153939.png (188.95 KB, 下载次数: 5)

QQ截图20130717153939.png

Lv1.梦旅人

梦石
0
星屑
50
在线时间
30 小时
注册时间
2013-6-10
帖子
17
2
 楼主| 发表于 2013-7-17 16:04:46 | 只看该作者
代码工程如下:
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. #——说明

  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7.    
  8. #默认对话字没有声音,如果需要声音,
  9. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  10. #我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  11. # 其他在对话中可以使用的功能:

  12. # \n[1]:显示1号角色的姓名

  13. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

  14. # \p[1]:对话框出现在1号事件的上方
  15. # \p[0]:主人公上方出现对话框
  16. #——————————————————使用\p功能后可以自动调整对话框大小

  17. # \\:显示"\"这个符号

  18. # \c[1-8]:更改颜色

  19. # \g:显示金钱窗口

  20. # \a[SE文件名]:对话的时候播放SE

  21. # \s[1-19]:更改弹字的速度

  22. # \.   :停顿一刹那(1、2帧)
  23. # \|   :停顿片刻(20帧)

  24. # \>   :文字不用打字方式
  25. # \<   :文字使用打字方式

  26. # \!   :等待玩家按回车再继续
  27. # \~   :文字直接消失

  28. # \I   :下一行从这个位置开始

  29. # \o[123]:文字透明度改为123,模拟将死之人(汗)

  30. # \h[12]:改用12号字

  31. # \b[50]:空50象素

  32. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

  33. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  34. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”

  35. # \Lk:清除左边的图像
  36. # \Rk:清除右边的图像
  37. # \M[60]:等待60帧文字直接消失

  38. #脚本冲突可能:
  39. #不用说了。因为改了分辨率所有原有窗口需要自己定义,基本上可以算是和所有脚本冲突。
  40. module Style
  41.   Font = []
  42.   Size = []
  43.   Color = []
  44.   
  45.   Font[1] = "微软雅黑"
  46.   Color[1] = ::Color.new(128,128,128)
  47.   Size[1] = 10
  48.   
  49. end
  50. #============================
  51. class Game_System
  52. attr_accessor :typing
  53. attr_accessor :soundname_on_speak
  54. alias carol3_ini initialize
  55. def initialize
  56.    carol3_ini
  57.    @typing = true
  58.    @soundname_on_speak = nil
  59. end
  60. end
  61. #=================================
  62. #==============================================================================
  63. # ■ Window_Message
  64. #------------------------------------------------------------------------------
  65. class Window_Message < Window_Selectable
  66. #--------------------------------------------------------------------------
  67. # ● 初始化状态
  68. #--------------------------------------------------------------------------
  69. def initialize
  70.    super(10, 200, 620, 280)
  71.    self.contents = Bitmap.new(width - 32, height - 32)
  72.    self.visible = false
  73.    self.z = 9998
  74.    @fade_in = false
  75.    @fade_out = false
  76.    @contents_showing = false
  77.    @cursor_width = 0
  78.    @autoclosetime = -1
  79.    self.active = false
  80.    self.index = -1
  81.    if $game_system.soundname_on_speak == nil then
  82.      $game_system.soundname_on_speak = ""
  83.    end
  84.    @opacity_text_buf = Bitmap.new(32, 32)
  85. end
  86. #--------------------------------------------------------------------------
  87. # ● 释放
  88. #--------------------------------------------------------------------------
  89. def dispose
  90.    terminate_message
  91.    $game_temp.message_window_showing = false
  92.    if @input_number_window != nil
  93.      @input_number_window.dispose
  94.    end
  95.    super
  96. end
  97. #--------------------------------------------------------------------------
  98. # ● 处理信息结束
  99. #--------------------------------------------------------------------------
  100. def terminate_message
  101.    self.active = false
  102.    self.pause = false
  103.    self.index = -1
  104.    self.contents.clear
  105.    # 清除显示中标志
  106.    @contents_showing = false
  107.    # 呼叫信息调用
  108.    if $game_temp.message_proc != nil
  109.      $game_temp.message_proc.call
  110.    end
  111.    # 清除文章、选择项、输入数值的相关变量
  112.    $game_temp.message_text = nil
  113.    $game_temp.message_proc = nil
  114.    $game_temp.choice_start = 99
  115.    $game_temp.choice_max = 0
  116.    $game_temp.choice_cancel_type = 0
  117.    $game_temp.choice_proc = nil
  118.    $game_temp.num_input_start = 99
  119.    $game_temp.num_input_variable_id = 0
  120.    $game_temp.num_input_digits_max = 0
  121.    # 开放金钱窗口
  122.    if @gold_window != nil
  123.      @gold_window.dispose
  124.      @gold_window = nil
  125.    end
  126.    if @name_window_frame != nil
  127.      @name_window_frame.dispose
  128.      @name_window_frame = nil
  129.    end
  130.    if @name_window_text != nil
  131.      @name_window_text.dispose
  132.      @name_window_text = nil
  133.    end
  134.    if @right_picture != nil and @right_keep == true
  135.      @right_picture.dispose
  136.    end   
  137.    if @left_picture != nil and @left_keep == true
  138.      @left_picture.dispose
  139.    end
  140. end
  141. def refresh
  142.    # 初期化
  143.    self.contents.clear
  144.    self.contents.font.color = normal_color
  145.    self.contents.font.size = Font.default_size
  146.    @x = @y = @max_x = @max_y = @indent = @lines = 0
  147.    @left_keep = @right_keep = false
  148.    @face_indent = 0
  149.    [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  150.    @cursor_width = 0
  151.    @autoclosetime = -1
  152.    @write_speed = 0
  153.    @write_wait = 0
  154.    @mid_stop = false
  155.    @face_file = nil
  156.    @popchar = -2
  157.    if $game_temp.choice_start == 0
  158.      @x = 8
  159.    end
  160.    if $game_temp.message_text != nil
  161.      @now_text = $game_temp.message_text
  162.      #——头像设置
  163.      if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  164.        @face_file = $1 + ".png"
  165.        @x = @face_indent = 128
  166.        if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  167.          self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  168.        end
  169.        @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  170.       
  171.      end
  172.      #——左半身像设置
  173.      if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  174.        [url=home.php?mod=space&uid=84331]@face[/url] = $1 + "_h.png"
  175.        if $加密 == true
  176.          if @left_picture != nil
  177.            @left_picture.dispose
  178.          end
  179.          @left_picture = Sprite.new
  180.          @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  181.          @left_picture.y = 480-@left_picture.bitmap.height
  182.          @left_picture.x = 0
  183.          @left_picture.z = 9999
  184.          @left_picture.mirror = true
  185.          @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  186.        else         
  187.          if FileTest.exist?("Graphics/battlers/#{@face}")
  188.            if @left_picture != nil
  189.              @left_picture.dispose
  190.            end
  191.            @left_picture = Sprite.new
  192.            @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  193.            @left_picture.y = 480-@left_picture.bitmap.height
  194.            @left_picture.x = 0
  195.            @left_picture.z = 9999
  196.            @left_picture.mirror = true
  197.            @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  198.          end
  199.        end
  200.       
  201.      end
  202.      #——右半身像设置
  203.      if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  204.        @face = $1 + "_h.png"
  205.        if $加密 == true
  206.          if @right_picture != nil
  207.            @right_picture.dispose
  208.          end
  209.          @right_picture = Sprite.new
  210.          @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  211.          @right_picture.y = 480-@right_picture.bitmap.height
  212.          @right_picture.x = 600-@right_picture.bitmap.width
  213.          @right_picture.z = 9999
  214.          @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  215.        else
  216.          if FileTest.exist?("Graphics/battlers/#{@face}")
  217.            if @right_picture != nil
  218.              @right_picture.dispose
  219.            end
  220.            @right_picture = Sprite.new
  221.            @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  222.            @right_picture.y = 480-@right_picture.bitmap.height
  223.            @right_picture.x = 600-@right_picture.bitmap.width
  224.            @right_picture.z = 9999
  225.            @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  226.          end
  227.        end
  228.       
  229.      end
  230.      if (/\\[Rr]k/.match(@now_text)) != nil
  231.        @right_keep = true
  232.        @now_text.sub!(/\\[Rr]k/) { "" }
  233.      end
  234.      if (/\\[Ll]k/.match(@now_text)) != nil
  235.        @left_keep = true
  236.        @now_text.sub!(/\\[Ll]k/) { "" }
  237.      end
  238.      # 显示人物姓名
  239.      name_window_set = false
  240.      if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  241.        name_window_set = true
  242.        name_text = $1
  243.        @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  244.      end
  245.    
  246.      # 文字位置的判定
  247.      if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  248.        @popchar = $1.to_i
  249.        if @popchar == -1
  250.          @x = @indent = 48
  251.          @y = 6
  252.        end
  253.        @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  254.      end
  255.    
  256.      # 开始
  257.      begin
  258.        last_text = @now_text.clone
  259.        @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  260.      end until @now_text == last_text
  261.      @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  262.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  263.    end
  264.    @now_text.gsub!(/\\\\/) { "\000" }
  265.    @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  266.    @now_text.gsub!(/\\[Gg]/) { "\002" }
  267.    @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  268.    @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  269.    @now_text.gsub!(/\\[.]/) { "\005" }
  270.    @now_text.gsub!(/\\[|]/) { "\006" }
  271.    @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  272.   
  273.    @now_text.gsub!(/\\[>]/) { "\016" }
  274.    @now_text.gsub!(/\\[<]/) { "\017" }
  275.    @now_text.gsub!(/\\[!]/) { "\020" }
  276.    @now_text.gsub!(/\\[~]/) { "\021" }
  277.   
  278.    @now_text.gsub!(/\\[Ii]/) { "\023" }
  279.    @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  280.    @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  281.    @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  282.    @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  283.    @now_text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\051[#{$1}]" }
  284.    @now_text.gsub!(/\\[Ss][Tt][Yy][Ll][Ee]\[([0-9]+)\]/) { "\052[#{$1}]" }
  285.    @now_text.gsub!(/\\[Ss][Ii][Zz][Ee]\[([0-9]+)\]/) { "\053[#{$1}]" }
  286.    if @popchar >= 0
  287.      @text_save = @now_text.clone
  288.      @max_x = 0
  289.      @max_y = 6
  290.      for i in 0..3
  291.        line = @now_text.split(/\n/)[3-i]
  292.        @max_y -= 1 if line == nil and @max_y <= 4-i
  293.        next if line == nil
  294.        cx = contents.text_size(line).width
  295.        @max_x = cx if cx > @max_x
  296.      end
  297.      self.width = @max_x + 48 + @face_indent
  298.      self.height = (@max_y - 1) * 32 + 64
  299.    else
  300.      @max_x = self.width - 32 - @face_indent
  301.    end
  302.    reset_window
  303.      if name_window_set
  304.        off_x = 0
  305.        off_y = -40
  306.        space = 2
  307.        x = self.x + off_x - space / 2
  308.        y = self.y + off_y - space / 2
  309.        w = self.contents.text_size(name_text).width + 26 + space
  310.        h = 40 + space
  311.        @name_window_frame = Window_Frame.new(x, y, w, h)
  312.        @name_window_frame.z = self.z + 1
  313.        x = self.x + off_x + 4
  314.        y = self.y + off_y
  315.        @name_window_text = Air_Text.new(x+4, y+6, name_text)
  316.        @name_window_text.z = self.z + 2
  317.      end
  318.    end
  319.    reset_window
  320.    if $game_temp.choice_max > 0
  321.      @item_max = $game_temp.choice_max
  322.      self.active = true
  323.      self.index = 0
  324.    end
  325.    if $game_temp.num_input_variable_id > 0
  326.      digits_max = $game_temp.num_input_digits_max
  327.      number = $game_variables[$game_temp.num_input_variable_id]
  328.      @input_number_window = Window_InputNumber.new(digits_max)
  329.      @input_number_window.number = number
  330.      @input_number_window.x = self.x + 8
  331.      @input_number_window.y = self.y + $game_temp.num_input_start * 32
  332.    end
  333. end
  334.   
  335. #--------------------------------------------------------------------------
  336. # ● 更新
  337. #--------------------------------------------------------------------------
  338. def update
  339.    super
  340.    if @autoclosetime == 0
  341.      @autoclosetime = -1
  342.      terminate_message
  343.   end
  344.    if @autoclosetime >= 1
  345.      @autoclosetime -= 1
  346.    end
  347.    if @fade_in
  348.      self.contents_opacity += 24
  349.      if @input_number_window != nil
  350.        @input_number_window.contents_opacity += 24
  351.      end
  352.      if self.contents_opacity == 255
  353.        @fade_in = false
  354.      end
  355.      return
  356.    end
  357.    @now_text = nil if @now_text == ""
  358.   
  359.    if @now_text != nil and @mid_stop == false
  360.      if @write_wait > 0
  361.        @write_wait -= 1
  362.        return
  363.      end
  364.      text_not_skip = $game_system.typing
  365.      while true
  366.        @max_x = @x if @max_x < @x
  367.        @max_y = @y if @max_y < @y
  368.        if (c = @now_text.slice!(/./m)) != nil
  369.          if c == "\000"
  370.            c = "\\"
  371.          end
  372.          if c == "\001"
  373.            @now_text.sub!(/\[([0-9]+)\]/, "")
  374.            color = $1.to_i
  375.            if color >= 0 and color <= 7
  376.              self.contents.font.color = text_color(color)
  377.            end
  378.            c = ""
  379.          end
  380.          if c == "\002"
  381.            if @gold_window == nil and @popchar <= 0
  382.              @gold_window = Window_Gold.new
  383.              @gold_window.x = 560 - @gold_window.width
  384.              if $game_temp.in_battle
  385.                @gold_window.y = 192
  386.              else
  387.                @gold_window.y = self.y >= 128 ? 32 : 384
  388.              end
  389.              @gold_window.opacity = self.opacity
  390.              @gold_window.back_opacity = self.back_opacity
  391.            end
  392.            c = ""
  393.          end
  394.          if c == "\003"
  395.            @now_text.sub!(/\[([0-9]+)\]/, "")
  396.            speed = $1.to_i
  397.            if speed >= 0 and speed <= 19
  398.              @write_speed = speed
  399.            end
  400.            c = ""
  401.          end
  402.          if c == "\004"
  403.            @now_text.sub!(/\[(.*?)\]/, "")
  404.            buftxt = $1.dup.to_s
  405.            if buftxt.match(/\//) == nil and buftxt != "" then
  406.              $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  407.            else
  408.              $game_system.soundname_on_speak = buftxt.dup
  409.            end
  410.            c = ""
  411.          elsif c == "\004"
  412.            c = ""
  413.          end
  414.          if c == "\005"
  415.            @write_wait += 5
  416.            c = ""
  417.          end
  418.          if c == "\006"
  419.            @write_wait += 20
  420.            c = ""
  421.          end
  422.          if c == "\016"
  423.            text_not_skip = false
  424.            c = ""
  425.          end
  426.          if c == "\017"
  427.            text_not_skip = true
  428.            c = ""
  429.          end
  430.          if c == "\020"
  431.            @mid_stop = true
  432.            c = ""
  433.          end
  434.          if c == "\021"
  435.            terminate_message
  436.            return
  437.          end
  438.          if c == "\023"
  439.            @indent = @x
  440.            c = ""
  441.          end
  442.          if c == "\024"
  443.            @now_text.sub!(/\[([0-9]+)\]/, "")
  444.            @opacity = $1.to_i
  445.            c = ""
  446.          end
  447.          if c == "\025"
  448.            @now_text.sub!(/\[([0-9]+)\]/, "")
  449.            self.contents.font.size = [[$1.to_i, 6].max, 32].min
  450.            c = ""
  451.          end
  452.          if c == "\026"
  453.            @now_text.sub!(/\[([0-9]+)\]/, "")
  454.            @x += $1.to_i
  455.            c = ""
  456.          end
  457.          if c == "\027"
  458.            @now_text.sub!(/\[(.*?)\]/, "")
  459.            @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  460.            if $game_system.soundname_on_speak != ""
  461.              Audio.se_play($game_system.soundname_on_speak)
  462.            end
  463.            c = ""
  464.          end
  465.          if c == "\030"
  466.            @now_text.sub!(/\[(.*?)\]/, "")
  467.            self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  468.           if $game_system.soundname_on_speak != ""
  469.              Audio.se_play($game_system.soundname_on_speak)
  470.            end
  471.            @x += 24
  472.            c = ""
  473.          end
  474.          if c == "\050"

  475.          @now_text.sub!(/\[([0-9]+)\]/, "")

  476.          @autoclosetime = $1.to_i

  477.          next

  478.          end
  479.          if c == "\051"
  480.            @now_text.sub!(/\[(.*?)\]/, "")
  481.            self.contents.font.name = $1
  482.            next
  483.          end
  484.          if c == "\052"
  485.            @now_text.sub!(/\[([0-9]+)\]/, "")
  486.            self.contents.font.name = Style::Font[$1.to_i]
  487.            self.contents.font.color = Style::Color[$1.to_i]
  488.            self.contents.font.size = Style::Size[$1.to_i]
  489.            next
  490.          end
  491.          if c == "\053"
  492.            @now_text.sub!(/\[([0-9]+)\]/, "")
  493.            self.contents.font.size = $1.to_i
  494.            next
  495.          end
  496.          if c == "\n"
  497.            if @lines >= $game_temp.choice_start
  498.              @cursor_width = [@cursor_width, @max_x - @face_indent].max
  499.            end
  500.            @lines += 1
  501.            @y += 1
  502.            @x = 0 + @indent + @face_indent
  503.            if @lines >= $game_temp.choice_start
  504.              @x = 8 + @indent + @face_indent
  505.            end
  506.            c = ""
  507.          end
  508.          if c != ""
  509.            # 文字描画
  510.            @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  511.            if $game_system.soundname_on_speak != "" then
  512.            Audio.se_play($game_system.soundname_on_speak)
  513.            end
  514.          end
  515.          if Input.press?(Input::B)
  516.            text_not_skip = false
  517.          end
  518.        else
  519.          text_not_skip = true
  520.          break
  521.        end
  522.        # 終了判定
  523.        if text_not_skip
  524.          break
  525.        end
  526.      end
  527.      @write_wait += @write_speed
  528.      return
  529.    end
  530.    if @input_number_window != nil
  531.      @input_number_window.update
  532.      # 決定
  533.      if Input.trigger?(Input::C)
  534.        $game_system.se_play($data_system.decision_se)
  535.        $game_variables[$game_temp.num_input_variable_id] =
  536.        @input_number_window.number
  537.        $game_map.need_refresh = true
  538.        @input_number_window.dispose
  539.        @input_number_window = nil
  540.        terminate_message
  541.      end
  542.      return
  543.    end
  544.    if @contents_showing
  545.      if $game_temp.choice_max == 0
  546.        self.pause = true
  547.      end
  548.      # 取消
  549.      if Input.trigger?(Input::B)
  550.        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  551.          $game_system.se_play($data_system.cancel_se)
  552.          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  553.          terminate_message
  554.        end
  555.      end
  556.      # 決定
  557.      if Input.trigger?(Input::C)
  558.        if $game_temp.choice_max > 0
  559.          $game_system.se_play($data_system.decision_se)
  560.          $game_temp.choice_proc.call(self.index)
  561.        end
  562.        if @mid_stop
  563.          @mid_stop = false
  564.          return
  565.        else
  566.          terminate_message
  567.        end
  568.      end
  569.      return
  570.    end
  571.    if @fade_out == false and $game_temp.message_text != nil
  572.      @contents_showing = true
  573.      $game_temp.message_window_showing = true
  574.      refresh
  575.      Graphics.frame_reset
  576.      self.visible = true
  577.      self.contents_opacity = 0
  578.    if @input_number_window != nil
  579.      @input_number_window.contents_opacity = 0
  580.    end
  581.      @fade_in = true
  582.      return
  583.    end
  584.    if self.visible
  585.      @fade_out = true
  586.      self.opacity -= 48
  587.      if self.opacity == 0
  588.        self.visible = false
  589.        @fade_out = false
  590.        $game_temp.message_window_showing = false
  591.      end
  592.      return
  593.    end
  594. end
  595. #--------------------------------------------------------------------------
  596. # ● 获得字符
  597. #--------------------------------------------------------------------------
  598. def get_character(parameter)
  599.    case parameter
  600.    when 0
  601.      return $game_player
  602.    else
  603.      events = $game_map.events
  604.      return events == nil ? nil : events[parameter]
  605.    end
  606. end
  607. #--------------------------------------------------------------------------
  608. # ● ウィンドウの位置と不透明度の設定
  609. #--------------------------------------------------------------------------
  610. def reset_window
  611.    # 判定
  612.    if @popchar >= 0
  613.      events = $game_map.events
  614.      if events != nil
  615.        character = get_character(@popchar)
  616.        x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  617.        y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  618.        self.x = x
  619.        self.y = y
  620.      end
  621.    elsif @popchar == -1
  622.      self.x = -4
  623.      self.y = -4
  624.      self.width = 648
  625.      self.height = 488
  626.    else
  627.      if $game_temp.in_battle
  628.        self.y = 16
  629.      else
  630.        case $game_system.message_position
  631.        when 0 # 上
  632.          self.y = 16
  633.        when 1 # 中
  634.          self.y = 160
  635.        when 2 # 下
  636.          self.y = 320
  637.        end
  638.        self.x = 45
  639.        if @face_file == nil
  640.          self.width = 550
  641.        else
  642.          self.width = 600
  643.          self.x -= 60
  644.        end
  645.        self.height = 240
  646.      end
  647.    end
  648.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  649.    if @face_file != nil
  650.      self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  651.    end
  652.    if @popchar == -1
  653.      self.opacity = 255
  654.      self.back_opacity = 0
  655.    elsif $game_system.message_frame == 0
  656.      self.opacity = 255
  657.      self.back_opacity = 100
  658.    else
  659.      self.opacity = 0
  660.      self.back_opacity = 100
  661.    end
  662. end
  663. #--------------------------------------------------------------------------
  664. # ● line_height
  665. #--------------------------------------------------------------------------
  666. # 返回値:行高
  667. #--------------------------------------------------------------------------
  668. def line_height
  669.    return 32
  670.    if self.contents.font.size >= 20 and self.contents.font.size <= 24
  671.      return 32
  672.    else
  673.      return self.contents.font.size * 15 / 10
  674.    end
  675. end
  676. #--------------------------------------------------------------------------
  677. # ● 透過文字描画
  678. #--------------------------------------------------------------------------
  679. # target :描画対象。Bitmapクラスを指定。
  680. # x :x座標
  681. # y :y座標
  682. # str  :描画文字列
  683. # opacity:透過率(0~255)
  684. # 返回値 :文字幅(@x増加値)。
  685. #--------------------------------------------------------------------------
  686. def opacity_draw_text(target, x, y, str,opacity)
  687.    height = target.font.size
  688.    width = target.text_size(str).width
  689.    opacity = [[opacity, 0].max, 255].min
  690.    if opacity == 255
  691.      target.draw_text(x, y, width, height, str)
  692.      return width
  693.    else
  694.      if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  695.        @opacity_text_buf.dispose
  696.        @opacity_text_buf = Bitmap.new(width, height)
  697.      else
  698.        @opacity_text_buf.clear
  699.      end
  700.      @opacity_text_buf.font.size = target.font.size
  701.      @opacity_text_buf.draw_text(0, 0, width, height, str)
  702.      target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  703.    return width
  704.    end
  705. end
  706. def ruby_draw_text(target, x, y, str,opacity)
  707.    sizeback = target.font.size
  708.    target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  709.    rubysize = [rubysize, 6].max
  710.   
  711.    opacity = [[opacity, 0].max, 255].min
  712.    split_s = str.split(/,/)
  713.   
  714.    split_s[0] == nil ? split_s[0] = "" : nil
  715.    split_s[1] == nil ? split_s[1] = "" : nil
  716.   
  717.    height = sizeback + rubysize
  718.    width = target.text_size(split_s[0]).width
  719.   
  720.    target.font.size = rubysize
  721.    ruby_width = target.text_size(split_s[1]).width
  722.    target.font.size = sizeback
  723.   
  724.    buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  725.   
  726.    width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  727.   
  728.    if opacity == 255
  729.      target.font.size = rubysize
  730.      target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  731.      target.font.size = sizeback
  732.      target.draw_text(x, y, width, target.font.size, split_s[0])
  733.      return width
  734.    else
  735.      if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  736.        @opacity_text_buf.dispose
  737.        @opacity_text_buf = Bitmap.new(buf_width, height)
  738.      else
  739.        @opacity_text_buf.clear
  740.      end
  741.      @opacity_text_buf.font.size = rubysize
  742.      @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  743.      @opacity_text_buf.font.size = sizeback
  744.      @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  745.      if sub_x >= 0
  746.        target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  747.      else
  748.        target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  749.      end
  750.      return width
  751.    end
  752. end
  753. #--------------------------------------------------------------------------
  754. # ● \V 变换
  755. #--------------------------------------------------------------------------
  756. def convart_value(option, index)
  757.    option == nil ? option = "" : nil
  758.    option.downcase!
  759.    case option
  760.      when "i"
  761.        unless $data_items[index].name == nil
  762.          r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  763.        end
  764.      when "w"
  765.        unless $data_weapons[index].name == nil
  766.          r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  767.        end
  768.      when "a"
  769.        unless $data_armors[index].name == nil
  770.          r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  771.        end
  772.      when "s"
  773.        unless $data_skills[index].name == nil
  774.          r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  775.        end
  776.      else
  777.      r = $game_variables[index]
  778.    end
  779.    r == nil ? r = "" : nil
  780.    return r
  781. end
  782. #--------------------------------------------------------------------------
  783. # ● 解放
  784. #--------------------------------------------------------------------------
  785. def dispose
  786.    terminate_message
  787.    if @gaiji_cache != nil
  788.      unless @gaiji_cache.disposed?
  789.        @gaiji_cache.dispose
  790.      end
  791.    end
  792.    unless @opacity_text_buf.disposed?
  793.      @opacity_text_buf.dispose
  794.    end
  795.    $game_temp.message_window_showing = false
  796.    if @input_number_window != nil
  797.      @input_number_window.dispose
  798.    end
  799.    super
  800. end
  801. #--------------------------------------------------------------------------
  802. # ● 矩形更新
  803. #--------------------------------------------------------------------------
  804. def update_cursor_rect
  805.    if @index >= 0
  806.      n = $game_temp.choice_start + @index
  807.      self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  808.    else
  809.      self.cursor_rect.empty
  810.    end
  811. end
  812. end
  813. #==============================================================================
  814. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  815. #==============================================================================
  816. class Window_Frame < Window_Base
  817. #--------------------------------------------------------------------------
  818. # ● オブジェクト初期化
  819. #--------------------------------------------------------------------------
  820. def initialize(x, y, width, height)
  821.    super(x, y, width, height)
  822.    self.contents = nil
  823.    self.back_opacity = 100
  824. end
  825. #--------------------------------------------------------------------------
  826. # ● 解放
  827. #--------------------------------------------------------------------------
  828. def dispose
  829.    super
  830.    end
  831. end
  832. #==============================================================================
  833. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  834. #==============================================================================
  835. class Air_Text < Window_Base
  836. #--------------------------------------------------------------------------
  837. # ● オブジェクト初期化
  838. #--------------------------------------------------------------------------
  839. def initialize(x, y, designate_text)
  840.    super(x-16, y-16, 32 + designate_text.size * 12, 56)
  841.    self.opacity = 0
  842.    self.back_opacity = 0
  843.    self.contents = Bitmap.new(self.width - 32, self.height - 32)
  844.    w = self.contents.width
  845.    h = self.contents.height
  846.    self.contents.draw_text(0, 0, w, h, designate_text)
  847. end
  848. #--------------------------------------------------------------------------
  849. # ● 解放
  850. #--------------------------------------------------------------------------
  851. def dispose
  852.    self.contents.clear
  853.    super
  854. end
  855. end



  856. #==============================================================================
  857. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  858. #==============================================================================
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 06:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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