XP 스크립트

  파일을 좀 더 수정해서 세이브파일명까지 설정할 수 있도록 하였습니다.  세이브 디렉토리는 기본이 Game.exe가 있는 곳이고('.'), 그 외의 문자열을 쓰면 지정된 이름대로 세이브 디렉토리가 생성됩니다.


#==============================================================================
# ■ ASM - advanced save menu
#------------------------------------------------------------------------------
# by squall // squall@loeher.zzn.com
# edited by J.D. Slasha (1-20-06)
# monday the 28th of november 2005
#
# Allows to have up to 99 files.
# Files are stored inside of the folder 'Saves' inside of the game's folder.
# Don't forget to create that folder if it doesn't already exist.
#==============================================================================
# Save overwriting confirm by RPG Advocate
# Merged & Edited by L
# - 20??-??-??(Date cannot be determined):
# The maximum file quantity can be configured.
# Edited it for RMXP SDK.
# Included RPG Advocate's 'Save file overwriting confirmation'.
# Made it to show some more information, like current money in possesion.
# - 2010-09-11:
# Added save directory name and extension configuration.
# Scene_Title::main_test_continue is modified.
# - 2010-10-05: Added save file name configuration, edited some codes a bit.
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
if Object.const_defined?('SDK')
SDK.log('Advanced Save Menu', 'squall', 1.0, '2005-11-28')

#--------------------------------------------------------------------------
# * Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.0, [1])

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Advanced Save Menu')

module ASM_Setup
SAVE_DIR = '.' #Save file location. Default: Root(.)
SAVE_EXT = 'rxdata' #Save file Extension. Default: rxdata
SAVE_NAME = 'Save' #Save file name. Default: Save
SAVE_MAX_FILES = 12
end

#==============================================================================
# ■ Window_File
#------------------------------------------------------------------------------
#  This window shows a list of recorded save files.
#==============================================================================

class Window_File < Window_Selectable
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize()
super(0, 64, 320, 416)
self.contents = Bitmap.new(width - 32, SAVE_MAX_FILES * 32)
index = $game_temp.last_file_index == nil ? 0 : $game_temp.last_file_index
self.index = index
@item_max = SAVE_MAX_FILES
refresh
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def refresh
time_stamp = Time.at(0)
for i in 0...SAVE_MAX_FILES
filename = "#{SAVE_NAME}#{i + 1}.#{SAVE_EXT}"
self.contents.draw_text(1, i * 32, 32, 32, (i + 1).to_s, 1)
if FileTest.exist?("#{SAVE_DIR}/#{filename}")
size = File.size("#{SAVE_DIR}/#{filename}")
#if size.between?(1000, 999999)
if size.between?(1024, 1048575)
#size /= 1000
size /= 1024
size_str = "#{size} Kb"
#elsif size > 999999
elsif size > 1048575
#size /= 1000000
size /= 1048576
size_str = "#{size} Mb"
else
size_str = size.to_s
end
time_stamp = File.open("#{SAVE_DIR}/#{filename}", "r").mtime
date = time_stamp.strftime("%m/%d/%Y")
time = time_stamp.strftime("%H:%M")
self.contents.draw_text(38, i * 32, 120, 32, date)
self.contents.draw_text(160, i * 32, 100, 32, time)
self.contents.draw_text(0, i * 32, 284, 32, size_str, 2)
end
end
end
end

#==============================================================================
# ■ Window_FileStatus
#------------------------------------------------------------------------------
#  This window shows the status of the currently selected save file
#==============================================================================

class Window_FileStatus < Window_Base
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(save_window)
super(320, 64, 320, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@save_window = save_window
@index = @save_window.index
rect = Rect.new(x + 16, y + (height - 32) / 2 + 16, width - 32, (height - 32) / 2)
@viewport = Viewport.new(rect)
@viewport.z = z + 10
refresh
end
#--------------------------------------------------------------------------
# ● dispose the map and the window
#--------------------------------------------------------------------------
def dispose
tilemap_dispose
@viewport.dispose
super
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y)
face = RPG::Cache.character("SaveFaces/" + actor.character_name, actor.character_hue)
fw = face.width
fh = face.height
src_rect = Rect.new(0, 0, fw, fh)
self.contents.blt(x - fw / 23, y - fh, face, src_rect)
end

