#==============================================================================
# メッセージ制御文字追加 カスタム By 貪藻矢射妥←
#------------------------------------------------------------------------------
# 原作: メッセージ制御文字追加 Ver 1.18
# 原作者: ショウ様
# HP: 歯車の城
# アドレス: http://members.jcom.home.ne.jp/cogwheel/
#
# 改造内容:
# ・一部の定数をカスタマイズポイントへ移動
# ・制御文字を若干変更(個人的)
# ・メッセージウィンドウ/履歴ウィンドウでの描画の統合化(?)
# ・外字ファイルの規格とインポート先の変更
# ・縁取り文字への対応
#
#
# ※外字に対してルビを振ることが可能ですが、\r["外字" + 本文,ルビ]などの後、
# すぐ改行がくるとルビが正常に表示されません
#
# ※外字はgaiji_[n(1〜)].png(基本)とgaiji_s_[n(1〜)].png(陰文字用)とを
# Picturesフォルダにインポートする。
# 外字ファイルにはDRAW_MSG::EP_SIZE×DRAW_MSG::EP_SIZE(デフォルトはアイコンの
# 規格と同サイズ)の画像をDRAW_MSG::EP_MAX個並べたものを使用する。
# ちなみに、DRAW_MSG::EP_MAX - 1を超えた画像を指定した場合はgaiji_[n+1].png
# の画像を使用していく。
#
# 使用できる制御文字は以下の通りです。
#
# \c[s] : フォントカラーを変更します。(システムカラー)
# \c[c] : フォントカラーを変更します。(クライシスカラー)
# \c[k] : フォントカラーを変更します。(ノックアウトカラー)
# \a[num(,num)] : アクター顔グラフィックの表示
# \r[main,ruby] : mainの上にrubyを挿入
# \ev[num(,num)]: イベントX 番の…『(1):上に(2):下に』吹き出し表示
# \e[num] : 外字の表示。
# \w[num] : 文字スピードを通常の数値倍にする(小数不可)
# \s[num] : 文字の大きさ変更。通常は22
# \f[num] : フォントの変更。
# \en[num] : エネミーの表示
# \cls[num] : クラスの表示
# \m[num] : マップ名の表示
# \. : 1/4秒ウェイト
# \; : 1/2秒ウェイト
# \| : 1秒ウェイト
# \! : 文字の表示を一旦停止し、キー入力を待つ
# \>\< : \>\<の間にある文を一瞬で表示する
# \^ : キー入力を待たずに強制的にウィンドウを閉じる
# \i : インデントの設定。改行時、文を挿入地点から折り返し表示させる
# \lt : 文の左詰。インデントの解除
# \ct : 文の中央構え
# \rt : 文の右詰
# \n : 強制改行
# \p : 次の改行を無視
# <B> : 太字の開始
# </B> : 太字の解除
# <I> : イタリック(斜め文字)の開始
# </I> : イタリック(斜め文字)の解除
#
#==============================================================================
# 変更履歴
#
# 2009:05:07
# ・外字ファイルが存在しない場合何も描画しないように処理を追加
# ・フォントを変更したまま改行するとフォントを変えてないのにデフォルトに戻って
# しまうバグを修正
#
# 2009:05:08
# ・フォントを変更し、改行を行った際、履歴ウィンドウでは最終的に変更された
# フォントで改行後の文字を描画していたバグを修正
# EX)
# \f[2]あああ
# いいい
# ううう\f[0] ← この行は本来\f[2]で描かれるはずが\f[0]で描かれていた。
#
# 2009:06:03
# ・ウィンドウの横幅、高さをカスタマイズポイントで設定可能に
#
# 2009:11:21
# ・self.contentsのみしか使用できなかったものを拡張したことによる微修正
# ・一番最初の文字がデフォルトフォントでその行でフォントの変更を行った際、
# ウィンドウには最終的に変更されたフォントで最初から描画していたバグを修正
# EX)
# お\f[2]ああ ← この行は『あ』以降\f[2]で描画されるはずが最初から\f[2]だった
# いいい
# ううう\f[0]
#
# 2010:03:27
# ・\en[n]でエネミーの名称を表示可能に
# ・\cls[n]でクラスの名称を表示可能に
# ・\m[n]でマップの名称を表示可能に
#
# 2011:03:05
# ・Window_BGを導入することでウィンドウの背景を画像に変更可能に
#
# 2011:07:01
# ・履歴ウィンドウの最中にCode Crush様のショートカットが使われると履歴用の
# カーソルが残るバグを修正
#
# 2015:10:01
# ・VXA風Sound対応
#
# 2020:10:01
# ・Window VXA対応
#
# 2024:05:01
# ・固定文字列対応
#==============================================================================
# ※ちょろっと問題・・・
#
# 1つのメッセージウィンドウで文字色、フォントなどを変えっぱなしで次の
# メッセージで元に戻した場合など、履歴やウィンドウの表示が多少オカしくなります。
# ・・・し、仕様ということでご勘弁ください。
# フォントの設定はそのメッセージウィンドウ内で完結させてください。
#=============================================================================
# カスタマイズポイント
#=============================================================================
module CWM
# メッセージ履歴最大値
HISTORY_SIZE = 100
# 顔グラのフェードイン表示
FADE = true
# エンターキー押下時のメッセージ一括表示可否
ENTER = true
# シフトスキップの可否
# (0:不可, 1:デバッグ中のみ可, 2:常に可)
SHIFT = 1
# 履歴ウィンドウのウィンドウスキン
HW_WIN_SKIN = "MGS ウィンドウスキン2"
# メッセージウィンドウの横幅
MSG_WIN_WIDTH = 480
# メッセージウィンドウの高さ
MSG_WIN_HEIGHT = 160
# 履歴ウィンドウの横幅
HIS_WIN_WIDTH = 486
# 履歴ウィンドウの高さ
HIS_WIN_HEIGHT = 352
# メッセージウィンドウの背景
WIN_BK = "m_win_bg"
# メッセージウィンドウを画像にするか
USE_WIN_BK = true
# ウィンドウの最大透明度
MAX_OPA = 160
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================
class Game_Player < Game_Character
include CWM
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :message_speed # メッセージ速度
attr_accessor :message_history # メッセージ履歴
attr_accessor :history_size # メッセージ履歴サイズ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super
@message_speed = 1
@message_history = []
@history_size = HISTORY_SIZE
end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
# 文章表示に使うメッセージウィンドウです。
#==============================================================================
class Window_Message < Window_Selectable
include CWM
include DRAW_MSG
#--------------------------------------------------------------------------
# ● 顔グラフィック表示
#--------------------------------------------------------------------------
def actor(name1, name2, write = true)
case name1
when 1
case name2
when 0
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "001-Fighter01")
when 1
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "002-Fighter02")
when 2
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "003-Fighter03")
end
when 2
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "010-Lancer02")
when 3
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "013-Warrior01")
when 4
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "019-Thief04")
when 5
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "022-Hunter03")
when 6
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "023-Gunner01")
when 7
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "029-Cleric05")
when 8
face = Bitmap.new(FIX_PATH::PATH_GRA_BATRER + "038-Mage06")
end
if write
type = 6
@face.bitmap = face
@face.x = self.x + 16
@face.y = self.y + self.height - 16
@face.z = self.z + 1
@face.ox = ((face.width) * (type % 3)) / 2
@face.oy = ((face.height) * (type / 3)) / 2
end
@fi = face.width
@x = @fi + @i if @x <= @fi
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
#super(80, 304, 480, 160)
super((640 - MSG_WIN_WIDTH) / 2, 480 - MSG_WIN_HEIGHT - 16,
MSG_WIN_WIDTH, MSG_WIN_HEIGHT)
self.contents = Bitmap.new(width - 32, height - 32)
self.visible = false
self.z = 9998
if USE_WIN_BK && $OuterFlgs["Window_BG"]
make_bg(WIN_BK)
end
# 顔グラフィックの作成
@face = Sprite.new(self.viewport)
@face.bitmap = Bitmap.new(10, 10)
@face.visible = false
@text = ""
@fade_in = false
@fade_out = false
@contents_showing = false
@contents_showed = false
@cursor_width = 0
self.active = false
self.index = -1
# 履歴ウィンドウの作成
@h_window = Window.new(self.viewport)
#@h_window.x = 77
#@h_window.y = 64
@h_window.x = (640 - HIS_WIN_WIDTH) / 2
@h_window.y = (480 - HIS_WIN_HEIGHT) / 2
@h_window.z = 10001
#@h_window.width = 486
#@h_window.height = 352
@h_window.width = HIS_WIN_WIDTH
@h_window.height = HIS_WIN_HEIGHT
@h_window.opacity = 0
@h_window.back_opacity = MAX_OPA
@h_window.windowskin = RPG::Cache.windowskin(HW_WIN_SKIN)
@h_window.deactivate
@h_window.hide
@c_w = 0
# メッセージスピードの初期化
unless $game_player.message_speed.is_a?(Numeric)
$game_player.message_speed = 1
end
$his_flg = false
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
terminate_message
$game_temp.message_window_showing = false
@face.dispose
if @input_number_window != nil
@input_number_window.dispose
end
@h_window.dispose
super
end
#--------------------------------------------------------------------------
# ● メッセージ終了処理
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
# 表示中フラグをクリア
@contents_showing = false
@contents_showed = false
# メッセージ コールバックを呼ぶ
if $game_temp.message_proc != nil
$game_temp.message_proc.call
end
# 文章、選択肢、数値入力に関する変数をクリア
$game_temp.message_text = nil
$game_temp.message_proc = nil
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
# ゴールドウィンドウを開放
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
end
#--------------------------------------------------------------------------
# ● テキスト初期化設定
#--------------------------------------------------------------------------
def text_initialize
# メッセージウィンドウ初期化設定
#@text = $game_temp.message_text
# 一番最初のフォント名がデフォルトでその行でフォントを変更した場合表示が
# オカしくなるのでまず、フォントをデフォルトに戻して見る。
@text = "\\f[0]" + $game_temp.message_text
@back_up = @text.clone
@rubi = ""
@speed = $game_player.message_speed
font_size = 22
@wait = 0
@push_enter = false
@contents_close = false
@cursor_width = 0
# 制御文字処理
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[(\d+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
# アクター名に置き換え
@text.gsub!(/\\[Nn]\[(\d+)\]/) do
actor = $game_actors[$1.to_i]
actor != nil ? actor.name : ""
#$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# エネミー名に置き換え
@text.gsub!(/\\[Ee]n\[([0-9]+)\]/) do
enemy_name = $data_enemies[$1.to_i].name
enemy_name != nil ? enemy_name : ""
end
# クラス名に置き換え
@text.gsub!(/\\[Cc]ls\[([0-9]+)\]/) do
class_name = $data_classes[$1.to_i].name
class_name != nil ? class_name : ""
end
# マップ名に置き換え
@text.gsub!(/\\[Mm]\[([0-9]+)\]/) do
map_name = load_data(sprintf(FIX_PATH::PATH_DATA_MAPI))[$1.to_i].name
set_name = XRXS_MNT::SET_NAMES[$1.to_i]
map_name = set_name if set_name != nil
map_name != nil ? map_name : ""
end
# 便宜上、"\\\\" を "\000" に変換
@text.gsub!(/\\\\/) { "\000" }
# "\\C" を "\001" に、"\\G" を "\002" に変換
@text.gsub!(/\\[Cc]\[(.+?)\]/) { "\001[#{$1}]" }
# ゴールド表示
@text.gsub!(/\\[Gg]/) { "\002" }
# 制御文字をそれぞれバックスラッシュ記法に変換
# 文字スピードを通常の数値倍にする(小数不可)
@text.gsub!(/\\[Ww]\[(\d+)\]/) { "\003[#{$1}]" }
# 1/4秒ウェイト
@text.gsub!(/\\\./) { "\004" }
# 1/2秒ウェイト
@text.gsub!(/\\\;/) { "\005" }
# 1秒ウェイト
@text.gsub!(/\\\|/) { "\006" }
# 文字の表示を一旦停止し、キー入力を待つ
@text.gsub!(/\\\!/) { "\010" }
# \<まで瞬間表示
@text.gsub!(/\\\>/) { "\016" }
# \>から瞬間表示
@text.gsub!(/\\\) { "\017" }
# キー入力を待たずに強制的にウィンドウを閉じる
@text.gsub!(/\\\^/) { "\020" }
# インデントの設定。改行時、文を挿入地点から折り返し表示させる
@text.gsub!(/\\[Ii]/) { "\021" }
# 文の左詰。インデントの解除
@text.gsub!(/\\[Ll][Tt]/) { "\022" }
# 文の中央構え
@text.gsub!(/\\[Cc][Tt]/) { "\023" }
# 文の右詰
@text.gsub!(/\\[Rr][Tt]/) { "\024" }
# 文字の大きさ変更。通常は22
@text.gsub!(/\\[Ss]\[(\d+)\]/) { "\025[#{$1}]" }
# アクター顔グラフィックの表示
@text.gsub!(/\\[Aa]\[(\d+),?(\d*?)\]/) { "\026[#{$1},0#{$2}]" }
# ルビの表示
@text.gsub!(/\\[Rr]\[(.+?),(.+?)\]/) { "\027[#{$1},#{$2}]" }
# ルビ定型句の表示
#@text.gsub!(/\\[Rr]fix\[(.+?)\]/) { "\050[#{$1}]" }
# フォントの変更
@text.gsub!(/\\[Ff]\[(\d+)\]/) { "\040[#{$1}]" }
# 外字の表示
@text.gsub!(/\\[Ee]\[(.+?)\]/) { "\030[#{$1}]" }
# 太字の開始
@text.gsub!(/\<[Bb]\>/) { "\031" }
# 太字の終了
@text.gsub!(/\<\/[Bb]\>/) { "\033" }
# イタリックの開始
@text.gsub!(/\<[Ii]\>/) { "\034" }
# イタリックの終了
@text.gsub!(/\<\/[Ii]\>/) { "\035" }
# ?
@text.gsub!(/\\[Ss][Tt]/) { "" }
# 強制改行
@text.gsub!(/\\[Nn]/) { "\n" }
# 次の改行を無視
@text.gsub!(/\\[Pp](.*?)\n/) { $1 }
@x = @i = 4
@fi = @y = @py = 0
# 最初の行がルビ付きの場合、字下げを行う
@text = "\n" if @text == ""
text = @text[/^.*?\n/]
r_height = 0
while ((c = text.slice!(/./m)) != nil)
# \S[n] の場合、フォントサイズの変更
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
font_size = ck_font_size($1.to_i)
next
end
# ルビが存在した場合
if c == "\027"
text.sub!(/\[(.+?),(.+?)\]/, "")
# ルビのテキストサイズを格納
r_height = [r_height, font_size].max
next
end
# ルビ定型句が存在した場合
#if c == "\050"
# text.sub!(/\[(.+?)\]/, "")
# # ルビのテキストサイズを格納
# r_height = [r_height, font_size].max
# next
#end
end
# 字下げの設定
@py = [(r_height + get_ruby_size(r_height) - 5) - max_height(@text), 0].max
# 選択肢なら字下げを行う
if $game_temp.choice_start == 0
@x = 12
end
# "\Ev[n]" がある場合、イベントnに吹き出し表示
unless self.contents.disposed?
self.contents.dispose
end
# 吹き出し表示の場合
if @text.gsub!(/\\[Ee]\\[Vv]\[(\-*?\d+),?(\d*?)\]/) { "" }
# メッセージの幅、高さの読み込み
@event = $game_system.map_interpreter.get_character($1.to_i)
self.contents = Bitmap.new(10, 10)
self.contents.font.size = font_size
self.width = text_width(@text) + 32
self.height = [text_height(@text) + 32 + @py, 32].max
# 数値入力の場合、高さと幅の調整
if $game_temp.num_input_variable_id > 0
dummy_bitmap = Bitmap.new(32, 32)
i_width = dummy_bitmap.text_size("0").width + 8
dummy_bitmap.dispose
self.width=[self.width,i_width*$game_temp.num_input_digits_max+48].max
self.height += 32
# 高さが数値分しかない場合、数値入力を繰り上げる
$game_temp.num_input_start -= 1 if self.height == 64
end
@w_pos = $2.to_i
window_position
self.contents.dispose
else
@event = nil
#self.x = 80
self.x = (640 - MSG_WIN_WIDTH) / 2
if $game_temp.in_battle
self.y = 16
else
case $game_system.message_position
when 0 # 上
self.y = 16
when 1 # 中
#self.y = 160
self.y = (480 - MSG_WIN_HEIGHT) / 2
when 2 # 下
#self.y = 304
self.y = 480 - MSG_WIN_HEIGHT - 16
end
end
self.width = MSG_WIN_WIDTH
self.height = MSG_WIN_HEIGHT
end
# ウィンドウ内容の初期化
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Font.default_name
self.contents.font.size = font_size
self.contents.font.color = normal_color
self.contents.font.bold = false
self.contents.font.italic = false
if USE_WIN_BK && $OuterFlgs["Window_BG"]
self.opacity = 0
end
self.z = 100
# メッセージ履歴に文章を挿入
history_write(@text.clone)
# 第一行目のフォントサイズが基準フォントサイズと異なる場合の体裁を整える
@h = max_height(@text) - self.contents.font.size
end
#--------------------------------------------------------------------------
# ● 吹き出し表示:ウィンドウ位置設定
#--------------------------------------------------------------------------
def window_position
m_x = (@event.real_x - $game_map.display_x) / 4 - self.width / 3
m_y = (@event.real_y - $game_map.display_y) / 4
if @w_pos == 0
m_y -= self.height + 32
else
m_y += 48
end
self.x =[[m_x, 0].max, 640 - self.width].min
self.y = [[m_y, 0].max, 480 - self.height].min
if @input_number_window != nil
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + 32 + @h + @py
end
end
include BM
include DIAMOND
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
# 表示待ちのメッセージがある場合
if @text != nil
# c に 1 文字を取得 (文字が取得できなくなるまでループ)
while ((c = @text.slice!(/./m)) != nil)
next unless control(c)
if @push_enter
@contents_showed = true
break
end
# 文字を描画
size = self.contents.font.size
#self.contents.draw_text(@x, @h + @py, 10 + size, 10 + size, c)
rectr = [@x, @h + @py, 10 + size, 10 + size]
draw_shadow_text(rectr, c, change_color(@color))
# x に描画した文字の幅を加算
@x += self.contents.text_size(c).width
rubi_draw if @rubi != ""
if @speed > 0 and @contents_showed == false and
not (ENTER and Input.trigger?(Input::C)) and
not (SHIFT >= ($DEBUG ? 0 : 1) and Input.press?(Input::SHIFT))
@wait += @speed if @wait <= 0
break if @wait > 0
end
end
if @text == ""
text_end
end
end
end
#--------------------------------------------------------------------------
# ● テキスト描画終了時
#--------------------------------------------------------------------------
def text_end
@contents_showed = true
# 選択肢の場合
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
@c_w = @h
end
# 数値入力の場合
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + 32 + @h + @py
end
end
#--------------------------------------------------------------------------
# ● 制御文字処理
#--------------------------------------------------------------------------
def control(c)
# \\ の場合
if c == "\000"
# 本来の文字に戻す
c = "\\"
return true
end
# \C[n] の場合
if c == "\001"
c_change
return false
end
# \G の場合
if c == "\002"
gold
return false
end
# \W[n] の場合
if c == "\003"
@text.sub!(/\[(\d+)\]/, "")
@speed = $game_player.message_speed * $1.to_i
return false
end
# \. の場合
if c == "\004"
@wait = 10
c.sub!("\004", "")
return true
end
# \; の場合
if c == "\005"
@wait = 20
c.sub!("\005", "")
return true
end
# \| の場合
if c == "\006"
@wait = 40
c.sub!("\006", "")
return true
end
# \! の場合
if c == "\010"
self.pause = true
@push_enter = true
@contents_showed = true
c.sub!("\010", "")
return true
end
# \> の場合
if c == "\016"
@temp_speed = @speed
@speed = 0
return false
end
# \< の場合
if c == "\017"
@speed = @temp_speed
c.sub!("\017", "")
return true
end
# \^ の場合
if c == "\020"
@contents_close = true
return false
end
# \I の場合
if c == "\021"
@i = @x - @fi
if @y >= $game_temp.choice_start
@i = @x - @fi - 8
end
return false
end
# \LT の場合
if c == "\022"
@i = @x = @fi + 4
return false
end
# \CT の場合
if c == "\023"
@text[(/(.+?)\n/)]
width = max_width($1)[0]
@x = (@fi + self.contents.width - width) / 2
return false
end
# \RT の場合
if c == "\024"
@text[(/(.+?)\n/)]
width = max_width($1)[0]
@x = self.contents.width - width - 4
return false
end
# \S[n] の場合
if c == "\025"
s_change
return false
end
# \A[n,m] の場合
if c == "\026"
@text.sub!(/\[(\-*\d+),(\d+)\]/, "")
actor($1.to_i, $2.to_i)
return false
end
# \R[n,m] の場合
if c == "\027"
@text.sub!(/\[(.+?),(.+?)\]/) { rubi_set($1, $2) }
return false
end
# \Rfix[n] の場合
#if c == "\050"
# @text.sub!(/\[(.+?)\]/) { rubi_set($1, FIX_RUBY[$1]) }
# return false
#end
# \F[n] の場合
if c == "\040"
@text.sub!(/\[(\d+)\]/, "")
get_font($1.to_i)
return false
end
# \E[i] の場合
if c == "\030"
@text.sub!(/\[(.+?)\]/, "")
letter($1.to_i)
return false
end
# <B> の場合
if c == "\031"
self.contents.font.bold = true
return false
end
# </B> の場合
if c == "\033"
self.contents.font.bold = false
return false
end
# <I> の場合
if c == "\034"
self.contents.font.italic = true
return false
end
# </I> の場合
if c == "\035"
self.contents.font.italic = false
return false
end
# 改行文字の場合
if c == "\n"
new_line
return false
end
return true
end
#--------------------------------------------------------------------------
# ● フォント変更
#--------------------------------------------------------------------------
def get_font(font_val)
font_name = change_font(font_val)
if @h_window.active
#obj = @h_window
obj = @h_window.contents
else
#obj = self
obj = self.contents
end
#obj.contents.font.name = font_name
obj.font.name = font_name
end
#--------------------------------------------------------------------------
# ● ルビサイズの取得
#--------------------------------------------------------------------------
def get_ruby_size(size)
return [(size + 66) / 8, size * 2 / 3].min
end
#--------------------------------------------------------------------------
# ● ルビ描画
#--------------------------------------------------------------------------
def rubi_draw
# フォントサイズのバックアップ
f_size = self.contents.font.size
# ルビサイズの設定
size = get_ruby_size(f_size)
if @h_window.active
#obj = @h_window
obj = @h_window.contents
else
#obj = self
obj = self.contents
end
#obj.contents.font.size = size
obj.font.size = size
# ルビのテキスト長 / メインテキストのテキスト長の算出
num = @rubi_s / @main_s.to_f
# 一回の描画でどれだけルビを振るか計算
cnt = num.ceil - (num.ceil - num).round
# 描画回数分だけルビの描画
for i in 1..cnt
c = @rubi.slice!(/./m)
rectr = [@rubi_x - 5 - size / 2, @h + @py - size + 3, 10 + size, 6 + size]
#draw_shadow_text(rectr, c, change_color(@color), 1)
draw_shadow_text_root(obj, rectr, c, change_color(@color), 1)
@rubi_x += @rubi_w
@rubi_s -= 1
end
@main_s -= 1
#self.contents.font.size = f_size
obj.font.size = f_size
end
#--------------------------------------------------------------------------
# ● ルビ設定
#--------------------------------------------------------------------------
def rubi_set(main, rubi)
text = main.clone
# \E[n] の場合を考慮する
text2 = text.clone
text2.gsub!(/\030\[([0-9]+)\]/, "■")
text3 = text2.clone
@rubi = rubi.clone
@main_s = 0
@rubi_s = 0
#while(main.slice!(/./m) != nil)
while(text3.slice!(/./m) != nil)
@main_s += 1
end
while(rubi.slice!(/./m) != nil)
@rubi_s += 1
end
f_size = self.contents.font.size
main_w = self.contents.text_size(text2).width
self.contents.font.size = get_ruby_size(f_size)
rubi_w = self.contents.text_size(@rubi).width
if main_w >= rubi_w or @rubi_s == 1
@rubi_x = @x + main_w.to_f / (@rubi_s * 2)
@rubi_w = main_w.to_f / @rubi_s
else
@rubi_x = @x - (rubi_w - main_w - self.contents.font.size) / 2
@rubi_w = rubi_w.to_f / @rubi_s
end
self.contents.font.size = f_size
return text
end
#--------------------------------------------------------------------------
# ● 外字の表示
#--------------------------------------------------------------------------
def letter(i)
pic_v = i / EP_MAX + 1
# ファイルが存在する場合のみ描画を行う。
if FileTest.exist?(DIR_NAME + EP_LIGHT_PIC + pic_v.to_s + EX_C_NAME) ||
FileTest.exist?(DIR_NAME + EP_SHADOW_PIC + pic_v.to_s + EX_C_NAME)
@gaiji_cache = RPG::Cache.picture(EP_LIGHT_PIC + pic_v.to_s)
@gaiji_cache2 = RPG::Cache.picture(EP_SHADOW_PIC + pic_v.to_s)
# 文字サイズを取得
size = self.contents.font.size
# アイコン描画サイズの取得
r_size = get_dis(size)
rectr = [@x, @h + @py + size - EP_SIZE + 5, r_size, r_size]
rect1 = Rect.new( rectr[0], rectr[1], rectr[2], rectr[3])
rect2 = Rect.new(rectr[0]+1, rectr[1]+1, rectr[2], rectr[3])
rect3 = Rect.new(rectr[0]+1, rectr[1]-1, rectr[2], rectr[3])
rect4 = Rect.new(rectr[0]-1, rectr[1]+1, rectr[2], rectr[3])
rect5 = Rect.new(rectr[0]-1, rectr[1]-1, rectr[2], rectr[3])
rect6 = Rect.new(i * EP_SIZE, 0, EP_SIZE, EP_SIZE)
if @h_window.active
#obj = @h_window
obj = @h_window.contents
else
#obj = self
obj = self.contents
end
# 外字データをstretch_bltで転送
list = [rect2, rect3, rect4, rect5]
for cnt in 0...list.size
#obj.contents.stretch_blt(list[cnt], @gaiji_cache2, rect6)
obj.stretch_blt(list[cnt], @gaiji_cache2, rect6)
end
#obj.contents.stretch_blt(rect1, @gaiji_cache, rect6)
obj.stretch_blt(rect1, @gaiji_cache, rect6)
@x += size
end
end
#--------------------------------------------------------------------------
# ● 文字色変更
#--------------------------------------------------------------------------
def c_change
# 文字色を変更
#@text.sub!(/\[(\d+)\]/, "")
@text.sub!(/\[(.+?)\]/, "")
@color = $1
font_color = change_color(@color)
if @h_window.active
#obj = @h_window
obj = @h_window.contents
else
#obj = self
obj = self.contents
end
#obj.contents.font.color = font_color
obj.font.color = font_color
end
#--------------------------------------------------------------------------
# ● 所持金表示
#--------------------------------------------------------------------------
def gold
# ゴールドウィンドウを作成
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
if $OuterFlgs["Window_BG"]
if @bg_sprite != nil
@gold_window.opacity = 160#@bg_sprite.opacity
@gold_window.back_opacity = 200#@bg_sprite.opacity
end
else
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
end
end
#--------------------------------------------------------------------------
# ● 文字サイズ変更
#--------------------------------------------------------------------------
def s_change
# 文字色を変更
@text.sub!(/\[([0-9]+)\]/, "")
@h += self.contents.font.size - $1.to_i
self.contents.font.size = ck_font_size($1.to_i)
end
#--------------------------------------------------------------------------
# ● 行のテキスト幅の取得
#--------------------------------------------------------------------------
def max_width(text)
# 不要な制御文字の削除
text.gsub!(/\001\[\d+\]/) { "" }
text.gsub!(/\002/) { "" }
text.gsub!(/\003\[\d+\]/) { "" }
text.gsub!(/\004/) { "" }
text.gsub!(/\005/) { "" }
text.gsub!(/\006/) { "" }
text.gsub!(/\010/) { "" }
text.gsub!(/\016/) { "" }
text.gsub!(/\017/) { "" }
text.gsub!(/\020/) { "" }
text.gsub!(/\022/) { "" }
text.gsub!(/\023/) { "" }
text.gsub!(/\024/) { "" }
text.gsub!(/\026\[\d+,\d+\]/) { "" }
text.gsub!(/\027\[(.+?),(.+?)\]/) { $1 }
#text.gsub!(/\050\[(.+?)\]/) { $1 }
# 現在のウィンドウ情報を取得
size = self.contents.font.size
bold = self.contents.font.bold
italic = self.contents.font.italic
font_name = self.contents.font.name
width = 0
i = @i
while ((c = text.slice!(/./m)) != nil)
# テキストが \I の場合インデントの設定
if c == "\021"
i = width
if @y >= $game_temp.choice_start
i = width - 8
end
next
end
# \S[n] の場合、フォントサイズの変更
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.size = ck_font_size($1.to_i)
next
end
# \F[n] の場合
if c == "\040"
text.sub!(/\[([0-9]+)\]/, "")
get_font($1.to_i)
next
end
# テキストが\E[i] の場合、外字分だけ幅を増やす
if c == "\030"
text.sub!(/\[(.+?)\]/, "")
#width += RPG::Cache.windowskin("Letter_"+($1.to_i/16).to_s).width / 4
width += get_dis(self.contents.font.size)
next
end
# <B> の場合
if c == "\031"
self.contents.font.bold = true
next
end
# </B> の場合
if c == "\033"
self.contents.font.bold = false
next
end
# <I> の場合
if c == "\034"
self.contents.font.italic = true
next
end
# </I> の場合
if c == "\035"
self.contents.font.italic = false
next
end
width += self.contents.text_size(c).width
end
# 行終了時のウィンドウ情報の格納
e_size = self.contents.font.size
e_bold = self.contents.font.bold
e_italic = self.contents.font.italic
e_name = self.contents.font.name
# ウィンドウ情報を元に戻す
self.contents.font.size = size
self.contents.font.bold = bold
self.contents.font.italic = italic
self.contents.font.name = font_name
return [width, i, e_size, e_bold, e_italic, e_name]
end
#--------------------------------------------------------------------------
# ● 文章全体の幅の取得
#--------------------------------------------------------------------------
def text_width(sentence)
# 現在のウィンドウ情報を取得
size = self.contents.font.size
bold = self.contents.font.bold
italic = self.contents.font.italic
name = self.contents.font.name
i = @i
x = @x
# 文章幅の取得開始
text = sentence.clone
width = 0
# \A[n,m] の場合
if text[/\026/]
text.sub!(/\026\[(\d+),(\d+)\]/, "")
actor($1.to_i, $2.to_i, false)
width = @x
end
cnt = 0
while text != ""
t_width = max_width(text[/^.*?\n/])
# 選択肢だった場合は幅に32加算する
t_width[0] += 20 if cnt >= $game_temp.choice_start
width = [width, @i + t_width[0]].max
# ウィンドウ情報を更新して次の行へ
@i = t_width[1]
self.contents.font.size = t_width[2]
self.contents.font.bold = t_width[3]
self.contents.font.italic = t_width[4]
self.contents.font.name = t_width[5]
text.sub!(/^.*?\n/) {""}
cnt += 1
end
# ウィンドウ情報を元に戻す
self.contents.font.size = size
self.contents.font.bold = bold
self.contents.font.italic = italic
self.contents.font.name = name
@i = i
@x = x
return width + @fi + 4
end
#--------------------------------------------------------------------------
# ● 行の最大テキスト高さを求める
#--------------------------------------------------------------------------
def max_height(sentence)
text = sentence[/(.+?)\n/]
t_size = 0
# テキストが空になるまで繰り返し
while text != "" and text != nil
c = text.slice!(/./m)
# テキストが \C[n] か \S[n] の場合次のテキストへ
if c == "\001" or c == "\003"
text.sub!(/\[([0-9]+)\]/, "")
next
end
# アクターグラフィックの場合次のテキストへ
if c == "\026"
text.sub!(/\[(\d+),(\d+)\]/, "")
next
end
# \F[n] の場合
if c == "\040"
text.sub!(/\[([0-9]+)\]/, "")
get_font($1.to_i)
next
end
# テキストが\E[i] の場合
if c == "\030"
text.sub!(/\[(.+?)\]/, "")
#p_height = RPG::Cache.windowskin("Letter_"+($1.to_i/16).to_s).height/4
#l_height = [((p_height + 1) * 8 - 66) / 9, (p_height + 1) * 3 / 5].max
p_height = get_dis(self.contents.font.size)
t_size = [t_size, p_height].max
next
end
# テキストが \S[n] の場合、最大テキスト高さに n を代入
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
t_size = [t_size, ck_font_size($1.to_i)].max
end
# 最大テキスト高さが0の場合、現在のフォントサイズを代入
t_size = self.contents.font.size if t_size == 0
end
return t_size
end
#--------------------------------------------------------------------------
# ● 文章全体の高さを求める
#--------------------------------------------------------------------------
def text_height(sentence)
# 高さ・ルビ分の高さを初期化
h = 0
size = self.contents.font.size
text = sentence.clone
if text[/^.*?\n/][/\027/]
py = get_ruby_size(max_height(text)) - 5
#elsif text[/^.*?\n/][/\050/]
# py = get_ruby_size(max_height(text)) - 5
else
py = 0
end
# 文章の総合高さを計算
while text != ""
# 現在の行の高さを計算
height = max_height(text)
# 総高さに現在の行の高さを加算
h += height + get_ruby_size(height) - 1
# \S[n] の場合、フォントサイズの変更
if text[/^.*?\n/][/.*\025\[(\d+)\]/]
self.contents.font.size = ck_font_size($1.to_i)
end
# 次の行へ
text.sub!(/^.*?\n/) {""}
end
self.contents.font.size = size
# 文章全体の高さを返す
return h
end
#--------------------------------------------------------------------------
# ● 改行
#--------------------------------------------------------------------------
def new_line
# 選択肢ならカーソルの幅を更新
font_name = self.contents.font.name
if @h_window.active == false and @y >= $game_temp.choice_start
@cursor_width = [@cursor_width, @x].max
end
# y に 1 を加算
@y += 1
# 次の行の最大テキスト高さ + ルビ分の字下げ
height = max_height(@text)
@h += height + get_ruby_size(height) - 1
@x = @fi + @i
# 選択肢なら字下げを行う
if @h_window.active == false and @y >= $game_temp.choice_start
@x = 8 + @fi + @i
# ルビ付きの場合、字下げを行う
text = @text[/^.*?\n/]
font_size = self.contents.font.size
r_height = 0
while text != "" and text != nil
c = text.slice!(/./m)
# \S[n] の場合、フォントサイズの変更
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
font_size = ck_font_size($1.to_i)
next
end
# ルビが存在した場合
if c == "\027"
text.sub!(/\[(.+?),(.+?)\]/, "")
# ルビのテキストサイズを格納
r_height = [r_height, font_size].max
next
end
# ルビ定型句が存在した場合
#if c == "\050"
# text.sub!(/\[(.+?)\]/, "")
# # ルビのテキストサイズを格納
# r_height = [r_height, font_size].max
# next
#end
# \F[n] の場合
if c == "\040"
text.sub!(/\[([0-9]+)\]/, "")
get_font($1.to_i)
next
end
end
# 字下げの設定
@py = [(r_height + get_ruby_size(r_height) - 5) - max_height(@text), 0].max
end
self.contents.font.name = font_name
# 次の文字へ
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# メッセージ履歴の呼び出し
if @h_window.active == false and (@contents_showed or
$game_system.map_interpreter.running? == false) and
(Input.trigger?(Input::L) or Input.trigger?(Input::R)) and
not $game_player.message_history.empty?
history_start
$his_flg = true
end
if @h_window.active
if @h_window.opacity < MAX8BIT
@h_window.contents_opacity += 24
@h_window.opacity += 24
@bar.opacity += 24
return
end
history_update
return
end
# メッセージ履歴消去中の場合
if @h_window.opacity > 0
# 透過度を増やす
@h_window.opacity -= 48
@h_window.contents_opacity -= 48
@bar.opacity -= 48
# メッセージ履歴が完全透過状態になった場合
if @h_window.opacity == 0
@h_window.hide
@h_window.contents.dispose
@bar.bitmap.dispose
@bar.dispose
if @contents_showed == false
$game_temp.message_window_showing = false
end
end
return
end
super
# 吹き出し表示の場合、ウィンドウ位置設定
window_position if @event != nil
# ウィンドウ枠非表示の場合、背景画像を一旦非表示にする
if $OuterFlgs["Window_BG"] && $game_system.message_frame != 0
#if @bg_sprite != nil
@bg_sprite.visible = false
#end
end
# フェードインの場合
if @fade_in
if $OuterFlgs["Window_BG"]
if @bg_sprite != nil
@bg_sprite.opacity += 24
end
else
self.contents_opacity += 24
end
@face.opacity += 24 if FADE
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if ($OuterFlgs["Window_BG"] && @bg_sprite != nil &&
@bg_sprite.opacity >= MAX_OPA) ||
(!$OuterFlgs["Window_BG"] && self.contents_opacity >= MAX_OPA)
@fade_in = false
end
end
# 数値入力中の場合
if @input_number_window != nil
@input_number_window.update
# 決定
if Input.trigger?(Input::C)
if @push_enter
self.pause = false
@push_enter = false
@contents_showed = false
return
end
Sound.play_ok
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
# 数値入力ウィンドウを解放
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
# メッセージ表示中の場合
if @contents_showing and @contents_showed == false
if (ENTER and Input.trigger?(Input::C)) or
(SHIFT >= ($DEBUG ? 0 : 1) and Input.press?(Input::SHIFT))
@wait = 0
end
if @wait > 0
@wait -= 1
return if @wait > 0
end
refresh
return
end
# メッセージ表示終了の場合
if @contents_showed
# 選択肢の表示中でなければポーズサインを表示
if $game_temp.choice_max == 0
self.pause = true
end
# キャンセル
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
Sound.play_cancel
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
end
# 決定
if Input.trigger?(Input::C)
if @push_enter
self.pause = false
@push_enter = false
@contents_showed = false
return
end
if $game_temp.choice_max > 0
Sound.play_ok
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
if SHIFT == 2 and Input.press?(Input::SHIFT) and $game_temp.choice_max == 0
if @push_enter
self.pause = false
@push_enter = false
@contents_showed = false
return
end
terminate_message
end
if @contents_close and $game_temp.choice_max == 0
if $game_temp.choice_max > 0
Sound.play_ok
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
return
end
# フェードアウト中以外で表示待ちのメッセージか選択肢がある場合
if @fade_out == false and $game_temp.message_text != nil
@contents_showing = true
$game_temp.message_window_showing = true
reset_window
text_initialize
self.visible = true
if $OuterFlgs["Window_BG"]
if @bg_sprite != nil
@bg_sprite.opacity = 0
end
else
self.contents_opacity = 0
end
@face.bitmap.clear
@face.visible = true
if FADE
@face.opacity = 0
else
@face.opacity = MAX8BIT
end
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
@fade_in = true
refresh
Graphics.frame_reset
return
end
# 表示すべきメッセージがないが、ウィンドウが可視状態の場合
if self.visible
@fade_out = true
if $OuterFlgs["Window_BG"]
if @bg_sprite != nil
@bg_sprite.opacity -= 48
end
else
self.opacity -= 48
end
@face.opacity -= 48
if ($OuterFlgs["Window_BG"] && @bg_sprite != nil &&
@bg_sprite.opacity == 0) ||
(!$OuterFlgs["Window_BG"] && self.opacity == 0)
# ウィンドウ枠を表示する場合
if $OuterFlgs["Window_BG"] && @bg_sprite != nil
@bg_sprite.visible = false
else
@bg_sprite.visible = true
end
self.visible = false
@face.visible = false
@fade_out = false
$game_temp.message_window_showing = false
end
return
end
end
#--------------------------------------------------------------------------
# ● メッセージ履歴テキスト格納
#--------------------------------------------------------------------------
def history_write(text)
# メッセージ履歴に不要な制御文字の削除
text.gsub!(/\002/) { "" }
text.gsub!(/\003\[\d+\]/) { "" }
text.gsub!(/\004/) { "" }
text.gsub!(/\005/) { "" }
text.gsub!(/\006/) { "" }
text.gsub!(/\010/) { "" }
text.gsub!(/\016/) { "" }
text.gsub!(/\017/) { "" }
text.gsub!(/\020/) { "" }
text.gsub!(/\026\[\d+,\d+\]/) { "" }
# メッセージ履歴の初期化
unless $game_player.message_history.is_a?(Array)
$game_player.history_size = HISTORY_SIZE
$game_player.message_history = []
end
# 現在のテキストをメッセージ履歴に格納
$game_player.message_history.push([text, text_height(text)])
# メッセージ履歴のサイズが大きい場合、最初の方より履歴を削除
if $game_player.message_history.size > $game_player.history_size
$game_player.message_history.shift
end
end
#--------------------------------------------------------------------------
# ● メッセージ履歴テキスト描画
#--------------------------------------------------------------------------
def history_refresh
# 描画範囲に何もかかれていない場合、メッセージ履歴の描画を行う
while (@h >= @h_window.oy and @h != 0)
# 初期設定
@text = $game_player.message_history[@index][0].clone
h = @h
self.contents.font.size = Font.default_size
self.contents.font.color = normal_color
self.contents.font.bold = false
self.contents.font.italic = false
self.contents.font.name = Font.default_name
@rubi = ""
@x = @i = 4
@fi = @y = 0
@h += max_height(@text) - self.contents.font.size - text_height(@text)
# ルビ付きの場合、字下げを行う
text = @text[/^.*?\n/]
font_size = self.contents.font.size
r_height = 0
while ((c = text.slice!(/./m)) != nil)
# \S[n] の場合、フォントサイズの変更
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
font_size = ck_font_size($1.to_i)
next
end
# ルビが存在した場合
if c == "\027"
text.sub!(/\[(.+?),(.+?)\]/, "")
# ルビのテキストサイズを格納
r_height = [r_height, font_size].max
next
end
# ルビ定型句が存在した場合
#if c == "\050"
# text.sub!(/\[(.+?)\]/, "")
# # ルビのテキストサイズを格納
# r_height = [r_height, font_size].max
# next
#end
# \F[n] の場合
if c == "\040"
text.sub!(/\[([0-9]+)\]/, "")
get_font($1.to_i)
next
end
end
# 字下げの設定
@py = [(r_height + get_ruby_size(r_height) - 5) - max_height(@text), 0].max
# c に 1 文字を取得 (文字が取得できなくなるまでループ)
while ((c = @text.slice!(/./m)) != nil)
# \F[n] の場合
if c == "\040"
@text.sub!(/\[([0-9]+)\]/, "")
self.contents.font.name = change_font($1.to_i)
next
end
next unless control(c)
# 文字を描画
size = self.contents.font.size
@h_window.contents.font.size = size
@h_window.contents.font.bold = self.contents.font.bold
@h_window.contents.font.italic = self.contents.font.italic
@h_window.contents.font.name = self.contents.font.name
#@h_window.contents.draw_text(@x, @h + @py, 10 + size, 10 + size, c)
rectr = [@x, @h + @py, 10 + size, 10 + size]
#draw_shadow_text(rectr, c, change_color(@color))
draw_shadow_text_root(@h_window.contents, rectr, c, change_color(@color))
# x に描画した文字の幅を加算
@x += @h_window.contents.text_size(c).width
rubi_draw if @rubi != ""
end
@h = h - text_height($game_player.message_history[@index][0])
@index -= 1
end
end
#--------------------------------------------------------------------------
# ● メッセージ履歴呼び出し
#--------------------------------------------------------------------------
def history_start
# メッセージ履歴初期化設定
$game_temp.message_window_showing = true
@h_window.activate
@h_window.show
# メッセージ履歴の最終行より、どれだけ描画できるか計算を行う
@h = 0
for history in $game_player.message_history
@h += history[1]
end
# メッセージ履歴描画矩形の作成
@h_window.contents = Bitmap.new(@h_window.width - 32, @h)
@h_window.opacity = 0
@h_window.contents_opacity = 0
@h_window.contents.fill_rect(
@h_window.width - 38, 0, 6, @h, Color.new(0, 0, 0, HARF8BIT))
@h_window.oy = [@h - (@h_window.height - 32), 0].max
# メッセージ履歴サイドバーの作成
@bar = Sprite.new(self.viewport)
height = [(@h_window.height - 32) ** 2 / @h, @h_window.height - 32].min
@bar.x = @h_window.x + @h_window.width - 22
@bar.y = @h_window.y + @h_window.height - 16 - height
@bar.z = 10003
@bar.opacity = 0
@bar.bitmap = Bitmap.new(6, height)
@bar.bitmap.fill_rect(0, 0, 6, height, Color.new( 16, 32, 64, 224))
@bar.bitmap.fill_rect(0, 0, 5, height - 1, Color.new( 32, 64, 128, 224))
@bar.bitmap.fill_rect(1, 1, 4, height - 2, Color.new(128, 224, 255, 255))
@bar.bitmap.fill_rect(1, 1, 3, height - 3, Color.new(192, 255, 255, 255))
@bar.bitmap.fill_rect(2, 2, 2, height - 4, Color.new( 32, 64, 128, 192))
@bar.bitmap.fill_rect(3, 3, 1, height - 5, Color.new( 48, 96, 192, 192))
@scroll_height = @h
# メッセージ履歴描画情報の初期設定
@index = $game_player.message_history.size - 1
# メッセージ履歴描画
history_refresh
end
#--------------------------------------------------------------------------
# ● メッセージ履歴フレーム更新
#--------------------------------------------------------------------------
def history_update
@h_window.update
# 十字キーの上が押下された場合
if Input.press?(Input::UP)
# ウィンドウ上方向にスクロール
@h_window.oy = [@h_window.oy - 8, 0].max
end
# 十字キーの下が押下された場合
if Input.press?(Input::DOWN)
# ウィンドウ下方向にスクロール
@h_window.oy = [[@h_window.oy + 8,
@h_window.contents.height - (@h_window.height - 32)].min, 0].max
end
# 十字キーの左が押下された場合
if Input.press?(Input::LEFT)
# ウィンドウ上方向に大きくスクロール
@h_window.oy = [@h_window.oy - 32, 0].max
end
# 十字キーの右が押下された場合
if Input.press?(Input::RIGHT)
# ウィンドウ下方向に大きくスクロール
@h_window.oy = [[@h_window.oy + 32,
@h_window.contents.height - (@h_window.height - 32)].min, 0].max
end
# L ボタンが押下された場合
if Input.press?(Input::L)
# ウィンドウ上方向に大きくスクロール
@h_window.oy = [@h_window.oy - 96, 0].max
end
# R ボタンの右が押下された場合
if Input.press?(Input::R)
# ウィンドウ下方向に大きくスクロール
@h_window.oy = [[@h_window.oy + 96,
@h_window.contents.height - (@h_window.height - 32)].min, 0].max
end
# スクロールバーの移動
@bar.y = 16 + @h_window.y +
((@h_window.height - 32) * @h_window.oy / @scroll_height.to_f).ceil
# メッセージ履歴の更新
history_refresh
if Input.trigger?(Input::B)
@h_window.deactivate
$his_flg = false
end
end
=begin
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
n = @c_w + @py - ($game_temp.choice_max - 1) * 32
self.cursor_rect.set(8, n + @index * 32, @cursor_width, 32)
else
self.cursor_rect.empty
end
end
=end
end
|