Advertisement
LiTTleDRAgo

[RGSS/2] Woratana Neo Save System VI

Feb 1st, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 55.26 KB | None | 0 0
  1. #==========================================================================
  2. # ? [XP/VX] ? Neo Save System VI edited
  3. #---------------------------------------------------------------------------
  4. # ? Author: Woratana [woratana@hotmail.com]
  5. # ? Thaiware RPG Maker Community
  6. # ? Last Updated:
  7. # ? Version: III -> VI (By Helladen)
  8. # ? Screenshot image credit Andreas21, and Cybersam
  9. # ? Commerical usage ask Woratana.
  10. #---------------------------------------------------------------------------
  11. # ? Converted to XP by LiTTleDRAgo
  12. #---------------------------------------------------------------------------
  13. # ? Features:
  14. # - Unlimited save slots, you can choose max save slot
  15. # - Many configuration options
  16. # - Swap tile support
  17. # - You can use image for scene's background
  18. # - Choose your save file's name, and folder to store save files
  19. # - Choose to show only information you want
  20. # - Editable text for information's title
  21. # - Draw tile map for map that player is currently on.
  22. # - Remove text you don't want from map's name (e.g. tags for special script)
  23. # - Choose map that you don't want to show the name on
  24. # - Include save confirmation window before overwrite old save
  25. #
  26. # For XP :
  27. # Put face into folder Graphics/Faces/ and name them into Actor{id}.png
  28. #    ex = Actor1.png
  29. # the faceset must 80x80
  30. #
  31. # Put Iconset.png in VX RTP and put it into folder Graphics/System
  32. #
  33. # Don't forget this script need screenshot.dll
  34. #
  35. #===========================================================================
  36.  
  37. VX = defined?(Window_BattleMessage)
  38. module Wora_NSS Wora_NSS
  39.   #==========================================================================
  40.   # * START NEO SAVE SYSTEM - SETUP
  41.   #--------------------------------------------------------------------------
  42.   OPACITY_DEFAULT = true # This will use the default opacity for windows.
  43.   # Please note that this will affect both opacitys below.
  44.  
  45.   NSS_WINDOW_OPACITY = 255 # All windows' opacity (Lowest 0 - 255 Highest).
  46.   # You can change this to 0 in case you want to use image for background.
  47.  
  48.   NSS_IMAGE_BG = '' # Background image file name, it must be in folder picture
  49.   #                use '' for no background.
  50.   NSS_IMAGE_BG_OPACITY = 255 # Opacity for background image.
  51.  
  52.   CENTER_NAME = true
  53.   # Set this to true will make Actor name center-aligned,
  54.   # if false will become left-aligned
  55.  
  56.   # If you use the screenshot method this does not matter.
  57.   SWAP_TILE = false # Make this false if you don't use the swap_tile script
  58.   SWAP_TILE_SWITCH = 0 # The switch needs to be the same as your swap tile
  59.   #                    switch, but if SWAP_TILE is false it does not matter.
  60.  
  61.   # If this is true it will screenshot the map, if false it will draw it.
  62.   SCREENSHOT_IMAGE = true # Drawing the map is good because it doesn't require
  63.   # a .DLL or images for the screenshot, and it will have tone and
  64.   # weather. If you are using SwapXT and this value is false you need to turn
  65.   # on swap tile.
  66.  
  67.   # Do you want to use your own custom images for each map via map name.
  68.   PREMADE_IMAGE = false # If this is true it sets its priority over
  69.   #                    screenshots/etc.
  70.  
  71.   # Image type for screenshot '.bmp', or '.jpg', or '.png'.
  72.   IMAGE_FILETYPE = '.png'
  73.  
  74.   # If this is true then the scene will not change when you save the game.
  75.   SCENE_CHANGE = false # Changes scene to map instead of remaining in Save screen.
  76.  
  77.   MAX_SAVE_SLOT = 20 # Max save slots.
  78.   SLOT_NAME = 'SLOT {id}'
  79.  
  80.   # Name of the slot (show in save slots list), use {id} for slot ID.
  81.   SAVE_FILE_NAME = VX ? 'Save{id}.rvdata' : 'Save{id}.rxdata'
  82.   # Save file name, you can also change its file type from .rvdata to other.
  83.  
  84.   # Use {id} for save slot ID.
  85.   SAVE_PATH = '' # Path to store save file, e.g. 'Save/' or '' (for game folder).
  86.   SAVED_SLOT_ICON = 133 # Icon Index for saved slot.
  87.  
  88.   EMPTY_SLOT_ICON = 141 # Icon Index for empty slot.
  89.   EMPTY_SLOT_TEXT = 'Empty' # Text to show for empty slot's data.
  90.  
  91.   DRAW_GOLD = true # Draw Gold.
  92.   DRAW_PLAYTIME = true # Draw playtime.
  93.   DRAW_LOCATION = true # Draw location.
  94.   DRAW_FACE = true # Draw actor's face.
  95.   DRAW_LEVEL = true # Draw actor's level.
  96.   DRAW_NAME = true # Draw actor's name.
  97.   DRAW_TEXT_GOLD = false # Draw the vocab::Gold text to the right of the number.
  98.  
  99.   PLAYTIME_TEXT = 'Play Time: '
  100.   GOLD_TEXT = 'Gold: '
  101.   LOCATION_TEXT = 'Location: '
  102.   LV_TEXT = 'Lv. '
  103.  
  104.   MAP_NAME_TEXT_SUB = %w{}
  105.   # Text that you want to remove from map name,
  106.   # e.g. %w{[LN] [DA]} will remove text '[LN]' and '[DA]' from map name.
  107.  
  108.   # Do we want to use corresponding variables for each map number in MAP_NO_NAME_LIST?
  109.   MAP_NO_NAME_VARIABLE = false # You just apply the value one to the variable which
  110.                               # is the map number to change it from MAP_NO_NAME.
  111.  
  112.   MAP_NO_NAME_LIST = [2] # ID of Map that will not show map name, e.g. [1,2,3].
  113.   MAP_NO_NAME = '???' # What you will use to call the map in the no name list.
  114.  
  115.   # This is a switch that can activate or deactivate maps from being displayed as
  116.   # MAP_NO_NAME. If it is off then maps will return back to normal.
  117.   MAP_NO_NAME_SWITCH = nil #95
  118.   # This switch has to be on for MAP_NO_NAME_LIST to work.
  119.  
  120.   MAP_BORDER = Color.new(0,0,0,200) # Map image border color (R,G,B,Opacity).
  121.   FACE_BORDER = Color.new(0,0,0,200) # Face border color.
  122.  
  123.   # Save confirmation window
  124.   SFC_Text_Confirm = 'Lanjutkan Save' # Text to confirm to save file.
  125.   SFC_Text_Cancel = 'Cancel' # Text to cancel to save.
  126.   SFC_Window_Width = 200 # Width of Confirmation Window.
  127.   SFC_Window_X_Offset = 0 # Move Confirmation Window horizontally.
  128.   SFC_Window_Y_Offset = 0 # Move Confirmation Window vertically.
  129.  
  130.   #-------------------------------------------------------------------------
  131.   # END NEO SAVE SYSTEM - SETUP (Edit below at your own risk)
  132.   #=========================================================================
  133.  
  134.   #-------------------------------------------------------------
  135.   # Screenshot V2 by Andreas21 and Cybersam
  136.   #-------------------------------------------------------------
  137.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  138.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  139.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  140.   module_function
  141.  
  142.   def self.shot(file_name)
  143.     case IMAGE_FILETYPE
  144.       when '.bmp'; typid = 0
  145.       when '.jpg'; typid = 1
  146.       when '.png'; typid = 2
  147.     end
  148.    
  149.     # Get Screenshot
  150.     filename = file_name + IMAGE_FILETYPE
  151.       if VX
  152.         @screen.call(0, 0, Graphics.width, Graphics.height, filename,
  153.         self.handel, typid)
  154.       else
  155.         @screen.call(0, 0, 640, 480, filename, self.handel,typid)
  156.       end
  157.     end
  158.    
  159.     def self.handel
  160.     game_name = "\0" * 256
  161.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  162.     game_name.delete!("\0")
  163.    
  164.     return @findwindow.call('RGSS Player',game_name)
  165.   end
  166. end
  167.  
  168. unless VX
  169.   #==============================================================================
  170.   # ** Vocab
  171.   #------------------------------------------------------------------------------
  172.   #  This module defines terms and messages. It defines some data as constant
  173.   # variables. Terms in the database are obtained from $data_system.
  174.   #==============================================================================
  175.   DataSystem = load_data("Data/System.rxdata")
  176.   module Vocab
  177.  
  178.     SaveMessage     = "Save ke File yang mana?"
  179.     LoadMessage     = "Load file yang mana?"
  180.     File            = "File"
  181.    
  182.     def self.gold
  183.       return DataSystem.words.gold
  184.     end
  185.   end
  186.  
  187.   #===============================================================================
  188.   # * Sound Module *
  189.   #  This is a module used by RPG Maker VX - it has been modified to process XP
  190.   #  sound commands.  
  191.   #===============================================================================
  192.   module Sound
  193.  
  194.     def self.play_cursor() $game_system.se_play($data_system.cursor_se) end
  195.     def self.play_decision() $game_system.se_play($data_system.decision_se) end
  196.     def self.play_cancel() $game_system.se_play($data_system.cancel_se) end
  197.     def self.play_buzzer() $game_system.se_play($data_system.buzzer_se) end
  198.     def self.play_equip() $game_system.se_play($data_system.equip_se)end
  199.     def self.play_save() $game_system.se_play($data_system.save_se)  end
  200.     def self.play_load() $game_system.se_play($data_system.load_se)  end
  201.  
  202.     end
  203.    
  204.   module Graphics
  205.    
  206.     def self.width()    640  end
  207.     def self.height()    480  end
  208.    
  209.   end
  210.  
  211.   class Bitmap
  212.     #--------------------------------------------------------------------------
  213.     # * Clear Rectangle
  214.     # by poccil
  215.     #--------------------------------------------------------------------------
  216.     def clear_rect(*arg)
  217.       if arg.length == 4
  218.         fill_rect(arg[0], arg[1], arg[2], arg[3], Color.new(0,0,0,0))      
  219.       elsif arg.length == 1
  220.         fill_rect(arg[0], Color.new(0,0,0,0))
  221.       else
  222.         raise ArgumentError.new
  223.       end
  224.     end
  225.   end
  226.  
  227.   #==============================================================================
  228.   # ** Cache
  229.   #------------------------------------------------------------------------------
  230.   #  This module loads each of graphics, creates a Bitmap object, and retains it.
  231.   # To speed up load times and conserve memory, this module holds the created
  232.   # Bitmap object in the internal hash, allowing the program to return
  233.   # preexisting objects when the same bitmap is requested again.
  234.   #==============================================================================
  235.   module Cache
  236.     #--------------------------------------------------------------------------
  237.     # * Get Face Graphic
  238.     #     filename : Filename
  239.     #--------------------------------------------------------------------------
  240.     def self.face(f) load_bitmap("Graphics/Faces/", f)  end
  241.     #--------------------------------------------------------------------------
  242.     # * Get System Graphic
  243.     #     filename : Filename
  244.     #--------------------------------------------------------------------------
  245.     def self.system(f)  load_bitmap("Graphics/System/", f)  end
  246.     #--------------------------------------------------------------------------
  247.     # * Clear Cache
  248.     #--------------------------------------------------------------------------
  249.     def self.clear
  250.       @cache = {} if @cache == nil
  251.       @cache.clear
  252.       GC.start
  253.     end
  254.     #--------------------------------------------------------------------------
  255.     # * Load Bitmap
  256.     #--------------------------------------------------------------------------
  257.     def self.load_bitmap(folder_name, filename, hue = 0)
  258.       @cache = {} if @cache == nil
  259.       path = folder_name + filename
  260.       if not @cache.include?(path) or @cache[path].disposed?
  261.         if filename.empty?
  262.           @cache[path] = Bitmap.new(32, 32)
  263.         else
  264.           @cache[path] = Bitmap.new(path)
  265.         end
  266.       end
  267.       if hue == 0
  268.         return @cache[path]
  269.       else
  270.         key = [path, hue]
  271.         if not @cache.include?(key) or @cache[key].disposed?
  272.           @cache[key] = @cache[path].clone
  273.           @cache[key].hue_change(hue)
  274.         end
  275.         return @cache[key]
  276.       end
  277.     end
  278.   end
  279.  
  280. end
  281.  
  282. #==============================================================================
  283. # ** Window_Base
  284. #------------------------------------------------------------------------------
  285. #  This is a superclass of all windows in the game.
  286. #==============================================================================
  287.  
  288. class Window_Base_Neo < Window
  289.   #--------------------------------------------------------------------------
  290.   # * Constants
  291.   #--------------------------------------------------------------------------
  292.   WLH = 24                  # Window Line Height
  293.   #--------------------------------------------------------------------------
  294.   # * Object Initialization
  295.   #     x      : window x-coordinate
  296.   #     y      : window y-coordinate
  297.   #     width  : window width
  298.   #     height : window height
  299.   #--------------------------------------------------------------------------
  300.   def initialize(x, y, width, height)
  301.     super()
  302.     unless VX
  303.       @windowskin_name = $game_system.windowskin_name
  304.       self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  305.     else
  306.       self.windowskin = Cache.system("Window")
  307.     end
  308.     self.x = x
  309.     self.y = y
  310.     self.width = width
  311.     self.height = height
  312.     self.z = 100
  313.     self.back_opacity = 200
  314.     self.opacity = 255
  315.     create_contents
  316.     @opening = false
  317.     @closing = false
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Dispose
  321.   #--------------------------------------------------------------------------
  322.   def dispose
  323.     self.contents.dispose
  324.     super
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # * Create Window Contents
  328.   #--------------------------------------------------------------------------
  329.   def create_contents
  330.     self.contents.dispose if self.contents
  331.     self.contents = Bitmap.new(width - 32, height - 32)
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # * Frame Update
  335.   #--------------------------------------------------------------------------
  336.   def update
  337.     super
  338.     if @opening
  339.       self.opacity += 48
  340.       @opening = false if self.opacity >= 255
  341.     elsif @closing
  342.       self.opacity -= 48
  343.       @closing = false if self.opacity <= 0
  344.     end
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # * Open Window
  348.   #--------------------------------------------------------------------------
  349.   def open
  350.     @opening = true if self.opacity < 255
  351.     @closing = false
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # * Close Window
  355.   #--------------------------------------------------------------------------
  356.   def close
  357.     @closing = true if self.opacity > 0
  358.     @opening = false
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # * Get Text Color
  362.   #     n : text color number (0-7)
  363.   #--------------------------------------------------------------------------
  364.   def text_color(n)
  365.     case n
  366.     when 0 then Color.new(255, 255, 255, 255)
  367.     when 1 then Color.new(128, 128, 255, 255)
  368.     when 2 then Color.new(255, 128, 128, 255)
  369.     when 3 then Color.new(128, 255, 128, 255)
  370.     when 4 then Color.new(128, 255, 255, 255)
  371.     when 5 then Color.new(255, 128, 255, 255)
  372.     when 6 then Color.new(255, 255, 128, 255)
  373.     when 7 then Color.new(192, 192, 192, 255)
  374.     else
  375.       normal_color
  376.     end
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # * Get Normal Text Color
  380.   #--------------------------------------------------------------------------
  381.   def normal_color() text_color(0) end
  382.   #--------------------------------------------------------------------------
  383.   # * Get System Text Color
  384.   #--------------------------------------------------------------------------
  385.   def system_color() Color.new(192, 224, 255, 255)  end
  386.   #--------------------------------------------------------------------------
  387.   # * Draw number with currency unit
  388.   #     value : Number (gold, etc)
  389.   #     x     : draw spot x-coordinate
  390.   #     y     : draw spot y-coordinate
  391.   #     width : Width
  392.   #--------------------------------------------------------------------------
  393.   def draw_currency_value(value, x, y, width)
  394.     cx = contents.text_size(Vocab::gold).width
  395.     self.contents.font.color = normal_color
  396.     self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
  397.     self.contents.font.color = system_color
  398.     self.contents.draw_text(x, y, width, WLH, Vocab::gold, 2)
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # * Draw Icon
  402.   #     icon_index : Icon number
  403.   #     x     : draw spot x-coordinate
  404.   #     y     : draw spot y-coordinate
  405.   #     enabled    : Enabled flag. When false, draw semi-transparently.
  406.   #--------------------------------------------------------------------------
  407.   def draw_icon(icon_index, x, y, enabled = true)
  408.     bitmap = Cache.system("Iconset")
  409.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  410.     self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # * Draw Face Graphic
  414.   #     face_name  : Face graphic filename
  415.   #     face_index : Face graphic index
  416.   #     x     : draw spot x-coordinate
  417.   #     y     : draw spot y-coordinate
  418.   #     size       : Display size
  419.   #--------------------------------------------------------------------------
  420.   def draw_face(face_name, face_index, x, y, size = 96)
  421.     bitmap = Cache.face(face_name)rescue Cache.face('')
  422.     rect = Rect.new(0, 0, 0, 0)
  423.     if VX
  424.       rect.x = face_index % 4 * 96 + (96 - size) / 2
  425.       rect.y = face_index / 4 * 96 + (96 - size) / 2
  426.     else
  427.       rect.x = 0
  428.       rect.y = 0
  429.     end
  430.     rect.width = size
  431.     rect.height = size
  432.     self.contents.blt(x, y, bitmap, rect)
  433.     bitmap.dispose
  434.   end
  435. end
  436. #==============================================================================
  437. # ** Window_Selectable
  438. #------------------------------------------------------------------------------
  439. #  This window contains cursor movement and scroll functions.
  440. #==============================================================================
  441.  
  442. class Window_Selectable_Neo < Window_Base_Neo
  443.   #--------------------------------------------------------------------------
  444.   # * Public Instance Variables
  445.   #--------------------------------------------------------------------------
  446.   attr_reader   :item_max                 # item count
  447.   attr_reader   :column_max               # digit count
  448.   attr_reader   :index                    # cursor position
  449.   attr_reader   :help_window              # help window
  450.   #--------------------------------------------------------------------------
  451.   # * Object Initialization
  452.   #     x       : window X coordinate
  453.   #     y       : window Y coordinate
  454.   #     width   : window width
  455.   #     height  : window height
  456.   #     spacing : width of empty space when items are arranged horizontally
  457.   #--------------------------------------------------------------------------
  458.   def initialize(x, y, width, height, spacing = 32)
  459.     @item_max = 1
  460.     @column_max = 1
  461.     @index = -1
  462.     @spacing = spacing
  463.     super(x, y, width, height)
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # * Create Window Contents
  467.   #--------------------------------------------------------------------------
  468.   def create_contents
  469.     self.contents.dispose if self.contents
  470.     self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # * Set Cursor Position
  474.   #     index : new cursor position
  475.   #--------------------------------------------------------------------------
  476.   def index=(index)
  477.     @index = index
  478.     update_cursor
  479.     call_update_help
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # * Get Row Count
  483.   #--------------------------------------------------------------------------
  484.   def row_max()(@item_max + @column_max - 1) / @column_max  end
  485.   #--------------------------------------------------------------------------
  486.   # * Get Top Row
  487.   #--------------------------------------------------------------------------
  488.   def top_row() self.oy / WLH end
  489.   #--------------------------------------------------------------------------
  490.   # * Set Top Row
  491.   #     row : row shown on top
  492.   #--------------------------------------------------------------------------
  493.   def top_row=(row)
  494.     row = 0 if row < 0
  495.     row = row_max - 1 if row > row_max - 1
  496.     self.oy = row * WLH
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # * Get Number of Rows Displayable on 1 Page
  500.   #--------------------------------------------------------------------------
  501.   def page_row_max() (self.height - 32) / WLH  end
  502.   #--------------------------------------------------------------------------
  503.   # * Get Number of Items Displayable on 1 Page
  504.   #--------------------------------------------------------------------------
  505.   def page_item_max() page_row_max * @column_max  end
  506.   #--------------------------------------------------------------------------
  507.   # * Get bottom row
  508.   #--------------------------------------------------------------------------
  509.   def bottom_row() top_row + page_row_max - 1  end
  510.   #--------------------------------------------------------------------------
  511.   # * Set bottom row
  512.   #     row : Row displayed at the bottom
  513.   #--------------------------------------------------------------------------
  514.   def bottom_row=(row) self.top_row = row - (page_row_max - 1) end
  515.   #--------------------------------------------------------------------------
  516.   # * Get rectangle for displaying items
  517.   #     index : item number
  518.   #--------------------------------------------------------------------------
  519.   def item_rect(index)
  520.     rect = Rect.new(0, 0, 0, 0)
  521.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  522.     rect.height = WLH
  523.     rect.x = index % @column_max * (rect.width + @spacing)
  524.     rect.y = index / @column_max * WLH
  525.     return rect
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # * Set Help Window
  529.   #     help_window : new help window
  530.   #--------------------------------------------------------------------------
  531.   def help_window=(help_window)
  532.     @help_window = help_window
  533.     call_update_help
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # * Determine if cursor is moveable
  537.   #--------------------------------------------------------------------------
  538.   def cursor_movable?
  539.     return false if (not visible or not active)
  540.     return false if (index < 0 or index > @item_max or @item_max == 0)
  541.     return false if (@opening or @closing)
  542.     return true
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # * Move cursor down
  546.   #     wrap : Wraparound allowed
  547.   #--------------------------------------------------------------------------
  548.   def cursor_down(wrap = false)
  549.     if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
  550.       @index = (@index + @column_max) % @item_max
  551.     end
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # * Move cursor up
  555.   #     wrap : Wraparound allowed
  556.   #--------------------------------------------------------------------------
  557.   def cursor_up(wrap = false)
  558.     if (@index >= @column_max) or (wrap and @column_max == 1)
  559.       @index = (@index - @column_max + @item_max) % @item_max
  560.     end
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # * Move cursor right
  564.   #     wrap : Wraparound allowed
  565.   #--------------------------------------------------------------------------
  566.   def cursor_right(wrap = false)
  567.     if (@column_max >= 2) and
  568.        (@index < @item_max - 1 or (wrap and page_row_max == 1))
  569.       @index = (@index + 1) % @item_max
  570.     end
  571.   end
  572.   #--------------------------------------------------------------------------
  573.   # * Move cursor left
  574.   #     wrap : Wraparound allowed
  575.   #--------------------------------------------------------------------------
  576.   def cursor_left(wrap = false)
  577.     if (@column_max >= 2) and
  578.        (@index > 0 or (wrap and page_row_max == 1))
  579.       @index = (@index - 1 + @item_max) % @item_max
  580.     end
  581.   end
  582.   #--------------------------------------------------------------------------
  583.   # * Move cursor one page down
  584.   #--------------------------------------------------------------------------
  585.   def cursor_pagedown
  586.     if top_row + page_row_max < row_max
  587.       @index = [@index + page_item_max, @item_max - 1].min
  588.       self.top_row += page_row_max
  589.     end
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # * Move cursor one page up
  593.   #--------------------------------------------------------------------------
  594.   def cursor_pageup
  595.     if top_row > 0
  596.       @index = [@index - page_item_max, 0].max
  597.       self.top_row -= page_row_max
  598.     end
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # * Frame Update
  602.   #--------------------------------------------------------------------------
  603.   def update
  604.     super
  605.     if cursor_movable?
  606.       last_index = @index
  607.       if Input.repeat?(Input::DOWN)
  608.         cursor_down(Input.trigger?(Input::DOWN))
  609.       end
  610.       if Input.repeat?(Input::UP)
  611.         cursor_up(Input.trigger?(Input::UP))
  612.       end
  613.       if Input.repeat?(Input::RIGHT)
  614.         cursor_right(Input.trigger?(Input::RIGHT))
  615.       end
  616.       if Input.repeat?(Input::LEFT)
  617.         cursor_left(Input.trigger?(Input::LEFT))
  618.       end
  619.       if Input.repeat?(Input::R)
  620.         cursor_pagedown
  621.       end
  622.       if Input.repeat?(Input::L)
  623.         cursor_pageup
  624.       end
  625.       if @index != last_index
  626.         Sound.play_cursor
  627.       end
  628.     end
  629.     update_cursor
  630.     call_update_help
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # * Update cursor
  634.   #--------------------------------------------------------------------------
  635.   def update_cursor
  636.     if @index < 0                   # If the cursor position is less than 0
  637.       self.cursor_rect.empty        # Empty cursor
  638.     else                            # If the cursor position is 0 or more
  639.       row = @index / @column_max    # Get current row
  640.       if row < top_row              # If before the currently displayed
  641.         self.top_row = row          # Scroll up
  642.       end
  643.       if row > bottom_row           # If after the currently displayed
  644.         self.bottom_row = row       # Scroll down
  645.       end
  646.       rect = item_rect(@index)      # Get rectangle of selected item
  647.       rect.y -= self.oy             # Match rectangle to scroll position
  648.       self.cursor_rect = rect       # Refresh cursor rectangle
  649.     end
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # * Call help window update method
  653.   #--------------------------------------------------------------------------
  654.   def call_update_help
  655.     if self.active and @help_window != nil
  656.        update_help
  657.     end
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # * Update help window (contents are defined by the subclasses)
  661.   #--------------------------------------------------------------------------
  662.   def update_help()  end
  663. end
  664. #==============================================================================
  665. # ** Window_Command
  666. #------------------------------------------------------------------------------
  667. #  This window deals with general command choices.
  668. #==============================================================================
  669.  
  670. class Window_Command_Neo < Window_Selectable_Neo
  671.   #--------------------------------------------------------------------------
  672.   # * Public Instance Variables
  673.   #--------------------------------------------------------------------------
  674.   attr_reader   :commands                 # command
  675.   #--------------------------------------------------------------------------
  676.   # * Object Initialization
  677.   #     width      : window width
  678.   #     commands   : command string array
  679.   #     column_max : digit count (if 2 or more, horizontal selection)
  680.   #     row_max    : row count (0: match command count)
  681.   #     spacing    : blank space when items are arrange horizontally
  682.   #--------------------------------------------------------------------------
  683.   def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  684.     if row_max == 0
  685.       row_max = (commands.size + column_max - 1) / column_max
  686.     end
  687.     super(0, 0, width, row_max * WLH + 32, spacing)
  688.     @commands = commands
  689.     @item_max = commands.size
  690.     @column_max = column_max
  691.     refresh
  692.     self.index = 0
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # * Refresh
  696.   #--------------------------------------------------------------------------
  697.   def refresh
  698.     self.contents.clear
  699.     for i in 0...@item_max
  700.       draw_item(i)
  701.     end
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # * Draw Item
  705.   #     index   : item number
  706.   #     enabled : enabled flag. When false, draw semi-transparently.
  707.   #--------------------------------------------------------------------------
  708.   def draw_item(index, enabled = true)
  709.     rect = item_rect(index)
  710.     rect.x += 4
  711.     rect.width -= 8
  712.     self.contents.clear_rect(rect)
  713.     self.contents.font.color = normal_color
  714.     self.contents.font.color.alpha = enabled ? 255 : 128
  715.     self.contents.draw_text(rect, @commands[index])
  716.   end
  717. end
  718. #==============================================================================
  719. # ** Scene_File
  720. #------------------------------------------------------------------------------
  721. #  This is a superclass for the save screen and load screen.
  722. #==============================================================================
  723. class Scene_File
  724.   include Wora_NSS
  725.   attr_reader :window_slotdetail
  726.   #--------------------------------------------------------------------------
  727.   # * Main Processing
  728.   #--------------------------------------------------------------------------
  729.   def main
  730.     start                         # Start processing
  731.     perform_transition            # Perform transition
  732.     Input.update                  # Update input information
  733.     loop do
  734.       Graphics.update             # Update game screen
  735.       Input.update                # Update input information
  736.       update                      # Update frame
  737.       break if $scene != self     # When screen is switched, interrupt loop
  738.     end
  739.     Graphics.update
  740.     Graphics.freeze               # Prepare transition
  741.     terminate                     # Termination processing
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # * Execute Transition
  745.   #--------------------------------------------------------------------------
  746.   def perform_transition()   Graphics.transition(10)  end
  747.   #--------------------------------------------------------------------------
  748.   # * Create Snapshot for Using as Background of Another Screen
  749.   #--------------------------------------------------------------------------
  750.   def snapshot_for_background
  751.     $game_temp.background_bitmap.dispose
  752.     $game_temp.background_bitmap = Graphics.snap_to_bitmap
  753.     $game_temp.background_bitmap.blur
  754.   end
  755.   #--------------------------------------------------------------------------
  756.   # * Create Background for Menu Screen
  757.   #--------------------------------------------------------------------------
  758.   def create_menu_background
  759.     @menuback_sprite = Sprite.new
  760.     @menuback_sprite.bitmap = $game_temp.background_bitmap
  761.     @menuback_sprite.color.set(16, 16, 16, 128)
  762.     update_menu_background
  763.   end
  764.   #--------------------------------------------------------------------------
  765.   # * Dispose of Background for Menu Screen
  766.   #--------------------------------------------------------------------------
  767.   def dispose_menu_background()   @menuback_sprite.dispose  end
  768.   #--------------------------------------------------------------------------
  769.   # * Update Background for Menu Screen
  770.   #--------------------------------------------------------------------------
  771.   def update_menu_background() end
  772.   #--------------------------------------------------------------------------
  773.   # * Start processing
  774.   #--------------------------------------------------------------------------
  775.   def start
  776.     create_menu_background
  777.     if NSS_IMAGE_BG != ''
  778.       @bg = Sprite.new
  779.       if VX
  780.         @bg.bitmap = Cache.picture(NSS_IMAGE_BG)
  781.       else
  782.         @bg.bitmap = RPG::Cache.picture(NSS_IMAGE_BG)
  783.       end
  784.       @bg.opacity = NSS_IMAGE_BG_OPACITY
  785.     end
  786.     @help_window = Window_Help.new
  787.     command = []
  788.     (1..MAX_SAVE_SLOT).each do |i|
  789.       command << SLOT_NAME.clone.gsub!(/\{ID\}/i) { i.to_s }
  790.     end
  791.    
  792.     @window_slotdetail = Window_NSS_SlotDetail.new
  793.     @window_slotlist = Window_SlotList.new(160, command)
  794.     @window_slotlist.y = @help_window.height
  795.     @window_slotlist.height = Graphics.height - @help_window.height
  796.    
  797.     if !OPACITY_DEFAULT
  798.       @help_window.opacity = NSS_WINDOW_OPACITY
  799.       @window_slotdetail.opacity = @window_slotlist.opacity = NSS_WINDOW_OPACITY
  800.     end
  801.  
  802.     # Create folder for save file
  803.     if SAVE_PATH != ''
  804.       Dir.mkdir(SAVE_PATH) if !FileTest.directory?(SAVE_PATH)
  805.     end
  806.    
  807.     if @saving
  808.       @index = $game_temp.last_file_index
  809.       @help_window.set_text(Vocab::SaveMessage)
  810.     else
  811.       @index = self.latest_file_index
  812.       @help_window.set_text(Vocab::LoadMessage)
  813.      
  814.       (1..MAX_SAVE_SLOT).each do |i|
  815.       @window_slotlist.draw_item(i-1, false) if !@window_slotdetail.file_exist?(i)
  816.       end
  817.     end
  818.     @window_slotlist.index = @index
  819.     # Draw information
  820.     @last_slot_index = @window_slotlist.index
  821.     @window_slotdetail.draw_data(@last_slot_index + 1)
  822.   end
  823.   #--------------------------------------------------------------------------  
  824.   # * Termination Processing
  825.   #--------------------------------------------------------------------------
  826.   def terminate
  827.     dispose_menu_background
  828.     unless @bg.nil?
  829.       @bg.bitmap.dispose
  830.       @bg.dispose
  831.     end
  832.     @window_slotlist.dispose
  833.     @window_slotdetail.dispose
  834.     @help_window.dispose
  835.   end
  836.   #--------------------------------------------------------------------------
  837.   # * Frame Update
  838.   #--------------------------------------------------------------------------
  839.   def update
  840.     if !@confirm_window.nil?
  841.       @confirm_window.update
  842.       if Input.trigger?(Input::C)
  843.         if @confirm_window.index == 0
  844.           determine_savefile
  845.           @confirm_window.dispose
  846.           @confirm_window = nil
  847.         else
  848.           Sound.play_cancel
  849.           @confirm_window.dispose
  850.           @confirm_window = nil
  851.         end
  852.       elsif Input.trigger?(Input::B)
  853.         Sound.play_cancel
  854.         @confirm_window.dispose
  855.         @confirm_window = nil
  856.       end
  857.     else
  858.       update_menu_background
  859.       @window_slotlist.update
  860.       if @window_slotlist.index != @last_slot_index
  861.         @last_slot_index = @window_slotlist.index
  862.         @window_slotdetail.draw_data(@last_slot_index + 1)
  863.       end
  864.       @help_window.update
  865.       update_savefile_selection
  866.     end
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # * Update Save File Selection
  870.   #--------------------------------------------------------------------------
  871.   def update_savefile_selection
  872.     if Input.trigger?(Input::C)
  873.       if @saving and @window_slotdetail.file_exist?(@last_slot_index + 1)
  874.         Sound.play_decision
  875.         text1 = SFC_Text_Confirm
  876.         text2 = SFC_Text_Cancel
  877.         @confirm_window = Window_Command.new(SFC_Window_Width,[text1,text2])
  878.         @confirm_window.x = ((544 - @confirm_window.width) / 2) + SFC_Window_X_Offset
  879.         @confirm_window.y = ((416 - @confirm_window.height) / 2) + SFC_Window_Y_Offset
  880.         @confirm_window.z = 9999
  881.       else
  882.         determine_savefile
  883.       end
  884.     elsif Input.trigger?(Input::B)
  885.       Sound.play_cancel
  886.       return_scene
  887.     end
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # * Return to Original Screen
  891.   #--------------------------------------------------------------------------
  892.   def return_scene
  893.     if @from_title || $game_temp.call_from_title
  894.       $game_temp.call_from_title = false
  895.       $scene = Scene_Title.new
  896.     elsif @from_event || $game_temp.call_from_event
  897.       $game_temp.call_from_event = false
  898.       $scene = Scene_Map.new
  899.     else
  900.       $scene = Scene_Menu.new(4)
  901.     end
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # * Execute Save
  905.   #--------------------------------------------------------------------------
  906.   def do_save
  907.     if SCREENSHOT_IMAGE
  908.       File.rename(SAVE_PATH + 'temp' + IMAGE_FILETYPE,
  909.       make_filename(@last_slot_index).gsub(/\..*$/){ '_ss' } + IMAGE_FILETYPE)  
  910.     end  
  911.     file = File.open(make_filename(@last_slot_index), "wb")
  912.     write_save_data(file)
  913.     file.close  
  914.     $game_temp.call_from_title = false
  915.     $game_temp.call_from_event = false
  916.     # Alter the scene after the saving is done
  917.     if SCENE_CHANGE
  918.       $scene = Scene_Map.new
  919.     else
  920.       if VX
  921.         $scene = Scene_File.new(true, false, false)
  922.       else
  923.         $scene = Scene_Save.new
  924.       end
  925.     end
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # * Execute Load
  929.   #--------------------------------------------------------------------------
  930.   def do_load
  931.     file = File.open(make_filename(@last_slot_index), "rb")
  932.     read_save_data(file)
  933.     file.close
  934.     unless VX
  935.       $game_system.bgm_play($game_system.playing_bgm)
  936.       $game_system.bgs_play($game_system.playing_bgs)
  937.     end
  938.     $scene = Scene_Map.new
  939.     if VX
  940.       RPG::BGM.fade(1500)
  941.       Graphics.fadeout(60)
  942.       Graphics.wait(40)
  943.       @last_bgm.play
  944.       @last_bgs.play
  945.     end
  946.     $game_temp.call_from_title = false
  947.     $game_temp.call_from_event = false
  948.   end
  949.   #--------------------------------------------------------------------------
  950.   # * Confirm Save File
  951.   #--------------------------------------------------------------------------
  952.   def determine_savefile
  953.     if @saving
  954.       Sound.play_save
  955.       do_save
  956.     else
  957.       if @window_slotdetail.file_exist?(@last_slot_index + 1)
  958.         Sound.play_load
  959.         do_load
  960.       else
  961.         Sound.play_buzzer
  962.         return
  963.       end
  964.     end
  965.     $game_temp.last_file_index = @last_slot_index
  966.   end
  967.   #--------------------------------------------------------------------------
  968.   # * Create Filename
  969.   #  file_index : save file index (0-3)
  970.   #--------------------------------------------------------------------------
  971.   def make_filename(file_index)
  972.     return SAVE_PATH + SAVE_FILE_NAME.gsub(/\{ID\}/i) { (file_index + 1).to_s }
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # * Select File With Newest Timestamp
  976.   #--------------------------------------------------------------------------
  977.   def latest_file_index
  978.     latest_index = 0
  979.     latest_time = Time.at(0)
  980.     (1..MAX_SAVE_SLOT).each do |i|
  981.       file_name = make_filename(i - 1)
  982.       next if !@window_slotdetail.file_exist?(i)
  983.       file_time = File.mtime(file_name)
  984.       if file_time > latest_time
  985.       latest_time = file_time
  986.       latest_index = i - 1
  987.       end
  988.     end
  989.     return latest_index
  990.   end
  991.  
  992. class Window_SlotList < Window_Command_Neo
  993.   #--------------------------------------------------------------------------
  994.   # * Draw Item
  995.   #--------------------------------------------------------------------------
  996.   def draw_item(index, enabled = true)
  997.     rect = item_rect(index)
  998.     rect.x += 4
  999.     rect.width -= 8
  1000.     icon_index = 0
  1001.     self.contents.clear_rect(rect)
  1002.     if $scene.window_slotdetail.file_exist?(index + 1)
  1003.       icon_index = Wora_NSS::SAVED_SLOT_ICON
  1004.     else
  1005.       icon_index = Wora_NSS::EMPTY_SLOT_ICON
  1006.     end
  1007.     if !icon_index.nil?
  1008.       rect.x -= 4
  1009.       draw_icon(icon_index, rect.x, rect.y, enabled) # Draw Icon
  1010.       rect.x += 26
  1011.       rect.width -= 20
  1012.     end
  1013.     self.contents.clear_rect(rect)
  1014.     self.contents.font.color = normal_color
  1015.     self.contents.font.color.alpha = enabled ? 255 : 128
  1016.     self.contents.draw_text(rect, @commands[index])
  1017.   end
  1018.  
  1019.   def cursor_down(wrap = false)
  1020.     if @index < @item_max - 1 or wrap
  1021.       @index = (@index + 1) % @item_max
  1022.     end
  1023.   end
  1024.  
  1025.   def cursor_up(wrap = false)
  1026.     if @index > 0 or wrap
  1027.       @index = (@index - 1 + @item_max) % @item_max
  1028.     end
  1029.   end
  1030. end
  1031.  
  1032. class Window_NSS_SlotDetail < Window_Base_Neo
  1033.   include Wora_NSS
  1034.  
  1035.   def initialize
  1036.   if VX
  1037.     super(160, 56, 384, 360)
  1038.   else
  1039.     super(160, 65, 480, 415)
  1040.   end
  1041.    
  1042.     @data = []
  1043.     @exist_list = []
  1044.     @bitmap_list = {}
  1045.     @map_name = []
  1046.   end
  1047.  
  1048.   def dispose
  1049.     dispose_tilemap
  1050.     super
  1051.   end
  1052.  
  1053.   def draw_data(slot_id)
  1054.     contents.clear # 352, 328
  1055.     dispose_tilemap
  1056.    
  1057.     load_save_data(slot_id) if @data[slot_id].nil?
  1058.       if @exist_list[slot_id]
  1059.         save_data = @data[slot_id]
  1060.     if VX
  1061.       contents.fill_rect(0,30,352,152, MAP_BORDER)
  1062.     else
  1063.       contents.fill_rect(0,30,458,160, MAP_BORDER)
  1064.     end
  1065.         if PREMADE_IMAGE
  1066.           bitmap = get_bitmap("Graphics/Save/" + @data[slot_id]['map_name'] + IMAGE_FILETYPE)
  1067.       if VX
  1068.             rect = Rect.new((Graphics.width-348)/2,(Graphics.height-156)/2,348,156)
  1069.       else
  1070.         rect = Rect.new((640-348)/2,(480-156)/2,448,156)
  1071.       end      
  1072.           contents.blt(2,32,bitmap,rect)
  1073.         elsif SCREENSHOT_IMAGE and save_data['ss']
  1074.           bitmap = get_bitmap(save_data['ss_path'])
  1075.       if VX
  1076.         rect = Rect.new((Graphics.width-348)/2,(Graphics.height-156)/2,348,156)
  1077.       else
  1078.         rect = Rect.new((640-348)/2,(480-156)/2,448,156)
  1079.       end
  1080.           contents.blt(2,32,bitmap,rect)
  1081.         elsif SWAP_TILE and $game_switches[SWAP_TILE_SWITCH]
  1082.           create_swaptilemap(save_data['gamemap'].data, save_data['gamemap'].display_x,
  1083.           save_data['gamemap'].display_y)
  1084.         else
  1085.           create_tilemap(save_data['gamemap'].data, save_data['gamemap'].display_x,
  1086.           save_data['gamemap'].display_y)
  1087.         end
  1088.        
  1089.         if DRAW_GOLD
  1090.           gold_textsize = contents.text_size(save_data['gamepar'].gold.to_s).width
  1091.           goldt_textsize = contents.text_size(GOLD_TEXT).width  
  1092.           contents.font.color = system_color
  1093.           contents.draw_text(0, 0, goldt_textsize, WLH, GOLD_TEXT)
  1094.           contents.font.color = normal_color
  1095.           contents.draw_text(goldt_textsize, 0, gold_textsize, WLH, save_data['gamepar'].gold.to_s)  
  1096.          
  1097.           if DRAW_TEXT_GOLD
  1098.             contents.draw_text(goldt_textsize + gold_textsize, 0, 200, WLH, Vocab::gold)
  1099.  
  1100.           else
  1101.             gold_textsize = 0
  1102.             goldt_textsize = 0             
  1103.           end
  1104.         end
  1105.        
  1106.         if DRAW_PLAYTIME
  1107.           hour = save_data['total_sec'] / 60 / 60
  1108.           min = save_data['total_sec'] / 60 % 60
  1109.           sec = save_data['total_sec'] % 60
  1110.           time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  1111.           pt_textsize = contents.text_size(PLAYTIME_TEXT).width
  1112.           ts_textsize = contents.text_size(time_string).width
  1113.           contents.font.color = system_color
  1114.           contents.draw_text(contents.width - ts_textsize - pt_textsize, 0,
  1115.           pt_textsize, WLH, PLAYTIME_TEXT)
  1116.           contents.draw_text(goldt_textsize + gold_textsize,0,200,WLH, Vocab::gold)
  1117.      
  1118.           contents.font.color = normal_color
  1119.           contents.draw_text(0, 0, contents.width, WLH, time_string, 2)
  1120.         end
  1121.        
  1122.         if DRAW_LOCATION
  1123.           lc_textsize = contents.text_size(LOCATION_TEXT).width
  1124.           mn_textsize = contents.text_size(save_data['map_name']).width
  1125.           contents.font.color = system_color
  1126.       y = VX ? 190 : 190+35
  1127.           contents.draw_text(0, y, contents.width, WLH, LOCATION_TEXT)
  1128.           contents.font.color = normal_color
  1129.           contents.draw_text(lc_textsize, y, contents.width, WLH, save_data['map_name'])
  1130.         end
  1131.        
  1132.         # Draw level & name
  1133.     game_party = VX ? save_data['gamepar'].members : save_data['gamepar'].actors
  1134.    
  1135.     game_party.each_index do |i|
  1136.           actor = save_data['gameactor'][game_party[i].id]
  1137.           face_x_base = (i*80) + (i*(8+ (VX ? 0 : 18)))
  1138.           face_y_base = 216
  1139.           face_y_base += 40 if !VX
  1140.           lvn_y_plus = 10
  1141.           lv_textsize = contents.text_size(actor.level.to_s).width
  1142.           lvt_textsize = contents.text_size(LV_TEXT).width
  1143.          
  1144.         if DRAW_FACE
  1145.           contents.fill_rect(face_x_base, face_y_base, 84, 84, FACE_BORDER)
  1146.       unless VX
  1147.         draw_face('Actor'+actor.id.to_s, 1, face_x_base + 2, face_y_base + 2, 80)
  1148.       else
  1149.         draw_face(actor.face_name, actor.face_index, face_x_base + 2,
  1150.         face_y_base + 2, 80)
  1151.       end
  1152.         end
  1153.        
  1154.         if DRAW_LEVEL
  1155.           contents.font.color = system_color
  1156.           contents.draw_text(face_x_base + 2 + 80 - lv_textsize - lvt_textsize,
  1157.           face_y_base + 2 + 80 - WLH + lvn_y_plus, lvt_textsize, WLH, LV_TEXT)
  1158.           contents.font.color = normal_color
  1159.           contents.draw_text(face_x_base + 2 + 80 - lv_textsize,
  1160.           face_y_base + 2 + 80 - WLH + lvn_y_plus, lv_textsize, WLH, actor.level.to_s)
  1161.         end
  1162.        
  1163.         if DRAW_NAME
  1164.           contents.draw_text(face_x_base, face_y_base + 2 + 80 + lvn_y_plus - 6, 84,
  1165.           WLH, actor.name, CENTER_NAME ? 1 : 4)
  1166.         end
  1167.       end
  1168.     else
  1169.       contents.draw_text(0,0, contents.width, contents.height - WLH, EMPTY_SLOT_TEXT, 1)
  1170.     end
  1171.   end
  1172.  
  1173.   def load_save_data(slot_id)
  1174.     file_name = make_filename(slot_id)
  1175.    
  1176.     if file_exist?(slot_id) or FileTest.exist?(file_name)
  1177.       @exist_list[slot_id] = true
  1178.       @data[slot_id] = {}
  1179.      
  1180.      
  1181.       # Start load data
  1182.       file = File.open(file_name, "r")
  1183.       @data[slot_id]['time'] = file.mtime
  1184.       @data[slot_id]['char'] = Marshal.load(file)
  1185.       @data[slot_id]['frame'] = Marshal.load(file)
  1186.       if VX
  1187.         @data[slot_id]['last_bgm'] = Marshal.load(file)
  1188.         @data[slot_id]['last_bgs'] = Marshal.load(file)
  1189.       end
  1190.       @data[slot_id]['gamesys'] = Marshal.load(file)
  1191.       @data[slot_id]['gamemes'] = Marshal.load(file)
  1192.       @data[slot_id]['gameswi'] = Marshal.load(file)
  1193.       @data[slot_id]['gamevar'] = Marshal.load(file)
  1194.       @data[slot_id]['gameselfvar'] = Marshal.load(file)
  1195.       @data[slot_id]['gameactor'] = Marshal.load(file)
  1196.       @data[slot_id]['gamepar'] = Marshal.load(file)
  1197.       @data[slot_id]['gametro'] = Marshal.load(file)
  1198.       @data[slot_id]['gamemap'] = Marshal.load(file)
  1199.       @data[slot_id]['total_sec'] = @data[slot_id]['frame'] / Graphics.frame_rate
  1200.      
  1201.       # Save the image
  1202.       if SCREENSHOT_IMAGE
  1203.         @data[slot_id]['ss_path'] = file_name.gsub(/\..*$/){'_ss'} + IMAGE_FILETYPE
  1204.         @data[slot_id]['ss'] = FileTest.exist?(@data[slot_id]['ss_path'])
  1205.       end
  1206.      
  1207.       @data[slot_id]['map_name'] = get_mapname(@data[slot_id]['gamemap'].map_id)
  1208.       file.close
  1209.     else
  1210.       @exist_list[slot_id] = false
  1211.       @data[slot_id] = -1
  1212.     end
  1213.   end
  1214.  
  1215.   def make_filename(file_index)
  1216.     return SAVE_PATH + SAVE_FILE_NAME.gsub(/\{ID\}/i) { (file_index).to_s }
  1217.   end
  1218.  
  1219.   def file_exist?(slot_id)
  1220.     return @exist_list[slot_id] if !@exist_list[slot_id].nil?
  1221.     @exist_list[slot_id] = FileTest.exist?(make_filename(slot_id))
  1222.     return @exist_list[slot_id]
  1223.   end
  1224.  
  1225.   def get_bitmap(path)
  1226.     if !@bitmap_list.include?(path)
  1227.       @bitmap_list[path] = Bitmap.new(path)
  1228.     end
  1229.     return @bitmap_list[path]
  1230.   end
  1231.  
  1232.   def get_mapname(map_id)
  1233.     if @map_data.nil?
  1234.       if VX
  1235.         @map_data = load_data("Data/MapInfos.rvdata")
  1236.       else
  1237.         @map_data = load_data("Data/MapInfos.rxdata")
  1238.       end
  1239.     end
  1240.     if @map_name[map_id].nil?
  1241.       if MAP_NO_NAME_LIST.include?(map_id) && MAP_NO_NAME_SWITCH &&
  1242.         (!$game_switches.nil? && $game_switches[MAP_NO_NAME_SWITCH])
  1243.         if $game_variables[map_id] == 0 or !MAP_NO_NAME_VARIABLE
  1244.           @map_name[map_id] = MAP_NO_NAME
  1245.         else
  1246.           @map_name[map_id] = @map_data[map_id].name
  1247.         end  
  1248.       else
  1249.         @map_name[map_id] = @map_data[map_id].name rescue ''
  1250.       end
  1251.    
  1252.       MAP_NAME_TEXT_SUB.each_index do |i|
  1253.       @map_name[map_id].sub!(MAP_NAME_TEXT_SUB[i], '')
  1254.       @mapname = @map_name[map_id]
  1255.       end
  1256.     end
  1257.    
  1258.     return @map_name[map_id]
  1259.   end  
  1260.  
  1261.   def create_tilemap(map_data, ox, oy)
  1262.     @viewport = Viewport.new(self.x + 2 + 16, self.y + 32 + 16, 348,156)
  1263.     @viewport.z = self.z
  1264.     return unless VX
  1265.     @tilemap = Tilemap.new(@viewport)
  1266.     @tilemap.bitmaps[0] = Cache.system("TileA1")
  1267.     @tilemap.bitmaps[1] = Cache.system("TileA2")
  1268.     @tilemap.bitmaps[2] = Cache.system("TileA3")
  1269.     @tilemap.bitmaps[3] = Cache.system("TileA4")
  1270.     @tilemap.bitmaps[4] = Cache.system("TileA5")
  1271.     @tilemap.bitmaps[5] = Cache.system("TileB")
  1272.     @tilemap.bitmaps[6] = Cache.system("TileC")
  1273.     @tilemap.bitmaps[7] = Cache.system("TileD")
  1274.     @tilemap.bitmaps[8] = Cache.system("TileE")
  1275.     @tilemap.map_data = map_data
  1276.     @tilemap.ox = ox / 8 + 99
  1277.     @tilemap.oy = oy / 8 + 90
  1278.   end
  1279.  
  1280.   def create_swaptilemap(map_data, ox, oy)
  1281.     @viewport = Viewport.new(self.x + 2 + 16, self.y + 32 + 16, 348,156)
  1282.     @viewport.z = self.z
  1283.     return unless VX
  1284.     @tilemap = Tilemap.new(@viewport)
  1285.    
  1286.     tile1 = Cache_Swap_Tiles.swap($tileA1 + ".png") rescue nil
  1287.     tile2 = Cache_Swap_Tiles.swap($tileA2 + ".png") rescue nil
  1288.     tile3 = Cache_Swap_Tiles.swap($tileA3 + ".png") rescue nil
  1289.     tile4 = Cache_Swap_Tiles.swap($tileA4 + ".png") rescue nil
  1290.     tile5 = Cache_Swap_Tiles.swap($tileA5 + ".png") rescue nil
  1291.     tile6 = Cache_Swap_Tiles.swap($tileB + ".png") rescue nil
  1292.     tile7 = Cache_Swap_Tiles.swap($tileC + ".png") rescue nil
  1293.     tile8 = Cache_Swap_Tiles.swap($tileD + ".png") rescue nil
  1294.     tile9 = Cache_Swap_Tiles.swap($tileE + ".png") rescue nil
  1295.    
  1296.     if $tileA1 != nil
  1297.       @tilemap.bitmaps[0] = tile1
  1298.     else
  1299.       @tilemap.bitmaps[0] = Cache.system("TileA1")
  1300.     end
  1301.  
  1302.     if $tileA2 != nil
  1303.       @tilemap.bitmaps[1] = tile2
  1304.     else
  1305.       @tilemap.bitmaps[1] = Cache.system("TileA2")
  1306.     end
  1307.  
  1308.     if $tileA3 != nil
  1309.       @tilemap.bitmaps[2] = tile3  
  1310.     else
  1311.       @tilemap.bitmaps[2] = Cache.system("TileA3")
  1312.     end  
  1313.  
  1314.     if $tileA4 != nil
  1315.       @tilemap.bitmaps[3] = tile4
  1316.     else
  1317.       @tilemap.bitmaps[3] = Cache.system("TileA4")
  1318.     end
  1319.  
  1320.     if $tileA5 != nil
  1321.       @tilemap.bitmaps[4] = tile5  
  1322.     else
  1323.       @tilemap.bitmaps[4] = Cache.system("TileA5")
  1324.     end
  1325.  
  1326.     if $tileB != nil
  1327.       @tilemap.bitmaps[5] = tile6
  1328.     else
  1329.       @tilemap.bitmaps[5] = Cache.system("TileB")  
  1330.     end  
  1331.  
  1332.     if $tileC != nil
  1333.       @tilemap.bitmaps[6] = tile7
  1334.     else
  1335.       @tilemap.bitmaps[6] = Cache.system("TileC")
  1336.     end  
  1337.  
  1338.     if $tileD != nil
  1339.       @tilemap.bitmaps[7] = tile8
  1340.     else
  1341.       @tilemap.bitmaps[7] = Cache.system("TileD")  
  1342.     end
  1343.  
  1344.     if $tileE != nil
  1345.       @tilemap.bitmaps[8] = tile9
  1346.     else
  1347.       @tilemap.bitmaps[8] = Cache.system("TileE")  
  1348.     end
  1349.    
  1350.     @tilemap.map_data = map_data
  1351.     @tilemap.ox = ox / 8 + 99
  1352.     @tilemap.oy = oy / 8 + 90
  1353.   end
  1354.    
  1355.   def dispose_tilemap
  1356.     unless @tilemap.nil?
  1357.       @tilemap.dispose
  1358.       @tilemap = nil
  1359.     end
  1360.   end
  1361.   end
  1362. end
  1363. #==============================================================================
  1364. # ** Scene_Save
  1365. #------------------------------------------------------------------------------
  1366. #  This class performs save screen processing.
  1367. #==============================================================================
  1368. class Scene_Save < Scene_File
  1369.   #--------------------------------------------------------------------------
  1370.   # * Object Initialization
  1371.   #--------------------------------------------------------------------------
  1372.   def initialize
  1373.     @saving = true
  1374.     super('')
  1375.   end
  1376. end
  1377. #==============================================================================
  1378. # ** Scene_Load
  1379. #------------------------------------------------------------------------------
  1380. #  This class performs load screen processing.
  1381. #==============================================================================
  1382. class Scene_Load < Scene_File
  1383.   #--------------------------------------------------------------------------
  1384.   # * Object Initialization
  1385.   #--------------------------------------------------------------------------
  1386.   def initialize
  1387.     @saving = false
  1388.     super('')
  1389.   end
  1390. end
  1391. #==============================================================================
  1392. # ** Scene_Title
  1393. #------------------------------------------------------------------------------
  1394. #  This class performs title screen processing.
  1395. #==============================================================================
  1396. name = VX ? "< Scene_Base" : ""
  1397. eval_text = "
  1398. class Scene_Title #{name}
  1399.  #--------------------------------------------------------------------------
  1400.  # * Check Continue
  1401.  #--------------------------------------------------------------------------
  1402.  def check_continue
  1403.    unless @checked
  1404.      @checked = true
  1405.      file_name = Wora_NSS::SAVE_PATH + Wora_NSS::SAVE_FILE_NAME.gsub(/\{ID\}/i) { '*' }
  1406.      @continue_enabled = (Dir.glob(file_name).size > 0)
  1407.      return @checked = true if VX
  1408.      if @continue_enabled
  1409.        @command_window.index = 1
  1410.        @command_window.draw_item(1, Color.new(255, 255, 255, 255))
  1411.      else
  1412.        @command_window.index = 0
  1413.        @command_window.disable_item(1)
  1414.      end
  1415.    end
  1416.  end
  1417.  unless VX
  1418.    #--------------------------------------------------------------------------
  1419.    # * Update Frame
  1420.    #--------------------------------------------------------------------------
  1421.    alias update_nss update
  1422.    def update
  1423.      check_continue
  1424.      update_nss
  1425.    end
  1426.    #--------------------------------------------------------------------------
  1427.    # * Command: Continue
  1428.    #--------------------------------------------------------------------------
  1429.    alias command_continue_nss command_continue
  1430.    def command_continue
  1431.      $game_temp          = Game_Temp.new
  1432.      $game_temp.call_from_title = true
  1433.      command_continue_nss
  1434.    end
  1435.  end
  1436. end
  1437.  
  1438. #==============================================================================
  1439. # ** Scene_Map
  1440. #------------------------------------------------------------------------------
  1441. #  This class performs map screen processing.
  1442. #==============================================================================
  1443. class Scene_Map #{name}
  1444.  if VX
  1445.    #--------------------------------------------------------------------------
  1446.    # * Terminate
  1447.    #--------------------------------------------------------------------------
  1448.    alias wora_nss_scemap_ter terminate
  1449.    def terminate
  1450.      Wora_NSS.shot(Wora_NSS::SAVE_PATH + 'temp')
  1451.      wora_nss_scemap_ter
  1452.    end
  1453.  else
  1454.    #--------------------------------------------------------------------------
  1455.    # * Main
  1456.    #--------------------------------------------------------------------------
  1457.    alias wora_nss_scemap_ter main
  1458.    def main
  1459.      wora_nss_scemap_ter
  1460.      Wora_NSS.shot(Wora_NSS::SAVE_PATH + 'temp')
  1461.    end
  1462.    #--------------------------------------------------------------------------
  1463.    # * Save Call
  1464.    #--------------------------------------------------------------------------
  1465.    alias wora_nss_scemap_callsave call_save
  1466.    def call_save
  1467.      $game_temp.save_calling = false
  1468.      $game_temp.call_from_event = true
  1469.      wora_nss_scemap_callsave
  1470.    end
  1471.  end
  1472. end#"
  1473. #==============================================================================
  1474. # ** Game_Temp
  1475. #------------------------------------------------------------------------------
  1476. #  This class handles temporary data that is not included with save data.
  1477. #  Refer to "$game_temp" for the instance of this class.
  1478. #==============================================================================
  1479. class Game_Temp
  1480.   attr_accessor :background_bitmap,:call_from_event,:call_from_title
  1481. end
  1482. eval(eval_text)
  1483.  
  1484. #======================================================================
  1485. # END - NEO SAVE SYSTEM by Woratana and Helladen
  1486. #======================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement