diff --git a/Hazel/src/Hazel/Core/Application.cpp b/Hazel/src/Hazel/Core/Application.cpp index ad6c847..36c09be 100644 --- a/Hazel/src/Hazel/Core/Application.cpp +++ b/Hazel/src/Hazel/Core/Application.cpp @@ -1,6 +1,7 @@ #include "Hazel/Core/Application.h" +#include #include #include #include @@ -14,17 +15,19 @@ namespace Hazel { Application* Application::s_Instance = nullptr; - Application::Application(const std::string& name, int width, int height) + Application::Application(const ApplicationSpecification& specification) + : m_Specification(specification) { HZ_PROFILE_FUNCTION(); if (s_Instance != nullptr) - { HZ_CORE_ERROR("Application already exists!"); - } s_Instance = this; - m_Window = Window::Create(WindowProps(name, width, height)); + if (!m_Specification.workingDirectory.empty()) + std::filesystem::current_path(m_Specification.workingDirectory); + + m_Window = Window::Create(WindowProps(m_Specification.name)); m_Window->SetEventCallback(std::bind(&Application::OnEvent, this, std::placeholders::_1)); m_Window->SetWindowResizeEventCallback(std::bind(&Application::OnWindowResize, this, std::placeholders::_1)); diff --git a/Hazel/src/Hazel/Core/Application.h b/Hazel/src/Hazel/Core/Application.h index 0a7e514..6b0c9a2 100644 --- a/Hazel/src/Hazel/Core/Application.h +++ b/Hazel/src/Hazel/Core/Application.h @@ -5,15 +5,37 @@ #include "Core.h" #include "Layer.h" #include "LayerStack.h" +#include "Log.h" #include "Hazel/Core/TimeStep.h" #include "Hazel/ImGui/ImGuiLayer.h" namespace Hazel { + struct ApplicationCommandLineArgs + { + int count = 0; + char** args = nullptr; + + const char* operator[](int index) + { + if (index >= count) + HZ_CORE_ERROR("args error"); + return args[count]; + } + }; + + struct ApplicationSpecification + { + std::string name = "Application"; + std::string workingDirectory; + ApplicationCommandLineArgs commandLineArgs; + + }; + class HAZEL_API Application { public: - Application(const std::string& name = "Hazel App", int width = 1280, int height = 720); + Application(const ApplicationSpecification& specification); virtual ~Application(); void Run(); @@ -30,7 +52,10 @@ namespace Hazel { inline Window& GetWindow() const { return *m_Window; } inline static Application& Get() { return *s_Instance; } + const ApplicationSpecification& GetSpecification() const { return m_Specification; } + private: + ApplicationSpecification m_Specification; Scope m_Window; ImGuiLayer* m_imguiLayer; bool m_Running = true; @@ -46,6 +71,6 @@ namespace Hazel { }; // to be defined int CLIENT - Application* CreateApplication(); + Application* CreateApplication(ApplicationCommandLineArgs args); }