縁取り文字
縁取り文字を描画します。
※既に他サイトにていろいろありますよね・・・
※貪藻矢射妥←ベースモジュール、draw_textベースモジュール、draw_text拡張 カスタムが必要です。
変更点
2008:09:18
・色のカスタマイズポイントを変更
・表示文字が nil の場合エラー落ちするバグを修正
2008:11:16
・戦闘時には無駄に重くなるので回避策を練り込む
2008:11:23
・ベースモジュールを別スクリプトとして定義
2009:04:24
・歯車の城 メッセージ制御文字追加 Ver 1.18 に対応
・momomomo? draw_text拡張(改造版) に対応
2009:06:03
・self.contents.draw_textとdraw_ex_textとで分けていた関数を統合
・文字サイズによって影の表示位置を(1,1)ずらす機能を搭載
2009:09:14
・管理がし易くなるようにちょっとした修正
2009:11:21
・self.contentsのみしか使用できなかったものを拡張
2011:12:08
・self.contents以外の場合、draw_shadow_text_rootでエラー落ちするバグを修正
#==============================================================================
# 縁取り文字 By 貪藻矢射妥←
#------------------------------------------------------------------------------
#
# draw_textを縁取り文字に変更します。
# 普通の描画じゃ物足りない人にうってつけ・・・
#
# ※注意
#
# draw_text(x, y, width, height, text, align)
# を
# rectr = [x, y, width, height]
# draw_shadow_text(rectr, text[,color, align, dflag])
# にする必要があります。(Rect.new ではないことに注意。)
#
# color:描画色
# dflag:有効文字色フラグ(通常は何も考えずにtrue(設定しなくていい))
#
#==============================================================================
# 変更履歴
#
# 2008:09:18
# ・色のカスタマイズポイントを変更
# ・表示文字が nil の場合エラー落ちするバグを修正
#
# 2008:11:16
# ・戦闘時には無駄に重くなるので回避策を練り込む
#
# 2008:11:23
# ・ベースモジュールを別スクリプトとして定義
#
# 2009:04:24
# ・歯車の城 メッセージ制御文字追加 Ver 1.18 に対応
# ・momomomo? draw_text拡張(改造版) に対応
#
# 2009:06:03
# ・self.contents.draw_textとdraw_ex_textとで分けていた関数を統合
# ・文字サイズによって影の表示位置を(1,1)ずらす機能を搭載
#
# 2009:09:14
# ・管理がし易くなるようにちょっとした修正
#
# 2009:11:21
# ・self.contentsのみしか使用できなかったものを拡張
#
# 2011:12:08
# ・self.contents以外の場合、draw_shadow_text_rootでエラー落ちするバグを修正
$OuterFlgs = {} if $OuterFlgs == nil
$OuterFlgs["Draw_Shadow"] = true
module DS
# バトル時も処理が無駄に重くなってもいいから縁取り文字にする場合はtrue
DRAW_SHADOW_BATTLE = false
# 陰を表示する位置を変更する文字サイズ
F_SIZE_M = 20
end
module DIAMOND
include BM
include DS
include DRAW_MSG
#--------------------------------------------------------------------------
# ● 縁取り文字描画 (self.contents Ver.)
# rectr : 全体の表示領域
# text : 表示文字
# color : 表示色
# align : 表示位置
# dflag : 有効文字色フラグ
#--------------------------------------------------------------------------
def draw_shadow_text(rectr, text, color=normal_color, align=0, dflag=true)
draw_shadow_text_root(self.contents, rectr, text, color, align, dflag)
end
#--------------------------------------------------------------------------
# ● 縁取り文字描画 (汎用 Ver.)
# root : 描画大本
# rectr : 全体の表示領域
# text : 表示文字
# color : 表示色
# align : 表示位置
# dflag : 有効文字色フラグ
#--------------------------------------------------------------------------
def draw_shadow_text_root(root, rectr, text, color, align=0, dflag=true)
# \c[n]が含まれている場合の対処
mono = del_change_color(text)
shadow_draw_root(root, rectr, mono, align, dflag)
# 無効文字色の場合
if dflag == false
# 透明度が127では無い場合
if color.alpha != HARF8BIT
color2 = color.clone
color2.alpha = HARF8BIT
root.font.color = color2
end
end
if root.font.color == BGCOLOR || root.font.color == BGCOLORD
# 有効色の場合
root.font.color = color
end
# 普通に文字を表示
if rectr.size == 4
draw_text2_root(root, rectr, text, align)
else
draw_ex_text_root(root, rectr[0], rectr[1], text, align)
end
end
#--------------------------------------------------------------------------
# ● 縁取り文字のフチ部分描画 (self.contents Ver.)
# rectr : 全体の表示領域
# text : 表示文字
# dflag : 有効文字色フラグ
#--------------------------------------------------------------------------
def shadow_draw(rectr, text, align=0, dflag=true)
shadow_draw_root(self.contents, rectr, text, align, dflag)
end
#--------------------------------------------------------------------------
# ● 縁取り文字のフチ部分描画 (汎用 Ver.)
# rectr : 全体の表示領域
# text : 表示文字
# dflag : 有効文字色フラグ
#--------------------------------------------------------------------------
def shadow_draw_root(root, rectr, text, align=0, dflag=true)
ret = get_rect_hyper(rectr)
if dflag == true
root.font.color = BGCOLOR
else
root.font.color = BGCOLORD
end
if not $scene.is_a?(Scene_Battle) || DRAW_SHADOW_BATTLE
for i in 0...ret.size
if rectr.size == 4
draw_text2_root(root, ret[i], text, align)
else
draw_ex_text_root(root, ret[i][0], ret[i][1], text, align, true)
end
end
else
# フォントサイズによって影の位置を微調整
if root.font.size > F_SIZE_M
ret[0][0] += 1
ret[0][1] += 1
end
if rectr.size == 4
draw_text2_root(root, ret[0], text, align)
else
draw_ex_text_root(root, ret[0][0], ret[0][1], text, align, true)
end
end
end
end
|
○使用方法
self.contents.draw_text(x, y, width, heigth, text, align)
の代わりに
rectr = [x, y, width, heigth]
draw_shadow_text(rectr, text, [color, align, dflag])
を指定する
※draw_text拡張 カスタムと併用する際は
rectr = [x, y]
draw_shadow_text(rectr, text, [color, align, dflag])
とする。
※文字の描画位置のサイズによってdraw_textなのかdraw_ex_textなのかの判定を行っています。
変数 |
内容 |
rectr |
文字の描画位置です
※Rect.new()ではなく、ただの配列で持ちます |
text |
表示文字。説明はいらないかと・・・ |
color |
表示色(省略可能です。) |
align |
表示位置(省略可能です。) |
dflag |
有効色か否か(省略可能です。) |
color, align, dflagの初期値はそれぞれnormal_color,0,trueです。
※上3つは省略可能だけどalignだけ、dflagだけ変えたい場合は設定しざるをえません
EX)
color = system_color, align = 1, dflag = falseの場合
draw_shadow_text(rectr, text, system_color, 1, false)
color = normal_color, align = 0, dflag = trueの場合
draw_shadow_text(rectr, text)
color = Color.new(128, 128, 128, 255), align = 0, dflag = trueの場合
draw_shadow_text(rectr, text, Color.new(128, 128, 128, 255))
color = normal_color, align = 0, dflag = falseの場合
draw_shadow_text(rectr, text, normal_color, 0, false)
→省略できるのに省略するとエラーを吐くので設定しないといけない
戻る