赞 | 0 |
VIP | 13 |
好人卡 | 13 |
积分 | 1 |
经验 | 7273 |
最后登录 | 2014-2-17 |
在线时间 | 37 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 37 小时
- 注册时间
- 2012-7-30
- 帖子
- 147
|
本帖最后由 devilg 于 2012-8-17 09:48 编辑
我来个好玩的。。。勿黑,先自我挽尊
因为没素材所以直接扩大原cg,有大个素材以后再改掉sprite的更新处就行了- #==============================================================================
- # ■ Window_Message
- #------------------------------------------------------------------------------
- # 显示文章的信息窗口。
- #==============================================================================
- class Window_Message < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 常量
- #--------------------------------------------------------------------------
- MAX_LINE = 4 # 最大行数
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, SHIT::SCREEN[1]-128, SHIT::SCREEN[0], 128)
- self.z = 200
- self.active = false
- self.index = -1
- self.openness = 0
- @opening = false # 窗口正在打开标志
- @closing = false # 窗口正在关闭标志
- @text = nil # 尚未显示文章
- @contents_x = 0 # 描绘下一字的 X 座标
- @contents_y = 0 # 描绘下一字的 Y 座标
- @line_count = 0 # 以描绘行数
- @wait_count = 0 # 等待祯数
- @background = 0 # 背景类型
- @position = 2 # 显示位置
- @show_fast = false # 瞬间表示文章标志
- @line_show_fast = false # 行快速显示文章标志
- @pause_skip = false # 不等待输入标志
- @sprite=Sprite.new
- create_gold_window
- create_number_input_window
- create_back_sprite
- end
- #--------------------------------------------------------------------------
- # ● 释放窗口
- #--------------------------------------------------------------------------
- def dispose
- super
- dispose_gold_window
- dispose_number_input_window
- dispose_back_sprite
- @sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_gold_window
- update_number_input_window
- update_back_sprite
- update_show_fast
- unless @opening or @closing # 窗口非正在打开或正在关闭中
- if @wait_count > 0 # 文间等待
- @wait_count -= 1
- elsif self.pause # 等待输入的情况下
- input_pause
- elsif self.active # 输入选择的情况下
- input_choice
- elsif @number_input_window.visible # 输入数值的情况下
- input_number
- elsif @text != nil # 有等待显示的文字的情况下
- update_message # 更新文章
- elsif continue? # 继续的情况下
- start_message # 开始文章
- open # 打开窗口
- $game_message.visible = true
- else # 否则
- close # 关闭窗口
- $game_message.visible = @closing
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成金钱窗口
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new(384, 0)
- @gold_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成数值输入窗口
- #--------------------------------------------------------------------------
- def create_number_input_window
- @number_input_window = Window_NumberInput.new
- @number_input_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 生成背景活动块
- #--------------------------------------------------------------------------
- def create_back_sprite
- @back_sprite = Sprite.new
- @back_sprite.bitmap = Cache.system("MessageBack")
- @back_sprite.visible = (@background == 1)
- @back_sprite.z = 190
- end
- #--------------------------------------------------------------------------
- # ● 释放金钱窗口
- #--------------------------------------------------------------------------
- def dispose_gold_window
- @gold_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 释放数值输入窗口
- #--------------------------------------------------------------------------
- def dispose_number_input_window
- @number_input_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 释放背景活动块
- #--------------------------------------------------------------------------
- def dispose_back_sprite
- @back_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新金钱窗口
- #--------------------------------------------------------------------------
- def update_gold_window
- @gold_window.update
- end
- #--------------------------------------------------------------------------
- # ● 更新数值输入窗口
- #--------------------------------------------------------------------------
- def update_number_input_window
- @number_input_window.update
- end
- #--------------------------------------------------------------------------
- # ● 更新背景活动块
- #--------------------------------------------------------------------------
- def update_back_sprite
- @back_sprite.visible = (@background == 1)
- @back_sprite.y = y - 16
- @back_sprite.opacity = openness
- @back_sprite.update
- end
- #--------------------------------------------------------------------------
- # ● 更新快速显示文章标志
- #--------------------------------------------------------------------------
- def update_show_fast
- if self.pause or self.openness < 255
- @show_fast = false
- elsif Input.trigger?(Input::C) and @wait_count < 2
- @show_fast = true
- elsif not Input.press?(Input::C)
- @show_fast = false
- end
- if @show_fast and @wait_count > 0
- @wait_count -= 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 判断下面的文章是否接着显示
- #--------------------------------------------------------------------------
- def continue?
- return true if $game_message.num_input_variable_id > 0
- return false if $game_message.texts.empty?
- if self.openness > 0 and not $game_temp.in_battle
- return false if @background != $game_message.background
- return false if @position != $game_message.position
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 开始显示文章
- #--------------------------------------------------------------------------
- def start_message
- @text = ""
- for i in 0...$game_message.texts.size
- @text += " " if i >= $game_message.choice_start
- @text += $game_message.texts[i].clone + "\x00"
- end
- @item_max = $game_message.choice_max
- convert_special_characters
- reset_window
- new_page
- end
- #--------------------------------------------------------------------------
- # ● 新页处理
- #--------------------------------------------------------------------------
- def new_page
- contents.clear
- @sprite.bitmap.clear if @sprite.bitmap != nil
- if $game_message.face_name.empty?
- else
- name = $game_message.face_name
- index = $game_message.face_index
- b = Cache.face(name)
- a = Bitmap.new(768,384)
- a.stretch_blt(a.rect,b, b.rect)
- b.dispose
- rect = Rect.new(0, 0, 0, 0)
- rect.x = index % 4 * 192
- rect.y = index / 4 * 192
- rect.width = 192
- rect.height = 192
- @sprite.bitmap=Bitmap.new(192,192)
- @sprite.x = self.x
- @sprite.y = self.y-192
- @sprite.bitmap.blt(0, 0, a, rect)
- a.dispose
- #draw_face(name, index, 0, 0)
-
- # @contents_x = 112
- end
- @contents_x = 0
- @contents_y = 0
- @line_count = 0
- @show_fast = false
- @line_show_fast = false
- @pause_skip = false
- contents.font.color = text_color(0)
- end
- #--------------------------------------------------------------------------
- # ● 新行处理
- #--------------------------------------------------------------------------
- def new_line
- #~ if $game_message.face_name.empty?
- #~ @contents_x = 0
- #~ else
- #~ @contents_x = 112
- #~ end
- @contents_x = 0
- @contents_y += WLH
- @line_count += 1
- @line_show_fast = false
- end
- #--------------------------------------------------------------------------
- # ● 转换特殊符号
- #--------------------------------------------------------------------------
- def convert_special_characters
- @text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
- #NOT FINISHED
- @text.gsub!(/\\Q\[([0-9]+)\]/i) { Game_Quest.new($game_variables[$1.to_i]).name }
- #modefied actor name
- @text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }
- @text.gsub!(/\\NN\[([0-9]+)\]/i) { $game_actors[$game_party.actors[$1.to_i-1]].name}
- @text.gsub!(/\\E/) { "\x00" }
- @text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
- @text.gsub!(/\\M\[([0-9]+)\]/i) { $data_mapinfos[$1.to_i].name}
- #
- @text.gsub!(/\\G/) { "\x02" }
- @text.gsub!(/\\NPC/) { $game_temp.message2u }
- @text.gsub!(/\\\./) { "\x03" }
- @text.gsub!(/\\\|/) { "\x04" }
- @text.gsub!(/\\!/) { "\x05" }
- @text.gsub!(/\\>/) { "\x06" }
- @text.gsub!(/\\</) { "\x07" }
- @text.gsub!(/\\\^/) { "\x08" }
- @text.gsub!(/\\\\/) { "\\" }
- end
- #--------------------------------------------------------------------------
- # ● 设定窗口背景和位置
- #--------------------------------------------------------------------------
- def reset_window
- @background = $game_message.background
- @position = $game_message.position
- if @background == 0 # 一般窗口
- self.opacity = 255
- else # 背景变暗并透明化
- self.opacity = 0
- end
- case @position
- when 0 # 上
- self.y = 0
- @gold_window.y = 360
- when 1 # 中
- self.y = SHIT::SCREEN[1]/2-64
- @gold_window.y = 0
- when 2 # 下
- self.y = SHIT::SCREEN[1]-128
- @gold_window.y = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 结束文章显示
- #--------------------------------------------------------------------------
- def terminate_message
- self.active = false
- self.pause = false
- self.index = -1
- @gold_window.close
- @number_input_window.active = false
- @number_input_window.visible = false
- $game_message.main_proc.call if $game_message.main_proc != nil
- $game_message.clear
- @sprite.bitmap.clear if @sprite.bitmap != nil
- end
- #--------------------------------------------------------------------------
- # ● 更新文章显示
- #--------------------------------------------------------------------------
- def update_message
- loop do
- c = @text.slice!(/./m) # 获取一个文字
- case c
- when nil # 无法获取文字时
- finish_message # 结束文章更新
- break
- when "\x00" # 新行
- new_line
- if @line_count >= MAX_LINE # 当行数已至最大行数
- unless @text.empty? # 并还有有等待显示的文字时
- self.pause = true # 等待输入
- break
- end
- end
- when "\x01" # \C[n](文字变色)
- @text.sub!(/\[([0-9]+)\]/, "")
- contents.font.color = text_color($1.to_i)
- next
- when "\x02" # \G (显示金钱)
- @gold_window.refresh
- @gold_window.open
- when "\x03" # \. (等待四分之一秒)
- @wait_count = 15
- break
- when "\x04" # \| (等待一秒)
- @wait_count = 60
- break
- when "\x05" # \! (等待输入)
- self.pause = true
- break
- when "\x06" # \> (瞬间表示on)
- @line_show_fast = true
- when "\x07" # \< (瞬间表示off)
- @line_show_fast = false
- when "\x08" # \^ (不等待输入)
- @pause_skip = true
- else # 一般文字
- contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
- c_width = contents.text_size(c).width
- @contents_x += c_width
- end
- break unless @show_fast or @line_show_fast
- end
- end
- #--------------------------------------------------------------------------
- # ● 结束文章更新
- #--------------------------------------------------------------------------
- def finish_message
- if $game_message.choice_max > 0
- start_choice
- elsif $game_message.num_input_variable_id > 0
- start_number_input
- elsif @pause_skip
- terminate_message
- else
- self.pause = true
- end
- @wait_count = 10
- @text = nil
- end
- #--------------------------------------------------------------------------
- # ● 开始选择项
- #--------------------------------------------------------------------------
- def start_choice
- self.active = true
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 开始数值输入
- #--------------------------------------------------------------------------
- def start_number_input
- digits_max = $game_message.num_input_digits_max
- number = $game_variables[$game_message.num_input_variable_id]
- @number_input_window.digits_max = digits_max
- @number_input_window.number = number
- if $game_message.face_name.empty?
- @number_input_window.x = x
- else
- @number_input_window.x = x + 112
- end
- @number_input_window.y = y + @contents_y
- @number_input_window.active = true
- @number_input_window.visible = true
- @number_input_window.update
- end
- #--------------------------------------------------------------------------
- # ● 刷新光标
- #--------------------------------------------------------------------------
- def update_cursor
- if @index >= 0
- x = $game_message.face_name.empty? ? 0 : 112
- y = ($game_message.choice_start + @index) * WLH
- self.cursor_rect.set(x, y, contents.width - x, WLH)
- else
- self.cursor_rect.empty
- end
- end
- #--------------------------------------------------------------------------
- # ● 等待输入处理
- #--------------------------------------------------------------------------
- def input_pause
- if Input.trigger?(Input::B) or Input.trigger?(Input::C)
- self.pause = false
- if @text != nil and not @text.empty?
- new_page if @line_count >= MAX_LINE
- else
- terminate_message
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 选择项处理
- #--------------------------------------------------------------------------
- def input_choice
- if Input.trigger?(Input::B)
- if $game_message.choice_cancel_type > 0
- Sound.play_cancel
- $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
- terminate_message
- end
- elsif Input.trigger?(Input::C)
- Sound.play_decision
- $game_message.choice_proc.call(self.index)
- terminate_message
- end
- end
- #--------------------------------------------------------------------------
- # ● 名称输入处理
- #--------------------------------------------------------------------------
- def input_number
- if Input.trigger?(Input::C)
- Sound.play_decision
- $game_variables[$game_message.num_input_variable_id] =
- @number_input_window.number
- $game_map.need_refresh = true
- terminate_message
- end
- end
- end
复制代码 |
-
1.png
(137.7 KB, 下载次数: 17)
评分
-
查看全部评分
|