コード例 #1
0
void defaultDolPrompt(const char *gameid)
{
	char id[7];
	snprintf(id, sizeof(id), gameid);
	defaultDolSelected = 0;

	//Metroid Prime Trilogy
	if (strcmp(id, "R3ME01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3", tr("Pick from a list"));
		if(choice == 1)
			defaultDolSelected = 780;

		else if(choice == 2)
			defaultDolSelected = 781;

		else if(choice == 3)
			defaultDolSelected = 782;
	}
	//Metroid Prime Trilogy
	else if (strcmp(id, "R3MP01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metroid Prime", "Metroid Prime 2", "Metroid Prime 3", tr("Pick from a list"));
		if(choice == 1)
			defaultDolSelected = 782;

		else if(choice == 2)
			defaultDolSelected = 783;

		else if(choice == 3)
			defaultDolSelected = 784;
	}
}
コード例 #2
0
ファイル: deleteMenu.c プロジェクト: Cyganet/wiicoverflow
bool Menu_Delete(){

	WPAD_Rumble(0,0);
	self.rumbleAmt = 0;
	
	struct discHdr *header = NULL;
 	char gameName[31]; 
	
	/* No game list */
	if (!self.gameCnt)
		return false;

	/* Selected game */
	header = &self.gameList[self.gameSelected];
	char title[MAX_TITLE_LEN];

	if(self.usingTitlesTxt){
		sprintf(title, "%s", header->title);
		getTitle(titleList, (char*)header->id, title);
	}
	else
		sprintf(title, "%s", (header->title));

	if(strlen(title) < 30) {
		sprintf(gameName, "%s", title);
	}
	else
	{
		strncpy(gameName, title, 27);
		gameName[27] = '\0';
		strncat(gameName, "...", 3);
	}

	//if(WindowPrompt(TX.askDelete, gameName, &yesButton, &noButton))
	if(WindowPromptInstall((char*)header->id, gameName, TX.askDelete, &yesButton, &noButton, 1))
	{
		BUFFER_KillBuffer();
		if(0 > WBFS_RemoveGame(header->id))
		{
			InitializeBuffer(self.gameList,self.gameCnt,BUFFER_WINDOW,COVER_COUNT/2.0 +self.shift,(settings.covers3d+settings.hq));
			BUFFER_InitBuffer();
			WindowPrompt(TX.errorDelete, TX.cantDelete, &okButton, 0);
		}
		else
		{
			GetEntries();
			InitializeBuffer(self.gameList,self.gameCnt,BUFFER_WINDOW,COVER_COUNT/2.0 +self.shift,(settings.covers3d+settings.hq));
			BUFFER_InitBuffer();
			WindowPrompt(TX.successDelete, TX.pressOkContinue, &okButton, 0);
			WBFS_DiskSpace(&self.usedSpace, &self.freeSpace);
			return true;
		}
	}
	
	return false;
}
コード例 #3
0
/****************************************************************************
 * MenuOGG
 ***************************************************************************/
bool MenuBackgroundMusic()
{
    bool ret = false;
    char entered[1024];
    int result = -1;
    snprintf(entered, sizeof(entered), "%s", Settings.ogg_path);

    if(strcmp(entered, "") == 0)
    {
        sprintf(entered, "%s", bootDevice);
    }
    else
    {
        char * pathptr = strrchr(entered, '/');
        if(pathptr)
        {
            pathptr++;
            int choice = WindowPrompt(tr("Playing Music:"), pathptr, tr("Play Previous"), tr("Play Next"), tr("Change Play Path"), tr("Cancel"));
            if(choice == 1)
            {
                return bgMusic->PlayPrevious();
            }
            else if(choice == 2)
            {
                return bgMusic->PlayNext();
            }
            else if(choice == 3)
            {
                pathptr[0] = 0;
            }
            else
                return true;
        }
        else
            sprintf(entered, "%s", bootDevice);
    }

    result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT);

    if(result)
    {
        if (!bgMusic->Load(entered))
        {
            WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK"));
        }
        else
            ret = true;
        bgMusic->Play();
        bgMusic->SetVolume(Settings.volume);
    }

    return ret;
}
コード例 #4
0
int CustomPathsSM::ChangePath(char * SettingsPath, int SizeOfPath)
{
	char entered[300];
	snprintf(entered, sizeof(entered), SettingsPath);

	HaltGui();
	GuiWindow * parent = (GuiWindow *) parentElement;
	if(parent) parent->SetState(STATE_DISABLED);
	this->SetState(STATE_DEFAULT);
	this->Remove(optionBrowser);
	ResumeGui();

	int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES);

	if(parent) parent->SetState(STATE_DEFAULT);
	this->Append(optionBrowser);

	if (result == 1)
	{
		if (entered[strlen(entered)-1] != '/')
			strcat(entered, "/");

		snprintf(SettingsPath, SizeOfPath, entered);
		WindowPrompt(tr( "Path Changed" ), 0, tr( "OK" ));
	}

	return result;
}
コード例 #5
0
ファイル: titles.c プロジェクト: Cyganet/wiicoverflow
void fillTitleStruct(s_title* titleList, int len){
	
	int i = 0;
	char line[MAX_TITLE_LEN];
	char fbuf[255];
	
	FILE* fp;
		sprintf(fbuf,"%s/titles.txt", dynPath.dir_usb_loader);
	fp = fopen(fbuf, "r");
	//fp = fopen(USBLOADER_PATH "/titles.txt", "r");
	
	if(fp == NULL){
		WindowPrompt("ERROR!", "Cannot fill struct!", 0, &cancelButton);
		return;
	}
	else
	{
		//while(fgets(line, sizeof(line), fp)){
		for(i=0; i<len; i++){
			fgets(line, sizeof(line), fp);
			snprintf(titleList[i].id, 7, "%s",line);
			sprintf(titleList[i].name, "%s",line+9);
			titleList[i].name[strlen(titleList[i].name)-1] = '\0';
			if (titleList[i].name[strlen(titleList[i].name)-1]==0x0d) // playing with notepad = stupid titles
			{
				titleList[i].name[strlen(titleList[i].name)-1] = '\0';
			}
			//i++;
			//break;
		}
		
		fclose(fp);
	}

}
コード例 #6
0
ファイル: ThemeMenu.cpp プロジェクト: joarley/usbloadergx
void ThemeMenu::SetupMainButtons()
{
	ThemeList.clear();

	DirList ThemeDir(Settings.theme_path, ".them", DirList::Files);
	if (ThemeDir.GetFilecount() == 0)
	{
		WindowPrompt(tr( "No themes found." ), 0, "OK");
	}

	for(int i = 0; i < ThemeDir.GetFilecount(); ++i)
	{
		u8 *buffer = NULL;
		u32 filesize;
		debughelper_printf("%i %s\n", i, ThemeDir.GetFilepath(i));
		LoadFileToMem(ThemeDir.GetFilepath(i), &buffer, &filesize);

		if(!buffer) continue;

		buffer[filesize-1] = '\0';

		int size = ThemeList.size();
		ThemeList.resize(size+1);

		ThemeList[size].Filepath = ThemeDir.GetFilepath(i);
		GetNodeText(buffer, "Theme-Title:", ThemeList[size].Title);
		GetNodeText(buffer, "Theme-Team:", ThemeList[size].Team);
		GetNodeText(buffer, "Theme-Version:", ThemeList[size].Version);
		GetNodeText(buffer, "Image-Folder:", ThemeList[size].ImageFolder);

		if(ThemeList[size].Title.size() == 0 && ThemeDir.GetFilename(i))
		{
			ThemeList[size].Title = ThemeDir.GetFilename(i);
			size_t pos = ThemeList[size].Title.rfind('.');
			if(pos != std::string::npos)
				ThemeList[size].Title.erase(pos);
		}

		if(ThemeList[size].ImageFolder.size() == 0)
		{
			ThemeList[size].ImageFolder = ThemeDir.GetFilepath(i);
			size_t pos = ThemeList[size].ImageFolder.rfind('.');
			if(pos != std::string::npos)
				ThemeList[size].ImageFolder.erase(pos);
			ThemeList[size].ImageFolder += '/';
		}
		else
		{
			std::string tempString = ThemeList[size].ImageFolder;
			ThemeList[size].ImageFolder = Settings.theme_path;
			ThemeList[size].ImageFolder += tempString;
			ThemeList[size].ImageFolder += '/';
		}

		SetMainButton(size, ThemeList[size].Title.c_str(), MainButtonImgData, NULL);

		free(buffer);
	}
}
コード例 #7
0
int GCDeleteMenu::Show()
{
	while(true)
	{
		usleep(10000);

		if (shutdown)
			Sys_Shutdown();
		else if (reset)
			Sys_Reboot();

		else if(backBtn->GetState() == STATE_CLICKED)
		{
			if(!changed || WindowPrompt(tr("Do you want to discard changes?"), 0, tr("Yes"), tr("No")))
				break;

			backBtn->ResetState();
		}

		else if (homeButton->GetState() == STATE_CLICKED)
		{
			gprintf("\thomeButton clicked\n");
			WindowExitPrompt();
			mainWindow->SetState(STATE_DISABLED);
			SetState(STATE_DEFAULT);
			homeButton->ResetState();
		}

		else if(button1->GetState() == STATE_CLICKED)
		{
			if(!changed)
			{
				WindowPrompt(tr("Error:"), tr("Nothing selected to delete."), tr("OK"));
			}
			else if(WindowPrompt(tr("Attention!"), tr("Are you really sure you want to delete all selected games from the SD card?"), tr("Yes"), tr("Cancel")))
			{
				DeleteSelectedGames();
				break;
			}

			button1->ResetState();
		}
	}

	return 0;
}
コード例 #8
0
ファイル: tools.cpp プロジェクト: Jeremy-D-Miller/wiixplorer
extern "C" void ShowMsg(const char * title, const char * format, ...)
{
	char *tmp=0;
	va_list va;
	va_start(va, format);
	if((vasprintf(&tmp, format, va)>=0) && tmp)
	{
		WindowPrompt(title, tmp, tr("OK"));
	}
	va_end(va);

	if(tmp)
		free(tmp);
}
コード例 #9
0
static void genesis_leave() {
    if (gensettings.saves & SAVES_SRAM) {
        /* save SRAM */
        save_sram(sramname);
    }
    else{
        if(WindowPrompt("Save", "Save SRAM?", "Save", "Don't Save")){
            save_sram(sramname);
        }
    }
    if (gensettings.saves & SAVES_STATES) {
        save_state(statename);
    }
    else{
        if(WindowPrompt("Save", "Save Save State?", "Save", "Don't Save")){
            save_state(statename);
        }
    }

    system_shutdown();
    //    audio_shutdown();
    error_shutdown();
    free(cart.rom);
}
コード例 #10
0
ファイル: ThemeMenu.cpp プロジェクト: joarley/usbloadergx
int ThemeMenu::MainLoop()
{
	if(defaultBtn->GetState() == STATE_CLICKED)
	{
		int choice = WindowPrompt(0, tr("Do you want to load the default theme?"), tr("Yes"), tr("Cancel"));
		if(choice)
		{
			HaltGui();
			Theme::SetDefault();
			Theme::Reload();
			ResumeGui();
			return MENU_THEMEMENU;
		}

		defaultBtn->ResetState();
	}

	return FlyingButtonsMenu::MainLoop();
}
コード例 #11
0
ファイル: cover.c プロジェクト: Cyganet/wiicoverflow
void batchDownloadCover(struct discHdr *gameList)
{
	int i;
	char id[7];
	
	for(i = 0; i < self.gameCnt; i++)
	{
		struct discHdr *header = &gameList[i];
		
		if(self.array_size < MAX_COVERS)
		{
			sprintf(id, "%s", header->id);
			sprintf(self.debugMsg, TX.checkNextCover, header->id);
			Paint_Progress_Generic(i, self.gameCnt, self.debugMsg);
			Download_Cover(id, i, self.gameCnt);
			//sprintf(filepath, USBLOADER_PATH "/covers/%s.png", header->id);
		}
	}
	WindowPrompt (TX.opFinished, TX.pressA, &okButton, 0);
}
コード例 #12
0
/****************************************************************************
 * MenuLanguageSelect
 ***************************************************************************/
int MenuLanguageSelect() {
    int cnt = 0;
    int ret = 0, choice = 0;
    int scrollon;
    int returnhere = 0;

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);

    char imgPath[100];

    snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
    GuiImageData btnOutline(imgPath, button_dialogue_box_png);
    snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
    GuiImageData settingsbg(imgPath, settings_background_png);

    GuiTrigger trigA;
    trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    GuiTrigger trigB;
    trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

    char fullpath[100];
    int countfiles = GetAllDirFiles(Settings.languagefiles_path);

    if (!strcmp("", Settings.languagefiles_path)) {
        sprintf(fullpath, "%s", tr("Standard"));
    } else {
        sprintf(fullpath, "%s", Settings.languagefiles_path);
    }

    GuiText titleTxt(fullpath, 24, (GXColor) {0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
    titleTxt.SetPosition(0,0);
    GuiButton pathBtn(300, 50);
    pathBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    pathBtn.SetPosition(0,28);
    pathBtn.SetLabel(&titleTxt);
    pathBtn.SetSoundOver(&btnSoundOver);
    pathBtn.SetSoundClick(btnClick2);
    pathBtn.SetTrigger(&trigA);
    pathBtn.SetEffectGrow();

    GuiImage oggmenubackground(&settingsbg);
    oggmenubackground.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    oggmenubackground.SetPosition(0, 0);

    GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext);
    backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage backBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        backBtnTxt.SetWidescreen(CFG.widescreen);
        backBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    backBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    backBtn.SetPosition(-190, 400);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetImage(&backBtnImg);
    backBtn.SetSoundOver(&btnSoundOver);
    backBtn.SetSoundClick(btnClick2);
    backBtn.SetTrigger(&trigA);
    backBtn.SetTrigger(&trigB);
    backBtn.SetEffectGrow();

    GuiText defaultBtnTxt(tr("Default") , 22, THEME.prompttext);
    defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage defaultBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        defaultBtnTxt.SetWidescreen(CFG.widescreen);
        defaultBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    defaultBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    defaultBtn.SetPosition(190, 400);
    defaultBtn.SetLabel(&defaultBtnTxt);
    defaultBtn.SetImage(&defaultBtnImg);
    defaultBtn.SetSoundOver(&btnSoundOver);
    defaultBtn.SetSoundClick(btnClick2);
    defaultBtn.SetTrigger(&trigA);
    defaultBtn.SetEffectGrow();

    GuiText updateBtnTxt(tr("Update Files") , 22, THEME.prompttext);
    updateBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage updateBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        updateBtnTxt.SetWidescreen(CFG.widescreen);
        updateBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    updateBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    updateBtn.SetPosition(0, 400);
    updateBtn.SetLabel(&updateBtnTxt);
    updateBtn.SetImage(&updateBtnImg);
    updateBtn.SetSoundOver(&btnSoundOver);
    updateBtn.SetSoundClick(btnClick2);
    updateBtn.SetTrigger(&trigA);
    updateBtn.SetEffectGrow();

    customOptionList options2(countfiles);

    for (cnt = 0; cnt < countfiles; cnt++) {
        char filename[64];
        strlcpy(filename, GetFileName(cnt), sizeof(filename));
        char *dot = strchr(filename, '.');
        if (dot) *dot='\0';
        options2.SetName(cnt, "%s", filename);
        options2.SetValue(cnt, NULL);

    }

    if (cnt < 9) {
        scrollon = 0;
    } else {
        scrollon = 1;
    }

    GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 10);
    optionBrowser4.SetPosition(0, 90);
    optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

    HaltGui();
    GuiWindow w(screenwidth, screenheight);
    w.Append(&oggmenubackground);
    w.Append(&pathBtn);
    w.Append(&backBtn);
    w.Append(&defaultBtn);
    w.Append(&updateBtn);
    w.Append(&optionBrowser4);
    mainWindow->Append(&w);

    w.SetEffect(EFFECT_FADE, 20);
    ResumeGui();

    while (w.GetEffect()>0) usleep(50);

    while (!returnhere) {

        if (shutdown == 1)
            Sys_Shutdown();
        else if (reset == 1)
            Sys_Reboot();

        else if (backBtn.GetState() == STATE_CLICKED) {

            backBtn.ResetState();
            break;
        }

        else if (defaultBtn.GetState() == STATE_CLICKED) {
            choice = WindowPrompt(tr("Loading standard language."),0,tr("OK"), tr("Cancel"));
            if (choice == 1) {
                sprintf(Settings.language_path, "notset");
                cfg_save_global();
                gettextCleanUp();
				HaltGui();
                CFG_Load();
				ResumeGui();
                returnhere = 2;
            }
            defaultBtn.ResetState();
			//optionBrowser4.SetFocus(1); // commented out to prevent crash
        }

        else if (updateBtn.GetState() == STATE_CLICKED) {
            choice = WindowPrompt(tr("Update all Language Files"),tr("Do you wish to update/download all language files?"),tr("OK"), tr("Cancel"));
            if (choice == 1) {

                bool network = true;
                if (!IsNetworkInit()) {
                    network = NetworkInitPrompt();
                }

                if (network) {
                    const char URL[60] = "http://usbloader-gui.googlecode.com/svn/trunk/Languages/";
                    char fullURL[300];
                    FILE *pfile;

                    URL_List LinkList(URL);
                    int listsize = LinkList.GetURLCount();

                    subfoldercreate(Settings.languagefiles_path);

                    for (int i = 0; i < listsize; i++) {

                        ShowProgress(tr("Updating Language Files:"), 0, LinkList.GetURL(i), i, listsize-1);

                        if (strcasecmp(".lang", strrchr(LinkList.GetURL(i), '.')) == 0) {

                            snprintf(fullURL, sizeof(fullURL), "%s%s", URL, LinkList.GetURL(i));

                            struct block file = downloadfile(fullURL);

                            if (file.data && file.size) {
                                char filepath[300];

                                snprintf(filepath, sizeof(filepath), "%s%s", Settings.languagefiles_path, LinkList.GetURL(i));
                                pfile = fopen(filepath, "wb");
                                fwrite(file.data, 1, file.size, pfile);
                                fclose(pfile);

                            }

                            free(file.data);
                        }
                    }
                    ProgressStop();
                    returnhere = 1;
                    break;
                }
            }
			updateBtn.ResetState();
			//optionBrowser4.SetFocus(1); // commented out to prevent crash
        }

        else if (pathBtn.GetState() == STATE_CLICKED) {
            w.Remove(&optionBrowser4);
            w.Remove(&backBtn);
            w.Remove(&pathBtn);
            w.Remove(&defaultBtn);
            char entered[43] = "";
            strlcpy(entered, Settings.languagefiles_path, sizeof(entered));
            int result = OnScreenKeyboard(entered,43,0);
            w.Append(&optionBrowser4);
            w.Append(&pathBtn);
            w.Append(&backBtn);
            w.Append(&defaultBtn);
            if ( result == 1 ) {
                int len = (strlen(entered)-1);
                if (entered[len] !='/')
                    strncat (entered, "/", 1);
                strlcpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path));
                WindowPrompt(tr("Languagepath changed."),0,tr("OK"));
                if (isInserted(bootDevice)) {
                    cfg_save_global();
                    returnhere = 1;
                    break;
                } else {
                    WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"));
                }
            }
            if (countfiles > 0) {
                optionBrowser4.SetFocus(1);
            }
            pathBtn.ResetState();
        }

        ret = optionBrowser4.GetClickedOption();

        if (ret>=0) {
            choice = WindowPrompt(tr("Do you want to change language?"), 0, tr("Yes"), tr("Cancel"));
            if (choice == 1) {
                if (isInserted(bootDevice)) {
                    snprintf(Settings.language_path, sizeof(Settings.language_path), "%s%s", Settings.languagefiles_path, GetFileName(ret));
                    cfg_save_global();
                    if (!checkfile(Settings.language_path)) {
                        sprintf(Settings.language_path, tr("not set"));
                        WindowPrompt(tr("File not found."),tr("Loading standard language."),tr("OK"));
                    }
                    gettextCleanUp();
					HaltGui();
					CFG_Load();
					ResumeGui();
                    returnhere = 2;
                    break;
                } else {
                    WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK"), 0,0,0,-1);
                }
            }
            optionBrowser4.SetFocus(1);
        }

    }

    w.SetEffect(EFFECT_FADE, -20);
    while (w.GetEffect()>0) usleep(50);

    HaltGui();
    mainWindow->Remove(&w);
    ResumeGui();

    return returnhere;
}
コード例 #13
0
ファイル: http.cpp プロジェクト: ifish12/WiiTweet
/****************************************************************************
 * http_request
 * Retrieves the specified URL, and stores it in the specified file or buffer
 ***************************************************************************/
int http_request(const char *url, FILE *hfile, u8 *buffer, u32 maxsize, bool silent, bool accept_encoding)
{
	int res = 0; int chunked = 0;
	char http_host[64];
	char http_path[256];
	char content_encoding[16] = "";
	u16 http_port;
	#ifdef DEBUGHEADERS
		int debugging = 0;
	#endif
	http_res result;
	u32 sizeread = 0;

	content_length = 0;

	int linecount;

	if(maxsize > MAX_SIZE){
		#ifdef DEBUGERRORS
			InfoPrompt("maxsize > MAX_SIZE");
		#endif
		return 0;
	}

	if (url == NULL || (hfile == NULL && buffer == NULL)){
		#ifdef DEBUGERRORS
			InfoPrompt("!url || (!hfile && !buffer)");
		#endif
		return 0;
	}

	if(!silent)
		ShowAction("Sending data...");
	
	split_res = http_split_url(http_host, http_path, url); // 2 : https ;  1 : http ;  0 : invalid url

	if (split_res == 2){
		http_port = 443;
		writeFunc = ssl_write;
		readFunc = ssl_read;		
	}else if( split_res == 1 ){
		http_port = 80;
		writeFunc = net_write;
		readFunc = net_read;
	}else{
		#ifdef DEBUGERRORS
			InfoPrompt("Invalid url");
		#endif
		return 0;
	}

	http_status = 404;

	int s = tcp_connect(http_host, http_port);

	if (s < 0)
	{
		result = HTTPR_ERR_CONNECT;
		#ifdef DEBUGERRORS
			InfoPrompt("Socket!");
		#endif
		return 0;
	}

	int ssl_context = 0;
	
	if(split_res == 2){  
		ssl_context = ssl_setup(http_host, s);
		#ifdef DEBUGERRORS
			if(ssl_context < 0){
				InfoPrompt("ssl_context() failed");
			}
		#endif
		if(ssl_context < 0){
			net_close(s);
			return 0;
		}
		scktctx = &ssl_context;
	} else{
		scktctx = &s;
	}

	if(curl_request){ //Request made by through the CURL class
		res = tcp_write(*scktctx, (u8 *) curl_request, strlen(curl_request));
	}else{
		char request[1024];
		char *r = request;
		r += sprintf(r, "GET %s HTTP/1.1\r\n", http_path);
		r += sprintf(r, "Host: %s\r\n", http_host);
		if(accept_encoding && hfile){
			r += sprintf(r, "Accept-Encoding: gzip, deflate\r\n");
		}
		r += sprintf(r, "Cache-Control: no-cache\r\n\r\n");
		res = tcp_write(*scktctx, (u8 *) request, strlen(request));
	}

	if(!silent)
		CancelAction();
		
	#ifdef DEBUGHEADERS
		InfoPrompt(http_path);
	#endif
	char line[1024]; //Twitter sends a long header

	for (linecount = 0; linecount < 45; linecount++)
	{
		if (tcp_readln(*scktctx, line, 1024) != 0)
		{
			#ifdef DEBUGERRORS
				InfoPrompt("tcp_readln != 0");
			#endif
			http_status = 404;
			result = HTTPR_ERR_REQUEST;
			break;
		}

		if (!line[0])
			break;

		#ifdef DEBUGHEADERS
				if(sscanf(line, "HTTP/1.%*u %u", &http_status)){
					if(http_status != 200)
						debugging = 1;
				}

				if(sscanf(line, "Content-Length: %u", &content_length) || sscanf(line, "Content-Encoding: %s", content_encoding)){
					if(!debugging){
						InfoPrompt(line);
					}
				}
				if(!strncmp(line, "Transfer-Encoding: chunked", 25)){ InfoPrompt("Transfer-Encoding: chunked"); chunked = 1; }
		#else
				sscanf(line, "HTTP/1.%*u %u", &http_status);
				sscanf(line, "Content-Length: %u", &content_length);
				sscanf(line, "Content-Encoding: %s", content_encoding);
				if(!strncmp(line, "Transfer-Encoding: chunked", 25)) chunked = 1;
		#endif

		u32 api_ratelimit=0;
		if(sscanf(line, "X-RateLimit-Remaining: %u", &api_ratelimit) && api_ratelimit <= 10 && api_ratelimit % 5 == 0){
			WindowPrompt("You are on fire!", "You are about to reach Twitter's requests limit. WiiTweet will not work correctly then.", "I'll take a break", 0);
		}
		
		if(get_timeoffset){
			if(!strncasecmp(line, "Date:", 5)){ //Case insensitiveness just in case...
				const char format[] = "%a, %d %b %Y %H:%M:%S %Z";
				const char *pointline = line;
				pointline += 6;
				struct tm tm;
				memset(&tm, 0, sizeof(tm));
				strptime(pointline, format, &tm);
				timeoffset = mktime(&tm) - time(NULL);
				get_timeoffset = 0;
			}
		}
		#ifdef DEBUGHEADERS
			if(debugging){
				InfoPrompt(line);
			}
		#endif
	}

	if (http_status != 200)
	{
		result = HTTPR_ERR_STATUS;
		#ifdef DEBUGERRORS
			if(ssl_context){
				if(ssl_shutdown(ssl_context)){
					InfoPrompt("ssl_shutdown() 1");
				}
			}
			net_close(s);
		#else
			if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
		#endif
		#ifdef DEBUGERRORS
			char status[64];
			sprintf(status, "HTTP Status = %d", http_status);
			InfoPrompt(status);
		#endif
		return 0;
	}//Try to read anyways? ssl gets rude if it is not convinced there is no data

	//length unknown - just read as much as we can
	if(content_length == 0)
	{
		content_length = maxsize;
	}
	else if (content_length > maxsize) //ssl_shutdown() would fail in this case (?), but it is not likely for our purposes...
	{
		result = HTTPR_ERR_TOOBIG;
		#ifdef DEBUGERRORS
			if(ssl_context){
				if(ssl_shutdown(ssl_context)){
					InfoPrompt("ssl_shutdown() 2");
				}
			}
			net_close(s);
		#else
			if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
		#endif
		#ifdef DEBUGERRORS
			InfoPrompt("content_length > maxsize");
		#endif
		return 0;
	}

	unsigned int inflatetype = 0;
	if(!strncasecmp(content_encoding, "gzip", 4)){
		inflatetype = 2;
	}else if(!strncasecmp(content_encoding, "deflate", 7)){
		inflatetype = 1;
	}else if(content_encoding[0] != '\0'){//Unsupported encoding. This should never happen.
		#ifdef DEBUGERRORS
			if(ssl_context){
				if(ssl_shutdown(ssl_context)){
					InfoPrompt("ssl_shutdown() 3");
				}
			}
			net_close(s);
		#else
			if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
		#endif
		#ifdef DEBUGERRORS
			InfoPrompt("Unsupported encoding");
		#endif
		return 0;
	}

	if (buffer != NULL)
	{
		if(!silent)
			ShowAction("Downloading...");

		if(inflatetype){ //Compressed content
			u8 * inflate_me = (u8 *) mem2_malloc(content_length, MEM2_OTHER);
			if(!inflate_me){
				#ifdef DEBUGERRORS
					if(ssl_context){
						if(ssl_shutdown(ssl_context)){
							InfoPrompt("ssl_shutdown() 4");
						}
					}
					net_close(s);
				#else
					if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
				#endif
				#ifdef DEBUGERRORS
					InfoPrompt("!inflate_me");
				#endif
				return 0;
			}
			#ifdef DEBUGHEADERS
				int tcpread = tcp_read(*scktctx, inflate_me, content_length, chunked);
				char atoi[64];
				sprintf(atoi, "%d", tcpread);
				WindowPrompt("tcp_read()", atoi, "ok", 0);
			#else
				int tcpread = tcp_read(*scktctx, inflate_me, content_length, chunked);
			#endif
/*
			static int s = 0;
			char path[256];
			sprintf(path, "sd:/catcha%d", s++);
			SaveFile ((char *)inflate_me, path, tcpread, 1);
*/
			sizeread = httpInflate(buffer, inflate_me, tcpread, inflatetype);
			if(sizeread < 0){
				mem2_free(inflate_me, MEM2_OTHER);
				#ifdef DEBUGERRORS
					if(ssl_context){
						if(ssl_shutdown(ssl_context)){
							InfoPrompt("ssl_shutdown() 5");
						}
					}
					net_close(s);
				#else
					if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
				#endif
				#ifdef DEBUGERRORS
					InfoPrompt("sizeread < 0");
				#endif
				return 0;
			}

			mem2_free(inflate_me, MEM2_OTHER);
		}else{ //Uncomprpessed content
			sizeread = tcp_read(*scktctx, buffer, content_length, chunked);
		}

		if(!silent)
			CancelAction();
	}
	else // write into file
	{
		/* Uncompressed data. This may fail if the content is chunked and longer than 32KB+2B but chunked is not used in such scenarios */

		u32 bufSize = (1024 * 32);
		u32 bytesLeft = content_length;
		u32 readSize;

		if(!silent)
			ShowProgress("Downloading...", 0, content_length);
		u8 * fbuffer = (u8 *) malloc(bufSize);
		if(fbuffer)
		{
			while (bytesLeft > 0)
			{
				if (bytesLeft < bufSize)
					readSize = bytesLeft;
				else
					readSize = bufSize;

				res = tcp_read(*scktctx, fbuffer, readSize, chunked);
				if (!res)
					break;

				sizeread += res;
				bytesLeft -= res;

				res = fwrite(fbuffer, 1, res, hfile);
				if (!res)
					break;
 
				if(!silent)
					ShowProgress("Downloading...", (content_length - bytesLeft), content_length);
			}
			free(fbuffer);
		}
		if(!silent)
			CancelAction();
	}

	#ifdef DEBUGERRORS
		if(ssl_context){
			if(ssl_shutdown(ssl_context)){
				InfoPrompt("ssl_shutdown() 6");
			}
		}
		net_close(s);
	#else
		if(ssl_context){ssl_shutdown(ssl_context);} net_close(s);
	#endif

	if (content_length < maxsize && sizeread != content_length && !inflatetype)
	{
		#ifdef DEBUGERRORS
			InfoPrompt("ERR_RECEIVE");
		#endif
		result = HTTPR_ERR_RECEIVE;
		return 0;
	}

	if (http_status != 200){
		#ifdef DEBUGERRORS
			InfoPrompt("http_status != 200");
		#endif
		return 0;
	}

	if(result) //Avoid ugly compiler warning :p
		result = HTTPR_OK;

	return sizeread;
}
コード例 #14
0
void WDMMenu::CheckGameFiles(const struct discHdr * header)
{
	wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) header->id);
	if (!disc)
	{
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return;
	}

	wiidisc_t *wdisc = wd_open_disc((int(*)(void *, u32, u32, void *)) wbfs_disc_read, disc);
	if (!wdisc)
	{
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return;
	}

	FST_ENTRY * fstbuffer = (FST_ENTRY *) wd_extract_file(wdisc, ONLY_GAME_PARTITION, (char*) "FST");
	if (!fstbuffer)
	{
		WindowPrompt(tr( "ERROR:" ), tr( "Not enough free memory." ), tr( "OK" ));
		return;
	}

	wd_close_disc(wdisc);
	WBFS_CloseDisc(disc);

	int position = 0;
	vector<pair<int, string> > FilesNotInWDM;

	for(int i = 0; i < wdmFile->size(); ++i)
	{
		if(stringcompare(wdmFile->GetDolName(i), "main") == true)
		{
			DOLOffsetList.push_back(pair<int, int>(0, wdmFile->GetParameter(i)));
			Options->SetName(position, "%i.", position+1);
			Options->SetValue(position, wdmFile->GetReplaceName(i));
			position++;
		}
	}

	for (u32 i = 1; i < fstbuffer[0].filelen; i++)
	{
		//don't add files that aren't .dol to the list
		const char * filename = fstfiles(fstbuffer, i);
		const char * fileext = NULL;

		if(filename)
			fileext = strrchr(filename, '.');

		if (fileext && strcasecmp(fileext, ".dol") == 0)
		{
			char NameCpy[strlen(filename)+1];
			strcpy(NameCpy, filename);
			char *extension = strrchr(NameCpy, '.');
			if(extension) *extension = 0;

			int j;
			for(j = 0; j < wdmFile->size(); ++j)
			{
				if(stringcompare(wdmFile->GetDolName(j), NameCpy) == true)
				{
					DOLOffsetList.push_back(pair<int, int>(i, wdmFile->GetParameter(j)));
					Options->SetName(position, "%i.", position+1);
					Options->SetValue(position, wdmFile->GetReplaceName(j));
					position++;
					break;
				}
			}

			if(j == wdmFile->size())
				FilesNotInWDM.push_back(pair<int, string>(i, filename));
		}
	}

	for(u32 i = 0; i < FilesNotInWDM.size(); ++i)
	{
		DOLOffsetList.push_back(pair<int, int>(FilesNotInWDM[i].first, 1));
		Options->SetName(position, "%i.", position+1);
		Options->SetValue(position, FilesNotInWDM[i].second.c_str());
		position++;
	}

	free(fstbuffer);
}
コード例 #15
0
ファイル: sys.cpp プロジェクト: gnils/usbloader-gx
void ShowMemInfo() {
	char buf[255];
    struct mallinfo mymallinfo = mallinfo();
    sprintf((char *) &buf,"Total: %d, Used: %d, Can be freed: %d", mymallinfo.arena/1024, mymallinfo.uordblks/1024, mymallinfo.keepcost/1024);
	WindowPrompt("Mem info", (char *) &buf, "OK");
}
コード例 #16
0
ファイル: cheatmenu.cpp プロジェクト: gnils/usbloader-gx
/****************************************************************************
 * CheatMenu
 ***************************************************************************/
int CheatMenu(const char * gameID) {
	int choice = 0;
	bool exit = false;
	int ret = 1;

	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);

	char imgPath[100];
	snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
	GuiImageData btnOutline(imgPath, button_dialogue_box_png);
	snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
	GuiImageData settingsbg(imgPath, settings_background_png);
	GuiImage settingsbackground(&settingsbg);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext);
	backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
	GuiImage backBtnImg(&btnOutline);
	GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, NULL, btnClick2,1);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetTrigger(&trigB);

	GuiText createBtnTxt(tr("Create") , 22, THEME.prompttext);
	createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
	GuiImage createBtnImg(&btnOutline);
	GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, NULL, btnClick2,1);
	createBtn.SetLabel(&createBtnTxt);

	char txtfilename[55];
	snprintf(txtfilename,sizeof(txtfilename),"%s%s.txt",Settings.TxtCheatcodespath,gameID);

	GCTCheats c;
	int check = c.openTxtfile(txtfilename);

	int download =0;

	switch (check) {
	case -1:
		WindowPrompt(tr("Error"),tr("Cheatfile is blank"),tr("OK"));
		break;
	case 0:
		download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("Download Now"),tr("Cancel"));
		if (download==1)
		{
			download = CodeDownload(gameID);
			if(download < 0 || c.openTxtfile(txtfilename) != 1)
				break;
		}
		else
			break;
	case 1:
		int cntcheats = c.getCnt();
		customOptionList cheatslst(cntcheats);
		GuiCustomOptionBrowser chtBrowser(400, 280, &cheatslst, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 1, 90);
		chtBrowser.SetPosition(0, 90);
		chtBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		chtBrowser.SetClickable(true);

		GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor) {0, 0, 0, 255});
		titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		titleTxt.SetMaxWidth(350, GuiText::SCROLL);
		titleTxt.SetPosition(12,40);

		for (int i = 0; i <= cntcheats; i++) {
            cheatslst.SetValue(i, "%s",c.getCheatName(i).c_str());
            cheatslst.SetName(i, "OFF");
        }

		HaltGui();
		GuiWindow w(screenwidth, screenheight);
		w.Append(&settingsbackground);
		w.Append(&titleTxt);
		w.Append(&backBtn);
		w.Append(&createBtn);
		w.Append(&chtBrowser);
		mainWindow->SetState(STATE_DISABLED);
		mainWindow->ChangeFocus(&w);
		mainWindow->Append(&w);
		ResumeGui();

		while (!exit) {
			VIDEO_WaitVSync ();

			ret = chtBrowser.GetClickedOption();
			if (ret != -1) {
				const char *strCheck = cheatslst.GetName(ret);
				if (strncmp(strCheck,"ON",2) == 0) {
					cheatslst.SetName(ret,"%s","OFF");
				} else if (strncmp(strCheck,"OFF",3) == 0) {
					cheatslst.SetName(ret,"%s","ON");
				}
			}

			if (createBtn.GetState() == STATE_CLICKED) {
				createBtn.ResetState();
				if (cntcheats > 0) {
					int selectednrs[30];
					int x = 0;
					for (int i = 0; i <= cntcheats; i++) {
						const char *strCheck = cheatslst.GetName(i);
						if (strncmp(strCheck,"ON",2) == 0) {
							selectednrs[x] = i;
							x++;
						}
					}
					if (x == 0) {
						WindowPrompt(tr("Error"),tr("No cheats were selected"),tr("OK"));
					} else {
						subfoldercreate(Settings.Cheatcodespath);
						string chtpath = Settings.Cheatcodespath;
						string gctfname = chtpath + c.getGameID() + ".gct";
						c.createGCT(selectednrs,x,gctfname.c_str());
						WindowPrompt(tr("GCT File created"),NULL,tr("OK"));
						exit = true;
						break;
					}
				} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
			}

			if (backBtn.GetState() == STATE_CLICKED) {
				backBtn.ResetState();
				exit = true;
				break;
			}
		}
		HaltGui();
		mainWindow->SetState(STATE_DEFAULT);
		mainWindow->Remove(&w);
		ResumeGui();
		break;
	}

	return choice;
}
コード例 #17
0
int autoSelectDolPrompt(const char *gameid)
{
	char id[7];
	snprintf(id, sizeof(id), gameid);

	//Indiana Jones and the Staff of Kings (Fate of Atlantis)
	if (strcmp(id, "RJ8E64") == 0 || strcmp(id, "RJ8P64") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Fate of Atlantis", tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 8; //from starstremr
		else if(choice == 0)
			return 0;
	}
	//Metal Slug Anthology (Metal Slug 6)
	else if (strcmp(id, "RMLEH4") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 54;
		else if(choice == 0)
			return 0;
	}
	//Metal Slug Anthology (Metal Slug 6)
	else if (strcmp(id, "RMLP7U") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Metal Slug 6", tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 56;
		else if(choice == 0)
			return 0;
	}
	//Rampage: Total Destruction (M1.dol=Rampage, jarvos.dol=Rampage World Tour)
	else if (strcmp(id, "RPGP5D") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "Rampage", "World Tour", tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 369;

		else if(choice == 2)
			return 368;

		else if(choice == 0)
			return 0;
	}
	//The House Of The Dead 2 & 3 Return (only to play 2)
	else if (strcmp(id, "RHDE8P") == 0 || strcmp(id, "RHDP8P") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, "HotD 2", tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 149;
		else if(choice == 2)
			return 0;
		else if(choice == 0)
			return 0;
	}
	//Grand Slam Tennis
	else if (strcmp(id, "R5TP69") == 0 || strcmp(id, "R5TE69") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 1493;//from isostar
		else if(choice == 0)
			return 0;
	}
	//Medal of Honor Heroes
	else if (strcmp(id, "RMZX69") == 0 || strcmp(id, "RMZP69") == 0 || strcmp(id, "RMZE69") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 492;//from isostar
		else if(choice == 0)
			return 0;
	}
	//Tiger Woods 10
	else if(strcmp(id, "R9OP69") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 1991;//from isostar
		else if(choice == 0)
			return 0;
	}
	//Tiger Woods 10
	else if(strcmp(id, "R9OE69") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 1973;//starstremr
		else if(choice == 0)
			return 0;
	}
	//The Legend of Zelda - Skyward Sword
	else if (strcmp(id, "SOUE01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 836;//from cheatfreak47
	}
	//The Legend of Zelda - Skyward Sword
	else if (strcmp(id, "SOUP01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 974;//from Cyan
	}
	//Virtual Tennis 2009
	else if (strcmp(id, "RVUP8P") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 16426;//from isostar
	}
	//Virtual Tennis 2009
	else if (strcmp(id, "RVUE8P") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 16405;//from isostar
		else if(choice == 0)
			return 0;
	}
	//Wii Sports Resort
	else if (strcmp(id, "RZTP01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 952;//from isostar
		else if(choice == 0)
			return 0;
	}
	//Wii Sports Resort
	else if (strcmp(id, "RZTE01") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 674;//from starstremr
		else if(choice == 0)
			return 0;
	}
	//Red Steel 2
	else if (strcmp(id, "RD2X41") == 0)
	{
		int choice = WindowPrompt(tr( "Select a DOL" ), 0, tr("Motion+ Video"), tr("Pick from a list"), tr( "Cancel" ));
		if(choice == 1)
			return 301;//from Cyan
		else if(choice == 0)
			return 0;
	}

	return -1;
}
コード例 #18
0
void GlobalSettings::CreateSettingsMenu(int menuNr)
{
    Settings Settings;
	
	if(CurrentMenu)
        return;

    int Idx = 0;

    //! GUI Settings
    if(menuNr == Idx++)
    {
        HideMenu();
        MainWindow::Instance()->ResumeGui();
        CurrentMenu = new GuiSettingsMenu();
        Append(CurrentMenu);
    }
    //! Sound
    else if(menuNr == Idx++)
    {
        HideMenu();
        MainWindow::Instance()->ResumeGui();
        CurrentMenu = new SoundSettingsMenu();
        Append(CurrentMenu);
    }
    //! Custom Paths
    else if(menuNr == Idx++)
    {
        HideMenu();
		MainWindow::Instance()->ResumeGui();
		CurrentMenu = new CustomPathsSM();
		Append(CurrentMenu);
    }
    //! WiiTDB
    if(menuNr == Idx++)
    {
        HideMenu();
        MainWindow::Instance()->ResumeGui();
        CurrentMenu = new WiiTDBSettingsMenu();
        Append(CurrentMenu);
    }
    //! Update
    else if(menuNr == Idx++)
    {
        HideMenu();
		MainWindow::Instance()->ResumeGui();
        CurrentMenu = new UpdateSettingsMenu();
        Append(CurrentMenu);
    }
    //! Default Settings
    else if(menuNr == Idx++)
    {
        int choice = WindowPrompt(tr( "Reset Settings" ), tr("Are you sure ?"), tr( "Yes" ), tr( "Cancel" ));
        if (choice == 1)
        {
			MainWindow::Instance()->HaltGui();
			Settings.SetDefault();
			bgMusic->Load(cfg.BgMusicPath);
			bgMusic->SetLoop(cfg.BgMusicLoop);
			bgMusic->SetVolume(cfg.MusicVolume);
			bgMusic->Play();
			Settings.LoadLanguage(NULL, APP_DEFAULT);
			returnMenu = MENU_SETTINGS;
			MainWindow::Instance()->ResumeGui();
		}
	}
    //! Credits
    else if(menuNr == Idx++)
    {
        HideMenu();
        Remove(backBtn);
        MainWindow::Instance()->ResumeGui();
        ShowCredits();
        Append(backBtn);
        ShowMenu();
    }
}
コード例 #19
0
int HomebrewReceiver::ReceiveFile()
{
	char filesizetxt[50];
	char temp[50];
	u32 filesize = 0;

	if (infilesize < MB_SIZE)
		snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fKB" ), infilesize / KB_SIZE);
	else snprintf(filesizetxt, sizeof(filesizetxt), tr( "Incoming file %0.2fMB" ), infilesize / MB_SIZE);

	snprintf(temp, sizeof(temp), tr( "Load file from: %s ?" ), GetIncommingIP());

	int choice = WindowPrompt(filesizetxt, temp, tr( "Load" ), tr( "Cancel" ));

	if (choice == 0)
		return 0;

	u32 read = 0;
	int len = NET_BLOCKSIZE;
	filesize = infilesize;
	u8 * buffer = (u8 *) malloc(infilesize);
	if(!buffer)
	{
		CloseConnection();
		WindowPrompt(tr( "Not enough memory." ), 0, tr( "OK" ));
		return 0;
	}

	bool error = false;
	while (read < infilesize)
	{
		ShowProgress(tr( "Receiving file from:" ), GetIncommingIP(), NULL, read, infilesize, true);
		
		if (infilesize - read < (u32) len)
			len = infilesize - read;
		else len = NET_BLOCKSIZE;
		
		int result = network_read(connection, buffer+read, len);
		
		if (result < 0)
		{
			CloseConnection();
			ProgressStop();
			WindowPrompt(tr( "Error while transfering data." ), 0, tr( "OK" ));
			free(buffer);
			return 0;
		}
		if (!result)
		{
			break;
		}
		
		read += result;
	}

	char filename[101];
	memset(filename, 0, sizeof(filename));
	
	network_read(connection, (u8*) filename, 100);
	
	//! Uncompress Wiiload
	if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4)
	{
		u8 *unc = (u8 *) malloc(uncfilesize);
		if(!unc)
		{
			free(buffer);
			CloseConnection();
			ProgressStop();
			WindowPrompt(tr( "Not enough memory." ), 0, tr( "OK" ));
			return 0;
		}
		
		uLongf f = uncfilesize;
		error = uncompress(unc, &f, buffer, infilesize) != Z_OK;
		uncfilesize = f;
		filesize = uncfilesize;
		
		free(buffer);
		buffer = unc;
		free(unc);
	}

	CopyHomebrewMemory(buffer, 0, filesize);
	
	ProgressStop();

	if (error || read != infilesize)
	{
		WindowPrompt(tr( "Error:" ), tr( "No data could be read." ), tr( "OK" ));
		FreeHomebrewBuffer();
		return 0;
	}

	CloseConnection();
	
	AddBootArgument(filename);

	return BootHomebrewFromMem();
}
コード例 #20
0
void Explorer::ProcessArcChoice(int choice, const char * destCandidat)
{
	ArchiveBrowser * browser = (ArchiveBrowser *) curBrowser;
	if(!browser)
		return;

	if(choice == ArcPasteItems)
	{
		int ret = WindowPrompt(tr("Paste the item(s) into this directory?"), Clipboard::Instance()->GetItemName(Clipboard::Instance()->GetItemcount()-1), tr("Yes"), tr("Cancel"));
		if(ret <= 0)
			return;

		PackTask *task = new PackTask(Clipboard::Instance(), browser->GetCurrentPath(), browser->GetArchive(), Settings.CompressionLevel);
		task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
		this->explorerTasks++;
		Taskbar::Instance()->AddTask(task);
		ThreadedTaskHandler::Instance()->AddTask(task);

		Clipboard::Instance()->Reset();
	}

	else if(choice == ArcExtractFile)
	{
		int ret = WindowPrompt(tr("Extract the selected item(s)?"), browser->GetCurrentName(), tr("Yes"), tr("Cancel"));
		if(ret <= 0)
			return;

		char dest[MAXPATHLEN];
		snprintf(dest, sizeof(dest), "%s", destCandidat);

		int result = OnScreenKeyboard(dest, sizeof(dest));
		if(result)
		{
			//append selected Item
			browser->MarkCurrentItem();
			//Get ItemMarker
			ItemMarker * IMarker = browser->GetItemMarker();
			//switch between browser index and archive file index
			for(int i = 0; i < IMarker->GetItemcount(); i++)
				IMarker->GetItem(i)->itemindex = browser->GetItemStructure(IMarker->GetItem(i)->itemindex)->fileindex;

			UnpackTask *task = new UnpackTask(IMarker, dest, browser->GetArchive(), false);
			task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
			this->explorerTasks++;
			Taskbar::Instance()->AddTask(task);
			ThreadedTaskHandler::Instance()->AddTask(task);

			IMarker->Reset();
		}
	}
	else if(choice == ArcExtractAll)
	{
		int ret = WindowPrompt(tr("Extract full archive?"), 0, tr("Yes"), tr("Cancel"));
		if(ret <= 0)
			return;

		char dest[MAXPATHLEN];
		snprintf(dest, sizeof(dest), "%s", destCandidat);
		if(dest[strlen(dest)-1] != '/')
			strcat(dest, "/");

		strncat(dest, browser->GetArchiveName(), sizeof(dest));

		char * ext = strrchr(dest, '.');
		if(ext)
			ext[0] = 0;
		strcat(dest, "/");

		int result = OnScreenKeyboard(dest, sizeof(dest));
		if(result)
		{
			UnpackTask *task = new UnpackTask(browser->GetItemMarker(), dest, browser->GetArchive(), true);
			task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
			this->explorerTasks++;
			Taskbar::Instance()->AddTask(task);
			ThreadedTaskHandler::Instance()->AddTask(task);

			browser->GetItemMarker()->Reset();
		}
	}
	else if(choice == ArcProperties)
	{
		browser->MarkCurrentItem();
		ItemMarker * Marker = browser->GetItemMarker();

		ArchiveProperties * Prompt = new ArchiveProperties(browser->GetArchive(), Marker);
		Prompt->SetAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
		Prompt->DimBackground(true);
		Application::Instance()->SetUpdateOnly(Prompt);
		Application::Instance()->Append(Prompt);

		Marker->Reset();
	}
}
コード例 #21
0
int SoundSettingsMenu::GetMenuInternal()
{
    int ret = optionBrowser->GetClickedOption();

    if (ret < 0)
        return MENU_NONE;

    int Idx = -1;

    //! Settings: Music Volume
    if (ret == ++Idx)
    {
        cfg.MusicVolume += 10;
        if (cfg.MusicVolume > 100) cfg.MusicVolume = 0;
        bgMusic->SetVolume(cfg.MusicVolume);
    }

    //! Settings: Credits Volume
    else if (ret == ++Idx)
    {
        cfg.CreditsVolume += 10;
        if (cfg.CreditsVolume > 100) cfg.CreditsVolume = 0;
    }

    //! Settings: SFX Volume
    else if (ret == ++Idx)
    {
        cfg.SFXVolume += 10;
        if (cfg.SFXVolume > 100) cfg.SFXVolume = 0;
    }

    //! Settings: BgMusic Path
	else if (ret == ++Idx)
    {
		MainWindow::Instance()->SetState(STATE_DISABLED);

		char entered[MAXPATHLEN];
		int ret = MenuBackgroundMusic(entered);
		if(ret == 1)
		{
			if (!bgMusic->Load(entered))
			{
				WindowPrompt(tr("Not supported format!"), tr("Loading standard music."), tr("OK"));
			}
			else
			{
				bgMusic->SetLoop(cfg.BgMusicLoop);
				bgMusic->SetVolume(cfg.MusicVolume);
				bgMusic->Play();
			}
		}
		else if(ret == 2)
		{
			bgMusic->PlayPrevious();
		}
		else if(ret == 3)
		{
			bgMusic->PlayNext();
		}
		
		MainWindow::Instance()->SetState(STATE_DEFAULT);
	}
	
	//! Settings: BgMusic Loop
    else if (ret == ++Idx)
    {
        if (++cfg.BgMusicLoop > 3) cfg.BgMusicLoop = 0;
		bgMusic->SetLoop(cfg.BgMusicLoop);
		bgMusic->Play();
    }

    //! Button: Reset BgMusic
    else if (ret == ++Idx)
    {
        strcpy(cfg.BgMusicPath, "");
		cfg.BgMusicLoop = LOOP;
		bgMusic->Load(cfg.BgMusicPath);
		bgMusic->SetLoop(cfg.BgMusicLoop);
		bgMusic->SetVolume(cfg.MusicVolume);
		bgMusic->Play();
    }

    SetOptionValues();

    return MENU_NONE;
}
コード例 #22
0
ファイル: ThemeMenu.cpp プロジェクト: joarley/usbloadergx
void ThemeMenu::MainButtonClicked(int button)
{
	//! TODO: Clean me
	const char * title = ThemeList[button].Title.c_str();
	const char * author = ThemeList[button].Team.c_str();
	const char * version = ThemeList[button].Version.c_str();
	GuiImageData *thumbimageData = ThemePreviews[button % 4];

	debughelper_printf("\nTheme_Prompt(%s ,%s)", title, author);
	bool leave = false;

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData dialogBox(Resources::GetFile("theme_dialogue_box.png"), Resources::GetFileSize("theme_dialogue_box.png"));

	GuiImage dialogBoxImg(&dialogBox);

	GuiWindow promptWindow(dialogBox.GetWidth(), dialogBox.GetHeight());
	promptWindow.SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	int PositionY = 30;

	GuiText titleTxt(tr( "Theme Title:" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(230, PositionY);
	PositionY += 20;

	GuiText titleTxt2(title, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	titleTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt2.SetPosition(230, PositionY);
	titleTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, WRAP);

	if(titleTxt2.GetTextWidth() >= dialogBox.GetWidth() - 220)
		PositionY += 50;
	else
		PositionY += 30;

	GuiText authorTxt(tr( "Author(s):" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	authorTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	authorTxt.SetPosition(230, PositionY);
	PositionY += 20;

	GuiText authorTxt2(author, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	authorTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	authorTxt2.SetPosition(230, PositionY);
	authorTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, DOTTED);

	if(authorTxt2.GetTextWidth() >= dialogBox.GetWidth() - 220)
		PositionY += 50;
	else
		PositionY += 30;

	GuiText versionTxt(tr( "Version:" ), 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	versionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	versionTxt.SetPosition(230, PositionY);

	GuiText versionTxt2(version, 18, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
	versionTxt2.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	versionTxt2.SetPosition(235+versionTxt.GetTextWidth(), PositionY);
	versionTxt2.SetMaxWidth(dialogBox.GetWidth() - 220, DOTTED);

	GuiText applyBtnTxt(tr( "Apply" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	applyBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage applyBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		applyBtnTxt.SetWidescreen(Settings.widescreen);
		applyBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton applyBtn(&applyBtnImg, &applyBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 170, &trigA, btnSoundOver, btnSoundClick2, 1);
	applyBtn.SetLabel(&applyBtnTxt);
	applyBtn.SetScale(0.9);

	GuiText backBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	backBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage backBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		backBtnTxt.SetWidescreen(Settings.widescreen);
		backBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton backBtn(&backBtnImg, &backBtnImg, ALIGN_RIGHT, ALIGN_TOP, -5, 220, &trigA, btnSoundOver, btnSoundClick2, 1);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetTrigger(&trigB);
	backBtn.SetScale(0.9);

	GuiImage ThemeImage(thumbimageData);
	ThemeImage.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	ThemeImage.SetPosition(20, 10);
	ThemeImage.SetScale(0.8);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&ThemeImage);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&titleTxt2);
	promptWindow.Append(&authorTxt);
	promptWindow.Append(&authorTxt2);
	promptWindow.Append(&versionTxt);
	promptWindow.Append(&versionTxt2);
	promptWindow.Append(&applyBtn);
	promptWindow.Append(&backBtn);

	HaltGui();
	promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	ResumeGui();

	while (!leave)
	{
		usleep(100);

		if (shutdown)
			Sys_Shutdown();
		else if (reset)
			Sys_Reboot();

		if (applyBtn.GetState() == STATE_CLICKED)
		{
			int choice = WindowPrompt(tr( "Do you want to apply this theme?" ), title, tr( "Yes" ), tr( "Cancel" ));
			if (choice)
			{
				if (Theme::Load(ThemeList[button].Filepath.c_str()))
				{
					snprintf(Settings.theme, sizeof(Settings.theme), ThemeList[button].Filepath.c_str());
					Theme::Reload();
					returnMenu = MENU_THEMEMENU;
					leave = true;
				}
			}
			mainWindow->SetState(STATE_DISABLED);
			promptWindow.SetState(STATE_DEFAULT);
			applyBtn.ResetState();
		}

		else if (backBtn.GetState() == STATE_CLICKED)
		{
			leave = true;
			backBtn.ResetState();
		}
	}

	promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
	while (promptWindow.GetEffect() > 0) usleep(100);
	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
コード例 #23
0
ファイル: HomebrewBrowse.cpp プロジェクト: gnils/usbloader-gx
/****************************************************************************
 * MenuHomebrewBrowse
 ***************************************************************************/
int MenuHomebrewBrowse() {
    int menu = MENU_NONE;
    int choice = 0;

    HomebrewFiles HomebrewFiles(Settings.homebrewapps_path);

    u32 filecount = HomebrewFiles.GetFilecount();

    if (!filecount) {
        WindowPrompt(tr("No .dol or .elf files found."),0, tr("OK"));
        return MENU_DISCLIST;
    }

    enum {
        FADE,
        LEFT,
        RIGHT
    };

    if (IsNetworkInit())
        ResumeNetworkWait();

    int slidedirection = FADE;

    /*** Sound Variables ***/
    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume);
	// because destroy GuiSound must wait while sound playing is finished, we use a global sound
	if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
	//	GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume);
    GuiSound btnClick1(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);

    /*** Image Variables ***/
    char imgPath[150];
    snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path);
    GuiImageData btnOutline(imgPath, button_dialogue_box_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
    GuiImageData bgData(imgPath, settings_background_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_title.png", CFG.theme_path);
    GuiImageData MainButtonImgData(imgPath, settings_title_png);

    snprintf(imgPath, sizeof(imgPath), "%ssettings_title_over.png", CFG.theme_path);
    GuiImageData MainButtonImgOverData(imgPath, settings_title_over_png);

    snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_left.png", CFG.theme_path);
    GuiImageData arrow_left(imgPath, startgame_arrow_left_png);

    snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path);
    GuiImageData arrow_right(imgPath, startgame_arrow_right_png);

    snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path);
    GuiImageData wifiImgData(imgPath, Wifi_btn_png);

    snprintf(imgPath, sizeof(imgPath), "%sChannel_btn.png", CFG.theme_path);
    GuiImageData channelImgData(imgPath, Channel_btn_png);


    GuiImage background(&bgData);

    /*** Trigger Variables ***/
    GuiTrigger trigA;
    trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    GuiTrigger trigHome;
    trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
    GuiTrigger trigB;
    trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
    GuiTrigger trigL;
    trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
    GuiTrigger trigR;
    trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
    GuiTrigger trigMinus;
    trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
    GuiTrigger trigPlus;
    trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);

    GuiText titleTxt(tr("Homebrew Launcher"), 28, (GXColor) {0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    titleTxt.SetPosition(0,40);

    GuiImageData *IconData[4];
    GuiImage *IconImg[4];

    for (int i = 0; i < 4; i++) {
        IconData[i] = NULL;
        IconImg[i] = NULL;
    }
    /*** Buttons ***/

    GuiText backBtnTxt(tr("Back") , 22, THEME.prompttext);
    backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
    GuiImage backBtnImg(&btnOutline);
    if (Settings.wsprompt == yes) {
        backBtnTxt.SetWidescreen(CFG.widescreen);
        backBtnImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, btnClick2,1);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetTrigger(&trigB);

    GuiButton h**o(1,1);
    h**o.SetTrigger(&trigHome);

    GuiImage GoLeftImg(&arrow_left);
    GuiButton GoLeftBtn(GoLeftImg.GetWidth(), GoLeftImg.GetHeight());
    GoLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    GoLeftBtn.SetPosition(25, -25);
    GoLeftBtn.SetImage(&GoLeftImg);
    GoLeftBtn.SetSoundOver(&btnSoundOver);
    GoLeftBtn.SetSoundClick(btnClick2);
    GoLeftBtn.SetEffectGrow();
    GoLeftBtn.SetTrigger(&trigA);
    GoLeftBtn.SetTrigger(&trigL);
    GoLeftBtn.SetTrigger(&trigMinus);

    GuiImage GoRightImg(&arrow_right);
    GuiButton GoRightBtn(GoRightImg.GetWidth(), GoRightImg.GetHeight());
    GoRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
    GoRightBtn.SetPosition(-25, -25);
    GoRightBtn.SetImage(&GoRightImg);
    GoRightBtn.SetSoundOver(&btnSoundOver);
    GoRightBtn.SetSoundClick(btnClick2);
    GoRightBtn.SetEffectGrow();
    GoRightBtn.SetTrigger(&trigA);
    GoRightBtn.SetTrigger(&trigR);
    GoRightBtn.SetTrigger(&trigPlus);

    char MainButtonText[50];
    snprintf(MainButtonText, sizeof(MainButtonText), "%s", " ");

    GuiImage MainButton1Img(&MainButtonImgData);
    GuiImage MainButton1ImgOver(&MainButtonImgOverData);
    GuiText MainButton1Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
    MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton1Txt.SetPosition(148, -12);
    GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
    MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton1DescTxt.SetPosition(148, 15);
    GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
    MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton1DescOverTxt.SetPosition(148, 15);
    GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
    MainButton1.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton1.SetPosition(0, 90);
    MainButton1.SetImage(&MainButton1Img);
    MainButton1.SetImageOver(&MainButton1ImgOver);
    MainButton1.SetLabel(&MainButton1Txt);
    MainButton1.SetLabel(&MainButton1DescTxt,1);
    MainButton1.SetLabelOver(&MainButton1DescOverTxt,1);
    MainButton1.SetSoundOver(&btnSoundOver);
    MainButton1.SetSoundClick(&btnClick1);
    MainButton1.SetEffectGrow();
    MainButton1.SetTrigger(&trigA);

    GuiImage MainButton2Img(&MainButtonImgData);
    GuiImage MainButton2ImgOver(&MainButtonImgOverData);
    GuiText MainButton2Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
    MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton2Txt.SetPosition(148, -12);
    MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton2DescTxt.SetPosition(148, 15);
    MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton2DescOverTxt.SetPosition(148, 15);
    MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
    MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton2.SetPosition(0, 160);
    MainButton2.SetImage(&MainButton2Img);
    MainButton2.SetImageOver(&MainButton2ImgOver);
    MainButton2.SetLabel(&MainButton2Txt);
    MainButton2.SetLabel(&MainButton2DescTxt,1);
    MainButton2.SetLabelOver(&MainButton2DescOverTxt,1);
    MainButton2.SetSoundOver(&btnSoundOver);
    MainButton2.SetSoundClick(&btnClick1);
    MainButton2.SetEffectGrow();
    MainButton2.SetTrigger(&trigA);

    GuiImage MainButton3Img(&MainButtonImgData);
    GuiImage MainButton3ImgOver(&MainButtonImgOverData);
    GuiText MainButton3Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton3Txt.SetPosition(148, -12);
    MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton3DescTxt.SetPosition(148, 15);
    MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
    MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton3DescOverTxt.SetPosition(148, 15);
    MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
    MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton3.SetPosition(0, 230);
    MainButton3.SetImage(&MainButton3Img);
    MainButton3.SetImageOver(&MainButton3ImgOver);
    MainButton3.SetLabel(&MainButton3Txt);
    MainButton3.SetLabel(&MainButton3DescTxt,1);
    MainButton3.SetLabelOver(&MainButton3DescOverTxt,1);
    MainButton3.SetSoundOver(&btnSoundOver);
    MainButton3.SetSoundClick(&btnClick1);
    MainButton3.SetEffectGrow();
    MainButton3.SetTrigger(&trigA);

    GuiImage MainButton4Img(&MainButtonImgData);
    GuiImage MainButton4ImgOver(&MainButtonImgOverData);
    GuiText MainButton4Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255} );
    MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton4Txt.SetPosition(148, -12);
    MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
    MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton4DescTxt.SetPosition(148, 15);
    MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
    GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
    MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    MainButton4DescOverTxt.SetPosition(148, 15);
    MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
    GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
    MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    MainButton4.SetPosition(0, 300);
    MainButton4.SetImage(&MainButton4Img);
    MainButton4.SetImageOver(&MainButton4ImgOver);
    MainButton4.SetLabel(&MainButton4Txt);
    MainButton4.SetLabel(&MainButton4DescTxt,1);
    MainButton4.SetLabelOver(&MainButton4DescOverTxt,1);
    MainButton4.SetSoundOver(&btnSoundOver);
    MainButton4.SetSoundClick(&btnClick1);
    MainButton4.SetEffectGrow();
    MainButton4.SetTrigger(&trigA);

    GuiImage wifiImg(&wifiImgData);
    if (Settings.wsprompt == yes) {
        wifiImg.SetWidescreen(CFG.widescreen);
    }
    GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
    wifiBtn.SetImage(&wifiImg);
    wifiBtn.SetPosition(500, 400);
    wifiBtn.SetSoundOver(&btnSoundOver);
    wifiBtn.SetSoundClick(&btnClick1);
    wifiBtn.SetEffectGrow();
    wifiBtn.SetAlpha(80);
    wifiBtn.SetTrigger(&trigA);

    GuiImage channelBtnImg(&channelImgData);
    channelBtnImg.SetWidescreen(CFG.widescreen);
    GuiButton channelBtn(channelBtnImg.GetWidth(), channelBtnImg.GetHeight());
    channelBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    channelBtn.SetPosition(440, 400);
    channelBtn.SetImage(&channelBtnImg);
    channelBtn.SetSoundOver(&btnSoundOver);
    channelBtn.SetSoundClick(btnClick2);
    channelBtn.SetEffectGrow();
    channelBtn.SetTrigger(&trigA);

    GuiTooltip * titleTT = NULL;


    GuiWindow w(screenwidth, screenheight);

    /*** XML Variables ***/
    HomebrewXML XMLInfo[4];

    int pageToDisplay = 1;
    const int pages = roundup(filecount/4.0f);
    bool wifi_btn_loaded=false;

    while (menu == MENU_NONE) { //set pageToDisplay to 0 to quit
        VIDEO_WaitVSync ();

        menu = MENU_NONE;
        bool changed = false;
        int fileoffset = pageToDisplay*4-4;

        /** Standard procedure made in all pages **/
        MainButton1.StopEffect();
        MainButton2.StopEffect();
        MainButton3.StopEffect();
        MainButton4.StopEffect();

        if (slidedirection == RIGHT) {
            MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
            MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
            MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
            MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 60);
            while (MainButton1.GetEffect()>0) usleep(50);
        } else if (slidedirection == LEFT) {
            MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
            MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
            MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
            MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 60);
            while (MainButton1.GetEffect()>0) usleep(50);
        }

        HaltGui();

        mainWindow->RemoveAll();

        /** Set new icons **/
        for (int i = 0; i < 4; i++) {
            if (IconData[i] != NULL) {
                delete IconData[i];
                IconData[i] = NULL;
            }
            if (IconImg[i] != NULL) {
                delete IconImg[i];
                IconImg[i] = NULL;
            }
            if (fileoffset+i < (int) filecount) {
                char iconpath[200];
                snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+i));
                IconData[i] = new GuiImageData(iconpath, 0);
                if (IconData[i]->GetImage()) {
                    IconImg[i] = new GuiImage(IconData[i]);
                    IconImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
                    IconImg[i]->SetPosition(12, 0);
                    IconImg[i]->SetScale(0.95);
                }
            }
        }

        if (IconImg[0] != 0)
            MainButton1.SetIcon(IconImg[0]);
        else
            MainButton1.SetIcon(NULL);
        if (IconImg[1] != 0)
            MainButton2.SetIcon(IconImg[1]);
        else
            MainButton2.SetIcon(NULL);
        if (IconImg[2] != 0)
            MainButton3.SetIcon(IconImg[2]);
        else
            MainButton3.SetIcon(NULL);
        if (IconImg[3] != 0)
            MainButton4.SetIcon(IconImg[3]);
        else
            MainButton4.SetIcon(NULL);

        mainWindow->Append(&w);
        w.RemoveAll();
        w.Append(&background);
        w.Append(&titleTxt);
        w.Append(&backBtn);
        w.Append(&h**o);
        w.Append(&wifiBtn);
        w.Append(&channelBtn);
        w.Append(&GoRightBtn);
        w.Append(&GoLeftBtn);

        if (pageToDisplay == pages) {
            int buttonsleft = filecount-(pages-1)*4;
            char * shortpath = NULL;
            char temp[200];

            if (buttonsleft > 0) {
                snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
                if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
                    MainButton1Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
                    MainButton1DescTxt.SetText(MainButtonText);
                    MainButton1DescOverTxt.SetText(MainButtonText);
                } else {
                    snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
                    shortpath = strrchr(temp, '/');
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
                    XMLInfo[0].SetName(MainButtonText);
                    MainButton1Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), " ");
                    MainButton1DescTxt.SetText(MainButtonText);
                    MainButton1DescOverTxt.SetText(MainButtonText);
                }
                w.Append(&MainButton1);
            }
            if (buttonsleft > 1) {
                snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
                if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
                    MainButton2Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
                    MainButton2DescTxt.SetText(MainButtonText);
                    MainButton2DescOverTxt.SetText(MainButtonText);
                } else {
                    snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
                    shortpath = strrchr(temp, '/');
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
                    XMLInfo[1].SetName(MainButtonText);
                    MainButton2Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), " ");
                    MainButton2DescTxt.SetText(MainButtonText);
                    MainButton2DescOverTxt.SetText(MainButtonText);
                }
                w.Append(&MainButton2);
            }
            if (buttonsleft > 2) {
                snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
                if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                    MainButton3Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                    MainButton3DescTxt.SetText(MainButtonText);
                    MainButton3DescOverTxt.SetText(MainButtonText);
                } else {
                    snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
                    shortpath = strrchr(temp, '/');
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
                    XMLInfo[2].SetName(MainButtonText);
                    MainButton3Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), " ");
                    MainButton3DescTxt.SetText(MainButtonText);
                    MainButton3DescOverTxt.SetText(MainButtonText);
                }
                w.Append(&MainButton3);
            }
            if (buttonsleft > 3) {
                snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
                if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                    MainButton4Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                    MainButton4DescTxt.SetText(MainButtonText);
                    MainButton4DescOverTxt.SetText(MainButtonText);
                } else {
                    snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
                    shortpath = strrchr(temp, '/');
                    snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
                    XMLInfo[3].SetName(MainButtonText);
                    MainButton4Txt.SetText(MainButtonText);
                    snprintf(MainButtonText, sizeof(MainButtonText), " ");
                    MainButton4DescTxt.SetText(MainButtonText);
                    MainButton4DescOverTxt.SetText(MainButtonText);
                }
                w.Append(&MainButton4);
            }
        } else {
            char temp[200];
            char *shortpath = NULL;

            snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));
            if (XMLInfo[0].LoadHomebrewXMLData(temp) > 0) {
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetName());
                MainButton1Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[0].GetShortDescription());
                MainButton1DescTxt.SetText(MainButtonText);
                MainButton1DescOverTxt.SetText(MainButtonText);
            } else {
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
                shortpath = strrchr(temp, '/');
                snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));
                XMLInfo[0].SetName(MainButtonText);
                MainButton1Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), " ");
                MainButton1DescTxt.SetText(MainButtonText);
                MainButton1DescOverTxt.SetText(MainButtonText);
            }

            w.Append(&MainButton1);

            snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));
            if (XMLInfo[1].LoadHomebrewXMLData(temp) > 0) {
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetName());
                MainButton2Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[1].GetShortDescription());
                MainButton2DescTxt.SetText(MainButtonText);
                MainButton2DescOverTxt.SetText(MainButtonText);
            } else {
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
                shortpath = strrchr(temp, '/');
                snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));
                XMLInfo[1].SetName(MainButtonText);
                MainButton2Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), " ");
                MainButton2DescTxt.SetText(MainButtonText);
                MainButton2DescOverTxt.SetText(MainButtonText);
            }

            w.Append(&MainButton2);

            snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));
            if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                MainButton3Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                MainButton3DescTxt.SetText(MainButtonText);
                MainButton3DescOverTxt.SetText(MainButtonText);
            } else {
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
                shortpath = strrchr(temp, '/');
                snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));
                XMLInfo[2].SetName(MainButtonText);
                MainButton3Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), " ");
                MainButton3DescTxt.SetText(MainButtonText);
                MainButton3DescOverTxt.SetText(MainButtonText);
            }
            w.Append(&MainButton3);

            snprintf(temp, sizeof(temp), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));
            if (XMLInfo[3].LoadHomebrewXMLData(temp) > 0) {
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetName());
                MainButton4Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), "%s", XMLInfo[3].GetShortDescription());
                MainButton4DescTxt.SetText(MainButtonText);
                MainButton4DescOverTxt.SetText(MainButtonText);
            } else {
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
                shortpath = strrchr(temp, '/');
                snprintf(MainButtonText, sizeof(MainButtonText), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));
                XMLInfo[3].SetName(MainButtonText);
                MainButton4Txt.SetText(MainButtonText);
                snprintf(MainButtonText, sizeof(MainButtonText), " ");
                MainButton4DescTxt.SetText(MainButtonText);
                MainButton4DescOverTxt.SetText(MainButtonText);
            }

            w.Append(&MainButton4);
        }

        MainButton1.StopEffect();
        MainButton2.StopEffect();
        MainButton3.StopEffect();
        MainButton4.StopEffect();

        MainButton1.SetEffectGrow();
        MainButton2.SetEffectGrow();
        MainButton3.SetEffectGrow();
        MainButton4.SetEffectGrow();

        if (slidedirection == FADE) {
            MainButton1.SetEffect(EFFECT_FADE, 20);
            MainButton2.SetEffect(EFFECT_FADE, 20);
            MainButton3.SetEffect(EFFECT_FADE, 20);
            MainButton4.SetEffect(EFFECT_FADE, 20);
        } else if (slidedirection == LEFT) {
            MainButton1.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
            MainButton2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
            MainButton3.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
            MainButton4.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 60);
        } else if (slidedirection == RIGHT) {
            MainButton1.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
            MainButton2.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
            MainButton3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
            MainButton4.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_IN, 60);
        }

        mainWindow->Append(&w);

        ResumeGui();

        while (MainButton1.GetEffect() > 0) usleep(50);

        while (!changed) {
            VIDEO_WaitVSync ();

            if (MainButton1.GetState() == STATE_CLICKED) {
                char temp[200];
                char iconpath[200];
                char metapath[200];
                char * shortpath = NULL;

                //write iconpath
                snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset));

                //write iconpath
                snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset));

                //get filesize
                u64 filesize = HomebrewFiles.GetFilesize(fileoffset);
                //write short filename
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset)), "%s", HomebrewFiles.GetFilepath(fileoffset));
                shortpath = strrchr(temp, '/');
                snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset));

                int choice = HBCWindowPrompt(XMLInfo[0].GetName(), XMLInfo[0].GetCoder(), XMLInfo[0].GetVersion(), XMLInfo[0].GetReleasedate(), XMLInfo[0].GetLongDescription(), iconpath, filesize);
                if (choice == 1) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset), HomebrewFiles.GetFilename(fileoffset));
                    break;
                }
                MainButton1.ResetState();
            } else if (MainButton2.GetState() == STATE_CLICKED) {
                char temp[200];
                char iconpath[200];
                char metapath[200];
                char * shortpath = NULL;

                //write iconpath
                snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+1));

                //write iconpath
                snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+1));

                //get filesize
                u64 filesize = HomebrewFiles.GetFilesize(fileoffset+1);
                //write short filename
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+1)), "%s", HomebrewFiles.GetFilepath(fileoffset+1));
                shortpath = strrchr(temp, '/');
                snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+1));

                int choice = HBCWindowPrompt(XMLInfo[1].GetName(), XMLInfo[1].GetCoder(), XMLInfo[1].GetVersion(), XMLInfo[1].GetReleasedate(), XMLInfo[1].GetLongDescription(), iconpath, filesize);
                if (choice == 1) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+1), HomebrewFiles.GetFilename(fileoffset+1));
                    break;
                }
                MainButton2.ResetState();
            } else if (MainButton3.GetState() == STATE_CLICKED) {
                char temp[200];
                char iconpath[200];
                char metapath[200];
                char * shortpath = NULL;

                //write iconpath
                snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+2));

                //write iconpath
                snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+2));

                //get filesize
                u64 filesize = HomebrewFiles.GetFilesize(fileoffset+2);
                //write short filename
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+2)), "%s", HomebrewFiles.GetFilepath(fileoffset+2));
                shortpath = strrchr(temp, '/');
                snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+2));

                int choice = HBCWindowPrompt(XMLInfo[2].GetName(), XMLInfo[2].GetCoder(), XMLInfo[2].GetVersion(), XMLInfo[2].GetReleasedate(), XMLInfo[2].GetLongDescription(), iconpath, filesize);
                if (choice == 1) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+2), HomebrewFiles.GetFilename(fileoffset+2));
                    break;
                }
                MainButton3.ResetState();
            } else if (MainButton4.GetState() == STATE_CLICKED) {
                char temp[200];
                char iconpath[200];
                char metapath[200];
                char * shortpath = NULL;

                //write iconpath
                snprintf(metapath, sizeof(metapath), "%smeta.xml", HomebrewFiles.GetFilepath(fileoffset+3));

                //write iconpath
                snprintf(iconpath, sizeof(iconpath), "%sicon.png", HomebrewFiles.GetFilepath(fileoffset+3));

                //get filesize
                u64 filesize = HomebrewFiles.GetFilesize(fileoffset+3);
                //write short filename
                snprintf(temp, strlen(HomebrewFiles.GetFilepath(fileoffset+3)), "%s", HomebrewFiles.GetFilepath(fileoffset+3));
                shortpath = strrchr(temp, '/');
                snprintf(temp, sizeof(temp), "%s/%s", shortpath, HomebrewFiles.GetFilename(fileoffset+3));

                int choice = HBCWindowPrompt(XMLInfo[3].GetName(), XMLInfo[3].GetCoder(), XMLInfo[3].GetVersion(), XMLInfo[3].GetReleasedate(), XMLInfo[3].GetLongDescription(), iconpath, filesize);
                if (choice == 1) {
                    boothomebrew = 1;
                    menu = MENU_EXIT;
                    snprintf(Settings.selected_homebrew, sizeof(Settings.selected_homebrew), "%s%s",  HomebrewFiles.GetFilepath(fileoffset+3), HomebrewFiles.GetFilename(fileoffset+3));
                    break;
                }
                MainButton4.ResetState();
            }

            else if (shutdown == 1)
                Sys_Shutdown();
            else if (reset == 1)
                Sys_Reboot();

            else if (backBtn.GetState() == STATE_CLICKED) {
                menu = MENU_DISCLIST;
                changed = true;
            }

            else if (GoLeftBtn.GetState() == STATE_CLICKED) {
                pageToDisplay--;
                /** Change direction of the flying buttons **/
                if (pageToDisplay < 1)
                    pageToDisplay = pages;
                slidedirection = LEFT;
                changed = true;
                GoLeftBtn.ResetState();
            }

            else if (GoRightBtn.GetState() == STATE_CLICKED) {
                pageToDisplay++;
                /** Change direction of the flying buttons **/
                if (pageToDisplay > pages)
                    pageToDisplay = 1;
                slidedirection = RIGHT;
                changed = true;
                GoRightBtn.ResetState();
            }

            else if (wifiBtn.GetState() == STATE_CLICKED) {

                ResumeNetworkWait();
                wifiBtn.ResetState();
            }

            else if (h**o.GetState() == STATE_CLICKED) {
                cfg_save_global();
                bgMusic->Pause();
                choice = WindowExitPrompt();
                bgMusic->Resume();

                if (choice == 3) {
                    Sys_LoadMenu(); // Back to System Menu
                } else if (choice == 2) {
                    Sys_BackToLoader();
                } else {
                    h**o.ResetState();
                }
            }

            else if (infilesize > 0) {
                char filesizetxt[50];
                char temp[50];

                if (infilesize < MB_SIZE)
                    snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KB_SIZE);
                else
                    snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fMB"), infilesize/MB_SIZE);

                snprintf(temp, sizeof(temp), tr("Load file from: %s ?"), GetIncommingIP());

                int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel"));

                if (choice == 1) {

                    int res = AllocHomebrewMemory(infilesize);

                    if (res < 0) {
                        CloseConnection();
                        WindowPrompt(tr("Not enough free memory."), 0, tr("OK"));
                    } else {
                        u32 read = 0;
                        u8 *temp = NULL;
                        int len = NETWORKBLOCKSIZE;
                        temp = (u8 *) malloc(infilesize);

						bool error = false;
						u8 *ptr = temp;
                        while (read < infilesize) {

                            ShowProgress(tr("Receiving file from:"), GetIncommingIP(), NULL, read, infilesize, true);

                            if (infilesize - read < (u32) len)
                                len = infilesize-read;
                            else
                                len = NETWORKBLOCKSIZE;

                            int result = network_read(ptr, len);

                            if (result < 0) {
                                WindowPrompt(tr("Error while transfering data."), 0, tr("OK"));
								error = true;
                                break;
                            }
                            if (!result) {
                                break;
							}

							ptr += result;

                            read += result;
                        }
						
						char filename[101];
						if (!error) {
						
							network_read((u8*) &filename, 100);
							
							// Do we need to unzip this thing?
							if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) {

								// We need to unzip...
								if (temp[0] == 'P' && temp[1] == 'K' && temp[2] == 0x03 && temp[3] == 0x04) {
									// It's a zip file, unzip to the apps directory
									
									// Zip archive, ask for permission to install the zip
									char zippath[255];
									sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename);
									
									FILE *fp = fopen(zippath, "wb");
									if (fp != NULL)
									{
										fwrite(temp, 1, infilesize, fp);
										fclose(fp);
										
										// Now unzip the zip file...
										unzFile uf = unzOpen(zippath);
										if (uf==NULL) {
											error = true;
										} else {
											extractZip(uf,0,1,0, Settings.homebrewapps_path);
											unzCloseCurrentFile(uf);
											
											remove(zippath);
											
											// Reload this menu here...
											menu = MENU_HOMEBREWBROWSE;
											break;
										}
									} else {
										error = true;
									}
								} else if (uncfilesize != 0) { // if uncfilesize == 0, it's not compressed
									// It's compressed, uncompress
									u8 *unc = (u8 *) malloc(uncfilesize);
									uLongf f = uncfilesize;
									error = uncompress(unc, &f, temp, infilesize) != Z_OK;
									uncfilesize = f;
									
									free(temp);
									temp = unc;
								}
							}
							
							if (!error && strstr(filename,".zip") == NULL) {
								innetbuffer = temp;
							}
						}
						
                        ProgressStop();

                        if (error || read != infilesize) {
                            WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK"));
                            FreeHomebrewBuffer();
                        } else {
                            if (strstr(filename,".dol") || strstr(filename,".DOL")
                                || strstr(filename,".elf") || strstr(filename,".ELF")) {
                                boothomebrew = 2;
                                menu = MENU_EXIT;
                                CloseConnection();
                                break;
                            } else if (strstr(filename,".zip")) {
                                WindowPrompt(tr("Success:"), tr("Uploaded ZIP file installed to homebrew directory."), tr("OK"));
								CloseConnection();
                            } else {
                                FreeHomebrewBuffer();
                                WindowPrompt(tr("ERROR:"), tr("Not a DOL/ELF file."), tr("OK"));
							}
                        }
                    }
                }
                CloseConnection();
                ResumeNetworkWait();
            }

            else if (channelBtn.GetState() == STATE_CLICKED) {
                w.SetState(STATE_DISABLED);
                //10001 are the channels that are installed as channels, not including shop channel/mii channel etc
                u32 num = 0x00010001;
                TitleBrowser(num);
                //if they didn't boot a channel reset this window
                w.SetState(STATE_DEFAULT);
                channelBtn.ResetState();


            }

            if (IsNetworkInit()) {
                if (!wifi_btn_loaded) {
                    wifiBtn.SetAlpha(255);

                    titleTT = new GuiTooltip(GetNetworkIP());
                    titleTT->SetAlpha(THEME.tooltipAlpha);
                    wifiBtn.SetToolTip(titleTT,0,-50,0,5);
                    wifi_btn_loaded=true;
                }
            }
        }
    }

    w.SetEffect(EFFECT_FADE, -20);
    while (w.GetEffect()>0) usleep(50);

    HaltGui();

    for (int i = 0; i < 4; i++) {
        if (IconData[i] != NULL) {
            delete IconData[i];
            IconData[i] = NULL;
        }
        if (IconImg[i] != NULL) {
            delete IconImg[i];
            IconImg[i] = NULL;
        }
    }

    delete titleTT;
    titleTT = NULL;

    if (IsNetworkInit())
        HaltNetworkThread();

    mainWindow->RemoveAll();
    mainWindow->Append(bgImg);

    ResumeGui();

    return menu;
}
コード例 #24
0
/********************************************************************************
 *Disk Browser
 *********************************************************************************/
