|
Muto 0.0.1
|
The core application class that manages the main loop, window, layers, and event handling. More...
#include <Application.h>
Public Member Functions | |
| Application (ApplicationSettings settings) | |
| Constructs the Application with the given settings. | |
| Application (const std::string &name="") | |
| Constructs the Application with the given name. | |
| void | Close () |
| Closes the application. | |
| ImGuiLayer * | GetImGuiLayer () |
| Retrieves the ImGui layer. | |
| ApplicationSettings & | GetSettings () |
| Retrieves the application settings. | |
| const ApplicationSettings & | GetSettings () const |
| Retrieves the application settings as a const reference. | |
| Window & | GetWindow () |
| Retrieves the application window. | |
| void | OnEvent (Event &e) |
| Handles incoming events and dispatches them to the appropriate handlers. | |
| void | PushLayer (Layer *layer) |
| Adds a layer to the application layer stack. | |
| void | PushOverlay (Layer *overlay) |
| Adds an overlay layer to the application layer stack. | |
| std::string | ResolvePath (const std::string &Path, PathResolveMode Mode=PathResolveMode::AssetsDirectory) const |
| Resolves the full path to a resource based on a relative path and the application's settings. | |
| void | Run () |
| Starts the main application loop. | |
| virtual | ~Application () |
Static Public Member Functions | |
| static Application & | Get () |
| Retrieves the singleton instance of the Application. | |
Private Member Functions | |
| MutoResult | InitFileSystem () |
| Initializes the file system for the application. | |
| MutoResult | InitFileSystem (ApplicationSettings &Settings) |
| Initializes the file system for the application with the given settings. | |
| bool | OnWindowClose (WindowCloseEvent &e) |
| Event handler for window close events. | |
| bool | OnWindowResize (WindowResizeEvent &e) |
| Event handler for window resize events. | |
| std::string | ResolvePath_AssetsDirectory (const std::string &Path) const |
| Resolves the full path to a resource based on the application's assets directory. | |
| std::string | ResolvePath_ProjectDirectory (const std::string &Path) const |
| Resolves the full path to a resource based on the application's project directory. | |
| std::string | ResolvePath_WorkingDirectory (const std::string &Path) const |
| Resolves the full path to a resource based on the application's working directory. | |
Private Attributes | |
| ImGuiLayer * | m_ImGuiLayer |
| ImGui layer for rendering GUI elements. | |
| float | m_LastFrameTime = 0.0f |
| Time of the last frame, used for calculating timestep. | |
| LayerStack | m_LayerStack |
| Stack of layers managed by the application. | |
| bool | m_Minimized = false |
| Flag indicating whether the application is minimized. | |
| bool | m_Running = true |
| Flag indicating whether the application is running. | |
| Scope< ApplicationSettings > | m_Settings |
| Scoped pointer to the application settings. | |
| Scope< Window > | m_Window |
| Scoped pointer to the applications underlying window. | |
Static Private Attributes | |
| static Application * | s_Instance = nullptr |
The core application class that manages the main loop, window, layers, and event handling.
Update class to accept ApplicationSettings in constructor and verify its utility/use
Create a dedicated ResourceManager class to handle resource path resolution and management
| Muto::Application::Application | ( | const std::string & | name = "" | ) |
Constructs the Application with the given name.
| name | The name of the application. Defaults to an empty string. |
References Muto::ImGuiLayer::ImGuiLayer(), Muto::Renderer::Init(), InitFileSystem(), Muto::MutoResult::IsSuccess(), m_ImGuiLayer, PushOverlay(), Muto::MutoResult::ResultMessage, and s_Instance.
| Muto::Application::Application | ( | ApplicationSettings | settings | ) |
Constructs the Application with the given settings.
| settings | The settings to configure the application. |
References Muto::ImGuiLayer::ImGuiLayer(), Muto::Renderer::Init(), Muto::MutoResult::IsSuccess(), m_ImGuiLayer, PushOverlay(), Muto::MutoResult::ResultMessage, and s_Instance.
Referenced by SandboxApp::SandboxApp().
|
virtual |
| void Muto::Application::Close | ( | ) |
Closes the application.
References m_Running.
Referenced by Muto::EditorLayer::OnImGuiRender().
|
inlinestatic |
Retrieves the singleton instance of the Application.
References s_Instance.
Referenced by Muto::ImGuiLayer::End(), Muto::Input::GetMousePosition(), Muto::Renderer2D::Init(), Muto::Input::IsKeyPressed(), Muto::Input::IsMouseButtonPressed(), Muto::ImGuiLayer::OnAttach(), Muto::EditorLayer::OnImGuiRender(), and Sandbox2D::OnUpdate().
|
inline |
Retrieves the ImGui layer.
References m_ImGuiLayer.
Referenced by Muto::EditorLayer::OnImGuiRender().
|
inline |
Retrieves the application settings.
|
inline |
Retrieves the application settings as a const reference.
|
inline |
Retrieves the application window.
Referenced by Muto::ImGuiLayer::End(), Muto::Input::GetMousePosition(), Muto::Input::IsKeyPressed(), Muto::Input::IsMouseButtonPressed(), and Sandbox2D::OnUpdate().
|
private |
Initializes the file system for the application.
Ensure working directory exists
Ensure project directory exists
Ensure assets directory exists
Ensure working directory exists
Ensure project directory exists
Ensure assets directory exists
References Muto::FAILURE.
Referenced by Application().
|
private |
Initializes the file system for the application with the given settings.
| Settings | The settings to configure the file system. |
Ensure working directory exists
Ensure project directory exists
Ensure assets directory exists
Ensure working directory exists
Ensure project directory exists
Ensure assets directory exists
References Muto::ApplicationSettings::AssetsDirectory, Muto::FAILURE, Muto::IsAbsolutePath(), Muto::JoinPaths(), Muto::NormalizePath(), Muto::ApplicationSettings::ProjectDirectory, and Muto::ApplicationSettings::WorkingDirectory.
Handles incoming events and dispatches them to the appropriate handlers.
References Muto::EventDispatcher::EventDispatcher(), Muto::Event::Handled, OnWindowClose(), and OnWindowResize().
|
private |
|
private |
Event handler for window resize events.
References Muto::WindowResizeEvent::GetHeight(), Muto::WindowResizeEvent::GetWidth(), m_Minimized, and Muto::Renderer::OnWindowResize().
Referenced by OnEvent().
Adds a layer to the application layer stack.
References Muto::Layer::OnAttach().
Referenced by Muto::Mutare::Mutare(), SandboxApp::SandboxApp(), and SandboxApp::SandboxApp().
Adds an overlay layer to the application layer stack.
References Muto::Layer::OnAttach().
Referenced by Application(), and Application().
| std::string Muto::Application::ResolvePath | ( | const std::string & | Path, |
| PathResolveMode | Mode = PathResolveMode::AssetsDirectory |
||
| ) | const |
Resolves the full path to a resource based on a relative path and the application's settings.
| Path | The path to the resource. |
| Mode | The mode to use for resolving the path. Defaults to PathResolveMode::AssetsDirectory. |
References Muto::AssetsDirectory, Muto::ProjectDirectory, ResolvePath_AssetsDirectory(), ResolvePath_ProjectDirectory(), ResolvePath_WorkingDirectory(), and Muto::WorkingDirectory.
Referenced by Muto::Renderer2D::Init(), and Muto::ImGuiLayer::OnAttach().
|
private |
Resolves the full path to a resource based on the application's assets directory.
| Path | The path to the resource. |
References Muto::IsAbsolutePath(), and Muto::NormalizePath().
Referenced by ResolvePath().
|
private |
Resolves the full path to a resource based on the application's project directory.
| Path | The path to the resource. |
References Muto::IsAbsolutePath(), and Muto::NormalizePath().
Referenced by ResolvePath().
|
private |
Resolves the full path to a resource based on the application's working directory.
| Path | The path to the resource. |
References Muto::IsAbsolutePath(), and Muto::NormalizePath().
Referenced by ResolvePath().
| void Muto::Application::Run | ( | ) |
Starts the main application loop.
Update layers
ImGui render layers
Update window second
Update layers
ImGui render layers
Update window second
References Muto::ImGuiLayer::Begin(), Muto::ImGuiLayer::End(), m_ImGuiLayer, m_LastFrameTime, m_Minimized, and m_Running.
|
private |
ImGui layer for rendering GUI elements.
Referenced by Application(), Application(), GetImGuiLayer(), and Run().
|
private |
Time of the last frame, used for calculating timestep.
Referenced by Run().
|
private |
Stack of layers managed by the application.
Flag indicating whether the application is minimized.
Referenced by OnWindowResize(), and Run().
Flag indicating whether the application is running.
Referenced by Close(), OnWindowClose(), and Run().
|
private |
Scoped pointer to the application settings.
Scoped pointer to the applications underlying window.
|
staticprivate |
Referenced by Application(), Application(), and Get().