eugene222

FF 9 File Scene

Jul 23rd, 2014
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.24 KB | None | 0 0
  1. #===============================================================================
  2. # ** FF 9 File Scene **
  3. #  
  4. # Author:       Evgenij
  5. # Version:      1.0
  6. # Date:         23.07.2014
  7. #
  8. # Terms of Use: http://evgenij-scripts.org/?page_id=34
  9. #
  10. # Thanks:   Perusa      - for the request
  11. #       BigEd781    - for the VX Script, I have used his pictures
  12. #                 as reference for this script.
  13. #===============================================================================
  14. # Description:
  15. #   This script tries to mimick the Final Fantasy 9 Save Menu.
  16. #   It is plug and play, but you need to delete your old savefiles first.
  17. #  
  18. #   I
  19. #===============================================================================
  20. module EVG
  21.   #=============================================================================
  22.   # CONFIG START
  23.   #=============================================================================
  24.   module FileConfig
  25.    
  26.     SAVE_SLOTS = 16
  27.    
  28.     LOCATION_ICON = 231
  29.     TIME_ICON = 280
  30.     GOLD_ICON = 361
  31.    
  32.     EMPTY_TEXT = "--- LEER ---"
  33.     SELECT_TEXT = "Wähle einen Slot"
  34.     SLOT_TEXT = "Slot"
  35.     SAVE_TEXT = "Speichern"
  36.     LOAD_TEXT = "Laden"
  37.   end
  38.   #=============================================================================
  39.   # CONFIG END
  40.   #=============================================================================
  41.   module FileTopWindows
  42.     #--------------------------------------------------------------------------
  43.     V_SPACING = 12
  44.     H_SPACING = 12
  45.     SWINDOW_WIDTH = 96
  46.     SWINDOW_PADDING = 6
  47.     #--------------------------------------------------------------------------
  48.     def description_window_width
  49.       Graphics.width - (H_SPACING * 2) - SWINDOW_WIDTH * 2 - SWINDOW_PADDING
  50.     end
  51.     #--------------------------------------------------------------------------
  52.     def standard_padding
  53.       return 6
  54.     end
  55.     #--------------------------------------------------------------------------
  56.     def window_height
  57.       return fitting_height(1)
  58.     end
  59.     #--------------------------------------------------------------------------
  60.   end
  61.   #=============================================================================
  62. end
  63. #===============================================================================
  64. module DataManager
  65.   #--------------------------------------------------------------------------
  66.   class << self
  67.     alias :evg_dm_msh_sff9      :make_save_header
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   def self.savefile_max
  71.     return EVG::FileConfig::SAVE_SLOTS
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   def self.make_save_header
  75.     header = evg_dm_msh_sff9
  76.     header[:faces] = $game_party.faces_for_savefile
  77.     header[:location] = $game_map.display_name
  78.     header[:leader_name] = $game_party.leader.name
  79.     header[:leader_level] = $game_party.leader.level
  80.     header[:gold] = $game_party.gold
  81.     header
  82.   end
  83.   #--------------------------------------------------------------------------
  84. end
  85. #===============================================================================
  86. class Game_Party
  87.   #--------------------------------------------------------------------------
  88.   def faces_for_savefile
  89.     battle_members.collect do |actor|
  90.       [actor.face_name, actor.face_index]
  91.     end
  92.   end
  93.   #--------------------------------------------------------------------------
  94. end
  95. #===============================================================================
  96. class Window_FileDescription < Window_Base
  97.   #--------------------------------------------------------------------------
  98.   include EVG::FileTopWindows
  99.   #--------------------------------------------------------------------------
  100.   def initialize
  101.     super(H_SPACING, V_SPACING, description_window_width, window_height)
  102.     refresh
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   def window_height
  106.     return fitting_height(1)
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   def refresh
  110.     contents.clear
  111.     draw_text_ex(12, 0, EVG::FileConfig::SELECT_TEXT)
  112.   end
  113.   #--------------------------------------------------------------------------
  114. end
  115. #===============================================================================
  116. class Window_FileSlot < Window_Base
  117.   #--------------------------------------------------------------------------
  118.   include EVG::FileTopWindows
  119.   #--------------------------------------------------------------------------
  120.   def initialize
  121.     super(window_x, V_SPACING, window_width, window_height)
  122.     @slot = "1"
  123.     refresh
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   def window_x
  127.     return H_SPACING + description_window_width
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   def window_width
  131.     return SWINDOW_WIDTH
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   def window_height
  135.     fitting_height(1)
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   def slot=(slot)
  139.     @slot = slot
  140.     refresh
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   def refresh
  144.     contents.clear
  145.     draw_text(0, 0, contents.width, line_height, "#{EVG::FileConfig::SLOT_TEXT} #{@slot}", 1)
  146.   end
  147.   #--------------------------------------------------------------------------
  148. end
  149. #===============================================================================
  150. class Window_FileInfo < Window_Base
  151.   #--------------------------------------------------------------------------
  152.   include EVG::FileTopWindows
  153.   #--------------------------------------------------------------------------
  154.   def initialize(type = "")
  155.     super(window_x, V_SPACING, window_width, window_height)
  156.     refresh(type)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   def window_x
  160.     H_SPACING + description_window_width + SWINDOW_WIDTH + SWINDOW_PADDING
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   def window_width
  164.     return SWINDOW_WIDTH
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   def window_height
  168.     return fitting_height(1)
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   def refresh(type)
  172.     contents.clear
  173.     draw_text(0, 0, contents.width, line_height, type, 1)
  174.   end
  175. end
  176. #===============================================================================
  177. class Window_SaveFile < Window_Base
  178.   #--------------------------------------------------------------------------
  179.   def initialize(height, index)
  180.     super(window_x, index * height, window_width, height)
  181.     @file_index = index
  182.     get_header
  183.     refresh
  184.     @selected = false
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   def get_header
  188.     @header = DataManager.load_header(@file_index)
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   def header
  192.     return @header
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   def window_x
  196.     return EVG::FileTopWindows::H_SPACING
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   def window_width
  200.     return Graphics.width - EVG::FileTopWindows::H_SPACING * 2
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   def text_x
  204.     return 72 * 4 + 6
  205.   end
  206.   #--------------------------------------------------------------------------
  207.   def text_width
  208.     (contents.width - text_x) / 2
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   def draw_face(face_name, face_index, x, y)
  212.     bitmap = Cache.face(face_name)
  213.     rect = Rect.new(face_index % 4 * 96 + 12, face_index / 4 * 96 + 12, 70, 71)
  214.     contents.blt(x, y, bitmap, rect)
  215.     bitmap.dispose
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   def refresh
  219.     contents.clear
  220.     change_color(normal_color)
  221.     if header
  222.       draw_party_faces(72, 0)
  223.       draw_leader_name(text_x, 3)
  224.       draw_leader_level(text_x, line_height + 2)
  225.       draw_location(text_x, line_height * 2)
  226.       draw_playtime(text_x + text_width, 3)
  227.       draw_gold(text_x + text_width, line_height + 2)
  228.     else
  229.       draw_text(0,0, contents.width, contents.height, EVG::FileConfig::EMPTY_TEXT, 1)
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   def draw_party_faces(x, y)
  234.     header[:faces].each_with_index do |data, i|
  235.       draw_face(data[0], data[1], x * i + 2, y + 2)
  236.     end
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   def draw_leader_name(x, y, width = 112)
  240.     draw_text(x, y, width, line_height, header[:leader_name])
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   def draw_leader_level(x, y)
  244.     change_color(system_color)
  245.     draw_text(x, y, 32, line_height, Vocab::level_a)
  246.     change_color(normal_color)
  247.     draw_text(x + 32, y, 24, line_height, header[:leader_level], 2)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   def draw_location(x, y)
  251.     return if header[:location].empty?
  252.     draw_icon(EVG::FileConfig::LOCATION_ICON, x, y)
  253.     draw_text(x + 28, y, text_width * 2 - 28, line_height, header[:location])
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   def draw_playtime(x, y)
  257.     draw_icon(EVG::FileConfig::TIME_ICON, x - 12, y)
  258.     draw_text(x, y, text_width - 6, line_height, header[:playtime_s], 2)
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   def draw_gold(x, y)
  262.     draw_icon(EVG::FileConfig::GOLD_ICON, x - 12, y)
  263.     draw_text(x, y, text_width - 6, line_height, header[:gold], 2)
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   def update_cursor
  267.     if @selected
  268.       cursor_rect.set(contents.rect)
  269.     else
  270.       cursor_rect.empty
  271.     end
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   def standard_padding
  275.     return 6
  276.   end
  277.   #--------------------------------------------------------------------------
  278. end
  279. #===============================================================================
  280. class Scene_File < Scene_MenuBase
  281.   #--------------------------------------------------------------------------
  282.   def start
  283.     super
  284.     create_help_window
  285.     create_info_window
  286.     create_slot_window
  287.     create_savefile_viewport
  288.     create_savefile_windows
  289.     init_selection
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   def create_help_window
  293.     @help_window = Window_FileDescription.new
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   def create_slot_window
  297.     @slot_window = Window_FileSlot.new
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   def create_info_window
  301.     return
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   def terminate
  305.     super
  306.     @savefile_viewport.dispose
  307.     @savefile_windows.each {|window| window.dispose }
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   def create_savefile_viewport
  311.     @savefile_viewport = Viewport.new
  312.     @savefile_viewport.rect.y = @help_window.height + EVG::FileTopWindows::V_SPACING + 6
  313.     @savefile_viewport.rect.height -= @help_window.height + 6 + (EVG::FileTopWindows::V_SPACING * 2) + 1
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   def update_cursor
  317.     last_index = @index
  318.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  319.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  320.     cursor_pagedown   if Input.trigger?(:R)
  321.     cursor_pageup     if Input.trigger?(:L)
  322.     if @index != last_index
  323.       Sound.play_cursor
  324.       @savefile_windows[last_index].selected = false
  325.       @savefile_windows[@index].selected = true
  326.       @slot_window.slot = @index + 1 if @slot_window
  327.     end
  328.   end
  329.   #--------------------------------------------------------------------------
  330. end
  331. #===============================================================================
  332. class Scene_Save
  333.   #--------------------------------------------------------------------------
  334.   def create_info_window
  335.     @info_window = Window_FileInfo.new(EVG::FileConfig::SAVE_TEXT)
  336.   end
  337.   #--------------------------------------------------------------------------
  338. end
  339. #===============================================================================
  340. class Scene_Load
  341.   #--------------------------------------------------------------------------
  342.   def create_info_window
  343.     @info_window = Window_FileInfo.new(EVG::FileConfig::LOAD_TEXT)
  344.   end
  345.   #--------------------------------------------------------------------------
  346. end
  347. #===============================================================================
  348. # SCRIPT END
  349. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment