# Artificer's Scrollwork

A local development workbench for ServUO shard developers. Browse UO client assets (statics, mobiles, gumps), navigate ServUO C# scripts with full class and method trees, trace method call chains as interactive flow diagrams, and render Gump classes visually — all without a live shard connection.

Built with **Tauri** (Rust shell) + **React** frontend + **C# Roslyn sidecar**.

---

## Requirements

You need the following installed before you can build or run the app.

### 1. Rust (stable)

Download and run the installer from https://rustup.rs

During installation, accept the default options. When it finishes, open a new terminal and verify:

```
rustc --version
cargo --version
```

### 2. Node.js 20 or later

Download the LTS installer from https://nodejs.org

After installing, verify:

```
node --version
npm --version
```

### 3. .NET 8 SDK

Download from https://dotnet.microsoft.com/download/dotnet/8.0

Choose the **SDK** (not Runtime) for Windows x64. After installing, verify:

```
dotnet --version
```

Should print `8.x.x` or higher.

### 4. Tauri CLI

After Rust is installed, run:

```
cargo install tauri-cli
```

This takes a few minutes. Verify with:

```
cargo tauri --version
```

### 5. WebView2 Runtime

Required by Tauri on Windows. Most Windows 10/11 machines already have it via Microsoft Edge. If the app fails to launch, download it from:

https://developer.microsoft.com/microsoft-edge/webview2/

---

## Getting Started

### Clone the repository

```
git clone https://gitea.whitlocktech.com/whitlocktech/Artificers-Scrollwork.git
cd Artificers-Scrollwork
```

### Install JavaScript dependencies

```
npm install
```

### Build the C# sidecar

The sidecar handles Roslyn script parsing. It must be compiled before running the app.

```
cd sidecar
dotnet publish -c Release -r win-x64 --self-contained
cd ..
```

Then copy the compiled binary into the Tauri binaries folder:

```
copy sidecar\bin\Release\net8.0\win-x64\publish\asw-sidecar.exe src-tauri\binaries\asw-sidecar-x86_64-pc-windows-msvc.exe
```

---

## Running in Dev Mode

Dev mode runs the app with hot reload. The Rust backend and React frontend reload automatically as you make changes.

Make sure you have completed the sidecar build step above, then run:

```
npm run tauri dev
```

The app window will open. First launch may take a minute while Rust compiles the backend.

On first run, use the Config screen (gear icon, top right) to set:
- **UO Root** — path to your Ultima Online client folder (must contain `art.mul` or `artLegacyMUL.uop`)
- **ServUO Scripts** — path to your ServUO `Scripts/` folder

---

## Building the MSI Installer

### Windows Defender note

The Tauri bundler patches the compiled `.exe` immediately after Rust finishes building it. Windows Defender or the Program Compatibility Assistant can lock the file during this window and cause the build to fail with error 1224.

**Before building**, add the target folder to Windows Defender exclusions:

1. Open **Windows Security** → **Virus & threat protection** → **Manage settings**
2. Scroll to **Exclusions** → **Add or remove exclusions**
3. Add this folder: `<repo root>\src-tauri\target`

If the build still fails, run this in an **Administrator** PowerShell before building:

```powershell
Stop-Service PcaSvc -Force
npm run tauri build
Start-Service PcaSvc
```

### Build steps

Make sure the sidecar is compiled and copied (see above), then:

```
npm run tauri build
```

The finished MSI will be at:

```
src-tauri\target\release\bundle\msi\Artificer's Scrollwork_0.1.0_x64_en-US.msi
```

Double-click the MSI to install. The app will appear in your Start menu as **Artificer's Scrollwork**.

---

## Project Structure

```
artificers-scrollwork/
├── src/                    React frontend
├── src-tauri/              Rust / Tauri backend
│   ├── src/
│   │   ├── assets/         .mul / .uop file parsers
│   │   ├── commands/       Tauri IPC command handlers
│   │   └── ipc/            C# sidecar process management
│   └── binaries/           Compiled sidecar binary (git-ignored)
├── sidecar/                C# Roslyn sidecar
│   ├── Parsing/            Script indexer and call chain tracer
│   └── Gumps/              Gump constructor extractor
├── UO Gumps/               Bundled gump BMP art + XML manifests
└── UO artwork/             Bundled static tile BMP art
```

---

## Updating the Sidecar

If you change any C# code in `sidecar/`, you must recompile and copy the binary before the changes take effect:

```
cd sidecar
dotnet publish -c Release -r win-x64 --self-contained
cd ..
copy sidecar\bin\Release\net8.0\win-x64\publish\asw-sidecar.exe src-tauri\binaries\asw-sidecar-x86_64-pc-windows-msvc.exe
```

Then restart dev mode or rebuild the MSI.

---

## License

MIT — see LICENSE file.
