XP 스크립트

원본: http://www.hbgames.org/forums/viewtopic.php?f=12&t=7212 (이 쓰레드의 두 번째 글)
J.D. Slasha의 편집판: http://www.hbgames.org/forums/viewtopic.php?f=156&t=1502&p=14113

  이전에 편집했던 것에 세이브 장소와 확장자 설정을 추가했습니다.


**원본 내지는 J.D.Slasha의 편집에서 바뀐 점:
- 최대 세이브 갯수를 원하는 대로 설정 가능(원본은 99개)
- RPG Advocate씨의 세이브 덮어쓰기 확인 실장
- 세이브 장소로 지정된 디렉토리가 없을 경우 스크립트에서 자동으로 생성
- 세이브 장소와 확장자 설정 추가.


#==============================================================================
# ■ 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
#==============================================================================

#------------------------------------------------------------------------------
# * 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 = 'Saves/' #Save file location. Default(?): Saves
SAVE_EXT = '.rxdata' #Save file Extension. Default: rxdata
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#{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#{@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#{@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 File.exist?(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+savename, "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#{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+'Save*'+ASM_Setup::SAVE_EXT).size > 0)
end
end

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


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6317
201 기타 Chaos Project Debug System 1.06b by Blizzard file Alkaid 2010.09.07 1370
200 그래픽 Weather Script(버전 불명) by ccoa 1 file Alkaid 2010.09.08 1574
199 메시지 Universal Message System 1.8.0 by ccoa 1 file Alkaid 2010.09.08 2186
198 메뉴 Ring menu edit for SDK2 (Original by Hypershadow180) file Alkaid 2010.09.08 1380
197 메뉴 Ring menu edit (Non-SDK ver.) Alkaid 2010.09.08 1550
196 기타 간단한 Scene_Base Alkaid 2010.09.09 1394
195 아이템 Categorized Items Menu 1.3 by albertfish 1 file Alkaid 2010.09.09 1798
194 메시지 Hermes(Hermes Extends RPGXP Message System) 0.3d by derula Alkaid 2010.09.10 2028
193 전투 DerVVulfman's addons for Mr.Mo's ABS file Alkaid 2010.09.10 1645
192 전투 Mr. Mo's ABS 5.5 13 Alkaid 2010.09.10 3460
191 전투 CTB by Charlie Fleed 3.1 - FF10 스타일의 전투시스템 6 Alkaid 2010.09.10 2978
190 전투 Minkoff's Animated Battlers - Enhanced 13.2 by DerVVulfman Alkaid 2010.09.10 1688
189 메뉴 L's Custom Menu #4: 'Compact' (SDK 2.x 필수) Alkaid 2010.09.11 1764
188 액터 크리쳐 합체, 'SW_CreatureMix(for_rmxp)' by SiotWarrior 21 file 시옷전사 2010.09.11 2782
187 HUD MOG_C_HUD. 6 file Bera 2010.09.11 2337
186 HUD MOG_Active_Hud 3 file Bera 2010.09.11 2470
» 저장 Advanced Save Menu 편집한 것. (SDK2용) Alkaid 2010.09.11 1220
184 메뉴 L's Custom Menu #3: 1인용 메뉴 Revision 1 3 Alkaid 2010.09.12 2367
183 그래픽 MAWS: Modified Advanced Weather Script 1.2 by Agckuu Coceg 2 file Alkaid 2010.09.13 1970
182 액터 Actor Customization 6.0.2 by Synthesize 4 file Alkaid 2010.09.17 1913
Board Pagination Prev 1 ... 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Next
/ 52