Guest User

Untitled

a guest
Jun 18th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #===============================================================================
  2. # APPDATA Saving
  3. # By Jet10985 (Jet)
  4. #===============================================================================
  5. # This script will save your game's save files in the APPDATA directory of the
  6. # user's computer. This is useful for keeping save files after game deletion,
  7. # and is required by some commercial portals.
  8. # This script has: 0 customization options.
  9. #===============================================================================
  10. # Overwritten Methods:
  11. # DataManager: save_file_exists?, make_filename
  12. #-------------------------------------------------------------------------------
  13. # Aliased methods:
  14. # None
  15. #===============================================================================
  16. =begin
  17. The directory that save files willbe in will be the APPDATA directory of the
  18. player's computer, followed by the name of your game as written in the
  19. Config.ini file, followed by "Saves".
  20. =end
  21.  
  22. module Utility
  23.  
  24. Win32API.new('kernel32', 'GetEnvironmentVariable', 'ppl', 'l').call(
  25. "APPDATA", title = "\0" * 256, 256)
  26. APPDATA = title.unpack("C*").pack("U*").delete!("\0")
  27.  
  28. a = Win32API.new('kernel32', 'GetPrivateProfileString', 'pppplp', 'l')
  29. a.call("Game", "Title", "", title = "\0" * 256, 256, ".//Game.ini")
  30.  
  31. GAME_NAME = title.unpack("C*").pack("U*").delete!("\0")
  32.  
  33.  
  34. APPDATA_DIRECTORY = "#{APPDATA}\\#{GAME_NAME.gsub(/[\\\/\:\*\?\"\<\>\|]/, '')}"
  35.  
  36. end
  37.  
  38. class << DataManager
  39.  
  40. def save_file_exists?(*args, &block)
  41. f = Utility::APPDATA_DIRECTORY.dup
  42. Dir.mkdir(f) unless File.directory?(f)
  43. f << "\\Saves"
  44. Dir.mkdir(f) unless File.directory?(f)
  45. entries = Dir.entries(f.unpack("U*").pack("C*"), :encoding => 'UTF-8')
  46. entries.size > 2
  47. end
  48.  
  49. def make_filename(index)
  50. f = Utility::APPDATA_DIRECTORY
  51. Dir.mkdir(f) unless File.directory?(f)
  52. f = f + "\\Saves"
  53. Dir.mkdir(f) unless File.directory?(f)
  54. "#{f}\\#{sprintf("Save%02d.rvdata2", index + 1)}"
  55. end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment