Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ==============================================================================
- ** Custom DataManager
- Author: Tsukihime
- Version: 1.0
- Date: May 18, 2012
- ------------------------------------------------------------------------------
- ** Change log
- 1.0 May 18
- -Initial release
- ------------------------------------------------------------------------------
- This script provides the functionality for saving and loading custom
- data to save files.
- ==============================================================================
- =end
- $imported = {} if $imported.nil?
- $imported["Tsuki_CustomDataManager"] = true
- module DataManager
- class << self
- alias custom_data_load_normal_database load_normal_database
- alias custom_data_make_save_contents make_save_contents
- alias custom_data_extract_save_contents extract_save_contents
- end
- def self.load_normal_database
- custom_data_load_normal_database
- load_custom_database
- end
- #--------------------------------------------------------------------------
- # * Initialize custom data
- #--------------------------------------------------------------------------
- def self.load_custom_database
- $custom_actors = [] if $custom_actors.nil?
- $custom_classes = [] if $custom_classes.nil?
- $custom_skills = [] if $custom_skills.nil?
- $custom_items = [] if $custom_items.nil?
- $custom_weapons = [] if $custom_weapons.nil?
- $custom_armors = [] if $custom_armors.nil?
- $custom_enemies = [] if $custom_enemies.nil?
- $custom_troops = [] if $custom_troops.nil?
- $custom_states = [] if $custom_states.nil?
- $custom_animations = [] if $custom_animations.nil?
- $custom_tilesets = [] if $custom_tilesets.nil?
- $custom_common_events = [] if $custom_common_events.nil?
- $custom_mapinfos = {} if $custom_mapinfos.nil?
- $custom_system = RPG::System.new if $custom_system.nil?
- end
- #--------------------------------------------------------------------------
- # * Merge custom data with game data when saving
- #--------------------------------------------------------------------------
- def self.make_save_contents
- contents = custom_data_make_save_contents
- contents = contents.merge(make_custom_contents)
- contents
- end
- #--------------------------------------------------------------------------
- # * Save custom data
- #--------------------------------------------------------------------------
- def self.make_custom_contents
- contents = {}
- contents[:custom_actors] = $custom_actors
- contents[:custom_classes] = $custom_classes
- contents[:custom_skills] = $custom_skills
- contents[:custom_items] = $custom_items
- contents[:custom_weapons] = $custom_weapons
- contents[:custom_armors] = $custom_armors
- contents[:custom_enemies] = $custom_enemies
- contents[:custom_troops] = $custom_troops
- contents[:custom_states] = $custom_states
- contents[:custom_animations] = $custom_animations
- contents[:custom_tilesets] = $custom_tilesets
- contents[:custom_common_events] = $custom_common_events
- contents[:custom_system] = $custom_system
- contents[:custom_mapinfos] = $custom_mapinfos
- contents
- end
- #--------------------------------------------------------------------------
- # * Modified data load from save file to extract custom data
- #--------------------------------------------------------------------------
- def self.extract_save_contents(contents)
- custom_data_extract_save_contents(contents)
- extract_custom_contents(contents)
- merge_custom_contents
- end
- #--------------------------------------------------------------------------
- # * Load custom data
- #--------------------------------------------------------------------------
- def self.extract_custom_contents(contents)
- $custom_actors = contents[:custom_actors]
- $custom_classes = contents[:custom_classes]
- $custom_skills = contents[:custom_skills]
- $custom_items = contents[:custom_items]
- $custom_weapons = contents[:custom_weapons]
- $custom_armors = contents[:custom_armors]
- $custom_enemies = contents[:custom_enemies]
- $custom_troops = contents[:custom_troops]
- $custom_states = contents[:custom_states]
- $custom_animations = contents[:custom_animations]
- $custom_tilesets = contents[:custom_tilesets]
- $custom_common_events = contents[:custom_common_events]
- $custom_system = contents[:custom_system]
- $custom_mapinfos = contents[:custom_mapinfos]
- end
- #--------------------------------------------------------------------------
- # * Merge custom data with default database data
- #--------------------------------------------------------------------------
- def self.merge_custom_contents
- $data_actors.concat ($custom_actors)
- $data_classes.concat ($custom_classes)
- $data_skills.concat ($custom_skills)
- $data_items.concat ($custom_items)
- $data_weapons.concat ($custom_weapons)
- $data_armors.concat ($custom_armors)
- $data_enemies.concat ($custom_enemies)
- $data_troops.concat ($custom_troops)
- $data_states.concat ($custom_states)
- $data_animations.concat ($custom_animations)
- $data_tilesets.concat ($custom_tilesets)
- $data_common_events.concat ($custom_common_events)
- $data_mapinfos.merge ($custom_mapinfos)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment