コード例 #1
0
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
revtext(const char *msg)
{
	bool stop = false;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	TextLine revtext;
	revtext.text(msg, 18, 400);

    int i = 0;
    int y = 90;
	int place = 25;

	int number = 7;

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiText * Entrie[number];

	for(i=0; i < number && i < (signed)revtext.line.size(); i++)
	{
		Entrie[i] = new GuiText(revtext.line[i].c_str(), 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i]->SetPosition(50, y);
		y += place;
	}

	GuiText titleTxt(tr("Info"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);

	GuiText backTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());

	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -25);

	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)revtext.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(!stop)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP)
		{
			int z = revtext.text_up();

			for(int x=0; x < i; x++)
				Entrie[x]->SetText(revtext.line[x + z].c_str());


			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
		{
			int z = revtext.text_down(number);

			for(int x=0; x < i; x++)
				Entrie[x]->SetText(revtext.line[x + z].c_str());


			HaltResumeGui();
		}

		if(back.GetState() == STATE_CLICKED)
			stop = true;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
コード例 #2
0
int MenuSettingsTheme()
{
	int menu = MENU_NONE;

	int ret = -1;
	int activated = -1;
	int i = 0;
	int focus = 0;

	OptionList options;

	sprintf(options.name[i], tr("STANDARD"));
	if(stricmp(Options.temp_theme.c_str(), tr("STANDARD")) == 0)
	{
		sprintf (options.value[i], tr("activated"));
		activated = i;
	}
	else
		sprintf (options.value[i], " ");

	i++;

	DIR *dirHandle;
	struct dirent * dirEntry;
	dirHandle = opendir(check_path(Settings.device_dat + ":/config/HBF/Themes").c_str());
	if (dirHandle) {
		while (0 != (dirEntry = readdir(dirHandle)))
		{
			if(stricmp(dirEntry->d_name, ".") != 0 && stricmp(dirEntry->d_name, "..") != 0)
			{
				sprintf(options.name[i], dirEntry->d_name);

				if(stricmp(Options.temp_theme.c_str(), dirEntry->d_name) == 0)
				{
					sprintf (options.value[i], tr("activated"));
					activated = i;
				}
				else
					sprintf (options.value[i], " ");

				i++;
			}
		}
		closedir(dirHandle);
	}

	options.length = i;

	GuiImageData bgImgData(Theme.background);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage bgImg(&bgImgData);

	GuiText titleTxt(tr("Themes"), 28, (GXColor){Theme.title_1, Theme.title_2, Theme.title_3, 255});
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiText downloadBtnTxt(tr("Download"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage downloadBtnImg(&btnOutline);
	GuiImage downloadBtnImgOver(&btnOutlineOver);
	GuiButton downloadBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	downloadBtn.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	downloadBtn.SetPosition(-100, 38);
	downloadBtn.SetLabel(&downloadBtnTxt);
	downloadBtn.SetImage(&downloadBtnImg);
	downloadBtn.SetImageOver(&downloadBtnImgOver);
	downloadBtn.SetTrigger(&trigA);
	downloadBtn.SetEffectGrow();

	GuiText okBtnTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(100, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

	GuiText backBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backBtnImg(&btnOutline);
	GuiImage backBtnImgOver(&btnOutlineOver);
	GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	backBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	backBtn.SetPosition(-100, -35);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetImage(&backBtnImg);
	backBtn.SetImageOver(&backBtnImgOver);
	backBtn.SetTrigger(&trigA);
	backBtn.SetEffectGrow();

	GuiOptionBrowser optionBrowser(552, 248, &options);
	optionBrowser.SetPosition(0, 108);
	optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	optionBrowser.Col1Scroll(280);
	optionBrowser.SetCol2Position(340);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&bgImg);
	w.Append(&titleTxt);
	w.Append(&downloadBtn);
	w.Append(&okBtn);
	w.Append(&backBtn);
	mainWindow->Append(&w);
	mainWindow->Append(&optionBrowser);

	mainWindow->ChangeFocus(&optionBrowser);
	ResumeGui();

	while(menu == MENU_NONE)
	{
		usleep(100);

		ret = optionBrowser.GetClickedOption();

		if(ret != -1)
		{
			for(i=0; i < options.length; i++)
			{
				if(i == ret)
				{
					sprintf (options.value[i], tr("activated"));
					activated = i;
				}
				else
					sprintf (options.value[i], " ");
			}
			optionBrowser.TriggerUpdate();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_B)
		{
			if(focus == 0)
			{
				focus = 1;
				mainWindow->ChangeFocus(&w);
				downloadBtn.ResetState();
				okBtn.SetState(STATE_SELECTED);
			}
			else
			{
				focus = 0;
				mainWindow->ChangeFocus(&optionBrowser);
			}
			HaltResumeGui();
		}

		if(downloadBtn.GetState() == STATE_CLICKED)
		{
			downloadBtn.ResetState();
			string themedownload = checkThemesPrompt();
			if(themedownload != "NULL")
			{
				if(theme_folder_exists(themedownload))
				{
					themeDownload(themedownload);
					menu = MENU_SETTINGS_THEME;
					theme_dl = true;
					break;
				}
			}
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			Options.temp_theme = options.name[activated];
			menu = MENU_SETTINGS_FILE;
		}

		if(backBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}

		if(runaway == true)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}
	}
	HaltGui();
	mainWindow->Remove(&optionBrowser);
	mainWindow->Remove(&w);
	return menu;
}
コード例 #3
0
/****************************************************************************
 * Kategorie entfernen
 ***************************************************************************/
string eraseCategory()
{
	bool stop = true;
	int kategorieInt = 1;
	string kategoriename = AvailableCategory.categories[kategorieInt];

	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);

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiText zeile1Txt(tr("Remove Category"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile1Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile1Txt.SetPosition(0, -100);

	GuiText zeile2Txt(AvailableCategory.categories[1].c_str(), 24, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile2Txt.SetPosition(0, -10);

	GuiText zeile4Txt(tr("Select Category   (-/+)"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	zeile4Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	zeile4Txt.SetPosition(0, 60);

	GuiText okTxt(tr("Yes"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okImg(&btnOutline);
	GuiImage okImgOver(&btnOutlineOver);
	GuiButton ok(btnOutline.GetWidth(), btnOutline.GetHeight());
	ok.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	ok.SetPosition(-120, -25);
	ok.SetLabel(&okTxt);
	ok.SetImage(&okImg);
	ok.SetImageOver(&okImgOver);
	ok.SetTrigger(&trigA);

	GuiText backTxt(tr("No"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());
	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(120, -25);
	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetTrigger(&trigB);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&zeile1Txt);
	promptWindow.Append(&zeile2Txt);
	promptWindow.Append(&zeile4Txt);
	promptWindow.Append(&ok);
	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(stop)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_R
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_PLUS)
		{
			kategorieInt++;
			if ( kategorieInt >= (signed)AvailableCategory.categories.size() )
				kategorieInt = 1;

			kategoriename = AvailableCategory.categories[kategorieInt];
			zeile2Txt.SetText(kategoriename.c_str());
			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS) || PAD_ButtonsDown(0) & PAD_TRIGGER_L
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_MINUS)
		{
			kategorieInt--;
			if ( kategorieInt < 1 )
				kategorieInt = AvailableCategory.categories.size() -1;

			kategoriename = AvailableCategory.categories[kategorieInt];
			zeile2Txt.SetText(kategoriename.c_str());
			HaltResumeGui();
		}

		if(ok.GetState() == STATE_CLICKED)
			stop = false;

		if(back.GetState() == STATE_CLICKED)
		{
			kategoriename = "NULL";
			stop = false;
		}
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();

	return kategoriename;
}
コード例 #4
0
string choiceRev(string revs)
{
	bool stop = false;
	string rev = "NULL";

	TextLine versions;
	versions.list(revs);

	GuiText titleTxt(tr("Update"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	int place = 23;
	int y = 150;
	int i = 0;
	int number = 5;
	int selection = 0;
	int selctionPos = y;

	GuiText selectionTxt(">>                              <<", 20, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	selectionTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	selectionTxt.SetPosition(0, y);

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiText * Entrie[number];

	for(i=0; i < number && i < (signed)versions.line.size(); i++)
	{
		Entrie[i] = new GuiText(versions.line[i].c_str(), 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		Entrie[i]->SetPosition(0, y);
		y += place;
	}

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&selectionTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)versions.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

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

	while(!stop)
	{
		usleep(100);

		if(WPAD_ButtonsHeld(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP)
		{

			selection--;
			if(selection < 0)
			{
				selection = 0;

				int z = versions.text_up();
				for(int x=0; x < i; x++)
					Entrie[x]->SetText(versions.line[x + z].c_str());
			}
			selectionTxt.SetPosition(0, selection * place + selctionPos);

			HaltResumeGui();
			usleep(100000);
		}

		if(WPAD_ButtonsHeld(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN)
		{

			selection++;
			if(selection > number -1)
			{
				selection = number -1;

				int z = versions.text_down(number);
				for(int x=0; x < i; x++)
					Entrie[x]->SetText(versions.line[x + z].c_str());
			}
			selectionTxt.SetPosition(0, selection * place + selctionPos);

			HaltResumeGui();
			usleep(100000);
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A) || PAD_ButtonsDown(0) & PAD_BUTTON_A)
		{
			rev = versions.line[selection + versions.textScrollPos];
			stop = true;
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B)
			stop = true;
	}

	promptWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
	while(promptWindow.GetEffect() > 0) usleep(100);
	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
	return rev;
}
コード例 #5
0
/****************************************************************************
 * MetaEdit
 *
 * meta bearbeiten
 ***************************************************************************/
bool
MetaEdit(string dir)
{
	int choice = -1;
	bool changed = false;

	dir += "meta.xml";
	string line, quelltext;

	ifstream in(dir.c_str());
	while(getline(in, line))
		quelltext += line + "\n";

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	TextLine meta;
	meta.text(quelltext, 18, 440);

    int i = 0;
    int y = 90;
	int place = 25;

	int number = 7;
	int startline = 0;

	GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	upTxt.SetFont(symbol_ttf, symbol_ttf_size);
	upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	upTxt.SetPosition(0, y -20);

	GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downTxt.SetFont(symbol_ttf, symbol_ttf_size);
	downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	downTxt.SetPosition(0, y + (place * (number-1)) + 15);

	GuiButton * Entrie[number];
	GuiText * EntrieTxt[number];

	for(i=0; i < number && i < (signed)meta.line.size(); i++)
	{
		EntrieTxt[i] = new GuiText(meta.line[i].c_str(), 18, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
		EntrieTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i] = new GuiButton(440, 18);
		Entrie[i]->SetLabel(EntrieTxt[i]);
		Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
		Entrie[i]->SetPosition(40, y);
		Entrie[i]->SetTrigger(&trigA);
		y += place;
	}

	GuiText titleTxt("meta.xml", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0,40);

	GuiText backTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());

	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -25);

	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetState(STATE_SELECTED);

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);

	for(int x=0; x < i; x++)
		promptWindow.Append(Entrie[x]);

	if((signed)meta.line.size() >= number)
	{
		promptWindow.Append(&upTxt);
		promptWindow.Append(&downTxt);
	}

	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(choice == -1)
	{
		usleep(100);

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_UP)
		{
			startline = meta.text_up();

			for(int x=0; x < i; x++)
				EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN
		   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_DOWN)
		{
			startline = meta.text_down(number);

			for(int x=0; x < i; x++)
				EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

			HaltResumeGui();
		}

		if(back.GetState() == STATE_CLICKED)
			choice = 0;

		for(int x=0; x < i; x++)
		{
			if(Entrie[x]->GetState() == STATE_CLICKED)
			{
				Entrie[x]->ResetState();

				string temp = meta.line[x + startline];
				while((signed)temp.find("\n") != -1)
					temp.replace(temp.find("\n"), 1, "¶");

				char new_text[256];
				sprintf (new_text, "%s", temp.c_str());
				OnScreenKeyboard(new_text, 256, true);

				mainWindow->SetState(STATE_DISABLED);
				promptWindow.SetState(STATE_DEFAULT);

				if(strcasecmp(new_text,"NULL") != 0 )
				{
					changed = true;
					meta.line[x + startline] = new_text;
					while((signed)meta.line[x + startline].find("¶") != -1)
						meta.line[x + startline].replace(meta.line[x + startline].find("¶"), 1, "\n");

					EntrieTxt[x]->SetText(meta.line[x + startline].c_str());

					quelltext.clear();
					for(int a = 0; a < (signed)meta.line.size(); a++)
						quelltext += meta.line[a];

					meta.text(quelltext, 18, 440);
					for(int x=0; x < i; x++)
						EntrieTxt[x]->SetText(meta.line[x + startline].c_str());
				}

				break;
			}
		}
	}

	if(changed)
	{
		ofstream datei(dir.c_str());
		datei << quelltext;
	//	for(int i = 0; i < (signed)meta.line.size(); i++)
	//		datei << meta.line[i];
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
	return choice;
}
コード例 #6
0
/****************************************************************************
 * MenuSettings
 ***************************************************************************/
int MenuSettingsNetwork()
{
	int menu = MENU_NONE;

	int ret = -1;
	int i = 0;
	int focus = 0;

	int network = Options.temp_network;
	int wifigecko = Options.temp_wifigecko;
	int newrevtext = Options.temp_newrevtext;

	OptionList options;

	sprintf(options.name[i++], tr("Auto Connect"));
	sprintf(options.name[i++], tr("Enable Wifi Gecko"));
	sprintf(options.name[i++], tr("Update Info"));
	options.length = i;

	GuiImageData bgImgData(Theme.background);
	GuiImageData btnOutline(Theme.button_small);
	GuiImageData btnOutlineOver(Theme.button_small_focus);

	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

	GuiImage bgImg(&bgImgData);

	GuiText titleTxt(tr("Network Settings"), 28, (GXColor){Theme.title_1, Theme.title_2, Theme.title_3, 255});
	titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiText okBtnTxt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(100, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

	GuiText backBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiImage backBtnImg(&btnOutline);
	GuiImage backBtnImgOver(&btnOutlineOver);
	GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	backBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	backBtn.SetPosition(-100, -35);
	backBtn.SetLabel(&backBtnTxt);
	backBtn.SetImage(&backBtnImg);
	backBtn.SetImageOver(&backBtnImgOver);
	backBtn.SetTrigger(&trigA);
	backBtn.SetEffectGrow();

	GuiOptionBrowser optionBrowser(552, 248, &options);
	optionBrowser.SetPosition(0, 108);
	optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	optionBrowser.SetCol2Position(340);

	HaltGui();
	GuiWindow w(screenwidth, screenheight);
	w.Append(&bgImg);
	w.Append(&titleTxt);
	w.Append(&okBtn);
	w.Append(&backBtn);
	mainWindow->Append(&w);
	mainWindow->Append(&optionBrowser);

	mainWindow->ChangeFocus(&optionBrowser);
	ResumeGui();

	int change = 0;
	while(menu == MENU_NONE)
	{
		usleep(100);

		ret = optionBrowser.GetChangedOption();

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT) || PAD_ButtonsDown(0) & PAD_BUTTON_RIGHT)
		{
			change = 0;
			switch (ret)
			{
				case 0:
					change = network;
					change++;
					if(change > 1)
						change = 1;
					network = change;
					break;

				case 1:
					change = wifigecko;
					change++;
					if(change > 1)
						change = 1;
					wifigecko = change;
					break;

				case 2:
					change = newrevtext;
					change++;
					if(change > 1)
						change = 1;
					newrevtext = change;
					break;
			}
			HaltResumeGui();
		}

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT) || PAD_ButtonsDown(0) & PAD_BUTTON_LEFT)
		{
			change = 0;
			switch (ret)
			{
				case 0:
					change = network;
					change--;
					if(change < 0)
						change = 0;
					network = change;
					break;

				case 1:
					change = wifigecko;
					change--;
					if(change < 0)
						change = 0;
					wifigecko = change;
					break;

				case 2:
					change = newrevtext;
					change--;
					if(change < 0)
						change = 0;
					newrevtext = change;
					break;
			}
			HaltResumeGui();
		}

		if(change != -1)
		{
			change = -1;

			if(network == 0)
				sprintf (options.value[0], tr("No"));
			else
				sprintf (options.value[0], tr("Yes"));

			if(wifigecko == 0)
				sprintf (options.value[1], tr("No"));
			else
				sprintf (options.value[1], tr("Yes"));

			if(newrevtext == 0)
				sprintf (options.value[2], tr("No"));
			else
				sprintf (options.value[2], tr("Yes"));

			optionBrowser.TriggerUpdate();
		}

		if(optionBrowser.GetClickedOption() != -1)
			optionBrowser.TriggerUpdate();

		if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B)
		{
			if(focus == 0)
			{
				focus = 1;
				mainWindow->ChangeFocus(&w);
			}
			else
			{
				focus = 0;
				mainWindow->ChangeFocus(&optionBrowser);
			}
			HaltResumeGui();
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			if (Options.temp_network != network)
			{
				if(network == 1)
				{
					ResumeNetworkThread();
				}
				else
				{
					HaltNetworkThread();
				}
			}
			Options.temp_network = network;
			Options.temp_wifigecko = wifigecko;
			Options.temp_newrevtext = newrevtext;
			menu = MENU_SETTINGS_FILE;
		}

		if(backBtn.GetState() == STATE_CLICKED)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}

		if(runaway == true)
		{
			Options.temp_last_setting = 1;
			menu = MENU_SETTINGS_FILE;
		}
	}
	HaltGui();
	mainWindow->Remove(&optionBrowser);
	mainWindow->Remove(&w);
	return menu;
}
コード例 #7
0
string FontList()
{
	string downloadfont = "error";
	bool stop = false;

	char buffer[100];
	sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/");

	struct block file = downloadfile(buffer);
	if (file.data != NULL)
	{
		string source_fonts = (char*)file.data;
		vector<string> fonts;

		while(1)
		{
			if((signed)source_fonts.find("../Fonts/") == -1)
				break;

			source_fonts.erase(0, source_fonts.find("../Fonts/"));
			source_fonts.erase(0, source_fonts.find("s/") +2);

			fonts.push_back(source_fonts.substr(0, source_fonts.find("\"")));

			source_fonts.erase(0, source_fonts.find("<"));
		}

		free(file.data);

		GuiText titleTxt(tr("Download"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
		titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		titleTxt.SetPosition(0, 40);

		GuiWindow promptWindow(520,360);
		promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
		promptWindow.SetPosition(0, -10);
		GuiTrigger trigA;
		trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

		GuiImageData dialogBox(Theme.dialog_background);
		GuiImage dialogBoxImg(&dialogBox);

		int place = 23;
		int y = 150;
		int i = 0;
		int number = 5;
		int selection = 0;
		int textScrollPos = 0;
		int selctionPos = y;

		GuiText selectionTxt(">>                                                                    <<", 20, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
		selectionTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		selectionTxt.SetPosition(0, y);

		GuiText upTxt("c", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
		upTxt.SetFont(symbol_ttf, symbol_ttf_size);
		upTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		upTxt.SetPosition(0, y -20);

		GuiText downTxt("d", 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
		downTxt.SetFont(symbol_ttf, symbol_ttf_size);
		downTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
		downTxt.SetPosition(0, y + (place * (number-1)) + 15);

		GuiText * Entrie[number];

		for(i=0; i < number && i < (signed)fonts.size(); i++)
		{
			Entrie[i] = new GuiText(fonts[i].c_str(), 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
			Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
			Entrie[i]->SetPosition(0, y);
			Entrie[i]->SetMaxWidth(300, SCROLL_HORIZONTAL);
			y += place;
		}

		promptWindow.Append(&dialogBoxImg);
		promptWindow.Append(&titleTxt);
		promptWindow.Append(&selectionTxt);

		for(int x=0; x < i; x++)
			promptWindow.Append(Entrie[x]);

		if((signed)fonts.size() >= number)
		{
			promptWindow.Append(&upTxt);
			promptWindow.Append(&downTxt);
		}

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

		while(!stop)
		{
			usleep(100);

			if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP) || PAD_ButtonsDown(0) & PAD_BUTTON_UP
			   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_UP)
			{
				selection--;
				if(selection < 0)
				{
					selection = 0;
					textScrollPos--;
					if(textScrollPos < 0)
						textScrollPos = 0;

					for(int x=0; x < number && x < (signed)fonts.size(); x++)
						Entrie[x]->SetText(fonts[x + textScrollPos].c_str());
				}
				selectionTxt.SetPosition(0, selection * place + selctionPos);

				HaltResumeGui();
			}

			if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN) || PAD_ButtonsDown(0) & PAD_BUTTON_DOWN
			   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_DOWN)
			{
				selection++;
				if(selection == (signed)fonts.size())
					selection = fonts.size() -1;
				if(selection > number -1)
				{
					selection = number -1;
					textScrollPos++;
					if(textScrollPos > (signed)fonts.size() - number)
						textScrollPos = fonts.size() - number;

					for(int x=0; x < number && x < (signed)fonts.size(); x++)
						Entrie[x]->SetText(fonts[x + textScrollPos].c_str());
				}
				selectionTxt.SetPosition(0, selection * place + selctionPos);

				HaltResumeGui();
			}

			if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A) || PAD_ButtonsDown(0) & PAD_BUTTON_A
			   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_A)
			{
				downloadfont = fonts[selection + textScrollPos];
				stop = true;
			}

			if(WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B) || PAD_ButtonsDown(0) & PAD_BUTTON_B
			   || WUPC_ButtonsDown(0) & WPAD_CLASSIC_BUTTON_B)
			{
				downloadfont = "NULL";
				stop = true;
			}
		}

		promptWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
		while(promptWindow.GetEffect() > 0) usleep(100);
		HaltGui();
		mainWindow->Remove(&promptWindow);
		mainWindow->SetState(STATE_DEFAULT);
		ResumeGui();
	}

	return downloadfont;
}