cleaned up code with themeInfo config, now looks a lot better
This commit is contained in:
parent
0f95009b51
commit
d79d501bcb
@ -298,27 +298,35 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
|||||||
config_t cfg = {0};
|
config_t cfg = {0};
|
||||||
config_init(&cfg);
|
config_init(&cfg);
|
||||||
config_setting_t *themeInfo;
|
config_setting_t *themeInfo;
|
||||||
char author[ENTRY_AUTHORLENGTH]={0}, themeVersion[ENTRY_VERLENGTH]={0}, name[ENTRY_NAMELENGTH]={0};
|
const char *name, *author, *version;
|
||||||
bool noName = true, noAuthor = true, noVersion = true;
|
bool noAuth = false, noVers = false;
|
||||||
if(config_read_file(&cfg, me->path)) {
|
if(config_read_file(&cfg, me->path)) {
|
||||||
themeInfo = config_lookup(&cfg, "themeInfo");
|
themeInfo = config_lookup(&cfg, "themeInfo");
|
||||||
if (themeInfo != NULL) {
|
if (themeInfo != NULL) {
|
||||||
strncpy(name, config_setting_get_string(config_setting_lookup(themeInfo, "name")), sizeof(name)-1);
|
if(config_setting_lookup_string(themeInfo, "name", &name))
|
||||||
if(name[0]!='\0') noName = false;
|
|
||||||
strncpy(author, config_setting_get_string(config_setting_lookup(themeInfo, "author")), sizeof(author)-1);
|
|
||||||
if(author[0]!='\0') noAuthor = false;
|
|
||||||
/*strncpy(themeVersion, config_setting_get_string(config_setting_lookup(themeInfo, "version")), sizeof(themeVersion)-1);
|
|
||||||
if(themeVersion[0]!='\0') noVersion = false;*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(noAuthor)
|
|
||||||
strncpy(author,"unknown", sizeof(author)-1);
|
|
||||||
if(noVersion)
|
|
||||||
strncpy(themeVersion,"1.0.0", sizeof(themeVersion)-1);
|
|
||||||
strncpy(me->author, author, sizeof(me->author)-1);
|
|
||||||
strncpy(me->version, themeVersion, sizeof(me->version)-1);
|
|
||||||
if(!noName)
|
|
||||||
strncpy(me->name, name, sizeof(me->name)-1);
|
strncpy(me->name, name, sizeof(me->name)-1);
|
||||||
|
if(!config_setting_lookup_string(themeInfo, "author", &author))
|
||||||
|
noAuth = true;
|
||||||
|
if(!config_setting_lookup_string(themeInfo, "version", &version))\
|
||||||
|
noVers = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noAuth = true;
|
||||||
|
noVers = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noAuth = true;
|
||||||
|
noVers = true;
|
||||||
|
}
|
||||||
|
if(noAuth)
|
||||||
|
strncpy(me->author, textGetString(StrId_DefaultPublisher), sizeof(me->author)-1);
|
||||||
|
else
|
||||||
|
strncpy(me->author, author, sizeof(me->author)-1);
|
||||||
|
if(noVers)
|
||||||
|
strncpy(me->version, "1.0.0", sizeof(me->version)-1);
|
||||||
|
else
|
||||||
|
strncpy(me->version, version, sizeof(me->version)-1);
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user