# unjammer/tilezed architecture

> Architecture diagram of the GitHub repository unjammer/tilezed, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unjammer/tilezed
- Repository: https://github.com/unjammer/tilezed

## Overview

Based on our analysis of the provided file tree and README, this project (“Project Zomboid TileZed”) is a fork of the Tiled map editor with significant extensions tailored to Project Zomboid. It is a desktop application (with a GUI based on Qt) that provides an advanced tile‐based map editor with integrated building tools, a LUA engine for added scripting support, and a flexible plugin architecture. The project is organized as a full-featured desktop editor with clearly separated modules for core mapping functionality, plugins, scripting, and utilities.

##### Main Components
- Core Mapping Engine: This includes the “libtiled” component (in src/libtiled) which handles map models, tiles, layers, tile sets, compression, and map reading/writing features. It is central to processing the tile data.
- Graphical User Interface (GUI): The UI components are primarily found in the “src/tiled” folder (with numerous .cpp, .h, and .ui files), as well as the “BuildingEditor” subdirectory. This represents the front-end of the editor where users interact with maps, buildings, and tiles.
- Plugin Architecture: There is a clearly defined “src/plugins” directory containing multiple plugins (for example, “droidcraft”, “flare”, “json”, “lua”, “lot”, “replicaisland”, “tengine”, and “tmw”). This subsystem is responsible for extending the functionality of the core engine.
- Scripting and LUA Integration: With a dedicated “src/lua” directory and numerous LUA scripts in the “lua” folder at the project root, this component supports scripting for custom behaviors, map generation enhancements, and tool automation.
- Automapping and Conversion Tools: The “src/automappingconverter” component is designed to convert or generate maps automatically.
- Configuration & Theme Management: Modules in “src/config” and theme-related files in “theme” are used to manage user preferences, themes (including the new dark theme), and tool configuration.
- External Libraries and Utilities: This includes “zlib” (for compression tasks), “qtsingleapplication”, “qtlockedfile”, and even Java-based tools under “util/java” and “util/java/libtiled-java” that suggest cross-language or auxiliary platform support.
- Testing and Documentation: The “tests” and “docs” directories illustrate that there are automated tests for various components and auto-generated documentation (using Doxyfile, etc.) to detail the architecture and API usage.

##### Relationships and Interactions
- The Core Mapping Engine (libtiled) forms the base layer; its APIs and data structures are used both by the GUI layer and by the plugins.
- The GUI layer (including the BuildingEditor) interacts with the core engine to display maps, enable tile editing, and allow configuration through dialogs. It also communicates with configuration modules and themes.
- Scripting and LUA integration interacts directly with the core and UI modules. The built-in LUA engine facilitates in-app scripting for map modifications, automation, and enhances the InGameMap features (e.g., route generation and building manipulation).
- Automapping converter tools take map data from the core and perform conversions or additional processing, likely feeding back results into the editor workflow.
- External libraries, such as zlib, sit adjacent to the core modules and provide supplementary functionality (compression, decompression) for map import/export.
- Configuration and theme management overlay the UI layer to allow for runtime adjustments to the user interface and application behavior.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system clearly separates the UI/editor, core mapping engine, plugin management, and scripting integrations.
- Modular Architecture: Components like libtiled, plugins, and configuration are clearly compartmentalized. This supports independent development, testing, and maintenance.
- Extensibility: Through the plugin system and integration with LUA, the design promotes extensibility, which is reinforced by the separate directories for each plugin type.
- Use of MVC-like Patterns: While not strictly an MVC, the separation between the map data model (libtiled), the views (GUI/editor), and the controllers (commands, automapping tools) shows a similar distribution of responsibilities.

##### Relevant Technologies, Frameworks, or Libraries
- Qt Framework: Evident from the .pro, .ui, and various Qt-specific modules (qtsingleapplication, qtlockedfile).
- LUA: For scripting integration.
- zlib: For compression operations.
- CMake and QMake: As build configuration tools (indicating cross-platform and configuration management practices).

a. Core Mapping Engine at the center (base layer) since it is the foundational component.
f. Finally, denote testing/documentation as peripheral but essential support modules, perhaps in a “Quality Assurance / Documentation” bubble.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        MAINGUI["Main GUI"]:::frontend
        BUILDING["Building Editor"]:::frontend
    end

    subgraph "Core Engine Layer"
        CORE["Core Mapping Engine (libtiled)"]:::core
    end

    subgraph "Extension Layer"
        PLUGIN["Plugin Architecture"]:::plugin
        SCRIPTING1["Scripting (src/lua)"]:::scripting
        SCRIPTING2["Scripting (lua root)"]:::scripting
    end

    subgraph "Support Tools"
        AUTOMAP["Automapping Converter"]:::support
        CONFIG["Configuration"]:::support
        THEME["Themes"]:::support
        ZLIB["zlib"]:::external
        QTAPP["QtSingleApplication"]:::external
        QTLOCK["QtLockedFile"]:::external
        LIBJAVA["LibtiledJava"]:::external
        TESTS["Tests"]:::qa
        DOCS["Docs"]:::qa
    end

    %% Connections
    MAINGUI -->|"calls"| CORE
    BUILDING -->|"calls"| CORE

    PLUGIN -->|"extends"| CORE
    PLUGIN -->|"integrates"| MAINGUI

    SCRIPTING1 -->|"interacts"| CORE
    SCRIPTING1 -->|"interacts"| MAINGUI
    SCRIPTING2 -->|"interacts"| CORE
    SCRIPTING2 -->|"interacts"| MAINGUI

    CORE -->|"providesData"| AUTOMAP

    CONFIG -->|"configures"| MAINGUI
    CONFIG -->|"configures"| CORE
    THEME -->|"appliesTo"| MAINGUI

    ZLIB -->|"supports"| CORE
    QTAPP -->|"supports"| CORE
    QTLOCK -->|"supports"| CORE
    LIBJAVA -->|"supports"| CORE

    TESTS ---|"validates"| CORE
    DOCS ---|"documents"| CORE
    TESTS ---|"validates"| MAINGUI
    DOCS ---|"documents"| MAINGUI

    %% Click Events
    click CORE "https://github.com/unjammer/tilezed/tree/B42/src/libtiled"
    click MAINGUI "https://github.com/unjammer/tilezed/tree/B42/src/tiled"
    click BUILDING "https://github.com/unjammer/tilezed/tree/B42/src/tiled/BuildingEditor"
    click PLUGIN "https://github.com/unjammer/tilezed/tree/B42/src/plugins"
    click SCRIPTING1 "https://github.com/unjammer/tilezed/tree/B42/src/lua"
    click SCRIPTING2 "https://github.com/unjammer/tilezed/tree/B42/lua"
    click AUTOMAP "https://github.com/unjammer/tilezed/tree/B42/src/automappingconverter"
    click CONFIG "https://github.com/unjammer/tilezed/tree/B42/src/config"
    click THEME "https://github.com/unjammer/tilezed/tree/B42/theme"
    click ZLIB "https://github.com/unjammer/tilezed/tree/B42/src/zlib"
    click QTAPP "https://github.com/unjammer/tilezed/tree/B42/src/qtsingleapplication"
    click QTLOCK "https://github.com/unjammer/tilezed/tree/B42/src/qtlockedfile"
    click LIBJAVA "https://github.com/unjammer/tilezed/tree/B42/util/java/libtiled-java"
    click TESTS "https://github.com/unjammer/tilezed/tree/B42/tests"
    click DOCS "https://github.com/unjammer/tilezed/tree/B42/docs"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef plugin fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef scripting fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef support fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef qa fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
