Skip to content

Commit

Permalink
Merge pull request #366 from carboncopies/316-import-progressbar-not-…
Browse files Browse the repository at this point in the history
…appearing

316 import progressbar not appearing
  • Loading branch information
datacrystals authored Sep 4, 2022
2 parents 42b69e8 + 5183374 commit 7c0c4de
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursor
Windows_->GUI_Window_FramerateHistogram_ = std::make_unique<GUI_Window_FramerateHistogram> ();
Windows_->GUI_Window_FrameratePlot_ = std::make_unique<GUI_Window_FrameratePlot> ();
Windows_->GUI_Window_ImportProgressBar_ = std::make_unique<GUI_Window_ImportProgressBar> (SystemUtils_);
Windows_->GUI_Window_ObjectProperties_ = std::make_unique<GUI_Window_ObjectProperties> (Gizmo, SceneManager, ProjectUtils, VisualRenderer);
Windows_->GUI_Window_ObjectProperties_ = std::make_unique<GUI_Window_ObjectProperties> (Gizmo, SceneManager, ProjectUtils, VisualRenderer);
Windows_->GUI_Window_ProjectSettings_ = std::make_unique<GUI_Window_ProjectSettings> (ProjectUtils, SystemUtils_);
Windows_->GUI_Window_RAMGraph_ = std::make_unique<GUI_Window_RAMGraph> (SystemUtils_);
Windows_->GUI_Window_RenderingSettings_ = std::make_unique<GUI_Window_RenderingSettings> (SystemUtils_);
Expand All @@ -59,8 +59,8 @@ ERS_CLASS_ThemeManager* ThemeManager, ERS_CLASS_FontManager* FontManager, Cursor
Windows_->GUI_Window_OpenProject_ = std::make_unique<GUI_Window_OpenProject> (SystemUtils_);
Windows_->GUI_Window_NewProject_ = std::make_unique<GUI_Window_NewProject> (SystemUtils_);
Windows_->GUI_Window_AssetStreamingSettings_ = std::make_unique<GUI_Window_AssetStreamingSettings> (SystemUtils_, ProjectUtils);
Windows_->GUI_Window_ImportModel_ = std::make_unique<GUI_Window_ImportModel> (SystemUtils_, ProjectUtils);
Windows_->GUI_Window_ImportModelDirectory_ = std::make_unique<GUI_Window_ImportModelDirectory> (SystemUtils_, ProjectUtils);
Windows_->GUI_Window_ImportModel_ = std::make_unique<GUI_Window_ImportModel> (SystemUtils_, ProjectUtils, Windows_->GUI_Window_ImportProgressBar_.get());
Windows_->GUI_Window_ImportModelDirectory_ = std::make_unique<GUI_Window_ImportModelDirectory> (SystemUtils_, ProjectUtils, Windows_->GUI_Window_ImportProgressBar_.get());


