Exemplo n.º 1
0
void createMenuEntryShortcut(menu_s* m, shortcut_s* s)
{
    if(!m || !s)return;

    static menuEntry_s tmpEntry;
    static smdh_s tmpSmdh;

    char* execPath = s->executable;

    if(!fileExists(execPath, &sdmcArchive))return;

    int i, l=-1; for(i=0; execPath[i]; i++) if(execPath[i]=='/') l=i;

    char* iconPath = s->icon;
    int ret = loadFile(iconPath, &tmpSmdh, &sdmcArchive, sizeof(smdh_s));

    if(!ret)
    {
        initEmptyMenuEntry(&tmpEntry);
        ret = extractSmdhData(&tmpSmdh, tmpEntry.name, tmpEntry.description, tmpEntry.author, tmpEntry.iconData);
        strncpy(tmpEntry.executablePath, execPath, ENTRY_PATHLENGTH);
    }

    if(ret) initMenuEntry(&tmpEntry, execPath, &execPath[l+1], execPath, "Unknown publisher", (u8*)installerIcon_bin);

    if(s->name) strncpy(tmpEntry.name, s->name, ENTRY_NAMELENGTH);
    if(s->description) strncpy(tmpEntry.description, s->description, ENTRY_DESCLENGTH);
    if(s->author) strncpy(tmpEntry.author, s->author, ENTRY_AUTHORLENGTH);

    if(s->arg)
    {
        strncpy(tmpEntry.arg, s->arg, ENTRY_ARGLENGTH);
    }

    if(fileExists(s->descriptor, &sdmcArchive)) loadDescriptor(&tmpEntry.descriptor, s->descriptor);

    tmpEntry.isShortcut = true;

    if (s->hasBanner) {
        strcpy(tmpEntry.bannerImagePath, s->bannerImagePath);
        tmpEntry.bannerIsFullScreen = s->bannerIsFullScreen;
    }
    else {
        tmpEntry.bannerImagePath[0] = '\0';
    }

    tmpEntry.hasBanner = s->hasBanner;

    addMenuEntryCopy(m, &tmpEntry);
}
Exemplo n.º 2
0
void initMenuEntry(menuEntry_s* me, char* execPath, char* name, char* description, char* author, u8* iconData, menuEntryType_s type)
{
	if(!me)return;

	initEmptyMenuEntry(me);

	strncpy(me->executablePath, execPath, ENTRY_PATHLENGTH);
	strncpy(me->name, name, ENTRY_NAMELENGTH);
	strncpy(me->description, description, ENTRY_DESCLENGTH);
	strncpy(me->author, author, ENTRY_AUTHORLENGTH);
	me->type = type;
	if(iconData)memcpy(me->iconData, iconData, ENTRY_ICONSIZE);

	initDescriptor(&me->descriptor);
}
Exemplo n.º 3
0
void addDirectoryToMenu(menu_s* m, char* path)
{
	if(!m || !path)return;

	static menuEntry_s tmpEntry;
	static smdh_s tmpSmdh;
	static char execPath[128];
	static char iconPath[128];
	static char xmlPath[128];

	int i, l=-1; for(i=0; path[i]; i++) if(path[i]=='/') l=i;

	snprintf(execPath, 128, "%s/boot.3dsx", path);
	if(!fileExists(execPath, &sdmcArchive))
	{
		snprintf(execPath, 128, "%s/%s.3dsx", path, &path[l+1]);
		if(!fileExists(execPath, &sdmcArchive))return;
	}

	bool icon=false;
	snprintf(iconPath, 128, "%s/icon.bin", path);
	if(!icon && !(icon=fileExists(iconPath, &sdmcArchive)))snprintf(iconPath, 128, "%s/icon.smdh", path);
	if(!icon && !(icon=fileExists(iconPath, &sdmcArchive)))snprintf(iconPath, 128, "%s/icon.icn", path);
	if(!icon && !(icon=fileExists(iconPath, &sdmcArchive)))snprintf(iconPath, 128, "%s/%s.smdh", path, &path[l+1]);
	if(!icon && !(icon=fileExists(iconPath, &sdmcArchive)))snprintf(iconPath, 128, "%s/%s.icn", path, &path[l+1]);

	int ret=loadFile(iconPath, &tmpSmdh, &sdmcArchive, sizeof(smdh_s));

	if(!ret)
	{
		initEmptyMenuEntry(&tmpEntry);
		ret=extractSmdhData(&tmpSmdh, tmpEntry.name, tmpEntry.description, tmpEntry.author, tmpEntry.iconData);
		strncpy(tmpEntry.executablePath, execPath, ENTRY_PATHLENGTH);
	}

	if(ret)initMenuEntry(&tmpEntry, execPath, &path[l+1], execPath, "", (u8*)installerIcon_bin);

	snprintf(xmlPath, 128, "%s/descriptor.xml", path);

	if(!fileExists(xmlPath, &sdmcArchive))snprintf(xmlPath, 128, "%s/%s.xml", path, &path[l+1]);
	loadDescriptor(&tmpEntry.descriptor, xmlPath);

	addBannerPathToMenuEntry(tmpEntry.bannerImagePath, path, &path[l+1], &tmpEntry.bannerIsFullScreen, &tmpEntry.hasBanner);

	addMenuEntryCopy(m, &tmpEntry);
}