Skip to content

Commit

Permalink
Merge pull request #244 from carboncopies/234-add-new-scene-button
Browse files Browse the repository at this point in the history
234 add new scene button
  • Loading branch information
datacrystals authored Jun 30, 2022
2 parents af6adb0 + c4ce075 commit a4f48bd
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 20 deletions.
1 change: 0 additions & 1 deletion Source/Core/Editor/Menus/GUI_Menu_File/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ target_link_libraries(Menu_File
ERS_STRUCT_Scene

GUI_Window_ProjectSettings
GUI_Window_ShaderEditor

ERS_CLASS_VisualRenderer
)
Expand Down
11 changes: 1 addition & 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 @@ -15,7 +15,6 @@ GUI_Menu_File::GUI_Menu_File(ERS_STRUCT_SystemUtils* SystemUtils, ERS_CLASS_Scen

SceneWriter_ = std::make_unique<SceneWriter>(SystemUtils_);
ImportAsset_ = std::make_unique<GUI_ImportAsset>(SystemUtils_);
ShaderEditor_ = std::make_unique<GUI_Window_ShaderEditor>(SystemUtils_, ProjectUtils_, VisualRenderer_);
GUI_Window_ProjectSettings_ = std::make_unique<GUI_Window_ProjectSettings>(ProjectUtils, SystemUtils);

}
Expand Down Expand Up @@ -45,14 +44,7 @@ void GUI_Menu_File::Draw() {
}
ImGui::Separator();


// Shader Editor
if (ImGui::MenuItem("Shader Editor")) {
ShaderEditor_->Enabled_ = !ShaderEditor_->Enabled_;
}
ImGui::Separator();

