mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[client] added support for alert text
This commit is contained in:
parent
86207993b8
commit
b26a535451
@ -60,6 +60,7 @@ typedef LG_RendererOpt * LG_RendererOptions;
|
||||
typedef struct LG_RendererParams
|
||||
{
|
||||
TTF_Font * font;
|
||||
TTF_Font * alertFont;
|
||||
bool showFPS;
|
||||
}
|
||||
LG_RendererParams;
|
||||
|
@ -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,48 +717,53 @@ int run()
|
||||
// SIGINT and the user sending a close event, such as ALT+F4
|
||||
signal(SIGINT, intHandler);
|
||||
|
||||
if (params.showFPS)
|
||||
if (TTF_Init() < 0)
|
||||
{
|
||||
if (TTF_Init() < 0)
|
||||
{
|
||||
DEBUG_ERROR("TTL_Init Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FcConfig * config = FcInitLoadConfigAndFonts();
|
||||
if (!config)
|
||||
{
|
||||
DEBUG_ERROR("FcInitLoadConfigAndFonts Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FcPattern * pat = FcNameParse((const FcChar8*)"FreeMono");
|
||||
FcConfigSubstitute (config, pat, FcMatchPattern);
|
||||
FcDefaultSubstitute(pat);
|
||||
FcResult result;
|
||||
FcChar8 * file = NULL;
|
||||
FcPattern * font = FcFontMatch(config, pat, &result);
|
||||
|
||||
if (font && (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch))
|
||||
{
|
||||
state.font = TTF_OpenFont((char *)file, 14);
|
||||
if (!state.font)
|
||||
{
|
||||
DEBUG_ERROR("TTL_OpenFont Failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_ERROR("Failed to locate a font for FPS display");
|
||||
return -1;
|
||||
}
|
||||
FcPatternDestroy(pat);
|
||||
DEBUG_ERROR("TTL_Init Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FcConfig * config = FcInitLoadConfigAndFonts();
|
||||
if (!config)
|
||||
{
|
||||
DEBUG_ERROR("FcInitLoadConfigAndFonts Failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FcPattern * pat = FcNameParse((const FcChar8*)"FreeMono");
|
||||
FcConfigSubstitute (config, pat, FcMatchPattern);
|
||||
FcDefaultSubstitute(pat);
|
||||
FcResult result;
|
||||
FcChar8 * file = NULL;
|
||||
FcPattern * font = FcFontMatch(config, pat, &result);
|
||||
|
||||
if (font && (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch))
|
||||
{
|
||||
state.font = TTF_OpenFont((char *)file, 14);
|
||||
if (!state.font)
|
||||
{
|
||||
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 text display");
|
||||
return -1;
|
||||
}
|
||||
FcPatternDestroy(pat);
|
||||
|
||||
LG_RendererParams lgrParams;
|
||||
lgrParams.font = state.font;
|
||||
lgrParams.showFPS = params.showFPS;
|
||||
lgrParams.font = state.font;
|
||||
lgrParams.alertFont = state.alertFont;
|
||||
lgrParams.showFPS = params.showFPS;
|
||||
Uint32 sdlFlags;
|
||||
|
||||
if (params.forceRenderer)
|
||||
|
Loading…
Reference in New Issue
Block a user