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

View File

@ -94,7 +94,7 @@ namespace SHADE
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;
}

View File

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

View File

@ -62,9 +62,9 @@ namespace SHADE
loadFunctions();
// Generate script assembly if it hasn't been before
#ifndef _PUBLISH
#ifndef _PUBLISH
BuildScriptAssembly();
#endif
#endif
// Initialise the CSharp Engine
csEngineInit();

View File

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