|
|
@@ -6,12 +6,14 @@
|
|
|
#include <SDL3/SDL.h>
|
|
|
#include <core/StatusCodeOk.hpp>
|
|
|
#include <core/StatusCodeWindowApiLoadingFailed.hpp>
|
|
|
+#include <core/StatusCodeWindowCreationFailed.hpp>
|
|
|
#include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
|
|
|
#include <window/SdlApi.hpp>
|
|
|
#include <window/SdlWindowApi.hpp>
|
|
|
|
|
|
using ls::atlantis::core::StatusCodeOk;
|
|
|
using ls::atlantis::core::StatusCodeWindowApiLoadingFailed;
|
|
|
+using ls::atlantis::core::StatusCodeWindowCreationFailed;
|
|
|
using ls::atlantis::interfaces::AStatusCode;
|
|
|
using ls::atlantis::interfaces::ISdlApi;
|
|
|
using ls::std::core::NullPointerArgumentEvaluator;
|
|
|
@@ -23,7 +25,9 @@ using ::std::shared_ptr;
|
|
|
SdlWindowApi::SdlWindowApi() : SdlWindowApi(make_shared<SdlApi>())
|
|
|
{}
|
|
|
|
|
|
-SdlWindowApi::SdlWindowApi(const shared_ptr<ISdlApi> &_sdlApi) : sdlApi(_sdlApi)
|
|
|
+SdlWindowApi::SdlWindowApi(const shared_ptr<ISdlApi> &_sdlApi)
|
|
|
+ : sdlApi(_sdlApi),
|
|
|
+ window(nullptr, [this](SDL_Window *_window) { this->sdlApi->DestroyWindow(_window); })
|
|
|
{
|
|
|
NullPointerArgumentEvaluator(_sdlApi).evaluate();
|
|
|
}
|
|
|
@@ -35,15 +39,29 @@ SdlWindowApi::~SdlWindowApi()
|
|
|
|
|
|
shared_ptr<AStatusCode> SdlWindowApi::init()
|
|
|
{
|
|
|
- return SdlWindowApi::_initApi();
|
|
|
+ shared_ptr<AStatusCode> statusCode = this->_initApi();
|
|
|
+
|
|
|
+ if (statusCode->getId() == StatusCodeOk{}.getId())
|
|
|
+ {
|
|
|
+ statusCode = this->_createWindow();
|
|
|
+ }
|
|
|
+
|
|
|
+ return statusCode;
|
|
|
}
|
|
|
|
|
|
shared_ptr<AStatusCode> SdlWindowApi::_createWindow()
|
|
|
{
|
|
|
+ window.reset(sdlApi->CreateWindow("", 0, 0, SDL_WINDOW_FULLSCREEN));
|
|
|
+
|
|
|
+ if (window == nullptr)
|
|
|
+ {
|
|
|
+ return make_shared<StatusCodeWindowCreationFailed>();
|
|
|
+ }
|
|
|
+
|
|
|
return make_shared<StatusCodeOk>();
|
|
|
}
|
|
|
|
|
|
-shared_ptr<AStatusCode> SdlWindowApi::_initApi()
|
|
|
+shared_ptr<AStatusCode> SdlWindowApi::_initApi() const
|
|
|
{
|
|
|
shared_ptr<AStatusCode> statusCode = make_shared<StatusCodeOk>();
|
|
|
|