Metadata-Version: 2.4
Name: mb-sc-tools
Version: 0.1.3
Summary: Mobile-friendly Supercell .sc/.sctx decoder and encoder for Python
Author: bsod4ik
License-Expression: MIT
Keywords: supercell,brawl-stars,sc,texture,astc,mobile
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: flatbuffers>=25.0.0
Requires-Dist: zstandard>=0.22.0
Requires-Dist: lz4>=4.3.3
Requires-Dist: Pillow>=10.0.0
Dynamic: license-file

# mb-sc-tools

`mb-sc-tools` is a Python library and CLI for decoding and encoding Supercell `.sc` and `.sctx` files on phones and desktops.

It supports:

- decoding `.sc` and `.sctx` into PNG textures and `data.json`
- encoding edited PNGs back into `.sc` and `.sctx`
- standalone `.sctx` rebuilds from `data.json` + PNG without requiring the original backup file
- `SC` wrappers with `zstd`, `lzma`, and `lz4` payloads
- ARM64 phones and desktop systems
- automatic `astcenc` download on first use for ASTC/KTX textures
- configurable workspace, output paths, backup name, and ASTC encoder path

## Install

```bash
pip install mb-sc-tools
```

## CLI

```bash
mb-sc-tools
```

Or direct commands:

```bash
mb-sc-tools decode /path/to/ui.sc
mb-sc-tools decode /path/to/bgr.sctx
mb-sc-tools encode /path/to/sc_decoded/ui
```

More explicit control:

```bash
mb-sc-tools decode /path/to/ui.sc \
  --workspace-root /tmp/sc-work \
  --output-dir /tmp/sc-work/custom/ui \
  --source-backup-name source.sc

mb-sc-tools encode /tmp/sc-work/custom/ui \
  --workspace-root /tmp/sc-work \
  --output /tmp/sc-work/sc_encoded/ui.sc
```

## Python API

```python
from pathlib import Path

from mb_sc_tools import (
    DecodeOptions,
    EncodeOptions,
    WorkspaceConfig,
    decode_to_workspace,
    encode_folder,
)

workspace = WorkspaceConfig(root=Path("/tmp/sc-work"))

decoded_dir, data = decode_to_workspace(
    Path("/sdcard/ui.sc"),
    options=DecodeOptions(
        workspace=workspace,
        source_backup_name="source.sc",
    ),
)

encoded_path = encode_folder(
    decoded_dir,
    options=EncodeOptions(
        workspace=workspace,
        output_path=Path("/tmp/sc-work/sc_encoded/ui.sc"),
    ),
)
```

## Output layout

On Android/Termux, if `/sdcard/sc` exists the tool writes to:

- `/sdcard/sc/sc_decoded/<file_stem>/`
- `/sdcard/sc/sc_encoded/<original_name>.sc`

Otherwise it writes to a local `./sc/` workspace.
