Project1
标题:
「立ち絵表示」和「吹きだしウィンドウ」同时使用
[打印本页]
作者:
wshzya
时间:
2012-12-26 21:08
标题:
「立ち絵表示」和「吹きだしウィンドウ」同时使用
本帖最后由 wshzya 于 2013-3-17 12:54 编辑
RT,要同时使用「吹きだしウィンドウ」(对话泡泡)脚本和「空メッセージでウィンドウを開かない」「立ち絵表示」时,怎么呼出立绘图片呢?还要新设一个文件夹?
「吹きだしウィンドウ」
=begin
吹きだしウィンドウVXAce
2011.12.25 tamura改造
2012年02月28日 改訂
※このスクリプトは、ちいさな本屋様(http://xrxs.at-ninja.jp/)
が製作されたものをtamuraがACE用に改造した物です。
原版:
▽▽▽ XRXSv2. メッセージ表示フルグレードアップVX ▽▽▽
publish 2010/ 3/ 2
update - 11/ 1/10a
※※警告※※
「立ち絵機能」ON時、立ち絵(指定圖片)會表示、窗口位置
右左変更時、圖片Y座標不正常。
原因調査中。若不想立ち絵不表示時、亊件指今中的「注釈」填入
「立ち絵表示 off」的記述、可把立ち絵機能関閉。
●機能一覧
?亊件指今「脚本」中、$win_x $win_y値、
($win_x 、$win_y)指定表示窗口位置。画面左上(0,0)。
?按下鍵盤Q、
窗口消失。Q決定、取消鍵元戻。
?文章設定、可用以下文字操作。
? \name[] : 在對話窗口上出現小窗口中,出現[]内的文字。
\h[-1] : 在玩者上面出現對話窗口。
\h[0] : 在正發生的事件出現對話窗口。
\h[1] : 在[]内的ID號的事件出現對話窗口。
H可用大文字。
通常的窗口、但對話吹出位置不同、
\t[-2] : 窗口上下に表示時、X座標MINAS_TWE_X_POS固定。
$win_x 左右表示時、Y座標窗口中心下固定。
\t[-3] : 窗口上下に表示時、X座標MINAS_THREE_X_POS固定。
$win_x 左右表示時、Y座標窗口中心下固定。
\t[-1] : 玩者向對話吹出位置表示。
\t[0] : 現在執行的事件對話吹出位置表示。
\t[1] : []内的ID事件對話吹出位置表示。
\O[128] : 文字透明。[]内是alpha値、0透明、255通常。
\D : 文字影有
\hold : 最後的文章限定。信息結束,不關上窗口。
其他的信息被表示時消失。
被鎖定的窗,不能用Q按鈕消去。
●その他
?ACEに標準装備されている機能は通常通り使用できます。
?A1殿(http://a1tktk.web.fc2.com/)の立ち絵スクリプトに対応しています。
このスクリプトの上に「RGSS3用A1共通処理」
このスクリプトの下に「空メッセージでウィンドウを開かない」「立ち絵表示」を
配置して下さい。
残念ながら、「ネームウィンドウ」は使えません。上記\nameをお使いください。
※立ち絵を表示しない時は、注釈で「立ち絵表示 off」とした方が無難です。
?イベントの下から話しかけたら上へポップ、上から話しかけたら下へポップするという
機能を追加。カスタマイズポイントで POP_DIRECTION = ture と変更のこと。
●廃止機能
?\Iがすでに使われているので、イタリック文字変換を廃止。
?スピード変更、改行、最後に入手したアイテムの表示を、ACE化にともない廃止。
【改訂履歴】
2012.01.10 ?ウィンドウを消したまま次のウィンドウを自動で表示すると、
ネームウィンドウが表示されるのを修正。
2012.01.11 ?ネームウィンドウが出しっぱなしになるのを修正。
2012.01.12 ?メニューを出してから決定ボタンを押すとネームウィンドウがでる不具合の修正。
2012.02.01 ?ネームウィンドウのオープン&クローズのタイミングを変更。
?hold機能を追加。
2012.02.10 ?キャラポップした時、一行ずつしか表示されない不具合を修正。
2012.02.14 ?アイテム名などの文字数が正常に取得できなかったのを修正。
2012.02.21 ?話しかけられた方向によって、ポップ方向を変えられるようにした。
2012.02.25 ?すべてのシーン遷移の際はテールを破棄(イベント中でショップ起動など)
2012.02.28 ?エスケープ文字の処理が上手くいかない問題について暫定対策。
=end
#==============================================================================
# カスタマイズポイント
#==============================================================================
#=begin
class Window_Message < Window_Base
#
# 基本行数
#
MAX_LINE = 4
#
# \p[] - キャラポップの高さ
#
CHARPOP_HEIGHT = 40
#
# \name[] - 名前枠 X,Y座標
#
NAME_WINDOW_OFFSET_X = 0
NAME_WINDOW_OFFSET_Y = -24
#
#
MINAS_TWE_X_POS = 100 # $t[-2]のときの、テールのX座標。
MINAS_THREE_X_POS = 444 # $t[-3]のときの、テールのX座標。
POP_DIRECTION = false #イベントの方向を考慮。
end
#==============================================================================
# 参照機能
#==============================================================================
class Game_Temp
attr_accessor :last_gain_material
attr_accessor :last_gain_holder
end
#==============================================================================
# フルグレードアップベース - 制御文字?基本機能
#==============================================================================
class Window_Message < Window_Base
attr_accessor :tail
#--------------------------------------------------------------------------
# ● 特殊文字の変換 + 準備
# 変換?消去してもいい部分を処理、フラグのセット。
#--------------------------------------------------------------------------
alias xrxsv2_convert_escape_characters convert_escape_characters
def convert_escape_characters(text)
#@textsが使いずらいので、ここで別変数に保管。
@all_texts = []
str = text.gsub(/\\/) { "\e" }
@all_texts = str.split("\n")
# 初期化
contents.font.size = Font.default_size
contents.font.bold = Font.default_italic
contents.font.italic = Font.default_bold
contents.font.shadow = Font.default_shadow
@type_wait = 0
@line_widths = []
@line_aligns = []
self.pop_character = nil
# ウィンドウ保持指定\holdがあるか?
@window_hold = (text.gsub!(/\\hold/) { "" } != nil)
# \info
@info_mode = (text.gsub!(/\\info/) { "" } != nil)
# 改行削除指定\_があるか?
if (/\\_(.*?)\x00/.match(@text)) != nil
$game_message.choice_start -= 1
text.gsub!(/\\_(.*?)\x00/) { $1.to_s }
end
# \name 判定
if text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
name = $1
bitmap = @name_sprite.bitmap
w = [bitmap.text_size(name).width, 1].max
bitmap.dispose
@name_sprite.bitmap = Bitmap.new(w, 32)
bitmap = @name_sprite.bitmap
bitmap.draw_text(0, 0, bitmap.width, bitmap.height, name)
@name_window.width = w + 16
@name_window.create_contents
@name_window.open if @name_window.openness == 0
if self.visible #名前だけ表示されるのを防止。
@name_window.visible = true
@name_sprite.visible = true
else
@name_window.visible = false
@name_sprite.visible = false
end
else
@name_window.visible = false
@name_sprite.visible = false
@name_sprite.bitmap.dispose
@name_sprite.bitmap = Bitmap.new(32,32)
end
$name = $1 #あれこれで使うので、ネームウィンドウに表示予定の名前を取得。
# キャラボップモード
if text.gsub!(/\\[Hh]\[-1\]/) { "" }
self.pop_character = -1
elsif text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "" }
self.pop_character = $1.to_i
elsif text.gsub!(/\\[Hh]/) { "" }
self.pop_character = 0
#テール表示モード
elsif text.gsub!(/\\[Tt]\[-1\]/) { "" }
self.tail_character = -1
elsif text.gsub!(/\\[Tt]\[-2\]/) { "" }
self.tail_character = -2
elsif text.gsub!(/\\[Tt]\[-3\]/) { "" }
self.tail_character = -3
elsif text.gsub!(/\\[Tt]\[([0-9]+)\]/) { "" }
self.tail_character = $1.to_i
elsif text.gsub!(/\\[Tt]/) { "" }
self.tail_character = 0
else
self.pop_character = nil
end
# 制御文字処理
text = xrxsv2_convert_escape_characters(text)
text.gsub!(/\\[Ss]\[([0-9]+)\]/i) { "\eS[#{$1}]" }
text.gsub!(/\\[Oo]\[([0-9]+)\]/i) { "\eO[#{$1}]" }
text.gsub!(/\\last_holder/i) { "\e18" }
text.gsub!(/\\last_material/i) { "\e19" }
text.gsub!(/\\B/) { "\eB" }
text.gsub!(/\\D/) { "\eD" }
#text.gsub!(/\\n/) { "\n" }
#
# ライン情報の取得
rxs = ["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08",
/\[([0-9]+)\]/,
"\x11","\x12","\x13","\x14", "\x15", "\x16", "\x17", "\x18","\x19"]
lines = text.split("\x00")
@lines_max = lines.size
for i in 0...@lines_max
line = lines[i]
for rx in rxs
line.gsub!(rx) {""}
end
@line_aligns[i] =
line.sub!(/\\center/) {""} ? CENTER :
line.sub!(/\\right/) {""} ? RIGHT :
AUTO
# 行の横幅の取得と設定
cx = text_width_no_escape(line,text) #test
#cx = contents.text_size(line,text).width
@line_widths[i] = cx
end
# 位置揃え制御文字の削除
text.gsub!(/\\center/) {""}
text.gsub!(/\\right/) {""}
# キャラポップ時のウィンドウリサイズ
reszie_window_for_pop
del_tail # if @tail != nil
# $mes_id が空のときと戦闘中はふきだしを表示しない
if defined?($game_system.show_stand_picture) #立ち絵に対応。
$mes_id = -1 if $game_system.show_stand_picture == true
end
if $mes_id != nil and not $game_party.in_battle
# ふきだしのテールを描画
skin = "Window"
if @background == 0
#画像の準備
@tail = Sprite.new
@tail.visible = false
# 位置を取得
tale_pos = get_tale_pos
if $win_x != nil
if $win_x > 0
@tail.bitmap = Cache.system(skin + "-right")
@tail.x = tale_pos[0]
@tail.y = tale_pos[1]
@tail.z = self.z + 1
elsif $win_x < 0
@tail.bitmap = Cache.system(skin + "-left")
@tail.x = tale_pos[0]
@tail.y = tale_pos[1]
@tail.z = self.z + 1
else
create_tail_up_under
end
else
create_tail_up_under
end
# エクストラスプライトに登録
@extra_sprites = [] if @extra_sprites.nil?
@extra_sprites.push(@tail) if @tail != nil
# 更新
update_tail
end
end
open_and_wait #リサイズが終わった時点でウィンドウオープン。
return text
end
#--------------------------------------------------------------------------
# ● 文字の長さを取得する。エスケープ文字は含まない。
# line : 表示しようとしている全ての文字列。
# text : その列の文字。
#--------------------------------------------------------------------------
def text_width_no_escape(line , text_o)
add = 0
text = Marshal.load(Marshal.dump(text_o))
text.gsub!(/\ehold/) { "" }
text.gsub!(/\einfo/) { "" }
# 改行削除指定\_があるか?
if (/\\_(.*?)\x00/.match(@text)) != nil
$game_message.choice_start -= 1
text.gsub!(/\\_(.*?)\x00/) { "" }
end
# \name 判定
text.sub!(/\e[Nn]ame\[(.*?)\]/) { "" }
text.gsub!(/\e[Hh]\[-1\]/) { "" }
text.gsub!(/\e[Hh]\[([0-9]+)\]/) { "" }
text.gsub!(/\e[Hh]/) { "" }
text.gsub!(/\e[Tt]\[-1\]/) { "" }
text.gsub!(/\e[Tt]\[-2\]/) { "" }
text.gsub!(/\e[Tt]\[-3\]/) { "" }
text.gsub!(/\e[Tt]\[([0-9]+)\]/) { "" }
text.gsub!(/\e[Tt]/) { "" }
# 制御文字処理
text.gsub!(/\e[Ss]\[([0-9]+)\]/i) { "" }
text.gsub!(/\e[Oo]\[([0-9]+)\]/i) { "" }
text.gsub!(/\elast_holder/i) { "" }
text.gsub!(/\elast_material/i) { "" }
#text.gsub!(/\eV/) { "" } #変数に置き換える。
#text.gsub!(/\eN/) { "" } #名前へ置き換える。
#text.gsub!(/\eP/) { "" } #名前へ置き換える。
#text.gsub!(/\eG/) { "" } #金額へ置き換える。
#text.gsub!(/\eC/) { "" }
text.gsub!(/\eB/) { "" }
text.gsub!(/\eD/) { "" }
if text =~ /\eI/
loop do
if str = text.sub!(/\eI\[(\d+)\]/){ "" }
add += 24
else
break
end
end
end
#text.gsub!(/\\n/) { "\n" }
text.sub!(/\ecenter/) {""}
text.sub!(/\eright/) {""}
text.gsub!(/\ecenter/) {""}
text.gsub!(/\eright/) {""}
text = xrxsv2_convert_escape_characters(text)
basic_width = text_size(text).width + add
esc = text.scan(/\e(\S)/)
return ( basic_width - esc.size * (contents.font.size - 4) ) #\eの幅は20?
end
#--------------------------------------------------------------------------
# ● 最も長い列の長さを調べる。エスケープ文字は含まない。
#--------------------------------------------------------------------------
def max_width
text_size = []
for i in 0 ... @all_texts.size
text_size.push text_width_no_escape(@all_texts[i],@all_texts[i]) + 20
end
return text_size.max
end
#--------------------------------------------------------------------------
# ● 吹きだしテールが上か下の場合の画像を準備。
#--------------------------------------------------------------------------
def create_tail_up_under
skin = "Window"
tale_pos = get_tale_pos
case @position
when 0 # 上
@tail.bitmap = Cache.system(skin + "-top")
@tail.x = tale_pos[0]
@tail.y = tale_pos[1]
@tail.z = self.z + 1
when 1 # 中
@tail.dispose
@tail = nil
when 2 # 下
@tail.bitmap = Cache.system(skin + "-under")
@tail.x = tale_pos[0]
@tail.y = tale_pos[1]
@tail.z = self.z + 1
end
end
#--------------------------------------------------------------------------
# ● 全テキストの処理
#--------------------------------------------------------------------------
def process_all_text
#open_and_wait #リサイズがあるので、すぐにウィンドウをオープンしない。
text = convert_escape_characters($game_message.all_text)
pos = {}
new_page(text, pos)
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
#--------------------------------------------------------------------------
# ● メッセージの更新 *
#--------------------------------------------------------------------------
def update_message
@wait_count = @type_wait
loop do
c = @text.slice!(/./m)
case update_message_type(c)
when 1
break
when 2
next
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# 一文字の描画 (返り値 1:break, 2:next)
#--------------------------------------------------------------------------
#=begin
def process_escape_character(code, text, pos)
case code.upcase
when '$'
@gold_window.open
when '.'
wait(15)
when '|'
wait(60)
when '!'
input_pause
when '>'
@line_show_fast = true
when '<'
@line_show_fast = false
when '^'
@pause_skip = true
#when 'n' # 改行
# new_line
# max = MAX_LINE
# max = 14 if self.pop_character != nil
# if @line_count >= max # 行数が最大のとき
# unless @text.empty? # さらに続きがあるなら
# self.pause = true # 入力待ちを入れる
#return 1
# end
# end
#when 'S' # \S[n] (スピード変更)
# text.sub!(/\[([0-9]+)\]/, "")
# @type_wait = $1.to_i
# return 2
when 'O' # \O 文字を透明にする。
text.sub!(/\[([0-9]+)\]/, "")
contents.font.color.alpha = $1.to_i
#return 2
when 'D' #\D 文字に影をつける
contents.font.shadow ^= true
#when '18'
# name = ($game_temp.last_gain_holder.name rescue "")
# update_message_type_draw_at(name)
#when '19'
# item = ($game_temp.last_gain_material.item rescue nil)
# draw_item_name(item, @contents_x, @contents_y)
# @contents_x += 196
else
super
end
end
#=end
#--------------------------------------------------------------------------
# ● 改ページ処理
#--------------------------------------------------------------------------
alias xrxsv2_new_page new_page
def new_page(text, pos)
xrxsv2_new_page(text, pos)
update_charpop_window
end
#--------------------------------------------------------------------------
# ● 改行位置の取得
#--------------------------------------------------------------------------
#def new_line_x
# $game_message.face_name.empty? ? 0 : 112
#end
#--------------------------------------------------------------------------
# ● 改行処理
#--------------------------------------------------------------------------
alias xrxsv2_new_line_x new_line_x
def new_line
xrxsv2_new_line
set_align
end
#--------------------------------------------------------------------------
# 位置揃え
#--------------------------------------------------------------------------
def set_align
w = @line_widths[@line_count].to_i
a = @line_aligns[@line_count]
case a
when CENTER
@contents_x = @contents_x + ((contents.width - @contents_x) - w) / 2
when RIGHT
@contents_x = contents.width - w
end
end
#--------------------------------------------------------------------------
# ● ファイバーのメイン処理 ☆再定義
#--------------------------------------------------------------------------
def fiber_main
$game_message.visible = true
update_background
update_placement
loop do
process_all_text if $game_message.has_text?
process_input
$game_message.clear
@gold_window.close
process_hold #ホールドウィンドウの処理。
Fiber.yield
break unless text_continue?
end
close_and_wait
$game_message.visible = false
@fiber = nil
end
#--------------------------------------------------------------------------
# 定数
#--------------------------------------------------------------------------
AUTO = 0
LEFT = 1
CENTER = 2
RIGHT = 3
end
#==============================================================================
# アクティブイベント取得
#==============================================================================
class Game_Interpreter
attr_reader :event_id
end
#==============================================================================
# 各種機能の追加 - キャラポップ/ネーム/ホールド
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ● カーソルの更新 *
#--------------------------------------------------------------------------
def update_cursor
if @index >= 0
x = ($game_message.face_name.empty? ? 0 : 112)
y = ($game_message.choice_start + @index) * WLH - 1
w = contents.width - x
if self.pop_character != nil
x += 28
w -= 20
end
self.cursor_rect.set(x, y, w, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# キャラクターの取得
# parameter : パラメータ
#--------------------------------------------------------------------------
def get_character(parameter)
# パラメータで分岐
case parameter
when -1 # プレイヤー
return $game_player
when 0 # 現在アクティブなイベント
id = $game_map.interpreter.event_id
events = $game_map.events
return events == nil ? nil : events[id]
else # 特定のイベント
events = $game_map.events
return events == nil ? nil : events[parameter]
end
end
#--------------------------------------------------------------------------
# (メッセージ終了時)ホールドの処理
#--------------------------------------------------------------------------
def process_hold
if @window_hold
@held_windows.push(Window_Copy.new(self))
@held_windows.push(Window_Copy.new(@name_window))
@held_windows.push(Sprite_Copy.new(@name_sprite))
@held_windows.push(Sprite_Copy.new(@back_sprite))
for sprite in @extra_sprites
next if sprite.disposed?
@held_windows.push(Sprite_Copy.new(sprite))
end
@extra_sprites.clear
self.openness = 0
#@name_window.openness = 0
@back_sprite.visible = false
else
@held_windows.each {|object| object.dispose}
@held_windows.clear
end
#@name_window.close
#@name_sprite.visible = false
end
#--------------------------------------------------------------------------
# キャラポップ位置の設定と取得
#--------------------------------------------------------------------------
def pop_character=(character_id)
@pop_character = character_id
end
def pop_character
return @pop_character
end
#--------------------------------------------------------------------------
# キャラポップ時のウィンドウリサイズ
#--------------------------------------------------------------------------
def reszie_window_for_pop
#キャラポップ
if self.pop_character != nil
max_x = @line_widths.max.to_i
n = max_x + 32
n += $game_message.face_name.empty? ? 0 : 122
m = $game_message.face_name.empty? ? 0 : 96
w = @name_sprite.bitmap.width
#self.width = [n, w].max
self.width = max_width
#self.height = [@lines_max * line_height, m].max + 32
self.height = [@all_texts.size * line_height, m].max + 32
create_contents
update_charpop_window
elsif @info_mode
@line_aligns[0] = CENTER
self.x = - 8
self.width = Graphics.width + 16
self.height = 56
create_contents
else
self.x = 0
self.width = Graphics.width
self.height = MAX_LINE * line_height + 32
update_placement #位置情報修正。
create_contents
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの作成
#--------------------------------------------------------------------------
alias xrxsv2_create_back_sprite create_back_sprite
def create_back_sprite
xrxsv2_create_back_sprite
@back_sprite.zoom_x = 1.0 * Graphics.width / @back_sprite.bitmap.width
@name_window = Window_Base.new(0,0,112,36)
@name_window.visible = false
@name_sprite = Sprite.new
@name_sprite.bitmap = Bitmap.new(32,32)
@name_sprite.visible = false
self.x = self.x
self.y = self.y
self.z = self.z
@held_windows = []
@extra_sprites = []
end
#--------------------------------------------------------------------------
# ● 背景スプライトの解放
#--------------------------------------------------------------------------
alias xrxsv2_dispose_back_sprite dispose_back_sprite
def dispose_back_sprite
xrxsv2_dispose_back_sprite
@name_window.dispose if @name_window != nil #メニュー画面を出そうとするとエラー?
@name_sprite.dispose if @name_sprite != nil
for window in @held_windows
window.dispose
end
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
alias xrxsv2_update_back_sprite update_back_sprite
def update_back_sprite
@name_window.update
xrxsv2_update_back_sprite
update_charpop_window
end
#--------------------------------------------------------------------------
# ウィンドウの位置と不透明度の設定 (キャラポップ)
#--------------------------------------------------------------------------
def update_charpop_window
if self.pop_character
character = get_character(self.pop_character)
return if character == nil
# [X座標]
n = self.width / 2
n = [n, @name_skin.width + 16].max if @current_name != nil
w = @name_sprite.bitmap.width
x = character.screen_x - [[n, w].max, self.width - 32].min
# [Y座標]
if self.pop_character == 0 and POP_DIRECTION #イベントの方向を考慮。
if character.direction == 2 #下向き
@position = 0 #上にポップ
elsif character.direction == 8 #上向き
@position = 2 #下にポップ
end
end
case @position
when 0
y = character.screen_y - CHARPOP_HEIGHT - self.height
else
y = character.screen_y + 16
end
x_max = Graphics.width - 4 - self.width
x_min = 4
y_max = Graphics.height - self.height
y_min = 4
self.x = [[x, x_max].min, x_min].max
self.y = [[y, y_max].min, y_min].max
end
end
#--------------------------------------------------------------------------
# 位置の連動
#--------------------------------------------------------------------------
def x=(n)
super
if @name_window
@name_window.x = n + NAME_WINDOW_OFFSET_X
@name_sprite.x = n + NAME_WINDOW_OFFSET_X + 8
end
end
def y=(n)
super
if @name_window
@name_window.y = n + NAME_WINDOW_OFFSET_Y
@name_sprite.y = n + NAME_WINDOW_OFFSET_Y + 2
end
end
def z=(n)
super
if @name_window
@name_window.z = n + 11#1 テールの上に表示されるので、Zを水増しする。
@name_sprite.z = n + 12#2
end
end
#--------------------------------------------------------------------------
# ● ファイバーのメイン処理
#--------------------------------------------------------------------------
def fiber_main_namewin
fiber_main_namewin_default
@name_window.openness = 0
@name_sprite.bitmap.clear
$name = ""
end
alias :fiber_main_namewin_default :fiber_main
alias :fiber_main :fiber_main_namewin
end
#==============================================================================
# 伸縮対応
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定 [再定義]
#--------------------------------------------------------------------------
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 = (Graphics.height - self.height) / 2
@gold_window.y = 0
when 2 # 下
self.y = Graphics.height - self.height
@gold_window.y = 0
end
end
end
#==============================================================================
# □ Window_Copy
#------------------------------------------------------------------------------
# 指定のウィンドウのコピーを作成します。
#==============================================================================
class Window_Copy < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(window)
super(window.x, window.y, window.width, window.height)
self.contents = window.contents.dup unless window.contents.nil?
self.opacity = window.opacity
self.back_opacity = window.back_opacity
self.z = window.z - 3
self.visible = window.visible
end
end
#==============================================================================
# □ Sprite_Copy
#------------------------------------------------------------------------------
# 指定のスプライトのコピーを作成します。
#==============================================================================
class Sprite_Copy < Sprite
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(sprite)
super()
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z - 3
self.ox = sprite.ox
self.oy = sprite.oy
self.zoom_x = sprite.zoom_x
self.visible = sprite.visible
end
end
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#■吹きだしテールの表示ルーチン。
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#==============================================================================
# +++ 「+ふきだし表示」VX +++
# by パラ犬 http://2d6.parasite.jp/
# ×
# row http://xms.rdy.jp/
#
# publish 2010/ 3/ 2
# update -
#
#------------------------------------------------------------------------------
# ほぼどんなメッセージウィンドウに対しても後付け可能な「ふきだし表示」です。
# また、テール部分のみの自動追尾機能を持ちます。
# ふきだし表示をするには、
# テール用画像「Window-top」「Window-under」を
# 「Graphics/System」フォルダにインポートしておく必要があります。
#==============================================================================
# ■ Window_Message
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ● メッセージの開始
#--------------------------------------------------------------------------
alias parashelf_update_all_windows update_all_windows
def update_all_windows
parashelf_update_all_windows
update_tail
end
#--------------------------------------------------------------------------
# クローズ [オーバーライド]
#--------------------------------------------------------------------------
def close
super
del_tail
@name_window.close if @name_window != nil #ネームウィンドウのクローズ動作。
end
#--------------------------------------------------------------------------
# ● 背景スプライトの更新
#--------------------------------------------------------------------------
alias parashelf_update_back_sprite update_back_sprite
def update_back_sprite
parashelf_update_back_sprite
update_tail
end
#--------------------------------------------------------------------------
# ○ フレーム更新 (ふきだしテールの更新)
#--------------------------------------------------------------------------
def update_tail
# ふきだしモードではイベントの動きに追従
if $mes_id != nil and @tail != nil
tale_pos = get_tale_pos
@tail.x = tale_pos[0]
@tail.y = tale_pos[1]
update_tail_bitmap
end
end
##--------------------------------------------------------------------------
# ○ ふきだしテールの画像を更新。
#--------------------------------------------------------------------------
def update_tail_bitmap
skin = "Window"
if $win_x != nil
if $win_x > 0
@tail.bitmap = Cache.system(skin + "-right")
elsif $win_x < 0
@tail.bitmap = Cache.system(skin + "-left")
else
case @position
when 0 # 上
@tail.bitmap = Cache.system(skin + "-top")
when 2 # 下
@tail.bitmap = Cache.system(skin + "-under")
end
end
else
case @position
when 0 # 上
@tail.bitmap = Cache.system(skin + "-top")
when 2 # 下
@tail.bitmap = Cache.system(skin + "-under")
end
end
# 可視状態
if self.visible == true
@tail.visible = self.openness == 255
else
@tail.visible = false
end
end
#--------------------------------------------------------------------------
# ○ テールの位置を計算
#--------------------------------------------------------------------------
def get_tale_pos
if defined?($game_system.show_stand_picture) #A1立ち絵スクリプトを入れている。
if $game_system.show_stand_picture #立ち絵on
pos = get_tale_pos_stand_pic
else
pos = get_tale_pos_normal
end
else
pos = get_tale_pos_normal
end
return pos
end
#--------------------------------------------------------------------------
# ○ テールの位置を計算/立ち絵使用時。※NAME_CHANGEの編集必須。
#--------------------------------------------------------------------------
def get_tale_pos_stand_pic
if $game_message.face_name != "" and @tail != nil
name = A1_System::StandPicture::NAME_CHANGE[$game_message.face_name]
chara = name[$game_message.face_index][0]
if @stand_pic[chara] != nil #立ち絵無しの場合通常通り。
x = @stand_pic[chara].pic_sprite.x + @stand_pic[chara].pic_sprite.width / 2
y = get_tale_pos_normal_updown
update_tail_bitmap
else
return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
end
else
return get_tale_pos_normal #立ち絵が見つからない場合は通常通り。
end
return [x,y]
end
#--------------------------------------------------------------------------
# ○ テールの位置を計算/立ち絵未使用時。
#--------------------------------------------------------------------------
def get_tale_pos_normal
if $mes_id == (-2) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
if $win_x != nil
if $win_x > 0
x = $win_x - @tail.width / 2
y = self.y + self.height / 2 - @tail.height / 2
elsif $win_x < 0
x = self.width - @tail.width / 2
y = self.y + self.height / 2 - @tail.height / 2
else
x = MINAS_TWE_X_POS
y = get_tale_pos_normal_updown
end
else
x = MINAS_TWE_X_POS
y = get_tale_pos_normal_updown
end
elsif $mes_id <= (-3) #左右の場合は高さはウィンドウ中心。上下ならやや左に配置。
if $win_x != nil
if $win_x > 0
x = $win_x - @tail.width / 2
y = self.y + self.height / 2
elsif $win_x < 0
x = self.width - @tail.width / 2
y = self.y + self.height / 2
else
x = MINAS_THREE_X_POS
y = get_tale_pos_normal_updown
end
else
x = MINAS_THREE_X_POS
y = get_tale_pos_normal_updown
end
else
character = get_character($mes_id)
x = [[character.screen_x - 16, self.x].max, self.x + self.width - 32].min
if $win_x != nil
if $win_x > 0
x = $win_x - @tail.width / 2
y = character.screen_y
elsif $win_x < 0
x = self.width
y = character.screen_y
else
y = get_tale_pos_normal_updown
end
else
y = get_tale_pos_normal_updown
end
end
return [x, y]
end
#--------------------------------------------------------------------------
# ○ テールが上下の時、かつ[-2][-3]でない時のy座標の取得。
#--------------------------------------------------------------------------
def get_tale_pos_normal_updown
case @position
when 0
y = self.y + self.height - @tail.height / 2
else
y = self.y - @tail.height / 2
end
return y
end
#--------------------------------------------------------------------------
# ○ ふきだしを破棄
#--------------------------------------------------------------------------
def del_tail
if @tail != nil
@tail.dispose
@tail = nil
end
end
end
#
# ▼▲▼ XRXS 9拡張CO-X. ふきだし自動設定 ▼▲▼
#==============================================================================
# ■ Window_Message
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ○ ポップキャラクターの設定
#--------------------------------------------------------------------------
def pop_character=(character_id)
@pop_character = character_id
$mes_id = character_id
end
#--------------------------------------------------------------------------
# ○ テールキャラクターの設定
#--------------------------------------------------------------------------
def tail_character=(character_id)
#@pop_character = character_id
$mes_id = character_id
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# メニューを開いてからウィンドウが出るとネームウィンドウが表示される不具合修正。
#==============================================================================
#class Scene_Menu < Scene_MenuBase
# def terminate_hukidasi_menyu
# @name_window.openness = 0 if @name_window != nil
# terminate_hukidasi_menyu_default
# end
# alias :terminate_hukidasi_menyu_default :terminate
# alias :terminate :terminate_hukidasi_menyu
#end
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#■ウィンドウ非表示ルーチン
#■吹きだしテールとネームウィンドウに対応。
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#==============================================================================
# L(キーボードのQ)を押すと、メッセージウィンドウを表示?非表示
#==============================================================================
class Window_Message < Window_Base
def update_winoff
unless $game_party.in_battle #バトル中は無効。
if Input.trigger?(Input::L)
if self.visible == true
self.visible = false
@tail.visible = false if @tail != nil
else
self.visible = true
end
if @name_window != nil
if @name_window.visible == false and $name != nil and $name != ""
@name_window.visible = true
@name_sprite.visible = true
else
@name_window.visible = false
@name_sprite.visible = false
end
end
elsif Input.trigger?(Input::C) or Input.trigger?(Input::B)
self.visible = true if self.visible == false
@tail.visible = true if @tail != nil and @tail.visible == false
if @name_window != nil and $name != nil
if $name != ""
@name_window.visible = true
@name_sprite.visible = true
end
end
end
end
update_winoff_default
end
alias :update_winoff_default :update
alias :update :update_winoff
end
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#■ウィンドウ表示位置指定ルーチン
#■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
#===========================================================================
#イベントコマンド「スクリプト」を使い、
#$win_x=100
#$win_y=100
#と入力すれば、ウィンドウを(100、100)の位置に表示します。
#使わない時は
#$win_x=nil
#などとnilを入力しておいてください。
#===========================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ● ウィンドウの背景と位置の設定 [再定義]
#--------------------------------------------------------------------------
def update_placement_position
update_placement_position_default
if $win_x != nil
if $win_x > 0
self.x = $win_x
self.width -= $win_x
else
self.x = 0
self.width += $win_x
end
end
if $win_y != nil
self.y = $win_y
end
end
alias_method :update_placement_position_default, :update_placement
alias_method :update_placement, :update_placement_position
end
#==============================================================================
# ■ SceneManager
#------------------------------------------------------------------------------
# シーン遷移のさい、テールを破棄する。
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# ● 呼び出し
#--------------------------------------------------------------------------
def self.call_sceman_hukidasi(scene_class)
if defined?(self.scene.message_window)
self.scene.message_window.del_tail if self.scene.message_window.tail != nil
end
@stack.push(@scene)
@scene = scene_class.new
end
#--------------------------------------------------------------------------
# ● クラスメソッドのエイリアス
#--------------------------------------------------------------------------
class << self
alias :call_sceman_hukidasi_default :call
alias :call :call_sceman_hukidasi
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 戦闘トランジションのさい、テールを破棄。
#==============================================================================
class Scene_Map < Scene_Base
attr_accessor :message_window
#--------------------------------------------------------------------------
# ● 戦闘前トランジション実行
#--------------------------------------------------------------------------
def perform_battle_transition_hukidasi
@message_window.del_tail #テールの破棄
perform_battle_transition_hukidasi_default
end
alias_method :perform_battle_transition_hukidasi_default, :perform_battle_transition
alias_method :perform_battle_transition, :perform_battle_transition_hukidasi
end
复制代码
「空メッセージでウィンドウを開かない」和「立ち絵表示」,本来是三个,不过「ネームウィンドウ」不能共用
#===========================================================================
# ◆ A1 Scripts ◆
# 空メッセージでウィンドウを開かない(RGSS3)
#
# バージョン : 1.00 (2011/12/15)
# 作者 : A1
# URL : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・空メッセージやメッセージに出さないコマンドのみの文章の時
# メッセージウィンドウを開かないようにします
#---------------------------------------------------------------------------
# 更新履歴 :2011/12/15 Ver1.00 リリース
#---------------------------------------------------------------------------
# 設置場所
# 再定義メソッドのため、なるべく上の方
#
# 必要スクリプト
# なし
#---------------------------------------------------------------------------
# 使い方
# このスクリプトを導入することで適用されます
#==============================================================================
$imported ||= {}
$imported["A1_EmptyMassage"] = true
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 文章表示に使うメッセージウィンドウです。
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ★ 全テキストの処理
#--------------------------------------------------------------------------
def process_all_text
text = convert_escape_characters($game_message.all_text)
pos = {}
new_page(text, pos)
open_and_wait if chk_text(text.clone)
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
#--------------------------------------------------------------------------
# ○ 文章のチェック
#--------------------------------------------------------------------------
def chk_text(text)
text.gsub!(/\e.+\[.+\]/,"")
text.gsub!(/\e\^/,"")
text.gsub!(/\n/,"")
return false if text.empty?
return true
end
end
复制代码
#===========================================================================
# ◆ A1 Scripts ◆
# 立ち絵表示(RGSS3)
#
# バージョン : 1.10 (2011/12/15)
# 作者 : A1
# URL : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・「ピクチャの表示」などを使わなくても立ち絵を表示・非表示・移動します
#---------------------------------------------------------------------------
# 更新履歴 :2011/12/15 Ver1.00 リリース
#---------------------------------------------------------------------------
# 設置場所
# RGSS3用A1共通スクリプトより下
# (ネームウィンドウ以下)
#
# 必要スクリプト
# RGSS3用A1共通処理
#---------------------------------------------------------------------------
# 使い方
# 顔グラフィックに対応した立ち絵を
# Picturesフォルダにインポートすれば機能します
#
# 対応する立ち絵のファイル名は
# [顔グラフィックファイル名]_[顔グラフィックスインデックス]_[0 or 1]
#
# 例:顔グラフィック Actor1 のIndex 0 (ラルフ) の場合
# Actor1_0_0 が対応立ち絵になります
# Actor1_0_1 があれば口パクします
#
# 立ち絵表示フラグをOnにすると、立ち絵が表示されるようになります
# 立ち絵表示フラグの番号は設定項目で設定できます
#
# 名前の置き換え
# 設定項目の「名前の置き換え」を設定することで
# 顔グラフィックファイル名と、表示する立ちグラフィックの関連付けができます
#
# 例1(1つの顔グラフィックファイルを複数キャラで使用する場合)
# "Actor1" => [["ラルフ",0],["アリシア",0],nil,nil,
# nil, nil, nil,nil],
#
# 顔グラフィックファイル「Actor1」のIndex0を表示した際
# ラルフ_0_0 が対応立ち絵になります
# ラルフ_0_1 があれば口パクします
#
# 「Actor1」のIndex1を表示した際は
# アリシア_0_0 が対応立ち絵になります
# アリシア_0_1 があれば口パクします
#
# 例2(複数の顔グラフィックファイルを1キャラで使用する場合)
# "ラルフ" => [["ラルフ",0]] (省略可能)
# "ラルフ_ex" => [["ラルフ",1]]
#
# 顔グラフィックファイル「ラルフ」「ラルフ_ex」に対応した
# 全ての立ち絵を、「ラルフ」の立ち絵として扱います
#---------------------------------------------------------------------------
# 追加文章中コマンド
#
# \TURN[direction] 翻转图片
# direction = 向きを指定します (L or R)
#
# L : 元の立ち絵を反転させます
# R : 反転を元の立ち絵に戻します
# 使用例:\TURN[L]
#
# \RETURN[duration] 立ち絵を所定の位置に戻します
# duration = 移動完了までの時間(フレーム)
#
# \ERASE 立ち絵を消去します
#
# \SHOW 消去した立ち絵を表示させます
#
# \TONE[duration,red,green,blue,gray]
# 立ち絵の色調を変更します
# duration = 色調変更完了までの時間(フレーム)
# red = 色調の赤要素
# green = 色調の緑要素
# blue = 色調の青要素
# gray = 色調のグレー要素(省略可)
#
# \MV[x,y,duration] 立ち絵を移動します(絶対座標)
# x = 移動先のx座標
# y = 移動先のy座標
# duration = 移動完了までの時間(フレーム)
#
# \MVA[x,y,duration] 立ち絵を移動します(相対座標)
# x = x方向の移動距離
# y = y方向の移動距離
# duration = 移動完了までの時間(フレーム)
#
# \OP[opacity,duration] 立ち絵の透明度を変更します
# opacity = 透明度
# duration = 透明度変更完了までの時間(フレーム)
#
#
# \BYE[direction,duration] 立ち絵を画面外に移動させます
# direction = 向きを指定します (L or R or D)
# duration = 移動完了までの時間(フレーム)
#
# L : 画面左に退場します
# R : 画面右に退場します
# D : 画面下に退場します
# 使用例:\BYE[L,60]
#==============================================================================
$imported ||= {}
$imported["A1_Stand_Picture"] = true
if $imported["A1_Common_Script"]
#==============================================================================
# ■ 設定項目
#==============================================================================
module A1_System::StandPicture
# 名前の置き換え
NAME_CHANGE = {
"吕@八健将_1" => [["高顺",0],["高顺",0],nil,nil,
nil, nil, nil,nil],
}
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 文章表示に使うメッセージウィンドウです。
#==============================================================================
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# ○ 定数
#--------------------------------------------------------------------------
LEFT = 0
RIGHT = 1
BYE_DURATION = 30
MOVE_DURATION = 30
#--------------------------------------------------------------------------
# ☆ オブジェクト初期化
#--------------------------------------------------------------------------
alias a1_stand_picture_window_message_initialize initialize
def initialize
@stand_pic = {}
@show_pos = []
@prev_name = ""
@pre_message = false
a1_stand_picture_window_message_initialize
end
#--------------------------------------------------------------------------
# ☆ 改ページ処理
#--------------------------------------------------------------------------
alias a1_stand_picture_window_message_new_page new_page
def new_page(text, pos)
file_name = $game_message.face_name
file_index = $game_message.face_index
file_info = find_name(file_name, file_index)
name = file_info[0]
index = file_info[1]
# 顔グラフィックがない
if name.empty?
# 従来の改ページ処理
a1_stand_picture_window_message_new_page(text, pos)
return
# 顔グラフィックがある
else
# 立ち絵作成(新顔なら表示)
new_face = false
new_face = create_stand_pic(file_name, name, index) if @stand_pic[name] == nil
# 立ち絵がない
unless stand_pic_enable?(name)
# 従来の改ページ処理
a1_stand_picture_window_message_new_page(text, pos)
return
end
end
unless new_face
if show_pos(name) > -1
# 顔グラフィック変更
@stand_pic[name].change_face(file_name, index)
elsif @show_pos.size == 2
change_character(file_name, name, index)
else
create_stand_pic(file_name, name, index)
end
end
# 顔グラフィックスを一度emptyにする
$game_message.face_name = "" if @stand_pic[name].enable_bitmap?(index)
# 従来の改ページ処理
a1_stand_picture_window_message_new_page(text, pos)
# 顔グラフィックスを戻す
$game_message.face_name = file_name
# 直前に話した名前を入れる
@prev_name = name
if $imported["A1_Name_Window"]
pos = show_pos(name)
unless stand_pic_enable?(name)
show_name_window(file_name, file_index, 0)
else
bitmap_width = @stand_pic[name].pic_sprite.bitmap.width
x = bitmap_width / 2 if pos == 0
x = Graphics.width - bitmap_width / 2 if pos == 1
show_name_window(file_name, file_index, x, 0)
end
end
end
#--------------------------------------------------------------------------
# ☆ 改行処理
#--------------------------------------------------------------------------
alias a1_stand_picture_window_message_new_line_x new_line_x
def new_line_x
file_name = $game_message.face_name
file_index = $game_message.face_index
file_info = find_name(file_name, file_index)
name = file_info[0]
index = file_info[1]
# 顔グラフィックがない
if name.empty?
# 従来の改行処理
return a1_stand_picture_window_message_new_line_x
end
# 立ち絵がない
unless stand_pic_enable?(name)
# 従来の改行処理
return a1_stand_picture_window_message_new_line_x
end
# 顔グラフィックスを一度emptyにする
$game_message.face_name = "" if @stand_pic[name].enable_bitmap?(index)
# 従来の改行処理
ret = a1_stand_picture_window_message_new_line_x
# 顔グラフィックスを戻す
$game_message.face_name = file_name
return ret
end
#--------------------------------------------------------------------------
# ○ 立ち絵作成
#--------------------------------------------------------------------------
def create_stand_pic(file_name, name, index, duration = MOVE_DURATION)
@stand_pic[name] = Game_StandPic.new(name, index)
return if @stand_pic[name].pic_sprite == nil
return unless $game_system.show_stand_picture
if @show_pos.size == 0
pos = LEFT
@show_pos[0] = name
elsif @show_pos.size == 1
pos = RIGHT
@show_pos[1] = name
else
change_character(file_name, name, index)
return true
end
@stand_pic[name].show(file_name, pos,index, duration)
return true
end
#--------------------------------------------------------------------------
# ○ 表示する立ち絵の変更
#--------------------------------------------------------------------------
def change_character(file_name, name, index, duration = MOVE_DURATION)
return if @stand_pic[name].pic_sprite == nil
return unless $game_system.show_stand_picture
no_index = no_prev_index
no_prev_name = @show_pos[no_index]
case no_index
when 0
@stand_pic[no_prev_name].bye("L",BYE_DURATION) if stand_pic_enable?(no_prev_name)
pos = LEFT
@show_pos[0] = name
when 1
@stand_pic[no_prev_name].bye("R",BYE_DURATION) if stand_pic_enable?(no_prev_name)
pos = RIGHT
@show_pos[1] = name
end
@stand_pic[name].show(file_name, pos,index, duration) if stand_pic_enable?(name)
end
#--------------------------------------------------------------------------
# ○ 直前に話していないIndexを取得
#--------------------------------------------------------------------------
def no_prev_index
return 0 if @show_pos[0] != @prev_name
return 1 if @show_pos[1] != @prev_name
end
#--------------------------------------------------------------------------
# ○ 表示されているか調べる
#--------------------------------------------------------------------------
def show_pos(name)
return 0 if @show_pos[0] == name
return 1 if @show_pos[1] == name
return -1
end
#--------------------------------------------------------------------------
# ☆ フレーム更新
#--------------------------------------------------------------------------
alias a1_stand_pic_window_message_update update
def update
update_stand_pic
a1_stand_pic_window_message_update
end
#--------------------------------------------------------------------------
# ○ 立ち絵のアップデート
#--------------------------------------------------------------------------
def update_stand_pic
for name in @stand_pic.keys
@stand_pic[name].update
end
end
#--------------------------------------------------------------------------
# ○ 文章のチェック
#--------------------------------------------------------------------------
alias a1_stand_pic_wm_chk_text chk_text
def chk_text(text)
text.gsub!(/\eERASE/,"")
text.gsub!(/\eSHOW/,"")
return a1_stand_pic_wm_chk_text(text)
end
#--------------------------------------------------------------------------
# ☆ 制御文字の処理
# code : 制御文字の本体部分(「\C[1]」なら「C」)
# text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
# pos : 描画位置 {:x, :y, :new_x, :height}
#--------------------------------------------------------------------------
alias a1_stand_pic_wm_process_escape_character process_escape_character
def process_escape_character(code, text, pos)
file_name = $game_message.face_name
file_index = $game_message.face_index
file_info = find_name(file_name, file_index)
name = file_info[0]
index = file_info[1]
case code.upcase
when 'TURN'
text.slice!(/\[(.)\]/) rescue 0
if stand_bitmap_enable?(name, index)
case $1
when 'L'
@stand_pic[name].pic_sprite.mirror = true
when 'R'
@stand_pic[name].pic_sprite.mirror = false
end
end
return true
when 'RETURN'
text.slice!(/\[(\d+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
index = show_pos(name)
return if index == -1
duration = $1.to_i
@stand_pic[name].return_pos(index, duration)
end
when 'SHOW'
if stand_bitmap_enable?(name, index)
return if @stand_pic[name].pic_sprite == nil or name.empty?
@stand_pic[name].pic_sprite.visible = true
end
when 'ERASE'
if stand_bitmap_enable?(name, index)
return if @stand_pic[name].pic_sprite == nil or name.empty?
@stand_pic[name].pic_sprite.visible = false
end
when 'TONE'
text.slice!(/\[(.+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
params = $1.to_s.split(",")
duration = params[0].to_i
red = $a1_common.minus_to_i(params[1])
green = $a1_common.minus_to_i(params[2])
blue = $a1_common.minus_to_i(params[3])
gray = $a1_common.minus_to_i(params[4]) unless params[4] == nil
if gray == nil
tone = Tone.new(red, green, blue)
else
tone = Tone.new(red, green, blue, gray)
end
@stand_pic[name].start_tone_change(tone, duration)
end
when 'MV'
text.slice!(/\[([-]*\d+)[,]([-]*\d+)[,](\d+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
x = $a1_common.minus_to_i($1)
y = $a1_common.minus_to_i($2)
duration = $3.to_i
@stand_pic[name].move(x, y, duration)
end
when 'MVA'
text.slice!(/\[([-]*\d+)[,]([-]*\d+)[,](\d+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
x = $a1_common.minus_to_i($1)
y = $a1_common.minus_to_i($2)
duration = $3.to_i
@stand_pic[name].move_plus(x, y, duration)
end
when 'OP'
text.slice!(/\[(\d+)[,](\d+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
@stand_pic[name].change_opacity($1.to_i,$2.to_i)
end
when 'BYE'
text.slice!(/^\[(.)[,](\d+)\]/) rescue 0
if stand_bitmap_enable?(name, index)
@show_pos.delete_at(show_pos(name))
@stand_pic[name].bye($1,$2.to_i)
end
else
a1_stand_pic_wm_process_escape_character(code, text, pos)
end
end
#--------------------------------------------------------------------------
# ☆ 通常文字の処理
#--------------------------------------------------------------------------
alias a1_stand_pic_wm_process_normal_character process_normal_character
def process_normal_character(c, pos)
file_name = $game_message.face_name
file_index = $game_message.face_index
file_info = find_name(file_name, file_index)
name = file_info[0]
index = file_info[1]
if stand_bitmap_enable?(name, index)
@stand_pic[name].mouth_move
end
a1_stand_pic_wm_process_normal_character(c, pos)
end
#--------------------------------------------------------------------------
# ○ 立ち絵が有効?
#--------------------------------------------------------------------------
def stand_pic_enable?(name)
return false if name.empty?
return false if @stand_pic[name] == nil
return false if @stand_pic[name].pic_sprite == nil
return false unless $game_system.show_stand_picture
return true
end
#--------------------------------------------------------------------------
# ○ ビットマップが有効?
#--------------------------------------------------------------------------
def stand_bitmap_enable?(name, index)
return false if name.empty?
return false if @stand_pic[name].pic_sprite == nil
return false unless @stand_pic[name].enable_bitmap?(index)
return false unless $game_system.show_stand_picture
return true
end
#--------------------------------------------------------------------------
# ☆ 解放
#--------------------------------------------------------------------------
alias a1_stand_pic_window_message_dispose dispose
def dispose
a1_stand_pic_window_message_dispose
dispose_stand_picture
end
#--------------------------------------------------------------------------
# ○ 立ち絵の解放
#--------------------------------------------------------------------------
def dispose_stand_picture
for name in @stand_pic.keys
@stand_pic[name].erase
end
end
#--------------------------------------------------------------------------
# ○ 名前の検索
#--------------------------------------------------------------------------
def find_name(filename, fileindex)
list = A1_System::StandPicture::NAME_CHANGE[filename]
return [filename,fileindex] if list == nil
if list.size == 1
info = list[0]
return [info[0],info[1]*8+fileindex]
end
return [filename,fileindex] if list[fileindex] == nil
return list[fileindex]
end
end
#==============================================================================
# ■ Game_StandPic
#==============================================================================
class Game_StandPic
#--------------------------------------------------------------------------
# ○ 定数
#--------------------------------------------------------------------------
LEFT = 0
RIGHT = 1
MOVE_DURATION = 30
MOUTH_MOVE_DURATION = 4
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :x # X 座標
attr_reader :y # Y 座標
attr_reader :opacity # 不透明度
attr_reader :tone # 色調
attr_reader :mirror # 左右反転
attr_reader :pic_sprite # スプライト
attr_reader :bitmap # ビットマップの配列
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# number : ピクチャ番号
#--------------------------------------------------------------------------
def initialize(name, index)
@name = name
@duration = 0
@target_opacity = 255.0
@tone = Tone.new(0, 0, 0, 0)
@tone_target = Tone.new(0, 0, 0, 0)
@tone_duration = 0
@mirror = false
@pic_sprite = nil
@face_index = 0
@mouth_index = 0
@mouth_move_duration = 0
@pos = -1
@bitmap = []
@bitmap_test = []
plus = (index / 8) * 8
create_bitmap(name, plus)
@pic_sprite = create_sprite if @bitmap.size > 0
end
#--------------------------------------------------------------------------
# ● スプライトの作成
#--------------------------------------------------------------------------
def create_sprite
pic_sprite = Sprite.new
pic_sprite.visible = false
return pic_sprite
end
#--------------------------------------------------------------------------
# ● ビットマップの作成
#--------------------------------------------------------------------------
def create_bitmap(name, plus = 0)
file = sprintf("Graphics/Pictures/%s",name)
Dir::glob(sprintf("%s*.*",file)).each {|f|
next unless f =~ /#{file}_(\d+)_(\d+)/i
next unless FileTest.file?(f)
next unless file_ext(f)
index = $1.to_i + plus
@bitmap[index] = [] if @bitmap[index] == nil
file_name = File.basename(f,".*")
@bitmap[index][$2.to_i] = Cache.picture(file_name)
@bitmap_test[index] = true
}
end
#--------------------------------------------------------------------------
# ● 拡張子を調べる
#--------------------------------------------------------------------------
def file_ext(f)
return true if File::extname(f) == ".png"
return true if File::extname(f) == ".bmp"
return false
end
#--------------------------------------------------------------------------
# ● ビットマップの存在を調べる
#--------------------------------------------------------------------------
def enable_bitmap?(index)
return false if @bitmap[index] == nil
return true
end
#--------------------------------------------------------------------------
# ● 代替ビットマップの検索
#--------------------------------------------------------------------------
def search_bitmap
for bitmap in @bitmap
next if bitmap == nil
return bitmap[0]
end
end
#--------------------------------------------------------------------------
# ● ピクチャの表示
#--------------------------------------------------------------------------
def show(file_name, pos, index, duration, opacity = 255)
@face_index = index
@pos = pos
if @bitmap[@face_index] == nil and @bitmap_test[@face_index] != true
plus = (@face_index / 8) * 8
create_bitmap(file_name, plus)
end
if @bitmap[@face_index] == nil or $game_system.show_stand_picture == false
@pic_sprite.bitmap = nil
@pic_sprite.visible = false
bitmap = search_bitmap
else
@pic_sprite.visible = true
@pic_sprite.bitmap = @bitmap[@face_index][0]
bitmap = @pic_sprite.bitmap
end
fix_pos(pos, duration, bitmap, opacity)
return true
end
#--------------------------------------------------------------------------
# ● 場所確定
#--------------------------------------------------------------------------
def fix_pos(pos, duration, bitmap, opacity)
case pos
when LEFT
@pic_sprite.x = (0 - bitmap.width).to_f
@target_x = 0.0
@duration = duration
@pic_sprite.mirror = false
when RIGHT
@pic_sprite.x = Graphics.width.to_f
@target_x = (Graphics.width - bitmap.width).to_f
@duration = duration
@pic_sprite.mirror = true
end
@pic_sprite.opacity = opacity.to_f
@pic_sprite.visible = true
@pic_sprite.y = (Graphics.height - bitmap.height).to_f
@target_y = @pic_sprite.y
end
#--------------------------------------------------------------------------
# ● 定位置に戻る
#--------------------------------------------------------------------------
def return_pos(pos, duration)
case pos
when LEFT
@target_x = 0.0
@duration = duration
@pic_sprite.mirror = false
when RIGHT
@target_x = (Graphics.width - @pic_sprite.bitmap.width).to_f
@duration = duration
@pic_sprite.mirror = true
end
@target_y = (Graphics.height - @pic_sprite.bitmap.height).to_f
end
#--------------------------------------------------------------------------
# ● 顔変更
#--------------------------------------------------------------------------
def change_face(name, index)
@face_index = index
if @bitmap[@face_index] == nil and @bitmap_test[@face_index] != true
plus = (@face_index / 8) * 8
create_bitmap(name, plus)
end
if @bitmap[@face_index] == nil or $game_system.show_stand_picture == false
@pic_sprite.bitmap = nil
@pic_sprite.visible = false
else
@pic_sprite.bitmap = @bitmap[@face_index][0]
case @pos
when LEFT
@pic_sprite.x = 0.0
when RIGHT
@pic_sprite.x = (Graphics.width - @pic_sprite.bitmap.width).to_f
end
@pic_sprite.y = (Graphics.height - @pic_sprite.bitmap.height).to_f
@target_x = @pic_sprite.x
@target_y = @pic_sprite.y
@pic_sprite.visible = true
end
end
#--------------------------------------------------------------------------
# ● 口パク
#--------------------------------------------------------------------------
def mouth_move
return if @mouth_move_duration > 0
return if bitmap[@face_index] == nil
return if bitmap[@face_index].size == 1
@mouth_move_duration = MOUTH_MOVE_DURATION
if @mouth_index == 0 and bitmap[@face_index][1] != nil
@mouth_index = 1
elsif @mouth_index == 1
@mouth_index = 0
end
@pic_sprite.bitmap = bitmap[@face_index][@mouth_index]
end
#--------------------------------------------------------------------------
# ● ピクチャの移動
#--------------------------------------------------------------------------
def move(x, y, duration)
@target_x = x
@target_y = y
@duration = duration
end
#--------------------------------------------------------------------------
# ● 透明度変更
#--------------------------------------------------------------------------
def change_opacity(opacity, duration)
@target_opacity = opacity
@duration = duration
end
#--------------------------------------------------------------------------
# ● 相対移動
#--------------------------------------------------------------------------
def move_plus(x, y, duration)
@target_x = @pic_sprite.x + x
@target_y = @pic_sprite.y + y
@duration = duration
end
#--------------------------------------------------------------------------
# ● 退場
#--------------------------------------------------------------------------
def bye(direction, duration)
return if @pic_sprite.bitmap == nil
case direction
when "D"
@target_y = Graphics.height
when "R"
@target_x = Graphics.width
when "L"
@target_x = 0 - @pic_sprite.bitmap.width
end
@duration = duration
end
#--------------------------------------------------------------------------
# ● 色調変更の開始
#--------------------------------------------------------------------------
def start_tone_change(tone, duration)
@tone_target = tone.clone
@tone_duration = duration
if @tone_duration == 0
@tone = @tone_target.clone
end
end
#--------------------------------------------------------------------------
# ● ピクチャの消去
#--------------------------------------------------------------------------
def erase
for arr in @bitmap
next if arr == nil
for bitmap in arr
next if bitmap == nil
bitmap.dispose
end
end
@bitmap = nil
return if @pic_sprite == nil
@pic_sprite.dispose
@pic_sprite = nil
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
return if @pic_sprite == nil
@mouth_move_duration -= 1 if @mouth_move_duration > 0
if @duration >= 1
d = @duration
@pic_sprite.x = (@pic_sprite.x * (d - 1) + @target_x) / d
@pic_sprite.y = (@pic_sprite.y * (d - 1) + @target_y) / d
@pic_sprite.opacity = (@pic_sprite.opacity * (d - 1) + @target_opacity) / d
@duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
@pic_sprite.tone = @tone
end
end
end
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
# システム周りのデータを扱うクラスです。乗り物や BGM などの管理も行います。
# このクラスのインスタンスは $game_system で参照されます。
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :show_stand_picture # 立ち絵表示フラグ
#--------------------------------------------------------------------------
# ☆ オブジェクト初期化
#--------------------------------------------------------------------------
alias a1_stand_picture_game_system_initialize initialize
def initialize
a1_stand_picture_game_system_initialize
@show_stand_picture = false
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ○ 注釈の処理
#--------------------------------------------------------------------------
alias a1_stand_picture_proc_comment_command proc_comment_command
def proc_comment_command(command, params)
if command == "立ち絵表示"
case params[0]
when "on"
$game_system.show_stand_picture = true
when "off"
$game_system.show_stand_picture = false
end
else
a1_stand_picture_proc_comment_command(command, params)
end
end
end
end
复制代码
差不多就这样了……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1