Project1

标题: 如何让对话使用另一种skin? [打印本页]

作者: 斷·月    时间: 2008-9-21 20:57
提示: 作者被禁止或删除 内容自动屏蔽
作者: ONEWateR    时间: 2008-9-21 20:59
脚本 Window_Message

  def initialize
    super(80, 304, 480, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.visible = false
    self.z = 9998
    @fade_in = false
    @fade_out = false
    @contents_showing = false
    @cursor_width = 0
    self.active = false
    self.index = -1     
    self.windowskin = RPG::Cache.windowskin(窗口名称)
  end


作者: redant    时间: 2008-9-21 20:59
事件里 有 更改窗口外观
作者: ONEWateR    时间: 2008-9-21 21:36
  1. #==============================================================================
  2. # ■ Window_Message
  3. #------------------------------------------------------------------------------
  4. #  显示文章的信息窗口。
  5. #==============================================================================

  6. class Window_Message < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化状态
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(80, 304, 480, 160)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     self.visible = false
  14.     self.z = 9998
  15.     @fade_in = false
  16.     @fade_out = false
  17.     @contents_showing = false
  18.     @cursor_width = 0
  19.     self.active = false
  20.     self.index = -1
  21.   #--------------------------------------------------------------------------

  22.     self.windowskin = RPG::Cache.windowskin(窗口名称)
  23.    
  24.   #--------------------------------------------------------------------------

  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 释放
  28.   #--------------------------------------------------------------------------
  29.   def dispose
  30.     terminate_message
  31.     $game_temp.message_window_showing = false
  32.     if @input_number_window != nil
  33.       @input_number_window.dispose
  34.     end
  35.     super
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 处理信息结束
  39.   #--------------------------------------------------------------------------
  40.   def terminate_message
  41.     self.active = false
  42.     self.pause = false
  43.     self.index = -1
  44.     self.contents.clear
  45.     # 清除显示中标志
  46.     @contents_showing = false
  47.     # 呼叫信息调用
  48.     if $game_temp.message_proc != nil
  49.       $game_temp.message_proc.call
  50.     end
  51.     # 清除文章、选择项、输入数值的相关变量
  52.     $game_temp.message_text = nil
  53.     $game_temp.message_proc = nil
  54.     $game_temp.choice_start = 99
  55.     $game_temp.choice_max = 0
  56.     $game_temp.choice_cancel_type = 0
  57.     $game_temp.choice_proc = nil
  58.     $game_temp.num_input_start = 99
  59.     $game_temp.num_input_variable_id = 0
  60.     $game_temp.num_input_digits_max = 0
  61.     # 开放金钱窗口
  62.     if @gold_window != nil
  63.       @gold_window.dispose
  64.       @gold_window = nil
  65.     end
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 刷新
  69.   #--------------------------------------------------------------------------
  70.   def refresh
  71.     self.contents.clear
  72.     self.contents.font.color = normal_color
  73.     x = y = 0
  74.     @cursor_width = 0
  75.     # 到选择项的下一行字
  76.     if $game_temp.choice_start == 0
  77.       x = 8
  78.     end
  79.     # 有等待显示的文字的情况下
  80.     if $game_temp.message_text != nil
  81.       text = $game_temp.message_text
  82.       # 限制文字处理
  83.       begin
  84.         last_text = text.clone
  85.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  86.       end until text == last_text
  87.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  88.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  89.       end
  90.       # 为了方便、将 "\\\\" 变换为 "\000"
  91.       text.gsub!(/\\\\/) { "\000" }
  92.       # "\\C" 变为 "\001" に、"\\G" 变为 "\002"
  93.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  94.       text.gsub!(/\\[Gg]/) { "\002" }
  95.       # c 获取 1 个字 (如果不能取得文字就循环)
  96.       while ((c = text.slice!(/./m)) != nil)
  97.         # \\ 的情况下
  98.         if c == "\000"
  99.           # 还原为本来的文字
  100.           c = "\\"
  101.         end
  102.         # \C[n] 的情况下
  103.         if c == "\001"
  104.           # 更改文字色
  105.           text.sub!(/\[([0-9]+)\]/, "")
  106.           color = $1.to_i
  107.           if color >= 0 and color <= 7
  108.             self.contents.font.color = text_color(color)
  109.           end
  110.           # 下面的文字
  111.           next
  112.         end
  113.         # \G 的情况下
  114.         if c == "\002"
  115.           # 生成金钱窗口
  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.           # 下面的文字
  128.           next
  129.         end
  130.         # 另起一行文字的情况下
  131.         if c == "\n"
  132.           # 刷新选择项及光标的高
  133.           if y >= $game_temp.choice_start
  134.             @cursor_width = [@cursor_width, x].max
  135.           end
  136.           # y 加 1
  137.           y += 1
  138.           x = 0
  139.           # 移动到选择项的下一行
  140.           if y >= $game_temp.choice_start
  141.             x = 8
  142.           end
  143.           # 下面的文字
  144.           next
  145.         end
  146.         # 描绘文字
  147.         self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
  148.         # x 为要描绘文字的加法运算
  149.         x += self.contents.text_size(c).width
  150.       end
  151.     end
  152.     # 选择项的情况
  153.     if $game_temp.choice_max > 0
  154.       @item_max = $game_temp.choice_max
  155.       self.active = true
  156.       self.index = 0
  157.     end
  158.     # 输入数值的情况
  159.     if $game_temp.num_input_variable_id > 0
  160.       digits_max = $game_temp.num_input_digits_max
  161.       number = $game_variables[$game_temp.num_input_variable_id]
  162.       @input_number_window = Window_InputNumber.new(digits_max)
  163.       @input_number_window.number = number
  164.       @input_number_window.x = self.x + 8
  165.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # ● 设置窗口位置与不透明度
  170.   #--------------------------------------------------------------------------
  171.   def reset_window
  172.     if $game_temp.in_battle
  173.       self.y = 16
  174.     else
  175.       case $game_system.message_position
  176.       when 0  # 上
  177.         self.y = 16
  178.       when 1  # 中
  179.         self.y = 160
  180.       when 2  # 下
  181.         self.y = 304
  182.       end
  183.     end
  184.     if $game_system.message_frame == 0
  185.       self.opacity = 255
  186.     else
  187.       self.opacity = 0
  188.     end
  189.     self.back_opacity = 160
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 刷新画面
  193.   #--------------------------------------------------------------------------
  194.   def update
  195.     super
  196.     # 渐变的情况下
  197.     if @fade_in
  198.       self.contents_opacity += 24
  199.       if @input_number_window != nil
  200.         @input_number_window.contents_opacity += 24
  201.       end
  202.       if self.contents_opacity == 255
  203.         @fade_in = false
  204.       end
  205.       return
  206.     end
  207.     # 输入数值的情况下
  208.     if @input_number_window != nil
  209.       @input_number_window.update
  210.       # 确定
  211.       if Input.trigger?(Input::C)
  212.         $game_system.se_play($data_system.decision_se)
  213.         $game_variables[$game_temp.num_input_variable_id] =
  214.           @input_number_window.number
  215.         $game_map.need_refresh = true
  216.         # 释放输入数值窗口
  217.         @input_number_window.dispose
  218.         @input_number_window = nil
  219.         terminate_message
  220.       end
  221.       return
  222.     end
  223.     # 显示信息中的情况下
  224.     if @contents_showing
  225.       # 如果不是在显示选择项中就显示暂停标志
  226.       if $game_temp.choice_max == 0
  227.         self.pause = true
  228.       end
  229.       # 取消
  230.       if Input.trigger?(Input::B)
  231.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  232.           $game_system.se_play($data_system.cancel_se)
  233.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  234.           terminate_message
  235.         end
  236.       end
  237.       # 确定
  238.       if Input.trigger?(Input::C)
  239.         if $game_temp.choice_max > 0
  240.           $game_system.se_play($data_system.decision_se)
  241.           $game_temp.choice_proc.call(self.index)
  242.         end
  243.         terminate_message
  244.       end
  245.       return
  246.     end
  247.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  248.     if @fade_out == false and $game_temp.message_text != nil
  249.       @contents_showing = true
  250.       $game_temp.message_window_showing = true
  251.       reset_window
  252.       refresh
  253.       Graphics.frame_reset
  254.       self.visible = true
  255.       self.contents_opacity = 0
  256.       if @input_number_window != nil
  257.         @input_number_window.contents_opacity = 0
  258.       end
  259.       @fade_in = true
  260.       return
  261.     end
  262.     # 没有可以显示的信息、但是窗口为可见的情况下
  263.     if self.visible
  264.       @fade_out = true
  265.       self.opacity -= 48
  266.       if self.opacity == 0
  267.         self.visible = false
  268.         @fade_out = false
  269.         $game_temp.message_window_showing = false
  270.       end
  271.       return
  272.     end
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 刷新光标矩形
  276.   #--------------------------------------------------------------------------
  277.   def update_cursor_rect
  278.     if @index >= 0
  279.       n = $game_temp.choice_start + @index
  280.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  281.     else
  282.       self.cursor_rect.empty
  283.     end
  284.   end
  285. end
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1