Skip to content

Game saves

Andrey edited this page Sep 21, 2023 · 1 revision

Introduce

GeometryDash store your progress in two files

  1. CCGameManager.dat
    Your profile, password, achievements, spent attempts are stored here...
    Also there are the levels you opened stored here
  2. CCLocalLevels.dat
    Your levels from the "Create" tab stored here

For windows this files located in C:\Users\User\AppData\Local\GeometryDash\

Interaction

The GameData class is used to work with this data.
There are two implementations for each file

  1. LocalLevels
  2. GameManager

Load data

To load data, you can use the static LoadFileAsync and LoadFile method

Asynchronous

This code will try to "guess" the path to the file
That is, trying to find files in the default path

var local = await LocalLevels.LoadFileAsync();
var manager = await GameManager.LoadFileAsync();

Synchronous

There are also synchronous method alternatives if you don't want to use await

var local = LocalLevels.LoadFile();
var manager = GameManager.LoadFile();

Custom path

You can specify a custom file name to load it

var local = await LocalLevels.LoadFileAsync("/home/folleach/geometrydash/CCLocalLevels.dat");
var manager = await GameManager.LoadFileAsync("/home/folleach/geometrydash/CCGameManager.dat");

Editing

GameManager

LocalLevels

Level metadata

For example, there is such a list of levels
list of levels

Check if level exists

if (local.LevelExists("my level"))
    Console.WriteLine("my level does exists!");

Get specific level

To get a specific level of the list

var levelMeta3 = local.GetLevel("my level"); // will return the 3rd level in a row
var levelMeta2 = local.GetLevel("my level", revision: 1); // will return the 2nd level in a row
var levelMeta1 = local.GetLevel("hardest demon", revision: 0); // will return the 1st level in a row

Get all levels

LocalLevels implements IEnumerable<LevelCreatorModel> so you can get the full list of levels like this

foreach (var levelMeta in local)
    Console.WriteLine($"{levelMeta.Name}. rev: {levelMeta.Revision}");

will return

hardest demon. rev: 0
my level. rev: 1
my level. rev: 0

GetLevel returns LevelCreatorModel it contains meta information about the level, such as name, description, whether the level is verified, and so on.
It also stores information about the blocks themselves in the level in a compressed form (the LevelString field)

Level data

Load

To load a level from metadata, you need to use LoadLevel method.

var level = levelMeta.LoadLevel();

This will create a new class Level from the LevelString.
Learn more about Level

Save

To save the level back, use SaveLevel(level)

local.SaveLevel(level);

Reset level

Of course, you can create a new level

local.SaveLevel(new Level());

Save data

There are similar methods for saving

local.Save();
local.Save("/home/folleach/geometrydash/CCLocalLevels.dat");
await local.SaveAsync();
await local.SaveAsync("/home/folleach/geometrydash/CCLocalLevels.dat");

Safe saving

But before saving, make sure that the game is not running unless you specify a specific path.
Otherwise, when you close the game, it will overwrite your file. It always happens!

if (GameProcess.GameCount() > 0)
    Console.WriteLine("the game is running");
else
    Console.WriteLine("the game is not running");

Create a new instance of data

var local = await LocalLevels.LoadFileAsync();
local.Add(new LevelCreatorModel());

Old docs

This GameManager and LocalLevels.

GameData

The main class contains methods for loading and saving data.
Contains 2 constructor.

  1. Accepts the GameDataType enumeration and loads either the CCGameManager.dat file or the CCLocalLevels.dat file. depending on the parameter constructor.
  2. Accepts the string (Full path to the file) and loads it.
GameData data = new GameData(GameDataType.GameManager);
//Or
GameData data = new GameData(GameDataType.LocalLevels);
//Or
GameData data = new GameData(@"D:\GeometryDashFileData.dat");

Loaded data is stored in the variable DataPlist which is a class Plist.

float VolumeBackground = data.DataPlist["bgVolume"];
bool FullScreen = GameConvert.StringToBool(data.DataPlist["valueKeeper"]["gv_0025"], true);

And also contains 2 methods, Load and Save.
Load - The file is loaded with the path to which is contained in the private variable GameDataFile that was created when the constructor was called.

data.Load();

Save - Saves the data in the path specified in the GameDataFile variable or in the specified path in the parameter.
Returns the result of saving. (Boolean).

  • true - Success.
  • false - Failed.
//Saving data on the path by variable
data.Save();
//Saving data on the path by parametr
data.Save(@"D:\GeometryDashFileData.dat");
//Checks if the game is open and save or cancel.
bool saved = data.Save(true);
bool saved = data.Save(true, @"D:\GeometryDashFileData.dat");
if (saved)
    //Success
else
    //Failed

There are 2 more classes that are inherited from GameData.
GameManager and LocalLevels.
These classes contain properties from files in a convenient way.
For example, what was higher:

GameManager data = new GameManager();
float VolumeBackground = data.MusicVolume;
bool FullScreen = data.FullScreen;