示例#1
0
void MenuOptions::handlerLanguage(AG_Event * event){
	AG_Button *button = static_cast<AG_Button *>(AG_PTR(1));
	AG_TlistItem *li = static_cast<AG_TlistItem *>(AG_PTR(2));
	Config::language_t * lang = static_cast<Config::language_t *>(li->p1);
	try{
		LANG->set_language_(lang->name);
		CONFIG->language_ = lang->name;
		handlerBack();
		create();
	}
	catch(const TiXmlException & ex){
		for(Uint16 i=0 ; i<CONFIG->languages_.size() ; ++i){
			if(CONFIG->language_==CONFIG->languages_[i].name){
				AG_ButtonText(button, "%s",
					CONFIG->languages_[i].show.c_str());
				break;
			}
		}
		AG_TextError("%s\n%s", LANG_MENU(LANG_OPTIONS, LANG_ERR_SET_LANG),
			ex.what());
	}
}
示例#2
0
文件: textdlg.c 项目: adsr/agar
int
main(int argc, char *argv[])
{
	char s[256];
	double v = 10.0;
	char *driverSpec = NULL, *optArg;
	int c;

	while ((c = AG_Getopt(argc, argv, "?hd:", &optArg, NULL)) != -1) {
		switch (c) {
		case 'd':
			driverSpec = optArg;
			break;
		case '?':
		case 'h':
		default:
			printf("Usage: textdlg [-d agar-driver-spec]\n");
			return (1);
		}
	}
	if (AG_InitCore("agar-textdlg-demo", 0) == -1 ||
	    AG_InitGraphics(driverSpec) == -1) {
		fprintf(stderr, "%s\n", AG_GetError());
		return (1);
	}
	AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI);
	AG_BindGlobalKey(AG_KEY_F8, AG_KEYMOD_ANY, AG_ViewCapture);
	
	/* Prompt for a series of options. */
	{
		AG_Button *btns[3];

		btns[0] = AG_ButtonNew(NULL, 0, NULL);
		btns[1] = AG_ButtonNew(NULL, 0, NULL);
		btns[2] = AG_ButtonNew(NULL, 0, NULL);
		AG_TextPromptOptions(btns, 3, "Multiple-choice selection: ");
		AG_ButtonText(btns[0], "Yes");
		AG_ButtonText(btns[1], "No");
		AG_ButtonText(btns[2], "Maybe");
	}
	
	/* Prompt for a string and invoke callback on return. */
	AG_TextPromptString("Prompt for a string: ", EnteredString, NULL);

	/* Various canned dialogs as described in AG_Text(3). */
	AG_TextWarning("my-warning-key", "This is a warning");
	AG_TextError("This is an error message");
	AG_TextTmsg(AG_MSG_INFO, 3000, "This is a timed message");
	AG_TextMsg(AG_MSG_INFO, "This is an informational message");
	AG_TextInfo("infomsg",
	    "This is an informational message. Multiline text is "
	    "always allowed. Text will be wrapped to multiple lines "
	    "if it cannot be displayed properly on a single line.");

	/* Edit an existing floating-point variable. */
	AG_TextEditFloat(&v, 0.0, 100.0, "cm", "Edit a float value: ");

	/* Edit an existing fixed-size string buffer. */
	AG_Strlcpy(s, "Test string", sizeof(s));
	AG_TextEditString(s, sizeof(s), "Edit a string: ");

	/* Use the standard Agar event loop. */
	AG_EventLoop();
	AG_Destroy();
	return (0);
}
示例#3
0
MenuOptions::MenuOptions():
			speed_(CONFIG->speed()),
			visible_presumption_(CONFIG->visible_presumption()),
			split_screen_(CONFIG->split_screen()),
			fullscreen_(CONFIG->fullscreen()),
			sound_(CONFIG->sound()){
	AG_Box * item;
	AG_UCombo *combo;
	AG_TlistItem * combo_item;
	AG_Checkbox * checkbox;
	// nadpis
	createHeading(LANG_MENU(LANG_OPTIONS, LANG_HEADING));

	// jazyk
	item = createItem(LANG_MENU(LANG_OPTIONS, LANG_LANGUAGE));
	combo = AG_UComboNew(item, AG_UCOMBO_HFILL);
	AG_SetEvent(combo, "ucombo-selected", handlerLanguage,
			"%p", combo->button);
	for(Uint16 i=0 ; i<CONFIG->languages_.size() ; ++i){
		combo_item = AG_TlistAddPtr(combo->list, 0,
			CONFIG->languages_[i].show.c_str(), &CONFIG->languages_[i]);
		if(CONFIG->language_==CONFIG->languages_[i].name)
			AG_ButtonText(combo->button, "%s", combo_item->text);
	}

	// klavesy
	item = createItem(LANG_MENU(LANG_OPTIONS, LANG_CONTROLS));
	AG_SetEvent(item, "window-mousebuttondown",
			MenuOptionsControls::create, 0);

	// rychlost hry
	item = createItemHoriz(LANG_MENU(LANG_OPTIONS, LANG_SPEED));
	AG_AddEvent(items_.back(), "window-keyup", handlerIntItem,
		"%p,%i,%i", &speed_,
		CONFIG_SPEED_MIN, CONFIG_SPEED_MAX);

	AG_NumericalNewIntR(item, 0, 0, 0, &speed_,
		CONFIG_SPEED_MIN, CONFIG_SPEED_MAX);

	// viditelna presumpce
	createCheckboxItem(LANG_MENU(LANG_OPTIONS, LANG_PRESUMPTIONS),
		&visible_presumption_);
	// rozedelni obrazovek
	createCheckboxItem(LANG_MENU(LANG_OPTIONS, LANG_SPLIT_SCREEN),
		&split_screen_);

	// fullscreen
	checkbox = createCheckboxItem(LANG_MENU(LANG_OPTIONS, LANG_FULLSCREEN),
		&fullscreen_);
	AG_AddEvent(items_.back(), "window-mousebuttondown", handlerToggleFullscreen, 0);
	AG_AddEvent(checkbox, "window-mousebuttondown", handlerToggleFullscreen, 0);

	// zvuk - neni implementovano
// 	createCheckboxItem(LANG_MENU(LANG_OPTIONS, LANG_SOUND),
// 		&sound_);

	// back
	item = createItem(LANG_MENU(LANG_OPTIONS, LANG_SAVE));
	AG_SetEvent(item, "window-mousebuttondown", handlerBack, 0);

	AG_SpacerNewHoriz(win);
}