Use our json parser to make sense of emoji names instead of our previously hacked up mess.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6201 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
1af4e05ab6
commit
1fd65cc80d
2 changed files with 21 additions and 35 deletions
|
@ -1357,49 +1357,35 @@ static const qbyte *builtinemojidata =
|
||||||
static void Key_LoadEmojiList(void)
|
static void Key_LoadEmojiList(void)
|
||||||
{
|
{
|
||||||
qbyte line[1024];
|
qbyte line[1024];
|
||||||
char nam[64];
|
|
||||||
char rep[64];
|
|
||||||
vfsfile_t *f;
|
vfsfile_t *f;
|
||||||
char *json = FS_MallocFile("emoji.json", FS_GAME, NULL); //https://unicodey.com/emoji-data/emoji.json
|
char *json = FS_MallocFile("data-by-emoji.json", FS_GAME, NULL); //https://unpkg.com/unicode-emoji-json/data-by-emoji.json
|
||||||
|
|
||||||
emojidata = Z_StrDup(builtinemojidata);
|
emojidata = Z_StrDup(builtinemojidata);
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
char *unified;
|
//eg: { "utf8":{"slug":"text_for_emoji"}, ... } (there's a few other keys*/
|
||||||
for (unified = json; (unified = strstr(unified, ",\"unified\":\"")); )
|
json_t *root = JSON_Parse(json);
|
||||||
|
json_t *def;
|
||||||
|
char nam[64];
|
||||||
|
for (def = (root?root->child:NULL); def; def = def->sibling)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int e;
|
||||||
char *t;
|
const char *o;
|
||||||
char *sn;
|
utf8_decode(&e, def->name, &o);
|
||||||
unsigned int u;
|
if (*o)
|
||||||
unified += 12;
|
continue; //we can only cope with single codepoints.
|
||||||
t = unified;
|
if (JSON_GetString(def, "slug", nam+1, sizeof(nam)-2, NULL))
|
||||||
//do
|
|
||||||
//{
|
|
||||||
u = strtol(t, &t, 16);
|
|
||||||
i += utf8_encode(rep+i, u, countof(rep)-i);
|
|
||||||
//} while (i < countof(rep) && *t++ == '-');
|
|
||||||
if (*t!='\"')
|
|
||||||
continue;
|
|
||||||
rep[i] = 0;
|
|
||||||
|
|
||||||
sn = strstr(unified, "\"short_names\":[");
|
|
||||||
if (sn)
|
|
||||||
{
|
{
|
||||||
sn += 15;
|
|
||||||
while (sn && *sn == '\"')
|
|
||||||
{
|
|
||||||
sn = COM_ParseTokenOut(sn, NULL, nam+1, sizeof(nam)-1, NULL);
|
|
||||||
nam[0] = ':';
|
nam[0] = ':';
|
||||||
Q_strncatz(nam, ":", sizeof(nam));
|
Q_strncatz(nam, ":", sizeof(nam));
|
||||||
line[0] = strlen(nam);
|
line[0] = strlen(nam);
|
||||||
line[1] = strlen(rep);
|
line[1] = strlen(def->name);
|
||||||
strcpy(line+2, nam);
|
strcpy(line+2, nam);
|
||||||
strcpy(line+2+line[0], rep);
|
strcpy(line+2+line[0], def->name);
|
||||||
Z_StrCat((char**)&emojidata, line);
|
Z_StrCat((char**)&emojidata, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
JSON_Destroy(root);
|
||||||
FS_FreeFile(json);
|
FS_FreeFile(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1062,7 +1062,7 @@ qboolean GLBE_BeginShadowMap(int id, int w, int h, uploadfmt_t encoding, int *re
|
||||||
texid_t tex;
|
texid_t tex;
|
||||||
if (shadowmap[id])
|
if (shadowmap[id])
|
||||||
Image_DestroyTexture(shadowmap[id]);
|
Image_DestroyTexture(shadowmap[id]);
|
||||||
tex = shadowmap[id] = Image_CreateTexture(va("***shadowmap2d%i***", id), NULL, IF_NOPURGE);
|
tex = shadowmap[id] = Image_CreateTexture(va("***shadowmap2d%i***", id), NULL, IF_NOPURGE|IF_CLAMP|IF_NOMIPMAP|IF_RENDERTARGET);
|
||||||
tex->width = w;
|
tex->width = w;
|
||||||
tex->height = h;
|
tex->height = h;
|
||||||
tex->format = encoding;
|
tex->format = encoding;
|
||||||
|
|
Loading…
Reference in a new issue