Database

Usually the levels are stored on the hard disk. When loaded from there the levels can be played in JSoko. When new solutions have been found (for instance by the built-in solver of JSoko) these solutions are added to the level as long as JSoko stays open. When JSoko is closed all found solutions are lost.

One way to store new solutions is to save a level back to hard disk. This has disadvantages:

  • every time a new solution has been found and JSoko is to be closed the levels have to be saved to hard disk
  • there either is a new file on the hard disk for the saved levels every time they are saved  OR
  • the level files on the hard disk are overwritten with the new data. While overwriting the files JSoko can't assure that the file format isn't destroyed - just because the files may be created by another Sokoban program using a different format for storing the level data than JSoko.

To avoid these disadvantages there is a database in JSoko. It can be used to store a single level or a whole level collection consisting of several levels.

The data is stored in the file: /leveldata/leveldataDB.data     (this path is relative to the folder JSoko has been unzipped to)

The stored levels can be loaded from the database again and been played. When a new solution is found and a level has been loaded from the database this solution is automatically saved in the database, too. Hence, there is no need to save the level when JSoko is closed.

Note: This automatic saving is only done when a level has been loaded from the database.

New since JSoko version 1.74:

Levels loaded from hard disk or the clipboard are automatically saved in the collection "unregistered". Every time a level is loaded JSoko checks whether a similar level (comparing the level elements: walls, boxes, goals, ...) is already stored in the "unregistered" collection. If this is the case, the solutions of the stored level in the database are added to the loaded level and the level is connected with the one in the database. This means adding new solutions or deleting solutions from the loaded level also adds the solutions to / removes the solutions from the level in the database.

Nevertheless, it's recommended to import all level collection to the database manually. This way the levels are stored for a collection having a specific name and can be easily loaded by selecting the corresponding level collection for playing.

Since version 1.74 JSoko can be installed using the JSoko installer. Usually the installer is temporarily provided access to specifc folders during the installation but later JSoko can't access the folder anymore. Hence, JSoko uses the default "app folder" for the operation system it is running on.

JSoko stores all user data in the following folders:

  • Windows: %appdata%/jsoko
  • Linux/Unix: XDG_CONFIG_HOME/jsoko    and XDG_DATA_HOME/jsoko
  • Mac: /Library/Preferences/de.sokoban_online.jsoko  and /Library/jsoko

Importing levels to the database

To import a level to the database there are three menu items in the "Database" menu of JSoko:

Import level to database

Imports the currently loaded level to the database. If an identical level is already stored in the database (identical = same board) then JSoko asks whether the levels is to be stored as new level or just the solutions of the level are to be added to the already stored level in the database. The imported level is imported using the collection "Unassigned levels" which means this level isn't assigned to any collection, yet.

Import collection to database

Imports the currently loaded collection to the database. All levels are imported and assigned to the collections. If the collection has been loaded from the database JSoko asks whether it has to be imported as new collection. Note: JSoko doesn't checks for duplicate levels when importing a collection. Hence, if you import collections which share identical levels these levels are stored twice in the database after the import

Import collections of folder ...

Shows a folder chooser for choosing the folder to select collections from. The selected folder and all sub folders are searched for *.txt, *.sok and *.xsb files. All of these files can be selected to be imported to the database.

Import data from another database ... (since version 1.74)

Shows a file chooser for selecting the database file to be imported. JSoko can only import data from databases that have been created by JSoko.

Using the database

The database can be opened through the "Database" menu of JSoko by choosing the menu item "Browse database".

The database GUI consists of four tabs: