diff --git a/SpecProject/CMakeLists.txt b/SpecProject/CMakeLists.txt index 13851d0..293b61e 100644 --- a/SpecProject/CMakeLists.txt +++ b/SpecProject/CMakeLists.txt @@ -46,4 +46,5 @@ endif() set_target_properties(SpecProject PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SPECTER_BINARY_DIR}) -add_custom_command(TARGET SpecProject POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Assets ${SPECTER_BINARY_DIR}/Assets) +#No longer needed, but maybe come back if I don't like the programatic solution +#add_custom_command(TARGET SpecProject POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Assets ${SPECTER_BINARY_DIR}/Assets) diff --git a/SpecProject/src/main.cpp b/SpecProject/src/main.cpp index e32607b..dfd9000 100644 --- a/SpecProject/src/main.cpp +++ b/SpecProject/src/main.cpp @@ -7,13 +7,14 @@ #include "Specter.h" #include "SPSAnalysisStage.h" #include "SPSInputLayer.h" +#include //User application class. Pushes user analysis stages. class SPSApp : public Specter::Application { public: - SPSApp() : - Specter::Application() + SPSApp(const Specter::ApplicationArgs& args) : + Specter::Application(args) { PushLayer(new Specter::SPSInputLayer()); //PushLayer(new Navigator::TestServerLayer()); @@ -22,7 +23,7 @@ public: }; //Define the creation function to make our user application -Specter::Application* Specter::CreateApplication() { return new SPSApp(); } +Specter::Application* Specter::CreateApplication(const ApplicationArgs& args) { return new SPSApp(args); } //Make sure to initialize log BEFORE creating application. int main(int argc, const char** argv) @@ -30,8 +31,15 @@ int main(int argc, const char** argv) Specter::Logger::Init(); SPEC_TRACE("Logger Initialized!"); + Specter::ApplicationArgs args; + args.name = "SPS Specter"; + if (std::filesystem::current_path().string().find("SpecProject") != std::string::npos) + args.runtimePath = ""; //Dont modify runtime path, already points to SpecProject + else + args.runtimePath = "../SpecProject"; //Assume we're attempting to run from bin dir? Technically would also work for any new subproject made by same method as SpecProject + SPEC_PROFILE_BEGIN_SESSION("Startup", "navprofile_startup.json"); - auto app = Specter::CreateApplication(); + auto app = Specter::CreateApplication(args); SPEC_PROFILE_END_SESSION(); SPEC_PROFILE_BEGIN_SESSION("Runtime", "navprofile_runtime.json"); diff --git a/Specter/src/Specter/Core/Application.cpp b/Specter/src/Specter/Core/Application.cpp index a549cf8..f58d8de 100644 --- a/Specter/src/Specter/Core/Application.cpp +++ b/Specter/src/Specter/Core/Application.cpp @@ -18,14 +18,20 @@ namespace Specter { Application* Application::s_instance = nullptr; - Application::Application() : - m_runFlag(true) + Application::Application(const ApplicationArgs& args) : + m_args(args), m_runFlag(true) { SPEC_PROFILE_FUNCTION(); s_instance = this; - m_window = std::unique_ptr(Window::Create()); + //Set the runtime path so that we can find our assets + if(!m_args.runtimePath.empty()) + std::filesystem::current_path(m_args.runtimePath); + + SPEC_INFO("Runtime Directory: {0}", std::filesystem::current_path().string()); + + m_window = std::unique_ptr(Window::Create({m_args.name, 1280, 720})); m_window->SetEventCallback(BIND_EVENT_FUNCTION(Application::OnEvent)); //Allow window to pass events back m_physicsLayer = new PhysicsLayer(); diff --git a/Specter/src/Specter/Core/Application.h b/Specter/src/Specter/Core/Application.h index f512b29..540b485 100644 --- a/Specter/src/Specter/Core/Application.h +++ b/Specter/src/Specter/Core/Application.h @@ -24,10 +24,16 @@ namespace Specter { + struct ApplicationArgs + { + std::string name = ""; + std::string runtimePath = ""; + }; + class Application { public: - Application(); + Application(const ApplicationArgs& args); virtual ~Application(); void Run(); @@ -42,9 +48,13 @@ namespace Specter { inline Window& GetWindow() { return *m_window; } + inline const ApplicationArgs& GetArgs() { return m_args; } + private: bool OnWindowCloseEvent(WindowCloseEvent& event); + ApplicationArgs m_args; + LayerStack m_stack; std::unique_ptr m_window; ImGuiLayer* m_imgui_layer; @@ -62,7 +72,7 @@ namespace Specter { This function is left to be defined by the user. In principle we don't need to do this, as the Specter library doesn't handle creation of the application, but I like it and might be useful for changing to a system with a pre-defined entry point. */ - Application* CreateApplication(); + Application* CreateApplication(const ApplicationArgs& args); } #endif \ No newline at end of file diff --git a/Specter/src/Specter/Core/SpectrumSerializer.cpp b/Specter/src/Specter/Core/SpectrumSerializer.cpp index 6f7949c..7ffbe4f 100644 --- a/Specter/src/Specter/Core/SpectrumSerializer.cpp +++ b/Specter/src/Specter/Core/SpectrumSerializer.cpp @@ -1,6 +1,6 @@ /* SpectrumSerializer.h - SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .nav file. These are formated text files. + SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .spec file. These are formated text files. Note that by virtue of the way that cuts work, they are written first. A couple of notes: