mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] splash: added LG url, version and copyright strings
This commit is contained in:
parent
56ec98524c
commit
aba8c5b499
@ -26,10 +26,15 @@
|
|||||||
#include "overlay_utils.h"
|
#include "overlay_utils.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
#include "common/appstrings.h"
|
||||||
|
#include "common/stringlist.h"
|
||||||
|
#include "common/stringutils.h"
|
||||||
|
|
||||||
#include "resources/lg-logo.svg.h"
|
#include "resources/lg-logo.svg.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#define SEGMENTS 12
|
#define SEGMENTS 12
|
||||||
|
|
||||||
@ -38,6 +43,8 @@ static bool l_fadeDone;
|
|||||||
static float l_alpha;
|
static float l_alpha;
|
||||||
static OverlayImage l_logo;
|
static OverlayImage l_logo;
|
||||||
static float l_vectors[SEGMENTS][2];
|
static float l_vectors[SEGMENTS][2];
|
||||||
|
static StringList l_tagline;
|
||||||
|
static StringList l_footline;
|
||||||
|
|
||||||
static void calcRadialVectors(float vectors[][2], int segments)
|
static void calcRadialVectors(float vectors[][2], int segments)
|
||||||
{
|
{
|
||||||
@ -86,12 +93,63 @@ static bool splash_init(void ** udata, const void * params)
|
|||||||
|
|
||||||
overlayLoadSVG(b_lg_logo_svg, b_lg_logo_svg_size, &l_logo, 200, 200);
|
overlayLoadSVG(b_lg_logo_svg, b_lg_logo_svg_size, &l_logo, 200, 200);
|
||||||
calcRadialVectors(l_vectors, ARRAY_LENGTH(l_vectors));
|
calcRadialVectors(l_vectors, ARRAY_LENGTH(l_vectors));
|
||||||
|
|
||||||
|
l_tagline = stringlist_new(false);
|
||||||
|
l_footline = stringlist_new(false);
|
||||||
|
|
||||||
|
stringlist_push(l_tagline, "Looking Glass");
|
||||||
|
stringlist_push(l_tagline, (char *)LG_WEBSITE_URL);
|
||||||
|
|
||||||
|
stringlist_push(l_footline, (char *)LG_VERSION_STR);
|
||||||
|
stringlist_push(l_footline, (char *)LG_COPYRIGHT_STR);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void splash_free(void * udata)
|
static void splash_free(void * udata)
|
||||||
{
|
{
|
||||||
overlayFreeImage(&l_logo);
|
overlayFreeImage(&l_logo);
|
||||||
|
stringlist_free(&l_tagline );
|
||||||
|
stringlist_free(&l_footline);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void renderText(ImDrawList * list, int x, int y, ImU32 color,
|
||||||
|
StringList lines, bool topAlign)
|
||||||
|
{
|
||||||
|
static float textHeight = 0.0f;
|
||||||
|
ImVec2 size;
|
||||||
|
|
||||||
|
if (textHeight == 0.0f)
|
||||||
|
{
|
||||||
|
const char * tmp = "W";
|
||||||
|
igCalcTextSize(&size, tmp, tmp + 1, false, 0.0f);
|
||||||
|
textHeight = size.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
float fy = y;
|
||||||
|
const unsigned int count = stringlist_count(lines);
|
||||||
|
for(int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
const char * text = stringlist_at(lines, topAlign ? i : count - i - 1);
|
||||||
|
const int len = strlen(text);
|
||||||
|
|
||||||
|
igCalcTextSize(&size, text, text + len, false, 0.0f);
|
||||||
|
ImDrawList_AddText_Vec2(
|
||||||
|
list,
|
||||||
|
(ImVec2){
|
||||||
|
x - size.x / 2,
|
||||||
|
topAlign ? fy : fy - size.y
|
||||||
|
},
|
||||||
|
color,
|
||||||
|
text,
|
||||||
|
text + len
|
||||||
|
);
|
||||||
|
|
||||||
|
if (topAlign)
|
||||||
|
fy += textHeight;
|
||||||
|
else
|
||||||
|
fy -= textHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int splash_render(void * udata, bool interactive, struct Rect * windowRects,
|
static int splash_render(void * udata, bool interactive, struct Rect * windowRects,
|
||||||
@ -124,6 +182,8 @@ static int splash_render(void * udata, bool interactive, struct Rect * windowRec
|
|||||||
0.0f, 0.0f, 0.0f, alpha});
|
0.0f, 0.0f, 0.0f, alpha});
|
||||||
const ImU32 imageColor = igColorConvertFloat4ToU32((ImVec4){
|
const ImU32 imageColor = igColorConvertFloat4ToU32((ImVec4){
|
||||||
1.0f, 1.0f, 1.0f, alpha});
|
1.0f, 1.0f, 1.0f, alpha});
|
||||||
|
const ImU32 fontColor = igColorConvertFloat4ToU32((ImVec4){
|
||||||
|
0.8f, 0.8f, 0.8f, alpha});
|
||||||
|
|
||||||
drawRadialGradient(list,
|
drawRadialGradient(list,
|
||||||
screen->x / 2, screen->y / 2,
|
screen->x / 2, screen->y / 2,
|
||||||
@ -148,6 +208,20 @@ static int splash_render(void * udata, bool interactive, struct Rect * windowRec
|
|||||||
(ImVec2){ 1, 1 },
|
(ImVec2){ 1, 1 },
|
||||||
imageColor);
|
imageColor);
|
||||||
|
|
||||||
|
renderText(list,
|
||||||
|
screen->x / 2,
|
||||||
|
logoRect.y + logoRect.h + 10,
|
||||||
|
fontColor,
|
||||||
|
l_tagline,
|
||||||
|
true);
|
||||||
|
|
||||||
|
renderText(list,
|
||||||
|
screen->x / 2,
|
||||||
|
screen->y - 10,
|
||||||
|
fontColor,
|
||||||
|
l_footline,
|
||||||
|
false);
|
||||||
|
|
||||||
*windowRects = rect;
|
*windowRects = rect;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user