[client] added support for alert text

This commit is contained in:
Geoffrey McRae 2018-05-29 11:06:42 +10:00
parent 86207993b8
commit b26a535451
2 changed files with 46 additions and 39 deletions

View File

@ -60,6 +60,7 @@ typedef LG_RendererOpt * LG_RendererOptions;
typedef struct LG_RendererParams
{
TTF_Font * font;
TTF_Font * alertFont;
bool showFPS;
}
LG_RendererParams;

View File

@ -52,6 +52,7 @@ struct AppState
bool keyDown[SDL_NUM_SCANCODES];
TTF_Font * font;
TTF_Font * alertFont;
SDL_Point srcSize;
LG_RendererRect dstRect;
SDL_Point cursor;
@ -529,7 +530,7 @@ int eventFilter(void * userdata, SDL_Event * event)
if (state.lgr)
state.lgr->on_alert(
state.lgrData,
LG_ALERT_INFO,
serverMode ? LG_ALERT_SUCCESS : LG_ALERT_WARNING,
serverMode ? "Capture Enabled" : "Capture Disabled"
);
@ -716,8 +717,6 @@ int run()
// SIGINT and the user sending a close event, such as ALT+F4
signal(SIGINT, intHandler);
if (params.showFPS)
{
if (TTF_Init() < 0)
{
DEBUG_ERROR("TTL_Init Failed");
@ -746,17 +745,24 @@ int run()
DEBUG_ERROR("TTL_OpenFont Failed");
return -1;
}
state.alertFont = TTF_OpenFont((char *)file, 18);
if (!state.alertFont)
{
DEBUG_ERROR("TTL_OpenFont Failed");
return -1;
}
}
else
{
DEBUG_ERROR("Failed to locate a font for FPS display");
DEBUG_ERROR("Failed to locate a font for text display");
return -1;
}
FcPatternDestroy(pat);
}
LG_RendererParams lgrParams;
lgrParams.font = state.font;
lgrParams.alertFont = state.alertFont;
lgrParams.showFPS = params.showFPS;
Uint32 sdlFlags;