lets go
This commit is contained in:
BIN
.cache/clangd/index/Aeon.cpp.486F3A6DD69928F6.idx
Normal file
BIN
.cache/clangd/index/Aeon.cpp.486F3A6DD69928F6.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Aeon.hpp.A53F5D75FC880F09.idx
Normal file
BIN
.cache/clangd/index/Aeon.hpp.A53F5D75FC880F09.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Assert.hpp.FCC5E01277F7C7CE.idx
Normal file
BIN
.cache/clangd/index/Assert.hpp.FCC5E01277F7C7CE.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/ComponentController.hpp.97C5D5015D936EAC.idx
Normal file
BIN
.cache/clangd/index/ComponentController.hpp.97C5D5015D936EAC.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Display.cpp.D92635EEBD4AE5E7.idx
Normal file
BIN
.cache/clangd/index/Display.cpp.D92635EEBD4AE5E7.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Display.hpp.1F2BECCAA6FFFC93.idx
Normal file
BIN
.cache/clangd/index/Display.hpp.1F2BECCAA6FFFC93.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/EngineConfig.hpp.0EF2CD8B81B5CBC3.idx
Normal file
BIN
.cache/clangd/index/EngineConfig.hpp.0EF2CD8B81B5CBC3.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Entity.hpp.755C0D6DF9F32090.idx
Normal file
BIN
.cache/clangd/index/Entity.hpp.755C0D6DF9F32090.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/EntityController.cpp.15C613A4666FA9E9.idx
Normal file
BIN
.cache/clangd/index/EntityController.cpp.15C613A4666FA9E9.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/EntityController.hpp.A05C5AA2D5FDD335.idx
Normal file
BIN
.cache/clangd/index/EntityController.hpp.A05C5AA2D5FDD335.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Events.cpp.B4EE623917FA0DA2.idx
Normal file
BIN
.cache/clangd/index/Events.cpp.B4EE623917FA0DA2.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Events.hpp.A496277A6267D622.idx
Normal file
BIN
.cache/clangd/index/Events.hpp.A496277A6267D622.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/ExampleGame.cpp.9EC42D6E840C2507.idx
Normal file
BIN
.cache/clangd/index/ExampleGame.cpp.9EC42D6E840C2507.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/GameLayer.hpp.2FD71740EFD654A2.idx
Normal file
BIN
.cache/clangd/index/GameLayer.hpp.2FD71740EFD654A2.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/ImGui.hpp.D9F0B3635FB5E102.idx
Normal file
BIN
.cache/clangd/index/ImGui.hpp.D9F0B3635FB5E102.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Includes.hpp.F54D408F8139EA1E.idx
Normal file
BIN
.cache/clangd/index/Includes.hpp.F54D408F8139EA1E.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Input.cpp.43A863BDFFD32619.idx
Normal file
BIN
.cache/clangd/index/Input.cpp.43A863BDFFD32619.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Input.hpp.7A0BE460434DCB6B.idx
Normal file
BIN
.cache/clangd/index/Input.hpp.7A0BE460434DCB6B.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/InputMap.hpp.B92A15D4271A456C.idx
Normal file
BIN
.cache/clangd/index/InputMap.hpp.B92A15D4271A456C.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/RenderMaster.cpp.FB2469C012B524DF.idx
Normal file
BIN
.cache/clangd/index/RenderMaster.cpp.FB2469C012B524DF.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/RenderMaster.hpp.EDA52D09ADFC44AE.idx
Normal file
BIN
.cache/clangd/index/RenderMaster.hpp.EDA52D09ADFC44AE.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/Singleton.hpp.29617A099D8E65EE.idx
Normal file
BIN
.cache/clangd/index/Singleton.hpp.29617A099D8E65EE.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/glad.c.30975A047DE69F0C.idx
Normal file
BIN
.cache/clangd/index/glad.c.30975A047DE69F0C.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/glad.h.29D3E4FE97705D53.idx
Normal file
BIN
.cache/clangd/index/glad.h.29D3E4FE97705D53.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imconfig.h.BC4D5FD8D2B2E2D9.idx
Normal file
BIN
.cache/clangd/index/imconfig.h.BC4D5FD8D2B2E2D9.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui.cpp.22D74525CBA383BF.idx
Normal file
BIN
.cache/clangd/index/imgui.cpp.22D74525CBA383BF.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui.h.C72F17EDCE96FECB.idx
Normal file
BIN
.cache/clangd/index/imgui.h.C72F17EDCE96FECB.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_draw.cpp.568E5346954DA987.idx
Normal file
BIN
.cache/clangd/index/imgui_draw.cpp.568E5346954DA987.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_opengl2.cpp.B53B0289258249D9.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_opengl2.cpp.B53B0289258249D9.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_opengl2.h.760F23D44B19BEFF.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_opengl2.h.760F23D44B19BEFF.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_opengl3.cpp.2E5BE08BD904302C.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_opengl3.cpp.2E5BE08BD904302C.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_opengl3.h.721114A74EDC0BBC.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_opengl3.h.721114A74EDC0BBC.idx
Normal file
Binary file not shown.
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_sdl.cpp.E3965EBA77FC9AB6.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_sdl.cpp.E3965EBA77FC9AB6.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_impl_sdl.h.16F60CF22B0116EC.idx
Normal file
BIN
.cache/clangd/index/imgui_impl_sdl.h.16F60CF22B0116EC.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_internal.h.CE27FB5EA6D68FF8.idx
Normal file
BIN
.cache/clangd/index/imgui_internal.h.CE27FB5EA6D68FF8.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_tables.cpp.7D674032578A9ACB.idx
Normal file
BIN
.cache/clangd/index/imgui_tables.cpp.7D674032578A9ACB.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imgui_widgets.cpp.E3D2B0926EFE068D.idx
Normal file
BIN
.cache/clangd/index/imgui_widgets.cpp.E3D2B0926EFE068D.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imstb_rectpack.h.54D9710AEC75A87D.idx
Normal file
BIN
.cache/clangd/index/imstb_rectpack.h.54D9710AEC75A87D.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imstb_textedit.h.0234A9C40BC83F97.idx
Normal file
BIN
.cache/clangd/index/imstb_textedit.h.0234A9C40BC83F97.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/imstb_truetype.h.BA0779D8E5C26FB2.idx
Normal file
BIN
.cache/clangd/index/imstb_truetype.h.BA0779D8E5C26FB2.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/khrplatform.h.50BCDE84CFA5D07D.idx
Normal file
BIN
.cache/clangd/index/khrplatform.h.50BCDE84CFA5D07D.idx
Normal file
Binary file not shown.
@@ -1,143 +1,139 @@
|
|||||||
#include "Display.hpp"
|
#include "Display.hpp"
|
||||||
|
|
||||||
#include <Aeon/Includes.hpp>
|
|
||||||
|
|
||||||
#include <Aeon/Assert.hpp>
|
#include <Aeon/Assert.hpp>
|
||||||
#include <Aeon/Rendering/RenderMaster.hpp>
|
#include <Aeon/Includes.hpp>
|
||||||
#include <Aeon/Rendering/ImGui.hpp>
|
#include <Aeon/Rendering/ImGui.hpp>
|
||||||
|
|
||||||
using Core::Display;
|
using Core::Display;
|
||||||
|
|
||||||
Display::Display()
|
Display::Display()
|
||||||
: mWindow( nullptr )
|
: mWindow(nullptr), mContext(NULL), mClearColour {1.0f, 1.0f, 1.0f, 1.0f}
|
||||||
, mContext( NULL )
|
|
||||||
, mRenderer( Rendering::RenderMaster::GetInstance() )
|
|
||||||
, mClearColour{ 1.0f, 1.0f, 1.0f, 1.0f }
|
|
||||||
{
|
{
|
||||||
PushThisAsSink( "ENGINE_DISPLAY_CORE" );
|
PushThisAsSink("ENGINE_DISPLAY_CORE");
|
||||||
}
|
}
|
||||||
|
|
||||||
Display::~Display()
|
Display::~Display()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Display::Create( const DisplayProperties& properties )
|
bool Display::Create(const DisplayProperties& properties)
|
||||||
{
|
{
|
||||||
SDL_Init( SDL_INIT_VIDEO );
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
||||||
SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32 );
|
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
|
||||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
|
||||||
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 );
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 5 );
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
|
||||||
|
|
||||||
mWindow = SDL_CreateWindow( properties.Name.c_str(),
|
mWindow = SDL_CreateWindow(properties.Name.c_str(),
|
||||||
SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOWPOS_CENTERED,
|
||||||
SDL_WINDOWPOS_CENTERED, properties.Width, properties.Height,
|
SDL_WINDOWPOS_CENTERED,
|
||||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE );
|
properties.Width,
|
||||||
|
properties.Height,
|
||||||
|
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
AEON_ASSERT( mWindow, "Can't initialise window" );
|
AEON_ASSERT(mWindow, "Can't initialise window");
|
||||||
|
|
||||||
mContext = SDL_GL_CreateContext( mWindow );
|
mContext = SDL_GL_CreateContext(mWindow);
|
||||||
|
|
||||||
AEON_ASSERT( mContext, "Can't initialise context" );
|
AEON_ASSERT(mContext, "Can't initialise context");
|
||||||
|
|
||||||
SDL_GL_SetSwapInterval( static_cast<int>(!properties.VSync) );
|
SDL_GL_SetSwapInterval(static_cast<int>(!properties.VSync));
|
||||||
|
|
||||||
gladLoadGLLoader( SDL_GL_GetProcAddress );
|
gladLoadGLLoader(SDL_GL_GetProcAddress);
|
||||||
glEnable( GL_MULTISAMPLE );
|
glEnable(GL_MULTISAMPLE);
|
||||||
glCullFace( GL_BACK );
|
glCullFace(GL_BACK);
|
||||||
glEnable( GL_DEPTH_TEST );
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
mWidth = properties.Width;
|
mWidth = properties.Width;
|
||||||
mHeight = properties.Height;
|
mHeight = properties.Height;
|
||||||
|
|
||||||
Rendering::SetupImGui( mWindow, mContext );
|
Rendering::SetupImGui(mWindow, mContext);
|
||||||
|
|
||||||
// Make sure ImGUI is ready to be used on the first frame
|
// Make sure ImGUI is ready to be used on the first frame
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int Display::GetWidth()
|
const unsigned int Display::GetWidth()
|
||||||
{
|
{
|
||||||
return mWidth;
|
return mWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int Display::GetHeight()
|
const unsigned int Display::GetHeight()
|
||||||
{
|
{
|
||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_Window* Display::GetWindow()
|
const SDL_Window* Display::GetWindow()
|
||||||
{
|
{
|
||||||
return mWindow;
|
return mWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_GLContext& Display::GetContext()
|
const SDL_GLContext& Display::GetContext()
|
||||||
{
|
{
|
||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::SetClearColour( float r, float g, float b, float a )
|
void Display::SetClearColour(float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
mClearColour[0] = r * a;
|
mClearColour[0] = r * a;
|
||||||
mClearColour[1] = g * a;
|
mClearColour[1] = g * a;
|
||||||
mClearColour[2] = b * a;
|
mClearColour[2] = b * a;
|
||||||
mClearColour[3] = a;
|
mClearColour[3] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::EndFrame()
|
void Display::EndFrame()
|
||||||
{
|
{
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData( ImGui::GetDrawData() );
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
SDL_GL_SwapWindow( mWindow );
|
|
||||||
|
|
||||||
glClearColor( mClearColour[0], mClearColour[1], mClearColour[2], mClearColour[3] );
|
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
SDL_GL_SwapWindow(mWindow);
|
||||||
ImGui_ImplSDL2_NewFrame();
|
|
||||||
ImGui::NewFrame();
|
glClearColor(mClearColour[0], mClearColour[1], mClearColour[2], mClearColour[3]);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui_ImplSDL2_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::Destroy()
|
void Display::Destroy()
|
||||||
{
|
{
|
||||||
Rendering::CleanupImGui();
|
Rendering::CleanupImGui();
|
||||||
SDL_DestroyWindow( mWindow );
|
SDL_DestroyWindow(mWindow);
|
||||||
// dangly balls
|
// dangly balls
|
||||||
mWindow = nullptr;
|
mWindow = nullptr;
|
||||||
mWidth = 0;
|
mWidth = 0;
|
||||||
mHeight = 0;
|
mHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Display::EventRecieved( GenericEvent& e )
|
bool Display::EventRecieved(GenericEvent& e)
|
||||||
{
|
{
|
||||||
if ( e.Type == "DISPLAY_RESIZE" )
|
if (e.Type == "DISPLAY_RESIZE")
|
||||||
{
|
{
|
||||||
mWidth = e.x;
|
mWidth = e.x;
|
||||||
mHeight = e.y;
|
mHeight = e.y;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( e.Type == "DISPLAY_MOVE" )
|
if (e.Type == "DISPLAY_MOVE")
|
||||||
{
|
{
|
||||||
mX = e.x;
|
mX = e.x;
|
||||||
mY = e.y;
|
mY = e.y;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ private:
|
|||||||
SDL_Window* mWindow;
|
SDL_Window* mWindow;
|
||||||
SDL_GLContext mContext;
|
SDL_GLContext mContext;
|
||||||
|
|
||||||
RenderMaster& mRenderer;
|
|
||||||
|
|
||||||
unsigned int mWidth, mHeight = 0;
|
unsigned int mWidth, mHeight = 0;
|
||||||
unsigned int mX, mY = 0;
|
unsigned int mX, mY = 0;
|
||||||
float mClearColour[4];
|
float mClearColour[4];
|
||||||
|
|||||||
@@ -2,262 +2,265 @@
|
|||||||
|
|
||||||
#include <Aeon/Assert.hpp>
|
#include <Aeon/Assert.hpp>
|
||||||
|
|
||||||
using Core::GenericEvent;
|
|
||||||
using Core::EventListener;
|
|
||||||
using Core::EventDispatcher;
|
using Core::EventDispatcher;
|
||||||
|
using Core::EventListener;
|
||||||
using Core::EventManager;
|
using Core::EventManager;
|
||||||
|
using Core::GenericEvent;
|
||||||
|
|
||||||
// TODO: Events should use pre-allocated memory ALWAYS!
|
// TODO: Events should use pre-allocated memory ALWAYS!
|
||||||
// TODO: Look into Bump Allocation
|
// TODO: Look into Bump Allocation
|
||||||
|
|
||||||
EventListener::EventListener()
|
EventListener::EventListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventListener::~EventListener()
|
EventListener::~EventListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::PushThisAsSink( std::string system )
|
void EventListener::PushThisAsSink(std::string system)
|
||||||
{
|
{
|
||||||
mListenerID = EventManager::GetInstance().RegisterSinkPush( this, system );
|
mListenerID = EventManager::GetInstance().RegisterSinkPush(this, system);
|
||||||
AEON_ASSERT( mListenerID != -1, "Cannot register event sink" );
|
AEON_ASSERT(mListenerID != -1, "Cannot register event sink");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::PushAndStickThisAsSink( std::string system )
|
void EventListener::PushAndStickThisAsSink(std::string system)
|
||||||
{
|
{
|
||||||
mListenerID = EventManager::GetInstance().RegisterSinkPushStick( this, system );
|
mListenerID = EventManager::GetInstance().RegisterSinkPushStick(this, system);
|
||||||
AEON_ASSERT( mListenerID != -1, "Cannot register event sink" );
|
AEON_ASSERT(mListenerID != -1, "Cannot register event sink");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::UnshiftThisAsSink( std::string system )
|
void EventListener::UnshiftThisAsSink(std::string system)
|
||||||
{
|
{
|
||||||
mListenerID = EventManager::GetInstance().RegisterSinkUnshift( this, system );
|
mListenerID = EventManager::GetInstance().RegisterSinkUnshift(this, system);
|
||||||
AEON_ASSERT( mListenerID != -1, "Cannot register event sink" );
|
AEON_ASSERT(mListenerID != -1, "Cannot register event sink");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::ShiftSinkLeft( std::string forSystem )
|
void EventListener::ShiftSinkLeft(std::string forSystem)
|
||||||
{
|
{
|
||||||
EventManager::GetInstance().MoveSinkLeft( this, forSystem );
|
EventManager::GetInstance().MoveSinkLeft(this, forSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::ShiftSinkRight( std::string forSystem )
|
void EventListener::ShiftSinkRight(std::string forSystem)
|
||||||
{
|
{
|
||||||
EventManager::GetInstance().MoveSinkRight( this, forSystem );
|
EventManager::GetInstance().MoveSinkRight(this, forSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventListener::DeRegisterAsSink( std::string system )
|
void EventListener::DeRegisterAsSink(std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EventDispatcher::EventDispatcher()
|
EventDispatcher::EventDispatcher()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher::EventDispatcher( std::string system )
|
EventDispatcher::EventDispatcher(std::string system)
|
||||||
{
|
{
|
||||||
RegisterAsSource( system );
|
RegisterAsSource(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher::~EventDispatcher()
|
EventDispatcher::~EventDispatcher()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::RegisterAsSource( std::string system )
|
void EventDispatcher::RegisterAsSource(std::string system)
|
||||||
{
|
{
|
||||||
mDispatcherID = EventManager::GetInstance().RegisterSource( this, system );
|
mDispatcherID = EventManager::GetInstance().RegisterSource(this, system);
|
||||||
AEON_ASSERT( mDispatcherID != -1, "Cannot register event source" );
|
AEON_ASSERT(mDispatcherID != -1, "Cannot register event source");
|
||||||
mSystem = system;
|
mSystem = system;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::DeRegisterAsSource( std::string system )
|
void EventDispatcher::DeRegisterAsSource(std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::Dispatch( GenericEvent e )
|
void EventDispatcher::Dispatch(GenericEvent e)
|
||||||
{
|
{
|
||||||
e.System = mSystem;
|
e.System = mSystem;
|
||||||
EventManager::GetInstance().Dispatch( mDispatcherID, e );
|
EventManager::GetInstance().Dispatch(mDispatcherID, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::Dispatch( std::string type )
|
void EventDispatcher::Dispatch(std::string type)
|
||||||
{
|
{
|
||||||
GenericEvent e;
|
GenericEvent e;
|
||||||
e.Type = type;
|
e.Type = type;
|
||||||
e.System = mSystem;
|
e.System = mSystem;
|
||||||
EventManager::GetInstance().Dispatch( mDispatcherID, e );
|
EventManager::GetInstance().Dispatch(mDispatcherID, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventManager::EventManager()
|
EventManager::EventManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManager::~EventManager()
|
EventManager::~EventManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventManager::RegisterSource( EventDispatcher* source, std::string system )
|
int EventManager::RegisterSource(EventDispatcher* source, std::string system)
|
||||||
{
|
{
|
||||||
int id = mNextHeighest;
|
int id = mNextHeighest;
|
||||||
mSources[id] = system;
|
mSources[id] = system;
|
||||||
mNextHeighest++;
|
mNextHeighest++;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventManager::RegisterSinkPush( EventListener* sink, std::string system )
|
int EventManager::RegisterSinkPush(EventListener* sink, std::string system)
|
||||||
{
|
{
|
||||||
int id = mNextHeighest;
|
int id = mNextHeighest;
|
||||||
mListeners[id] = sink;
|
mListeners[id] = sink;
|
||||||
|
|
||||||
auto& sinkVector = mSinks[system];
|
auto& sinkVector = mSinks[system];
|
||||||
sinkVector.push_back( { sink, id } );
|
sinkVector.push_back({sink, id});
|
||||||
|
|
||||||
mNextHeighest++;
|
mNextHeighest++;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventManager::RegisterSinkPushStick( EventListener* sink, std::string system )
|
int EventManager::RegisterSinkPushStick(EventListener* sink, std::string system)
|
||||||
{
|
{
|
||||||
int id = mNextHeighest;
|
int id = mNextHeighest;
|
||||||
mListeners[id] = sink;
|
mListeners[id] = sink;
|
||||||
|
|
||||||
auto& sinkVector = mStickySinks[system];
|
auto& sinkVector = mStickySinks[system];
|
||||||
sinkVector.push_back( { sink, id } );
|
sinkVector.push_back({sink, id});
|
||||||
|
|
||||||
mNextHeighest++;
|
mNextHeighest++;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventManager::RegisterSinkUnshift( EventListener* sink, std::string system )
|
int EventManager::RegisterSinkUnshift(EventListener* sink, std::string system)
|
||||||
{
|
{
|
||||||
int id = mNextHeighest;
|
int id = mNextHeighest;
|
||||||
mListeners[id] = sink;
|
mListeners[id] = sink;
|
||||||
|
|
||||||
if ( !mSinks.count( system ) )
|
if (!mSinks.count(system))
|
||||||
{
|
{
|
||||||
return RegisterSinkPush( sink, system );
|
return RegisterSinkPush(sink, system);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& sinkVector = mSinks[system];
|
auto& sinkVector = mSinks[system];
|
||||||
sinkVector.insert( sinkVector.begin(), { sink, id } );
|
sinkVector.insert(sinkVector.begin(), {sink, id});
|
||||||
|
|
||||||
mNextHeighest++;
|
mNextHeighest++;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::MoveSinkLeft( EventListener* sink, std::string system )
|
void EventManager::MoveSinkLeft(EventListener* sink, std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::MoveSinkRight( EventListener* sink, std::string system )
|
void EventManager::MoveSinkRight(EventListener* sink, std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::RemoveSource( int dispatcherID, std::string system )
|
void EventManager::RemoveSource(int dispatcherID, std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::RemoveSink( int listenerID, std::string system )
|
void EventManager::RemoveSink(int listenerID, std::string system)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// it is important to reverse the lists so that the dispatching is done correctly
|
// it is important to reverse the lists so that the dispatching is done correctly
|
||||||
// this is more efficiently done at insert... lol
|
// this is more efficiently done at insert... lol
|
||||||
template <typename C>
|
template <typename C>
|
||||||
struct reverse_wrapper {
|
struct reverse_wrapper
|
||||||
|
{
|
||||||
|
|
||||||
C& c_;
|
C& c_;
|
||||||
reverse_wrapper(C& c) : c_(c) {}
|
reverse_wrapper(C& c) : c_(c)
|
||||||
|
{}
|
||||||
|
|
||||||
typename C::reverse_iterator begin() { return c_.rbegin(); }
|
typename C::reverse_iterator begin()
|
||||||
typename C::reverse_iterator end() { return c_.rend(); }
|
{
|
||||||
|
return c_.rbegin();
|
||||||
|
}
|
||||||
|
typename C::reverse_iterator end()
|
||||||
|
{
|
||||||
|
return c_.rend();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename C, size_t N>
|
template <typename C, size_t N>
|
||||||
struct reverse_wrapper< C[N] > {
|
struct reverse_wrapper<C[N]>
|
||||||
|
{
|
||||||
|
|
||||||
C(&c_)[N];
|
C (&c_)
|
||||||
reverse_wrapper(C(&c)[N]) : c_(c) {}
|
[N];
|
||||||
|
reverse_wrapper(C (&c)[N]) : c_(c)
|
||||||
|
{}
|
||||||
|
|
||||||
typename std::reverse_iterator<const C*> begin() { return std::rbegin(c_); }
|
typename std::reverse_iterator<const C*> begin()
|
||||||
typename std::reverse_iterator<const C*> end() { return std::rend(c_); }
|
{
|
||||||
|
return std::rbegin(c_);
|
||||||
|
}
|
||||||
|
typename std::reverse_iterator<const C*> end()
|
||||||
|
{
|
||||||
|
return std::rend(c_);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename C>
|
template <typename C>
|
||||||
reverse_wrapper<C> r_wrap(C& c) {
|
reverse_wrapper<C> r_wrap(C& c)
|
||||||
return reverse_wrapper<C>(c);
|
{
|
||||||
|
return reverse_wrapper<C>(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::Dispatch( int dispatcherID, GenericEvent e )
|
void EventManager::Dispatch(int dispatcherID, GenericEvent e)
|
||||||
{
|
{
|
||||||
std::string targetSink = mSources[dispatcherID];
|
std::string targetSink = mSources[dispatcherID];
|
||||||
auto stickySinks = mStickySinks[targetSink];
|
auto stickySinks = mStickySinks[targetSink];
|
||||||
auto sinks = mSinks[targetSink];
|
auto sinks = mSinks[targetSink];
|
||||||
|
|
||||||
if ( !stickySinks.empty() )
|
if (!stickySinks.empty())
|
||||||
{
|
{
|
||||||
for ( auto& listenerPair : r_wrap(stickySinks))
|
for (auto& listenerPair : r_wrap(stickySinks))
|
||||||
{
|
{
|
||||||
EventListener* listener = std::get<0>( listenerPair );
|
EventListener* listener = std::get<0>(listenerPair);
|
||||||
bool handled = listener->EventRecieved( e );
|
bool handled = listener->EventRecieved(e);
|
||||||
if ( handled ) e.Handled = handled;
|
if (handled)
|
||||||
|
e.Handled = handled;
|
||||||
|
|
||||||
if ( e.Handled )
|
if (e.Handled)
|
||||||
{
|
{
|
||||||
// destroy event
|
// destroy event
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sinks.empty())
|
if (!sinks.empty())
|
||||||
{
|
{
|
||||||
for (auto& listenerPair : r_wrap(sinks))
|
for (auto& listenerPair : r_wrap(sinks))
|
||||||
{
|
{
|
||||||
EventListener* listener = std::get<0>(listenerPair);
|
EventListener* listener = std::get<0>(listenerPair);
|
||||||
bool handled = listener->EventRecieved(e);
|
bool handled = listener->EventRecieved(e);
|
||||||
if (handled) e.Handled = handled;
|
if (handled)
|
||||||
|
e.Handled = handled;
|
||||||
|
|
||||||
if (e.Handled)
|
if (e.Handled)
|
||||||
{
|
{
|
||||||
// destroy event
|
// destroy event
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::DebugPrint()
|
void EventManager::DebugPrint()
|
||||||
{
|
{
|
||||||
std::cout << "----- BEGIN EVENTS DEBUG -----" << std::endl;
|
std::cout << "----- BEGIN EVENTS DEBUG -----" << std::endl;
|
||||||
for (auto const& [dispatcher, targetSink] : mSources)
|
for (auto const& [dispatcher, targetSink] : mSources)
|
||||||
{
|
{
|
||||||
auto stickySinks = mStickySinks[targetSink];
|
auto stickySinks = mStickySinks[targetSink];
|
||||||
auto sinks = mSinks[targetSink];
|
auto sinks = mSinks[targetSink];
|
||||||
|
|
||||||
int sourceCount = 0;
|
int sourceCount = 0;
|
||||||
for (auto const& [id, source] : mSources)
|
for (auto const& [id, source] : mSources)
|
||||||
if (source == targetSink) sourceCount++;
|
if (source == targetSink)
|
||||||
|
sourceCount++;
|
||||||
|
|
||||||
std::cout << targetSink << " has " << stickySinks.size() << " sticky and " << sinks.size() << " sink(s) and is being dispatched from " << sourceCount << " different source(s)" << std::endl;
|
std::cout << targetSink << " has " << stickySinks.size() << " sticky and " << sinks.size() << " sink(s) and is being dispatched from " << sourceCount << " different source(s)" << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << "----- END EVENTS DEBUG -----" << std::endl;
|
std::cout << "----- END EVENTS DEBUG -----" << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,173 +2,173 @@
|
|||||||
#define AEON_CORE_EVENTS_H_
|
#define AEON_CORE_EVENTS_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- Events have a source and a sink, where from and where too
|
- Events have a source and a sink, where from and where too
|
||||||
- Event sinks are systems that events are dispatched to from
|
- Event sinks are systems that events are dispatched to from
|
||||||
a source of the same system
|
a source of the same system
|
||||||
- Event listeners are layered, 0 is front, larger is back so
|
- Event listeners are layered, 0 is front, larger is back so
|
||||||
events propogate from the front to the back, not going
|
events propogate from the front to the back, not going
|
||||||
further once handled
|
further once handled
|
||||||
- Event sources can only dispatch events to a single system
|
- Event sources can only dispatch events to a single system
|
||||||
- Systems can request to only receive events from a certain
|
- Systems can request to only receive events from a certain
|
||||||
"system" category, or multiple
|
"system" category, or multiple
|
||||||
- Events are blocking for now
|
- Events are blocking for now
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Aeon/Includes.hpp>
|
#include <Aeon/Includes.hpp>
|
||||||
|
|
||||||
#include <Aeon/Singleton.hpp>
|
|
||||||
#include <Aeon/Input/InputMap.hpp>
|
#include <Aeon/Input/InputMap.hpp>
|
||||||
|
#include <Aeon/Singleton.hpp>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
// THis needs some redesigning so i can do this.AttachSpecificListener(Type, Action, [&] => {...})
|
// THis needs some redesigning so i can do this.AttachSpecificListener(Type, Action, [&] => {...})
|
||||||
// More specifically to support enumerator calling AND custom defined string calling
|
// More specifically to support enumerator calling AND custom defined string calling
|
||||||
// Maybe through a reserved enumeration map 0-100: system etc..
|
// Maybe through a reserved enumeration map 0-100: system etc..
|
||||||
/*
|
/*
|
||||||
* Engine event systems / type
|
* Engine event systems / type
|
||||||
* ENGINE_SYSTEM_CORE - start, stop, pause, etc
|
* ENGINE_SYSTEM_CORE - start, stop, pause, etc
|
||||||
* ENGINE_START - starts game loop execution
|
* ENGINE_START - starts game loop execution
|
||||||
* ENGINE_STOP
|
* ENGINE_STOP
|
||||||
* ENGINE_PAUSE
|
* ENGINE_PAUSE
|
||||||
* ENGINE_DISPLAY_CORE - window open, window close, etc
|
* ENGINE_DISPLAY_CORE - window open, window close, etc
|
||||||
* DISPLAY_RESIZE (x, y) - rezise to x, y being new w, h
|
* DISPLAY_RESIZE (x, y) - rezise to x, y being new w, h
|
||||||
* DISPLAY_MOVE (x, y) - move to x, y
|
* DISPLAY_MOVE (x, y) - move to x, y
|
||||||
* DISPLAY_SHOW - no data
|
* DISPLAY_SHOW - no data
|
||||||
* DISPLAY_HIDE - no data
|
* DISPLAY_HIDE - no data
|
||||||
* DISPLAY_MINIMISED - no data
|
* DISPLAY_MINIMISED - no data
|
||||||
* DISPLAY_MAXIMISED - no data
|
* DISPLAY_MAXIMISED - no data
|
||||||
* DISPLAY_CLOSED - no data
|
* DISPLAY_CLOSED - no data
|
||||||
* DISPLAY_MOUSE_ENTER - no data
|
* DISPLAY_MOUSE_ENTER - no data
|
||||||
* DISPLAY_MOUSE_LEAVE - no data
|
* DISPLAY_MOUSE_LEAVE - no data
|
||||||
* DISPLAY_FOCUS - no data
|
* DISPLAY_FOCUS - no data
|
||||||
* DISPLAY_OUT_OF_FOCUS - no data
|
* DISPLAY_OUT_OF_FOCUS - no data
|
||||||
* ENGINE_INPUT_MOUSE
|
* ENGINE_INPUT_MOUSE
|
||||||
* MOUSE_LEFT_DOWN - no data
|
* MOUSE_LEFT_DOWN - no data
|
||||||
* MOUSE_LEFT_UP - no data
|
* MOUSE_LEFT_UP - no data
|
||||||
* MOUSE_RIGHT_DOWN - no data
|
* MOUSE_RIGHT_DOWN - no data
|
||||||
* MOUSE_RIGHT_UP - no data
|
* MOUSE_RIGHT_UP - no data
|
||||||
* MOUSE_MIDDLE_DOWN - no data
|
* MOUSE_MIDDLE_DOWN - no data
|
||||||
* MOUSE_MIDDLE_UP - no data
|
* MOUSE_MIDDLE_UP - no data
|
||||||
* MOUSE_SCROLL - y+-
|
* MOUSE_SCROLL - y+-
|
||||||
* MOUSE_MOVE - move to x, y relative dx, dy
|
* MOUSE_MOVE - move to x, y relative dx, dy
|
||||||
* ENGINE_INPUT_KEYBOARD
|
* ENGINE_INPUT_KEYBOARD
|
||||||
* KEYBOARD_KEYDOWN - keycode, keymod
|
* KEYBOARD_KEYDOWN - keycode, keymod
|
||||||
* KEYBOARD_KEYUP - keycode, keymod
|
* KEYBOARD_KEYUP - keycode, keymod
|
||||||
* KEYBOARD_KEYPRESS - keycode for continual pressing, keymod
|
* KEYBOARD_KEYPRESS - keycode for continual pressing, keymod
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
struct GenericEvent
|
struct GenericEvent
|
||||||
{
|
{
|
||||||
// always populated
|
// always populated
|
||||||
std::string System;
|
std::string System;
|
||||||
std::string Type;
|
std::string Type;
|
||||||
|
|
||||||
// the rest can be empty
|
|
||||||
// user defined
|
|
||||||
std::string Data;
|
|
||||||
|
|
||||||
// DISPLAY_RESIZE DISPLAY_MOVE MOUSE_MOVE
|
// the rest can be empty
|
||||||
int x, y;
|
// user defined
|
||||||
// MOUSE_MOVE
|
std::string Data;
|
||||||
int dx, dy;
|
|
||||||
|
|
||||||
// KEYBOARD_KEYDOWN KEYBOARD_KEYUP KEYBOARD_PRESSED
|
|
||||||
Input::EKeyCode keyCode;
|
|
||||||
uint16_t keyMods;
|
|
||||||
|
|
||||||
bool Handled = false;
|
// DISPLAY_RESIZE DISPLAY_MOVE MOUSE_MOVE
|
||||||
|
int x, y;
|
||||||
|
// MOUSE_MOVE
|
||||||
|
int dx, dy;
|
||||||
|
|
||||||
|
// KEYBOARD_KEYDOWN KEYBOARD_KEYUP KEYBOARD_PRESSED
|
||||||
|
Input::EKeyCode keyCode;
|
||||||
|
uint16_t keyMods;
|
||||||
|
|
||||||
|
// USER EVENTS
|
||||||
|
void* UserData = nullptr;
|
||||||
|
|
||||||
|
bool Handled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventListener
|
class EventListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventListener();
|
EventListener();
|
||||||
virtual ~EventListener();
|
virtual ~EventListener();
|
||||||
|
|
||||||
// Pushes sink to the top of the listener stack
|
// Pushes sink to the top of the listener stack
|
||||||
// underneath the stuck listeners
|
// underneath the stuck listeners
|
||||||
void PushThisAsSink( std::string system );
|
void PushThisAsSink(std::string system);
|
||||||
// Pushes sink to the top of the listener stack
|
// Pushes sink to the top of the listener stack
|
||||||
// with all of the other "stuck" listeners
|
// with all of the other "stuck" listeners
|
||||||
void PushAndStickThisAsSink( std::string system );
|
void PushAndStickThisAsSink(std::string system);
|
||||||
// Pushes sink to the bottom of the listener stack
|
// Pushes sink to the bottom of the listener stack
|
||||||
void UnshiftThisAsSink( std::string system );
|
void UnshiftThisAsSink(std::string system);
|
||||||
|
|
||||||
void ShiftSinkLeft( std::string forSystem );
|
void ShiftSinkLeft(std::string forSystem);
|
||||||
void ShiftSinkRight( std::string forSystem );
|
void ShiftSinkRight(std::string forSystem);
|
||||||
|
|
||||||
void DeRegisterAsSink( std::string system );
|
void DeRegisterAsSink(std::string system);
|
||||||
|
|
||||||
// return true = event handled and will not be further
|
// return true = event handled and will not be further
|
||||||
// propogated
|
// propogated
|
||||||
virtual bool EventRecieved( GenericEvent& e ) = 0;
|
virtual bool EventRecieved(GenericEvent& e) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mListenerID = -1;
|
int mListenerID = -1;
|
||||||
|
|
||||||
friend class EventManager;
|
friend class EventManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventDispatcher
|
class EventDispatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventDispatcher();
|
EventDispatcher();
|
||||||
EventDispatcher( std::string system );
|
EventDispatcher(std::string system);
|
||||||
~EventDispatcher();
|
~EventDispatcher();
|
||||||
|
|
||||||
void RegisterAsSource( std::string system );
|
void RegisterAsSource(std::string system);
|
||||||
void DeRegisterAsSource( std::string system );
|
void DeRegisterAsSource(std::string system);
|
||||||
|
|
||||||
void Dispatch( GenericEvent e );
|
void Dispatch(GenericEvent e);
|
||||||
// no data needed, listeners act on the event happening
|
// no data needed, listeners act on the event happening
|
||||||
void Dispatch( std::string type );
|
void Dispatch(std::string type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mSystem;
|
std::string mSystem;
|
||||||
int mDispatcherID = -1;
|
int mDispatcherID = -1;
|
||||||
|
|
||||||
friend class EventManager;
|
friend class EventManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventManager : public Helpers::Singleton<EventManager>
|
class EventManager : public Helpers::Singleton<EventManager>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventManager();
|
EventManager();
|
||||||
~EventManager();
|
~EventManager();
|
||||||
|
|
||||||
int RegisterSource( EventDispatcher* source, std::string system );
|
int RegisterSource(EventDispatcher* source, std::string system);
|
||||||
|
|
||||||
int RegisterSinkPush( EventListener* sink, std::string system );
|
int RegisterSinkPush(EventListener* sink, std::string system);
|
||||||
int RegisterSinkPushStick( EventListener* sink, std::string system );
|
int RegisterSinkPushStick(EventListener* sink, std::string system);
|
||||||
int RegisterSinkUnshift( EventListener* sink, std::string system );
|
int RegisterSinkUnshift(EventListener* sink, std::string system);
|
||||||
|
|
||||||
void MoveSinkLeft( EventListener* sink, std::string system );
|
void MoveSinkLeft(EventListener* sink, std::string system);
|
||||||
void MoveSinkRight( EventListener* sink, std::string system );
|
void MoveSinkRight(EventListener* sink, std::string system);
|
||||||
|
|
||||||
void RemoveSource( int dispatcherID, std::string system );
|
void RemoveSource(int dispatcherID, std::string system);
|
||||||
|
|
||||||
void RemoveSink( int listenerID, std::string system );
|
|
||||||
|
|
||||||
void Dispatch( int dispatcherID, GenericEvent e );
|
void RemoveSink(int listenerID, std::string system);
|
||||||
|
|
||||||
void DebugPrint();
|
void Dispatch(int dispatcherID, GenericEvent e);
|
||||||
|
|
||||||
|
void DebugPrint();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// indexed by listener ID for quick lookup
|
||||||
|
std::map<int, const EventListener*> mListeners;
|
||||||
|
// indexed by dispatcher ID for itteration
|
||||||
|
std::map<int, std::string> mSources;
|
||||||
|
// indexed by (sink) system ID (string)
|
||||||
|
// their position in the vector is their layer
|
||||||
|
std::map<std::string, std::vector<std::tuple<EventListener*, int>>> mStickySinks;
|
||||||
|
std::map<std::string, std::vector<std::tuple<EventListener*, int>>> mSinks;
|
||||||
|
|
||||||
// indexed by listener ID for quick lookup
|
int mNextHeighest = 0;
|
||||||
std::map<int, const EventListener*> mListeners;
|
|
||||||
// indexed by dispatcher ID for itteration
|
|
||||||
std::map<int, std::string> mSources;
|
|
||||||
// indexed by (sink) system ID (string)
|
|
||||||
// their position in the vector is their layer
|
|
||||||
std::map<std::string, std::vector<std::tuple<EventListener*, int>>> mStickySinks;
|
|
||||||
std::map<std::string, std::vector<std::tuple<EventListener*, int>>> mSinks;
|
|
||||||
|
|
||||||
int mNextHeighest = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,26 +2,23 @@
|
|||||||
|
|
||||||
using namespace EC;
|
using namespace EC;
|
||||||
|
|
||||||
|
|
||||||
EntityRegistry::EntityRegistry()
|
EntityRegistry::EntityRegistry()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRegistry::~EntityRegistry()
|
EntityRegistry::~EntityRegistry()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity EntityRegistry::Create()
|
Entity EntityRegistry::Create()
|
||||||
{
|
{
|
||||||
uint32_t entityId;
|
uint32_t entityId;
|
||||||
if ( mFreedEntities.empty() )
|
if (mFreedEntities.empty())
|
||||||
{
|
{
|
||||||
mEntityCeiling++;
|
mEntityCeiling++;
|
||||||
entityId = mEntityCeiling;
|
entityId = mEntityCeiling;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFreedEntities.pop();
|
mFreedEntities.pop();
|
||||||
}
|
}
|
||||||
@@ -30,22 +27,23 @@ Entity EntityRegistry::Create()
|
|||||||
return entityId;
|
return entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity Copy( const Entity& entity )
|
Entity Copy(const Entity& entity)
|
||||||
{
|
{
|
||||||
// look up everything, create a new entity and populate
|
// look up everything, create a new entity and populate
|
||||||
// with the components in the og entity
|
// with the components in the og entity
|
||||||
|
|
||||||
return static_cast<uint32_t>( 0 );
|
return static_cast<uint32_t>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityRegistry::Destroy( Entity entity )
|
void EntityRegistry::Destroy(Entity entity)
|
||||||
{
|
{
|
||||||
if ( !this->Valid( entity ) ) return;
|
if (!this->Valid(entity))
|
||||||
|
return;
|
||||||
mFreedEntities.push(entity);
|
mFreedEntities.push(entity);
|
||||||
mEntities.erase(entity);
|
mEntities.erase(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityRegistry::Valid( const Entity entity )
|
bool EntityRegistry::Valid(const Entity entity)
|
||||||
{
|
{
|
||||||
return mEntities.find(entity) != mEntities.end();
|
return mEntities.find(entity) != mEntities.end();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#ifndef AEON_ENTITY_ENTITYCONTROLLER_H_
|
#ifndef AEON_ENTITY_ENTITYCONTROLLER_H_
|
||||||
#define AEON_ENTITY_ENTITYCONTROLLER_H_
|
#define AEON_ENTITY_ENTITYCONTROLLER_H_
|
||||||
|
|
||||||
#include <Aeon/Includes.hpp>
|
|
||||||
|
|
||||||
#include <Aeon/Entity/Entity.hpp>
|
#include <Aeon/Entity/Entity.hpp>
|
||||||
|
#include <Aeon/Includes.hpp>
|
||||||
|
|
||||||
namespace EC
|
namespace EC
|
||||||
{
|
{
|
||||||
@@ -17,9 +16,9 @@ public:
|
|||||||
~EntityRegistry();
|
~EntityRegistry();
|
||||||
|
|
||||||
Entity Create();
|
Entity Create();
|
||||||
Entity Copy( const Entity entity );
|
Entity Copy(const Entity entity);
|
||||||
void Destroy( Entity entity );
|
void Destroy(Entity entity);
|
||||||
bool Valid( const Entity entity );
|
bool Valid(const Entity entity);
|
||||||
|
|
||||||
// add, replace components
|
// add, replace components
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
@@ -27,7 +26,7 @@ public:
|
|||||||
|
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
TComponent& Replace(const Entity entity);
|
TComponent& Replace(const Entity entity);
|
||||||
|
|
||||||
// replace in-place
|
// replace in-place
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
TComponent& Patch(const Entity entity);
|
TComponent& Patch(const Entity entity);
|
||||||
@@ -35,7 +34,7 @@ public:
|
|||||||
// Get component from entity based on T
|
// Get component from entity based on T
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
TComponent& Get(const Entity entity);
|
TComponent& Get(const Entity entity);
|
||||||
|
|
||||||
// Get std::optional from entity based on T
|
// Get std::optional from entity based on T
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
std::optional<TComponent&> Opt(const Entity entity);
|
std::optional<TComponent&> Opt(const Entity entity);
|
||||||
@@ -43,7 +42,7 @@ public:
|
|||||||
// TODO: Sort by component properties, for example list of
|
// TODO: Sort by component properties, for example list of
|
||||||
// entities with the renderable components, sorted by Y pos
|
// entities with the renderable components, sorted by Y pos
|
||||||
// of position component
|
// of position component
|
||||||
// template <typename T>
|
// template <typename T>
|
||||||
// std::vector<T&> Sort(std::function<;
|
// std::vector<T&> Sort(std::function<;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,7 +57,7 @@ private:
|
|||||||
// optimisations coming soon TM
|
// optimisations coming soon TM
|
||||||
std::unordered_map<Entity, std::vector<std::string>> mEntities;
|
std::unordered_map<Entity, std::vector<std::string>> mEntities;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace EC
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,76 +1,67 @@
|
|||||||
#include "Input.hpp"
|
#include "Input.hpp"
|
||||||
|
|
||||||
#include <Aeon/Includes.hpp>
|
|
||||||
|
|
||||||
#include <Aeon/Core/Events.hpp>
|
#include <Aeon/Core/Events.hpp>
|
||||||
|
#include <Aeon/Includes.hpp>
|
||||||
#include <Aeon/Input/InputMap.hpp>
|
#include <Aeon/Input/InputMap.hpp>
|
||||||
#include <Aeon/Rendering/ImGui.hpp>
|
#include <Aeon/Rendering/ImGui.hpp>
|
||||||
|
|
||||||
using Input::InputController;
|
using Input::InputController;
|
||||||
|
|
||||||
InputController::InputController()
|
InputController::InputController()
|
||||||
: mEvent()
|
: mEvent(), mDisplayEventDispatcher(), mKeyboardEventDispatcher(), mMouseEventDispatcher()
|
||||||
, mDisplayEventDispatcher()
|
|
||||||
, mKeyboardEventDispatcher()
|
|
||||||
, mMouseEventDispatcher()
|
|
||||||
{
|
{
|
||||||
mDisplayEventDispatcher.RegisterAsSource( "ENGINE_DISPLAY_CORE" );
|
mDisplayEventDispatcher.RegisterAsSource("ENGINE_DISPLAY_CORE");
|
||||||
mMouseEventDispatcher.RegisterAsSource( "ENGINE_INPUT_MOUSE" );
|
mMouseEventDispatcher.RegisterAsSource("ENGINE_INPUT_MOUSE");
|
||||||
mKeyboardEventDispatcher.RegisterAsSource( "ENGINE_INPUT_KEYBOARD" );
|
mKeyboardEventDispatcher.RegisterAsSource("ENGINE_INPUT_KEYBOARD");
|
||||||
|
|
||||||
mKbdState = static_cast<const uint8_t*>(SDL_GetKeyboardState( &mNumScancodes ));
|
mKbdState = static_cast<const uint8_t*>(SDL_GetKeyboardState(&mNumScancodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
InputController::~InputController()
|
InputController::~InputController()
|
||||||
{
|
{
|
||||||
mDisplayEventDispatcher.DeRegisterAsSource( "ENGINE_DISPLAY_CORE" );
|
mDisplayEventDispatcher.DeRegisterAsSource("ENGINE_DISPLAY_CORE");
|
||||||
mMouseEventDispatcher.DeRegisterAsSource( "ENGINE_INPUT_MOUSE" );
|
mMouseEventDispatcher.DeRegisterAsSource("ENGINE_INPUT_MOUSE");
|
||||||
mKeyboardEventDispatcher.DeRegisterAsSource( "ENGINE_INPUT_KEYBOARD" );
|
mKeyboardEventDispatcher.DeRegisterAsSource("ENGINE_INPUT_KEYBOARD");
|
||||||
|
|
||||||
// Do not free mKbdState as that is done by SDL
|
// Do not free mKbdState as that is done by SDL
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::PollInput()
|
void InputController::PollInput()
|
||||||
{
|
{
|
||||||
//SDL_PumpEvents();
|
// SDL_PumpEvents();
|
||||||
while ( SDL_PollEvent( &mEvent ) )
|
while (SDL_PollEvent(&mEvent))
|
||||||
{
|
{
|
||||||
// Provide to non-event driven subsystem
|
// Provide to non-event driven subsystem
|
||||||
ImGui_ImplSDL2_ProcessEvent( &mEvent );
|
ImGui_ImplSDL2_ProcessEvent(&mEvent);
|
||||||
|
|
||||||
switch ( mEvent.type )
|
switch (mEvent.type)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT: {
|
||||||
{
|
|
||||||
mPollDisplay();
|
mPollDisplay();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL: {
|
||||||
{
|
|
||||||
mPollScroll();
|
mPollScroll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP: {
|
||||||
{
|
|
||||||
mPollClick();
|
mPollClick();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION: {
|
||||||
{
|
|
||||||
mPollMouse();
|
mPollMouse();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP: {
|
||||||
{
|
|
||||||
mPollKeyboard();
|
mPollKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// just in case
|
// just in case
|
||||||
mKbdState = static_cast<const uint8_t*>(SDL_GetKeyboardState( &mNumScancodes ));
|
mKbdState = static_cast<const uint8_t*>(SDL_GetKeyboardState(&mNumScancodes));
|
||||||
|
|
||||||
// keyboard processing
|
// keyboard processing
|
||||||
mPollScanKeyboard();
|
mPollScanKeyboard();
|
||||||
@@ -78,69 +69,58 @@ void InputController::PollInput()
|
|||||||
|
|
||||||
void InputController::mPollDisplay()
|
void InputController::mPollDisplay()
|
||||||
{
|
{
|
||||||
switch ( mEvent.window.event )
|
switch (mEvent.window.event)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_SHOWN:
|
case SDL_WINDOWEVENT_SHOWN: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_SHOW");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_SHOW" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_HIDDEN:
|
case SDL_WINDOWEVENT_HIDDEN: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_HIDE");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_HIDE" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_MOVED:
|
case SDL_WINDOWEVENT_MOVED: {
|
||||||
{
|
|
||||||
Core::GenericEvent e;
|
Core::GenericEvent e;
|
||||||
e.x = mEvent.window.data1;
|
e.x = mEvent.window.data1;
|
||||||
e.y = mEvent.window.data2;
|
e.y = mEvent.window.data2;
|
||||||
e.Type = "DISPLAY_MOVE";
|
e.Type = "DISPLAY_MOVE";
|
||||||
mDisplayEventDispatcher.Dispatch( e );
|
mDisplayEventDispatcher.Dispatch(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED: {
|
||||||
{
|
|
||||||
Core::GenericEvent e;
|
Core::GenericEvent e;
|
||||||
e.x = mEvent.window.data1;
|
e.x = mEvent.window.data1;
|
||||||
e.y = mEvent.window.data2;
|
e.y = mEvent.window.data2;
|
||||||
e.Type = "DISPLAY_RESIZE";
|
e.Type = "DISPLAY_RESIZE";
|
||||||
mDisplayEventDispatcher.Dispatch( e );
|
mDisplayEventDispatcher.Dispatch(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_MINIMIZED:
|
case SDL_WINDOWEVENT_MINIMIZED: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_MINIMISED");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_MINIMISED" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
case SDL_WINDOWEVENT_MAXIMIZED: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_MAXIMISED");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_MAXIMISED" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_MOUSE_ENTER");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_MOUSE_ENTER" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_LEAVE:
|
case SDL_WINDOWEVENT_LEAVE: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_MOUSE_LEAVE");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_MOUSE_LEAVE" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_FOCUS");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_FOCUS" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_OUT_OF_FOCUS");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_OUT_OF_FOCUS" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
case SDL_WINDOWEVENT_CLOSE: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("DISPLAY_CLOSED");
|
||||||
mDisplayEventDispatcher.Dispatch( "DISPLAY_CLOSED" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +134,7 @@ void InputController::mPollMouse()
|
|||||||
e.dx = mEvent.motion.xrel;
|
e.dx = mEvent.motion.xrel;
|
||||||
e.dy = mEvent.motion.yrel;
|
e.dy = mEvent.motion.yrel;
|
||||||
e.Type = "MOUSE_MOVE";
|
e.Type = "MOUSE_MOVE";
|
||||||
mMouseEventDispatcher.Dispatch( e );
|
mMouseEventDispatcher.Dispatch(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::mPollScroll()
|
void InputController::mPollScroll()
|
||||||
@@ -162,49 +142,43 @@ void InputController::mPollScroll()
|
|||||||
Core::GenericEvent e;
|
Core::GenericEvent e;
|
||||||
e.y = mEvent.wheel.y;
|
e.y = mEvent.wheel.y;
|
||||||
e.Type = "MOUSE_SCROLL";
|
e.Type = "MOUSE_SCROLL";
|
||||||
mMouseEventDispatcher.Dispatch( e );
|
mMouseEventDispatcher.Dispatch(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::mPollClick()
|
void InputController::mPollClick()
|
||||||
{
|
{
|
||||||
if ( mEvent.button.state == SDL_PRESSED )
|
if (mEvent.button.state == SDL_PRESSED)
|
||||||
{
|
{
|
||||||
switch ( mEvent.button.button )
|
switch (mEvent.button.button)
|
||||||
{
|
{
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_LEFT_DOWN");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_LEFT_DOWN" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_BUTTON_RIGHT:
|
case SDL_BUTTON_RIGHT: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_RIGHT_DOWN");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_RIGHT_DOWN" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_MIDDLE: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_MIDDLE_DOWN");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_MIDDLE_DOWN" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( mEvent.button.state == SDL_RELEASED )
|
else if (mEvent.button.state == SDL_RELEASED)
|
||||||
{
|
{
|
||||||
switch ( mEvent.button.button )
|
switch (mEvent.button.button)
|
||||||
{
|
{
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_LEFT_UP");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_LEFT_UP" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_BUTTON_RIGHT:
|
case SDL_BUTTON_RIGHT: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_RIGHT_UP");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_RIGHT_UP" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_MIDDLE: {
|
||||||
{
|
mDisplayEventDispatcher.Dispatch("MOUSE_MIDDLE_UP");
|
||||||
mDisplayEventDispatcher.Dispatch( "MOUSE_MIDDLE_UP" );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,41 +187,41 @@ void InputController::mPollClick()
|
|||||||
|
|
||||||
void InputController::mPollKeyboard()
|
void InputController::mPollKeyboard()
|
||||||
{
|
{
|
||||||
EKeyCode keycode = KeyCodeFromSDL( mEvent.key.keysym.sym );
|
EKeyCode keycode = KeyCodeFromSDL(mEvent.key.keysym.sym);
|
||||||
Core::GenericEvent e;
|
Core::GenericEvent e;
|
||||||
e.keyCode = KeyCodeFromSDL(keycode);
|
e.keyCode = KeyCodeFromSDL(keycode);
|
||||||
if ( mEvent.key.state == SDL_PRESSED )
|
if (mEvent.key.state == SDL_PRESSED)
|
||||||
{
|
{
|
||||||
e.Type = "KEYBOARD_KEYDOWN";
|
e.Type = "KEYBOARD_KEYDOWN";
|
||||||
}
|
}
|
||||||
else if ( mEvent.key.state == SDL_RELEASED )
|
else if (mEvent.key.state == SDL_RELEASED)
|
||||||
{
|
{
|
||||||
e.Type = "KEYBOARD_KEYUP";
|
e.Type = "KEYBOARD_KEYUP";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t mods = mEvent.key.keysym.mod;
|
uint16_t mods = mEvent.key.keysym.mod;
|
||||||
e.keyMods = mods;
|
e.keyMods = mods;
|
||||||
|
|
||||||
mModKeyState = mods;
|
mModKeyState = mods;
|
||||||
|
|
||||||
mKeyboardEventDispatcher.Dispatch( e );
|
mKeyboardEventDispatcher.Dispatch(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::mPollScanKeyboard()
|
void InputController::mPollScanKeyboard()
|
||||||
{
|
{
|
||||||
//this is naive, can be optimised with double buffering
|
// this is naive, can be optimised with double buffering
|
||||||
for ( int i = 0; i < mNumScancodes; i++ )
|
for (int i = 0; i < mNumScancodes; i++)
|
||||||
{
|
{
|
||||||
bool isKeyPressed = (bool)mKbdState[i];
|
bool isKeyPressed = (bool)mKbdState[i];
|
||||||
if ( isKeyPressed )
|
if (isKeyPressed)
|
||||||
{
|
{
|
||||||
EKeyCode whatKeyPressed = KeyCodeFromScanCode( (SDL_Scancode)i );
|
EKeyCode whatKeyPressed = KeyCodeFromScanCode((SDL_Scancode)i);
|
||||||
|
|
||||||
Core::GenericEvent e;
|
Core::GenericEvent e;
|
||||||
e.keyCode = whatKeyPressed;
|
e.keyCode = whatKeyPressed;
|
||||||
e.keyMods = mModKeyState;
|
e.keyMods = mModKeyState;
|
||||||
e.Type = "KEYBOARD_KEYPRESS";
|
e.Type = "KEYBOARD_KEYPRESS";
|
||||||
mKeyboardEventDispatcher.Dispatch( e );
|
mKeyboardEventDispatcher.Dispatch(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
0
Aeon/Rendering/Material.cpp
Normal file
0
Aeon/Rendering/Material.cpp
Normal file
0
Aeon/Rendering/Material.hpp
Normal file
0
Aeon/Rendering/Material.hpp
Normal file
0
Aeon/Rendering/Mesh.cpp
Normal file
0
Aeon/Rendering/Mesh.cpp
Normal file
0
Aeon/Rendering/Mesh.hpp
Normal file
0
Aeon/Rendering/Mesh.hpp
Normal file
@@ -11,12 +11,13 @@ namespace Rendering
|
|||||||
class RenderMaster : public Helpers::Singleton<Rendering::RenderMaster>
|
class RenderMaster : public Helpers::Singleton<Rendering::RenderMaster>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderMaster();
|
RenderMaster();
|
||||||
|
|
||||||
|
void QueueRenderable(Renderable* renderable);
|
||||||
|
|
||||||
|
|
||||||
void QueueRenderable( Renderable* renderable );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Rendering
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
0
Aeon/Rendering/Renderable.cpp
Normal file
0
Aeon/Rendering/Renderable.cpp
Normal file
@@ -1,197 +0,0 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
|
|
||||||
#.rst:
|
|
||||||
# FindSDL2
|
|
||||||
# -------
|
|
||||||
#
|
|
||||||
# Locate SDL2 library
|
|
||||||
#
|
|
||||||
# This module defines
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# SDL2_LIBRARY, the name of the library to link against
|
|
||||||
# SDL2_FOUND, if false, do not try to link to SDL
|
|
||||||
# SDL2_INCLUDE_DIR, where to find SDL.h
|
|
||||||
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# This module responds to the flag:
|
|
||||||
#
|
|
||||||
# ::
|
|
||||||
#
|
|
||||||
# SDL2_BUILDING_LIBRARY
|
|
||||||
# If this is defined, then no SDL2_main will be linked in because
|
|
||||||
# only applications need main().
|
|
||||||
# Otherwise, it is assumed you are building an application and this
|
|
||||||
# module will attempt to locate and set the proper link flags
|
|
||||||
# as part of the returned SDL2_LIBRARY variable.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
|
||||||
# OS X framework based version. (Other versions link to -lSDLmain which
|
|
||||||
# this module will try to find on your behalf.) Also for OS X, this
|
|
||||||
# module will automatically add the -framework Cocoa on your behalf.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
|
|
||||||
# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
|
|
||||||
# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
|
|
||||||
# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
|
|
||||||
# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
|
|
||||||
# value as appropriate. These values are used to generate the final
|
|
||||||
# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
|
|
||||||
# does not get created.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# $SDL2DIR is an environment variable that would correspond to the
|
|
||||||
# ./configure --prefix=$SDL2DIR used in building SDL. l.e.galup 9-20-02
|
|
||||||
#
|
|
||||||
# Modified by Eric Wing. Added code to assist with automated building
|
|
||||||
# by using environmental variables and providing a more
|
|
||||||
# controlled/consistent search behavior. Added new modifications to
|
|
||||||
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
|
||||||
# Also corrected the header search path to follow "proper" SDL
|
|
||||||
# guidelines. Added a search for SDLmain which is needed by some
|
|
||||||
# platforms. Added a search for threads which is needed by some
|
|
||||||
# platforms. Added needed compile switches for MinGW.
|
|
||||||
#
|
|
||||||
# On OSX, this will prefer the Framework version (if found) over others.
|
|
||||||
# People will have to manually change the cache values of SDL2_LIBRARY to
|
|
||||||
# override this selection or set the CMake environment
|
|
||||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
|
||||||
#
|
|
||||||
# Note that the header path has changed from SDL/SDL.h to just SDL.h
|
|
||||||
# This needed to change because "proper" SDL convention is #include
|
|
||||||
# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
|
||||||
# because not all systems place things in SDL/ (see FreeBSD).
|
|
||||||
|
|
||||||
if(NOT SDL2_DIR)
|
|
||||||
set(SDL2_DIR "" CACHE PATH "SDL2 directory")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
|
||||||
HINTS
|
|
||||||
ENV SDL2DIR
|
|
||||||
${SDL2_DIR}
|
|
||||||
PATH_SUFFIXES SDL2
|
|
||||||
# path suffixes to search inside ENV{SDL2DIR}
|
|
||||||
include/SDL2 include
|
|
||||||
)
|
|
||||||
|
|
||||||
# AWLAYS 64 bit
|
|
||||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
|
||||||
|
|
||||||
find_library(SDL2_LIBRARY_TEMP
|
|
||||||
NAMES SDL2
|
|
||||||
HINTS
|
|
||||||
ENV SDL2DIR
|
|
||||||
${SDL2_DIR}
|
|
||||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Hide this cache variable from the user, it's an internal implementation
|
|
||||||
# detail. The documented library variable for the user is SDL2_LIBRARY
|
|
||||||
# which is derived from SDL2_LIBRARY_TEMP further below.
|
|
||||||
set_property(CACHE SDL2_LIBRARY_TEMP PROPERTY TYPE INTERNAL)
|
|
||||||
|
|
||||||
if(NOT SDL2_BUILDING_LIBRARY)
|
|
||||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
|
||||||
# Non-OS X framework versions expect you to also dynamically link to
|
|
||||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
|
||||||
# seem to provide SDLmain for compatibility even though they don't
|
|
||||||
# necessarily need it.
|
|
||||||
find_library(SDL2MAIN_LIBRARY
|
|
||||||
NAMES SDL2main
|
|
||||||
HINTS
|
|
||||||
ENV SDL2DIR
|
|
||||||
${SDL2_DIR}
|
|
||||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
|
||||||
PATHS
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# SDL may require threads on your system.
|
|
||||||
# The Apple build may not need an explicit flag because one of the
|
|
||||||
# frameworks may already provide it.
|
|
||||||
# But for non-OSX systems, I will use the CMake Threads package.
|
|
||||||
if(NOT APPLE)
|
|
||||||
find_package(Threads)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# MinGW needs an additional link flag, -mwindows
|
|
||||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -mwindows
|
|
||||||
if(MINGW)
|
|
||||||
set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SDL2_LIBRARY_TEMP)
|
|
||||||
# For SDLmain
|
|
||||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
|
||||||
list(FIND SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
|
||||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
|
||||||
set(SDL2_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
|
|
||||||
endif()
|
|
||||||
unset(_SDL2_MAIN_INDEX)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
|
||||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
|
||||||
# though it actually is there if I modify a pre-used variable.
|
|
||||||
# I think it has something to do with the CACHE STRING.
|
|
||||||
# So I use a temporary variable until the end so I can set the
|
|
||||||
# "real" variable in one-shot.
|
|
||||||
if(APPLE)
|
|
||||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# For threads, as mentioned Apple doesn't need this.
|
|
||||||
# In fact, there seems to be a problem if I used the Threads package
|
|
||||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
|
||||||
if(NOT APPLE)
|
|
||||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# For MinGW library
|
|
||||||
if(MINGW)
|
|
||||||
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Set the final string here so the GUI reflects the final state.
|
|
||||||
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL2_version.h")
|
|
||||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+[0-9]+$")
|
|
||||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+[0-9]+$")
|
|
||||||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+[0-9]+$")
|
|
||||||
string(REGEX REPLACE "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
|
|
||||||
string(REGEX REPLACE "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
|
|
||||||
string(REGEX REPLACE "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
|
|
||||||
set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH})
|
|
||||||
unset(SDL2_VERSION_MAJOR_LINE)
|
|
||||||
unset(SDL2_VERSION_MINOR_LINE)
|
|
||||||
unset(SDL2_VERSION_PATCH_LINE)
|
|
||||||
unset(SDL2_VERSION_MAJOR)
|
|
||||||
unset(SDL2_VERSION_MINOR)
|
|
||||||
unset(SDL2_VERSION_PATCH)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(SDL2_LIBRARIES ${SDL2_LIBRARY} ${SDL2MAIN_LIBRARY})
|
|
||||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
|
|
||||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
|
||||||
VERSION_VAR SDL2_VERSION_STRING)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "x64-Debug",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"configurationType": "Debug",
|
|
||||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
|
||||||
"cmakeCommandArgs": "-DSDL2_PATH=\"C:/Users/benja/Programming/lib/SDL2-2.0.16/\"",
|
|
||||||
"buildCommandArgs": "-v",
|
|
||||||
"ctestCommandArgs": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "x64-Release",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"configurationType": "RelWithDebInfo",
|
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
|
||||||
"cmakeCommandArgs": "-DSDL2_DIR=\"C:/Users/benja/Programming/lib/SDL2-2.0.16/\"",
|
|
||||||
"buildCommandArgs": "-v",
|
|
||||||
"ctestCommandArgs": "",
|
|
||||||
"inheritEnvironments": [ "msvc_x64_x64" ]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user