diff --git a/README.md b/README.md index 057b504a6ad075761a150b570e7f6a401d79eee4..daccf98f62f9404223e6899fb12772aabeb80d05 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,54 @@ Todo # Documentation The following is a documentation for all the code used in the project. As the project is currently at development halt, there are a few known issues that can not be addressed for the time being. They are pointed out in their respective sections. ## Architecture -Todo +The application is split into different modules, each module handles a subset of the total functionality. The major modules and their responsibilities are +- **`WaveHandler`** + - Handle the wave textures + - Handle integration of the wave equation + - Handle rendering the wave + - Handle certain texture initialisations for other modules *(this should be changed)* +- **`InputHandler`** + - Interface with SDL to fetch user input + - Translate user input to a usable format (`Pevent`) + - Communicate user input to other modules +- **`GuiHandler`** + - Interface with `ImGui` + - Draw the GUI + - Communicate GUI input to other modules +- **`SlimBlockchainHandler`** + - Handle the "Spielen" functionality (place, move, remove blocks) + - Draw to wave and damping textures to implement "Spielen" +- **`DrawingHandler`** + - Handle the "Zeichnen" and "Radieren" functionality (draw strokes) + - Draw to wave and damping textures to implement "Zeichnen" and "Radieren" +- **`PatternHandler`** + - Handle all predefined structure placements + - Draw structures to damping textures +- **`TimeoutHandler`** + - Handle the Timeout functionality (if no user input for N seconds, send reset requests to everyone) + - Send reset requests to other modules +- **`Toolbox`** + - Store information needed by several other modules ("global state") + - Implement an event chain where current events are stored + - Implement a mailbox to facilitate the passing of messages + +Much like the name suggests, the `Toolbox` is passed around from one module to the next, and each can then access everything stored within it. +Each module can see all information and decide how it reacts to the current combination of state, messages and events (user input). +The logical flow of the application game loop goes as follows: +1. `InputHandler` writes new user input into the `Toolbox` event chain +2. `TimeoutHandler` checks if there is any user input, and if timeout occurs posts reset requests to the `Toolbox` mailbox targeting all other modules +3. `GuiHandler` checks if user input targets the GUI, updates the global state (e.g. change source frequency, change game mode to "Zeichnen") and sends appropriate messages to other modules (e.g. place structure) +4. `WaveHandler` checks if any messages that target it have been posted +5. `SlimBlockchainHandler` reacts to its messages and user input +6. `DrawingHandler` reacts to its messages and user input +7. `PatternHandler` reacts to its messages and user input +8. Now all state has been updated, all messages posted and handled and damping textures are final +9. `WaveHandler` timesteps the wave +10. `WaveHandler` renders the new wave to the screen +11. `GuiHandler` renders the GUI to the screen +12. Renderbuffers are swapped and the frame ends + + ## Classes ### Drawer ([drawer.hpp](include/drawer.hpp), [drawer.cpp](src/drawer.cpp)) **Description**