ZS Compact Title Screen
ZS Compact Title Screen // Forum request. Combines the save menu and title menu into one.Customization:
[*]Enable or disable the Continue command. If enabled, you have to click on Continue to scroll through save files. If disabled, you can scroll through the save files and command menu at the same time. (left/right for command window, up/down for the save files.)
[*]Adjust the width of both windows, and adjust the offset of the characters drawn in the save files.
Screenshots:
Setup:
[*]Paste under the Materials slot, above main.
[*]This script does not write over Scene_Title. It's a new scene (Scene_TitleFile).
Known issues:
[*]None.
Usage Notes:
[*]Don't remove the author part of the header.
[*]Script is allowed for commercial and non-commercial projects.
[*]Users are free to modify the script as they wish for their own projects.
[*]Extra credit: PencilCase27, for their horizontal commands code. https://forums.rpgmakerweb.com/index.php?threads/titlescreen-with-horizontal-commands.32262/
Code:
#==============================================================================
#
# ** Title: ZS Compact Title Screen 1.0
# Created: August 2019
# Creator: ZirconStorms
# Extra Credits: PencilCase27 (Horizontal Commands code)
#
#------------------------------------------------------------------------------
# ** Description: Combines the save menu and title menu into one.
#------------------------------------------------------------------------------
#
# Script is allowed for commercial and non-commercial games.
# In the game's credits or read.me, credit "ZirconStorms" and "PencilCase27".
# No compatibility fixes will be provided unless frequently asked.
#
#==============================================================================
# Customizable Section Begins Here.
#==============================================================================
module ZIRCON_TITLEFILE
CONTINUE_OPTION = false
#If set to false, you'll be able to control both menus at the same time.
#If set to true, you'll need to click on Continue to navigate the save files.
SHOW_TITLEGRAPHICS = true
#Show the titlescreen graphics if true, black background if false.
#Because this menu layout is crowded, the game title won't be drawn.
WINDOW_WIDTHS = 400 #Graphics.width
#set it to the value (in pixels) you want both the title and save file
#windows to have. Graphics.width = Full width of your game's window.
CHARACTEROFFSET = 45
#offsets the character sprites (to the left) by that value (in pixels).
end
#==============================================================================
# Customizable Section Ends Here.
#==============================================================================
class Window_TitleCommand < Window_Command
#--------------------------------------------------------------------------
def initialize
super(0, 0)
if ZIRCON_TITLEFILE::CONTINUE_OPTION == true
select_symbol(:continue) if continue_enabled
select_symbol(:new_game) if !continue_enabled
else
select_symbol(:new_game)
end
self.openness = 255
self.x = (Graphics.width - width) / 2
open
end
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled) if ZIRCON_TITLEFILE::CONTINUE_OPTION == true
add_command(Vocab::shutdown, :shutdown)
end
#--------------------------------------------------------------------------
def window_width
return ZIRCON_TITLEFILE::WINDOW_WIDTHS
end
#--------------------------------------------------------------------------
def window_height
return line_height + 24
end
#--------------------------------------------------------------------------
def col_max
return item_max
end
#--------------------------------------------------------------------------
def alignment
return 1
end
#--------------------------------------------------------------------------
end #Window_TitleCommand
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
def self.first_scene_class
$BTEST ? Scene_Battle : Scene_TitleFile
end
#--------------------------------------------------------------------------
end #SceneManager
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :selected # selected
#--------------------------------------------------------------------------
# * Object Initialization
# index : index of save files
#--------------------------------------------------------------------------
def initialize(height, index)
super(0, index * height, Graphics.width, height)
@file_index = index
refresh
@selected = false
self.width = ZIRCON_TITLEFILE::WINDOW_WIDTHS
self.x = (Graphics.width - width) / 2
self.arrows_visible = false #Arrows on the right and left side are hidden.
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
name = Vocab::File + " #{@file_index + 1}"
draw_text(4, 0, 200, line_height, name)
@name_width = text_size(name).width
draw_party_characters(152 - ZIRCON_TITLEFILE::CHARACTEROFFSET, 58)
draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
end
#--------------------------------------------------------------------------
# * Draw Play Time
#--------------------------------------------------------------------------
def draw_playtime(x, y, width, align)
header = DataManager.load_header(@file_index)
return unless header
draw_text(x - (Graphics.width - ZIRCON_TITLEFILE::WINDOW_WIDTHS), y, width, line_height, header[:playtime_s], 2)
end
#--------------------------------------------------------------------------
end #Window_SaveFile
#==============================================================================
class Scene_TitleFile < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
SceneManager.clear
Graphics.freeze
if ZIRCON_TITLEFILE::SHOW_TITLEGRAPHICS == true
create_background
create_foreground
end
create_command_window
play_title_music
create_savefile_viewport
create_savefile_windows
@savedindex = 0
init_selection if ZIRCON_TITLEFILE::CONTINUE_OPTION == false
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
SceneManager.snapshot_for_background
if ZIRCON_TITLEFILE::SHOW_TITLEGRAPHICS == true
dispose_background
dispose_foreground
end
@savefile_viewport.dispose
@savefile_windows.each {|window| window.dispose }
end
#--------------------------------------------------------------------------
# * Create Background
#-------------------------------------------------------------------------
def create_background
@sprite1 = Sprite.new
@sprite1.bitmap = Cache.title1($data_system.title1_name)
@sprite2 = Sprite.new
@sprite2.bitmap = Cache.title2($data_system.title2_name)
center_sprite(@sprite1)
center_sprite(@sprite2)
end
#--------------------------------------------------------------------------
# * Create Foreground
#--------------------------------------------------------------------------
def create_foreground
@foreground_sprite = Sprite.new
@foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
end
#--------------------------------------------------------------------------
# * Create Foreground
#--------------------------------------------------------------------------
def dispose_background
@sprite1.bitmap.dispose
@sprite1.dispose
@sprite2.bitmap.dispose
@sprite2.dispose
end
#--------------------------------------------------------------------------
# * Free Foreground
#--------------------------------------------------------------------------
def dispose_foreground
@foreground_sprite.bitmap.dispose
@foreground_sprite.dispose
end
#--------------------------------------------------------------------------
# * Move Sprite to Screen Center
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@savefile_windows.each {|window| window.update }
update_savefile_selection
end
#--------------------------------------------------------------------------
# * Create Help Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_TitleCommand.new
@command_window.set_handler(:new_game, method(:command_new_game))
@command_window.set_handler(:continue, method(:command_continue))
@command_window.set_handler(:shutdown, method(:command_shutdown))
end
#--------------------------------------------------------------------------
# * Create Save File Viewport
#--------------------------------------------------------------------------
def create_savefile_viewport
@savefile_viewport = Viewport.new
@savefile_viewport.z = 300
@savefile_viewport.rect.y += @command_window.height
@savefile_viewport.rect.height -= @command_window.height
end
#--------------------------------------------------------------------------
# * Create Save File Window
#--------------------------------------------------------------------------
def create_savefile_windows
@savefile_windows = Array.new(item_max) do |i|
Window_SaveFile.new(savefile_height, i)
end
@savefile_windows.each {|window| window.viewport = @savefile_viewport }
end
#--------------------------------------------------------------------------
# * Initialize Selection State
#--------------------------------------------------------------------------
def init_selection
@index = first_savefile_index
@savefile_windows[@index].selected = true
####self.top_index = @index - visible_max / 2
ensure_cursor_visible
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
DataManager.savefile_max
end
#--------------------------------------------------------------------------
# * Get Number of Save Files to Show on Screen
#--------------------------------------------------------------------------
def visible_max
return 4
end
#--------------------------------------------------------------------------
# * Get Height of Save File Window
#--------------------------------------------------------------------------
def savefile_height
@savefile_viewport.rect.height / visible_max
end
#--------------------------------------------------------------------------
# * Get File Index to Select First
#--------------------------------------------------------------------------
def first_savefile_index
return @savedindex
end
#--------------------------------------------------------------------------
# * Get Current Index
#--------------------------------------------------------------------------
def index
@index
end
#--------------------------------------------------------------------------
# * Get Top Index
#--------------------------------------------------------------------------
def top_index
@savefile_viewport.oy / savefile_height
end
#--------------------------------------------------------------------------
# * Set Top Index
#--------------------------------------------------------------------------
def top_index=(index)
index = 0 if index < 0
index = item_max - visible_max if index > item_max - visible_max
@savefile_viewport.oy = index * savefile_height
end
#--------------------------------------------------------------------------
# * Get Bottom Index
#--------------------------------------------------------------------------
def bottom_index
top_index + visible_max - 1
end
#--------------------------------------------------------------------------
# * Set Bottom Index
#--------------------------------------------------------------------------
def bottom_index=(index)
self.top_index = index - (visible_max - 1)
end
#--------------------------------------------------------------------------
# * Update Save File Selection
#--------------------------------------------------------------------------
def update_savefile_selection
return on_savefile_ok if Input.trigger?(:C)
return on_savefile_cancel if Input.trigger?(:B)
update_cursor
end
#--------------------------------------------------------------------------
# * Save File
#--------------------------------------------------------------------------
def on_savefile_ok
end
#--------------------------------------------------------------------------
# * Save File
#--------------------------------------------------------------------------
def on_savefile_cancel
Sound.play_cancel if @activate_files == true
@command_window.activate
@savefile_windows[@index].deactivate
@savedindex = @index
@activate_files = false
end
#--------------------------------------------------------------------------
# * Update Cursor
#--------------------------------------------------------------------------
def update_cursor
last_index = @index
if ZIRCON_TITLEFILE::CONTINUE_OPTION == false
cursor_down (Input.trigger?(:DOWN))if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_pagedown if Input.trigger?(:R)
cursor_pageup if Input.trigger?(:L)
if @index != last_index
Sound.play_cursor
@savefile_windows.selected = false
@savefile_windows[@index].selected = true
end
end
if @activate_files == true
cursor_down (Input.trigger?(:DOWN))if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_pagedown if Input.trigger?(:R)
cursor_pageup if Input.trigger?(:L)
if @index != last_index
Sound.play_cursor
@savefile_windows.selected = false
@savefile_windows[@index].selected = true
end
end
end
#--------------------------------------------------------------------------
# * Move Cursor Down
#--------------------------------------------------------------------------
def cursor_down(wrap)
@index = (@index + 1) % item_max if @index < item_max - 1 || wrap
ensure_cursor_visible
end
#--------------------------------------------------------------------------
# * Move Cursor Up
#--------------------------------------------------------------------------
def cursor_up(wrap)
@index = (@index - 1 + item_max) % item_max if @index > 0 || wrap
ensure_cursor_visible
end
#--------------------------------------------------------------------------
# * Move Cursor One Page Down
#--------------------------------------------------------------------------
def cursor_pagedown
if top_index + visible_max < item_max
self.top_index += visible_max
@index = [@index + visible_max, item_max - 1].min
end
end
#--------------------------------------------------------------------------
# * Move Cursor One Page Up
#--------------------------------------------------------------------------
def cursor_pageup
if top_index > 0
self.top_index -= visible_max
@index = [@index - visible_max, 0].max
end
end
#--------------------------------------------------------------------------
# * Scroll Cursor to Position Within Screen
#--------------------------------------------------------------------------
def ensure_cursor_visible
self.top_index = index if index < top_index
self.bottom_index = index if index > bottom_index
end
#--------------------------------------------------------------------------
# * Command
#--------------------------------------------------------------------------
def command_new_game
if ZIRCON_TITLEFILE::CONTINUE_OPTION == true
DataManager.setup_new_game
#removed close command window effect.
fadeout_all
$game_map.autoplay
SceneManager.goto(Scene_Map)
else
if DataManager.load_game(@index)
Sound.play_load
fadeout_all
$game_system.on_after_load
SceneManager.goto(Scene_Map)
else
DataManager.setup_new_game
#removed close command window effect.
fadeout_all
$game_map.autoplay
SceneManager.goto(Scene_Map)
end
end
end
#--------------------------------------------------------------------------
# * Command
#--------------------------------------------------------------------------
def command_continue
init_selection
@activate_files = true
end
#--------------------------------------------------------------------------
# * Command
#--------------------------------------------------------------------------
def command_shutdown
#removed close command window effect.
fadeout_all
SceneManager.exit
end
#--------------------------------------------------------------------------
# * Play Title Screen Music
#--------------------------------------------------------------------------
def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end
#--------------------------------------------------------------------------
end #Scene_TitleFile
#==============================================================================
class Scene_End < Scene_MenuBase
#--------------------------------------------------------------------------
def command_to_title
close_command_window
fadeout_all
SceneManager.goto(Scene_TitleFile)
end
#--------------------------------------------------------------------------
end #Scene_End
#==============================================================================
本贴来自国际rpgmaker官方论坛作者:tvghost处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/zs-compact-title-screen.111754/
页:
[1]