Added preprocessor checks for editor

This commit is contained in:
Xiao Qi 2023-02-03 19:37:56 +08:00
parent 7818c6f2d2
commit c9db8262b7
5 changed files with 18 additions and 12 deletions

View File

@ -5,6 +5,7 @@
//#define SHEDITOR //#define SHEDITOR
#ifdef SHEDITOR #ifdef SHEDITOR
#include "Editor/SHEditor.h" #include "Editor/SHEditor.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
//#include "Scenes/SBEditorScene.h" //#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR #endif // SHEDITOR
@ -31,7 +32,6 @@
#include "Input/SHInputManager.h" #include "Input/SHInputManager.h"
#include "Math/Transform/SHTransformSystem.h" #include "Math/Transform/SHTransformSystem.h"
#include "Physics/System/SHPhysicsSystem.h" #include "Physics/System/SHPhysicsSystem.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
#include "Scripting/SHScriptEngine.h" #include "Scripting/SHScriptEngine.h"
#include "UI/SHUISystem.h" #include "UI/SHUISystem.h"
#include "Animation/SHAnimationSystem.h" #include "Animation/SHAnimationSystem.h"
@ -74,12 +74,15 @@ namespace Sandbox
#endif #endif
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData); window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
SHAssetManager::Load();
// Create Systems // Create Systems
SHSystemManager::CreateSystem<SHScriptEngine>(); SHSystemManager::CreateSystem<SHScriptEngine>();
SHSystemManager::CreateSystem<SHTransformSystem>(); SHSystemManager::CreateSystem<SHTransformSystem>();
SHSystemManager::CreateSystem<SHPhysicsSystem>(); SHSystemManager::CreateSystem<SHPhysicsSystem>();
#ifndef _PUBLISH #ifdef SHEDITOR
SHSystemManager::CreateSystem<SHPhysicsDebugDrawSystem>(); SHSystemManager::CreateSystem<SHPhysicsDebugDrawSystem>();
#endif #endif
@ -122,7 +125,7 @@ namespace Sandbox
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsUpdate>(); SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsUpdate>();
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>(); SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>();
#ifndef _PUBLISH #ifdef SHEDITOR
SHSystemManager::RegisterRoutine<SHPhysicsDebugDrawSystem, SHPhysicsDebugDrawSystem::PhysicsDebugDraw>(); SHSystemManager::RegisterRoutine<SHPhysicsDebugDrawSystem, SHPhysicsDebugDrawSystem::PhysicsDebugDraw>();
#endif #endif
@ -155,7 +158,6 @@ namespace Sandbox
SHComponentManager::CreateComponentSparseSet<SHAnimatorComponent>(); SHComponentManager::CreateComponentSparseSet<SHAnimatorComponent>();
//SHComponentManager::CreateComponentSparseSet<SHCameraComponent>(); //SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
SHAssetManager::Load();
//auto font = SHAssetManager::GetData<SHFontAsset>(176667660); //auto font = SHAssetManager::GetData<SHFontAsset>(176667660);
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>(); SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();

View File

@ -94,7 +94,7 @@ namespace SHADE
if (systemContainer.find(id) == systemContainer.end()) if (systemContainer.find(id) == systemContainer.end())
{ {
std::cout << "System Manager error: System Version " << version << " does not exit." << std::endl; std::cout << "System Manager error: System Version " << typeid(T).name() << ", " << version << " does not exist." << std::endl;
return nullptr; return nullptr;
} }

View File

@ -170,10 +170,7 @@ namespace SHADE
SHCollisionListener collisionListener; SHCollisionListener collisionListener;
SHRaycaster raycaster; SHRaycaster raycaster;
// For the debug drawer to draw rays
#ifdef SHEDITOR
std::vector<RaycastHit> raycastHits; std::vector<RaycastHit> raycastHits;
#endif
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Function Members */ /* Function Members */

View File

@ -28,25 +28,32 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
bool Application::IsPlaying::get() bool Application::IsPlaying::get()
{ {
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>(); auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor) if (editor)
return editor->editorState == SHEditor::State::PLAY return editor->editorState == SHEditor::State::PLAY
|| ||
editor->editorState == SHEditor::State::PAUSE; editor->editorState == SHEditor::State::PAUSE;
#endif
return true; return true;
} }
bool Application::IsPaused::get() bool Application::IsPaused::get()
{ {
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>(); auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor) if (editor)
return editor->editorState == SHEditor::State::PAUSE; return editor->editorState == SHEditor::State::PAUSE;
#endif
return false; return false;
} }
bool Application::IsEditor::get() bool Application::IsEditor::get()
{ {
#ifdef SHEDITOR
return SHSystemManager::GetSystem<SHEditor>() != nullptr; return SHSystemManager::GetSystem<SHEditor>() != nullptr;
#else
return false;
#endif
} }
int Application::WindowWidth::get() int Application::WindowWidth::get()
{ {