=begin
#==============================================================================
[名前] YakiNoriBaseScripts
[作者] 焼きノリ
[配布元] まったりツクール雑貨 http://mata-tuku.ldblog.jp/
#------------------------------------------------------------------------------
[更新履歴]
・2012/08/26 公開
・2012/09/09 Window_Selectableにメソッド追加
#==============================================================================
#------------------------------------------------------------------------------
[対応]
・RGSS2、RGSS3両方可能
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
[機能]
・焼きノリが制作したスクリプトを使う際に必要になります。
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
[使用方法]
・必ず、拙作の他のスクリプトの一番上に配置してください。
#------------------------------------------------------------------------------
[再定義箇所]
・なし
#------------------------------------------------------------------------------
[○ : 新規定義, ◎ : エイリアス定義, ● : 再定義]
#------------------------------------------------------------------------------
=end
$YkNr_Scripts ||= {}
$YkNr_Scripts[:YakiNoriBaseScripts] = true
#※このスクリプトを使用しない場合は、↑を false にすること
if $YkNr_Scripts[:YakiNoriBaseScripts]
#==============================================================================
# ■ YakiNori
#------------------------------------------------------------------------------
# 拙作の各自作スクリプトで使用するメソッドの集まりです。
#==============================================================================
module YakiNori
#--------------------------------------------------------------------------
# ○ 定数用モジュールに定義されている定数をフリーズ
# このメソッドのみ、定数モジュールより先に定義する
#--------------------------------------------------------------------------
def self.freeze_all_constants(mod)
_const_modules = "#{mod.name}::Const"
eval("#{_const_modules}.constants").each do |const|
_constant = "#{_const_modules}::#{const}"
eval("#{_constant}.freeze") if !eval("#{_constant}.frozen?")
end
end
#==============================================================================
# ■ 定数用モジュール
#==============================================================================
module Const
end
freeze_all_constants(self) # 定数をフリーズ
#==============================================================================
# ■ インスタンスメソッド用モジュール
#------------------------------------------------------------------------------
# このモジュールをインクルードすることで、ここで定義したメソッドが使用可能。
#==============================================================================
module Instance
end
#==============================================================================
# ■ 拡張モジュール用モジュール
#------------------------------------------------------------------------------
# このモジュールに自作スクリプトで使用するモジュールを集結させます
#==============================================================================
module BaseExModules
# オブジェクトクラスにインクルード
Object.__send__ :include, self
end
#==============================================================================
# ■ 特異メソッド
#==============================================================================
#--------------------------------------------------------------------------
# ○ 拡張モジュール用モジュールに定義されているか取得
# 引数は、RGSS,RGSS2では文字列に、RGSS3はシンボル値を渡してください
#--------------------------------------------------------------------------
def self.include_module?(module_name_sym)
BaseExModules.constants.include?(module_name_sym)
end
end
#==============================================================================
# ■ Kernel
#==============================================================================
module Kernel
#--------------------------------------------------------------------------
# ○ RPGVXAce かどうか
#--------------------------------------------------------------------------
def vxace?
# Ruby 1.9 以降とそれ以前では、実行結果が違う
return false if public_methods.all? {|item| item.is_a?(String)}
return false if !defined?(Graphics.play_movie)
return defined?(BasicObject)
end
#--------------------------------------------------------------------------
# ○ RGSSのバージョンを取得
#--------------------------------------------------------------------------
def rgss_version
_version = {2 => false, 3 => false}
_version[vxace? ? 3 : 2] = true
return _version
end
#--------------------------------------------------------------------------
# ○ 定数
#--------------------------------------------------------------------------
RGSS = rgss_version ; RGSS.freeze
#--------------------------------------------------------------------------
# ○ ログテキストファイルの出力
# alert : 出力完了のメッセージボックスを表示するか
# *words : 出力するオブジェクト
#--------------------------------------------------------------------------
def p_log(alert, *words)
w_time = Time.now
message = "■ 以下を出力しました。\n\n"
open("game.log", "a") {|log|
log.print("# ")
# 現在年月日
log.print(w_time.year) ; log.print("/")
log.print(w_time.mon) ; log.print("/")
log.print(w_time.mday) ; log.print(" ")
# 現在時刻
log.print(w_time.hour) ; log.print(":")
log.print(w_time.min) ; log.print(":")
log.print(w_time.sec) ; log.print("\n")
# 出力
words.each {|word| log.print(word) ; log.print("\n")}
log.print("# --------------------\n\n")
}
print message + words.to_s if alert
end
#--------------------------------------------------------------------------
if RGSS[3] && !$!
#--------------------------------------------------------------------------
# ◎ メソッド p を RGSS2 仕様に戻す
#--------------------------------------------------------------------------
alias c_p p
alias p msgbox_p
#--------------------------------------------------------------------------
# ◎ メソッド print を RGSS2 仕様に戻す
#--------------------------------------------------------------------------
alias c_print print
alias print msgbox
end # RGSS[3] && !$!
end
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# ○ アイテムの種別IDを取得
# 武器なら1000番台、防具なら2000番台の数値を返します。
#--------------------------------------------------------------------------
def kind_id
_result = 0
case self.class.name
when "RPG::Item" ; _result = id
when "RPG::Weapon"; _result = id + 1000
when "RPG::Armor" ; _result = id + 2000
end
return _result
end
end
#==============================================================================
# ■ Game_CharacterBase
#==============================================================================
class Game_CharacterBase
#--------------------------------------------------------------------------
# ○ 正面にイベントが存在するか取得
#--------------------------------------------------------------------------
def exist_event_front?
x2 = $game_map.round_x_with_direction(@x, @direction)
y2 = $game_map.round_y_with_direction(@y, @direction)
return !$game_map.events_xy(x2, y2).empty?
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ○ エディター上のマップ名を取得
#--------------------------------------------------------------------------
def editor_name
$data_mapinfos[map_id].name
end
end
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ○ イベント名の取得
#--------------------------------------------------------------------------
def name
@event.name
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ○ ゲージの描画 (外枠付)
# rate : 割合(1.0 で満タン)
# color1 : グラデーション 左端
# color2 : グラデーション 右端
#--------------------------------------------------------------------------
def draw_gauge_ex(x, y, width, rate, color1, color2)
fill_w = ((width-2) * rate).to_i
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 8, gauge_back_color)
contents.gradient_fill_rect(x+1, gauge_y+1, fill_w, 6, color1, color2)
end
end
#==============================================================================
# ■ Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# ○ 現在の列の取得
#--------------------------------------------------------------------------
def column
index % col_max
end
#--------------------------------------------------------------------------
# ○ 行と列から項目の位置を取得
#--------------------------------------------------------------------------
def index_pos(row, column)
row * col_max + (column - 1)
end
end
#==============================================================================
# □ VX Ace は以下の処理はしない
#==============================================================================
if !RGSS[3]
#--------------------------------------------------------------------------
# ○ $data_mapinfos のロード
#--------------------------------------------------------------------------
$data_mapinfos ||= load_data("Data/MapInfos.rvdata")
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ◎ マップ名を取得
#--------------------------------------------------------------------------
alias name editor_name
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ○ テキスト描画色の変更
# enabled : 有効フラグ。false のとき半透明で描画
#--------------------------------------------------------------------------
def change_color(color, enabled = true)
contents.font.color.set(color)
contents.font.color.alpha = translucent_alpha unless enabled
end
#--------------------------------------------------------------------------
# ○ テキストの描画
# args : Bitmap#draw_text と同じ
#--------------------------------------------------------------------------
def draw_text(*args)
contents.draw_text(*args)
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :previous_scene # 現在のひとつ前の画面(文字列)
#--------------------------------------------------------------------------
# ◎ オブジェクト初期化
#--------------------------------------------------------------------------
alias yknr_LogDisable_initialize initialize
def initialize
yknr_LogDisable_initialize
@previous_scene = ""
end
end
#==============================================================================
# ■ Scene_Base
#==============================================================================
class Scene_Base
#--------------------------------------------------------------------------
# ○ 終了処理
#--------------------------------------------------------------------------
def terminate
# 現在の画面を保存
$game_temp.previous_scene = self.class.name
end
end
end # !RGSS[3]
end # $YkNr_Scripts