Пример #1
0
int Confirm(char *message, char *yesText, char *noText, int defaultItem) {
    TEXTMENU ConfirmMenu;
    TEXTMENUITEM YesItem, NoItem;

    memset(&ConfirmMenu, 0x00, sizeof(TEXTMENU));
    memset(&YesItem, 0x00, sizeof(TEXTMENUITEM));
    memset(&NoItem, 0x00, sizeof(TEXTMENUITEM));
    
    //Title the menu
    strncpy(ConfirmMenu.szCaption, message, MENUCAPTIONSIZE);
    
    //Set up the yes/no items
    strncpy(YesItem.szCaption, yesText, MENUCAPTIONSIZE);
    strncpy(NoItem.szCaption, noText, MENUCAPTIONSIZE);
    YesItem.functionPtr=Confirm_Yes;
    NoItem.functionPtr=Confirm_No;
    //Add them to the menu    
    TextMenuAddItem(&ConfirmMenu, &YesItem);    
    TextMenuAddItem(&ConfirmMenu, &NoItem);    
    
    //Draw the menu
    TextMenu(&ConfirmMenu, defaultItem?&YesItem:&NoItem);
    
    return Confirm_Result;
}
Пример #2
0
void DrawBootMenu(void *rootEntry) {
	//entry is the pointer to the root config entry
	TEXTMENU *menu;
	TEXTMENUITEM *menuPtr, *defaultMenuItem;
	CONFIGENTRY *configEntry, *currentConfigEntry;
	extern int timedOut;

	defaultMenuItem=NULL;
	configEntry = rootEntry;

	if (configEntry->nextConfigEntry==NULL) {
		//If there is only one option, just boot it.
		BootMenuEntry(configEntry);
		return;
	}

	if (timedOut) {
		//We should be non-interactive, then.
		//If there is a default entry, boot that.
		for (currentConfigEntry = configEntry; currentConfigEntry != NULL; 
			currentConfigEntry = currentConfigEntry->nextConfigEntry) {
			if (currentConfigEntry->isDefault) {
				BootMenuEntry(currentConfigEntry);
				return;
			}
		}
		//There wasn't a default entry, so just boot the first in the list
		BootMenuEntry(configEntry);
		return;
	}
	
	menu = malloc(sizeof(TEXTMENU));
	memset(menu,0x00,sizeof(TEXTMENU));
	strcpy(menu->szCaption, "Boot menu");
  
	for (currentConfigEntry = configEntry; currentConfigEntry != NULL; 
		currentConfigEntry = currentConfigEntry->nextConfigEntry) {
	
		menuPtr = malloc(sizeof(TEXTMENUITEM*));
		memset(menuPtr, 0x00, sizeof(menuPtr));
		if (currentConfigEntry->title == NULL) {
			strcpy(menuPtr->szCaption,"Untitled");
		}
		else strncpy(menuPtr->szCaption,currentConfigEntry->title,50);
		menuPtr->functionPtr = BootMenuEntry;
		menuPtr->functionDataPtr = (void *)currentConfigEntry;
		//If this config entry is default, mark the menu item as default.
		if (currentConfigEntry->isDefault) defaultMenuItem = menuPtr;
		TextMenuAddItem(menu,menuPtr);
	}
	TextMenu(menu, defaultMenuItem);
}
Пример #3
0
void AdvancedMenu(void *textmenu) {
	TextMenu((TEXTMENU*)textmenu, NULL);
}
Пример #4
0
void DrawChildTextMenu(void *menu) {
	TextMenu((TEXTMENU*)menu);
}