void drawPuzzle(void) { bool isPlaying = (state == STATE_FREE || state == STATE_PICKED); if (toDrawAll) { arduboy.clear(); drawBoard(0); drawPieces(); toDrawAll = false; } else if (isPlaying && focusPieceIdx >= 0) { drawPiece(focusPieceIdx); } if (state == STATE_FREE) { drawCursor(); } if (state == STATE_CLEAR) { drawClearEffect(); } if (isHelpVisible && isPlaying) { HELP_T idx; if (state == STATE_FREE) { idx = HELP_FREE; } else { idx = (arduboy.buttonPressed(A_BUTTON)) ? HELP_HOLD : HELP_PICK; } drawHelp(idx, helpX, helpY); } }
void HUD::draw() { if (mToggleHelp) drawHelp(); //display help info al_draw_text(mpFont, al_map_rgb(255, 255, 255), X_CENTRE, TOP_LEFT_X - 20, ALLEGRO_ALIGN_CENTRE, mHelpText[6].c_str()); }
void ofApp::draw(){ ofDisableLighting(); ofBackgroundGradient( ofColor(40,40,40), ofColor(0,0,0), OF_GRADIENT_CIRCULAR); cam.begin(); scene.draw(); cam.end(); drawHelp(); kui.draw(); }
//se l'utente si trova in un menu lo disegna e rit. true //altrim. non fa niente e rit. false bool MenuMgr::draw() { if (!showingGAMEOVER && !showingMainMenu && !showingWin && !showingHelp) return false; if (showingMainMenu) drawMainMenu(); else if (showingGAMEOVER) drawGameOver(); else if (showingWin) drawWin(); else if (showingHelp) { drawHelp(); } return true; }
void Starfield::draw() { clear_screen(0); foreach (Star& star, stars) { if (star.z <= movementSpeed) { star = newStar(); } else { const int scrX = star.x / static_cast<signed>(star.z) + scr_width / 2; const int scrY = star.y / static_cast<signed>(star.z) + scr_height / 2; const Uint8 drawColor = color + ((star.z / 16) & 0x1F); drawStar(scrX, scrY, drawColor, VGAScreen); star.z -= movementSpeed; } } if (!helpText.empty()) { if (showHelp) drawHelp(); else JE_outText(4, 4, "F1: Help", 1, 0); } if (messageDisplayTime > 0) { JE_outText(JE_fontCenter(message, TINY_FONT), 4, message, fadeColors(messageDisplayTime, MESSAGE_TIME, 2, 8, 11), 4); --messageDisplayTime; } pattern->step(speed, speed2); }
int main(int argc, char* argv[]) { //The current working directory: Directory* dir = NULL; //Checks if too many arguments have been given: if(argc > 2) { std::cerr << "Please pass a single, valid directory\n"; return -1; } //Otherwise, sees if a directory has been given, //and if so, attempt to open it: else if(argc == 2) { //Attempt to open try { dir = new Directory(argv[1]); } //Give an error message and quit if it fails: catch(int e) { std::cerr << "Cannot open '" << argv[1] << "': "; switch(e) { case EACCES: std::cerr << "Permission denied."; break; case ENOENT: std::cerr << "No such directory."; break; case ENOTDIR: std::cerr << "Not a directory."; break; } std::cerr << std::endl; return -1; } } //Otherwise, there are no arguments given, so use //the user's current working directory: else { //Get the current working directory: char* cwd = getcwd(NULL, 0); //Attempt to open it: try { dir = new Directory(cwd); } //Give an error message and quit if it fails: catch(int e) { std::cerr << "Cannot open '" << cwd << "': "; switch(e) { case EACCES: std::cerr << "Permission denied."; break; case ENOENT: std::cerr << "No such directory."; break; case ENOTDIR: std::cerr << "Not a directory."; break; } std::cerr << std::endl; return -1; } } //Attempt to read the directory's contents: try { dir->read(); } //Give an error message and quit if it fails: catch(int e) { std::cerr << "Cannot open '" << dir->getPath() << "': "; switch(errno) { case EACCES: std::cerr << "Permission denied."; break; case ENOENT: std::cerr << "No such directory."; break; case ENOTDIR: std::cerr << "Not a directory."; break; } std::cerr << std::endl; return -1; } if(dir->getName() == "../") dir->cleanPath(); //Initialise ncurses: initscr(); //The colour pairs: init_pair(2, COLOR_WHITE, COLOR_RED); //Enable keypad mode (allows use of the up and down arrows): keypad(stdscr, true); //Start using colour: start_color(); //Update the screen: refresh(); //Hides the cursor, set 'noecho()': curs_set(0); noecho(); int input = 0; std::string path = ""; unsigned int selection = 0; DiskItem* clipboard = NULL; //While the user has not quit: while((char(input) != 'q') && (char(input) != 'Q')) { //Redraw the windows and help: updateWindows(); drawHelp(); //If necessary, resizes the directory path: path = ""; if(dir->getPath().length() >= screenX) path = fitToSize(dir->getPath(), (screenX - 2)); else path = dir->getPath(); //The X position needed to print the path in the centre: int pos = ((screenX - path.length()) / 2); //Write the user's current directory: mvprintw(0, pos, "%s", path.c_str()); //Get the files and sort the contents: std::vector <DiskItem*> items = dir->getFiles(); //Checks if the contents of the directory will fit in the window: if((fileview.height - 2) > (items.size() - dir->getDotfiles())) { //Print the contents, except the dotfiles, to the window: for(unsigned int i = dir->getDotfiles(); i < items.size(); i++) { //If we're printing the current selection, highlight it: if(selection == (i - dir->getDotfiles())) { //Print the name: mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str()); //Move to the beginning of the line, and highlight the line up to but excluding the window border: mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL); } else //Print the name: mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str()); } } //Otherwise, we can only print part of the directory's contents: else { //If the selection is less than the height, display the first few items: if(selection < (fileview.height - 2)) { for(unsigned int i = dir->getDotfiles(); i < ((fileview.height - 2) + dir->getDotfiles()); i++) { //If we're printing the current selection, highlight it: if(selection == (i - dir->getDotfiles())) { //Print the name: mvwprintw(fileview.window,((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str()); //Move to the beginning of the line, and highlight the line up to but excluding the window border: mvwchgat(fileview.window, ((i - dir->getDotfiles()) + 1), 1, (fileview.width - 2), A_NORMAL, 1, NULL); } else //Print the name: mvwprintw(fileview.window, ((i - dir->getDotfiles()) + 1), 1, "%s", items[i]->getName().c_str()); } } //Otherwise, display the selection as the last item: else { for(unsigned int i = (dir->getDotfiles() + ((selection + 1) - (fileview.height - 2))); i < ((selection + 1) + dir->getDotfiles()); i++) { unsigned int y = i - ((selection - (fileview.height - 2)) + dir->getDotfiles()); //If we're printing the current selection, highlight it: if(selection == (i - dir->getDotfiles())) { //Print the name: mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str()); //Move to the beginning of the line, and highlight the line up to but excluding the window border: mvwchgat(fileview.window, y, 1, (fileview.width - 2), A_NORMAL, 1, NULL); } else //Print the name: mvwprintw(fileview.window, y, 1, "%s", items[i]->getName().c_str()); } } } //Print the selected file's metadata to the 'fileinfo' window: printMetaData(items[selection + dir->getDotfiles()]); //Print the contents of the clipboard to the 'extrainfo' window: printClipboard(clipboard); //Refresh the screen and windows: refresh(); wrefresh(fileview.window); wrefresh(fileinfo.window); wrefresh(extrainfo.window); //Gets the input: input = getch(); //Moves the selection up or down if those keys were pressed: if((input == KEY_UP) || (char(input) == 'k') || (char(input) == 'K')) if(selection > 0) selection--; if((input == KEY_DOWN) || (char(input) == 'j') || (char(input) == 'J')) if(selection < ((items.size() - dir->getDotfiles()) - 1)) selection++; //If the user has pressed Enter: if(char(input) == '\n') { //Attempts to cast the current selection to a Directory*: Directory* selected = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]); //If the user has selected a directory: if(selected != NULL) { //Keep the old directory so we can delete it: Directory* oldDir = dir; //Makes a copy of the directory we want to move to: try { dir = new Directory(selected); dir->read(); delete oldDir; selection = 0; clear(); } //If an error occurs, inform the user with a message box: catch(int e) { std::string error = "Cannot open '" + dir->getPath() + "' "; switch(errno) { case EACCES: error += "Permission denied."; break; case ENOENT: error += "No such directory."; break; case ENOTDIR: error += "Not a directory."; break; } messageBox(error); } } } //Otherwise, if the user has pressed 'd' for delete: else if((char(input) == 'd') || (char(input) == 'D')) { DiskItem* selected = items[selection + dir->getDotfiles()]; //Attempt to delete the selected item: if(selected->deletef()) { delete selected; dir->getFiles().erase(dir->getFiles().begin() + (selection + dir->getDotfiles())); //If we deleted the last item, then 'selection + dir->getDotfiles()' will //go out of bounds on the 'item' array, so decrement selection: if((selection + dir->getDotfiles()) == dir->getFiles().size()) selection--; } //If an error occurs, inform the user with a message box: else { std::string error = "Could not delete '" + selected->getPath() + "'"; messageBox(error); } } //Otherwise, if the user has pressed 'c' for copy: else if((char(input) == 'C') || (char(input) == 'c')) { if(items[selection + dir->getDotfiles()]->getName() != "../") { //Checks if we are trying to copy a directory or a file: clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]); if(clipboard == NULL) { //We are copying a file: clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()])); } else { //We are copying a directory: clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()])); } } } //Otherwise, if the user has pressed 'x' for cut: else if((char(input) == 'X') || (char(input) == 'x')) { if(items[selection + dir->getDotfiles()]->getName() != "../") { //Checks if we are trying to cut a directory or a file: clipboard = dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]); if(clipboard == NULL) { //We are cutting a file: clipboard = new File(dynamic_cast <File*>(items[selection + dir->getDotfiles()])); } else { //We are cutting a directory: clipboard = new Directory(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()])); } clipboard->cut(); } } //Otherwise, if the user has pressed 'p' for paste: else if((char(input) == 'P') || (char(input) == 'p')) { if(clipboard != NULL) { //Attempt to paste the item in the clipboard: if(! clipboard->paste(dir->getPath())) { //If an error occurs, inform the user with a message box: std::string error = "Could not paste '" + clipboard->getName() + "'"; messageBox(error); } else { //If it works fine, add the new item to the directory's list of items: DiskItem* item = clipboard; dir->getFiles().push_back(item); std::sort(dir->getFiles().begin(), dir->getFiles().end(), byName); //Empty the clipboard: clipboard = NULL; } } } //Otherwise, if the user presses 'r' for rename: else if((char(input) == 'R') || (char(input) == 'r')) { //Get the new name, and attempt to rename the selected item: std::string newName = inputBox(); if(newName != "") { //Check if we are renaming a directory: if(dynamic_cast <Directory*>(items[selection + dir->getDotfiles()]) != NULL) newName += '/'; if(! items[selection + dir->getDotfiles()]->rename(newName.c_str())) { //If an error occurs, inform the user with a message box: std::string error = "Cannot rename '" + items[selection + dir->getDotfiles()]->getName() + "'"; messageBox(error); } } } } //Delete the directory object: delete dir; //Close ncurses: endwin(); return 0; }
// does what its name suggests void PortVideoSDL::mainLoop() { unsigned char* cameraReadBuffer = NULL; while(running_) { // do nothing if paused if (pause_){ process_events(); SDL_Delay(50); continue; } long start_time = currentTime(); cameraReadBuffer = ringBuffer->getNextBufferToRead(); // loop until we get access to a frame while (cameraReadBuffer==NULL) { cameraReadBuffer = ringBuffer->getNextBufferToRead(); //if (cameraReadBuffer!=NULL) break; SDL_Delay(1); process_events(); if(!running_) { endLoop(); return; } } long camera_time = currentTime(); //memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); //ringBuffer->readFinished(); // try again if we can get a more recent frame /*do { memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); ringBuffer->readFinished(); cameraReadBuffer = ringBuffer->getNextBufferToRead(); } while( cameraReadBuffer != NULL );*/ // do the actual image processing job for (frame = processorList.begin(); frame!=processorList.end(); frame++) (*frame)->process(cameraReadBuffer,destBuffer_,displayImage_); long processing_time = currentTime(); if(camera_ != 0){ // update display switch( displayMode_ ) { case NO_DISPLAY: break; case SOURCE_DISPLAY: { memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); SDL_BlitSurface(sourceImage_, NULL, window_, NULL); if (help_) drawHelp(); camera_->drawGUI(displayImage_); SDL_BlitSurface(displayImage_, NULL, window_, NULL); SDL_FillRect(displayImage_, NULL, 0 ); SDL_Flip(window_); break; } case DEST_DISPLAY: { SDL_BlitSurface(destImage_, NULL, window_, NULL); if (help_) drawHelp(); camera_->drawGUI(displayImage_); SDL_BlitSurface(displayImage_, NULL, window_, NULL); SDL_FillRect(displayImage_, NULL, 0 ); SDL_Flip(window_); break; } } } #ifndef NDEBUG if (recording_) { if (displayMode_!=SOURCE_DISPLAY) memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); saveBuffer(sourceBuffer_); } #endif ringBuffer->readFinished(); if (!recording_) frameStatistics(camera_time-start_time,processing_time-camera_time, currentTime()-start_time); process_events(); } endLoop(); }
int main() { gw.begin(); //uint8_t nodeID = 22; //gw.begin(nodeID,3,RF24_2MBPS); //uint16_t address = 0; //gw.begin(address,3,RF24_2MBPS); /** Setup NCurses**/ /*******************************/ win = initscr(); cbreak(); noecho(); getmaxyx(win,maxX,maxY); start_color(); curs_set(0); init_pair(1, COLOR_GREEN, COLOR_BLACK); init_pair(2, COLOR_RED, COLOR_BLACK); /** Setup Pads**/ /*******************************/ devPad = newpad(11,40); meshPad = newpad(11,50); rf24Pad = newpad(11,40); connPad = newpad(21,150); cfgPad = newpad(10,40); scrollok(meshPad,true); scrollok(connPad,true); scrollok(rf24Pad,true); timeout(0); drawMain(); /******************************************************************/ /***********************LOOP***************************************/ while(1){ //delayMicroseconds(5000); //delay(1); /** * The gateway handles all IP traffic (marked as EXTERNAL_DATA_TYPE) and passes it to the associated network interface * RF24Network user payloads are loaded into the user cache */ gw.update(); /** Read RF24Network Payloads (Do nothing with them currently) **/ /*******************************/ if( network.available() ){ RF24NetworkHeader header; size_t size = network.peek(header); uint8_t buf[size]; if(header.type == 1){ struct timeStruct{ uint8_t hr; uint8_t min; }myTime; time_t mTime; time(&mTime); struct tm* tm = localtime(&mTime); myTime.hr = tm->tm_hour; myTime.min = tm->tm_min; RF24NetworkHeader hdr(header.from_node,1); network.write(hdr,&myTime,sizeof(myTime)); } network.read(header,&buf,size); } /** Mesh address/id printout **/ /*******************************/ if(millis() - meshInfoTimer > updateRate){ getmaxyx(win,maxX,maxY); // Draw the pads on screen drawDevPad(); prefresh(devPad,0,0, 4,1, 15,25); drawMeshPad(); wscrl(meshPad,meshScroll); prefresh(meshPad,0,0, 4,26, 15,47); drawRF24Pad(); prefresh(rf24Pad,0,0, 4,51, 15, 73); if(showConnPad){ drawConnPad(); wscrl(connPad,connScroll); prefresh(connPad,0,0, 15,1, maxX-1,maxY-2); } } //MeshInfo Timer /** Handle keyboard input **/ /*******************************/ int myChar; if ( (myChar = getch()) == '\033') { getch(); switch(getch()){ case 'A': if(padSelection == 0){meshScroll++;}else if(padSelection == 1){connScroll++;} break; case 'B': if(padSelection == 0){meshScroll--;}else if(padSelection == 1){connScroll--;} break; case 'C': padSelection++; padSelection= std::min(padSelection,1); break; //right case 'D': padSelection--; padSelection= std::max(padSelection,0); break; //left } meshScroll = std::max(meshScroll,0); connScroll = std::max(connScroll,0); meshInfoTimer = 0; }else if(myChar > -1){ switch(myChar){ // a: En/Disable display of active connections case 'a' : showConnPad = !showConnPad; if(!showConnPad){ wclear(connPad); prefresh(connPad,0,0, 15,1, maxX-1,maxY-2); drawMain();} break; // w: Increase frame-rate of curses display case 'w' : if(updateRate > 100){updateRate-=100;} mvwprintw(win,2,27,"Refresh Rate: %.1f fps",1000.0/updateRate); refresh(); break; // s: Decrease frame-rate of curses display case 's' : updateRate+=100; mvwprintw(win,2,27,"Refresh Rate: %.1f fps \t",1000.0/updateRate); refresh(); break; // c: Display IP configuration menu case 'c' : drawCfg(1); break; // h: Display help menu case 'h' : drawHelp(); break; case 'x' : clear(); endwin(); return 0; break; } } delay(2); }//while 1 //delwin(meshPad); //delwin(connPad); clear(); endwin(); return 0; }//main
int main(void) { gfxInitDefault(); consoleInitDefault(); Result ret; state = STATE_START; ret = FS_Init(); if (R_FAILED(ret)) { consoleLog("\nCouldn't initialize the FS module!\n"); consoleLog("Have you selected a title?\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } ret = saveInit(); if (R_FAILED(ret)) { consoleLog("\nCouldn't initialize the Save module!\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } ret = saveGetTitleId(&titleid); if (R_FAILED(ret)) { consoleLog("\nCouldn't get the title id of the game!\n"); consoleLog("Error code: 0x%lx\n", ret); // state = STATE_ERROR; // TODO: Remove out of Citra } fsDirInit(); fsBackInit(titleid); switchState(&state); consoleSelectNew(&consoleLog); drawHelp(); u64 heldUp = 0; u64 heldDown = 0; u32 kDown, kHeld; while (aptMainLoop()) { gspWaitForVBlank(); hidScanInput(); kDown = hidKeysDown(); kHeld = hidKeysHeld(); switch (state) { case STATE_BROWSE: { if (kDown & (KEY_LEFT | KEY_RIGHT)) { fsDirSwitch(NULL); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_ZL) { fsDirSwitch(&saveDir); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_ZR) { fsDirSwitch(&sdmcDir); fsDirPrintSave(); fsDirPrintSdmc(); } if (kDown & KEY_UP) { fsDirMove(-1); fsDirPrintCurrent(); heldUp = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_UP) { if (heldUp + HELD_TICK < svcGetSystemTick()) { fsDirMove(-1); fsDirPrintCurrent(); heldUp = svcGetSystemTick(); } } #endif if (kDown & KEY_DOWN) { fsDirMove(+1); fsDirPrintCurrent(); heldDown = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_DOWN) { if (heldDown + HELD_TICK < svcGetSystemTick()) { fsDirMove(+1); fsDirPrintCurrent(); heldDown = svcGetSystemTick(); } } #endif if (kDown & KEY_A) { ret = fsDirGotoSubDir(); consoleLog(" > fsDirGotoSubDir: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_B) { ret = fsDirGotoParentDir(); consoleLog(" > fsDirGotoParentDir: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_X) { ret = fsDirDeleteCurrentEntry(); consoleLog(" > fsDirDeleteCurrentEntry: %lx\n", ret); fsDirPrintCurrent(); } if (kDown & KEY_Y) { ret = fsDirCopyCurrentEntry(false); consoleLog(" > fsDirCopyCurrentEntry: %lx\n", ret); fsDirPrintDick(); } break; } case STATE_BACKUP: { if (kDown & KEY_A) { ret = fsBackImport(); consoleLog(" > fsBackImport: %lx\n", ret); fsBackPrintSave(); } if (kDown & KEY_B) { state = STATE_BACKUP_KEY; // TODO: setKeyboardString consoleSelectNew(&logConsole); } if (kDown & KEY_X) { ret = fsBackDelete(); consoleLog(" > fsBackDelete: %lx\n", ret); fsBackPrintBackup(); } if (kDown & KEY_Y) { ret = fsBackExport(); consoleLog(" > fsBackExport: %lx\n", ret); fsBackPrintBackup(); } if (kDown & KEY_UP) { fsBackMove(-1); fsBackPrintBackup(); heldUp = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_UP) { if (heldUp + HELD_TICK < svcGetSystemTick()) { fsBackMove(-1); fsBackPrintBackup(); heldUp = svcGetSystemTick(); } } #endif if (kDown & KEY_DOWN) { fsBackMove(+1); fsBackPrintBackup(); heldDown = svcGetSystemTick() + HELD_TICK * 2; } #ifndef NO_HELD_TICK else if (kHeld & KEY_DOWN) { if (heldDown + HELD_TICK < svcGetSystemTick()) { fsBackMove(+1); fsBackPrintBackup(); heldDown = svcGetSystemTick(); } } #endif break; } case STATE_BACKUP_KEY: { // TODO: updateKeyboard if (kDown & KEY_A) { state = STATE_BACKUP; // TODO: getKeyboardString drawBackup(); } if (kDown & KEY_B) { state = STATE_BACKUP; drawBackup(); } break; } case STATE_ERROR: { consoleLog("\nAn error has occured...\n"); consoleLog("Please check previous logs!\n"); consoleLog("\nPress start to exit.\n"); state = STATE_EOF; break; } default: break; } { if (kDown & KEY_L) { // TODO: Prev switchState(&state); } if (kDown & KEY_R) { // TODO: Next switchState(&state); } if (kDown & KEY_SELECT) { drawHelp(); } } if (kDown & KEY_START) break; gfxFlushBuffers(); gfxSwapBuffers(); } fsDirExit(); fsBackExit(); FS_Exit(); { hidScanInput(); if (!(hidKeysHeld() & KEY_L) && !(hidKeysHeld() & KEY_R)) { u8 out = 0; FS_MediaType mediaType = 3; FSUSER_GetMediaType(&mediaType); Result ret = saveRemoveSecureValue(titleid, mediaType, &out); if (R_FAILED(ret)) { consoleSelect(&logConsole); printf("\nSecure value not removed.\n"); printf("It might already be unitialized.\n"); printf("Error code: 0x%lx (%i)\n", ret, out); printf("\n\nPress any key to exit.\n"); waitKey(KEY_ANY); } } } gfxExit(); return 0; }
void drawBackup(void) { fsBackPrintSave(); fsBackPrintBackup(); drawHelp(); }
void drawBrowse(void) { fsDirPrintSave(); fsDirPrintSdmc(); drawHelp(); }
//gestisce i tasti premuti dall'utente void MenuMgr::manageKeyPressed(bool *keys, int size, float deltaT) { //sto disegnando game, no menu if (!showingMainMenu && !showingGAMEOVER && !showingWin && !showingHelp) return; timeSinceLastKeypress += deltaT; //sono nel Main menu if (showingMainMenu) { //posso premere un tasto ogni 100ms, evito di "saltare" elem. menu perchè selez. cambia troppo velocemente. if (timeSinceLastKeypress >= 0.100) { timeSinceLastKeypress = 0; //azzero contatore if (keys[VK_UP]) { sndMgr->play("KEY"); //selez. elem. sopra, se primo non va + su di così if (selectedMenuItem == 1 || selectedMenuItem == 2) selectedMenuItem--; } else if (keys[VK_DOWN]) { sndMgr->play("KEY"); if (selectedMenuItem == 0 || selectedMenuItem == 1) selectedMenuItem++; } else if (keys[VK_RETURN]) { sndMgr->play("MENUKEY"); if (selectedMenuItem == 0) drawGame(); else if (selectedMenuItem == 1) drawHelp(); else if (selectedMenuItem == 2) winMgr.quit(); } } //timeSinceLastKeyPRess > ... } else if (showingGAMEOVER) { if (timeSinceLastKeypress >= 0.400 && keys[VK_RETURN] ) { //qls tasto si prema si finisce nel main menu //showingGAMEOVER = false; resetShowing(); showingMainMenu = true; timeSinceLastKeypress = 0; sndMgr->play("KEY"); } } else if (showingWin) { if (timeSinceLastKeypress >= 0.400 && keys[VK_RETURN] ) { //qls tasto si prema si finisce nel main menu //showingWin = false; resetShowing(); showingMainMenu = true; timeSinceLastKeypress = 0; sndMgr->play("KEY"); } } else if (showingHelp) { //evita di prendere 2 invio in successione if (timeSinceLastKeypress >= 0.400 && keys[VK_RETURN] ) { timeSinceLastKeypress = 0; //showingHelp = false; resetShowing(); showingMainMenu = true; timeSinceLastKeypress = 0; sndMgr->play("KEY"); } } }
void DragFrameShape::draw_Help(const DrawBuf &buf) const { drawHelp(buf,btnHelp); }