Skip to main content

Crate gdlib

Crate gdlib 

Source
Expand description

§GDLib Crates.io

A typesafe, rust library to interface with GD savefiles. It is intended to enable programmatic savefile operations, such as automatic level creation.

Documentation can be found on docs.rs As of v0.3.1, GDLib is in active development.

§Repository structure

  • .github: workflows for GitHub.
  • test_gmds: .gmd files for tests.
  • src: source code of library
  • examples: example usages of GDLib.

§Overview

GDLib is an API that is designed to parse the Geometry Dash savefile format. It can parse levels and objects from the savefile (CCLocalLevels.dat) and from .gmd files.

Features

  • Full CRUD control: ability to create and modify levels at the developer’s discretion
  • Easy modification of objects through built-in methods and objects
  • Full support for read from and writing to .dat and .gmd files
  • Optimized to be fast and lightweight

§Usage instructions

This crate can be added to a project by running cargo add gdlib.

§Minimal example

This example can be found at examples/minimal.rs.

use gdlib::{core::GDError, gdlevel::Level, gdobj::Group};

fn main() -> Result<(), GDError> {
    // Load level from .gmd file
    let mut level = Level::from_gmd("test_gmds/level.gmd")?;

    // Get level data, which is None only if it hasn't been initialized.
    if let Some(data) = level.get_decrypted_data_ref() {
        // Add group 42 to all objects
        for obj in data.objects.iter_mut() {
            obj.config.add_group(Group::Regular(42));
        }
    }

    // Export level
    level.export_to_gmd("test_gmds/generated_group_42.gmd")?;
    Ok(())
}

§License

GDLib is distributed under the MIT License.

Modules§

core
This module contains various utilities for debugging and processing structs
deserialiser
Here lies the decryption functions for GD savefiles
gdlevel
This file contains the necessary structs for interfacing with the level(s) themselves
gdobj
This module contains the GDObject struct, used for parsing to/from raw object strings This module also contains the GDObjConfig struct for creating new GDObjects
rand
Implementations and uses of Pseudo-RNG in Geometry Dash.
serialiser
This module contains all of the encryption code for GD savefiles.