Add SDL2 support
This commit is contained in:
@ -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);
|
||||
|
||||
28
include/TessesFramework/SDL2/FontCache.hpp
Normal file
28
include/TessesFramework/SDL2/FontCache.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#if defined(TESSESFRAMEWORK_ENABLE_SDL2)
|
||||
#include <array>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
namespace Tesses::Framework::SDL2
|
||||
{
|
||||
class FontCache
|
||||
{
|
||||
std::array<SDL_Texture*,96> font_chrs;
|
||||
int mw,mh,ps;
|
||||
void Load(SDL_Renderer* renderer,TTF_Font* font,const SDL_Color& color);
|
||||
public:
|
||||
FontCache(SDL_Renderer* renderer,TTF_Font* font,const SDL_Color& color);
|
||||
FontCache(SDL_Renderer* renderer,std::string font,int sz,const SDL_Color& color);
|
||||
FontCache(SDL_Renderer* renderer,const uint8_t* mem,size_t cnt,int sz,const SDL_Color& color);
|
||||
FontCache(SDL_Renderer* renderer,const std::vector<uint8_t>& v,int sz,const SDL_Color& color);
|
||||
|
||||
SDL_Texture* operator[](char c);
|
||||
int MaxWidth();
|
||||
int MaxHeight();
|
||||
int PointSize();
|
||||
~FontCache();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@ -27,4 +27,5 @@
|
||||
#include "Lazy.hpp"
|
||||
#include "Mail/Smtp.hpp"
|
||||
#include "HiddenField.hpp"
|
||||
#include "Serialization/Json.hpp"
|
||||
#include "Serialization/Json.hpp"
|
||||
#include "SDL2/FontCache.hpp"
|
||||
Reference in New Issue
Block a user