Advertisement
estriole

EST - SUIKODEN SAVE LOAD SCENE

Jul 2nd, 2013
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.83 KB | None | 0 0
  1. =begin
  2.  ■ Information      ╒═════════════════════════════════════════════════════════╛
  3.  EST - Suikoden Save Scene
  4.  by Estriole
  5.  v.1.2
  6.  
  7.  ■ Changelog        ╒═════════════════════════════════════════════════════════╛
  8.  v1.0 2013.07.02     >     Initial Release
  9.  v1.1 2013.09.26     >     Add confirmation window (Yes / No)
  10.                      >     Patch for moghunter adv_load bar.
  11.                            put this script below moghunter adv_load bar script.
  12.  v1.2 2013.11.14     >     Compatibility with custom resolution script.
  13.                            also add config for max save. if using resolution
  14.                            640x480 it can fit 12 save slot.
  15.                            
  16.  ■ Introduction     ╒═════════════════════════════════════════════════════════╛
  17.    This script recreate Suikoden II Save and Load Scene.
  18.    
  19.  ■ Requirement     ╒═════════════════════════════════════════════════════════╛
  20.    This Script requires YANFLY Party Script to make it work flawlessly
  21.  if not using YANFLY Party script. then the formation won't be listed.
  22.  
  23.  ■ How to Use     ╒═════════════════════════════════════════════════════════╛
  24.  > put "savebackground" image (default... or whatever you set in configuration)
  25.  in your Graphics/System/ folder. *required...
  26.  > You can customize in module estriole whether you want to use party leader as
  27.  save name (default set to false). if true it will use leader name instead of
  28.  fixed actor. if false you can define which actor that used as the save name.
  29.  > $$$ Profit $$$
  30.  
  31. =end
  32. module ESTRIOLE
  33.   module SUIKODEN
  34.     module SAVE
  35.       #if true it will use $game_party.leader name as the save file name
  36.       SUIKODEN_SAVE_USE_LEADER = false
  37.       #if use leader false. it will use $game_actor with above id instead
  38.       SUIKODEN_SAVE_USE_ACTOR = 1
  39.       #save background filename
  40.       SUIKODEN_SAVE_BG_NAME = "savebackground"
  41.       #maximum save slot. if using resolution 640x480 it fit 12 save slot
  42.       MAX_SAVE = 9
  43.     end
  44.   end
  45. end
  46.  
  47. # Save/Load Scene Hijack Patch
  48. module SceneManager
  49.   class << self; alias est_suikosave_menu_hijack_call call; end  
  50.   def self.call(scene_class)
  51.     scene_class = Scene_SuikoSave if scene_class == Scene_Save
  52.     scene_class = Scene_SuikoLoad if scene_class == Scene_Load
  53.     est_suikosave_menu_hijack_call(scene_class)
  54.   end
  55. end
  56.  
  57. module DataManager
  58.   def self.savefile_max
  59.     return ESTRIOLE::SUIKODEN::SAVE::MAX_SAVE
  60.   end
  61. end
  62.  
  63. class Window_SuikoConfirm < Window_Command
  64. include ESTRIOLE::SUIKODEN::SAVE
  65.   def initialize
  66.     dw = 100
  67.     dh = fitting_height *2
  68.     dx = Graphics.width/2 - dw/2
  69.     dy = Graphics.height/2 - dh/2
  70.     @window_width = dw
  71.     @window_height = dh
  72.     super(dx,dy)
  73.     select_last
  74.     deactivate
  75.     hide
  76.   end  
  77.   def window_width; return @window_width ;end
  78.   def window_height; return @window_height ;end
  79.   def current_item_enabled?; true; end
  80.   def command_enabled?(index); true; end
  81.   def ok_enabled?; true; end
  82.   def call_ok_handler
  83.     current_data == "Yes" ? call_handler(:ok) : call_handler(:cancel)
  84.     select_last
  85.   end    
  86.   def select_last
  87.     select(0)
  88.   end
  89.   def make_command_list
  90.     @list = ["Yes","No"]  
  91.   end
  92.   def command_name(index)
  93.     @list[index]
  94.   end
  95. end
  96.  
  97. class Scene_SuikoFile < Scene_Base
  98. include ESTRIOLE::SUIKODEN::SAVE
  99.   def start
  100.     super
  101.     draw_save_bg
  102.     create_save_file_window
  103.     create_save_confirm_window
  104.     create_help_window
  105.     create_info_window
  106.   end
  107.   def update
  108.     super
  109.     @info_window.set_file(@save_file_window.index) if @info_window
  110.   end
  111.   def draw_save_bg
  112.     @background = Sprite.new
  113.     @background.bitmap = Cache.system(SUIKODEN_SAVE_BG_NAME)
  114.   end
  115.   def create_save_file_window
  116.     @save_file_window = Window_Suiko_SaveFile.new
  117.     @save_file_window.set_handler(:ok,method(:on_save_ok))    
  118.     @save_file_window.set_handler(:cancel,method(:return_scene))    
  119.   end
  120.   def create_save_confirm_window
  121.     @save_confirm_window = Window_SuikoConfirm.new
  122.     @save_confirm_window.set_handler(:ok,method(:on_confirm_ok))    
  123.     @save_confirm_window.set_handler(:cancel,method(:on_confirm_cancel))    
  124.   end
  125.   def on_save_ok
  126.     @help_window.set_text(confirm_window_text)
  127.     @save_confirm_window.show.activate
  128.     @save_file_window.deactivate
  129.   end
  130.   def on_confirm_ok
  131.     @save_file_window.activate
  132.   end
  133.   def on_confirm_cancel
  134.     @save_confirm_window.select_last
  135.     @save_confirm_window.hide.deactivate
  136.     @help_window.set_text(help_window_text)
  137.     @save_file_window.activate
  138.   end
  139.   def help_window_text
  140.     Vocab::SaveMessage
  141.   end
  142.   def create_help_window
  143.     @help_window = Window_SuikoFileHelp.new(1)
  144.     @help_window.set_text(help_window_text)
  145.   end
  146.   def create_info_window
  147.     @info_window = Window_SuikoFileMember.new
  148.     @info_window.y = Graphics.height - 120
  149.     @info_window.set_file(0)
  150.   end
  151.   def terminate
  152.     super
  153.     @background.bitmap.dispose
  154.     @background.dispose
  155.   end
  156. end
  157.  
  158. class Scene_SuikoSave < Scene_SuikoFile
  159.   def on_confirm_ok
  160.     if DataManager.save_game(@save_file_window.index)
  161.       on_save_success
  162.     else
  163.       Sound.play_buzzer
  164.     end    
  165.     @save_confirm_window.select_last
  166.     @save_confirm_window.hide.deactivate
  167.     @save_file_window.activate
  168.   end
  169.   def on_save_success
  170.     Sound.play_save
  171.     @save_file_window.refresh
  172.     @info_window.refresh
  173.   end    
  174.   def help_window_text
  175.     Vocab::SaveMessage
  176.   end
  177.   def confirm_window_text
  178.     "Okay to Save to this slot?"
  179.   end
  180. end
  181. class Scene_SuikoLoad < Scene_SuikoFile
  182.   def on_save_ok
  183.     if DataManager.load_game(@save_file_window.index)
  184.       super
  185.     else
  186.     Audio.se_stop
  187.     Sound.play_buzzer
  188.     @save_file_window.activate    
  189.     end
  190.   end
  191.   def on_confirm_ok
  192.     if DataManager.load_game(@save_file_window.index)
  193.       on_load_success
  194.     else
  195.       Sound.play_buzzer
  196.     end
  197.     @save_confirm_window.select_last
  198.     @save_confirm_window.hide.deactivate
  199.     @save_file_window.activate
  200.   end
  201.   def on_load_success
  202.     Sound.play_load
  203.     fadeout_all
  204.     $game_system.on_after_load
  205.     SceneManager.goto(Scene_Map)
  206.   end      
  207.   def help_window_text
  208.     Vocab::LoadMessage
  209.   end
  210.   def confirm_window_text
  211.     "Okay to Load from this slot?"
  212.   end
  213. end
  214.  
  215. class Window_SuikoFileMember < Window_Base
  216.   #--------------------------------------------------------------------------
  217.   # ● オブジェクト初期化
  218.   #--------------------------------------------------------------------------
  219.   def initialize(line_number = 4)
  220.     super(10, line_height, Graphics.width-20, fitting_height(line_number))
  221.     @level = "--"
  222.     @area  = "--------"
  223.     @formation = [0,0,0,0,0,0]
  224.   end
  225.   def set_file(index)
  226.     return if @index == index
  227.     @index = index
  228.     refresh
  229.   end
  230.   def refresh
  231.     contents.clear
  232.     draw_info
  233.   end
  234.   def get_info
  235.     header = DataManager.load_header(@index)
  236.     @level = header ? header[:leader_level] : "--"
  237.     @area  = header ? header[:map_name] : "--------"
  238.     @formation = header ? header[:formation] ? header[:formation] : [0,0,0,0,0,0] : [0,0,0,0,0,0]
  239.   end
  240.   def draw_info
  241.     get_info
  242.     actors = @formation.collect{|pos|
  243.     pos == 0 ? "----------" : $game_actors[pos].name
  244.     }
  245.     change_color(system_color)
  246.     draw_text(0,0,width,line_height,"Level")
  247.     draw_text(0,line_height,width,line_height,"Area")
  248.     change_color(normal_color)
  249.     draw_text(70,0,width-50,line_height,"#{@level}")
  250.     draw_text(70,line_height,width-50,line_height,"#{@area}")
  251.     reset_font_settings
  252.     #draw_formation
  253.     change_color(system_color)
  254.     draw_text(0,2*line_height,width,line_height,"1. ")
  255.     draw_text(150,2*line_height,width,line_height,"2. ")
  256.     draw_text(300,2*line_height,width,line_height,"3. ")
  257.     draw_text(0,3*line_height,width,line_height,"4. ")
  258.     draw_text(150,3*line_height,width,line_height,"5. ")
  259.     draw_text(300,3*line_height,width,line_height,"6. ")
  260.     change_color(normal_color)
  261.     draw_text(0+20,2*line_height,width-20,line_height,"#{actors[0]}")
  262.     draw_text(150+20,2*line_height,width-20,line_height,"#{actors[1]}")
  263.     draw_text(300+20,2*line_height,width-20,line_height,"#{actors[2]}")
  264.     draw_text(0+20,3*line_height,width-20,line_height,"#{actors[3]}")
  265.     draw_text(150+20,3*line_height,width-20,line_height,"#{actors[4]}")
  266.     draw_text(300+20,3*line_height,width-20,line_height,"#{actors[5]}")
  267.    
  268.   end
  269. end
  270.  
  271. class Window_SuikoFileHelp < Window_Base
  272.   #--------------------------------------------------------------------------
  273.   # ● オブジェクト初期化
  274.   #--------------------------------------------------------------------------
  275.   def initialize(line_number = 1)
  276.     super(50, line_height, Graphics.width-100, fitting_height(line_number))
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● テキスト設定
  280.   #--------------------------------------------------------------------------
  281.   def set_text(text)
  282.     if text != @text
  283.       @text = text
  284.       refresh
  285.     end
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● クリア
  289.   #--------------------------------------------------------------------------
  290.   def clear
  291.     set_text("")
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● アイテム設定
  295.   #     item : スキル、アイテム等
  296.   #--------------------------------------------------------------------------
  297.   def set_item(item)
  298.     set_text(item ? item.description : "")
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ● リフレッシュ
  302.   #--------------------------------------------------------------------------
  303.   def refresh
  304.     contents.clear
  305.     draw_text_ex(4, 0, @text)
  306.   end
  307. end
  308.  
  309. class Window_Suiko_SaveFile < Window_Command
  310. include ESTRIOLE::SUIKODEN::SAVE
  311.   def initialize
  312.     dx = 0
  313.     dy = 80
  314.     dw = Graphics.width
  315.     dh = Graphics.height - 80
  316.     @window_width = dw
  317.     @window_height = dh
  318.     @border_window = {}
  319.     super(dx,dy)
  320.     self.opacity = 0
  321.     select_last
  322.   end
  323.   def dispose
  324.     super
  325.     @border_window.each_value do |window|
  326.       window.dispose if window && !window.disposed?
  327.     end
  328.   end
  329.   def item_max
  330.     DataManager.savefile_max
  331.   end
  332.  
  333.   def col_max
  334.     3
  335.   end
  336.   def item_width
  337.     (@window_width - 2 * standard_padding)/ 3 - 2 * standard_padding
  338.   end
  339.   def item_height
  340.     3*line_height-2*standard_padding
  341.   end  
  342.   def item_rect(index)
  343.     rect = Rect.new
  344.     rect.width = item_width
  345.     rect.height = item_height
  346.     rect.x = index % col_max * (item_width + spacing)
  347.     rect.y = index / col_max * (item_height + spacing/2)
  348.     rect
  349.   end
  350.  
  351.   def window_width; return @window_width ;end
  352.   def window_height; return @window_height ;end
  353.   def current_item_enabled?; true; end
  354.   def command_enabled?(index); true; end
  355.   def ok_enabled?; true ; end
  356.   def call_ok_handler; call_handler(:ok); end
  357.   def select_last
  358.     select(0)
  359.   end
  360.   def make_command_list
  361.     @list = Array.new(item_max) do |i|
  362.       @list[i] = "#{Vocab::File} #{i+1}"
  363.     end
  364.     return @list
  365.   end
  366.   def command_name(index)
  367.     @list[index]
  368.   end
  369.   def draw_item(index)
  370.     @border_window[index].dispose if @border_window[index] && !@border_window[index].disposed?
  371.     #@border_window[index] = Window_Base.new(self.x+item_rect(index).x+3,self.y+item_rect(index).y + 5,168,63)
  372.     dw = item_width + 1.25 * standard_padding
  373.     dh = item_height + 1.25 * standard_padding
  374.     @border_window[index] = Window_Base.new(self.x+item_rect(index).x+3,self.y+item_rect(index).y + 5,dw,dh)
  375.     @border_window[index].z = self.z - 10
  376.     header = DataManager.load_header(index)
  377.     return draw_text(item_rect(index).x,item_rect(index).y,item_width,item_height,"No Save File", 1) if !header
  378.     contents.font.bold = true
  379.     contents.font.size = 14
  380.     change_color(normal_color)
  381.     draw_text(10 + item_rect(index).x,item_rect(index).y,item_width,line_height,"#{header[:leader]}", 3)
  382.     change_color(system_color)
  383.     draw_text(10 + item_rect(index).x,item_rect(index).y + line_height,item_width,line_height,"Playtime", 3)
  384.     change_color(normal_color)
  385.     draw_text(10 + item_rect(index).x+item_width/2,item_rect(index).y + line_height,item_width/2,line_height,"#{header[:playtime_s]}", 3)
  386.     reset_font_settings
  387.   end
  388. end
  389.  
  390. module DataManager
  391. include ESTRIOLE::SUIKODEN::SAVE
  392.   class << self; alias est_sksave_saveload_make_save_header make_save_header; end
  393.   def self.make_save_header
  394.       header = est_sksave_saveload_make_save_header
  395.       header[:leader] = $game_actors[SUIKODEN_SAVE_USE_ACTOR].name
  396.       header[:leader] = $game_party.leader.name rescue $game_actors[SUIKODEN_SAVE_USE_ACTOR].name if SUIKODEN_SAVE_USE_LEADER
  397.       header[:leader_level] = $game_actors[SUIKODEN_SAVE_USE_ACTOR].level
  398.       header[:leader_level] = $game_party.leader.level rescue $game_actors[SUIKODEN_SAVE_USE_ACTOR].level if SUIKODEN_SAVE_USE_LEADER
  399.       header[:map_name] = $game_map.display_name
  400.       header[:formation] = $game_party.battle_members_array if $imported["YEA-PartySystem"] == true
  401.       header
  402.   end  
  403. end  
  404.  
  405. #moghunter adv_load_bar patch
  406. if $mog_rgss3_advanced_load_bar
  407. class Scene_SuikoSave < Scene_SuikoFile
  408.  
  409.  #--------------------------------------------------------------------------
  410.  # ● On Save Sucess
  411.  #--------------------------------------------------------------------------                
  412.   alias mog_advloadbar_on_save_success on_save_success
  413.   def on_save_success
  414.       mog_advloadbar_on_save_success
  415.       $game_temp.loadbar_type = 1
  416.       SceneManager.call(Scene_Load_Bar)    
  417.   end
  418.  
  419. end
  420.  
  421. #=============================================================================
  422. # ■ Scene Load
  423. #=============================================================================
  424. class Scene_SuikoLoad < Scene_SuikoFile
  425.  
  426.   #--------------------------------------------------------------------------
  427.   # ● On Load Success
  428.   #--------------------------------------------------------------------------
  429.   alias mog_advloadbar_on_load_success on_load_success
  430.   def on_load_success
  431.       mog_advloadbar_on_load_success
  432.       $game_system.save_bgm      
  433.       RPG::BGM.stop
  434.       $game_temp.loadbar_type = 0
  435.       SceneManager.call(Scene_Load_Bar)              
  436.   end
  437. end
  438. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement