-
Notifications
You must be signed in to change notification settings - Fork 7
Game saves
GeometryDash store your progress in two files
-
CCGameManager.dat
Your profile, password, achievements, spent attempts are stored here...
Also there are the levels you opened stored here -
CCLocalLevels.dat
Your levels from the "Create" tab stored here
For windows this files located in C:\Users\User\AppData\Local\GeometryDash\
The GameData
class is used to work with this data.
There are two implementations for each file
LocalLevels
GameManager
To load data, you can use the static LoadFileAsync
and LoadFile
method
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();
There are also synchronous method alternatives if you don't want to use await
var local = LocalLevels.LoadFile();
var manager = GameManager.LoadFile();
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");
For example, there is such a list of levels
if (local.LevelExists("my level"))
Console.WriteLine("my level does exists!");
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
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)
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
To save the level back, use SaveLevel(level)
local.SaveLevel(level);
Of course, you can create a new level
local.SaveLevel(new Level());
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");
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");
var local = await LocalLevels.LoadFileAsync();
local.Add(new LevelCreatorModel());
This GameManager and LocalLevels.
The main class contains methods for loading and saving data.
Contains 2 constructor.
- Accepts the GameDataType enumeration and loads either the CCGameManager.dat file or the CCLocalLevels.dat file. depending on the parameter constructor.
- 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;