# unjammer/worlded architecture

> Architecture diagram of the GitHub repository unjammer/worlded, 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/worlded
- Repository: https://github.com/unjammer/worlded

## Overview

This project is an unofficial fork of WorldEd—a standalone world editing tool that appears to support a variety of map and building editing capabilities. Its purpose is to provide an integrated editor built with Qt (leveraging files such as .pro and .pri for configuration) for tasks like map building (including in-game maps, enhanced tile handling, road and building editing, and biomap generation) plus support for external components (such as a built-in LUA engine and ZIP/compression libraries). The project’s file structure shows clear separations between UI/editor code, the embedded LUA engine, libraries for tiled maps, a custom locked file handler for Qt, a ZIP compression library (quazip), and the zlib compression library. Themes for the UI are managed separately in the “theme” folder.

##### Main Components
- Application Core (Editor): Represent the central component where most of the UI and the main application logic reside. This includes:
- The main window and its subcomponents (dialogs for “bmptotmx”, “newworld”, “preferences”, etc.)
- Modules such as Document, Logger, and Clipboard management.
- Sections like InGameMap and BuildingEditor, which handle specific editing features.
- Integrated Modules/Libraries:
- Embedded LUA Engine: Illustrate its role in scripting, especially for in-game map functionality.
- LibTiled: A dedicated module focused on handling tile maps (rendering, parsing maps, etc.).
- Quazip and Zlib: Show these as responsible for compression/decompression tasks used in map export or asset handling.
- QtLockedFile: Responsible for file locking on different OS’s.
- Themes: A separate component for the theme management system, pointing out its use of QSS files from the “theme” folder.

##### Relationships and Interactions
- UI and Core Communication:
- Signals and slots as a design pattern frequently used in Qt applications.
- Library Integration:
- That the core Editor modules interact with the LUA engine for scripting and with LibTiled for tile-based operations.
- Dependencies from the editor modules to the Quazip and Zlib libraries for asset compression, including any intermediary layers.
- Data Flow:
- How inputs (user interactions in dialogs, theme changes) propagate through the UI, trigger business logic (such as map generation or file management), which then interact with external libraries for processing and persistence.
- That the enhanced features (like in-game route generation or building renderings) rely on a collaboration between multiple modules.

##### Architectural Patterns or Design Principles
- Modular Design: The separation of concerns is clear. For example, each editing feature (map editing, building editing, theme management) is contained within self-sufficient subdirectories.
- MVC/MVVM Elements: Even if not strictly enforced, the presence of “views” (UI files, .ui header files) and underlying data management (document management, file system watchers) suggests an architectural pattern that separates presentation and business logic.
- Component Reusability: The project makes use of internal libraries (libtiled, LUA, quazip) and clearly encapsulates third-party code as submodules.

##### Technologies, Frameworks, and Libraries
- Qt (with its metabolites: signals/slots, QSS for themes, and .ui files)
- C++ (the language for the editor, with many modules such as BuildingEditor and InGameMap)
- LUA (for scripting internals)
- LibTiled (for tile map operations)
- Quazip and Zlib (for compression tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Application Core (Editor)"]:::editor
    B["Main Window & UI Dialogs"]:::ui
    C["Document & Logger Modules"]:::business
    D["InGameMap Module"]:::business
    E["BuildingEditor Module"]:::business
    F["Embedded LUA Engine"]:::integration
    G["LibTiled (Tile Map Handling)"]:::integration
    H["Quazip Library (ZIP Compression)"]:::integration
    I["Zlib Compression Library"]:::integration
    J["QtLockedFile"]:::integration
    K["Theme Management"]:::integration

    %% Core Structure
    A -->|"contains"| B
    A -->|"contains"| C
    B -->|"signals&slots"| C
    C -->|"triggers"| D
    C -->|"triggers"| E

    %% Integration Interactions
    D -->|"scripting"| F
    D -->|"tile_ops"| G
    E -->|"compression"| H
    E -->|"compression"| I
    C -->|"file-lock"| J
    B -->|"themes"| K

    %% Click Events for Application Core and UI Modules
    click A "https://github.com/unjammer/worlded/tree/B42/src/editor/"
    
    click B "https://github.com/unjammer/worlded/blob/B42/src/editor/mainwindow.cpp"
    click B "https://github.com/unjammer/worlded/blob/B42/src/editor/mainwindow.h"
    click B "https://github.com/unjammer/worlded/blob/B42/src/editor/mainwindow.ui"
    click B "https://github.com/unjammer/worlded/tree/B42/src/editor/.uic/"

    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/document.cpp"
    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/document.h"
    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/documentmanager.cpp"
    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/documentmanager.h"
    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/Logger.cpp"
    click C "https://github.com/unjammer/worlded/blob/B42/src/editor/Logger.h"

    click D "https://github.com/unjammer/worlded/tree/B42/src/editor/InGameMap/"
    click E "https://github.com/unjammer/worlded/tree/B42/src/editor/BuildingEditor/"

    click F "https://github.com/unjammer/worlded/tree/B42/src/lua/"
    click G "https://github.com/unjammer/worlded/tree/B42/src/libtiled/"

    click H "https://github.com/unjammer/worlded/tree/B42/src/quazip-1.1/"
    click I "https://github.com/unjammer/worlded/tree/B42/src/zlib/"

    click J "https://github.com/unjammer/worlded/tree/B42/src/qtlockedfile/"
    click K "https://github.com/unjammer/worlded/tree/B42/theme/"

    %% Styles
    classDef editor fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef ui fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef integration fill:#87CEEB,stroke:#333,stroke-width:2px;
```
