Refactored code
This commit is contained in:
parent
27484eef8b
commit
a9b0394d92
|
@ -7,17 +7,17 @@ using namespace sf;
|
||||||
class MyScreen : public IScreen
|
class MyScreen : public IScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OnFocus() override
|
void OnFocus(IWindow* parent) override
|
||||||
{
|
{
|
||||||
printf("Received Focus\n");
|
printf("Received Focus\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnDefocus() override
|
void OnDefocus() override
|
||||||
{
|
{
|
||||||
printf("Lost Focus\n");
|
printf("Lost Focus\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnRender(SDL_Renderer* renderer) override
|
void OnRender(SDL_Renderer* renderer) override
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace sf
|
||||||
public:
|
public:
|
||||||
virtual void OnFocus(IWindow* parent) { }
|
virtual void OnFocus(IWindow* parent) { }
|
||||||
virtual void OnDefocus() { }
|
virtual void OnDefocus() { }
|
||||||
virtual bool OnUpdate(double frametime) override { return true; }
|
bool OnUpdate(double frametime) override { return true; }
|
||||||
virtual bool OnEvent(const SDL_Event& event) override { return true; }
|
bool OnEvent(const SDL_Event& event) override { return true; }
|
||||||
virtual void OnRender(SDL_Renderer* renderer) override {}
|
void OnRender(SDL_Renderer* renderer) override {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IScreen() = default;
|
IScreen() = default;
|
||||||
|
|
|
@ -51,7 +51,6 @@ namespace sf
|
||||||
m_oEventFunction = std::bind(&IWindow::OnEvent, this, std::placeholders::_1);
|
m_oEventFunction = std::bind(&IWindow::OnEvent, this, std::placeholders::_1);
|
||||||
m_oUpdateFunction = std::bind<bool>(&IWindow::OnUpdate, this, std::placeholders::_1);
|
m_oUpdateFunction = std::bind<bool>(&IWindow::OnUpdate, this, std::placeholders::_1);
|
||||||
m_oRenderFunction = std::bind(&IWindow::OnRender, this, std::placeholders::_1);
|
m_oRenderFunction = std::bind(&IWindow::OnRender, this, std::placeholders::_1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWindow::Destroy()
|
void IWindow::Destroy()
|
||||||
|
@ -78,7 +77,6 @@ namespace sf
|
||||||
|
|
||||||
if(m_oMsgLoopThread.joinable())
|
if(m_oMsgLoopThread.joinable())
|
||||||
m_oMsgLoopThread.join();
|
m_oMsgLoopThread.join();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWindow::AddEventCallback(EventCallback callback, void* userdata)
|
void IWindow::AddEventCallback(EventCallback callback, void* userdata)
|
||||||
|
@ -109,7 +107,6 @@ namespace sf
|
||||||
m_oEventFunction = std::bind(&IWindow::OnEvent, this, std::placeholders::_1);
|
m_oEventFunction = std::bind(&IWindow::OnEvent, this, std::placeholders::_1);
|
||||||
m_oUpdateFunction = std::bind<bool>(&IWindow::OnUpdate, this, std::placeholders::_1);
|
m_oUpdateFunction = std::bind<bool>(&IWindow::OnUpdate, this, std::placeholders::_1);
|
||||||
m_oRenderFunction = std::bind(&IWindow::OnRender, this, std::placeholders::_1);
|
m_oRenderFunction = std::bind(&IWindow::OnRender, this, std::placeholders::_1);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +116,6 @@ namespace sf
|
||||||
m_oSize(size), m_oPosition(position), m_strTitle(title), m_uWindowFlags(windowFlags),
|
m_oSize(size), m_oPosition(position), m_strTitle(title), m_uWindowFlags(windowFlags),
|
||||||
m_uRenderFlags(renderFlags), m_pCurrentScreen(nullptr), m_pCurrentException("")
|
m_uRenderFlags(renderFlags), m_pCurrentScreen(nullptr), m_pCurrentException("")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWindow::MessageLoop()
|
void IWindow::MessageLoop()
|
||||||
|
@ -142,7 +138,6 @@ namespace sf
|
||||||
{
|
{
|
||||||
if (m_oEventFunction(m_oEvent))
|
if (m_oEventFunction(m_oEvent))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_oEvent.type == SDL_QUIT)
|
if (m_oEvent.type == SDL_QUIT)
|
||||||
{
|
{
|
||||||
m_atomWindowOpen = false;
|
m_atomWindowOpen = false;
|
||||||
|
|
|
@ -38,9 +38,9 @@ namespace sf
|
||||||
|
|
||||||
virtual bool OnCreate() { return true; }
|
virtual bool OnCreate() { return true; }
|
||||||
virtual void OnClose() { }
|
virtual void OnClose() { }
|
||||||
virtual bool OnEvent(const SDL_Event& event) override { return true; }
|
bool OnEvent(const SDL_Event& event) override { return true; }
|
||||||
virtual bool OnUpdate(double frametime) override { return true; }
|
bool OnUpdate(double frametime) override { return true; }
|
||||||
virtual void OnRender(SDL_Renderer* renderer) override { }
|
void OnRender(SDL_Renderer* renderer) override { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SDL_Window* m_pWindow;
|
SDL_Window* m_pWindow;
|
||||||
|
|
Loading…
Reference in a new issue