MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); console = new Console; setCentralWidget(console); serial = new QSerialPort(this); serialTimeOut = new QTimer(this); initActionsConnections(); saveFileName = ""; connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(handleError(QSerialPort::SerialPortError))); connect(serial, SIGNAL(readyRead()), this, SLOT(readData())); connect(serialTimeOut,SIGNAL(timeout()), this,SLOT(endUpload())); DataUpload = false; #ifndef QT_DEBUG QTimer* init_timer = new QTimer(this); init_timer->singleShot(100, this, SLOT(showSplash())); #else #ifdef TEST_REG QTimer* init_timer = new QTimer(this); init_timer->singleShot(100, this, SLOT(showSplash())); #else QTimer* init_timer = new QTimer(this); init_timer->singleShot(20, this, SLOT(loadExampleFile())); #endif #endif connectTimer = new QTimer(this); }
void Magazin::appLoop() { switch(_state) { case exiting: _mainWindow.close(); break; case showingSplash: showSplash(); break; case showingMenu: showMenu(); break; case showingLogInfo: showLogInfo(); break; case logging: showLogScreen(); break; case registering: showRegisterScreen(); break; case displayingCars: displayCars(); break; } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); console = new Console; console->setEnabled(false); setCentralWidget(console); serial = new QSerialPort(this); settings = new SettingsDialog; serialTimeOut = new QTimer(this); ui->actionQuit->setEnabled(true); initActionsConnections(); connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(handleError(QSerialPort::SerialPortError))); connect(serial, SIGNAL(readyRead()), this, SLOT(readData())); connect(console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray))); connect(serialTimeOut,SIGNAL(timeout()), this,SLOT(endUpload())); QTimer* init_timer = new QTimer(this); init_timer->singleShot(100, this, SLOT(showSplash())); }
void BadaGraphicsManager::internUpdateScreen() { if (!_initState) { OpenGLGraphicsManager::internUpdateScreen(); eglSwapBuffers(_eglDisplay, _eglSurface); } else { showSplash(); } }
void stateMachine() { // Main program loop switch (state) { case SPLASH: showSplash(); break; case MAIN_MENU: mainMenu(); break; case SETTINGS: settings(); break; case FILL: fill(); break; case FILL_ENTER: fillEnter(); break; case RESET_CONFIRM: resetConfirm(); break; case FILL_CONFIRM: fillConfirm(); break; case FILL_PROGRESS: fillProgress(); break; case FILL_DONE: fillDone(); break; case FLOW_ERROR: flowError(); break; case BACKLIGHT_ENTER: backlightEnter(); break; case BACKLIGHT_DONE: backlightDone(); break; default: changeState(MAIN_MENU); // If for some reason state variable is unset (which should never ever happen) go back to MAIN_MENU! break; } }
int main(int argc, char *argv[]) { if(argc >= 2) { if(strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"--help") == 0) { printf("\nConway\n"); printf("Copyright 2015 Harley Wiltzer\n\n"); printf("conway:\t\tOpen conway with a random color\n"); printf("conway 1:\tOpen conway blue theme\n"); printf("conway 2:\tOpen conway red theme\n"); printf("conway 3:\tOpen conway green theme\n"); printf("conway 4:\tOpen conway yellow theme\n"); printf("conway 5:\tOpen conway light blue theme\n"); printf("conway 6:\tOpen conway orange theme\n"); printf("conway 7:\tOpen conway white theme\n"); printf("\n"); printf("While running conway...\n"); printf("=======================\n"); printf("q:\t\tClose conway\n"); printf("space:\t\tActivate/Kill cell\n"); printf("enter:\t\tStart ticking\n"); printf("h:\t\tMove cursor left\n"); printf("j:\t\tMove cursor down\n"); printf("k:\t\tMove cursor up\n"); printf("l:\t\tMove cursor right\n"); printf("d:\t\tClear all cells\n"); printf("=:\t\tIncrease the amount of ticks by 10\n"); printf("-:\t\tDecrease the amount of ticks by 10\n"); printf("+:\t\tIncrease the amount of ticks by 1\n"); printf("_:\t\tDecrease the amount of ticks by 1\n"); return 0; } } int i, c; initCurses(); showSplash(); totalTicks = 0; refresh(); getch(); win = createWindow(WIN_WIDTH,rows,0,cols - WIN_WIDTH - 1); cols = cols - WIN_WIDTH - 1; xs = rows; ys = cols / 2; area = rows * cols; game = createWindow(cols - 1,rows,0,0); ticks = DEFAULT_TICKS; int cells[area / 2]; for(i = 0; i < area/2; i++) { cells[i] = 0; } x = y = row = col = 0; if(has_colors() == 0) wprintw(game,"NO COLORS\n"); if(argc < 2) { srand(time(NULL)); color = rand()%7 + 1; } else { if(atoi(argv[1]) > 7 || atoi(argv[1]) < 1) { srand(time(NULL)); color = rand()%7 + 1; } else { color = atoi(argv[1]); } } x = ys/2; y = xs/2; wmove(game,y, x * 2); x = 2; y = 2; wrefresh(game); updateWin(cells,area/2); wmove(game,y,x * 2); x = ys/2; y = xs/2; wmove(game,y,x * 2); while((ch = getch()) != 'q') { wclear(game); wclear(win); int r, c; render(cells,area/2); wmove(game,y, x * 2); switch(ch) { case 'h': if (x % ys == 0) break; x -= 1; wmove(game,y, x * 2); wrefresh(game); break; case 'j': if ((y + 1) % xs == 0) break; y += 1; wmove(game,y, x * 2); wrefresh(game); break; case 'k': if (y % xs == 0) break; y -= 1; wmove(game,y, x * 2); wrefresh(game); break; case 'l': if((x+1)%ys == 0) break; x += 1; wmove(game,y, x * 2); wrefresh(game); break; case ' ': cells[y * ys + x] = !cells[y * ys + x]; if(cells[y * ys + x]) drawCell(x,y); else eraseCell(x,y); updateWin(cells,area/2); break; case '\n': update(cells, area/2); break; case 'd': memset(cells,0,area/2); int q; for(q = 0; q < area/2; q++) { cells[q] = 0; } totalTicks = 0; render(cells, area/2); updateWin(cells,area/2); break; case '=': ticks += 10; updateWin(cells,area/2); break; case '-': if(ticks >= 20) ticks -= 10; updateWin(cells,area/2); break; case '+': ticks++; updateWin(cells,area/2); break; case '_': if(ticks > 2) ticks--; updateWin(cells, area/2); break; default: break; } updateWin(cells,area/2); wrefresh(game); } destroyWindow(game); destroyWindow(win); endwin(); return 0; }
void Engine::EngineLoop( ) { SDL_Event currentEvent; startTick = SDL_GetTicks( ); while( SDL_PollEvent( ¤tEvent ) ) { switch( currentEvent.type ) { case SDL_QUIT: engineState = Engine::exiting; break; case SDLK_ESCAPE: engineState = Engine::showingMenu; break; } if( currentEvent.type == SDL_KEYDOWN && engineState == Engine::playing ) { switch( currentEvent.key.keysym.sym ) { case SDLK_KP1: if( player.getBonus() ) player.setDirection( 5 ); else player.setDirection( 6 ); player.Move( ); break; case SDLK_KP2: if( player.getBonus() ) player.setDirection( 4 ); else player.setDirection( 3 ); player.Move( ); break; case SDLK_KP3: if( player.getBonus() ) player.setDirection( 6 ); else player.setDirection( 5 ); player.Move( ); break; case SDLK_KP4: if( player.getBonus() ) player.setDirection( 1 ); else player.setDirection( 2 ); player.Move( ); break; case SDLK_KP6: if( player.getBonus() ) player.setDirection( 2 ); else player.setDirection( 1 ); player.Move( ); break; case SDLK_KP7: if( player.getBonus() ) player.setDirection( 7 ); else player.setDirection( 8 ); player.Move( ); break; case SDLK_KP8: if( player.getBonus() ) player.setDirection( 3 ); else player.setDirection( 4 ); player.Move( ); break; case SDLK_KP9: if( player.getBonus() ) player.setDirection( 8 ); else player.setDirection( 7 ); player.Move( ); break; } } } switch( engineState ) { case Engine::playing: Game( ); break; case Engine::showingDeath: showDeath( ); break; case Engine::showingSplash: showSplash( ); break; case Engine::showingMenu: showMenu( ); break; case Engine::restart: Restart( ); break; case Engine::starting: Starting( ); break; case Engine::showingHighscore: showHighScore( ); break; case Engine::enteringName: enterName( ); break; } SDL_Flip( screen ); if( SDL_GetTicks( ) - startTick < 1000 / 30 ) { SDL_Delay( ( 1000 / 30 ) - (SDL_GetTicks() - startTick) ); } }
int main(int argc, char *argv[]) { // Define basic variables. int input; productList *products; Queue *q; // Allocate memory for pointers. products = newProductList(); q = newQueue(); // Load product-price data store and assert that it succeeded. if(loadProductList(products, "priceList.csv")!=0) { wait(); exit(-1); } queueInit(q); // Initialize queue. setAppTitle("SUPER MARKET COUNTER"); showSplash("splash.txt"); getch(); // Loops the menu till user chooses to exit. do { // Declare menu options. char mainMenu[][16]={"Arrive", "Process", "Print", "Front", "Rear", "Length", "Exit"}; // Display menu and receive user input. input = showMenu("Main Menu", mainMenu, 7); // Choose a function based on user input. switch(input) { case 1: qArrive(q, products); break; case 2: qProcess(q); break; case 3: qPrint(q); break; case 4: qFront(q); break; case 5: qRear(q); break; case 6: qLength(q); break; case 7: qExit(q, products); break; default: printf("Invalid Menu Option. Try again!"); wait(); continue; }; }while(1); return 0; }