desophos/idleon-saver

View on GitHub
README.md

Summary

Maintainability
Test Coverage
# Idleon Saver

[![Build](https://github.com/desophos/idleon-saver/actions/workflows/build.yml/badge.svg)](https://github.com/desophos/idleon-saver/actions/workflows/build.yml)
[![Test](https://github.com/desophos/idleon-saver/actions/workflows/test.yml/badge.svg)](https://github.com/desophos/idleon-saver/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/desophos/idleon-saver/badge.svg?branch=main)](https://coveralls.io/github/desophos/idleon-saver?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/bda291e68f16afb3fbfe/maintainability)](https://codeclimate.com/github/desophos/idleon-saver/maintainability)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Converts Legends of Idleon Steam save files to and from JSON with a friendly GUI that makes it easy to export your save data to [Idleon Companion](https://idleoncompanion.com/), [Cogstruction](https://github.com/automorphis/Cogstruction), and other tools.

## How to Use

0. **Run Steam**, since Legends of Idleon won't run without Steam.
1. **Download IdleonSaver.exe** from Assets in [the latest release](https://github.com/desophos/idleon-saver/releases/latest).
2. **Run IdleonSaver.exe** from your download folder.
3. If you get a "Windows protected your PC" popup window, **click "More info" then "Run Anyway"**.
4. **Follow the instructions** displayed in the app.
5. On the export screen, **click "Show Files"** to open the folder containing your exported data.

## For Developers

### Disclaimer

**Use at your own risk.**

**MAKE BACKUPS** before using and ***DO NOT USE THE ENCODER ON YOUR REAL SAVE DATABASE!***

I do not endorse using this tool to edit your live save files.
This tool is for educational and investigative purposes only.

### Setup

Use either [`poetry install`](https://python-poetry.org/docs/master/) (recommended) or `pip install .` to install dependencies.
If using poetry, replace `python` with `poetry run python` in this document (or run from a `poetry shell`).

If using leveldb scripts, copy your database to a test location (default is `~/dev/leveldb`). For example:

```
cp -r ~/AppData/Roaming/legends-of-idleon/"Local Storage"/leveldb ~/dev/leveldb
```

#### Updating idleon-data

If `idleon-saver/idleon-data/` is empty, make sure to run the following command from your project root:

```
git submodule update --init --recursive
```

### Running the GUI

To launch the GUI, run `python idleon_saver/gui/main.py`.

### Running scripts directly

#### Preamble

The first iteration of this project used scripts that interact with the leveldb directly instead of launching the game.
The flakiness of plyvel on Windows has prompted me to abandon that route, which is why the GUI doesn't use the leveldb scripts.

However, these scripts are still available for use if desired.

#### Usage

You can pass `--help` to any script to see the arguments it takes.
If your paths don't match the defaults, you'll need to pass your paths to the scripts.

Script arguments:

| Argument          | Description                                   | Default                                                           |
| ----------------- | --------------------------------------------- | ----------------------------------------------------------------- |
| `-n`, `--idleon`  | Legends of Idleon install path                | `C:/Program Files (x86)/Steam/steamapps/common/Legends of Idleon` |
| `-l`, `--ldb`     | Path to the leveldb to work with              | `~/dev/leveldb`                                                   |
| `-w`, `--workdir` | Working directory where files will be created | `<package directory>/work`                                        |
| `-i`, `--infile`  | Input filename                                | Varies by script                                                  |
| `-o`, `--outfile` | Output filename                               | Varies by script                                                  |

`python idleon_saver/scripts/decode.py` will decode leveldb data into 2 JSON files:

- `decoded_plain.json`, which is easier to read, and
- `decoded_types.json`, which contains all the information required to re-encode the data back into the leveldb.

`python idleon_saver/scripts/encode.py` will encode the data in `decoded_types.json` back into the database.

After you've obtained your `decoded_plain.json`, you can export it into formats used by community tools with `python idleon_saver/scripts/export.py`. This script takes two additional arguments:

| Argument         | Description                                            | Default            | Choices                                       |
| ---------------- | ------------------------------------------------------ | ------------------ | --------------------------------------------- |
| `-t`, `--to`     | Community tool format to export your data to           | `idleon_companion` | `idleon_companion`, `cogstruction`            |
| `-s`, `--source` | The save data's origin, which determines its structure | `firebase`         | `firebase`, `local`                           |

The `idleon_companion` option produces `idleon_companion.json` for import into [Idleon Companion](https://idleoncompanion.com/).

The `cogstruction` option produces `cog_datas.csv` and `empties_datas.csv` for use with [Cogstruction](https://github.com/automorphis/Cogstruction).

Data obtained from `inject.py` (or the GUI) is in the `firebase` format, while data obtained via `decode.py` is in the `local` format.

### Contributing

Feedback, suggestions, and contributions are welcome!

Use `poetry install --with dev,test` to install the optional dependencies. Run tests with [`pytest`](https://docs.pytest.org/en/latest/index.html). Please run [Black](https://black.readthedocs.io/en/stable/) before submitting a PR; I have it configured to run on save. Thanks for reading!

### Credits

- Windows plyvel wheels from https://github.com/synodriver/plyvel/actions