Advertisement
BigJoshieC

Autosave + Yanfly Save Engine Ace

Dec 20th, 2013
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 33.46 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Ace Save Engine v1.02 and Todd's Autosave v1.1.0
  4. # -- Last Updated: 12/21/13
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SaveEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 12/21/13 - Minor edits by BigJoshieC to fix Autosave name functionality
  17. # 6/25/12 - Made compatible.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # This script provides a new save interface for the player. Along with a new
  23. # interface, the player can also load and delete saves straight from the menu
  24. # itself. This will in turn make the save command from the Main Menu always
  25. # available, but the save option within the new save menu will be enabled
  26. # depending on whether or not it is allowed or disallowed. From the interface,
  27. # the player is given more information regarding the save file including the
  28. # the location the player saved at, the amount of gold available, and any
  29. # variables that you want to show the player as well. This will also autosave
  30. # the game based upon a variable.
  31. #
  32. #==============================================================================
  33. # ▼ Instructions
  34. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. # To install this script, open up your script editor and copy/paste this script
  36. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  37. #
  38. # For first time installers, be warned that loading this script the first time
  39. # may not display all information in the status window for save files made
  40. # before the installation of this script. To remedy this, just load up the save
  41. # and save the file again.
  42. #
  43. #==============================================================================
  44. # ▼ Compatibility
  45. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  46. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  47. # it will run with RPG Maker VX without adjusting.
  48. #
  49. #==============================================================================
  50.  
  51. module YEA
  52.   module SAVE
  53.    
  54.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55.     # - Slot Window Settings -
  56.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57.     # This section adjusts how the slot window appears on the left side of the
  58.     # screen. This also adjusts the maximum number of saves a player can make,
  59.     # the way the slot names appear, and the icons used.
  60.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  61.     MAX_FILES = 24         # Maximum saves a player can make. Without Autosave.
  62.     SLOT_NAME = "File %s"  # How the file slots will be named.
  63.    
  64.     # These are the icons
  65.     SAVE_ICON  = 368       # Icon used to indicate a save is present.
  66.     EMPTY_ICON = 375       # Icon used to indicate an empty file.
  67.    
  68.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  69.     # - Action Window Settings -
  70.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  71.     # This section adjusts how the action window appears, the sound effect
  72.     # played when deleting files, and what appears in the help window above.
  73.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  74.     ACTION_LOAD   = "Load"           # Text used for loading games.
  75.     ACTION_SAVE   = "Save"           # Text used for saving games.
  76.     ACTION_DELETE = "Delete"         # Text used for deleting games.
  77.     DELETE_SOUND  = RPG::SE.new("Collapse3", 100, 100) # Sound for deleting.
  78.    
  79.     # These text settings adjust what displays in the help window.
  80.     SELECT_HELP = "Please select a file slot."
  81.     LOAD_HELP   = "Loads the data from the saved game."
  82.     SAVE_HELP   = "Saves the current progress in your game."
  83.     DELETE_HELP = "Deletes all data from this save file."
  84.    
  85.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  86.     # - Status Window Settings -
  87.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  88.     # This section adjusts how the status window appears in the middle of the
  89.     # screen (that displays the game's data) such as the total playtime, total
  90.     # times saved, total gold, the party's current location, and the variables
  91.     # to be displayed.
  92.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  93.     EMPTY_TEXT = "No Save Data"      # Text used when no save data is present.
  94.     PLAYTIME   = "Playtime"          # Text used for total playtime.
  95.     TOTAL_SAVE = "Total Saves: "     # Text used to indicate total saves.
  96.     TOTAL_GOLD = "Total Gold: "      # Text used to indicate total gold.
  97.     LOCATION   = "Location: "        # Text used to indicate current location.
  98.    
  99.     # These variables will be shown in each of the two columns for those who
  100.     # would want to display more information than just what's shown. Input the
  101.     # variables into the arrays below to designate what data will be shown.
  102.     COLUMN1_VARIABLES = [1, 2, 3]
  103.     COLUMN2_VARIABLES = [4, 5, 6]
  104.    
  105.   end # SAVE
  106. end # YEA
  107.  
  108. module ToddAutoSaveAce
  109.  
  110.       #Autosave file name.
  111.       AUTOSAVEFILENAME = "AutoSave"
  112.      
  113.       #Specify which switches to turn on and off autosave
  114.      
  115.       #Autosave before battle?
  116.       AUTOSAVEBB = 1
  117.      
  118.       #Autosave when menu opened?
  119.       AUTOSAVEM =  2
  120.      
  121.       #Autosave when changing map?
  122.       AUTOSAVETM =  3
  123.      
  124.       #Variable ID that contains the number where the sutosave file will be saved.
  125.       VARIABLE = 1
  126.      
  127.     end
  128. #==============================================================================
  129. # ▼ Editting anything past this point may potentially result in causing
  130. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  131. # halitosis so edit at your own risk.
  132. #==============================================================================
  133.  
  134. #==============================================================================
  135. # ■ Icon
  136. #==============================================================================
  137.  
  138. module Icon
  139.  
  140.   #--------------------------------------------------------------------------
  141.   # self.save_icon
  142.   #--------------------------------------------------------------------------
  143.   def self.save_icon; return YEA::SAVE::SAVE_ICON; end
  144.  
  145.   #--------------------------------------------------------------------------
  146.   # self.empty_icon
  147.   #--------------------------------------------------------------------------
  148.   def self.empty_icon; return YEA::SAVE::EMPTY_ICON; end
  149.    
  150. end # Icon
  151.  
  152. #==============================================================================
  153. # ■ Numeric
  154. #==============================================================================
  155.  
  156. class Numeric
  157.  
  158.   #--------------------------------------------------------------------------
  159.   # new method: group_digits
  160.   #--------------------------------------------------------------------------
  161.   unless $imported["YEA-CoreEngine"]
  162.   def group; return self.to_s; end
  163.   end # $imported["YEA-CoreEngine"]
  164.    
  165. end # Numeric
  166.  
  167. #==============================================================================
  168. # ■ DataManager
  169. #==============================================================================
  170.  
  171. module DataManager
  172.  
  173.   #--------------------------------------------------------------------------
  174.   # overwrite method: savefile_max
  175.   #--------------------------------------------------------------------------
  176.   def self.savefile_max
  177.     return YEA::SAVE::MAX_FILES + 1
  178.   end
  179.  
  180.   #--------------------------------------------------------------------------
  181.   # overwrite method: self.make_save_header
  182.   #--------------------------------------------------------------------------
  183.   def self.make_save_header
  184.     header = {}
  185.     header[:characters]    = $game_party.characters_for_savefile
  186.     header[:playtime_s]    = $game_system.playtime_s
  187.     header[:system]        = Marshal.load(Marshal.dump($game_system))
  188.     header[:timer]         = Marshal.load(Marshal.dump($game_timer))
  189.     header[:message]       = Marshal.load(Marshal.dump($game_message))
  190.     header[:switches]      = Marshal.load(Marshal.dump($game_switches))
  191.     header[:variables]     = Marshal.load(Marshal.dump($game_variables))
  192.     header[:self_switches] = Marshal.load(Marshal.dump($game_self_switches))
  193.     header[:actors]        = Marshal.load(Marshal.dump($game_actors))
  194.     header[:party]         = Marshal.load(Marshal.dump($game_party))
  195.     header[:troop]         = Marshal.load(Marshal.dump($game_troop))
  196.     header[:map]           = Marshal.load(Marshal.dump($game_map))
  197.     header[:player]        = Marshal.load(Marshal.dump($game_player))
  198.     header
  199.   end
  200.  
  201. end # DataManager
  202.  
  203. #==============================================================================
  204. # ■ Window_MenuCommand
  205. #==============================================================================
  206.  
  207. class Window_MenuCommand < Window_Command
  208.  
  209.   #--------------------------------------------------------------------------
  210.   # overwrite method: save_enabled
  211.   #--------------------------------------------------------------------------
  212.   def save_enabled; return true; end
  213.  
  214. end # Window_MenuCommand
  215.  
  216. #==============================================================================
  217. # ■ Window_FileList
  218. #==============================================================================
  219.  
  220. class Window_FileList < Window_Selectable
  221.  
  222.   #--------------------------------------------------------------------------
  223.   # initialize
  224.   #--------------------------------------------------------------------------
  225.   def initialize(dx, dy)
  226.     super(dx, dy, 128, Graphics.height - dy)
  227.     refresh
  228.     activate
  229.     select(SceneManager.scene.first_savefile_index)
  230.   end
  231.  
  232.   #--------------------------------------------------------------------------
  233.   # item_max
  234.   #--------------------------------------------------------------------------
  235.   def item_max; return DataManager.savefile_max; end
  236.  
  237.   #--------------------------------------------------------------------------
  238.   # current_item_enabled?
  239.   #--------------------------------------------------------------------------
  240.   def current_item_enabled?
  241.     header = DataManager.load_header(index)
  242.     return false if header.nil? && SceneManager.scene_is?(Scene_Load)
  243.     return true
  244.   end
  245.  
  246.   #--------------------------------------------------------------------------
  247.   # refresh
  248.   #--------------------------------------------------------------------------
  249.   def refresh
  250.     create_contents
  251.     draw_all_items
  252.   end
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # draw_item
  256.   #--------------------------------------------------------------------------
  257.   def draw_item(index)
  258.     header = DataManager.load_header(index)
  259.     enabled = !header.nil?
  260.     rect = item_rect(index)
  261.     rect.width -= 4
  262.     draw_icon(save_icon?(header), rect.x, rect.y, enabled)
  263.     change_color(normal_color, enabled)
  264.      if index == $game_variables[ToddAutoSaveAce::VARIABLE]
  265.         text = ToddAutoSaveAce::AUTOSAVEFILENAME
  266.       else
  267.         text = sprintf(YEA::SAVE::SLOT_NAME, (index + 1).group)
  268.       end
  269.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  270.   end
  271.  
  272.   #--------------------------------------------------------------------------
  273.   # save_icon?
  274.   #--------------------------------------------------------------------------
  275.   def save_icon?(header)
  276.     return Icon.empty_icon if header.nil?
  277.     return Icon.save_icon
  278.   end
  279.  
  280. end # Window_FileList
  281.  
  282. #==============================================================================
  283. # ■ Window_FileStatus
  284. #==============================================================================
  285.  
  286. class Window_FileStatus < Window_Base
  287.  
  288.   #--------------------------------------------------------------------------
  289.   # initialize
  290.   #--------------------------------------------------------------------------
  291.   def initialize(dx, dy, file_window)
  292.     super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  293.     @file_window = file_window
  294.     @current_index = @file_window.index
  295.     refresh
  296.   end
  297.  
  298.   #--------------------------------------------------------------------------
  299.   # update
  300.   #--------------------------------------------------------------------------
  301.   def update
  302.     super
  303.     return if @file_window.index < 0
  304.     return if @current_index == @file_window.index
  305.     @current_index = @file_window.index
  306.     refresh
  307.   end
  308.  
  309.   #--------------------------------------------------------------------------
  310.   # refresh
  311.   #--------------------------------------------------------------------------
  312.   def refresh
  313.     contents.clear
  314.     reset_font_settings
  315.     @header = DataManager.load_header(@file_window.index)
  316.     if @header.nil?
  317.       draw_empty
  318.     else
  319.       draw_save_contents
  320.     end
  321.   end
  322.  
  323.   #--------------------------------------------------------------------------
  324.   # draw_empty
  325.   #--------------------------------------------------------------------------
  326.   def draw_empty
  327.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  328.     rect = Rect.new(0, 0, contents.width, contents.height)
  329.     contents.fill_rect(rect, colour)
  330.     text = YEA::SAVE::EMPTY_TEXT
  331.     change_color(system_color)
  332.     draw_text(rect, text, 1)
  333.   end
  334.  
  335.   #--------------------------------------------------------------------------
  336.   # draw_save_slot
  337.   #--------------------------------------------------------------------------
  338.   def draw_save_slot(dx, dy, dw)
  339.     reset_font_settings
  340.     change_color(system_color)
  341.     text = sprintf(YEA::SAVE::SLOT_NAME, "")
  342.     draw_text(dx, dy, dw, line_height, text)
  343.     cx = text_size(text).width
  344.     change_color(normal_color)
  345.     draw_text(dx+cx, dy, dw-cx, line_height, (@file_window.index+1).group)
  346.   end
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # draw_save_playtime
  350.   #--------------------------------------------------------------------------
  351.   def draw_save_playtime(dx, dy, dw)
  352.     return if @header[:playtime_s].nil?
  353.     reset_font_settings
  354.     change_color(system_color)
  355.     draw_text(dx, dy, dw, line_height, YEA::SAVE::PLAYTIME, 0)
  356.     change_color(normal_color)
  357.     draw_text(dx, dy, dw, line_height, @header[:playtime_s], 2)
  358.   end
  359.  
  360.   #--------------------------------------------------------------------------
  361.   # draw_save_total_saves
  362.   #--------------------------------------------------------------------------
  363.   def draw_save_total_saves(dx, dy, dw)
  364.     return if @header[:system].nil?
  365.     reset_font_settings
  366.     change_color(system_color)
  367.     text = YEA::SAVE::TOTAL_SAVE
  368.     draw_text(dx, dy, dw, line_height, text)
  369.     cx = text_size(text).width
  370.     change_color(normal_color)
  371.     draw_text(dx+cx, dy, dw-cx, line_height, @header[:system].save_count.group)
  372.   end
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # draw_save_gold
  376.   #--------------------------------------------------------------------------
  377.   def draw_save_gold(dx, dy, dw)
  378.     return if @header[:party].nil?
  379.     reset_font_settings
  380.     change_color(system_color)
  381.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  382.     text = Vocab::currency_unit
  383.     draw_text(dx, dy, dw, line_height, text, 2)
  384.     cx = text_size(text).width
  385.     change_color(normal_color)
  386.     text = @header[:party].gold.group
  387.     draw_text(dx, dy, dw-cx, line_height, text, 2)
  388.   end
  389.  
  390.   #--------------------------------------------------------------------------
  391.   # draw_save_location
  392.   #--------------------------------------------------------------------------
  393.   def draw_save_location(dx, dy, dw)
  394.     return if @header[:map].nil?
  395.     reset_font_settings
  396.     change_color(system_color)
  397.     draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION)
  398.     change_color(normal_color)
  399.     cx = text_size(YEA::SAVE::LOCATION).width
  400.     return if $data_mapinfos[@header[:map]].nil?
  401.     text = @header[:map].display_name
  402.     text = $data_mapinfos[@header[:map].map_id].name if text == ""
  403.     draw_text(dx+cx, dy, dw-cx, line_height, text)
  404.   end
  405.  
  406.   #--------------------------------------------------------------------------
  407.   # draw_save_characters
  408.   #--------------------------------------------------------------------------
  409.   def draw_save_characters(dx, dy)
  410.     return if @header[:party].nil?
  411.     reset_font_settings
  412.     make_font_smaller
  413.     dw = (contents.width - dx) / @header[:party].max_battle_members
  414.     dx += dw/2
  415.     for member in @header[:party].battle_members
  416.       next if member.nil?
  417.       member = @header[:actors][member.id]
  418.       change_color(normal_color)
  419.       draw_actor_graphic(member, dx, dy)
  420.       text = member.name
  421.       draw_text(dx-dw/2, dy, dw, line_height, text, 1)
  422.       text = member.level.group
  423.       draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
  424.       cx = text_size(text).width
  425.       change_color(system_color)
  426.       text = Vocab::level_a
  427.       draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
  428.       dx += dw
  429.     end
  430.   end
  431.  
  432.   #--------------------------------------------------------------------------
  433.   # draw_save_column1
  434.   #--------------------------------------------------------------------------
  435.   def draw_save_column1(dx, dy, dw)
  436.     data = YEA::SAVE::COLUMN1_VARIABLES
  437.     draw_column_data(data, dx, dy, dw)
  438.   end
  439.  
  440.   #--------------------------------------------------------------------------
  441.   # draw_save_column2
  442.   #--------------------------------------------------------------------------
  443.   def draw_save_column2(dx, dy, dw)
  444.     data = YEA::SAVE::COLUMN2_VARIABLES
  445.     draw_column_data(data, dx, dy, dw)
  446.   end
  447.  
  448.   #--------------------------------------------------------------------------
  449.   # draw_column_data
  450.   #--------------------------------------------------------------------------
  451.   def draw_column_data(data, dx, dy, dw)
  452.     return if @header[:variables].nil?
  453.     reset_font_settings
  454.     for variable_id in data
  455.       next if $data_system.variables[variable_id].nil?
  456.       change_color(system_color)
  457.       name = $data_system.variables[variable_id]
  458.       draw_text(dx, dy, dw, line_height, name, 0)
  459.       value = @header[:variables][variable_id].group
  460.       change_color(normal_color)
  461.       draw_text(dx, dy, dw, line_height, value, 2)
  462.       dy += line_height
  463.     end
  464.   end
  465.  
  466.   #--------------------------------------------------------------------------
  467.   # draw_save_contents
  468.   #--------------------------------------------------------------------------
  469.   def draw_save_contents
  470.     draw_save_slot(4, 0, contents.width/2-8)
  471.     draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
  472.     draw_save_total_saves(4, line_height, contents.width/2-8)
  473.     draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
  474.     draw_save_location(4, line_height*2, contents.width-8)
  475.     draw_save_characters(0, line_height*5 + line_height/3)
  476.     draw_save_column1(16, line_height*7, contents.width/2-48)
  477.     draw_save_column2(contents.width/2+16, line_height*7, contents.width/2-48)
  478.   end
  479.  
  480. end # Window_FileStatus
  481.  
  482. #==============================================================================
  483. # ■ Window_FileAction
  484. #==============================================================================
  485.  
  486. class Window_FileAction < Window_HorzCommand
  487.  
  488.   #--------------------------------------------------------------------------
  489.   # initialize
  490.   #--------------------------------------------------------------------------
  491.   def initialize(dx, dy, file_window)
  492.     @file_window = file_window
  493.     super(dx, dy)
  494.     deactivate
  495.     unselect
  496.   end
  497.  
  498.   #--------------------------------------------------------------------------
  499.   # window_width
  500.   #--------------------------------------------------------------------------
  501.   def window_width; Graphics.width - 128; end
  502.  
  503.   #--------------------------------------------------------------------------
  504.   # col_max
  505.   #--------------------------------------------------------------------------
  506.   def col_max; return 3; end
  507.  
  508.   #--------------------------------------------------------------------------
  509.   # update
  510.   #--------------------------------------------------------------------------
  511.   def update
  512.     super
  513.     return if @file_window.index < 0
  514.     return if @current_index == @file_window.index
  515.     @current_index = @file_window.index
  516.     refresh
  517.   end
  518.  
  519.   #--------------------------------------------------------------------------
  520.   # make_command_list
  521.   #--------------------------------------------------------------------------
  522.   def make_command_list
  523.     @header = DataManager.load_header(@file_window.index)
  524.     add_load_command
  525.     add_save_command
  526.     add_delete_command
  527.   end
  528.  
  529.   #--------------------------------------------------------------------------
  530.   # add_load_command
  531.   #--------------------------------------------------------------------------
  532.   def add_load_command
  533.     add_command(YEA::SAVE::ACTION_LOAD, :load, load_enabled?)
  534.   end
  535.  
  536.   #--------------------------------------------------------------------------
  537.   # load_enabled?
  538.   #--------------------------------------------------------------------------
  539.   def load_enabled?
  540.     return false if @header.nil?
  541.     return true
  542.   end
  543.  
  544.   #--------------------------------------------------------------------------
  545.   # add_save_command
  546.   #--------------------------------------------------------------------------
  547.   def add_save_command
  548.     add_command(YEA::SAVE::ACTION_SAVE, :save, save_enabled?)
  549.   end
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # save_enabled?
  553.   #--------------------------------------------------------------------------
  554.   def save_enabled?
  555.     return false if @header.nil? && SceneManager.scene_is?(Scene_Load)
  556.     return false if SceneManager.scene_is?(Scene_Load)
  557.     return false if $game_system.save_disabled
  558.     return true
  559.   end
  560.  
  561.   #--------------------------------------------------------------------------
  562.   # add_delete_command
  563.   #--------------------------------------------------------------------------
  564.   def add_delete_command
  565.     add_command(YEA::SAVE::ACTION_DELETE, :delete, delete_enabled?)
  566.   end
  567.  
  568.   #--------------------------------------------------------------------------
  569.   # delete_enabled?
  570.   #--------------------------------------------------------------------------
  571.   def delete_enabled?
  572.     return false if @header.nil?
  573.     return true
  574.   end
  575.  
  576.   #--------------------------------------------------------------------------
  577.   # update_help
  578.   #--------------------------------------------------------------------------
  579.   def update_help
  580.     case current_symbol
  581.     when :load; @help_window.set_text(YEA::SAVE::LOAD_HELP)
  582.     when :save; @help_window.set_text(YEA::SAVE::SAVE_HELP)
  583.     when :delete; @help_window.set_text(YEA::SAVE::DELETE_HELP)
  584.     end
  585.   end
  586.  
  587. end # Window_FileAction
  588.  
  589. #==============================================================================
  590. # ■ Scene_File
  591. #==============================================================================
  592.  
  593. class Scene_File < Scene_MenuBase
  594.  
  595.   #--------------------------------------------------------------------------
  596.   # overwrite method: start
  597.   #--------------------------------------------------------------------------
  598.   def start
  599.     super
  600.     create_all_windows
  601.   end
  602.  
  603.   #--------------------------------------------------------------------------
  604.   # overwrite method: terminate
  605.   #--------------------------------------------------------------------------
  606.   def terminate
  607.     super
  608.   end
  609.  
  610.   #--------------------------------------------------------------------------
  611.   # overwrite method: update
  612.   #--------------------------------------------------------------------------
  613.   def update
  614.     super
  615.   end
  616.  
  617.   #--------------------------------------------------------------------------
  618.   # new method: create_all_windows
  619.   #--------------------------------------------------------------------------
  620.   def create_all_windows
  621.     create_help_window
  622.     create_file_window
  623.     create_action_window
  624.     create_status_window
  625.   end
  626.  
  627.   #--------------------------------------------------------------------------
  628.   # overwrite method: create_help_window
  629.   #--------------------------------------------------------------------------
  630.   def create_help_window
  631.     @help_window = Window_Help.new
  632.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  633.   end
  634.  
  635.   #--------------------------------------------------------------------------
  636.   # new method: create_file_window
  637.   #--------------------------------------------------------------------------
  638.   def create_file_window
  639.     wy = @help_window.height
  640.     @file_window = Window_FileList.new(0, wy)
  641.     @file_window.set_handler(:ok, method(:on_file_ok))
  642.     @file_window.set_handler(:cancel, method(:return_scene))
  643.   end
  644.  
  645.   #--------------------------------------------------------------------------
  646.   # new method: create_action_window
  647.   #--------------------------------------------------------------------------
  648.   def create_action_window
  649.     wx = @file_window.width
  650.     wy = @help_window.height
  651.     @action_window = Window_FileAction.new(wx, wy, @file_window)
  652.     @action_window.help_window = @help_window
  653.     @action_window.set_handler(:cancel, method(:on_action_cancel))
  654.     @action_window.set_handler(:load, method(:on_action_load))
  655.     @action_window.set_handler(:save, method(:on_action_save))
  656.     @action_window.set_handler(:delete, method(:on_action_delete))
  657.   end
  658.  
  659.   #--------------------------------------------------------------------------
  660.   # new method: create_status_window
  661.   #--------------------------------------------------------------------------
  662.   def create_status_window
  663.     wx = @action_window.x
  664.     wy = @action_window.y + @action_window.height
  665.     @status_window = Window_FileStatus.new(wx, wy, @file_window)
  666.   end
  667.  
  668.   #--------------------------------------------------------------------------
  669.   # new method: on_file_ok
  670.   #--------------------------------------------------------------------------
  671.   def on_file_ok
  672.     @action_window.activate
  673.     index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
  674.     @action_window.select(index)
  675.   end
  676.  
  677.   #--------------------------------------------------------------------------
  678.   # new method: on_action_cancel
  679.   #--------------------------------------------------------------------------
  680.   def on_action_cancel
  681.     @action_window.unselect
  682.     @file_window.activate
  683.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  684.   end
  685.  
  686.   #--------------------------------------------------------------------------
  687.   # new method: on_action_load
  688.   #--------------------------------------------------------------------------
  689.   def on_action_load
  690.     if DataManager.load_game(@file_window.index)
  691.       on_load_success
  692.     else
  693.       Sound.play_buzzer
  694.     end
  695.   end
  696.  
  697.   #--------------------------------------------------------------------------
  698.   # overwrite method: on_load_success
  699.   #--------------------------------------------------------------------------
  700.   def on_load_success
  701.     Sound.play_load
  702.     fadeout_all
  703.     $game_system.on_after_load
  704.     SceneManager.goto(Scene_Map)
  705.   end
  706.  
  707.   #--------------------------------------------------------------------------
  708.   # new method: on_action_save
  709.   #--------------------------------------------------------------------------
  710.   def on_action_save
  711.     @action_window.activate
  712.     if DataManager.save_game(@file_window.index)
  713.       on_save_success
  714.       refresh_windows
  715.     else
  716.       Sound.play_buzzer
  717.     end
  718.   end
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # overwrite method: on_save_success
  722.   #--------------------------------------------------------------------------
  723.   def on_save_success; Sound.play_save; end
  724.  
  725.   #--------------------------------------------------------------------------
  726.   # new method: on_action_delete
  727.   #--------------------------------------------------------------------------
  728.   def on_action_delete
  729.     @action_window.activate
  730.     DataManager.delete_save_file(@file_window.index)
  731.     on_delete_success
  732.     refresh_windows
  733.   end
  734.  
  735.   #--------------------------------------------------------------------------
  736.   # new method: on_delete_success
  737.   #--------------------------------------------------------------------------
  738.   def on_delete_success
  739.     YEA::SAVE::DELETE_SOUND.play
  740.   end
  741.  
  742.   #--------------------------------------------------------------------------
  743.   # new method: refresh_windows
  744.   #--------------------------------------------------------------------------
  745.   def refresh_windows
  746.     @file_window.refresh
  747.     @action_window.refresh
  748.     @status_window.refresh
  749.   end
  750.  
  751. end # Scene_File
  752.  
  753. #==============================================================================
  754. # ■ Scene_Save
  755. #==============================================================================
  756.  
  757. class Scene_Save < Scene_File
  758.  
  759.   #--------------------------------------------------------------------------
  760.   # overwrite method: on_savefile_ok
  761.   #--------------------------------------------------------------------------
  762.   def on_savefile_ok; super; end
  763.  
  764.   #--------------------------------------------------------------------------
  765.   # overwrite method: on_save_success
  766.   #--------------------------------------------------------------------------
  767.   def on_save_success; super; end
  768.  
  769. end # help_window_text
  770.  
  771. #==============================================================================
  772. # ■ Scene_Load
  773. #==============================================================================
  774.  
  775. class Scene_Load < Scene_File
  776.  
  777.   #--------------------------------------------------------------------------
  778.   # overwrite method: on_savefile_ok
  779.   #--------------------------------------------------------------------------
  780.   def on_savefile_ok; super; end
  781.  
  782.   #--------------------------------------------------------------------------
  783.   # overwrite method: on_load_success
  784.   #--------------------------------------------------------------------------
  785.   def on_load_success; super; end
  786.  
  787. end # Scene_Load
  788. #==============================================================================
  789. # ** Autosave
  790. #------------------------------------------------------------------------------
  791. # This module contains the autosave method. This is allows you to use the
  792. # "Autosave.call" command.
  793. #==============================================================================
  794.  
  795. module Autosave
  796.   #--------------------------------------------------------------------------
  797.   # * Call method
  798.   #--------------------------------------------------------------------------
  799.   def self.call
  800.   DataManager.save_game_without_rescue($game_variables[ToddAutoSaveAce::VARIABLE])
  801. end
  802. end
  803. #==============================================================================
  804. # ** Scene_Map
  805. #------------------------------------------------------------------------------
  806. #  This class performs the map screen processing.
  807. #==============================================================================
  808.  
  809. class Scene_Map < Scene_Base
  810.   #--------------------------------------------------------------------------
  811.   # * Preprocessing for Battle Screen Transition
  812.   #--------------------------------------------------------------------------
  813.   def pre_battle_scene
  814.     Graphics.update
  815.     Graphics.freeze
  816.     @spriteset.dispose_characters
  817.     BattleManager.save_bgm_and_bgs
  818.     BattleManager.play_battle_bgm
  819.     Sound.play_battle_start
  820.   Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVEBB] == true
  821. end
  822.   #--------------------------------------------------------------------------
  823.   # * Call Menu Screen
  824.   #--------------------------------------------------------------------------
  825.   def call_menu
  826.     Sound.play_ok
  827.     SceneManager.call(Scene_Menu)
  828.     Window_MenuCommand::init_command_position
  829.   Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVEM] == true
  830. end
  831.   #--------------------------------------------------------------------------
  832.   # * Preprocessing for Transferring Player
  833.   #--------------------------------------------------------------------------
  834.   def pre_transfer
  835.     @map_name_window.close
  836.     case $game_temp.fade_type
  837.     when 0
  838.       fadeout(fadeout_speed)
  839.     when 1
  840.       white_fadeout(fadeout_speed)
  841.     end
  842.   #--------------------------------------------------------------------------
  843.   # * Post Processing for Transferring Player
  844.   #--------------------------------------------------------------------------
  845.   def post_transfer
  846.     case $game_temp.fade_type
  847.     when 0
  848.       Graphics.wait(fadein_speed / 2)
  849.       fadein(fadein_speed)
  850.     when 1
  851.       Graphics.wait(fadein_speed / 2)
  852.       white_fadein(fadein_speed)
  853.     end
  854.     @map_name_window.open
  855.   Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVETM] == true
  856.   end
  857.  end
  858. end
  859. #==============================================================================
  860. #
  861. # ▼ End of File
  862. #
  863. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement