diff --git a/WickedEngine/LoadingScreenComponent.cpp b/WickedEngine/LoadingScreenComponent.cpp index c606939a0..e91cc5a26 100644 --- a/WickedEngine/LoadingScreenComponent.cpp +++ b/WickedEngine/LoadingScreenComponent.cpp @@ -1,5 +1,5 @@ #include "LoadingScreenComponent.h" - +#include "MainComponent.h" LoadingScreenComponent::LoadingScreenComponent() { @@ -33,9 +33,14 @@ void LoadingScreenComponent::addLoadingFunction(function loadingFunction } } -void LoadingScreenComponent::addLoadingComponent(RenderableComponent* component) +void LoadingScreenComponent::addLoadingComponent(RenderableComponent* component, MainComponent* main) { - //TODO + addLoadingFunction([=] { + component->Load(); + }); + onFinished([=] { + main->activateComponent(component); + }); //addLoadingFunction(bind(&RenderableComponent::Load, this, component)); //onFinished(bind(&RenderableComponent::Start, this, component)); } @@ -90,8 +95,7 @@ int LoadingScreenComponent::getPercentageComplete() void LoadingScreenComponent::Unload() { - loaders.clear(); - finish = nullptr; + Renderable2DComponent::Unload(); } void LoadingScreenComponent::Start() @@ -102,3 +106,11 @@ void LoadingScreenComponent::Start() Renderable2DComponent::Start(); } +void LoadingScreenComponent::Stop() +{ + loaders.clear(); + finish = nullptr; + + Renderable2DComponent::Stop(); +} + diff --git a/WickedEngine/LoadingScreenComponent.h b/WickedEngine/LoadingScreenComponent.h index 04264c411..64332813a 100644 --- a/WickedEngine/LoadingScreenComponent.h +++ b/WickedEngine/LoadingScreenComponent.h @@ -2,6 +2,8 @@ #include "Renderable2DComponent.h" #include +class MainComponent; + class LoadingScreenComponent : public Renderable2DComponent { @@ -35,7 +37,7 @@ public: //use std::bind( YourFunctionPointer ) void addLoadingFunction(function loadingFunction); //Helper for loading a whole renderable component - void addLoadingComponent(RenderableComponent* component); + void addLoadingComponent(RenderableComponent* component, MainComponent* main); //Set a function that should be called when the loading finishes //use std::bind( YourFunctionPointer ) void onFinished(function finishFunction); @@ -45,8 +47,10 @@ public: bool isActive(); //Start Executing the tasks and mark the loading as active - virtual void Start(); - //Remove all tasks - virtual void Unload(); + virtual void Start() override; + //Clear all tasks + virtual void Stop() override; + + virtual void Unload() override; }; diff --git a/WickedEngine/MainComponent.cpp b/WickedEngine/MainComponent.cpp index 70b9976df..3cd51f887 100644 --- a/WickedEngine/MainComponent.cpp +++ b/WickedEngine/MainComponent.cpp @@ -33,7 +33,10 @@ MainComponent::MainComponent() MainComponent::~MainComponent() { - activeComponent->Unload(); + if (activeComponent != nullptr) + { + activeComponent->Unload(); + } } void MainComponent::Initialize() diff --git a/WickedEngine/RenderableComponent.h b/WickedEngine/RenderableComponent.h index f2e2abc68..e75e14d35 100644 --- a/WickedEngine/RenderableComponent.h +++ b/WickedEngine/RenderableComponent.h @@ -15,7 +15,7 @@ public: function onStop; RenderableComponent(){} - ~RenderableComponent(){} + virtual ~RenderableComponent() { Unload(); } // initialize component virtual void Initialize() {} diff --git a/WickedEngine/wiLoader.h b/WickedEngine/wiLoader.h index 7a0180cfc..791235078 100644 --- a/WickedEngine/wiLoader.h +++ b/WickedEngine/wiLoader.h @@ -793,6 +793,7 @@ struct Camera:public Transform{ XMFLOAT3 At, Up; float width, height; float zNearP, zFarP; + float fov; Frustum frustum; Camera():Transform(){ @@ -804,7 +805,7 @@ struct Camera:public Transform{ rotation_rest=newRot; name=newName; } - void SetUp(int newWidth, int newHeight, float newNear, float newFar) + void SetUp(int newWidth, int newHeight, float newNear, float newFar, float fov = XM_PI / 3.0f) { XMMATRIX View = XMMATRIX(); XMVECTOR At = XMVectorSet(0,0,1,0), Up = XMVectorSet(0,1,0,0), Eye = this->GetEye(); @@ -815,6 +816,8 @@ struct Camera:public Transform{ width = (float)newWidth; height = (float)newHeight; + this->fov = fov; + UpdateProjection(); XMStoreFloat4x4(&this->View, View); @@ -877,7 +880,7 @@ struct Camera:public Transform{ } void UpdateProjection() { - XMStoreFloat4x4(&this->Projection, XMMatrixPerspectiveFovLH(XM_PI / 3.0f, (float)width / (float)height, zNearP, zFarP)); + XMStoreFloat4x4(&this->Projection, XMMatrixPerspectiveFovLH(fov, (float)width / (float)height, zNearP, zFarP)); } XMVECTOR GetEye() diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 918c96670..d81f0940f 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -7,7 +7,7 @@ namespace wiVersion // minor features, major bug fixes const int minor = 8; // minor bug fixes, alterations, refactors - const int revision = 8; + const int revision = 4; long GetVersion()