258 lines
No EOL
10 KiB
Ruby
258 lines
No EOL
10 KiB
Ruby
=begin
|
||
RGSS3
|
||
|
||
★ ウィンドウスキン変更 ★
|
||
|
||
ゲーム中にウィンドウスキンの変更を可能にします。
|
||
|
||
● 使い方 ●========================================================
|
||
設定箇所で指定した変数に格納されている値に対応した
|
||
ウィンドウスキンが適用されます。
|
||
--------------------------------------------------------------------
|
||
変数の値を変更した瞬間にスキンが変更されます。
|
||
--------------------------------------------------------------------
|
||
イベントコマンドより下記のスクリプトを実行すると、
|
||
プレイヤーが任意にウィンドウスキンを変更できるシーンへ移行します。
|
||
call_skin_selection
|
||
====================================================================
|
||
|
||
ver1.00
|
||
|
||
Last Update : 2015/04/30
|
||
4/30 : RGSS2にあったものを移植
|
||
|
||
ろかん http://kaisou-ryouiki.sakura.ne.jp/
|
||
=end
|
||
|
||
#===================================
|
||
# ●設定箇所
|
||
#===================================
|
||
module Change_Window
|
||
# ウィンドウスキン変更に使用する変数番号
|
||
WINDOW_V = 193
|
||
|
||
# ウィンドウスキン定義
|
||
#【形式】
|
||
# ① => ["②", "③"],
|
||
# ① ウィンドウスキンに対応する変数の値(数値)
|
||
# ② ウィンドウスキンのファイル名(文字列)
|
||
# ③ ウィンドウスキンの名前(文字列) ※ウィンドウスキンを変更するシーンで利用されます
|
||
SKIN_INFO = {
|
||
0 => ["Window", "デフォルト"],
|
||
1 => ["Windowb", "メタリック"],
|
||
2 => ["window4", "森林"],
|
||
3 => ["window5", "クールブラック"],
|
||
}
|
||
end
|
||
#===================================
|
||
# ここまで
|
||
#===================================
|
||
|
||
$rsi ||= {}
|
||
$rsi["ウィンドウスキン変更"] = true
|
||
|
||
class Game_Temp
|
||
#--------------------------------------------------------------------------
|
||
# ● 公開インスタンス変数
|
||
#--------------------------------------------------------------------------
|
||
attr_accessor :skin_id # スキン番号
|
||
#--------------------------------------------------------------------------
|
||
# ● オブジェクト初期化
|
||
#--------------------------------------------------------------------------
|
||
alias change_skin_initialize initialize
|
||
def initialize
|
||
change_skin_initialize
|
||
@skin_id = 0
|
||
end
|
||
end
|
||
|
||
class Game_Interpreter
|
||
#--------------------------------------------------------------------------
|
||
# ● ウィンドウ選択シーンへ移行
|
||
#--------------------------------------------------------------------------
|
||
def call_skin_selection
|
||
SceneManager.call(Scene_SelectWindow)
|
||
end
|
||
end
|
||
|
||
class Window_Base < Window
|
||
#--------------------------------------------------------------------------
|
||
# ● インクルード Change_Window
|
||
#--------------------------------------------------------------------------
|
||
include Change_Window
|
||
#--------------------------------------------------------------------------
|
||
# ● オブジェクト初期化
|
||
#--------------------------------------------------------------------------
|
||
alias change_skin_initialize initialize
|
||
def initialize(x, y, width, height)
|
||
change_skin_initialize(x, y, width, height)
|
||
change_window_skin
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● ウィンドウスキンの適用
|
||
#--------------------------------------------------------------------------
|
||
def change_window_skin
|
||
self.windowskin = Cache.system(SKIN_INFO[$game_variables[WINDOW_V]][0])
|
||
end
|
||
end
|
||
|
||
class Window_SkinSelect < Window_Base
|
||
#--------------------------------------------------------------------------
|
||
# ● インクルード Change_Window
|
||
#--------------------------------------------------------------------------
|
||
include Change_Window
|
||
#--------------------------------------------------------------------------
|
||
# ● オブジェクト初期化
|
||
#--------------------------------------------------------------------------
|
||
def initialize
|
||
super(get_x, get_y, get_width, get_height)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● X 座標の取得
|
||
#--------------------------------------------------------------------------
|
||
def get_x
|
||
Graphics.width / 2 - get_width / 2
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● Y 座標の取得
|
||
#--------------------------------------------------------------------------
|
||
def get_y
|
||
Graphics.height / 2 - get_height / 2
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 横幅の取得
|
||
#--------------------------------------------------------------------------
|
||
def get_width
|
||
350
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 縦幅の取得
|
||
#--------------------------------------------------------------------------
|
||
def get_height
|
||
100
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● ウィンドウスキンの適用
|
||
#--------------------------------------------------------------------------
|
||
def change_window_skin
|
||
super
|
||
self.contents.clear
|
||
self.contents.font.size = 20
|
||
self.contents.font.color = system_color
|
||
draw_text(0, 0, contents.width, line_height, "ウィンドウスキンを選択してください", 1)
|
||
self.contents.font.color = normal_color
|
||
self.contents.font.size = 23
|
||
self.contents.font.italic = true
|
||
draw_text(0, line_height + 15, contents.width, line_height, "- #{SKIN_INFO[$game_variables[WINDOW_V]][1]} -", 1)
|
||
self.contents.font.italic = false
|
||
self.contents.font.bold = true
|
||
draw_text(0, line_height + 15, contents.width, line_height, "<<", 0)
|
||
draw_text(0, line_height + 15, contents.width, line_height, ">>", 2)
|
||
self.contents.font.bold = false
|
||
end
|
||
end
|
||
|
||
class Scene_Base
|
||
#--------------------------------------------------------------------------
|
||
# ● インクルード Change_Window
|
||
#--------------------------------------------------------------------------
|
||
include Change_Window
|
||
#--------------------------------------------------------------------------
|
||
# ● フレーム更新
|
||
#--------------------------------------------------------------------------
|
||
alias change_skin_update update
|
||
def update
|
||
change_skin_update
|
||
update_skin
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● ウィンドウスキンの更新
|
||
#--------------------------------------------------------------------------
|
||
def update_skin
|
||
if $game_variables[WINDOW_V] != $game_temp.skin_id
|
||
$game_temp.skin_id = $game_variables[WINDOW_V]
|
||
update_skin_all_windows
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 全ウィンドウのスキン更新
|
||
#--------------------------------------------------------------------------
|
||
def update_skin_all_windows
|
||
ObjectSpace.each_object(Window_Base){|window|
|
||
window.change_window_skin unless window.disposed?
|
||
}
|
||
end
|
||
end
|
||
|
||
class Scene_SelectWindow < Scene_Base
|
||
#--------------------------------------------------------------------------
|
||
# ● 開始処理
|
||
#--------------------------------------------------------------------------
|
||
def start
|
||
super
|
||
create_background
|
||
create_window
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 背景の作成
|
||
#--------------------------------------------------------------------------
|
||
def create_background
|
||
@background_sprite = Sprite.new
|
||
@background_sprite.bitmap = SceneManager.background_bitmap
|
||
@background_sprite.color.set(16, 16, 16, 128)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 終了処理
|
||
#--------------------------------------------------------------------------
|
||
def terminate
|
||
super
|
||
dispose_background
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 背景の解放
|
||
#--------------------------------------------------------------------------
|
||
def dispose_background
|
||
@background_sprite.dispose
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● ウィンドウの作成
|
||
#--------------------------------------------------------------------------
|
||
def create_window
|
||
@skin_select_window = Window_SkinSelect.new
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● フレーム更新
|
||
#--------------------------------------------------------------------------
|
||
def update
|
||
update_change_skin unless update_call_return
|
||
super
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 前のシーンに戻る
|
||
#--------------------------------------------------------------------------
|
||
def update_call_return
|
||
if Input.trigger?(:B)
|
||
Sound.play_cancel
|
||
return_scene
|
||
true
|
||
else
|
||
false
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● スキン変更の更新
|
||
#--------------------------------------------------------------------------
|
||
def update_change_skin
|
||
if Input.trigger?(:RIGHT)
|
||
Sound.play_ok
|
||
list = SKIN_INFO.keys.sort
|
||
$game_variables[WINDOW_V] = list[list.index($game_variables[WINDOW_V]).next]
|
||
$game_variables[WINDOW_V] = list.first unless $game_variables[WINDOW_V]
|
||
elsif Input.trigger?(:LEFT)
|
||
Sound.play_ok
|
||
list = SKIN_INFO.keys.sort
|
||
$game_variables[WINDOW_V] = list[list.index($game_variables[WINDOW_V]) - 1]
|
||
$game_variables[WINDOW_V] = list.last unless $game_variables[WINDOW_V]
|
||
end
|
||
end
|
||
end |