luistop12Jue Sep 12, 2013 5:07 am
SUPER MODERADOR
Hace rato que hunter me hiso . y no he aportado nada xD, Pero en fin.
DESCRIPCIÓN
Con este script podrás salvar tu juego en un estilo unico
USO
- Spoiler:
En el script
SCREENS
DEMO
De momento ninguna
SCRIPT
- Spoiler:
- Código:
#==============================================================================
# ■ VX-RGSS-26 ファイル画面-改 [Ver.1.0.0] by Claimh
#------------------------------------------------------------------------------
# ファイル画面を改変します。
#【変更点】
# ・ファイル構成変更(FileHader化)
# ・現在位置表示追加
# ・顔グラフィック描画追加
#==============================================================================
module SaveEx
# Usar face en menu de guardado (true activado/false desactivado)
USE_FACE = true
# Mostrar el nombre del mapa (true activado/false desactivado)
MAP_NAME = true
# Mostrar el nombre del mapa (true activado/false desactivado)
BASE_NAME = true
end
#==============================================================================
# ■ Game_Map 拡張メソッド
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● マップ名取得
#--------------------------------------------------------------------------
def map_name
mapInfo = load_data(sprintf("Data/MapInfos.rvdata"))
return mapInfo[@map_id].name
end
#--------------------------------------------------------------------------
# ● 親マップID取得
#--------------------------------------------------------------------------
def parent_id
mapInfo = load_data(sprintf("Data/MapInfos.rvdata"))
return mapInfo[@map_id].parent_id
end
#--------------------------------------------------------------------------
# ● 大元の親マップID取得
#--------------------------------------------------------------------------
def base_parent_id
mapInfo = load_data(sprintf("Data/MapInfos.rvdata"))
return search_parent_id(mapInfo)
end
def search_parent_id(mapInfo)
m_id = @map_id
loop do
p_id = mapInfo[m_id].parent_id
return m_id if p_id == 0
m_id = p_id
end
end
#--------------------------------------------------------------------------
# ● 大元の親マップ名取得
#--------------------------------------------------------------------------
def base_map_name
mapInfo = load_data(sprintf("Data/MapInfos.rvdata"))
return mapInfo[search_parent_id(mapInfo)].name
end
end
#==============================================================================
# ■ FileHeader : セーブファイルヘッダ
#==============================================================================
class FileHeader
attr_reader :characters # キャラクター
attr_reader :faces # 顔グラフィック
attr_reader :map_name # マップ名
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@characters = []
@faces = []
for actor in $game_party.members
@characters.push([actor.character_name, actor.character_index])
@faces.push([actor.face_name, actor.face_index])
end
@map_name = SaveEx::BASE_NAME ? $game_map.base_map_name : $game_map.map_name
end
end
#==============================================================================
# ■ Window_SaveFile
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :filename # ファイル名
attr_reader :file_exist # ファイル存在フラグ
attr_reader :time_stamp # タイムスタンプ
attr_reader :selected # 選択状態
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# file_index : セーブファイルのインデックス (0~3)
# filename : ファイル名
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 56 + file_index % 4 * 90, 544, 90)
@file_index = file_index
@filename = filename
load_gamedata
refresh
@selected = false
end
#--------------------------------------------------------------------------
# ● ゲームデータの一部をロード
# スイッチや変数はデフォルトでは未使用 (地名表示などの拡張用) 。
#--------------------------------------------------------------------------
def load_gamedata
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
begin
@header = Marshal.load(file)
@frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
@game_system = Marshal.load(file)
@game_message = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
rescue
@file_exist = false
ensure
file.close
end
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
name = Vocab::File + " #{@file_index + 1}"
self.contents.draw_text(4, 0, 200, WLH, name)
@name_width = contents.text_size(name).width
if @file_exist
SaveEx::USE_FACE ? draw_party_faces(100, -10) : draw_party_characters(152, 58)
self.contents.draw_text(320-16, 0, 200, WLH, @header.map_name, 2) if SaveEx::MAP_NAME
draw_playtime(0, 34, contents.width - 4, 2)
end
end
#--------------------------------------------------------------------------
# ● パーティキャラの描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_party_characters(x, y)
for i in 0...@header.characters.size
name = @header.characters[i][0]
index = @header.characters[i][1]
draw_character(name, index, x + i * 48, y)
end
end
#--------------------------------------------------------------------------
# ● パーティキャラの描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_party_faces(x, y)
for i in 0...@header.faces.size
name = @header.faces[i][0]
index = @header.faces[i][1]
draw_face(name, index, x + i * 90, y) # 4人以上だと文字とかぶる…
end
end
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# saving : セーブフラグ (false ならロード画面)
# from_title : タイトルの「コンティニュー」で呼び出されたフラグ
# from_event : イベントの「セーブ画面の呼び出し」で呼び出されたフラグ
#--------------------------------------------------------------------------
def initialize(saving, from_title, from_event, menu_index=4)
@saving = saving
@from_title = from_title
@from_event = from_event
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 元の画面へ戻る
#--------------------------------------------------------------------------
def return_scene
if @from_title
$scene = Scene_Title.new
elsif @from_event
$scene = Scene_Map.new
else
$scene = Scene_Menu.new(@menu_index)
end
end
#--------------------------------------------------------------------------
# ● セーブデータの書き込み
# file : 書き込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def write_save_data(file)
header = FileHeader.new
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(header, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
# file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def read_save_data(file)
header = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end