SHARE
TWEET

Untitled

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