Add SDL2 support

This commit is contained in:
2025-06-07 02:41:14 -05:00
parent 8dc8b9ea86
commit dd4527645e
9 changed files with 188 additions and 4 deletions

View File

@ -8,7 +8,7 @@
#include <map>
#include <vector>
#include <functional>
#include "Threading/Mutex.hpp"
class TextException : public std::exception {
std::string error_message;
@ -52,18 +52,22 @@ namespace Tesses::Framework
template<typename...TArgs>
class EventList : public Event<TArgs...> {
Threading::Mutex mtx;
std::vector<std::shared_ptr<Event<TArgs...>>> items;
public:
void operator+=(std::shared_ptr<Event<TArgs...>> event)
{
mtx.Lock();
for(std::shared_ptr<Event<TArgs...>>& item : this->items)
{
if(item.get() == event.get()) return;
}
this->items.push_back(event);
mtx.Unlock();
}
void operator-=(std::shared_ptr<Event<TArgs...>> event)
{
mtx.Lock();
for(auto i = this->items.begin(); i != this->items.end(); i++)
{
if(i->get() == event.get())
@ -72,13 +76,16 @@ namespace Tesses::Framework
return;
}
}
mtx.Lock();
}
void Invoke(TArgs... args)
{
mtx.Lock();
for(auto& item : this->items)
{
item->Invoke(args...);
}
mtx.Unlock();
}
};
@ -89,6 +96,7 @@ namespace Tesses::Framework
void TF_RunEventLoop();
void TF_RunEventLoopItteration();
bool TF_IsRunning();
void TF_SetIsRunning(bool _isRunning);
void TF_Quit();
bool TF_GetConsoleEventsEnabled();
void TF_SetConsoleEventsEnabled(bool flag);