-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from carboncopies/271-implement-option-to-cre…
…ate-new-project 271 implement option to create new project
- Loading branch information
Showing
63 changed files
with
3,325 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Source/Core/Editor/Windows/GUI_Window_NewProject/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
######################################################################## | ||
# This file is part of the BrainGenix-ERS Environment Rendering System # | ||
######################################################################## | ||
|
||
# Create Library (Name Should Be Parent Dir Name) | ||
add_library(GUI_Window_NewProject | ||
|
||
# Add Source Files (.cpp) | ||
"GUI_Window_NewProject.cpp" | ||
|
||
# Add Header Files (.h) | ||
"GUI_Window_NewProject.h" | ||
|
||
|
||
${BACKWARD_ENABLE} | ||
) | ||
|
||
# Link 3rd Party Libs | ||
target_link_libraries(GUI_Window_NewProject | ||
glad | ||
glfw | ||
IMGUI | ||
ImGuiFileDialog | ||
) | ||
|
||
# Link Internal Libs | ||
target_link_libraries(GUI_Window_NewProject | ||
ERS_STRUCT_SystemUtils | ||
) | ||
|
||
target_include_directories(GUI_Window_NewProject PUBLIC ./) |
95 changes: 95 additions & 0 deletions
95
Source/Core/Editor/Windows/GUI_Window_NewProject/GUI_Window_NewProject.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#include <GUI_Window_NewProject.h> | ||
|
||
|
||
GUI_Window_NewProject::GUI_Window_NewProject(ERS_STRUCT_SystemUtils* SystemUtils) { | ||
|
||
SystemUtils_ = SystemUtils; | ||
SystemUtils_->Logger_->Log("Seting Up New Project Window Dialog", 5); | ||
|
||
} | ||
|
||
|
||
GUI_Window_NewProject::~GUI_Window_NewProject() { | ||
|
||
SystemUtils_->Logger_->Log("New Project Window Dialog Destructor Called", 6); | ||
|
||
} | ||
|
||
|
||
void GUI_Window_NewProject::Draw() { | ||
|
||
if (Enabled_ && !LastWindowState_) { | ||
ImGuiFileDialog::Instance()->OpenDialog("New Project", "New Project", nullptr, "~", "", 0); | ||
|
||
} | ||
|
||
if (Enabled_) { | ||
|
||
// Draw File Dialog | ||
if (ImGuiFileDialog::Instance()->Display("New Project", ImGuiWindowFlags_None, ImVec2(600, 300))) { | ||
|
||
|
||
if (ImGuiFileDialog::Instance()->IsOk()) | ||
{ | ||
|
||
std::string Path = ImGuiFileDialog::Instance()->GetCurrentPath(); | ||
Path += "/"; | ||
SystemUtils_->Logger_->Log(std::string("Creating New Project In Target Directory '") + Path + "'", 5); | ||
|
||
// TodO add system to get project dir from config file, | ||
// then have it iterate over all files, copying them to the new selected path | ||
// finally, have the system load that | ||
// check for bugs and edge-cases | ||
|
||
std::string DefualtProjectPath = "EditorAssets/Projects/NewProject/"; | ||
std::string CurrentExecutablePath = std::filesystem::current_path(); | ||
|
||
for (const auto &Entry : std::filesystem::recursive_directory_iterator(DefualtProjectPath)) { | ||
|
||
// Get The Current Absolute Path To File, As Well As It's Filename | ||
std::string PathRelativeName{Entry.path().u8string()}; | ||
std::string File = CurrentExecutablePath + "/" + PathRelativeName; | ||
std::string FileName = PathRelativeName.substr(PathRelativeName.find_last_of("/"), sizeof(PathRelativeName)); | ||
|
||
SystemUtils_->Logger_->Log(std::string("Copying File '") + File + "' To New Project Directory", 4); | ||
std::filesystem::copy_file(File, Path + FileName); | ||
|
||
} | ||
|
||
|
||
std::string Command; | ||
#if defined(_WIN32) | ||
Command += ""; | ||
#elif defined(__APPLE__) | ||
Command += "./"; | ||
#else | ||
Command += "./"; | ||
#endif | ||
Command += "BrainGenix-ERS -ProjectDirectory "; | ||
Command += '"' + Path + '"' + " &"; | ||
std::system(Command.c_str()); | ||
|
||
// Quit System | ||
SystemUtils_->Logger_->Log("Shutting Down This Editor Window Now, Launching Editor For That Project", 5); | ||
*SystemUtils_->SystemShouldRun_ = false; | ||
|
||
|
||
} | ||
|
||
ImGuiFileDialog::Instance()->Close(); | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
LastWindowState_ = Enabled_; | ||
|
||
|
||
} | ||
|
57 changes: 57 additions & 0 deletions
57
Source/Core/Editor/Windows/GUI_Window_NewProject/GUI_Window_NewProject.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#pragma once | ||
|
||
|
||
// Standard Libraries (BG convention: use <> instead of "") | ||
#include <memory> | ||
#include <iostream> | ||
|
||
// Third-Party Libraries (BG convention: use <> instead of "") | ||
#include <yaml-cpp/yaml.h> | ||
|
||
#include <imgui.h> | ||
|
||
#include <ImGuiFileDialog.h> | ||
|
||
// Internal Libraries (BG convention: use <> instead of "") | ||
#include <ERS_STRUCT_SystemUtils.h> | ||
|
||
|
||
/** | ||
* @brief This class provides the GUI to the import asset option within the file menu. | ||
* | ||
*/ | ||
class GUI_Window_NewProject { | ||
|
||
private: | ||
|
||
ERS_STRUCT_SystemUtils* SystemUtils_; /**<used to get access to system utilites like IOmanager, logger, etc.*/ | ||
bool LastWindowState_ = false; /**<State of the wiundow last frame*/ | ||
|
||
public: | ||
|
||
bool Enabled_ = false; /**<Show/hide the window*/ | ||
|
||
/** | ||
* @brief Construct a new gui importasset object. | ||
* | ||
* @param SystemUtils | ||
*/ | ||
GUI_Window_NewProject(ERS_STRUCT_SystemUtils* SystemUtils); | ||
|
||
/** | ||
* @brief Destroy the gui importasset object. | ||
* | ||
*/ | ||
~GUI_Window_NewProject(); | ||
|
||
/** | ||
* @brief Update Any Windows | ||
* | ||
*/ | ||
void Draw(); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.