Class GameLoading


  • public class GameLoading
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger LOGGER  
      private org.jdom.Element root  
      private Variant variant  
    • Constructor Summary

      Constructors 
      Constructor Description
      GameLoading()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.jdom.Element getRoot()  
      Variant getVariant()  
      private java.lang.String latestSaveFilename​(java.lang.String[] filenames)
      Find from the list of savegame filenames the one with the highest numerical value (1000000000_xxx.xml comes after 999999999_xxx.xml)
      java.lang.String loadGame​(java.lang.String filename)
      Try to load a game from saveDirName/filename.
      java.lang.String loadGameFromFile​(java.io.File file)
      Load contents of the file, get variant name, load the right variant and get the root element.
      private long numberValue​(java.lang.String filename)
      Extract and return the numeric part of a filename.
      private java.io.File resolveFileNameToFile​(java.lang.String filename)
      For a given filename, open the file with that name from save game directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • root

        private org.jdom.Element root
    • Constructor Detail

      • GameLoading

        public GameLoading()
    • Method Detail

      • getVariant

        public Variant getVariant()
      • getRoot

        public org.jdom.Element getRoot()
      • loadGame

        public java.lang.String loadGame​(java.lang.String filename)
        Try to load a game from saveDirName/filename. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.
        Returns:
        String telling reason for failure, or null if all ok
      • resolveFileNameToFile

        private java.io.File resolveFileNameToFile​(java.lang.String filename)
        For a given filename, open the file with that name from save game directory. If no such file, try also whether with adding ".xml" it would become a valid/existing file. If the filename is "--latest" then load the latest savegame that can be found in saveDirName.
        Parameters:
        filename - The name of the file to load, or "--latest" for looking for latest save game (snapshot) file.
        Returns:
        The File object for that filename, or null if no such file can't be found
      • loadGameFromFile

        public java.lang.String loadGameFromFile​(java.io.File file)
        Load contents of the file, get variant name, load the right variant and get the root element. Currently also gets all variant data files and puts them to file cache but that is going to be removed one day. Soon ;-)
        Parameters:
        file - The file from which to load the game
        Returns:
        True if load was successful, otherwise false
      • latestSaveFilename

        private java.lang.String latestSaveFilename​(java.lang.String[] filenames)
        Find from the list of savegame filenames the one with the highest numerical value (1000000000_xxx.xml comes after 999999999_xxx.xml)
        Parameters:
        filenames - An array of strings which represent filenames
        Returns:
        Latest savegame from the list
      • numberValue

        private long numberValue​(java.lang.String filename)
        Extract and return the numeric part of a filename.