# maktoobgar/scene_manager architecture

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

- Interactive diagram: https://gitdiagram.com/maktoobgar/scene_manager
- Repository: https://github.com/maktoobgar/scene_manager

## Overview

##### Main Components
- Scene Manager Core Module:
– This includes the primary script (SceneManager.gd) and associated helper functions that provide scene validation, transition effects, and signal emitting.
– Capture the functions such as change_scene, no_effect_change_scene, load_scene_interactive, etc.
- UI and Plugin Integration:
– Include the plugin configuration file (plugin.cfg) that integrates the tool into the Godot Editor.
- Transition and Effects Components:
– There are shader files (scene_manager.gdshader) and shader patterns located under shader_patterns that drive the visual transitions.
– Represent the fade-in, fade-out, and any special pattern transitions used for scene changes.
- Data Storage:
– The file scenes.gd acts as a stored dictionary of scene key–scene mappings which is crucial for maintaining state across transitions and during related actions such as “reload”, “back”, or “reset”.
- Demo Integration:
– The demo folder shows examples of scene scripts and scenes (scene1.tscn, scene2.tscn, etc.). It illustrates usage scenarios for the Scene Manager.
- External Interactions:
– Since this project communicates with the Godot editor’s file system (using reactive functions to watch file changes) and uses signals for asynchronous updates (for loading percent updates, scene_changed, fade transitions), it is key to capture these external dependencies.

##### Visualizing Component Relationships and Interactions
- External signals and state flows (for interactions like load_percent_changed, load_finished, fade_in_started, etc.) around the core module. Use these to indicate asynchronous events that update UI elements or trigger changes in scene flow.
- Demo as an example client that consumes the Scene Manager API. This can be placed as a separate component that sends inputs to the core module and receives callbacks/events in return.
- Integration point with the Godot Plugin system (plugin.cfg and the use of the addon in the project.godot file). This shows how the plugin is activated from within the Godot editor.

##### Architectural Patterns and Design Principles
- Model-View-Controller Elements: Although not formally segmented, notice the separation where the scene management logic (model/controller) is distinct from the UI components (view).
- Signal-Based Communication: Emphasize the use of signals for decoupled event handling (scene_changed, load_percent_changed, etc.).
- Configuration and Extensibility: The project permits customizable options (fade options, general transition options), which suggests a pattern for configurable behavior.
- Plugin-Based Architecture: Show the addon structure enabling modular extension into Godot.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    subgraph "Godot Plugin Integration"
        UI1["Menu (UI)"]:::ui
        UI2["Scene List (UI)"]:::ui
        CFG["Plugin Configuration (plugin.cfg)"]:::config
    end

    subgraph "Scene Manager Core"
        CORE["Scene Manager Core Module"]:::core
        CORE -->|"calls_change_scene"| CORE_FUNC["Core Functions (change_scene,no_effect_change_scene,load_scene_interactive)"]:::core
        CORE -->|"emits_signals"| SIGNALS["Godot Signals (scene_changed,load_percent_changed,fade_in_started)"]:::signal
        CORE -->|"accesses_data"| DATA["Data Storage (scenes.gd)"]:::data
    end

    subgraph "Transition Effects"
        SHADER["Shader File (scene_manager.gdshader)"]:::transition
        PATTERNS["Shader Patterns"]:::transition
        SHADER -->|"supports"| PATTERNS
    end

    subgraph "UI Components"
        UI1_LINK["Menu UI"]:::ui
        UI2_LINK["Scene List UI"]:::ui
    end

    subgraph "Demo/Client"
        DEMO["Demo/Client Scripts"]:::demo
    end

    %% Connections
    UI1 -->|"triggers"| CORE
    UI2 -->|"triggers"| CORE
    CFG -->|"activates"| CORE
    CORE -->|"invokes_fade_effects"| SHADER
    CORE -->|"updates_on"| SIGNALS
    CORE_FUNC -->|"requests_effects"| SHADER
    CORE -->|"reads_from"| DATA
    DEMO -->|"calls_API"| CORE

    %% Click Events for Component Mapping
    click CORE "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/scene_manager.gd"
    click UI1 "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/menu.tscn"
    click UI2 "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/scene_list.tscn"
    click CFG "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/plugin.cfg"
    click SHADER "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/scene_manager.gdshader"
    click PATTERNS "https://github.com/maktoobgar/scene_manager/tree/main/addons/scene_manager/shader_patterns"
    click DATA "https://github.com/maktoobgar/scene_manager/blob/main/addons/scene_manager/scenes.gd"
    click DEMO "https://github.com/maktoobgar/scene_manager/tree/main/demo"

    %% Styles
    classDef core fill:#f9c,stroke:#333,stroke-width:2px;
    classDef ui fill:#ccf,stroke:#333,stroke-width:2px;
    classDef config fill:#efe,stroke:#333,stroke-width:2px;
    classDef transition fill:#cfc,stroke:#333,stroke-width:2px;
    classDef data fill:#fcf,stroke:#333,stroke-width:2px;
    classDef signal fill:#ffc,stroke:#333,stroke-width:2px;
    classDef demo fill:#cff,stroke:#333,stroke-width:2px;
```
