#==============================================================================
# draw_text拡張 カスタム By 貪藻矢射妥←
#------------------------------------------------------------------------------
# 原作: 文字描画拡張 Ver1.00 (更新:2007.05.19)
# 図鑑コメント機能追加(基本)
# 原作者: momomo様、かつおぶし様
# HP: momomomo?
# アドレス: http://f53.aaa.livedoor.jp/~momomo/
#
# 改造内容:
# ・図鑑コメント機能の文字描画機能を別モジュール化
# ・制御文字の変更(個人的)
# ・アイコン+テキスト描画の文字サイズ変更時の対応
# ・ピクチャー/バトラー/キャラクター表示の後幅分x座標をずらす対応
#
# ※このモジュールを導入していれば冒険日記の
# class Window_Base < Window
# の中身をinclude RUBY_SYSだけにできます。
#
# 使用制御文字一覧
#
# \n[ID] : "ID"番のアクターの名前を表示します。
# \v[ID] : 変数 "ID"番の値を表示します。
# \vn[ID] : 変数 "ID"番に付いた名前を表示します。
# \s[ID,ON文字列,OFF文字列]
# : スイッチ "ID"番がONかOFFかでどちらかに置き換える。
# \sn[ID] : スイッチ "ID"番に付いた名前を表示します。
# \c[num] : フォントカラーを変更します。(Window_Baseのtext_colorの番号)
# \c[s] : フォントカラーを変更します。(システムカラー)
# \c[c] : フォントカラーを変更します。(クライシスカラー)
# \c[k] : フォントカラーを変更します。(ノックアウトカラー)
# \b : ボールド表示。(トグル式)
# \i : イタリック体表示。(トグル式)
# \g : 所持金を表示します。
# \lt : その行を左寄せ表示に戻します。
# \rt : その行を右寄せ表示にします。
# \ct : その行を中央寄せ表示にします。
# \o[ope] : 不透明度を変更します。(0〜255)
# \s[size] : フォントサイズを変更します。(6〜32)
# \r[text,ruby] : ルビ付きの文字を表示します。
# \rfix[text] : textに割りつけられているルビを表示します
# \e[num] : 外字を表示します。(0〜x)
# \f[num] : ドローフォントを変更します。(0〜x)
# \i[ID] : "ID"番のアイテムをアイコン付で表示します。
# \w[ID] : "ID"番の武器をアイコン付で表示します。
# \a[ID] : "ID"番の防具をアイコン付で表示します。
# \j[ID] : "ID"番のスキルをアイコン付で表示します。
# \en[ID] : "ID"番のエネミーの名前を表示します。
# \cls[ID] : "ID"番のクラスの名前を表示します。
# \m[ID] : "ID"番のマップの名前を表示します。
# \pic[x,y,filename]
# : ピクチャーにインポートされた画像を表示します。
# \spic[x1,y1,w1,h1,filename,x2,y2,w2,h2]
# : ピクチャーにインポートされた画像を Rect.new(x2,y2,w2,h2)
# から Rect.new(x1,y1,w1,h1) に転送表示します。
# \bat[x,y,filename,hue]
# : バトラーにインポートされた画像を表示します。
# \cha[x,y,filename,hue,向き,パターン]
# : キャラクターにインポートされた画像を表示します。
# ※向き → テンキーの配置と同じ、下2左4右6上8
# パターン → 1〜4
#
# ※\c[n](テキストカラーをノーマルカラーへ)は\c[0]と同じ(default)なので削除。
# ※外字表示とテキストの純粋な幅の取得に関しては
# 歯車の城:メッセージ制御文字追加 Ver 1.18 カスタム
# を参考にしています。
#
#==============================================================================
# 変更履歴
# 2009:05:07
# ・外字ファイルが存在しない場合何も描画しないように処理を追加
#
# 2009:09:14
# ・draw_ex用色変え削除をRUBY_SYSからDRAW_MSGに移動
#
# 2009:11:21
# ・self.contentsのみしか使用できなかったものを拡張
#
# 2010:03:27
# ・\en[n]でエネミーの名称を表示可能に
# ・\cls[n]でクラスの名称を表示可能に
# ・\m[n]でマップの名称を表示可能に
#
# 2011:06:04
# ・ピクチャーの表示を拡張
#
# 2011:07:01
# ・○ フォント変更 にてwhen 0 はデフォルト同じなので削除
#
# 2012:01:21
# ・定型句ルビ実装
#
# 2024:03:01
# ・Windows10などでデフォルトでインストールされているフォントが減ったので
# フォント変更のフォントを変更
# Windows8などからもってこられればあるいは・・・
#
# 2024:05:01
# ・固定文字列対応
module DRAW_MSG
# 最小フォントサイズ
FONT_SIZE_MIN = 6
# 最大フォントサイズ
FONT_SIZE_MAX = 32
# 外字1つのサイズ
EP_SIZE = 24
# 外字ファイル1つの最大外字個数
EP_MAX = 8
# 外字ファイル名(基本)
EP_LIGHT_PIC = "gaiji_"
# 陰文字外字ファイル名(基本)
EP_SHADOW_PIC = "gaiji_s_"
# インポート先ディレクトリネーム
DIR_NAME = "Graphics/Pictures/"
# 外字ファイル拡張子
EX_C_NAME = ".png"
# ルビ定型句セット
FIX_RUBY = {
"開封" => "かいほう",
"綺羅神無" => "らじんきむ",
"応龍" => "おうりゅう",
"齎" => "もたら",
"麒麟" => "キリン",
"霊龜" => "れいき",
"素盞嗚尊" => "スサノオノミコト",
"燭龍" => "しょくりゅう",
"月陽歳刑" => "つきかげさいぎょう",
"歳星黄幡" => "さいせいおうばん",
"天下太陰" => "てんげだいおん",
"元屠歳殺" => "げんとさいさつ" ,
"天蓋流剣鞘" => "てんがいりゅうけんしょう",
"絳征" => "こうせい",
"炎一刀" => "ほむらいっとう",
"虹影" => "にじかげ",
"誘薙双剣" => "いざなぎそうけん",
"天狼碎牙" => "てんろうさいが",
"天狼真牙" => "てんろうしんが",
"穀蔵院一刀" => "こくぞういんいっとう",
"愛染" => "あいぜん",
"舞雅" => "むげ",
"雅閃" => "がせん",
"秘雅閃" => "ひがせん",
"極雅閃" => "きょくがせん",
"終雅閃" => "しゅうがせん",
"黎淵夢" => "くろきふちのゆめ",
"夢刃" => "むじん",
"示現流瞬槍" => "じげんりゅうしゅんそう",
"黎杭打刳撃" => "パイルドライバー",
"逆転黎杭打刳撃" => "リバース・パイルドライバー",
"回転黎杭打刳撃" => "スピニング・パイルドライバー",
"跳躍黎杭打刳撃" => "ジャンピング・パイルドライバー",
"旋抉黎杭打刳撃" => "スクリュー・パイルドライバー",
"削岩錐穴黎杭打刳撃" => "ドリル・ア・ホール・パイルドライバー",
"被覆鋼弾" => "フルメタルジャケット",
"撤甲弾" => "アーマーピアシング",
"炸 裂 弾" => "エクスプロージョンブリット",
"黒き猛禽の爪" => "ブラックタロン",
"鵺帛主" => "ヤヌス",
"王宮一級品" => "ロイヤルコレクション",
"零道漓" =>"プルウィウス",
" 真 " => "チェンジ!!",
"殺形刀" => "サルヒヨンド",
" S D " => "SEED DESTINY",
"天国" => "あまくに",
"碧聖刃" => "シアンセイクレド",
" S T " => "シャイニング・トラペゾヘドロン",
"保護陰盾" => "プロテクトシェード",
"蘭花" => "ランファ",
" AT " => "アナザータイプ",
"夢龍" => "モンリョン",
"春香" => "チュンヒャン",
"文秀" => "ムンス",
"元述" => "ウォンスル",
"英實" => "ヨンシル",
"暗行御史" => "アメンオサ",
"山道" => "サンド",
"朱羅姫" => "シュラキ",
"奠夷瑪" => "ディーヴァ",
"女王禍" => "ジョーカー",
"茜瑙哭" => "セドナ",
"爾幽樟" => "ニュクス",
"刺舞鴉" => "シヴァ",
"逢喇且雫" => "アフラ・マズダ",
"槃導邏" => "パンドラ",
"霹瓏婚枢" => "ペルクナス",
"炳佩鍍嵩" => "ヘパイトス",
"靉颪栖" => "アイオロス",
"宕瓏牙" => "ドゥルガー",
"微朱主" => "ヴィシュヌ",
"魔血玉" => "デモンブラッド",
"呪符" => "タリズマン",
"閣氏" => "カクシ",
"歳殺陽天" => "さいさつようてん",
"歳刑星天" => "さいぎょうせいてん",
"黄幡暗天" => "おうばんあんてん",
"太陰邪天" => "だいおんじゃてん",
"陰轟留牡鴉" => "アンゴルモア",
"緋々色金" => "ヒヒイロカネ",
"青生生魂" => "アボイタカラ",
"楼蘭" => "ロウラン",
"泱硫堕" => "オルクス",
"場違いな白き遺物" => "ポジティヴ・オーパーツ",
"場違いな黒き遺物" => "ネガティヴ・オーパーツ",
"場違いな影の遺物" => "シルエット・オーパーツ",
}
#--------------------------------------------------------------------------
# ○ アイコン描画サイズ取得
#--------------------------------------------------------------------------
# アイコンのデフォルトサイズは24でテキストのデフォルトサイズは22なので、
# テキストのサイズが変わり次第アイコンの描画サイズも比例変形させる。
#--------------------------------------------------------------------------
def get_dis(size)
return (EP_SIZE.to_f * size.to_f / Font.default_size.to_f).to_i
end
#--------------------------------------------------------------------------
# ● 文字色取得 拡張
# n : 文字色番号 (0〜) または s,c,k
# ※存在しないものを指定した場合はノーマルカラーが設定されます。
#--------------------------------------------------------------------------
def change_color(n)
if n.to_i.to_s == n
return text_color(n.to_i)
else
case n
when 's'
return system_color
when 'c'
return crisis_color
when 'k'
return knockout_color
else
return normal_color
end
end
end
#--------------------------------------------------------------------------
# ○ フォント変更
# n : フォント番号 (0〜)
# ※存在しないものを指定した場合はデフォルトフォントが設定されます。
#--------------------------------------------------------------------------
def change_font(n)
ms_mincho = "MS P明朝"
case n
when 1
return ms_mincho
when 2
return ["HG行書体", "メイリオ", Font.default_name]
when 3
return ["HGP創英角ポップ体", "UD デジタル 教科書体 NP-R", Font.default_name]
when 4
return ["HG丸ゴシックM-PRO", "BIZ UDPゴシック", Font.default_name]
when 5
return ["HG正楷書体-PRO", "BIZ UDP明朝", ms_mincho]
when 6
return ["HGP創英プレゼンスEB", "游ゴシック", Font.default_name]
when 7
return ["麗流隷書", "游明朝", ms_mincho]
when 8
return ["江戸勘亭流P", "Yu Gothic UI", Font.default_name]
when 9
return ["富士ポップP", "Meiryo UI", Font.default_name]
else
return Font.default_name
end
end
#--------------------------------------------------------------------------
# ○ フォントサイズチェック
# フォントサイズをFONT_SIZE_MINからFONT_SIZE_MAXの間にまるめこみます。
#--------------------------------------------------------------------------
def ck_font_size(size)
return [[size, FONT_SIZE_MIN].max, FONT_SIZE_MAX].min
end
#--------------------------------------------------------------------------
# ● draw_ex用色変え削除
#--------------------------------------------------------------------------
def del_change_color(text)
if text != nil
bl_text = text.clone
bl_text.gsub!(/\001\[(.+?)\]/) {""}
return bl_text
else
return text
end
end
end
module RUBY_SYS
include DIAMOND
include BM
include DRAW_MSG
#--------------------------------------------------------------------------
# ● 文字列変換
#--------------------------------------------------------------------------
def transfer(str)
#p str
text = str.clone
# 制御文字処理
begin
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end
# アクター名に置き換え
text.gsub!(/\\[Nn]\[([0-9]+)\]/) 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
# 変数名に置き換え
text.gsub!(/\\[Vv]n\[([0-9]+)\]/) do
value_name = $data_system.variables[$1.to_i]
value_name != nil ? value_name : ""
#$data_system.variables[$1.to_i] != nil ? $data_system.variables[$1.to_i] : ""
end
# スイッチ名に置き換え
text.gsub!(/\\[Ss]n\[([0-9]+)\]/) do
sw_name = $data_system.switches[$1.to_i]
sw_name != nil ? sw_name : ""
#$data_system.switches[$1.to_i] != nil ? $data_system.switches[$1.to_i] : ""
end
# スイッチの状態でどちらかに置き換える
text.gsub!(/\\[Ss]w\[(.+?),(.+?),(.+?)\]/) do
$game_switches[$1.to_i] ? $2 : $3
end
# 便宜上、"\\\\" を "\000" に変換
text.gsub!(/\\\\/) { "\000" }
# "\\C" を "\001" に、"\\G" を "\002" に変換
#text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Cc]\[(.+?)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
# 不透明度
text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\200[#{$1}]" }
# 文字サイズ
text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\201[#{$1}]" }
# ルビ
text.gsub!(/\\[Rr]\[(.+?),(.+?)\]/) { "\202[#{$1},#{$2}]" }
# 定型句ルビ
text.gsub!(/\\[Rr]fix\[(.+?)\]/) { "\205[#{$1}]" }
# 外字
text.gsub!(/\\[Ee]\[([0-9]+)\]/) { "\203[#{$1}]" }
# フォント
text.gsub!(/\\[Ff]\[([0-9]+)\]/) { "\204[#{$1}]" }
# アイテム(アイコン付)
text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\220[#{$1}]" }
# 武器(アイコン付)
text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\221[#{$1}]" }
# 防具(アイコン付)
text.gsub!(/\\[Aa]\[([0-9]+)\]/) { "\222[#{$1}]" }
# スキル(アイコン付)
text.gsub!(/\\[Jj]\[([0-9]+)\]/) { "\223[#{$1}]" }
# ピクチャ表示
text.gsub!(/\\[Pp]ic\[([0-9]+),([0-9]+),([^,\]]+)\]/) {
"\250[#{$1},#{$2},#{$3}]" }
# ピクチャ転送表示
text.gsub!(/\\[Ss]pic\[([0-9]+),([0-9]+),([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+)\]/) {
"\253[#{$1},#{$2},#{$3},#{$4},#{$5},#{$6},#{$7},#{$8},#{$9}]" }
# バトラー表示
text.gsub!(/\\[Bb]at\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/) {
"\251[#{$1},#{$2},#{$3},#{$4}]" }
# キャラグラフィック表示
text.gsub!(/\\[Cc]ha\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/) {
"\252[#{$1},#{$2},#{$3},#{$4},#{$5},#{$6}]" }
text.gsub!(/\\p(.*?)\n/) { $1 }
text.gsub!(/\\[Bb]/) { "\260" }
text.gsub!(/\\[Ii]/) { "\261" }
# 改行
text.gsub!(/\\[Nn]/) { "\n" }
return text
end
#--------------------------------------------------------------------------
# ● 変換した文字列を描画 (self.contents Ver.)
#--------------------------------------------------------------------------
def draw_ex_text(ox, oy, str, align = 0, mltdrw = false)
draw_ex_text_root(self.contents, ox, oy, str, align = 0, mltdrw)
end
#--------------------------------------------------------------------------
# ● 変換した文字列を描画 (汎用 Ver.)
#--------------------------------------------------------------------------
def draw_ex_text_root(root, ox, oy, str, align = 0, mltdrw = false)
text = str.clone
x = 0
y = 0
# c に 1 文字を取得 (文字が取得できなくなるまでループ)
while ((c = text.slice!(/./m)) != nil)
# \\ の場合
if c == "\000"
# 本来の文字に戻す
c = "\\"
end
# \C[n] の場合
if c == "\001"
# 文字色を変更
#text.sub!(/\[([0-9]+)\]/, "")
text.sub!(/\[(.+?)\]/, "")
color = $1
root.font.color = change_color(color)
# 次の文字へ
next
end
# \G の場合
if c == "\002"
# 所持ゴールドに変換
c = $game_party.gold.to_s
# 文字を描画
root.draw_text(ox+4+x, oy+4+ 32 * y, root.text_size(c).width, 32, c)
# x に描画した文字の幅を加算
x += root.text_size(c).width
# 次の文字へ
next
end
# \O の場合
if c == "\200"
text.sub!(/\[([0-9]+)\]/, "")
opacity = $1.to_i
temp = root.font.color.clone
temp.alpha = opacity
root.font.color = temp
# 次の文字へ
next
end
# \S の場合
if c == "\201"
text.sub!(/\[([0-9]+)\]/, "")
root.font.size = ck_font_size($1.to_i)
# 次の文字へ
next
end
# \R の場合
if c == "\202"
text.sub!(/\[(.+?),(.+?)\]/, "")
x += ruby_set(root, ox + x, oy + (y * 32), $1, $2)
# 次の文字へ
next
end
# \Rfix の場合
if c == "\205"
text.sub!(/\[(.+?)\]/, "")
tmp_st = $1
tmp_rb = FIX_RUBY[$1]
x += ruby_set(root, ox + x, oy + (y * 32), tmp_st, tmp_rb)
# 次の文字へ
next
end
# \ Eの場合
if c == "\203"
text.sub!(/\[([0-9]+)\]/, "")
gaiji_val = $1.to_i
fs = root.font.size - 22
# 外字を表示
x += letter(root, ox + x + 4, oy + fs / 2 + y + 4, gaiji_val, mltdrw)
next
end
# \F[n] の場合
if c == "\204"
text.sub!(/\[([0-9]+)\]/, "")
font_val = $1.to_i
#get_font(font_val)
root.font.name = change_font(font_val)
next
end
# \I の場合
if c == "\220"
text.sub!(/\[([0-9]+)\]/, "")
item = $data_items[$1.to_i]
fs = root.font.size - 22
x += set_icon(root, ox + x + 4, oy + fs / 2 + y + 4, item, mltdrw)
# 次の文字へ
next
end
# \W の場合
if c == "\221"
text.sub!(/\[([0-9]+)\]/, "")
weapon = $data_weapons[$1.to_i]
fs = root.font.size - 22
x += set_icon(root, ox + x + 4, oy + fs / 2 + y + 4, weapon, mltdrw)
# 次の文字へ
next
end
# \A の場合
if c == "\222"
text.sub!(/\[([0-9]+)\]/, "")
armor = $data_armors[$1.to_i]
fs = root.font.size - 22
x += set_icon(root, ox + x + 4, oy + fs / 2 + y + 4, armor, mltdrw)
# 次の文字へ
next
end
# \J の場合
if c == "\223"
text.sub!(/\[([0-9]+)\]/, "")
skill = $data_skills[$1.to_i]
fs = root.font.size - 22
x += set_icon(root, ox + x + 4, oy + fs / 2 + y + 4, skill, mltdrw)
# 次の文字へ
next
end
# \Pic の場合
if c == "\250"
text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+)\]/, "")
ope = root.font.color.alpha
x += set_picture(root, $1.to_i, $2.to_i, $3, ope)
# 次の文字へ
next
end
# \Spic の場合
if c == "\253"
text.sub!(/\[([0-9]+),([0-9]+),([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+)\]/, "")
ope = root.font.color.alpha
x += set_s_picture(root, $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5,
$6.to_i, $7.to_i, $8.to_i, $9.to_i, ope)
# 次の文字へ
next
end
# \Bat の場合
if c == "\251"
text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+)\]/, "")
ope = root.font.color.alpha
x += set_battler(root, $1.to_i, $2.to_i, $3, $4.to_i, ope)
# 次の文字へ
next
end
# \Cha の場合
if c == "\252"
text.sub!(/\[([0-9]+),([0-9]+),([^,\]]+),([0-9]+),([0-9]+),([0-9]+)\]/, "")
ope = root.font.color.alpha
x += set_character(root, $1.to_i, $2.to_i, $3, $4.to_i, $5.to_i,
$6.to_i, ope)
# 次の文字へ
next
end
# \B
if c == "\260"
root.font.bold ^= true
next
end
# \I
if c == "\261"
root.font.italic ^= true
next
end
# 改行文字の場合
if c == "\n"
# y に 1 を加算
y += 1
x = 0
# 次の文字へ
next
end
# 文字を描画
root.draw_text(ox + 4 + x, oy+ 32 * y, 40, 32, c)
# x に描画した文字の幅を加算
x += root.text_size(c).width
if @gaiji_cache != nil and not @gaiji_cache.disposed?
@gaiji_cache.dispose
end
if @gaiji_cache2 != nil and not @gaiji_cache2.disposed?
@gaiji_cache2.dispose
end
end
end
#--------------------------------------------------------------------------
# ● フォント変更 (未使用?)
#--------------------------------------------------------------------------
def get_font(root, font_val)
root.font.name = change_font(font_val)
end
#--------------------------------------------------------------------------
# ● ルビ描画
#--------------------------------------------------------------------------
def ruby_set(root, x, y, str, ruby)
text_w = root.text_size(str).width
text_h = root.text_size(str).height
f_size_back = root.font.size
ruby_size = 10
root.font.size = ruby_size
ruby_w = root.text_size(ruby).width
root.draw_text(4 + x, 4 + 4 + y - ruby_size + 1 + 1, text_w, ruby_size, ruby, 1)
root.font.size = f_size_back
root.draw_text(4 + x, 4 + 4 + y + 1, text_w, text_h, str)
return text_w
end
#--------------------------------------------------------------------------
# ● ピクチャー描画
#--------------------------------------------------------------------------
def set_picture(root, x, y, filename, opacity=MAX8BIT)
bitmap = RPG::Cache.picture(filename)
root.blt(x, y, bitmap, bitmap.rect, opacity)
return bitmap.rect.width
end
#--------------------------------------------------------------------------
# ● ピクチャー転送描画
#--------------------------------------------------------------------------
def set_s_picture(root, x1, y1, w1, h1, filename, x2, y2, w2, h2, opacity=MAX8BIT)
bitmap = RPG::Cache.picture(filename)
dest_rect = Rect.new(x1, y1, w1, h1)
src_rect = Rect.new(x2, y2, w2, h2)
root.stretch_blt(dest_rect, bitmap, src_rect, opacity)
return dest_rect.width
end
#--------------------------------------------------------------------------
# ● バトラー描画
#--------------------------------------------------------------------------
def set_battler(root, x, y, filename, hue, opacity=MAX8BIT)
bitmap = RPG::Cache.battler(filename, hue)
root.blt(x, y, bitmap, bitmap.rect, opacity)
return bitmap.rect.width
end
#--------------------------------------------------------------------------
# ● キャラクター描画
#--------------------------------------------------------------------------
def set_character(root, x, y, filename, hue, dir, pat, opacity=MAX8BIT)
bitmap = RPG::Cache.character(filename, hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
cy = ch * (dir / 2 - 1)
cx = cw * (pat - 1)
src_rect = Rect.new(cx, cy, cw, ch)
root.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
return cw
end
#--------------------------------------------------------------------------
# ● テキストの行数を返す
#--------------------------------------------------------------------------
def text_row(str)
text = str.clone
num = 0
# c に 1 文字を取得 (文字が取得できなくなるまでループ)
while ((c = text.slice!(/./m)) != nil)
# 改行文字の場合
if c == "\n"
# num に 1 を加算
num += 1
# 次の文字へ
next
end
end
return num
end
#--------------------------------------------------------------------------
# ○ アイコン+名前描画
#--------------------------------------------------------------------------
# x :x座標
# y :y座標
# item :描画アイコン
# mltdrw:縁取り文字用フラグ
# 返り値:外字幅(@x増加値)
#--------------------------------------------------------------------------
def set_icon(root, x, y, item, mltdrw)
icon = RPG::Cache.icon(item.icon_name)
name = item.name
size = root.font.size
r_size = get_dis(size)
rectr = Rect.new(x, y, r_size, r_size)
if !mltdrw
root.stretch_blt(rectr, icon, icon.rect)
end
x += size
name = transfer(name)
width = c_text_width_root(root, name.dup)
draw_ex_text(x, y - 4, name)
return r_size + width
end
#--------------------------------------------------------------------------
# ○ 外字描画
#--------------------------------------------------------------------------
# x :x座標
# y :y座標
# num :外字番号
# mltdrw:縁取り文字用フラグ
# 返り値:外字幅(@x増加値)
#--------------------------------------------------------------------------
def letter(root, x, y, num, mltdrw)
pic_v = num / 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 = root.font.size
# アイコン描画サイズの取得
r_size = get_dis(size)
rect1 = Rect.new(x, y, r_size, r_size)
rect6 = Rect.new(num * EP_SIZE, 0, EP_SIZE, EP_SIZE)
# 外字データをstretch_bltで転送
if mltdrw
root.stretch_blt(rect1, @gaiji_cache2, rect6)
end
if !mltdrw
root.stretch_blt(rect1, @gaiji_cache, rect6)
end
# 文字サイズを返す
return r_size
else
return 0
end
end
#--------------------------------------------------------------------------
# ● 純粋なテキスト幅の取得 (self.contents Ver.)
#--------------------------------------------------------------------------
def c_text_width(text)
c_text_width_root(self.contents, text)
end
#--------------------------------------------------------------------------
# ● 純粋なテキスト幅の取得 (汎用 Ver.)
#--------------------------------------------------------------------------
def c_text_width_root(root, text)
size = root.font.size
font = root.font.name
text.gsub!(/\001\[(.+?)\]/) {""}
text.gsub!(/\003\[(.+?)\]/) {""}
text.gsub!(/\200\[(.+?)\]/) {""}
text.gsub!(/\202\[(.+?),(.+?)\]/) { $1 }
text.gsub!(/\260\[(.+?)\]/) {""}
text.gsub!(/\261\[(.+?)\]/) {""}
text.gsub!(/\n/) {""}
width = 0
while ((c = text.slice!(/./m)) != nil)
# \S[n] の場合
if c == "\025"
text.sub!(/\[([0-9]+)\]/, "")
root.font.size = ck_font_size($1.to_i)
next
end
# \F[n] の場合
if c == "\204"
text.sub!(/\[([0-9]+)\]/, "")
root.font.name = change_font($1.to_i)
next
end
# \E[n] の場合
if c == "\203"
text.sub!(/\[([0-9]+)\]/, "")
root.font.size = get_dis(size)
next
end
width += root.text_size(c).width
# \E[n]にて変更したアトのための対処
root.font.size = size
end
root.font.size = size
root.font.name = font
return width
end
end
|