#============================================================================== # ■ VXAce-RGSS3-17 タイトルカスタマイズ [main] by Claimh #============================================================================== #============================================================================== # ■ Title #============================================================================== module Title #-------------------------------------------------------------------------- # ● スキップコマンド : C, B, 方向キー #-------------------------------------------------------------------------- def self.skip_trigger? (Input.trigger?(:C) or Input.trigger?(:B) or Input.dir4 > 0) end end #============================================================================== # ■ Title::Scene #============================================================================== module Title::Scene S_START = 0 # 起動 S_LOGO = 1 # ロゴシーン S_DEMO = 2 # イベントデモ S_TITLE = 3 # タイトル #-------------------------------------------------------------------------- # ● ロゴシーンの有無 #-------------------------------------------------------------------------- def self.enable_logo(timeout=false) false end #-------------------------------------------------------------------------- # ● イベントシーンの有無 #-------------------------------------------------------------------------- def self.enable_demo(timeout=false) false end end #============================================================================== # ■ TitleBack : 背景プレーン #============================================================================== class TitleBack < Plane #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(b, main=false) @index = main ? 0 : 1 super(Viewport.new(0, 0, Graphics.width, Graphics.height)) self.bitmap = b self.viewport.z = 100 fit_screen if Title::TB_FIT[@index] @stop = false reset_pos stop_pos end def bwz; (bitmap.width * zoom_x).truncate; end # ズーム後のbitmap幅 def bhz; (bitmap.height* zoom_y).truncate; end # ズーム後のbitmap高さ def vw; viewport.rect.width; end def vh; viewport.rect.height; end #-------------------------------------------------------------------------- # ● オブジェクト破棄 #-------------------------------------------------------------------------- def dispose self.bitmap.dispose self.viewport.dispose super end #-------------------------------------------------------------------------- # ● 画面にフィットさせる #-------------------------------------------------------------------------- def fit_screen x_zoom = vw * 1.0 / bitmap.width y_zoom = vh * 1.0 / bitmap.height zoom = x_zoom > y_zoom ? x_zoom : y_zoom self.zoom_x = self.zoom_y = zoom end #-------------------------------------------------------------------------- # ● 画像位置の設定 #-------------------------------------------------------------------------- def x4; 0; end def x5; (bwz - vw) / 2; end def x6; (bwz - vw); end def y2; (bhz - vh); end def y5; (bhz - vh) / 2; end def y8; 0; end def reset_pos case Title::TB_BASE[@index] when 1; self.ox = x4; self.oy = y2 when 2; self.ox = x5; self.oy = y2 when 3; self.ox = x6; self.oy = y2 when 4; self.ox = x4; self.oy = y5 when 6; self.ox = x6; self.oy = y5 when 7; self.ox = x4; self.oy = y8 when 8; self.ox = x5; self.oy = y8 when 9; self.ox = x6; self.oy = y8 else; self.ox = x5; self.oy = y5 end end #-------------------------------------------------------------------------- # ● 終端点の設定 #-------------------------------------------------------------------------- def stop_pos case Title::TB_BASE[@index] when 1,4,7; @x_gap = x6 when 3,6,9; @x_gap = x4 else; @x_gap = nil end case Title::TB_BASE[@index] when 1,2,3; @y_gap = y8 when 7,8,9; @y_gap = y2 else; @y_gap = nil end end #-------------------------------------------------------------------------- # ● スクロール判定 #-------------------------------------------------------------------------- def scroll? Title::SCROLL_TG[@index] end #-------------------------------------------------------------------------- # ● スクロール終端判定 #-------------------------------------------------------------------------- def scroll_stop? return unless Title::SCROLL_STOP[@index] if !@x_gap.nil? # p "#{self.ox}, #{@x_gap}" case Title::SCROLL_DIR[@index] when 1,4,7; x_end_stop if self.ox < @x_gap when 3,6,9; x_end_stop if self.ox > @x_gap end end if !@y_gap.nil? # p "#{self.oy}, #{@y_gap}" case Title::SCROLL_DIR[@index] when 1,2,3; y_end_stop if self.oy > @y_gap when 7,8,9; y_end_stop if self.oy < @y_gap end end end def x_end_stop self.ox = @x_gap @stop = true end def y_end_stop self.oy = @y_gap @stop = true end #-------------------------------------------------------------------------- # ● Xスクロール #-------------------------------------------------------------------------- def scroll_x(n) self.ox = self.ox + n * Title::SCROLL_SPD[@index] end def scroll_r; scroll_x( 1) end def scroll_l; scroll_x(-1) end #-------------------------------------------------------------------------- # ● Yスクロール #-------------------------------------------------------------------------- def scroll_y(n) self.oy = self.oy + n * Title::SCROLL_SPD[@index] end def scroll_u; scroll_y(-1) end def scroll_d; scroll_y( 1) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return unless scroll? return if @stop case Title::SCROLL_DIR[@index] when 1; scroll_l; scroll_d when 2; scroll_d when 3; scroll_r; scroll_d when 4; scroll_l when 6; scroll_r when 7; scroll_l; scroll_u when 8; scroll_u when 9; scroll_r; scroll_u end scroll_stop? self.ox %= viewport.rect.width self.oy %= viewport.rect.height end end #============================================================================== # ■ Spriteset_TitleMap : タイトル背景マップ #============================================================================== class Spriteset_TitleMap < Spriteset_Map #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super $game_map.update(true) end end #============================================================================== # ■ Title::TitleName #============================================================================== class Title::TitleName #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(type) @type = type @name = @file = "" @rect = Rect.new @x_align = @y_align = 0 end #-------------------------------------------------------------------------- # ● 描画対象の矩形 #-------------------------------------------------------------------------- def src_rect(name, file, bitmap) if @type @name = name @srect = bitmap.text_size(name) else @file = file b = Cache.system(file) @srect = Rect.new(0, 0, b.width, b.height) end end #-------------------------------------------------------------------------- # ● タイトル矩形の計算 #-------------------------------------------------------------------------- def calc_rect(config, half=true) if config.x < 0 @rect.x += config.width @rect.width = Graphics.width - config.width @x_align = 1 else @rect.x = config.x @rect.width = @srect.width end if config.y < 0 @rect.y += config.height @rect.height = half ? Graphics.height / 2 : Graphics.height @y_align = 1 else @rect.y = config.y @rect.height = @srect.height end end #-------------------------------------------------------------------------- # ● タイトル描画 #-------------------------------------------------------------------------- def draw_tile(bitmap) if @type bitmap.draw_text(@rect, @name, @x_align) else b = Cache.system(@file) @rect.x = ((@rect.width - b.width) / 2) if @x_align == 1 @rect.y = ((@rect.height - b.height) / 2) if @y_align == 1 bitmap.blt(@rect.x, @rect.y, b, @srect) end end end #============================================================================== # ■ Sprite_TitleName : タイトル名スプライト #============================================================================== class Sprite_TitleName < Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(main) @main = main super(Viewport.new(0, 0, Graphics.width, Graphics.height)) self.bitmap = Bitmap.new(Graphics.width, Graphics.height) self.viewport.z = 200 main ? Title.set_main_bitmap(self.bitmap) : Title.set_sub_bitmap(self.bitmap) end #-------------------------------------------------------------------------- # ● オブジェクト破棄 #-------------------------------------------------------------------------- def dispose self.bitmap.dispose self.viewport.dispose super end #-------------------------------------------------------------------------- # ● タイトル描画 #-------------------------------------------------------------------------- def draw_title @main ? draw_main_title : draw_sub_title end #-------------------------------------------------------------------------- # ● メインタイトル描画 #-------------------------------------------------------------------------- def draw_main_title title = Title::TitleName.new(Title::TM_TYPE) title.src_rect($data_system.game_title, Title::TM_NAME, self.bitmap) title.calc_rect(Title::TM_RECT) title.draw_tile(self.bitmap) end #-------------------------------------------------------------------------- # ● サブタイトル描画 #-------------------------------------------------------------------------- def draw_sub_title title = Title::TitleName.new(Title::TS_TYPE) title.src_rect(Title::TS_NAME, Title::TS_NAME, self.bitmap) title.calc_rect(Title::TS_RECT) title.draw_tile(self.bitmap) end end #============================================================================== # ■ Scene_Title #------------------------------------------------------------------------------ #  タイトル画面の処理を行うクラスです。 #============================================================================== class Scene_Title < Scene_Base include Title::Scene #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super prepare(S_START) @timecnt = 0 end #-------------------------------------------------------------------------- # ● 準備 #-------------------------------------------------------------------------- def prepare(scene=S_TITLE, timeout=false, index=-1) @pre_scene = scene @timeout = timeout @index = index end #-------------------------------------------------------------------------- # ● トランジション実行 #-------------------------------------------------------------------------- def perform_transition Title::TITLE_TRN.nil? ? super : Graphics.transition(transition_speed, Title::TITLE_TRN) end #-------------------------------------------------------------------------- # ● 開始前シーン制御 #-------------------------------------------------------------------------- def check_pre_scene if Title::SKIP_ALL return skip_start end if Title::SKIP_NEWGAME return skip_start unless DataManager.save_file_exists? end if Title::SKIP_CONTINUE return DataManager.save_file_exists? ? SceneManager.call(Scene_Load) : skip_start end if Title::Scene.enable_logo(@timeout) and @pre_scene < S_LOGO return call_new_scene(Scene_Logo) end if Title::Scene.enable_demo(@timeout) and @pre_scene < S_DEMO return call_new_scene(Scene_EvDemo) end end #-------------------------------------------------------------------------- # ● 開始前シーン制御 #-------------------------------------------------------------------------- def call_new_scene(scene) SceneManager.call(scene) SceneManager.scene.prepare(@timeout) Graphics.freeze end #-------------------------------------------------------------------------- # ● Skip New Game #-------------------------------------------------------------------------- def skip_start DataManager.setup_new_game fadeout_all $game_map.autoplay SceneManager.goto(Scene_Map) Graphics.freeze end #-------------------------------------------------------------------------- # ● Skip Continue #-------------------------------------------------------------------------- def skip_continue play_title_music SceneManager.call(Scene_Load) Graphics.freeze end #-------------------------------------------------------------------------- # ● メイン #-------------------------------------------------------------------------- def main check_pre_scene return if scene_changing? super end #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- def post_start setup_fadein if Title::FADEIN_PATTERN > 0 super exec_fadein if Title::FADEIN_PATTERN > 0 end #-------------------------------------------------------------------------- # ● フェードin処理準備 #-------------------------------------------------------------------------- def setup_fadein @text_sprites.each { |s| s.opacity = 0 } @command_window.open end #-------------------------------------------------------------------------- # ● フェードin処理 #-------------------------------------------------------------------------- def exec_fadein case Title::FADEIN_PATTERN when 1 # メインタイトル+サブタイトル+コマンド Title::FADEIN_TIME.times do |i| @text_sprites.each { |s| s.opacity += 255/Title::FADEIN_TIME } @command_window.update_open break if update_fade end when 2 # メインタイトル+サブタイトル → コマンド Title::FADEIN_TIME.times do |i| @text_sprites.each { |s| s.opacity += 255/Title::FADEIN_TIME } break if update_fade end Title::FADEIN_TIME.times do |i| @command_window.update_open break if update_fade end end @text_sprites.each { |s| s.opacity = 255 } @command_window.update_open while !@command_window.open? end #-------------------------------------------------------------------------- # ● フェードinのフレーム更新 #-------------------------------------------------------------------------- def update_fade update_background Graphics.update Input.update @command_window.process_cursor_move Title.skip_trigger? end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias start_title start def start start_title create_message_window if Title::TB_MAP create_scroll_text_window if Title::TB_MAP end #-------------------------------------------------------------------------- # ● 背景の作成 [再定義] #-------------------------------------------------------------------------- def create_background @back_sprites = [] if Title::TB_MAP DataManager.create_game_objects $game_map.setup(Title::TB_MAP_ID) $game_player.moveto(Title::TB_MAP_POS.x, Title::TB_MAP_POS.y) @back_sprites.push(Spriteset_TitleMap.new) @back_sprites[0].update @back_sprites.push(TitleBack.new(Cache.title2($data_system.title2_name))) if Title::TB_MAP_2 else @back_sprites.push(TitleBack.new(Cache.title1($data_system.title1_name), true)) @back_sprites.push(TitleBack.new(Cache.title2($data_system.title2_name))) end create_weather end #-------------------------------------------------------------------------- # ● 背景のフレーム更新 #-------------------------------------------------------------------------- def update_background @back_sprites.each { |s| s.update } update_weather end #-------------------------------------------------------------------------- # ● 前景の作成 [再定義] #-------------------------------------------------------------------------- def create_foreground @text_sprites = [] return unless $data_system.opt_draw_title (Title::TS ? 2 : 1).times {|i| @text_sprites.push(Sprite_TitleName.new(i==0))} draw_game_title end #-------------------------------------------------------------------------- # ● ゲームタイトルの描画 [再定義] #-------------------------------------------------------------------------- def draw_game_title @text_sprites.each { |s| s.draw_title } end #-------------------------------------------------------------------------- # ● 背景の解放 [再定義] #-------------------------------------------------------------------------- def dispose_background dispose_weather @back_sprites.each { |s| s.dispose } end #-------------------------------------------------------------------------- # ● 前景の解放 [再定義] #-------------------------------------------------------------------------- def dispose_foreground @text_sprites.each { |s| s.bitmap.dispose; s.dispose } end #-------------------------------------------------------------------------- # ● メッセージウィンドウの作成 #-------------------------------------------------------------------------- def create_message_window @message_window = Window_Message.new end #-------------------------------------------------------------------------- # ● スクロール文章ウィンドウの作成 #-------------------------------------------------------------------------- def create_scroll_text_window @scroll_text_window = Window_ScrollText.new end #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_command_window_title create_command_window def create_command_window create_command_window_title Title::CMD_BOX.select { |i| i > 2 }.each do |c| @command_window.set_handler(Title::EXCMD[c][2], method(:command_extra)) end @command_window.select(@index) if @index >= 0 end #-------------------------------------------------------------------------- # ● コマンド[ニューゲーム] #-------------------------------------------------------------------------- alias command_new_game_title command_new_game def command_new_game map_clear if Title::TB_MAP command_new_game_title end #-------------------------------------------------------------------------- # ● コマンド[拡張コマンド] #-------------------------------------------------------------------------- def command_extra close_command_window map_clear if Title::TB_MAP SceneManager.call(Title::EXCMD[@command_window.cmd_no][1]) end #-------------------------------------------------------------------------- # ● 天候スプライトの作成 #-------------------------------------------------------------------------- def create_weather @w_viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @w_viewport.z = 100 @weather = Spriteset_Weather.new(@w_viewport) @weather.type = Title::WEATHER_TYPE @weather.power = Title::WEATHER_POWER @weather.update end #-------------------------------------------------------------------------- # ● 天候スプライトの解放 #-------------------------------------------------------------------------- def dispose_weather @w_viewport.dispose @weather.dispose end #-------------------------------------------------------------------------- # ● 天候スプライトのフレーム更新 #-------------------------------------------------------------------------- def update_weather @weather.update end #-------------------------------------------------------------------------- # ● タイトル画面の音楽演奏 #-------------------------------------------------------------------------- alias play_title_music_title play_title_music def play_title_music play_title_music_title Title::BGS.play unless Title::BGS.nil? end #-------------------------------------------------------------------------- # ● マップ表示のクリア(マップ使用時はfreezeして、画面をクリアする) #-------------------------------------------------------------------------- def map_clear Graphics.freeze $game_map.screen.clear end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_background update_timeout end #-------------------------------------------------------------------------- # ● タイムアウト #-------------------------------------------------------------------------- def update_timeout @timecnt += 1 if @timecnt >= Title::TIME_OUT_CNT map_clear if Title::TB_MAP fadeout_all SceneManager.goto(Scene_Title) SceneManager.scene.prepare(Title::Scene::S_START, true) end end end #============================================================================== # ■ Window_TitleCommand #------------------------------------------------------------------------------ #  タイトル画面で、ニューゲーム/コンティニューを選択するウィンドウです。 #============================================================================== class Window_TitleCommand < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_title initialize def initialize @slot_n = 0 @slot_chg = false @cmds = enable_cmd_list initialize_title Title.cmd_window_opacity(self) Title.set_cmd_bitmap(self.contents) end #-------------------------------------------------------------------------- # ● 行の高さを取得 #-------------------------------------------------------------------------- def line_height Title::CMD_TYPE ? Title::CMD_RECT.height : Cache.system(Title::CMD_GRPHIC[0][0]).height end #-------------------------------------------------------------------------- # ● ウィンドウ内容の作成 #-------------------------------------------------------------------------- def create_contents super Title.set_cmd_bitmap(self.contents) end #-------------------------------------------------------------------------- # ● カーソルの移動処理 #-------------------------------------------------------------------------- def process_cursor_move return unless cursor_movable? @slot_chg = false super Sound.play_cursor if @slot_chg end #-------------------------------------------------------------------------- # ● アライメントの取得 #-------------------------------------------------------------------------- def alignment Title::CT_ALIGN end #-------------------------------------------------------------------------- # ● コマンド番号取得 #-------------------------------------------------------------------------- def command_no(index) @list[index][:ext] end def cmd_no @list[@index][:ext] end #-------------------------------------------------------------------------- # ● テキスト幅 #-------------------------------------------------------------------------- def cmd_width_max(add_w=0) sizes = [] item_max.times{ |i| sizes.push(cmd_text_w(i) + (i * add_w)) } return sizes.max + 8 end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width [160, cmd_width_max(Title::CMD_RECT.width) + standard_padding * 2].max end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 #-------------------------------------------------------------------------- def align_x(index, x=0) if Title::CMD_TYPE case alignment when 0; #non when 1; return (cmd_width_max + x - cmd_text_w(command_no(index))) / 2 when 2; return cmd_width_max + x - cmd_text_w(command_no(index)) end end return 0 end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 #-------------------------------------------------------------------------- def item_rect(index) rect = super(index) rect.x += index * Title::CMD_RECT.width if Title::CT_CUR_FIT rect.x += align_x(index, -8) rect.width = cmd_text_w(command_no(index)) + 8 end rect end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得(テキスト用) #-------------------------------------------------------------------------- def item_rect_for_text(index) rect = super(index) if Title::CT_CUR_FIT rect.x -= align_x(index, 8) rect.width = cmd_width_max + 8 end rect end #-------------------------------------------------------------------------- # ● ウィンドウ位置の更新 #-------------------------------------------------------------------------- def update_placement self.x = Title::CMD_RECT.x < 0 ? (Graphics.width - width) / 2 : Title::CMD_RECT.x self.y = Title::CMD_RECT.y < 0 ? (Graphics.height * 1.6 - height) / 2 : Title::CMD_RECT.y end #-------------------------------------------------------------------------- # ● 表示対象のコマンドリスト #-------------------------------------------------------------------------- def enable_cmd_list Title::CMD_BOX.uniq.select { |c| Title.excmd_enable?(c) } end def cmd_list slot_shift end #-------------------------------------------------------------------------- # ● コマンドごとのテキスト幅 #-------------------------------------------------------------------------- def cmd_text_w(index) if Title::CMD_TYPE if disposed? b = Title.set_cmd_bitmap(Bitmap.new(1,1)) w = b.text_size(command_name(index)).width b.dispose else w = contents.text_size(command_name(index)).width end else w = Cache.system(Title::CMD_GRPHIC[command_no(index)][0]).width end return w end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list cmd_list.each do |c| case c when 0; add_command(Vocab::new_game, :new_game, true, c) when 1; add_command(Vocab::continue, :continue, continue_enabled, c) when 2; add_command(Vocab::shutdown, :shutdown, true, c) else; add_command(Title::EXCMD[c][0], Title::EXCMD[c][2], true, c) end end end #-------------------------------------------------------------------------- # ● スロット式の固定Index #-------------------------------------------------------------------------- def slot_i ((@cmds.size-1)/2).truncate end #-------------------------------------------------------------------------- # ● カーソル位置の設定 #-------------------------------------------------------------------------- def index=(index) if Title::CMD_SLOT @slot_n = (slot_i - index) % item_max @slot_chg = @slot_n != 0 super(slot_i) refresh else super(index) end end #-------------------------------------------------------------------------- # ● 項目の選択 #-------------------------------------------------------------------------- def select(index) old_index = @index super(index) if !Title::CMD_SLOT and Title::CMD_CHNG redraw_item(old_index) redraw_item(index) end end #-------------------------------------------------------------------------- # ● スロットシフト #-------------------------------------------------------------------------- def slot_shift if Title::CMD_SLOT @slot_n.abs.times do |i| @cmds.unshift(@cmds.pop) if @slot_n > 0 @cmds.push(@cmds.shift) if @slot_n < 0 end end @cmds end #-------------------------------------------------------------------------- # ● スロット表示時の不透明化 #-------------------------------------------------------------------------- def slot_alpha(index) return 0 if Title::CMD_SLOT_ALL (@index-index).abs < 2 ? 0 : 255 end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) Title::CMD_TYPE ? draw_item_text(index) : draw_cmd(index) end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item_text(index) change_color(normal_color, command_enabled?(index)) contents.font.color.alpha -= slot_alpha(index) if Title::CMD_SLOT draw_text(item_rect_for_text(index), command_name(index), alignment) end #-------------------------------------------------------------------------- # ● 画像描画 #-------------------------------------------------------------------------- def draw_cmd(index) g = Title::CMD_GRPHIC[command_no(index)] b = Cache.system((Title::CMD_CHNG and index != @index) ? g[1] : g[0]) rect = item_rect_for_text(index) opacity = command_enabled?(index) ? 255 : translucent_alpha opacity -= slot_alpha(index) if Title::CMD_SLOT contents.blt(rect.x, rect.y, b, Rect.new(0,0,b.width,b.height), opacity) end #-------------------------------------------------------------------------- # ● カーソルの更新 #-------------------------------------------------------------------------- def update_cursor Title::DISABLE_CURSOR ? cursor_rect.empty : super end end