int main(){ dispMenu(); do{ std::string input; std::cout << "> "; getline(std::cin, input); if(!input.compare("1")){ getMale(); } else if(!input.compare("2")){ getFemale(); } else if(!input.compare("3")){ break; } else{ std::cout << "Input invalid\n"; } }while(1); return 0; }
unsigned char startMenu(void) { selectedMenuItem = (menuItem*)&m_s1i1; dispMenu(); return (0); }
int dispThread(SceSize args, void *argp) { sceIoChdir(cwd); initBackground(); while (exit_state != EXCEPTION) { if (exit_state) { setFadeMode(&main_fade,FADE_IN,0); if (getFadeState(&main_fade) == FADE_DONE) break; } if (checkGameState(GSQUARE)) { g2dClear(BLACK); dispgSquare(); } if (checkGameState(BANNER)) { g2dClear(BLACK); dispBanner(); } if (checkGameState(MENU)) { drawMovingBackground(); dispMenu(); } if (checkGameState(INGAME)) { drawMovingBackground(); camera(); drawLevel(); drawUI(); } if (checkGameState(LEVEL_TITLE)) { g2dClear(WHITE); intraFontSetStyle(seriffont,1.f,BLACK,0,0,INTRAFONT_ALIGN_CENTER); intraFontPrint(seriffont,G2D_SCR_W/2,G2D_SCR_H/2,lvl.title); } if (checkGameState(END)) { g2dClear(WHITE); g2dBeginRects(img.end); { g2dAdd(); } g2dEnd(); } drawFade(&main_fade); g2dFlip(G2D_VSYNC); } if (exit_state == EXCEPTION) dispException(); return 0; }
//----------------------------------------------------- unsigned char startMenu(void) { selectedMenuItem = &m_s0i1; dispMenu(); PT_INIT(&pt_display); return 0; }
void Menu_Select(void) { menuChange(SELECT); dispMenu(); //LCD_CMD (1); //LCD_GOTO (25); //LCD_STRING ("SELECT"); }
uint8_t startMenu() { selectedMenuItem = (menuItem*)&m_s1i1; dispMenu(0); setHandler(MSG_KEY_PRESS, &menuKey); setHandler(MSG_DISP_REFRESH, &dispMenu); return (0); }
void Menu_Next(void) { //LCD_CMD (1);//clrscr menuChange(NEXT); dispMenu(); //LCD_CMD (1); //LCD_GOTO (25); //LCD_STRING ("NEXT"); }
void Menu_Child(void) { //LCD_CMD (1);//clrscr menuChange(CHILD); dispMenu(); //LCD_CMD (1); //LCD_GOTO (25); //LCD_STRING ("CHILD"); }
void Menu_Parent(void) { //LCD_CMD (1);//clrscr menuChange(PARENT); dispMenu(); //LCD_CMD (1); //LCD_GOTO (25); //LCD_STRING ("PARENT"); }
void Menu_Previous(void) { //LCD_CMD (1);//clrscr menuChange(PREVIOUS); dispMenu(); //LCD_CMD (1);//clrscr //LCD_CMD (1); //LCD_GOTO (25); //LCD_STRING ("PREV"); }
int menu(void* scrbuf, const char* menuentries[]) { int selecteditem = 1; int lastitem; int blockarrow = 0; int inputpause = INPUTPAUSE; while (1) { sleep(10); //results in around 63 fps lastitem = dispMenu(scrbuf, 0, 0, menuentries, selecteditem); showBuffer(scrbuf); //closing menu: if (isKeyPressed(KEY_NSPIRE_ESC) || on_key_pressed()) return 0; //choosing an option: if (isKeyPressed(KEY_NSPIRE_ENTER)) return selecteditem; //navigating: if (isKeyPressed(KEY_NSPIRE_UP) && (blockarrow != 0x1 || inputpause <= 0)) { inputpause = INPUTPAUSE; blockarrow = 0x1; selecteditem--; if (selecteditem == 0) selecteditem = lastitem; } else if (isKeyPressed(KEY_NSPIRE_DOWN) && (blockarrow != 0x2 || inputpause <= 0)) { inputpause = INPUTPAUSE; blockarrow = 0x2; selecteditem++; if (selecteditem > lastitem) selecteditem = 1; } if (!isKeyPressed(KEY_NSPIRE_UP) && !isKeyPressed(KEY_NSPIRE_DOWN)) blockarrow = 0; else inputpause--; } }
uint8_t menuKey(msg_par par) { switch (par) { case 0: { return 1; } case KEY_LEFT: { menuChange(PREVIOUS); break; } case KEY_RIGHT: { menuChange(NEXT); break; } case KEY_DOWN: ; case KEY_OK: { // выбор пункта uint8_t sel; sel = SELECT; if (sel != 0) { sendMessage(MSG_MENU_SELECT, sel); killHandler(MSG_KEY_PRESS, &menuKey); killHandler(MSG_DISP_REFRESH, &dispMenu); return (1); } else { menuChange(CHILD); } break; } case KEY_UP: { // отмена выбора (возврат) menuChange(PARENT); } } dispMenu(0); return (1); }
unsigned char menuKey(unsigned char key) { menuItem* sel; if(!flag_menu_entry) { switch (key) { case 0: { return 1; } break; case '[': { menuChange(PREVIOUS); } break; case ']': { menuChange(NEXT); } break; case 'x': { _nop_(); } break; case 'F': { // выбор пункта sel = selectedMenuItem->Select;//SELECT; if (selectedMenuItem->Select != 0) { menuHandler(selectedMenuItem,key); return (1); } else { menuChange(CHILD); } } break; case 'C': { // отмена выбора (возврат) menuChange(PARENT); // LCD_WriteCommand(LCD_CMD_ON); } break; default: { } } if(key!=0) { LCD_WriteCommand(LCD_CMD_CLEAR); delay(10); dispMenu(); } } else { if(key== 'C') { // отмена выбора (возврат) flag_menu_entry=0; dynamic_disp=DYN_NOT_DISPLAY; LCD_WriteCommand(LCD_CMD_CLEAR); delay(3); LCD_WriteCommand(LCD_CMD_ON); delay(3); dispMenu(); } else { sel = SELECT; if (sel != 0) { menuHandler(selectedMenuItem,key); } } } return (1); }
/*-----------------------------------------------------------------------------*/ int main(int argc, char **argv) { char str[MAX_STR]; char userID[MAX_USER_NAME]; char buffer[MAX_BUFF]; SongType tempSong; /* Ncurses Menu */ char *mContent[] = { "Add Song", "Delete Song", "View Song(s)", "Quit" }; // dealWithIt(); printLogo("CLIENT", CLEAR); /* External Preprocessor commands */ if (extArguments (argc,argv) == 0) {return 0;} /* Welcome Screen and ask for username */ getUserID(userID, (unsigned) sizeof(userID)); /* Initiats connections */ initClientSocket(); /* Display confirmation for user */ printf(ANSI_COLOR_GREEN "Establising connection to server %s:%d \n\n" "For further assistance or " "help, please visit the help page by simply typing " ANSI_COLOR_YELLOW "'/h'" ANSI_COLOR_RESET" \n", SERVER_IP, SERVER_PORT); /* SEND USER THAT WE GOT FROM THE ABOVE fgets */ userID[strlen(userID)-1] = '\0'; // add a terminator at the end of the char[] strcpy(buffer, userID); send(mySocket, buffer, strlen(buffer), 0); /* Display Menu - Keep this if not using dup / dup2*/ dispMenu(); while (1) { /* For eye candy */ // printLogo("CLIENT", NO_CLEAR); /* Display Menu first */ // dispMenu(); // initNcursesMenu((sizeof(mContent) / sizeof(char*)),*mContent); printf("Please choose from the menu above: "); fgets(str, sizeof(str), stdin); str[strlen(str)-1] = '\0'; /* Deprecated * if (strcmp(str, "/h") == 0) { * printf(ANSI_COLOR_CYAN * "Welcome to the help page. This is a beta-help page\n" * "With later releases the help page should be using\n" * "the ncurses library.\n" * "Commands include :\n" * ANSI_COLOR_RED * "\t/h\t: For this lovely page\n" * "\t/q\t: Closes this program.\n" * ANSI_COLOR_RESET * ); * } else */ strcpy(buffer, str); /*Encryption - Usually one would use a key, but not in this case.*/ // encrypt(buffer); // send(mySocket, buffer, strlen(buffer), 0); encryptSend(mySocket, buffer, strlen(buffer),0); if (strcmp(str, "/q") == 0) { /* Soft-quiting */ break; } else if (strcmp(str, "a") == 0) { /* Add Song */ printf("You are about to send a song over: Please enter the following: \n" ANSI_COLOR_YELLOW "Name : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Artist: "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Album : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Duration (mins) : "); /* Just to make sure the user will use integars, if it is not the case * then he/she will be promted again to repeat their input. */ for(;;){ short *illegals = 0; fgets(str, sizeof(str), stdin); /* Check if str contains any non-ints*/ for (int i = 0; i < strlen(str) - 1; ++i) { if(!isdigit(str[i])) ++illegals; } /* If everything seems to be good, then exit*/ if ( illegals == 0) { tempSong.duration = atoi(str); // fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); /* Free illegals ... */ free(illegals); break; } printf(ANSI_COLOR_RED "EYYY!!! YO CHILL MAN!!" ANSI_COLOR_RESET " Only Integar values!\nLet's try that again...\n" ANSI_COLOR_YELLOW "Duration (mins) : " ); } // end sentinital loop ( I don't know how to spell, don't judge sheesh ) printf(ANSI_COLOR_GREEN "We are all good. Converting your song to send over\n" ANSI_COLOR_RESET ); } else if (strcmp(str, "b") == 0) { /* Delete Song */ printf(ANSI_COLOR_YELLOW); printf("Which song do you want to delete?\n" "Name ? : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Artist : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("That should be enough info\n"); printf(ANSI_COLOR_RESET); } else if (strcmp(str, "c") == 0) { /* View Song(s) */ fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); } else if (strcmp(str, "d") == 0) { break; } } close(mySocket); return 0; }