341 lines
No EOL
14 KiB
Ruby
341 lines
No EOL
14 KiB
Ruby
#==============================================================================
|
||
# □ Scene_CGView
|
||
#------------------------------------------------------------------------------
|
||
# クラスです。
|
||
#==============================================================================
|
||
|
||
class Scene_CGView < Scene_Base
|
||
#--------------------------------------------------------------------------
|
||
# ○ オブジェクト初期化
|
||
#--------------------------------------------------------------------------
|
||
def initialize(id, num, name, skip)
|
||
@id = id
|
||
@num = num
|
||
@name = name
|
||
@skip = skip
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 開始処理
|
||
#--------------------------------------------------------------------------
|
||
def start
|
||
super
|
||
create_background
|
||
create_cg
|
||
create_command_window
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● トランジション速度の取得
|
||
#--------------------------------------------------------------------------
|
||
def transition_speed
|
||
return 20
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 終了処理
|
||
#--------------------------------------------------------------------------
|
||
def terminate
|
||
super
|
||
dispose_background
|
||
dispose_cg
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 CG背景の作成
|
||
#--------------------------------------------------------------------------
|
||
def create_background
|
||
@sprite1 = Sprite.new
|
||
@sprite1.bitmap = Cache.cg_back("cg_back")
|
||
center_sprite(@sprite1)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 CG背景の解放
|
||
#--------------------------------------------------------------------------
|
||
def dispose_background
|
||
@sprite1.bitmap.dispose
|
||
@sprite1.dispose
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● スプライトを画面中央に移動
|
||
#--------------------------------------------------------------------------
|
||
def center_sprite(sprite)
|
||
sprite.ox = sprite.bitmap.width / 2
|
||
sprite.oy = sprite.bitmap.height / 2
|
||
sprite.x = Graphics.width / 2
|
||
sprite.y = Graphics.height / 2
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 CGの作成
|
||
#--------------------------------------------------------------------------
|
||
def create_cg
|
||
#name = Cache.picture("#{@name}_#{format("%02d",@id)}_01")
|
||
#$game_map.screen.pictures[1].show(name, 0, 0, 0, 100, 100, 255, 0)
|
||
@cg_sprite = Sprite.new
|
||
@cg_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||
|
||
name = "#{@name}_#{format("%02d",@id)}_01"
|
||
name = FAKEREAL.cg_select(name)
|
||
|
||
#name = "DMZ/" + name if !$game_switches[Option::EXH_D] && FAKEREAL.cg_exists?(name)
|
||
@cg_sprite.bitmap = Cache.picture(name)
|
||
|
||
@cg_sprite.z = 100
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 CG背景の解放
|
||
#--------------------------------------------------------------------------
|
||
def dispose_cg
|
||
@cg_sprite.bitmap.dispose
|
||
@cg_sprite.dispose
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● コマンドウィンドウの作成
|
||
#--------------------------------------------------------------------------
|
||
def create_command_window
|
||
@command_window = Window_CG_Command.new(@num)
|
||
@command_window.set_handler(:next, method(:change_cg))
|
||
@command_window.set_handler(:back, method(:change_cg))
|
||
@command_window.set_handler(:hide, method(:window_hide))
|
||
@command_window.set_handler(:cancel, method(:return_scene))
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def change_cg
|
||
#show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
|
||
i = 0
|
||
@skip.each {|sn| i += 1 if @command_window.page_index >= sn }
|
||
num = @command_window.page_index + i
|
||
@cg_sprite.bitmap.dispose
|
||
name = "#{@name}_#{format("%02d",@id)}_#{format("%02d",num)}"
|
||
name = FAKEREAL.cg_select(name)
|
||
#name = "DMZ/" + name if !$game_switches[Option::EXH_D] && FAKEREAL.cg_exists?(name)
|
||
@cg_sprite.bitmap = Cache.picture(name)
|
||
#@cg_sprite.bitmap = Cache.picture("#{@name}_#{format("%02d",@id)}_#{format("%02d",num)}")
|
||
#name = $game_map.screen.pictures[1].name
|
||
#if name =~ /^\w+_\d+?_(\d+?)$/
|
||
#name = name.gsub(/\d+?$/) { format("%02d",num) }
|
||
#$game_map.screen.pictures[1].change(name)
|
||
#end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def window_hide
|
||
@command_window.visible ^= true
|
||
end
|
||
end
|
||
|
||
class Window_CG_Command < Window_Selectable
|
||
#--------------------------------------------------------------------------
|
||
# ○ 公開インスタンス変数
|
||
#--------------------------------------------------------------------------
|
||
attr_reader :page_index # 現在のページ数
|
||
#--------------------------------------------------------------------------
|
||
# ● オブジェクト初期化
|
||
#-------------------------------------------------------------------------
|
||
def initialize(num)
|
||
super(window_x, window_y, window_width, window_height)
|
||
@page_index = 1
|
||
@page_max = num
|
||
self.opacity = 0
|
||
refresh
|
||
activate
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def window_x
|
||
Graphics.width - window_width
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def window_y
|
||
Graphics.height - window_height
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def window_width
|
||
180
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 ウィンドウ高さの取得
|
||
#--------------------------------------------------------------------------
|
||
def window_height
|
||
fitting_height(visible_line_number)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 表示行数の取得
|
||
#--------------------------------------------------------------------------
|
||
def visible_line_number
|
||
2
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● カーソルの移動処理
|
||
#--------------------------------------------------------------------------
|
||
def process_cursor_move
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定やキャンセルなどのハンドリング処理
|
||
#--------------------------------------------------------------------------
|
||
def process_handling
|
||
return unless open? && active
|
||
return process_ok if ok_enabled? && Input.trigger?(:C)
|
||
return process_cancel if cancel_enabled? && Input.trigger?(:B)
|
||
return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
|
||
return process_pageup if handle?(:pageup) && Input.trigger?(:L)
|
||
return process_next if ok_next? && Input.trigger?(:RIGHT)
|
||
return process_back if ok_back? && Input.trigger?(:LEFT)
|
||
return process_hide if ok_hide? && Input.trigger?(:Z)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 キャンセル処理の有効状態を取得
|
||
#--------------------------------------------------------------------------
|
||
def ok_next?
|
||
handle?(:next)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定処理の有効状態を取得
|
||
#--------------------------------------------------------------------------
|
||
def ok_back?
|
||
handle?(:back)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定処理の有効状態を取得
|
||
#--------------------------------------------------------------------------
|
||
def ok_hide?
|
||
handle?(:hide)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ボタンが押されたときの処理
|
||
#--------------------------------------------------------------------------
|
||
def process_next
|
||
Sound.play_cursor
|
||
Input.update
|
||
activate
|
||
@page_index += 1
|
||
@page_index = 1 if @page_index > @page_max
|
||
call_next_handler
|
||
refresh
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ボタンが押されたときの処理
|
||
#--------------------------------------------------------------------------
|
||
def process_back
|
||
Sound.play_cursor
|
||
Input.update
|
||
activate
|
||
@page_index -= 1
|
||
@page_index = @page_max if @page_index < 1
|
||
call_back_handler
|
||
refresh
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ボタンが押されたときの処理
|
||
#--------------------------------------------------------------------------
|
||
def process_hide
|
||
Sound.play_cursor
|
||
Input.update
|
||
activate
|
||
call_hide_handler
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ハンドラの呼び出し
|
||
#--------------------------------------------------------------------------
|
||
def call_next_handler
|
||
call_handler(:next)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ハンドラの呼び出し
|
||
#--------------------------------------------------------------------------
|
||
def call_back_handler
|
||
call_handler(:back)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 決定ハンドラの呼び出し
|
||
#--------------------------------------------------------------------------
|
||
def call_hide_handler
|
||
call_handler(:hide)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● フレーム更新
|
||
#--------------------------------------------------------------------------
|
||
def update
|
||
super
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 背景の描画
|
||
#--------------------------------------------------------------------------
|
||
def draw_background(rect)
|
||
#temp_rect = rect.clone
|
||
#temp_rect.width /= 2
|
||
contents.fill_rect(rect, back_color1)
|
||
#contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
|
||
#temp_rect.x = temp_rect.width
|
||
#contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 背景色 1 の取得
|
||
#--------------------------------------------------------------------------
|
||
def back_color1
|
||
Color.new(0, 0, 0, 192)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 背景色 2 の取得
|
||
#--------------------------------------------------------------------------
|
||
def back_color2
|
||
Color.new(0, 0, 0, 0)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇
|
||
#--------------------------------------------------------------------------
|
||
def draw_page
|
||
draw_text(0, 0, contents_width, line_height, "← #{@page_index}/#{@page_max} →", 1)
|
||
contents.font.size -= 8
|
||
draw_text(0, line_height, contents_width, line_height, "#{key_button("d")}で非表示", 1)
|
||
contents.font.size += 8
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# 〇 リフレッシュ
|
||
#--------------------------------------------------------------------------
|
||
def refresh
|
||
contents.clear
|
||
draw_background(contents.rect)
|
||
draw_page
|
||
end
|
||
end
|
||
|
||
|
||
#==============================================================================
|
||
# ■ Cache
|
||
#------------------------------------------------------------------------------
|
||
# 各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
|
||
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
|
||
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
|
||
# を返すようになっています。
|
||
#==============================================================================
|
||
|
||
module Cache
|
||
#--------------------------------------------------------------------------
|
||
# ● タイトル(背景)グラフィックの取得
|
||
#--------------------------------------------------------------------------
|
||
def self.cg_back(filename)
|
||
load_bitmap("Graphics/Pictures/", filename)
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ SceneManager
|
||
#------------------------------------------------------------------------------
|
||
# シーン遷移を管理するモジュール ※追加分
|
||
#==============================================================================
|
||
|
||
module SceneManager
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def self.cg_call(scene_class, id, num, name = "ev", skip = [])
|
||
@stack.push(@scene)
|
||
@scene = scene_class.new(id, num, name, skip)
|
||
Fiber.yield
|
||
end
|
||
end |