bool GameWidget::event(QEvent * event)
{
    bool ret = QWidget::event(event);
    if (event->type() == QEvent::UpdateRequest)
    {
        refreshScreen();
    }
    return ret;
}
void GameWidget::keyReleaseEvent(QKeyEvent *ke)
{
    ke->accept();
    switch (ke->key())
    {
    case Qt::Key_PageDown:
        newGame();
        flashScreen = true;
        update();
        break;

    case Qt::Key_PageUp:
        undo();
        flashScreen = true;
        update();
        break;

    case Qt::Key_Right:
        if (wygral > 0) break;
        currentX++;
        currentX %= board.size();
        update();
        break;

    case Qt::Key_Left:
        if (wygral > 0) break;
        currentX += board.size()-1;
        currentX %= board.size();
        update();
        break;

    case Qt::Key_Up:
        if (wygral > 0) break;
        currentY += board.size()-1;
        currentY %= board.size();
        update();
        break;

    case Qt::Key_Down:
        if (wygral > 0) break;
        currentY++;
        currentY %= board.size();
        update();
        break;

    case Qt::Key_Return:
        if (wygral > 0)
        {
            break;
        }
        move();
        flashScreen = true;
        update();
        break;
    }
    refreshScreen();
}
Example #3
0
void PileWidget::annuler() {
	Logger::v("PileWidget", "annuler() called");
	if(_saveIndex > 0) {
		Logger::d("PileWidget", "string is :"+_save[_saveIndex - 1]);
		_calculator.stateFromString(_save[_saveIndex - 1]);
		_saveIndex--;
	}
	refreshScreen();
}
Example #4
0
void PileWidget::retablir() {
	Logger::v("PileWidget", "retablir() called");
	if(_saveIndex < _save.size()) {
		Logger::d("PileWidget", "string is :"+_save[_saveIndex]);
		_calculator.stateFromString(_save[_saveIndex]);
		_saveIndex++;
	}
	refreshScreen();
}
Example #5
0
void Game::run() {

	/*TODO:The timer should be an object, Game::run should not call
	 * sdl functions directly
	 */

	LCVAR_Event gameEvent;
	gameEvent.type = NOTHING;
	int startTicks = 0;

	//TODO: Clean this up, do not hardcode
	turn = WHITE;

	bool gameEnd = false;
	short errorCode = 0;

	//TODO: Don't hardcode these settings
	engine->init(32, 600, 600, ".", errorCode);

	handleErrors(errorCode);

	drawEverything();
	refreshScreen();

	while (!gameEnd){

		getEvent(gameEvent);

		if(gameEvent.type == QUIT){

			gameEnd = true;

		}else if (gameEvent.type == MOVE){
			parseUserInput(gameEvent);
		}

		drawEverything();
		refreshScreen();

		gameEvent.type = NOTHING;

	}

}
Example #6
0
void GuiGame::displayBigCreature(const CommonCardData *cardData, const BoardCreatureData& data)
{
	if(_isBigCardOnBoard)
		return;
	createBigCard(cardData);
	_isBigCardOnBoard = true;
	updateCard(dynamic_cast<CreatureGui *>(_readableCard->getCard()), data);
	_context.gui->add(_readableCard);
	refreshScreen();
}
Example #7
0
void GuiGame::showAchievements()
{
	if(not _unlockedAchievements)
		return;
	auto& newAchievements{*_unlockedAchievements};
	//No new achievements
	if (newAchievements.size()==0)
		return;

	std::lock_guard<std::mutex> _lock{_accessScreen};
	static const std::string okButtonText{"Ok"};
	tgui::MessageBox::Ptr messageBox{std::make_shared<tgui::MessageBox>()};

	//set up message box
	messageBox->setText("New achievements unlocked !");
	messageBox->addButton(okButtonText);
	messageBox->getRenderer()->setTitleBarColor({127, 127, 127});
	_context.gui->add(messageBox);
	messageBox->setPosition((tgui::bindWidth(*_context.gui) - AchievementGui::getSize().x) / 2,
			(tgui::bindHeight(*_context.gui) - AchievementGui::getSize().y) / 2);
	messageBox->setSize(AchievementGui::getSize().x, AchievementGui::getSize().y);

	// Make the "Ok" button closing the message box
	// Note: do not try to pass messageBox as reference, since this lambda will
	// be stored elsewhere, the reference will become invalid when we'll go out
	// of the scope of this method! We must pass it by value.
	messageBox->connect("buttonPressed", [this, messageBox](const sf::String& buttonName)
	{
		if(buttonName == okButtonText)
		{
			messageBox->destroy();
			refreshScreen();
		}
	});

	// set up vertical layout
	tgui::VerticalLayout::Ptr layout{std::make_shared<tgui::VerticalLayout>()};
	layout->setPosition(0.f, 0.f);
	layout->setSize(AchievementGui::getSize().x, AchievementGui::getSize().y);
	messageBox->add(layout);

	_context.gui->draw();

	// create the achievement widgets
	std::vector<std::shared_ptr<AchievementWidget>> achievementWidgets{};
	unsigned int i{0};
	for(auto& achievement : newAchievements)
	{
		achievementWidgets.push_back(std::make_shared<AchievementWidget>(achievement));
		layout->add(achievementWidgets.back());
		++i;
	}
	layout->showWithEffect(tgui::ShowAnimationType::SlideFromBottom, sf::milliseconds(500));
}
Example #8
0
//Change the on-screen menu, refresh the screen
void menuDisplay::changeMenu(Menu newMenu[], int nRows){
  currentMenu=newMenu;
  nMenuRows=nRows;
  _currentTopRow=0;
  _arrowPos=0;

  //update variables within newMenu
  for (int ii=0; ii<nRows; ii++){
    newMenu[ii].setVars(_lcdRows, _lcdCols);
  }
  refreshScreen();
}
Example #9
0
//Initialise the display 
void menuDisplay::initDisplay()
{

  pinMode(_buttonPin,INPUT); 

  lcd->begin(_lcdCols, _lcdRows);
  lcd->createChar(0, _upArrow);
  lcd->createChar(1, _downArrow);  
  lcd->setCursor(0,0);
  refreshScreen();

}
Example #10
0
void printBoard(){
	
	for (int i = 0; i < W_BLOCKS; i++){
		for(int j = 0; j < H_BLOCKS; j++){
			if(boardFlag[i][j] == 1){
			 setBlock(i,j,board[i][j]);
			boardFlag[i][j] = 0;			
			}
		}
	}
refreshScreen(currentFrameBuffer);	
}
Example #11
0
void GuiGame::displayGame()
{
	// don't forget to lock the screen!
	std::lock_guard<std::mutex> _lock{_accessScreen};
	assert(std::this_thread::get_id() == _ownerId);

	displayHandCards();
	displaySelfBoard();
	displayOpponentBoard();
	displayInfo();

	updateGuiCardValues();

	refreshScreen();
}
Example #12
0
int startGame()
{
	Timer fpsTimer;
	if (initializeSDL() == -1) 
	{
		exit(-1);
	}
	else
	{
		//Create window
		if (GameEngine::getInstance().init() == Mario::STATUS_FATAL) 
		{
			exit(Mario::STATUS_FATAL);
		}
		else
		{
			while( GameEngine::getInstance().getStateId() != STATE_EXIT ) 
			{		
				fpsTimer.start();
				
				GameState* state = GameEngine::getInstance().getState();
				
				state->handle_events();

				state->logic();
				
				state->render();
				
				GameEngine::getInstance().changeState();

				refreshScreen();

				if (fpsTimer.getTicks() < Mario::UPDATE_RATE )
				{
					SDL_Delay ( Mario::UPDATE_RATE - fpsTimer.getTicks() );
				}
			}
		}
	}

	GameEngine::getInstance().shutdown();
	
	//Quit SDL subsystems
	IMG_Quit();
	SDL_Quit();

	return 0;
}
Example #13
0
void GameWidget::mousePressEvent(QMouseEvent *event)
{
    if (wygral > 0) return;
    int x = (event->pos().x() - fromLeft()) / cellSize();
    int y = (event->pos().y() - fromTop()) / cellSize();
    if (x >= 0 && x < board.size() && y >= 0 && y < board.size())
    {
        currentX = x;
        currentY = y;

        move();
        flashScreen = true;
        update();
        refreshScreen();
    }
}
Example #14
0
void PileWidget::eval() {
    QString input = ui->input->text();
    try {
        _calculator.eval(input);
        ui->input->clear();
	refreshScreen();
	// Gestion de la pile pour avancer/reculer (ctrl+Z, ctrl+y)
	while(_saveIndex != _save.size())
		_save.pop_back();
	_save.push_back(_calculator.stateToString());
	_saveIndex++;
    }
    catch (exception &ex) {
        emit error(QString(ex.what()));
    }
}
Example #15
0
void GuiGame::connectBigCardDisplay(CardWidget::Ptr& card, const CommonCardData *cardData, const BoardCreatureData *data)
{
	if(not data)
		card->connect("MouseEntered", &GuiGame::displayBigCard, this, cardData);
	else
		card->connect("MouseEntered", &GuiGame::displayBigCreature, this, cardData, *data);
	// When the mouse leaves the card area
	card->connect("MouseLeft", [this]()
	{
		if(not _readableCard)
			return;
		_context.gui->remove(_readableCard);
		_isBigCardOnBoard = false;
		refreshScreen();
	});
}
void CMMADisplay::SetClippingRegion()
{
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion");

    if (!iWindow ||
            (iWindow->GetDisplayWindowType() == MMMADisplayWindow::EDisplayWindowTypeIsBitmap) ||
            iClipRect == iWindow->DrawRect() && iContainerVisible && iVisible)
    {
        LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion before return");
        return;
    }

    TBool refreshScreen(EFalse);
    // Remove first the current clip rect if set
    LOG2(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: iClipRect = %d X %d",iClipRect.Width(),iClipRect.Height());
    if (!iClipRect.IsEmpty())
    {
        LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: Removing old rect");
        //iDirectContainer->MdcRemoveContentBounds(iClipRect);
        RemoveContentBoundFromJavaControl(iClipRect);
        iClipRect.SetRect(0, 0, 0, 0);
        refreshScreen = ETrue;
    }
    // If visible then set a new clip rect
    if (iVisible && iContainerVisible)
    {
        LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: inside if (iVisible && iContainerVisible)");
        iClipRect = iWindow->DrawRect();
        LOG2(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: inside if (iVisible && iContainerVisible)iClipRect = %d X %d",iClipRect.Width(),iClipRect.Height());
        if (!iClipRect.IsEmpty())
        {
            LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: Adding new rect");
            // Add new clipping rect
            //   iDirectContainer->MdcAddContentBounds(iClipRect);
            SetContentBoundToJavaControl(iClipRect);
            refreshScreen = ETrue;
        }
    }
    if (refreshScreen)
    {
        LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion: inside if(refreshScreen)");
        // refresh screen
        // iDirectContainer->MdcFlushContainer(iWindow->WindowRect());
        RefreshJavaControl();
    }
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetClippingRegion -");
}
void Statistics::incENQReceived()
{
	recENQ++;

	refreshScreen();
}
int main ( int argc, char **argv ) {
  
  SDL_Surface *video;
  SDL_Event event;
  
  Level level;
  level.camera.set( 0, 200, 0 );
  level.cameraSpeed.set( 0, 0, 0 );
  level.player.bodyRep.position.set( 6, 2, 1 );
  level.player.bodyRep.speed.set( 0, 0, 0 );

  initLevel( level );

  SDL_Init( SDL_INIT_EVERYTHING );

  if ( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) {
      std::cout << "Could not start sound system..." << std::endl;
      playSounds = false;
    } else {
      jetSound = Mix_LoadWAV( "res/jet.wav" );
      gotIt = Mix_LoadWAV( "res/gotIt.wav" );
      //      step = Mix_LoadWAV( "res/step.wav" );
      std::cout << "Sound ready!" << std::endl;
      playSounds = true;
  }
  
  video = SDL_SetVideoMode( 640, 480, 0, 0 );
  
  showTitleScreen( video );
  
  clock_t t0;
  clock_t t1;
  float delta;

  while ( running ) {
    
    t0 = clock();

    level.updateGame( gotIt, step, video );
    refreshScreen( video, level );
    
    
    if ( SDL_PollEvent( &event ) ) {
      
      if( event.type == SDL_QUIT ) {
	running = false;
      }
      
      handleEvents( event, level );
    }

    t1 = clock();
 
    delta = ((((float) t1 ) - ((float)t0)) / CLOCKS_PER_SEC );
    
    SDL_Delay( 50 - ( 1000 * delta ) );
  }
  
  SDL_FreeSurface( video );
  Mix_FreeChunk( jetSound );
  
  SDL_Quit();
  
  return 0;
}
Example #19
0
void OpenGLGraphicsManager::updateScreen() {
	if (!_gameScreen) {
		return;
	}

#ifdef USE_OSD
	{
		if (_osdMessageChangeRequest) {
			osdMessageUpdateSurface();
		}
	}

	if (_osdIconSurface) {
		_osdIconSurface->updateGLTexture();
	}
#endif

	// We only update the screen when there actually have been any changes.
	if (   !_forceRedraw
	    && !_gameScreen->isDirty()
	    && !(_overlayVisible && _overlay->isDirty())
	    && !(_cursorVisible && _cursor && _cursor->isDirty())
#ifdef USE_OSD
	    && !_osdMessageSurface && !_osdIconSurface
#endif
	    ) {
		return;
	}
	_forceRedraw = false;

	// Update changes to textures.
	_gameScreen->updateGLTexture();
	if (_cursor) {
		_cursor->updateGLTexture();
	}
	_overlay->updateGLTexture();

	// Clear the screen buffer.
	if (_scissorOverride && !_overlayVisible) {
		// In certain cases we need to assure that the whole screen area is
		// cleared. For example, when switching from overlay visible to
		// invisible, we need to assure that all contents are cleared to
		// properly remove all overlay contents.
		_backBuffer.enableScissorTest(false);
		GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
		_backBuffer.enableScissorTest(true);

		--_scissorOverride;
	} else {
		GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
	}

	const GLfloat shakeOffset = _gameScreenShakeOffset * (GLfloat)_displayHeight / _gameScreen->getHeight();

	// First step: Draw the (virtual) game screen.
	g_context.getActivePipeline()->drawTexture(_gameScreen->getGLTexture(), _displayX, _displayY + shakeOffset, _displayWidth, _displayHeight);

	// Second step: Draw the overlay if visible.
	if (_overlayVisible) {
		g_context.getActivePipeline()->drawTexture(_overlay->getGLTexture(), 0, 0, _outputScreenWidth, _outputScreenHeight);
	}

	// Third step: Draw the cursor if visible.
	if (_cursorVisible && _cursor) {
		// Adjust game screen shake position, but only when the overlay is not
		// visible.
		const GLfloat cursorOffset = _overlayVisible ? 0 : shakeOffset;

		g_context.getActivePipeline()->drawTexture(_cursor->getGLTexture(),
		                         _cursorDisplayX - _cursorHotspotXScaled,
		                         _cursorDisplayY - _cursorHotspotYScaled + cursorOffset,
		                         _cursorWidthScaled, _cursorHeightScaled);
	}

#ifdef USE_OSD
	// Fourth step: Draw the OSD.
	if (_osdMessageSurface) {
		// Update alpha value.
		const int diff = g_system->getMillis(false) - _osdMessageFadeStartTime;
		if (diff > 0) {
			if (diff >= kOSDMessageFadeOutDuration) {
				// Back to full transparency.
				_osdMessageAlpha = 0;
			} else {
				// Do a fade out.
				_osdMessageAlpha = kOSDMessageInitialAlpha - diff * kOSDMessageInitialAlpha / kOSDMessageFadeOutDuration;
			}
		}

		// Set the OSD transparency.
		g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, _osdMessageAlpha / 100.0f);

		int dstX = (_outputScreenWidth - _osdMessageSurface->getWidth()) / 2;
		int dstY = (_outputScreenHeight - _osdMessageSurface->getHeight()) / 2;

		// Draw the OSD texture.
		g_context.getActivePipeline()->drawTexture(_osdMessageSurface->getGLTexture(),
		                                           dstX, dstY, _osdMessageSurface->getWidth(), _osdMessageSurface->getHeight());

		// Reset color.
		g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, 1.0f);

		if (_osdMessageAlpha <= 0) {
			delete _osdMessageSurface;
			_osdMessageSurface = nullptr;
		}
	}

	if (_osdIconSurface) {
		int dstX = _outputScreenWidth - _osdIconSurface->getWidth() - kOSDIconRightMargin;
		int dstY = kOSDIconTopMargin;

		// Draw the OSD icon texture.
		g_context.getActivePipeline()->drawTexture(_osdIconSurface->getGLTexture(),
		                                           dstX, dstY, _osdIconSurface->getWidth(), _osdIconSurface->getHeight());
	}
#endif

	refreshScreen();
}
Example #20
0
static void initWithFont(int fontSize)
{
    loadFont(false);
    refreshScreen();
}
Example #21
0
File: jeu.c Project: pouet/rubik
int jeu(Cube * cube, struct SItem * it, int nbItem) {
  Bouton ** b;
  SDL_Rect rimg[6] = {
    { POS_X_CUBISO + 3, POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO +
      cube->nbCubLig * 53 + 12, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * OFFSET_X_H_CUBISO + 22 - 6,
      POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO +
      (cube->nbCubLig - 1) * OFFSET_Y_H_CUBISO + cube->nbCubLig * 53 + 12, 0, 0 },
    { POS_X_CUBISO, POS_Y_CUBISO + (cube->nbCubLig - 1) * OFFSET_Y_H_CUBISO - 15 + 10, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * OFFSET_X_H_CUBISO + 18, POS_Y_CUBISO - 15 + 10, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * (OFFSET_X_H_CUBISO * 2 ) + 10,
      POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO + 15, 0, 0 },
    { POS_X_CUBISO - 27, POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO + 15, 0, 0 }
  };
  SDL_Rect roff[6] = {
    { OFFSET_X_H_CUBISO, OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, -OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, -OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, OFFSET_Y_H_CUBISO, 0, 0 },
    { 0, 53, 0, 0 },
    { 0, 53, 0, 0 }
  };
  Input * in;
  int ret = M_MENU;
  int nbBtn;
  int done;
  int clic;
  int timer;
  int i, j, k;
  
  if (cube == NULL)
    return ret;
  
  in = newEvent();
  
  nbBtn = nbItem + cube->nbCubLig * 6;
  b = emalloc((nbBtn + 1) * sizeof **b, "Erreur d'allocation de boutons.\n");
  b[nbBtn] = NULL;
  
  for (i = 0, j = 0; i < nbItem; i++, j++)
    b[i] = creerBoutonTexte(it[i].pItemName, SCR_W - g_boutons[0]->w - 12,
                            SCR_H - 6 - (nbItem - i) * (g_boutons[0]->h + 6), 1);
  
  for (k = 0; k < 6; k++)
    for (i = 0; i < cube->nbCubLig; i++, j++)
      b[j] = creerBoutonImage(k * 3, rimg[k].x + roff[k].x * i,
                              rimg[k].y + roff[k].y * i, 1);
  
  refreshScreen();
  
  timer = 0;
  clic = 0;
  done = 0;
  while (!done) {
    updateEvents(in);
    
    if (in->quit) {
      done = 1;
      ret = M_QUIT;
    }
    
    for (i = 0; i < nbBtn; i++) {
      if (b[i]->actif) {
        if (collisionPoint(&b[i]->r, &in->mouse)) {
          /* Si on clique */
          if (!clic && (in->mousebuttons[1] || in->mousebuttons[2])) {
            clic = 1;
            b[i]->etat = BTN_ETAT_CLIC;
            b[i]->majAff = 1;
          }
          /* Si on relâche le clic */
          else if (clic && b[i]->etat == BTN_ETAT_CLIC &&
                   !in->mousebuttons[1] && !in->mousebuttons[2]) {
            clic = 0;
            b[i]->etat = BTN_ETAT_NORMAL;
            b[i]->majAff = 1;
            
            if (i < nbItem) {
              if (it[i].nItemVal == M_MENU || it[i].nItemVal == M_QUIT) {
                ret = it[i].nItemVal;
                if (it[i].pVal)
                  *it[i].pVal = it[i].nVal;
                done = 1;
              }
              else if (it[i].nItemVal == M_MELANGE) {
                melangerCube(cube);
                timer = 0;
                cube->tpsTotal = 0;
                cube->nbCoups = 0;
              }
              else if (it[i].nItemVal == M_REINIT) {
                refreshScreen();
                initCube(cube, cube->nbCubLig);
                timer = 0;
              }
              else if (it[i].nItemVal == M_SAUVE) {
                sauverCube(cube);
              }
            }
            else if (i >= nbItem) {
              int tmp = i - nbItem;
              
              cube->nbCoups++;
              if (timer == 0)
                timer = 1;
              
              /* Ca va crescendo on teste la borne la plus basse et ainsi de suite
               * sans retester plus bas, c'est déjà test avant */
              /* Flèche haut gauche */
              if (tmp < cube->nbCubLig) {
                rotationCubeEntier(cube, R_GAUCHE);
                mouvement(cube, tmp, R_BAS);
                rotationCubeEntier(cube, R_DROITE);
              }
              /* Flèches haut droite */
              else if (tmp < cube->nbCubLig * 2) {
                tmp -= cube->nbCubLig;
                mouvement(cube, tmp, R_BAS);
              }
              /* Flèches bas gauche */
              else if (tmp < cube->nbCubLig * 3) {
                tmp -= (cube->nbCubLig * 2);
                mouvement(cube, tmp, R_HAUT);
              }
              /* Flèches bas droite */
              else if (tmp < cube->nbCubLig * 4) {
                tmp -= (cube->nbCubLig * 3);
                rotationCubeEntier(cube, R_GAUCHE);
                mouvement(cube, tmp, R_HAUT);
                rotationCubeEntier(cube, R_DROITE);
              }
              /* Flèches droite */
              else if (tmp < cube->nbCubLig * 5) {
                tmp -= (cube->nbCubLig * 4);
                mouvement(cube, tmp, R_DROITE);
              }
              /* Flèches gauche */
              else if (tmp < cube->nbCubLig * 6) {
                tmp -= (cube->nbCubLig * 5);
                mouvement(cube, tmp, R_GAUCHE);
              }
              else {
                cube->nbCoups--;
                aprintf("Bouton inconnu.\n");
              }
            }
            else {
              aprintf("Bouton inconnu.\n");
            }
          }
          else if (b[i]->etat != BTN_ETAT_CLIC) {
            if (b[i]->etat != BTN_ETAT_SURVOLE)
              b[i]->majAff = 1;
            b[i]->etat = BTN_ETAT_SURVOLE;
          }
        }
        else if (b[i]->etat != BTN_ETAT_CLIC) {
          if (b[i]->etat != BTN_ETAT_NORMAL)
            b[i]->majAff = 1;
          b[i]->etat = BTN_ETAT_NORMAL;
        }
      }
    }
    
    if (clic && !in->mousebuttons[1] && !in->mousebuttons[2]) {
      clic = 0;
      for (i = 0; i < nbBtn; i++)
        if (b[i]->etat == BTN_ETAT_CLIC) {
          b[i]->etat = BTN_ETAT_NORMAL;
          b[i]->majAff = 1;
        }
    }
    
    if (timer)
      cube->tpsTotal += TICK;
    
    affiche(BCK_JEU, cube, b);
  }
  
  for (i = 0; i < nbBtn; i++)
    detruireBouton(&b[i]);
  free(b);
  deleteEvent(&in);
  
  return ret;
}
Example #22
0
void terminalDriver() {
  char commands[NUM_SAVED_COMMANDS][BUFFERSIZE];
  int lengths[NUM_SAVED_COMMANDS];
  int commandNum = 0, viewingNum = 0;

  char curCommand[BUFFERSIZE];
  int commandLength = 0, totalCommands = 0;

  char c;

  int trainSpeeds[80];
  int i;
  for(i=0; i<80; i++) {
    trainSpeeds[i] = 0;
  }
  int train[80];
  for(i=0; i<80; i++) {
    train[i] = -1;
  }

  Create(2, clockDriver);

  outputEscape("[2J[13;100r");
  refreshScreen();
  initializeTrack();
  moveCursor(13, 1);
  Putc(2, '>');
  while(true) {
    c = (char)Getc(2);
    switch(c) {
      case '\r':
	curCommand[commandLength] = '\0';
	strcpy(commands[commandNum], curCommand);
	lengths[commandNum] = commandLength;
	Putc(2, '\r');
	parseCommand(curCommand, trainSpeeds, train);
	commandNum++;
	commandNum %= NUM_SAVED_COMMANDS;
	viewingNum = commandNum;
	commands[commandNum][0] = '\0';
	commandLength = 0;
	if(totalCommands < NUM_SAVED_COMMANDS-1) totalCommands++;
	Putc(2, '>');
	break;
      case '\t':
	if(commandLength > 0) {
	  curCommand[commandLength] = '\0';
	  commandLength = tabComplete(curCommand);
	  outputEscape("[100D[K");
	  printf(">%s", curCommand);
	}
	break;
      case '\x8':
	if(commandLength > 0) {
	  commandLength--;
	  outputEscape("[1D[K");
	}
	break;
      case '\x1B':	//escape
	c = (char)Getc(2);
	c = (char)Getc(2);
	if(c == 'A') {
	  if(commandNum == viewingNum) {
	    curCommand[commandLength] = '\0';
	    strcpy(commands[commandNum], curCommand);
	    lengths[commandNum] = commandLength;
	  }
	  if(viewingNum != ((commandNum + NUM_SAVED_COMMANDS - totalCommands) 
					% NUM_SAVED_COMMANDS)) {
	    viewingNum += NUM_SAVED_COMMANDS - 1;
	    viewingNum %= NUM_SAVED_COMMANDS;
	    strcpy(curCommand, commands[viewingNum]);
	    commandLength = lengths[viewingNum];
	    outputEscape("[100D[K");
	    printf(">%s", curCommand);
	  }
	}else if(c == 'B') {
	  if(viewingNum != commandNum) {
	    viewingNum += 1;
	    viewingNum %= NUM_SAVED_COMMANDS;
	    strcpy(curCommand, commands[viewingNum]);
	    commandLength = lengths[viewingNum];
	    outputEscape("[100D[K");
	    printf(">%s", curCommand);
	  }
	}
	break;
      default:
	if(commandLength < BUFFERSIZE - 1) {
          curCommand[commandLength++] = c;
          Putc(2, c);
	}
        break;
    }
  }
}
Example #23
0
void ScreenMx508::refreshScreen(Screen::ScreenMode mode, QString from)
{
    refreshScreen(mode, 0, from);
}
void Statistics::addPacketSentSize(char* packetData)
{
	totalPacketSentSize += strlen(packetData);

	refreshScreen();
}
void Statistics::incNAKSent()
{
	sentNAK++;

	refreshScreen();
}
void Statistics::incENQSent()
{
	sentENQ++;

	refreshScreen();
}
void Statistics::incACKSent()
{
	sentACK++;

	refreshScreen();
}
Example #28
0
int simulatorControl ( )
{
	char inputChar;

	refreshScreen();
	
	inputChar = getchar();
	while (inputChar != EOF)
	{
		/*if (scanf("%c",&inputChar) < 0)
		{
			perror("Simulator input error:");
		}*/

		switch(inputChar)
		{
			case ADD_ONE_CORRECT_PRODUCT :
				addProducts(1, TRUE);
				break;
			case ADD_MANY_CORRECT_PRODUCTS :
				addProducts(MANY_MEANING, TRUE);
				break;
			case ADD_ONE_DEFECTIVE_PRODUCT :
				addProducts(1, FALSE);
				break;
			case ADD_MANY_DEFECTIVE_PRODUCTS :
				addProducts(MANY_MEANING, FALSE);
				break;
			case EMERGENCY_STOP :
				EmergencyStopHandler();
				break;
			case TOGGLE_MISSING_BOX :
				if (boxMissing())
				{
					setBoxMissing(FALSE);
				}
				else
				{
					setBoxMissing(TRUE);
				}
				break;
			case TOGGLE_PRINTR1_BROKEN :
				if (printerState(PRINTR1))
				{
					setPrinterState(PRINTR1,FALSE);
				}
				else
				{
					setPrinterState(PRINTR1,TRUE);
				}
				break;
			case TOGGLE_PRINTR2_BROKEN :
				if (printerState(PRINTR2))
				{
					setPrinterState(PRINTR2,FALSE);
				}
				else
				{
					setPrinterState(PRINTR2,TRUE);
				}
				break;
			case REFRESH :
			default :
				break;
		}

		refreshScreen();
		
		inputChar = getchar();
	}
	
	return 0;
}
void Statistics::incNAKReceived()
{
	recNAK++;

	refreshScreen();
}
Example #30
0
int main(void)
{
    struct _tm timeCheck;

    WatchDogDisable();

    NutDelay(100);

    SysInitIO();

	SPIinit();

	LedInit();

	LcdLowLevelInit();

    Uart0DriverInit();
    Uart0DriverStart();
	LogInit();

    X12Init();

    VsPlayerInit();

    NtpInit();

    NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
    NutThreadCreate("BackgroundThread", AlarmSync, NULL, 2500);
    NutThreadCreate("BackgroundThread", AlarmCheck, NULL, 256);

	KbInit();

    SysControlMainBeat(ON);             // enable 4.4 msecs heartbeat interrupt

    /*
     * Increase our priority so we can feed the watchdog.
     */
    NutThreadSetPriority(1);

	/* Enable global interrupts */
	sei();
	
	LcdBackLight(LCD_BACKLIGHT_ON);
    setCurrentDisplay(DISPLAY_DateTime, 5);

    X12RtcGetClock(&timeCheck);
    int hours;
    int mins;
    int secs;
    if(!NutNvMemLoad(100, &hours, sizeof(hours)))
    {
        printf("uren: %d", hours);
    }
    if(!NutNvMemLoad(105, &mins, sizeof(mins)))
    {
        printf(" minuten: %d", mins);
    }
    if(!NutNvMemLoad(110, &secs, sizeof(secs)))
    {
        printf(" seconden %d", secs);
    }
    printf("Welcome to Saltyradio.\nI'm using mac address:  %s\n\n\n", getMacAdress());

    for (;;)
    {
        //Key detecten
        if(KbGetKey() == KEY_01){
            setCurrentDisplay(DISPLAY_DateTime, 5);
        }
        else if(KbGetKey() == KEY_OK)
        {
            if(getCurrentDisplay() == DISPLAY_MainMenu)
            {
                clickOk();
            }
            else if(getCurrentDisplay() == DISPLAY_SettingsMenu)
            {
                clickOkSettings();
            }
            else if(getCurrentDisplay() == DISPLAY_Play || getCurrentDisplay() == DISPLAY_Song)
            {
                clickOkPlay();
            }
            else
            {
                setCurrentDisplay(DISPLAY_MainMenu, 10000);
            }
        }
        else if(KbGetKey() == KEY_LEFT)
        {
            switchLeft();
        }
        else if(KbGetKey() == KEY_RIGHT)
        {
            switchItem();
        }
        else if(KbGetKey() == KEY_DOWN){
            setCurrentDisplay(DISPLAY_Volume, 5);
            volumeDown();
        }else if(KbGetKey() == KEY_UP) {
            setCurrentDisplay(DISPLAY_Volume, 5);
            volumeUp();
        }
        refreshScreen();
        WatchDogRestart();
        NutSleep(100);
    }
    return(0);
}