Ejemplo n.º 1
0
void addSettingsMenuEntry(char * name, char * description, u8 * icon, bool * showTick, menu_s *m,  void (*callback)(), void *callbackObject1, void *callbackObject2) {
    static menuEntry_s settingsMenuEntry;

    settingsMenuEntry.hidden = false;
    settingsMenuEntry.isTitleEntry = false;

    strcpy(settingsMenuEntry.name, name);
    strcpy(settingsMenuEntry.description, description);
    if (icon) {
        int i;
        for (i=0; i<ENTRY_ICONSIZE; i++) {
            settingsMenuEntry.iconData[i] = icon[i];
        }
    }
    else {
        memset(settingsMenuEntry.iconData, 0, ENTRY_ICONSIZE);
    }
    settingsMenuEntry.showTick = showTick;
    settingsMenuEntry.callback = callback;
    settingsMenuEntry.callbackObject1 = callbackObject1;
    settingsMenuEntry.callbackObject2 = callbackObject2;

    strcpy(settingsMenuEntry.author, "");

    addMenuEntryCopy(m, &settingsMenuEntry);
}
Ejemplo n.º 2
0
void clearMenuEntries(menu_s* m)
{
	if(!m)return;

	m->selectedEntry=0;
	drawScrollBar(m);

	menuEntry_s* me = m->entries;
	menuEntry_s* temp = NULL;
	while(me)
	{
		temp=me->next;
		me->next = NULL;
		freeMenuEntry(me);
		free(me);
		me = temp;
	}

	m->numEntries = 0;
	m->entries = NULL;

	if(regionFreeAvailable)
	{
		// should always be available
		addMenuEntryCopy(m, &regionfreeEntry);
	}
}
Ejemplo n.º 3
0
void addThemeToList(char * fullPath, menuEntry_s * me, char * smdhName, int folderPathLen) {
    me->hidden = false;
    me->isTitleEntry = false;
    me->isRegionFreeEntry = false;

    char smdhPath[strlen(fullPath) + strlen(smdhName) + 1];
    strcpy(smdhPath, fullPath);
    strcat(smdhPath, smdhName);

    bool iconNeedsToBeGenerated = true;

    strcpy(me->name, "");
    strcpy(me->description, "");
    strcpy(me->author, "");

    if(fileExists(smdhPath, &sdmcArchive)) {
        static smdh_s tmpSmdh;
        int ret = loadFile(smdhPath, &tmpSmdh, &sdmcArchive, sizeof(smdh_s));

        if (!ret) {
            ret = extractSmdhData(&tmpSmdh, me->name, me->description, me->author, me->iconData);
            if (!ret) {
                iconNeedsToBeGenerated = false;
            }
        }
    }

    if (iconNeedsToBeGenerated) {
        memcpy(me->iconData, settingsIconTheme_bin, 48*48*3);
    }

    if (strlen(me->name) == 0) {
        if (strcmp(fullPath, "/3ds/") == 0) {
            strcpy(me->name, "3ds");
        }
        else {
            strcpy(me->name, fullPath+folderPathLen);
        }
    }

    if (strlen(me->description) == 0) {
        strcpy(me->description, "");
    }

    if (strlen(me->author) == 0) {
        strcpy(me->author, "");
    }

    me->drawFirstLetterOfName = iconNeedsToBeGenerated;
    me->drawFullTitle = true;

    strcpy(me->executablePath, fullPath+folderPathLen);

    addMenuEntryCopy(&themesMenu, me);
//    themesMenu.numEntries = themesMenu.numEntries + 1;
}
Ejemplo n.º 4
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);
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
void buildThemesList() {
    if (themesLoaded) {
        return;
    }

    themesLoaded = true;

    directoryContents * contents = contentsOfDirectoryAtPath(themesPath, true);

    themesMenu.entries=NULL;
    themesMenu.numEntries=0;
    themesMenu.selectedEntry=0;
    themesMenu.scrollLocation=0;
    themesMenu.scrollVelocity=0;
    themesMenu.scrollBarSize=0;
    themesMenu.scrollBarPos=0;
    themesMenu.scrollTarget=0;
    themesMenu.atEquilibrium=false;

    menuEntry_s randomEntry;
    strcpy(randomEntry.name, "Random theme");
    strcpy(randomEntry.description, "A random theme will be selected each time the launcher boots. Excludes the default theme.");
    strcpy(randomEntry.author, "");
    memcpy(randomEntry.iconData, settingsIconRandomTheme_bin, sizeof(randomEntry.iconData));
    randomEntry.hidden = false;
    randomEntry.isTitleEntry = false;
    randomEntry.isShortcut = false;
    randomEntry.isRegionFreeEntry = false;
    randomEntry.drawFirstLetterOfName = false;
    addMenuEntryCopy(&themesMenu, &randomEntry);

    char * smdhName = "/theme.smdh";
    int folderPathLen = strlen(themesPath);

    int i;
    for (i=0; i<contents->numPaths; i++) {
        char * fullPath = contents->paths[i];
        static menuEntry_s me;
        addThemeToList(fullPath, &me, smdhName, folderPathLen);
    }

    updateMenuIconPositions(&themesMenu);
    free(contents);
}
Ejemplo n.º 7
0
void initMenu(menu_s* m)
{
	if(!m)return;

	m->entries=NULL;
	m->numEntries=0;
	m->selectedEntry=0;
	m->scrollLocation=0;
	m->scrollVelocity=0;
	m->scrollBarSize=0;
	m->scrollBarPos=0;
	m->scrollTarget=0;
	m->atEquilibrium=false;

	if(regionFreeAvailable)
	{
		extractSmdhData((smdh_s*)regionfree_bin, regionfreeEntry.name, regionfreeEntry.description, regionfreeEntry.author, regionfreeEntry.iconData);
		strcpy(regionfreeEntry.executablePath, REGIONFREE_PATH);
		addMenuEntryCopy(m, &regionfreeEntry);
	}
}
Ejemplo n.º 8
0
void addFileToMenu(menu_s* m, char* execPath)
{
	if(!m || !execPath)return;

	static menuEntry_s tmpEntry;

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

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

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

	static char xmlPath[128];
	snprintf(xmlPath, 128, "%s", execPath);
	l = strlen(xmlPath);
	xmlPath[l-1] = 0;
	xmlPath[l-2] = 'l';
	xmlPath[l-3] = 'm';
	xmlPath[l-4] = 'x';
	if(fileExists(xmlPath, &sdmcArchive)) loadDescriptor(&tmpEntry.descriptor, xmlPath);

	addMenuEntryCopy(m, &tmpEntry);
}