# Asset Explorer

# Asset Explorer

The Asset Explorer allows you to browse, extract, and view Hytale game assets directly from the panel. Access it from **Tools** → **Asset Explorer**.

## Overview

Hytale stores game assets (models, textures, sounds, etc.) in compressed archives. The Asset Explorer provides:

- **Browse** the complete asset hierarchy
- **Extract** individual files or folders
- **Preview** supported file types
- **Search** for specific assets
- **Download** extracted files

## Extracting Assets

Before browsing, you need to extract the assets from the game archives.

### Automatic Extraction

1. Go to **Tools** → **Asset Explorer**
2. Click **Extract Assets**
3. Wait for the extraction to complete (may take several minutes)
4. Assets are extracted to `/opt/hytale/data/assets/`

### Manual Extraction

Using the server console:
```
/assets extract
```

Or via container:
```bash
docker exec hytale /opt/hytale/server/extract-assets.sh
```

## Browsing Assets

### Navigation

- **Folder Tree** - Left sidebar shows the directory structure
- **File List** - Main area shows files in current folder
- **Breadcrumbs** - Top bar shows current path
- **Back Button** - Return to parent folder

### Asset Categories

| Folder | Contents |
|--------|----------|
| `models/` | 3D models (.hym, .obj) |
| `textures/` | Image textures (.png, .jpg) |
| `sounds/` | Audio files (.ogg, .wav) |
| `shaders/` | Shader programs |
| `prefabs/` | Prefab definitions |
| `scripts/` | Lua/behavior scripts |
| `ui/` | UI layouts and assets |
| `localization/` | Translation files |

## Searching Assets

### Basic Search

1. Click the **Search** icon or press `Ctrl+F`
2. Enter your search term
3. Results show matching files across all folders

### Search Filters

- **Name**: `name:sword` - Files containing "sword"
- **Extension**: `ext:png` - Only PNG files
- **Path**: `path:models/creatures` - Within specific path
- **Size**: `size:>1MB` - Files larger than 1MB

### Search Examples

| Query | Results |
|-------|---------|
| `dragon` | All files with "dragon" in name |
| `ext:ogg` | All sound files |
| `path:textures name:grass` | Grass textures only |

## File Preview

### Supported Formats

| Type | Formats | Preview |
|------|---------|---------|
| Images | PNG, JPG, TGA, BMP | Full preview |
| Text | JSON, TXT, XML, LUA | Syntax highlighted |
| Audio | OGG, WAV | Audio player |
| Models | HYM | Metadata only |

### Preview Panel

1. Select a file in the file list
2. Preview appears in the right panel
3. Use zoom controls for images
4. Click **Open Full** for larger view

## Downloading Assets

### Single File

1. Select the file
2. Click **Download** button
3. File downloads to your browser

### Multiple Files

1. Select multiple files (Ctrl+Click)
2. Click **Download Selected**
3. Files are zipped and downloaded

### Entire Folder

1. Right-click on a folder
2. Select **Download as ZIP**
3. Folder contents are zipped and downloaded

## API Reference

### Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/assets/status` | Get extraction status |
| GET | `/api/assets/browse?path=` | List directory contents |
| GET | `/api/assets/tree?path=&depth=` | Get directory tree |
| GET | `/api/assets/file?path=` | Get file contents |
| POST | `/api/assets/extract` | Trigger asset extraction |
| DELETE | `/api/assets/cache` | Clear extracted assets |
| GET | `/api/assets/search?q=&ext=&content=&limit=` | Search assets |
| GET | `/api/assets/download/*` | Download file/folder |
| GET | `/api/assets/items?q=&limit=` | Search item list |
| GET | `/api/assets/item-icon/:itemId` | Get item icon (public) |
| GET | `/api/assets/player-avatar` | Get player avatar (public) |

### Search Parameters

| Parameter | Description | Example |
|-----------|-------------|---------|
| `q` | Search query | `dragon` |
| `ext` | File extensions | `png,jpg` |
| `content` | Search file contents | `true` |
| `limit` | Max results | `100` |
| `regex` | Use regex search | `false` |
| `glob` | Use glob patterns | `false` |

### Response Format

```json
{
  "path": "/textures/blocks",
  "entries": [
    {
      "name": "grass_top.png",
      "type": "file",
      "size": 4096,
      "modified": "2024-01-15T10:30:00Z"
    },
    {
      "name": "dirt",
      "type": "directory",
      "children": 12
    }
  ]
}
```

## Permissions

| Permission | Description |
|------------|-------------|
| `assets.view` | Browse, view, and download assets |
| `assets.manage` | Extract and manage assets |

## Storage Considerations

- Extracted assets require approximately **2-3 GB** of disk space
- Assets are stored in `/opt/hytale/data/assets/`
- Re-extraction overwrites existing files
- Consider backup before major extractions

## Troubleshooting

### Extraction Fails

1. Check available disk space
2. Verify server files are complete
3. Check container logs for errors:
   ```bash
   docker-compose logs hytale
   ```

### Preview Not Loading

1. Check file format is supported
2. Large files may take time to load
3. Clear browser cache

### Search Returns No Results

1. Ensure assets are extracted
2. Check search syntax
3. Try broader search terms