// Save Options
// Scene Options
if (ImGui::MenuItem("Save Active Scene")) {
SceneWriter_->ProcessScene(
SceneManager_->Scenes_[SceneManager_->ActiveScene_].get(),
Expand Down Expand Up @@ -83,7 +75,6 @@ void GUI_Menu_File::Draw() {
// Draw Subwindows
ImportAsset_->Draw();
GUI_Window_ProjectSettings_->Draw();
ShaderEditor_->Draw();



Expand Down
2 changes: 0 additions & 2 deletions Source/Core/Editor/Menus/GUI_Menu_File/GUI_Menu_File.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <ERS_SceneManager.h>

#include <GUI_Window_ProjectSettings.h>
#include <GUI_Window_ShaderEditor.h>

#include <ERS_CLASS_VisualRenderer.h>

Expand All @@ -50,7 +49,6 @@ class GUI_Menu_File {
std::unique_ptr<GUI_ImportAsset> ImportAsset_; /**<Pointer To Asset Importer System*/
std::unique_ptr<GUI_Window_ProjectSettings> GUI_Window_ProjectSettings_; /**<Project Settings Window*/
ERS_STRUCT_ProjectUtils* ProjectUtils_; /**<Pointer To Project Utils Instance*/
std::unique_ptr<GUI_Window_ShaderEditor> ShaderEditor_; /**<Pointer To Shader Editor Window Instance*/


public:
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Editor/Menus/GUI_Menu_Window/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ target_link_libraries(Menu_Window
GUI_Window_FramerateCounter
GUI_Window_FramerateHistogram
GUI_Window_FrameratePlot
GUI_Window_ShaderEditor


)

Expand Down
11 changes: 7 additions & 4 deletions Source/Core/Editor/Menus/GUI_Menu_Window/GUI_Menu_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ GUI_Menu_Window::GUI_Menu_Window(ERS_STRUCT_SystemUtils* SystemUtils, ERS_STRUCT
SystemUtils_->Logger_->Log("Editor Setting Up Window Menu", 4);


SystemUtils_->Logger_->Log("Initializing Editor Widgets", 5);
SystemUtils_->Logger_->Log("Initializing Editor Windows", 5);
GUI_Window_ObjectProperties_ = std::make_unique<GUI_Window_ObjectProperties>(Cursors3D, SceneManager, ProjectUtils_);
GUI_Window_RenderingSettings_ = std::make_unique<GUI_Window_RenderingSettings>(SystemUtils_);
GUI_Window_FrameLatencyGraph_ = std::make_unique<GUI_Window_FrameLatencyGraph>(SystemUtils_);
GUI_Window_RAMGraph_ = std::make_unique<GUI_Window_RAMGraph>(SystemUtils_);


SystemUtils_->Logger_->Log("Initializing Editor Windows", 5);
GUI_Window_SceneTree_ = std::make_unique<GUI_Window_SceneTree>(SceneManager, SystemUtils_, ProjectUtils_, Cursors3D);
GUI_Window_SystemLog_ = std::make_unique<GUI_Window_SystemLog>(SystemUtils_);
GUI_Window_AssetExplorer_ = std::make_unique<GUI_Window_AssetExplorer>(SystemUtils_, ProjectUtils_);
GUI_Window_ScriptEditor_ = std::make_unique<GUI_Window_ScriptEditor>(SystemUtils_, ProjectUtils_, VisualRenderer_);
GUI_Window_ShaderEditor_ = std::make_unique<GUI_Window_ShaderEditor>(SystemUtils_, ProjectUtils_, VisualRenderer_);


}

Expand Down Expand Up @@ -102,6 +101,7 @@ void GUI_Menu_Window::Draw() {
}

ImGui::MenuItem("Script Editor", "", &GUI_Window_ScriptEditor_->Enabled_);
ImGui::MenuItem("Shader Editor", "", &GUI_Window_ShaderEditor_->Enabled_);


ImGui::EndMenu();
Expand All @@ -127,5 +127,8 @@ void GUI_Menu_Window::Draw() {
GUI_Window_AssetExplorer_->Draw();
GUI_Window_ScriptEditor_->Draw();

GUI_Window_ShaderEditor_->Draw();



}
5 changes: 5 additions & 0 deletions Source/Core/Editor/Menus/GUI_Menu_Window/GUI_Menu_Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <GUI_Window_FramerateCounter.h>
#include <GUI_Window_FramerateHistogram.h>
#include <GUI_Window_FrameratePlot.h>
#include <GUI_Window_ShaderEditor.h>


#include <ERS_Editor_3DCursor.h>
#include <ERS_SceneManager.h>
Expand Down Expand Up @@ -62,6 +64,9 @@ class GUI_Menu_Window {
std::unique_ptr<GUI_Window_ObjectProperties> GUI_Window_ObjectProperties_; /**<Widget Instance*/
std::unique_ptr<GUI_Window_FrameLatencyGraph> GUI_Window_FrameLatencyGraph_; /**<Widget Instance*/

std::unique_ptr<GUI_Window_ShaderEditor> GUI_Window_ShaderEditor_; /**<Pointer To Shader Editor Window Instance*/


// Instantiate Windows Here
std::unique_ptr<GUI_Window_SceneTree> GUI_Window_SceneTree_; /**<Window Instance*/
std::unique_ptr<GUI_Window_SystemLog> GUI_Window_SystemLog_; /**<Window Instance*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void GUI_Window_ObjectProperties::Draw() {
// Set Initial Window Size
ImGui::SetWindowSize(ImVec2(400,250), ImGuiCond_FirstUseEver);

if (Visible) {

if (Visible && (SceneManager_->Scenes_[SceneManager_->ActiveScene_]->SceneObjects_.size() != 0)) {

// LocRotScale Properties
if (ImGui::CollapsingHeader("Physical Parameters", ImGuiTreeNodeFlags_DefaultOpen)) {
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Manager/ERS_SceneManager/ERS_SceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ ERS_CLASS_SceneManager::~ERS_CLASS_SceneManager() {

void ERS_CLASS_SceneManager::UpdateLocRotScale(glm::vec3 Pos, glm::vec3 Rot, glm::vec3 Scale) {

// If The Scene Has No Models, Exit Early
if (Scenes_[ActiveScene_]->SceneObjects_.size() == 0) {
return;
}

unsigned long SelectedObject = Scenes_[ActiveScene_]->SelectedObject;

if (Scenes_[ActiveScene_]->SceneObjects_[SelectedObject].Type_ == std::string("Model")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,21 @@ void ERS_CLASS_ViewportMenu::AddSpotLight(ERS_CLASS_ShadowMaps* ShadowMaps) {

}

void ERS_CLASS_ViewportMenu::AddScene() {

// Add Scene To List Of Scenes
ERS_STRUCT_Scene NewScene;
NewScene.ScenePath = SystemUtils_->ERS_IOSubsystem_->AllocateAssetID();
NewScene.SceneName = "New Scene";
NewScene.IsSceneLoaded = true;
NewScene.SceneFormatVersion = 1;

ProjectUtils_->ProjectManager_->Project_.SceneIDs.push_back(NewScene.ScenePath);

ProjectUtils_->SceneManager_->AddScene(NewScene);


}


void ERS_CLASS_ViewportMenu::DrawMenu(ERS_STRUCT_Viewport* Viewport, ERS_CLASS_ShadowMaps* ShadowMaps) {
Expand Down Expand Up @@ -346,6 +360,10 @@ void ERS_CLASS_ViewportMenu::DrawMenu(ERS_STRUCT_Viewport* Viewport, ERS_CLASS_S

}

if (ImGui::MenuItem("Scene")) {
AddScene();
}


ImGui::EndMenu();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class ERS_CLASS_ViewportMenu {
void AddPointLight(ERS_CLASS_ShadowMaps* ShadowMaps);
void AddDirectionalLight(ERS_CLASS_ShadowMaps* ShadowMaps);
void AddSpotLight(ERS_CLASS_ShadowMaps* ShadowMaps);
void AddScene();


};
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void ERS_CLASS_VisualRenderer::UpdateViewport(int Index, ERS_CLASS_SceneManager*

// Update Cursor If Selection Changed
ERS_STRUCT_Scene* ActiveScene = SceneManager->Scenes_[SceneManager->ActiveScene_].get();
if (ActiveScene->HasSelectionChanged && DrawCursor) {
if (ActiveScene->HasSelectionChanged && DrawCursor && (ActiveScene->SceneObjects_.size() != 0)) {

// Get Selected Model
int SelectedObject = ActiveScene->SelectedObject;
Expand Down

0 comments on commit a4f48bd

Please sign in to comment.