mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-29 15:12:19 +00:00
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)
|
||||
{
|
||||
qbyte line[1024];
|
||||
char nam[64];
|
||||
char rep[64];
|
||||
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);
|
||||
if (json)
|
||||
{
|
||||
char *unified;
|
||||
for (unified = json; (unified = strstr(unified, ",\"unified\":\"")); )
|
||||
//eg: { "utf8":{"slug":"text_for_emoji"}, ... } (there's a few other keys*/
|
||||
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;
|
||||
char *t;
|
||||
char *sn;
|
||||
unsigned int u;
|
||||
unified += 12;
|
||||
t = unified;
|
||||
//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)
|
||||
int e;
|
||||
const char *o;
|
||||
utf8_decode(&e, def->name, &o);
|
||||
if (*o)
|
||||
continue; //we can only cope with single codepoints.
|
||||
if (JSON_GetString(def, "slug", nam+1, sizeof(nam)-2, NULL))
|
||||
{
|
||||
sn += 15;
|
||||
while (sn && *sn == '\"')
|
||||
{
|
||||
sn = COM_ParseTokenOut(sn, NULL, nam+1, sizeof(nam)-1, NULL);
|
||||
nam[0] = ':';
|
||||
Q_strncatz(nam, ":", sizeof(nam));
|
||||
line[0] = strlen(nam);
|
||||
line[1] = strlen(rep);
|
||||
line[1] = strlen(def->name);
|
||||
strcpy(line+2, nam);
|
||||
strcpy(line+2+line[0], rep);
|
||||
strcpy(line+2+line[0], def->name);
|
||||
Z_StrCat((char**)&emojidata, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON_Destroy(root);
|
||||
FS_FreeFile(json);
|
||||
}
|
||||
|
||||
|
|
|
@ -1062,7 +1062,7 @@ qboolean GLBE_BeginShadowMap(int id, int w, int h, uploadfmt_t encoding, int *re
|
|||
texid_t tex;
|
||||
if (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->height = h;
|
||||
tex->format = encoding;
|
||||
|
|
Loading…
Reference in a new issue