def refresh
self.contents.clear
#tilemap_dispose
filename = "#{SAVE_NAME}#{@index + 1}.#{SAVE_EXT}"
return unless FileTest.exist?("#{SAVE_DIR}/#{filename}")
file = File.open("#{SAVE_DIR}/#{filename}", "r")
Marshal.load(file)
frame_count = Marshal.load(file)
for i in 0...6
Marshal.load(file)
end
party = Marshal.load(file)
Marshal.load(file)
map = Marshal.load(file)
for i in 0...party.actors.size
actor = party.actors[i]
#x = i % 1 * 144 +5
x = i % 2 * 144 + 4
#y = i / 1 * 94
#y = i / 2 * 64
y = i / 2 * 94
draw_actor_name(actor, x + 30, y)
draw_actor_level(actor, x + 30, y + 20)
draw_actor_graphic(actor, x + 10, y + 60)
#draw_actor_face(actor,x+10,y+400)
end
total_sec = frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
map_name = load_data("Data/MapInfos.rxdata")[map.map_id].name
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = system_color
#self.contents.draw_text(164, 125, 120, 32, "Play Time: ")
#self.contents.draw_text(164, 170, 120, 32, "Location: ")
self.contents.draw_text(0, 288, 120, 32, "Money:")
self.contents.draw_text(280-cx, 288, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(0, 320, 120, 32, "Play Time:")
self.contents.draw_text(0, 352, 120, 32, "Location:")
self.contents.font.color = normal_color
#self.contents.draw_text(184, 145, 120, 32, text)
#self.contents.draw_text(184, 190, 120, 32, map_name)
self.contents.draw_text(100, 288, 180-cx-2, 32, party.gold.to_s, 2)
self.contents.draw_text(100, 320, 180, 32, text, 2)
self.contents.draw_text(100, 352, 180, 32, map_name, 2)

#@tilemap = Tilemap.new(@viewport)
#@tilemap.tileset = RPG::Cache.tileset(map.tileset_name)
for i in 0..6
#autotile_name = map.autotile_names[i]
# @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
#@tilemap.map_data = map.data
#@tilemap.ox = map.display_x / 4 + 176
#@tilemap.oy = map.display_y / 4 + 148
end
#--------------------------------------------------------------------------
# ● tilemap_dispose
#--------------------------------------------------------------------------
def tilemap_dispose
unless @tilemap == nil
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
@tilemap = nil
end
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@tilemap.update if @tilemap != nil
if @index != @save_window.index
@index = @save_window.index
refresh
end
super
end
end

#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  Base scene for load and save menus.
#==============================================================================

class Scene_File < SDK::Scene_Base
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the scene
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● main
#--------------------------------------------------------------------------
def main_window
@help_window = Window_Help.new
@help_window.set_text(@help_text)
@file_window = Window_File.new
@status_window = Window_FileStatus.new(@file_window)
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(Input::C)
decision
$game_temp.last_file_index = @file_index
return
end
if Input.trigger?(Input::B)
cancel
return
end
end
#--------------------------------------------------------------------------
# ● return the selected file's name
#--------------------------------------------------------------------------
def filename
return "#{SAVE_NAME}#{@file_window.index + 1}.#{SAVE_EXT}"
end
end

#SDK Edit
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
#  Save menu
#==============================================================================

class Scene_Save < Scene_File
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the save menu
#--------------------------------------------------------------------------
def initialize
super("Select a file to record your progress.")
overwrite_confirm_window
end
#--------------
def overwrite_confirm_window
@confirm_window = Window_Base.new(120, 188, 400, 64) #추가
@confirm_window.contents = Bitmap.new(368, 32)
string = "이 파일에 덮어쓰시겠습니까?"
#@confirm_window.contents.font.name = ["Arial","굴림"]
@confirm_window.contents.font.size = 24
@confirm_window.contents.draw_text(4, 0, 368, 32, string)
@yes_no_window = Window_Command.new(100, ["Yes", "No"])
@confirm_window.visible = false
@confirm_window.z = 1500
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@yes_no_window.x = 270
@yes_no_window.y = 252
@yes_no_window.z = 1500
@mode = 0 #추가 끝
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
Dir.mkdir(SAVE_DIR) unless FileTest.directory?(SAVE_DIR) # Make 'Saves' directory
if FileTest.exist?("#{SAVE_DIR}/#{filename}") #추가-저장할 파일을 덮어쓸 것인가?
@file_window.active = false
@confirm_window.visible = true
@yes_no_window.visible = true
@yes_no_window.active = true
@mode = 1
else
$game_system.se_play($data_system.save_se)
file = File.open("#{SAVE_DIR}/#{filename}", "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
end
# -----------------------------
def update
if @mode == 0
super
else
#@help_window.update
#@yes_no_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @yes_no_window.index == 0
savename = filename
$game_system.se_play($data_system.save_se)
file = File.open("#{SAVE_DIR}/#{filename}", "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
else
$scene = Scene_Menu.new(4)
end
else
@yes_no_window.active = false
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@file_window.active = true
@mode = 0
end
end
if Input.trigger?(Input::B)
@yes_no_window.active = false
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@file_window.active = true
@mode = 0
return
end
end
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● save the current data into the selected file
#--------------------------------------------------------------------------
def write_save_data(file)
write_characters(file)
write_frame(file)
write_setup(file)
write_data(file)
end
#--------------------------------------------------------------------------
# * Make Character Data
#--------------------------------------------------------------------------
def write_characters(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
end
#--------------------------------------------------------------------------
# * Write Frame Count
#--------------------------------------------------------------------------
def write_frame(file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
end
#--------------------------------------------------------------------------
# * Write Setup
#--------------------------------------------------------------------------
def write_setup(file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
end
#--------------------------------------------------------------------------
# * Write Data
#--------------------------------------------------------------------------
def write_data(file)
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, 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
end

#SDK Edit
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
#  Load menu
#==============================================================================

class Scene_Load < Scene_File
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the menu
#--------------------------------------------------------------------------
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..SAVE_MAX_FILES-1
filename = "#{SAVE_NAME}#{i + 1}.#{SAVE_EXT}"
if FileTest.exist?("#{SAVE_DIR}/#{filename}")
file = File.open("#{SAVE_DIR}/#{filename}", "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Select a file to load.")
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
unless FileTest.exist?("#{SAVE_DIR}/#{filename}")
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open("#{SAVE_DIR}/#{filename}", "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● load the selected file
#--------------------------------------------------------------------------
def read_save_data(file)
read_characters(file)
read_frame(file)
read_data(file)
read_edit
read_refresh
end
#--------------------------------------------------------------------------
# * Read Character Data
#--------------------------------------------------------------------------
def read_characters(file)
# Read character data for drawing save file
characters = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Frame Count
#--------------------------------------------------------------------------
def read_frame(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Data
#--------------------------------------------------------------------------
def read_data(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = 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)
end
#--------------------------------------------------------------------------
# * Read Edit
#--------------------------------------------------------------------------
def read_edit
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
#--------------------------------------------------------------------------
# * Refresh Game Party
#--------------------------------------------------------------------------
def read_refresh
# Refresh party members
$game_party.refresh
end
end


#SDK2 Edit
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================

class Scene_Title < SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Test Initialization
#--------------------------------------------------------------------------
def main_test_continue
# Set Continued Enabled Flag
@continue_enabled = (Dir.glob("#{ASM_Setup::SAVE_DIR}/#{ASM_Setup::SAVE_NAME}*.#{ASM_Setup::SAVE_EXT}").size > 0)
end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
end


Comment '3'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
981 HUD [게이지바]3.0버젼「현재시간, 플레이시간, 걸음수, 윈도우 이동 추가」(HelloCoa2Ver3.0) 63 file 코아 코스튬 2010.10.30 4921
980 메시지 메세지플러스3.1v스크립트(얼굴표시,메세지색상,속도등정하는스크립트) 8 백호 2009.02.21 4880
979 윈도우_게이지 (HP, SP, 경험치<소수점포함>… 12 WMN 2008.04.06 4859
978 메뉴 1인 캐릭터 메뉴 스크립트 27 file - 하늘 - 2009.08.06 4790
977 이동 및 탈것 아하! 그렇구나의 3D 신기술 체험 30 아하!잘봤어요. 2010.02.28 4772
976 전투 사이드뷰 배틀 (2003 형식으 전투)| 12 file 아방스 2007.11.09 4744
975 메시지 메세지 표시 업그레이드 11 file 백호 2009.02.21 4729
974 전투 사이드뷰 방식 스크립트. 8 file 백호 2009.02.21 4640
973 HUD 새로운방법의 맵이름 표시 31 file 백호 2009.02.21 4618
972 그래픽 부드럽게 화면이 움직이는 스크립트 입니다. 16 GangSin 2012.09.12 4590
971 전투 ABP 액알 (Action Battle Player) 14 file 백호 2009.02.22 4557
970 HUD HP과 SP 바 19 Man... 2008.11.04 4535
969 이름입력 한글 이름 입력 15 ok하승헌 2010.02.18 4487
968 게이지바 만들기 [헬악이님 제공] 12 file 아방스 2007.11.09 4416
967 메뉴 메뉴에 그림넣기 4 file 백호 2009.02.22 4413
966 퀘스트 퀘스트 다이어리 15 백호 2009.02.21 4408
965 전투 XAS 여러가지버전. 9 §포뇨§ 2010.02.23 4396
964 타이틀/게임오버 타이틀 화면 커스터마이즈 (타이틀 메뉴 바꾸는 스크립트) 9 file №1 2012.08.04 4392
963 온라인 온라인 스크립트입니다^^(예제파일) 7 캉쿤 2011.09.24 4390
962 미니맵 미니맵 만들기~! 14 file 블리치캐릭셋원함 2010.11.24 4350
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52