Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

271 implement option to create new project #272

Merged
merged 60 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
26d8f19
Implement Option To Create New Project (#271(
datacrystals Jul 6, 2022
54b58c1
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
38fb5a3
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
e25e41d
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
97c76b7
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
fa374c9
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
6ed2587
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
0153dd1
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
abeb191
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
3117ddf
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
7d8cc1f
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
66c9b5b
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
dab5852
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
aaf2b87
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
6430333
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
01a6533
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
a5fccdf
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
028b67d
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
193b78b
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
ef1ee38
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
06656c3
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
4a6a682
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
a47824e
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
3d2e158
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
0bbffa8
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
a6c99df
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
318d1d6
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
caebc0f
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
2ec6cd3
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
80b1a97
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
0336c63
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
13ad52d
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
d16cad9
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
352133e
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
2f0da31
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
9151602
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
ae925b9
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
21d8314
Implement Option To Create New Project (#271)
datacrystals Jul 6, 2022
35a329a
Fix Broken FilePath
datacrystals Jul 15, 2022
8d713fe
Fix Broken FilePath
datacrystals Jul 15, 2022
b1d4279
Fix Broken FilePath
datacrystals Jul 15, 2022
c2970e3
Fix Broken FilePath
datacrystals Jul 15, 2022
8f98d2e
Fix Issues Caused By No Scene Existing In Project File
datacrystals Jul 15, 2022
bc8965a
Fix Issues Caused By No Scene Existing In Project File
datacrystals Jul 15, 2022
6264317
Debug OpenGL Errors
datacrystals Jul 15, 2022
55ecf00
Debug OpenGL Errors
datacrystals Jul 15, 2022
5e7c749
Debug OpenGL Errors
datacrystals Jul 15, 2022
669c667
Debug OpenGL Errors
datacrystals Jul 15, 2022
7d0a03b
Debug OpenGL Errors
datacrystals Jul 15, 2022
2e0d9a1
Debug OpenGL Errors
datacrystals Jul 15, 2022
54eb264
Debug OpenGL Errors
datacrystals Jul 15, 2022
b41919a
Debug OpenGL Errors
datacrystals Jul 15, 2022
307fe8f
Debug OpenGL Errors
datacrystals Jul 15, 2022
bfb3364
Debug OpenGL Errors
datacrystals Jul 15, 2022
b206fcb
Debug OpenGL Errors
datacrystals Jul 15, 2022
efa0fc8
Debug OpenGL Errors
datacrystals Jul 15, 2022
92cfa91
Debug OpenGL Errors
datacrystals Jul 15, 2022
c20c0ce
Debug OpenGL Errors
datacrystals Jul 15, 2022
9ee8b44
Debug OpenGL Errors
datacrystals Jul 15, 2022
16abebc
Debug OpenGL Errors
datacrystals Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Source/Core/Editor/Menus/GUI_Menu_File/GUI_Menu_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,12 @@ void GUI_Menu_File::Draw() {
// File Menu
if (ImGui::BeginMenu("File")) {

ImGui::MenuItem("New", "", &Windows_->GUI_Window_NewProject_->Enabled_);
ImGui::MenuItem("Open", "", &Windows_->GUI_Window_OpenProject_->Enabled_);
ImGui::Separator();

ImGui::MenuItem("About", "", &Windows_->GUI_Window_About_->Enabled_);
ImGui::Separator();

ImGui::MenuItem("Project Settings", "", &Windows_->GUI_Window_ProjectSettings_->Enabled_);
ImGui::Separator();

if (ImGui::MenuItem("Import Model")) {
ImportAsset_->OpenFileDialog();
}
ImGui::Separator();

// Save All
if (ImGui::MenuItem("Save")) {

SystemUtils_->Logger_->Log("Saving Project Data", 4);
Expand All @@ -61,6 +52,13 @@ void GUI_Menu_File::Draw() {
}
}

ImGui::MenuItem("Project Settings", "", &Windows_->GUI_Window_ProjectSettings_->Enabled_);
ImGui::MenuItem("About", "", &Windows_->GUI_Window_About_->Enabled_);
ImGui::Separator();

if (ImGui::MenuItem("Import Model")) {
ImportAsset_->OpenFileDialog();
}
ImGui::Separator();

// Exit Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ target_link_libraries(ERS_Editor_WindowManager
GUI_Window_ThemeSelector
GUI_Window_FontSelector
GUI_Window_OpenProject
GUI_Window_NewProject

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursor
Windows_->GUI_Window_TestEditor_ = std::make_unique<GUI_Window_TestEditor>(SystemUtils_);
Windows_->GUI_Window_ThemeSelector_ = std::make_unique<GUI_Window_ThemeSelector>(ThemeManager);
Windows_->GUI_Window_FontSelector_ = std::make_unique<GUI_Window_FontSelector>(FontManager);
Windows_->GUI_Window_OpenProject_ = std::make_unique<GUI_Window_OpenProject>(SystemUtils_);
Windows_->GUI_Window_OpenProject_ = std::make_unique<GUI_Window_OpenProject>(SystemUtils_);
Windows_->GUI_Window_NewProject_ = std::make_unique<GUI_Window_NewProject>(SystemUtils_);

SystemUtils_->Logger_->Log("WindowManager Subsystem Finished Setting Up Window Struct", 3);
SystemUtils_->Logger_->Log("WindowManager Subsystem Setting Up Window Index", 4);
Expand All @@ -81,6 +82,7 @@ ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursor
WindowNames_.push_back("ThemeSelector");
WindowNames_.push_back("FontSelector");
WindowNames_.push_back("OpenProject");
WindowNames_.push_back("NewProject");

SystemUtils_->Logger_->Log("WindowManager Subsystem Finished Setting Up Window Index", 3);

Expand Down Expand Up @@ -113,6 +115,7 @@ void ERS_CLASS_WindowManager::UpdateAllWindows() {
Windows_->GUI_Window_ThemeSelector_->Draw();
Windows_->GUI_Window_FontSelector_->Draw();
Windows_->GUI_Window_OpenProject_->Draw();
Windows_->GUI_Window_NewProject_->Draw();

}

Expand Down Expand Up @@ -183,6 +186,9 @@ bool ERS_CLASS_WindowManager::SetWindowStatus(std::string WindowName, bool Statu
} else if (WindowName == "OpenProject") {
Windows_->GUI_Window_OpenProject_->Enabled_ = Status;
return true;
} else if (WindowName == "NewProject") {
Windows_->GUI_Window_NewProject_->Enabled_ = Status;
return true;
} else {
return false;
}
Expand Down Expand Up @@ -256,6 +262,9 @@ bool ERS_CLASS_WindowManager::GetWindowStatus(std::string WindowName, bool* Stat
} else if (WindowName == "OpenProject") {
*Status = Windows_->GUI_Window_OpenProject_->Enabled_;
return true;
} else if (WindowName == "NewProject") {
*Status = Windows_->GUI_Window_NewProject_->Enabled_;
return true;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <GUI_Window_ThemeSelector.h>
#include <GUI_Window_FontSelector.h>
#include <GUI_Window_OpenProject.h>
#include <GUI_Window_NewProject.h>



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <GUI_Window_ThemeSelector.h>
#include <GUI_Window_FontSelector.h>
#include <GUI_Window_OpenProject.h>
#include <GUI_Window_NewProject.h>

/**
* @brief This structure holds unique pointers to all windows that are instantiated by the GUI.
Expand Down Expand Up @@ -61,6 +62,7 @@ struct ERS_STRUCT_Windows {
std::unique_ptr<GUI_Window_ThemeSelector> GUI_Window_ThemeSelector_;
std::unique_ptr<GUI_Window_FontSelector> GUI_Window_FontSelector_;
std::unique_ptr<GUI_Window_OpenProject> GUI_Window_OpenProject_;
std::unique_ptr<GUI_Window_NewProject> GUI_Window_NewProject_;


};
1 change: 1 addition & 0 deletions Source/Core/Editor/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ShaderEditor)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ScriptEditor)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_OpenProject)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_NewProject)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_ThemeSelector)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/GUI_Window_FontSelector)
Expand Down
31 changes: 31 additions & 0 deletions Source/Core/Editor/Windows/GUI_Window_NewProject/CMakeLists.txt
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 ./)
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_;


}

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();

};
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ GUI_Window_OpenProject::~GUI_Window_OpenProject() {
void GUI_Window_OpenProject::Draw() {

if (Enabled_ && !LastWindowState_) {
ImGuiFileDialog::Instance()->OpenDialog("Open Project", "Open Project", ".ERS", ".", "", 0);
ImGuiFileDialog::Instance()->OpenDialog("Open Project", "Open Project", nullptr, "~", "", 0);
}

if (Enabled_) {

// Draw File Dialog
if (ImGuiFileDialog::Instance()->Display("Open Project", ImGuiWindowFlags_None, ImVec2(400, 200))) {
if (ImGuiFileDialog::Instance()->Display("Open Project", ImGuiWindowFlags_None, ImVec2(600, 300))) {


if (ImGuiFileDialog::Instance()->IsOk())
Expand Down
27 changes: 22 additions & 5 deletions Source/Core/Manager/ERS_ProjectManager/ERS_ProjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,29 @@ void ERS_CLASS_ProjectManager::LoadProject(long AssetID) {
Project_.ControllerSettings->push_back(Settings);
}

// Load Default Scene
SystemUtils_->Logger_->Log(std::string(std::string("Loading Project Default Scene With ID ") + std::to_string(Project_.SceneIDs[Project_.DefaultScene])).c_str(), 5);
for (unsigned int i = 0; i < Project_.SceneIDs.size(); i++) {
SceneManager_->AddScene(SceneLoader_->ProcessScene(Project_.SceneIDs[i]));
// Handle The Defaut Scene
if (Project_.SceneIDs.size() > 0) {

// Load Default Scene If Applicable
SystemUtils_->Logger_->Log(std::string(std::string("Loading Project Default Scene With ID ") + std::to_string(Project_.SceneIDs[Project_.DefaultScene])).c_str(), 5);
for (unsigned int i = 0; i < Project_.SceneIDs.size(); i++) {
SceneManager_->AddScene(SceneLoader_->ProcessScene(Project_.SceneIDs[i]));
}
SceneManager_->SetActiveScene(Project_.DefaultScene);

} else {

// Create Blank Scene For The System
ERS_STRUCT_Scene NewScene;
NewScene.ScenePath = SystemUtils_->ERS_IOSubsystem_->AllocateAssetID();
NewScene.SceneName = "Untitled Scene";
NewScene.IsSceneLoaded = true;
NewScene.SceneFormatVersion = 1;

Project_.SceneIDs.push_back(NewScene.ScenePath);
SceneManager_->AddScene(NewScene);

}
SceneManager_->SetActiveScene(Project_.DefaultScene);

}

Expand Down
Loading