Refactored step 1: Core Architecture Setup
This commit is contained in:
75
src/core/ApplicationManager.h
Normal file
75
src/core/ApplicationManager.h
Normal file
@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
// Forward declarations
|
||||
class RenderManager;
|
||||
class InputManager;
|
||||
class StateManager;
|
||||
class AssetManager;
|
||||
class Game;
|
||||
class ScoreManager;
|
||||
class Starfield;
|
||||
class Starfield3D;
|
||||
class FontAtlas;
|
||||
class LineEffect;
|
||||
|
||||
/**
|
||||
* ApplicationManager - Central coordinator for the entire application lifecycle
|
||||
*
|
||||
* Responsibilities:
|
||||
* - Initialize and shutdown all subsystems
|
||||
* - Coordinate the main application loop
|
||||
* - Manage high-level application state
|
||||
* - Provide clean separation between main() and application logic
|
||||
*/
|
||||
class ApplicationManager {
|
||||
public:
|
||||
ApplicationManager();
|
||||
~ApplicationManager();
|
||||
|
||||
// Core lifecycle methods
|
||||
bool initialize(int argc, char* argv[]);
|
||||
void run();
|
||||
void shutdown();
|
||||
|
||||
// Application state
|
||||
bool isRunning() const { return m_running; }
|
||||
void requestShutdown() { m_running = false; }
|
||||
|
||||
// Access to managers (for now, will be replaced with dependency injection later)
|
||||
RenderManager* getRenderManager() const { return m_renderManager.get(); }
|
||||
StateManager* getStateManager() const { return m_stateManager.get(); }
|
||||
|
||||
private:
|
||||
// Initialization methods
|
||||
bool initializeSDL();
|
||||
bool initializeManagers();
|
||||
bool initializeGame();
|
||||
|
||||
// Main loop methods
|
||||
void processEvents();
|
||||
void update(float deltaTime);
|
||||
void render();
|
||||
|
||||
// Cleanup methods
|
||||
void cleanupManagers();
|
||||
void cleanupSDL();
|
||||
|
||||
// Core managers
|
||||
std::unique_ptr<RenderManager> m_renderManager;
|
||||
std::unique_ptr<StateManager> m_stateManager;
|
||||
|
||||
// Application state
|
||||
bool m_running = false;
|
||||
bool m_initialized = false;
|
||||
|
||||
// Timing
|
||||
uint64_t m_lastFrameTime = 0;
|
||||
|
||||
// Configuration
|
||||
int m_windowWidth = 1200;
|
||||
int m_windowHeight = 1000;
|
||||
std::string m_windowTitle = "Tetris (SDL3)";
|
||||
};
|
||||
Reference in New Issue
Block a user