# maygi/tof-overlay architecture

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

- Interactive diagram: https://gitdiagram.com/maygi/tof-overlay
- Repository: https://github.com/maygi/tof-overlay

## Overview

##### Main Components
- User Interface (UI):
- This is the overlay window that displays weapon cooldowns, timers, and visual effects. Components like GuiButton, AbstractFrame, GraphFrame, OptionsFrame, Overlay, and Tooltip (located in src/gui) represent the visual elements.
- Data/Model Layer:
- Contains data models for tracking weapon data, timers, and collections (classes in src/model, e.g., WeaponData, TimeCollection, DPSCollection, and MainDriver).
- Image Recognition and Processing:
- The overlay is driven by image recognition using the Sikuli API (indicated by the presence of lib/sikulixapi.jar) and makes use of image directories (images/sikuli) for template matching or text detection.
- Sound Module:
- Manages sound triggers for various events (both the sound files in the sound folder and the logic in src/sound/Sound.java).
- Particle Effects:
- Visual indicators such as particles are handled by the classes in src/particles (AbstractShapeParticle, CircleParticle, ParticleEmitter, TextParticle), likely used to provide visual feedback.
- Configuration/Properties:
- External configuration files such as config.properties and weapon.properties (editable by the user) determine runtime settings and weapon customization.
- External Libraries and Hooks:
- jnativehook is included to capture keyboard or mouse events, thus helping the overlay interact with user inputs while the game is in fullscreen mode.

##### Relationships and Interactions
- The MainDriver from src/model acts as the control center that initializes the program, orchestrating image processing (screen capturing via Sikuli) and passing the detected data to the model and UI layers.
- Once data is captured (such as current cooldowns or weapon states), the data models update the UI components accordingly.
- The GUI framework responds to both configuration changes (from config.properties/weapon.properties) and user interactions (e.g., dragging the window or resetting settings).
- Sound events are triggered based on state changes detected in the data models. The sound module and audio resources are then used to provide feedback.
- Particle components are likely summoned by the UI layer to display subtle visual effects in response to game events.
- External libraries (sikulixapi.jar and jnativehook) provide low-level functionality, interfacing with the system for screen capture and input event handling.

##### Architectural Patterns and Design Principles
- Separation of Concerns – The project neatly divides responsibilities: GUI (display logic in src/gui), Business/Data Model (src/model), and auxiliary services like sound and particle effects.
- Modular Design – With dedicated packages (gui, model, particles, sound, util), it’s easier to update or extend specific parts of the application.
- Event-Driven and Reactive Elements – The program actively responds to in-game visual cues and possibly user events (via jnativehook) to update state and trigger overlays.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Configuration & Properties<br/>(config.properties, weapon.properties)"]:::config
    B["MainDriver & Models<br/>(src/model)"]:::model
    D["Image Recognition<br/>(Sikuli API)"]:::recognition
    H["Image Templates<br/>(images/sikuli)"]:::recognition
    C["UI Components<br/>(src/gui)"]:::ui
    G["Native Hook<br/>(lib/jnativehook-2.2.2.jar)"]:::ext
    E["Sound Module<br/>(src/sound/Sound.java)"]:::aux
    I["Sound Files<br/>(sound)"]:::aux
    F["Particle Effects<br/>(src/particles)"]:::part

    A -->|"initializes"| B
    H -->|"provides_templates"| D
    D -->|"extracts_data"| B
    B -->|"updates"| C
    G -->|"captures_events"| C
    C -->|"triggers"| E
    C -->|"triggers"| F
    E -->|"utilizes"| I

    class A config
    class B model
    class C ui
    class D recognition
    class H recognition
    class G ext
    class E aux
    class I aux
    class F part

    click A "https://github.com/maygi/tof-overlay/blob/main/config.properties"
    click B "https://github.com/maygi/tof-overlay/tree/main/src/model"
    click C "https://github.com/maygi/tof-overlay/tree/main/src/gui"
    click D "https://github.com/maygi/tof-overlay/blob/main/lib/sikulixapi.jar"
    click H "https://github.com/maygi/tof-overlay/tree/main/images/sikuli"
    click E "https://github.com/maygi/tof-overlay/blob/main/src/sound/Sound.java"
    click I "https://github.com/maygi/tof-overlay/tree/main/sound"
    click F "https://github.com/maygi/tof-overlay/tree/main/src/particles"
    click G "https://github.com/maygi/tof-overlay/blob/main/lib/jnativehook-2.2.2.jar"
```
