Ejemplo n.º 1
0
void playerInterface(char** tab, int nbColumns, int nbLines,int noGui, int log,int megafunModeOption)
{
  int i=0,x,player=1,choice,win=0;
  char cChoice[2];
  int nbBombs[2]={3,3};
  struct Coord Coord;
  do
    {
      if(!noGui)
	displayGrid(tab,nbLines,nbColumns);
      if(i%2==0)
	{
	  player=1;
	  Coord.bawn='X';
	}
      else
	{
	  player=2;
	  Coord.bawn='O';
	}
      if(megafunModeOption)
	bombInterface(tab,nbColumns,nbLines,&nbBombs[player-1],log,noGui);
      printf("\nJoueur %d, choisissez une colonne dans laquelle insérer votre pion:",player);
      if(read(cChoice,2,&choice)==0)
	printf("Problème dans la fonction read!!!!!");
      if(choice<0 || choice>nbColumns-1) //si choix fantaisiste
	{
	  printf("Veuillez choisir une colonne entre 0 et %d\n",nbColumns-1);
	  ++i;//on incrémente i deux fois afin que ce soit le même joueur qui rejoue
	}
      else
	{
	  x=placeBawn(tab,nbLines,nbColumns,choice,&Coord);
	  win=winner(tab, nbLines, nbColumns,&Coord);
	  if(log)
	    logFunction(&Coord,i,0,player,x);
	  if(x==-1)
	    ++i;
	}
      system("clear");
      if(megafunModeOption)
	megafunMode(tab,nbLines,nbColumns,&i,log);
      i++;
    }while(win==0);
  if(!noGui)
    displayGrid(tab,nbLines,nbColumns);
  if(winner(tab,nbLines,nbColumns,&Coord)==1)
    printf("\nLe joueur %d gagne la partie!!\n",player);
  else 
    printf("\nEgalité!\n");
  if(log)
    logFunction(&Coord,i,1,player,x);
}
Ejemplo n.º 2
0
void
mama_log (MamaLogLevel level, const char *format, ...)
{
	/* Get the log function and the log level under the reader lock. */
	MamaLogLevel currentLevel	= 0;
	mamaLogCb	 logFunction	= NULL;

	/* Acquire the read lock. */
	mamaLog_acquireLock(1);

	/* Get the variables. */
	currentLevel	= gMamaLogLevel;
	logFunction		= gMamaLogFunc;
	
	/* Release the read lock as quickly as possible. */
	MRSWLock_release(g_lock, 1);
	
	/* Only log if this level is valid. */
	if((currentLevel >= level) && (currentLevel != MAMA_LOG_LEVEL_OFF))
    {
		/* Convert the variable argument list into a va_list object for passing amongst functions. */
        va_list ap;
        va_start (ap, format);

		/* Call the log function. */
        logFunction(level, format, ap);

		/* Finished with the variable argument list. */
        va_end (ap);
    }
}
Ejemplo n.º 3
0
void
mama_logVa(MamaLogLevel level, 
           const char   *format, 
           va_list      args)
{
	/* Get the log function and the log level under the reader lock. */
	MamaLogLevel currentLevel	= 0;
	mamaLogCb	 logFunction	= NULL;

	/* Acquire the read lock. */
	mamaLog_acquireLock(1);

	/* Get the variables. */
	currentLevel	= gMamaLogLevel;
	logFunction		= gMamaLogFunc;
	
	/* Release the read lock as quickly as possible. */
	MRSWLock_release(g_lock, 1);
	
	/* Only log if this level is valid. */
	if((currentLevel >= level) && (currentLevel != MAMA_LOG_LEVEL_OFF))
    {
		/* Call the log function. */
        logFunction(level, format, args);
    }
}
Ejemplo n.º 4
0
void Adaptor::ParseEnvironmentOptions()
{
  // get logging options
  unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
  unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
  unsigned int logPerformanceLevel = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE, 0 );
  unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );

  // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
  Dali::Integration::Log::LogFunction  logFunction(Dali::SlpPlatform::LogMessage);

  mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceLevel, logPanGesture );
  mEnvironmentOptions.SetPanGesturePredictionMode(GetIntegerEnvironmentVariable( DALI_ENV_PAN_PREDICTION_MODE, 1));

  mEnvironmentOptions.InstallLogFunction();
}
Ejemplo n.º 5
0
void
mama_forceLogVa(const char   *format, 
           va_list      args)
{
	/* Get the log function and the log level under the reader lock. */
	MamaLogLevel currentLevel	= 0;
	mamaLogCb	 logFunction	= NULL;

	/* Acquire the read lock. */
	mamaLog_acquireLock(1);

	/* Get the variables. */
	currentLevel	= gMamaLogLevel;
	logFunction = gMamaForceLogFunc;
	
	/* Release the read lock as quickly as possible. */
	MRSWLock_release(g_lock, 1);

	/* Call the log function. */
    logFunction(currentLevel, format, args);
}
void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
{
  // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
  Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
  mEnvironmentOptions->SetLogFunction( logFunction );
  mEnvironmentOptions->InstallLogFunction(); // install logging for main thread

  mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;

  std::string path;
  GetDataStoragePath( path );
  mPlatformAbstraction->SetDataStoragePath( path );

  ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
  if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
  {
    dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
  }
  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
  // files automatically.

  if( mEnvironmentOptions->PerformanceServerRequired() )
  {
    mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
  }

  mCallbackManager = CallbackManager::New();

  PositionSize size = mSurface->GetPositionSize();

  mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);

  if( mEnvironmentOptions->GetGlesCallTime() > 0 )
  {
    mGLES = new GlProxyImplementation( *mEnvironmentOptions );
  }
  else
  {
    mGLES = new GlImplementation();
  }

  mEglFactory = new EglFactory();

  EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();

  mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );

  const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
  if( 0u < timeInterval )
  {
    mObjectProfiler = new ObjectProfiler( timeInterval );
  }

  mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);

  mVSyncMonitor = new VSyncMonitor;

  mThreadController = new ThreadController( *this, *mEnvironmentOptions );

  // Should be called after Core creation
  if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
  {
    Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
  }
  if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
  {
    Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
  }
  if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
  {
    Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
  }
  if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
  {
    Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
  }
  if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
  {
    Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
  }
  if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
  {
    Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
  }
  if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
  {
    Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
  }
  if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
  {
    Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
  }
}