SystemUtils_->Logger_->Log("WindowManager Subsystem Finished Setting Up Window Struct", 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <GUI_Window_ImportModel.h>


GUI_Window_ImportModel::GUI_Window_ImportModel(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils) {
GUI_Window_ImportModel::GUI_Window_ImportModel(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils, GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar) {

SystemUtils_ = SystemUtils;
ProjectUtils_ = ProjectUtils;
SystemUtils_->Logger_->Log("Initializing Asset Importer GUI", 5);

GUI_Window_ImportProgressBar_ = std::make_unique<GUI_Window_ImportProgressBar>(SystemUtils_);
GUI_Window_ImportProgressBar_ = GUI_Window_ImportProgressBar;

}

Expand Down Expand Up @@ -44,7 +44,6 @@ void GUI_Window_ImportModel::Draw() {
if (Enabled_ && !AlreadyOpen_) {
OpenFileDialog();
AlreadyOpen_ = true;
GUI_Window_ImportProgressBar_->Enabled_ = true;
}

// Draw File Dialog
Expand Down Expand Up @@ -72,6 +71,7 @@ void GUI_Window_ImportModel::Draw() {
// Add To Queue, Launch Import
ProjectUtils_->ModelImporter_->AddToImportQueue(FilePaths, FlipTextures);
GUI_Window_ImportProgressBar_->Enabled_ = true;
Working_ = true;

}

Expand All @@ -82,9 +82,12 @@ void GUI_Window_ImportModel::Draw() {


// Update Window Stats
if (GUI_Window_ImportProgressBar_->Enabled_ && Enabled_) {
if (GUI_Window_ImportProgressBar_->Enabled_ && Working_) {
GUI_Window_ImportProgressBar_->UpdateTotalItems(ProjectUtils_->ModelImporter_->GetTotalItemsImported(), ProjectUtils_->ModelImporter_->GetTotalItemsToImport());
GUI_Window_ImportProgressBar_->UpdateJobState(ProjectUtils_->ModelImporter_->HasJobFinished());

Working_ = !ProjectUtils_->ModelImporter_->HasJobFinished();
GUI_Window_ImportProgressBar_->UpdateJobState(!Working_);

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class GUI_Window_ImportModel {

ERS_STRUCT_SystemUtils* SystemUtils_; /**<used to get access to system utilites like IOmanager, logger, etc.*/
ERS_STRUCT_ProjectUtils* ProjectUtils_; /**<Project utils struct used to get to the model importer class*/
std::unique_ptr<GUI_Window_ImportProgressBar> GUI_Window_ImportProgressBar_; /**<Pointer To Window Import Progres Bar*/
GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar_; /**<Pointer To Window Import Progres Bar*/
bool AlreadyOpen_ = false; /**<Keeps track of internal window state*/
bool Working_ = false; /**<Indicates if something is being imported*/

ERS_STRUCT_ModelImportOptions Options_; /**<Import Options For The Model*/

Expand All @@ -52,7 +53,7 @@ class GUI_Window_ImportModel {
*
* @param SystemUtils
*/
GUI_Window_ImportModel(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils);
GUI_Window_ImportModel(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils, GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar);

/**
* @brief Destroy the gui importasset object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <GUI_Window_ImportModelDirectory.h>


GUI_Window_ImportModelDirectory::GUI_Window_ImportModelDirectory(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils) {
GUI_Window_ImportModelDirectory::GUI_Window_ImportModelDirectory(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils, GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar) {

SystemUtils_ = SystemUtils;
ProjectUtils_ = ProjectUtils;
SystemUtils_->Logger_->Log("Initializing Asset Importer GUI", 5);

GUI_Window_ImportProgressBar_ = std::make_unique<GUI_Window_ImportProgressBar>(SystemUtils_);
GUI_Window_ImportProgressBar_ = GUI_Window_ImportProgressBar;

}

Expand Down Expand Up @@ -50,7 +50,6 @@ void GUI_Window_ImportModelDirectory::Draw() {
if (Enabled_ && !AlreadyOpen_) {
OpenFileDialog();
AlreadyOpen_ = true;
GUI_Window_ImportProgressBar_->Enabled_ = true;
}

// Draw File Dialog
Expand Down Expand Up @@ -83,6 +82,7 @@ void GUI_Window_ImportModelDirectory::Draw() {
// Add To Queue, Launch Import
ProjectUtils_->ModelImporter_->AddToImportQueue(FilePaths, FlipTextures);
GUI_Window_ImportProgressBar_->Enabled_ = true;
Working_ = true;

}

Expand All @@ -93,9 +93,12 @@ void GUI_Window_ImportModelDirectory::Draw() {


// Update Window Stats
if (GUI_Window_ImportProgressBar_->Enabled_ && Enabled_) {
if (GUI_Window_ImportProgressBar_->Enabled_ && Working_) {
GUI_Window_ImportProgressBar_->UpdateTotalItems(ProjectUtils_->ModelImporter_->GetTotalItemsImported(), ProjectUtils_->ModelImporter_->GetTotalItemsToImport());
GUI_Window_ImportProgressBar_->UpdateJobState(ProjectUtils_->ModelImporter_->HasJobFinished());

Working_ = !ProjectUtils_->ModelImporter_->HasJobFinished();
GUI_Window_ImportProgressBar_->UpdateJobState(!Working_);

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class GUI_Window_ImportModelDirectory {

ERS_STRUCT_SystemUtils* SystemUtils_; /**<used to get access to system utilites like IOmanager, logger, etc.*/
ERS_STRUCT_ProjectUtils* ProjectUtils_; /**<Project utils struct used to get to the model importer class*/
std::unique_ptr<GUI_Window_ImportProgressBar> GUI_Window_ImportProgressBar_; /**<Pointer To Window Import Progres Bar*/
GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar_; /**<Pointer To Window Import Progres Bar*/
bool AlreadyOpen_ = false; /**<Keeps track of internal window state*/
bool Working_ = false; /**<Indicates if something is being imported*/

ERS_STRUCT_ModelImportOptions Options_; /**<Import Options For The Model*/

Expand All @@ -54,7 +55,7 @@ class GUI_Window_ImportModelDirectory {
*
* @param SystemUtils
*/
GUI_Window_ImportModelDirectory(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils);
GUI_Window_ImportModelDirectory(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT_ProjectUtils* ProjectUtils, GUI_Window_ImportProgressBar* GUI_Window_ImportProgressBar);

/**
* @brief Destroy the gui importasset object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ void GUI_Window_ImportProgressBar::UpdateJobState(bool JobFinished) {
IsJobFinishing_ = false;
}

// Hide Window After Threshold Reached
if (ConsecFinished_ >= ConsecFinishedThreshold_) {
Enabled_ = false;
ConsecFinished_ = 0;
}


}

Expand Down Expand Up @@ -78,6 +74,15 @@ void GUI_Window_ImportProgressBar::Draw() {
}

ImGui::End();

// Hide Window After Threshold Reached
ConsecFinished_++;
if (ConsecFinished_ >= ConsecFinishedThreshold_) {
Enabled_ = false;
ConsecFinished_ = 0;
}


}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void ERS_CLASS_ModelImporter::AddToImportQueue(std::vector<std::string> AssetPat

SystemUtils_->Logger_->Log("Appending Assets To Asset Import Queue", 5);
LockAssetImportQueue_.lock();

HasJobFinished_ = false;
for (int i = 0; (long)i < (long)AssetPaths.size(); i++) {

std::string LogStr = std::string("Appending Asset: '") + AssetPaths[i] + std::string("' To Import Queue");
Expand Down

0 comments on commit 7c0c4de

Please sign in to comment.