int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_size)
{
	gprintf("\nDiscBrowser() started");
	bool exit = false;
	int ret = -1, choice;

	HaltGui();

	gprintf("WBFS_OpenDisc\n");
	wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) GameID);
	if (!disc)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return ret;
	}
	gprintf("wd_open_disc\n");
	wiidisc_t *wdisc = wd_open_disc((int(*)(void *, u32, u32, void *)) wbfs_disc_read, disc);
	if (!wdisc)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" ));
		return ret;
	}

	gprintf("wd_get_fst\n");
	FST_ENTRY * fstbuffer = (FST_ENTRY *) wd_extract_file(wdisc, ONLY_GAME_PARTITION, (char *) "FST");
	if (!fstbuffer)
	{
		ResumeGui();
		WindowPrompt(tr( "ERROR:" ), tr( "Not enough free memory." ), tr( "OK" ));
		return -1;
	}

	gprintf("wd_close_disc\n");
	wd_close_disc(wdisc);
	gprintf("WBFS_CloseDisc\n");
	WBFS_CloseDisc(disc);

	gprintf("options\n");
	OptionList options;

	for (u32 i = 0, position = 0; i < fstbuffer[0].filelen; i++)
	{
		//don't add files that aren't .dol to the list
		const char * filename = fstfiles(fstbuffer, i);
		const char * fileext = NULL;

		if(filename)
			fileext = strrchr(filename, '.');

		if (fileext && strcasecmp(fileext, ".dol") == 0)
		{
			options.SetName(position, "%s %03i", tr("Offset"), i);
			options.SetValue(position, filename);
			position++;
		}
	}

	free(fstbuffer);

	gprintf("\n%i alt dols found", options.GetLength()+1);
	if (options.GetLength() <= 0)
	{
		WindowPrompt(tr( "ERROR" ), tr( "No DOL file found on disc." ), tr( "OK" ));
		return ret;
	}

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigHome;
	trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiText titleTxt(GameTitles.GetTitle(GameID), 28, ( GXColor ) {0, 0, 0, 255});
	titleTxt.SetAlignment(ALIGN_CENTER, ALIGN_TOP);
	titleTxt.SetPosition(12, 40);
	titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);

	GuiImage settingsbackground(&settingsbg);
	GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
	settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	settingsbackgroundbtn.SetPosition(0, 0);
	settingsbackgroundbtn.SetImage(&settingsbackground);

	GuiText cancelBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage cancelBtnImg(&btnOutline);
	if (Settings.wsprompt == ON)
	{
		cancelBtnTxt.SetWidescreen(Settings.widescreen);
		cancelBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
	cancelBtn.SetScale(0.9);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetTrigger(&trigB);

	GuiOptionBrowser optionBrowser3(396, 280, &options, "bg_options_settings.png");
	optionBrowser3.SetPosition(0, 90);
	optionBrowser3.SetAlignment(ALIGN_CENTER, ALIGN_TOP);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&settingsbackgroundbtn);
	w.Append(&titleTxt);
	w.Append(&cancelBtn);
	w.Append(&optionBrowser3);

	mainWindow->Append(&w);

	ResumeGui();
	while (!exit)
	{
		usleep(100);

		if (shutdown)
			Sys_Shutdown();
		if (reset)
			Sys_Reboot();

		ret = optionBrowser3.GetClickedOption();

		if (ret >= 0)
		{
			choice = WindowPrompt(options.GetValue(ret), tr( "Load this DOL as alternate DOL?" ), tr( "OK" ), tr( "Cancel" ));
			if (choice)
			{
				snprintf(alternatedname, alternatedname_size, options.GetValue(ret));
				const char * offset = options.GetName(ret);
				if(offset)
					ret = atoi(offset+strlen("Offset ")); //doloffset
				else
					ret = -1; // weird problem
				exit = true;
			}
		}

		if (cancelBtn.GetState() == STATE_CLICKED)
		{
			exit = true;
		}
	}

	HaltGui();
	mainWindow->Remove(&w);
	ResumeGui();

	return ret;
}
コード例 #25
0
ファイル: ZipFile.cpp プロジェクト: Gamer125/wiibrowser
int ZipFile::ExtractFile(int ind, const char *dest, bool withpath)
{
    if(!SwitchMode(OPEN))
        return -1;

    if(!SeekFile(ind) && ind < RealArchiveItemCount)
        return -1;

    ArchiveFileStruct * CurArcFile = GetFileStruct(ind);

    u32 done = 0;

	char * RealFilename = strrchr(CurArcFile->filename, '/');
	if(RealFilename)
        RealFilename += 1;
    else
        RealFilename = CurArcFile->filename;

	char writepath[1024];
	if(withpath)
        snprintf(writepath, sizeof(writepath), "%s/%s", dest, CurArcFile->filename);
    else
        snprintf(writepath, sizeof(writepath), "%s/%s", dest, RealFilename);

	u32 filesize = CurArcFile->length;

    if(CurArcFile->isdir)
    {
        strncat(writepath, "/", sizeof(writepath));
        CreateSubfolder(writepath);
        return 1;
    }

    int ret = unzOpenCurrentFile(uzFile);

    if(ret != UNZ_OK)
        return -2;

    char * temppath = strdup(writepath);
    char * pointer = strrchr(temppath, '/');
    if(pointer)
    {
        pointer += 1;
        pointer[0] = '\0';
    }

    CreateSubfolder(temppath);

    free(temppath);
    temppath = NULL;

    u32 blocksize = 1024*50;
    void *buffer = malloc(blocksize);

    FILE *pfile = fopen(writepath, "wb");
    if(!pfile)
    {
        unzCloseCurrentFile(uzFile);
        free(buffer);
        fclose(pfile);
        WindowPrompt(("Could not extract file:"), CurArcFile->filename, "OK", NULL);
        return -3;
    }

    do
    {
        if(filesize - done < blocksize)
            blocksize = filesize - done;

        ret = unzReadCurrentFile(uzFile, buffer, blocksize);
        if(ret < 0)
        {
            free(buffer);
            fclose(pfile);
            unzCloseCurrentFile(uzFile);
            return -4;
        }

        fwrite(buffer, 1, blocksize, pfile);

        done += ret;

    } while(done < filesize);

    fclose(pfile);
    unzCloseCurrentFile(uzFile);

    free(buffer);

    return 1;
}
コード例 #26
0
int TitleBrowser()
{
	u32 num_titles;
	u32 num_sys_titles;
	s32 ret = -1;
	u64 *titleList = NULL;

	// Get count of titles of the good titles
	num_titles = NandTitles.SetType(0x10001);
	u32 n = num_titles;
	for (u32 i = 0; i < n; i++)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}

		//remove ones not actually installed on the nand
		if (!NandTitles.Exists(tid))
		{
			num_titles--;
		}
	}

	// Get count of system titles
	num_sys_titles = NandTitles.SetType(0x10002);
	n = num_sys_titles;
	for (u32 i = 0; i < n; i++)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}
		//these can't be booted anyways
		if (TITLE_LOWER( tid ) == 0x48414741 || TITLE_LOWER( tid ) == 0x48414141 || TITLE_LOWER( tid ) == 0x48414641)
		{
			num_sys_titles--;
			continue;
		}

		//these aren't installed on the nand
		if (!NandTitles.Exists(tid))
		{
			num_sys_titles--;
		}
	}

	//make a list of just the tids we are adding to the titlebrowser
	titleList = (u64*) memalign(32, (num_titles + num_sys_titles) * sizeof(u64));
	if (!titleList)
	{
		gprintf("TitleBrowser(): out of memory!\n");
		return -1;
	}
	OptionList options3;
	//write the titles on the option browser

	std::string Filepath = Settings.titlestxt_path;
	Filepath += "wiitdb.xml";

	GameTDB *XML_DB = new GameTDB(Filepath.c_str());
	XML_DB->SetLanguageCode(Settings.db_language);

	u32 i = 0;
	NandTitles.SetType(0x10001);
	//first add the good stuff
	while (i < num_titles)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			gprintf("shit happened3\n");
			break;
		}
		gprintf("[ %u ] tid: %016llx\t%s\n", i, tid, NandTitles.NameOf(tid));

		if (!NandTitles.Exists(tid))
		{
			continue;
		}

		char id[5];
		NandTitles.AsciiTID(tid, (char*) &id);

		const char* name = NULL;
		std::string TitleName;

		if(XML_DB->GetTitle(id, TitleName))
			name = TitleName.c_str();
		else
			name = NandTitles.NameOf(tid);

		options3.SetName(i, "%s", id);
		options3.SetValue(i, "%s", name ? name : tr( "Unknown" ));
		titleList[i] = tid;
		i++;
	}

	NandTitles.SetType(0x10002);
	while (i < num_sys_titles + num_titles)
	{
		u64 tid = NandTitles.Next();
		if (!tid)
		{
			break;
		}
		if (TITLE_LOWER( tid ) == 0x48414741 || TITLE_LOWER( tid ) == 0x48414141 || TITLE_LOWER( tid ) == 0x48414641) continue;

		if (!NandTitles.Exists(tid))
		{
			continue;
		}

		char id[5];
		NandTitles.AsciiTID(tid, (char*) &id);

		const char* name = NULL;
		std::string TitleName;

		if(XML_DB->GetTitle(id, TitleName))
			name = TitleName.c_str();
		else
			name = NandTitles.NameOf(tid);

		options3.SetName(i, "%s", id);
		options3.SetValue(i, "%s", name ? name : tr( "Unknown" ));
		titleList[i] = tid;
		i++;
	}

	delete XML_DB;
	XML_DB = NULL;

	if (i == num_titles + num_sys_titles)
	{
		options3.SetName(i, " ");
		options3.SetValue(i, "%s", tr( "Wii Settings" ));
	}

	bool exit = false;
	int total = num_titles + num_sys_titles;

	if (IsNetworkInit()) ResumeNetworkWait();

	GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
	GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	GuiTrigger trigHome;
	trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
	GuiTrigger trigB;
	trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiText titleTxt(tr( "Title Launcher" ), 28, ( GXColor )
	{   0, 0, 0, 255});
	titleTxt.SetAlignment(ALIGN_CENTER, ALIGN_TOP);
	titleTxt.SetPosition(12, 40);
	titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);

	GuiImage settingsbackground(&settingsbg);
	GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
	settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	settingsbackgroundbtn.SetPosition(0, 0);
	settingsbackgroundbtn.SetImage(&settingsbackground);

	GuiText cancelBtnTxt(tr( "Back" ), 22, thColor("r=0 g=0 b=0 a=255 - prompt windows button text color"));
	cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth() - 30);
	GuiImage cancelBtnImg(&btnOutline);
	if (Settings.wsprompt)
	{
		cancelBtnTxt.SetWidescreen(Settings.widescreen);
		cancelBtnImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton cancelBtn(&cancelBtnImg, &cancelBtnImg, 2, 3, 180, 400, &trigA, btnSoundOver, btnSoundClick2, 1);
	cancelBtn.SetScale(0.9);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetTrigger(&trigB);

	GuiOptionBrowser optionBrowser3(396, 280, &options3, "bg_options_settings.png");
	optionBrowser3.SetPosition(0, 90);
	optionBrowser3.SetAlignment(ALIGN_CENTER, ALIGN_TOP);

	GuiImageData wifiImgData(Resources::GetFile("wifi_btn.png"), Resources::GetFileSize("wifi_btn.png"));
	GuiImage wifiImg(&wifiImgData);
	if (Settings.wsprompt)
	{
		wifiImg.SetWidescreen(Settings.widescreen);
	}
	GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight());
	wifiBtn.SetImage(&wifiImg);
	wifiBtn.SetPosition(100, 400);
	wifiBtn.SetEffectGrow();
	wifiBtn.SetAlpha(80);
	wifiBtn.SetTrigger(&trigA);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&settingsbackgroundbtn);
	w.Append(&titleTxt);
	w.Append(&cancelBtn);
	w.Append(&wifiBtn);
	w.Append(&optionBrowser3);
	mainWindow->Append(&w);

	ResumeGui();

	while (!exit)
	{
		VIDEO_WaitVSync();

		if (shutdown == 1) Sys_Shutdown();
		if (reset == 1)
			Sys_Reboot();

		else if (wifiBtn.GetState() == STATE_CLICKED)
		{
			ResumeNetworkWait();
			wifiBtn.ResetState();
		}

		if (IsNetworkInit())
		{
			wifiBtn.SetAlpha(255);
		}

		ret = optionBrowser3.GetClickedOption();

		if (ret > -1)
		{ //if a click happened

			if (ret < total)
			{
				//set the title's name, number, ID to text
				char text[0x100];
				char id[5];
				NandTitles.AsciiTID(titleList[ret], (char*) &id);

				snprintf(text, sizeof(text), "%s : %s", id, NandTitles.NameOf(titleList[ret]));

				//prompt to boot selected title
				if (WindowPrompt(tr( "Boot?" ), text, tr( "OK" ), tr( "Cancel" )))
				{ //if they say yes
					ExitApp();
					WII_Initialize();
					WII_LaunchTitle(titleList[ret]);
					//this really shouldn't be needed because the title will be booted
					exit = true;
					break;
				}
				else
				{
					//if they said no to booting the title
					ret = -1;
					optionBrowser3.ResetState();
				}

			}
			else if (ret == total)
			{ //if they clicked to go to the wii settings
				ExitApp();
				WII_Initialize();
				WII_ReturnToSettings();
			}
		}
		if (cancelBtn.GetState() == STATE_CLICKED)
		{
			//break the loop and end the function
			exit = true;
			ret = -10;
		}
	}

	CloseConnection();
	if (IsNetworkInit()) HaltNetworkThread();

	HaltGui();
	mainWindow->Remove(&w);
	free(titleList);
	ResumeGui();

	return ret;
}
コード例 #27
0
void Explorer::ProcessChoice(int choice)
{
	FileBrowser * browser = (FileBrowser *) curBrowser;
	if(!browser)
		return;

	else if(browser->GetCurrentFilename() && strcmp(browser->GetCurrentFilename(),"..") != 0)
	{
		if(choice == CUT)
		{
			choice = WindowPrompt(browser->GetCurrentFilename(), tr("Cut current marked item(s)?"), tr("Yes"), tr("Cancel"));
			if(choice == 1)
			{
				Clipboard::Instance()->Reset();
				//append selected Item
				browser->MarkCurrentItem();
				//Get ItemMarker
				ItemMarker * IMarker = browser->GetItemMarker();

				for(int i = 0; i < IMarker->GetItemcount(); i++)
					Clipboard::Instance()->AddItem(IMarker->GetItem(i));

				IMarker->Reset();
				Clipboard::Instance()->Operation = OP_MOVE;
			}
		}

		else if(choice == COPY)
		{
			choice = WindowPrompt(browser->GetCurrentFilename(), tr("Copy current marked item(s)?"), tr("Yes"), tr("Cancel"));
			if(choice == 1)
			{
				Clipboard::Instance()->Reset();
				//append selected Item
				browser->MarkCurrentItem();
				//Get ItemMarker
				ItemMarker * IMarker = browser->GetItemMarker();

				for(int i = 0; i < IMarker->GetItemcount(); i++)
					Clipboard::Instance()->AddItem(IMarker->GetItem(i));

				IMarker->Reset();
				Clipboard::Instance()->Operation = OP_COPY;
			}
		}

		else if(choice == RENAME)
		{
			char srcpath[MAXPATHLEN];
			char destdir[MAXPATHLEN];
			snprintf(srcpath, sizeof(srcpath), "%s", browser->GetCurrentSelectedFilepath());
			char entered[151];
			snprintf(entered, sizeof(entered), "%s", browser->GetCurrentFilename());
			int result = OnScreenKeyboard(entered, 150);
			if(result == 1)
			{
				snprintf(destdir, sizeof(destdir), "%s/%s", browser->GetCurrentPath(), entered);
				if(!RenameFile(srcpath, destdir))
					WindowPrompt(tr("Failed renaming item"), tr("Name might already exists."), tr("OK"));
				//! Update browser
				guiBrowser->Refresh();
			}
		}

		else if(choice == DELETE)
		{
			char currentpath[MAXPATHLEN];
			snprintf(currentpath, sizeof(currentpath), "%s/", browser->GetCurrentSelectedFilepath());
			choice = WindowPrompt(browser->GetCurrentFilename(), tr("Delete the selected item(s) and its content?"), tr("Yes"), tr("Cancel"));
			if(choice == 1)
			{
				if(ProgressWindow::Instance()->IsRunning())
					choice = WindowPrompt(tr("Currently a process is running."), tr("Do you want to append this delete to the queue?"), tr("Yes"), tr("Cancel"));

				if(choice == 1)
				{
					//append selected Item
					browser->MarkCurrentItem();
					//Get ItemMarker
					ItemMarker * IMarker = browser->GetItemMarker();
					DeleteTask *task = new DeleteTask(IMarker);
					task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
					this->explorerTasks++;
					Taskbar::Instance()->AddTask(task);
					ThreadedTaskHandler::Instance()->AddTask(task);
					IMarker->Reset();
				}
			}
		}
	}
	else if(choice >= 0 && choice != PASTE && choice != NEWFOLDER && choice != PROPERTIES)
		WindowPrompt(tr("You cant use this operation on:"), tr("Directory .."), tr("OK"));

	if(choice == PASTE)
	{
		choice = WindowPrompt(Clipboard::Instance()->GetItemName(Clipboard::Instance()->GetItemcount()-1), tr("Paste item(s) into current directory?"), tr("Yes"), tr("Cancel"));
		if(choice == 1)
		{
			if(ProgressWindow::Instance()->IsRunning())
				choice = WindowPrompt(tr("Currently a process is running."), tr("Do you want to append this paste to the queue?"), tr("Yes"), tr("Cancel"));

			if(choice == 1)
			{
				if(Clipboard::Instance()->Operation == OP_COPY)
				{
					CopyTask *task = new CopyTask(Clipboard::Instance(), browser->GetCurrentPath());
					task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
					this->explorerTasks++;
					Taskbar::Instance()->AddTask(task);
					ThreadedTaskHandler::Instance()->AddTask(task);
				}
				else if(Clipboard::Instance()->Operation == OP_MOVE)
				{
					MoveTask *task = new MoveTask(Clipboard::Instance(), browser->GetCurrentPath());
					task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
					this->explorerTasks++;
					Taskbar::Instance()->AddTask(task);
					ThreadedTaskHandler::Instance()->AddTask(task);
				}
			}
		}
	}

	else if(choice == ADDTOZIP)
	{
		int ret = WindowPrompt(browser->GetCurrentFilename(), tr("Would you like to add/append the selected item(s) to a zip?"), tr("Yes"), tr("No"));
		if(ret <= 0)
			return;

		char DestZipPath[MAXPATHLEN];
		snprintf(DestZipPath, sizeof(DestZipPath), "%s", browser->GetCurrentPath());
		if(DestZipPath[strlen(DestZipPath)-1] != '/')
			strncat(DestZipPath, "/", sizeof(DestZipPath));
		strncat(DestZipPath, tr("NewZip.zip"), sizeof(DestZipPath));

		if(!OnScreenKeyboard(DestZipPath, sizeof(DestZipPath)))
			return;

		std::string DestPath = DestZipPath;
		size_t pos = DestPath.rfind('/');
		if(pos != std::string::npos)
			DestPath.erase(pos);

		CreateSubfolder(DestPath.c_str());

		//append selected Item
		browser->MarkCurrentItem();
		//Get ItemMarker
		ItemMarker * IMarker = browser->GetItemMarker();

		ZipFile *Zip = new ZipFile(DestZipPath, CheckFile(DestZipPath) ? ZipFile::APPEND : ZipFile::CREATE);
		ArchiveHandle * archive = new ArchiveHandle(Zip);

		PackTask *task = new PackTask(IMarker, "", archive, Settings.CompressionLevel);
		task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
		this->explorerTasks++;
		Taskbar::Instance()->AddTask(task);
		ThreadedTaskHandler::Instance()->AddTask(task);

		//! Update browser
		IMarker->Reset();
	}

	else if(choice == CHECK_MD5)
	{
		int md5Choice = 1;

		if(ProgressWindow::Instance()->IsRunning())
			md5Choice = WindowPrompt(tr("Currently a process is running."), tr("Do you want to append this process to the queue?"), tr("Yes"), tr("Cancel"));

		if(md5Choice == 1)
		{
			char LogPath[1024];
			snprintf(LogPath, sizeof(LogPath), "%s/MD5.log", browser->GetCurrentPath());

			browser->MarkCurrentItem();
			MD5Task *task = new MD5Task(browser->GetItemMarker(), LogPath);
			task->TaskEnd.connect(this, &Explorer::OnFinishedTask);
			this->explorerTasks++;
			Taskbar::Instance()->AddTask(task);
			ThreadedTaskHandler::Instance()->AddTask(task);
			browser->GetItemMarker()->Reset();
		}
	}

	else if(choice == NEWFOLDER)
	{
		char entered[151];
		snprintf(entered, sizeof(entered), tr("New Folder"));
		int result = OnScreenKeyboard(entered, 150);
		if(result == 1)
		{
			char currentpath[MAXPATHLEN];
			snprintf(currentpath, sizeof(currentpath), "%s/%s/", browser->GetCurrentPath(), entered);
			bool ret = CreateSubfolder(currentpath);
			if(ret == false)
				ShowError(tr("Unable to create folder."));

			//! Update browser
			guiBrowser->Refresh();
		}
	}
	else if(choice == PROPERTIES)
	{
		browser->MarkCurrentItem();
		ItemMarker * Marker = browser->GetItemMarker();
		Properties * Prompt = new Properties(Marker);
		Prompt->SetAlignment(ALIGN_CENTER | ALIGN_MIDDLE);
		Prompt->DimBackground(true);
		Application::Instance()->SetUpdateOnly(Prompt);
		Application::Instance()->Append(Prompt);
		Marker->Reset();
	}
}
コード例 #28
0
int UpdateLanguageFiles()
{
	if(!CreateSubfolder(Settings.languagefiles_path))
	{
		ShowError(tr("Could not create path: %s"), Settings.languagefiles_path);
		return -1;
	}

	if(!IsNetworkInit())
	{
		ShowError(tr("Network is not initiated."));
		return -2;
	}

	DirList Dir(Settings.languagefiles_path, ".lang");

	//give up now if we didn't find any
	if (Dir.GetFilecount() == 0)
	{
		if(WindowPrompt(tr("Error:"), tr("No language files to update on your devices! Do you want to download new language files?"), tr("Yes"), tr("No")))
			return DownloadAllLanguageFiles();

		return -2;
	}

	char savepath[150];
	char codeurl[200];

	//we assume that the network will already be init by another function
	// ( that has gui eletents in it because this one doesn't)
	int done = 0;

	//build the URL, save path, and download each file and save it
	for(int i = 0; i < Dir.GetFilecount(); ++i)
	{
		snprintf(codeurl, sizeof(codeurl), "%s%s?p=%s", LanguageFilesURL, Dir.GetFilename(i), GetRev());
		snprintf(savepath, sizeof(savepath), "%s/%s", Settings.languagefiles_path, Dir.GetFilename(i));

		struct block file = downloadfile(codeurl);

		ShowProgress(tr("Updating Language Files:"), 0, Dir.GetFilename(i), i, Dir.GetFilecount(), false, true);

		if (file.data != NULL)
		{
			FILE * pfile;
			pfile = fopen(savepath, "wb");
			if (pfile != NULL)
			{
				fwrite(file.data, 1, file.size, pfile);
				fclose(pfile);
				done++;
			}
			free(file.data);
		}
	}

	ProgressStop();

	// reload current language file
	if(Settings.language_path[0] != 0)
		Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT);
	else
		Settings.LoadLanguage(NULL, CONSOLE_DEFAULT);

	// return the number of files we updated
	return done;
}
コード例 #29
0
int HomeMenu::GetChoice()
{
	for (int i = 0; i < 4; i++)
	{
		if (WPAD_Probe(i, NULL) == WPAD_ERR_NONE)
		{
			int level = (WPAD_BatteryLevel(i) / 100.0) * 4;
			if (level > 4) level = 4;

			if (level <= 1) {
				BatteryBarImg[i]->SetImage(BatteryBarRedImgData);
				BatteryImg[i]->SetImage(BatteryRedImgData);
			} else {
				BatteryBarImg[i]->SetImage(BatteryBarImgData);
				BatteryImg[i]->SetImage(BatteryImgData);
			}

			BatteryImg[i]->SetTile(level);
			BatteryBtn[i]->SetAlpha(255);
			PlayerText[i]->SetAlpha(255);
		}
		else
		{
			BatteryBarImg[i]->SetImage(BatteryBarImgData);
			BatteryImg[i]->SetTile(0);
			BatteryBtn[i]->SetAlpha(130);
			PlayerText[i]->SetAlpha(100);
		}
	}

	if (TopBtn->GetState() == STATE_CLICKED)
	{
		TopBtn->ResetState();
		FadeOut();
		choice = 0; // return to SaveGame Manager GX
	}
	else if (BottomBtn->GetState() == STATE_CLICKED)
	{
		BottomBtn->ResetState();
		FadeOut();
		choice = 0; // return to SaveGame Manager GX
	}
	else if (ExitBtn->GetState() == STATE_CLICKED)
	{
		ExitBtn->ResetState();
		
		this->SetState(STATE_DISABLED);
		
		int ret = WindowPrompt(tr("Back to Loader"), 0, tr("Homebrew Channel"), tr("Wii Menu"), tr("Cancel"), 0, false);
		if (ret == 1)
			Sys_BackToLoader();
		else if(ret == 2)
		    Sys_LoadMenu();
		
		this->SetState(STATE_DEFAULT);
	}
	else if (ShutdownBtn->GetState() == STATE_CLICKED)
	{
		ShutdownBtn->ResetState();
		
		this->SetState(STATE_DISABLED);
		
		int ret = WindowPrompt(tr("ShutDown Wii"), 0, tr("Full Shutdown"), tr("Idle Shutdown"), tr("Cancel"), 0, false);
		if (ret == 1)
			Sys_ShutdownToStandby();
		else if (ret == 2)
		    Sys_ShutdownToIdle();
		
		this->SetState(STATE_DEFAULT);
	}
	else if (BottomBtn->GetState() == STATE_SELECTED)
	{
		WiimoteBtn->SetPosition(WiimoteBtn->GetLeft(), 210);
	}
	else if (BottomBtn->GetState() != STATE_SELECTED)
	{
		WiimoteBtn->SetPosition(WiimoteBtn->GetLeft(), 232);
	}

	return choice;
}
コード例 #30
0
	Append(resetBtn);

	SetupOptions();
}

ControlsSettingsMenu::~ControlsSettingsMenu()
{
	Remove(resetBtn);
	delete resetBtnTxt;
	delete resetBtnImg;
	delete resetBtn;
}

void ControlsSettingsMenu::OnResetButtonClick(GuiButton *sender UNUSED, int pointer UNUSED, const POINT &p UNUSED)
{
	int choice = WindowPrompt(tr("Do you want to reset the control settings?"), 0, tr("Yes"), tr("Cancel"));
	if(choice)
	{
		Settings.Controls.SetDefault();
		SetOptionValues();
	}
}

void ControlsSettingsMenu::SetupOptions()
{
	int i = 0;

	options.SetName(i++, tr("Screen Pointer Speed"));
	options.SetName(i++, tr("Screenshot Hold Button"));
	options.SetName(i++, tr("Screenshot Press Button"));
	options.SetName(i++, tr("Click Button"));