Exemple #1
0
void MainWindow::Play(const std::optional<std::string>& savestate_path)
{
  // If we're in a paused game, start it up again.
  // Otherwise, play the selected game, if there is one.
  // Otherwise, play the default game.
  // Otherwise, play the last played game, if there is one.
  // Otherwise, prompt for a new game.
  if (Core::GetState() == Core::State::Paused)
  {
    Core::SetState(Core::State::Running);
    EnableScreenSaver(false);
  }
  else
  {
    std::shared_ptr<const UICommon::GameFile> selection = m_game_list->GetSelectedGame();
    if (selection)
    {
      StartGame(selection->GetFilePath(), savestate_path);
      EnableScreenSaver(false);
    }
    else
    {
      QString default_path = QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
      if (!default_path.isEmpty() && QFile::exists(default_path))
      {
        StartGame(default_path, savestate_path);
        EnableScreenSaver(false);
      }
      else
      {
        Open();
      }
    }
  }
}
Exemple #2
0
void MainWindow::ForceStop()
{
  BootManager::Stop();
  EnableScreenSaver(true);
}
Exemple #3
0
void MainWindow::Pause()
{
  Core::SetState(Core::State::Paused);
  EnableScreenSaver(true);
}
Exemple #4
0
int main(int argc, char *argv[])
{
    /* Initialize Slideshow variables before the arguments are parsed..*/
    InitSlideShow();
    DisableScreenSaver();


    strcpy((char * ) frame.album_directory,"album"); // album or test_album for debugging..
    strcpy((char * ) frame.copy_directory,"Copied");
    strcpy((char * ) frame.move_directory,"Moved");
    strcpy((char * ) frame.resize_directory,"Resized");
    strcpy((char * ) frame.link_directory,"Linked");


    /* Parse Commandline arguments >>>>>>>>>>>>>>>>>> */
    if (!parseArguments(argc,argv))
    {
      fprintf(stderr,"Invalid arguments\n");
      EnableScreenSaver();
      return 1;
    }

    /* Turn on VSYNC to prevent tearing >>>>>>>>>>>>>>>>>> */
    putenv( (char *) "__GL_SYNC_TO_VBLANK=1" );
    //putenv( (char *) "__GL_SYNC_TO_VBLANK=1 __GL_YIELD=\"USLEEP\" " );
    /* GLUT Initialization >>>>>>>>>>>>>>>>>> */
    glutInit(&argc, argv);
    //Initializing Display Mode should be right after glutInit to ensure the window will get created using the correct flags..! ( double buffering etc )
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |  GLUT_ALPHA | GLUT_DEPTH ); // depth buffer and multisampling disabled for older systems..!  |GLUT_MULTISAMPLE | GLUT_DEPTH

    glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE ,GLUT_ACTION_CONTINUE_EXECUTION);

    int width_x=glutGet(GLUT_SCREEN_WIDTH);
    int width_y=glutGet(GLUT_SCREEN_HEIGHT)-50; // 50 for the lxpanel bar :P
    fprintf(stderr,"System Resolution is %ux%u\n",width_x,width_y);
    if (width_x>1024) { width_x=1024; }
    if (width_y>600)  { width_y=600; }

    char title[512]={0};
    sprintf(title,"Flashy Slideshows v%s %s - build %u - %s/%s/%s ",AutoVersion::FULLVERSION_STRING,AutoVersion::STATUS,(unsigned int) AutoVersion::BUILDS_COUNT,AutoVersion::DATE,AutoVersion::MONTH,AutoVersion::YEAR);


     fprintf(stderr,"Window Resolution is %ux%u\n",width_x,width_y);
     glutInitWindowSize(width_x,width_y);
     glutInitWindowPosition(0,0);

     frame.windowX=0; frame.windowY=0;
     frame.windowWidth=width_x; frame.windowHeight=width_y;
     originalWindow = glutCreateWindow(title);

   if (frame.fullscreen)
   {
      frame.fullscreen=0;
      ToggleFullscreen();
   }


    InitGlut();
    /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */


    /* OpenGL Initialization >>>>>>>>>>>>>>>>> */
    glClearColor(0,0,0,0);

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    //glEnable(GL_DEPTH_TEST);
    //glDepthFunc(GL_LESS);
    //glClearDepth(1.0);				// Enables Clearing Of The Depth Buffer



   if (frame.try_for_best_render_quality)
    {
     glEnable(GL_NORMALIZE);
     glShadeModel(GL_SMOOTH);
     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
     glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
     glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
     glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
    } else
    {
     glShadeModel(GL_FLAT);
    }

   /* LIGHTING , ENABLED ON GOOD RENDERING QUALITY ( TO ENABLE TRANSPARENCY ETC ) */
   if (frame.try_for_best_render_quality)
    {
    frame.lighting_enabled=1;
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
    //glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    //glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
    //glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
    //glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
    } else
    {
      frame.lighting_enabled=0;
    }
    /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */

   //Now that we have an OpenGL context we can query the maximum texture dimension..
   QueryAndSaveGPUAndSystemCapabilities();


    /* Initialize WxWidgets */
    WxWidgetsContext wxlibstuff;
    wxlibstuff.OnInit();
    fprintf(stderr,"Done with wxWidgets initialization\n");


    LoadStockTexturesAndSounds();
    InitEffects();

    if (!LoadPicturesOfDirectory((char*)frame.album_directory,frame.sort_type,frame.sort_ascending,frame.sort_randomization,frame.recursive))
      {
          EmmitDialogWarning( (char *) "Could not find any pictures in the directory of your selection");
          return 0;
      }
    frame.total_images=GetTotalViewableFilesInDirectory();
    if (!CreateSlideshowPictureStructure(GetTotalViewableFilesInDirectory()))
      {
          fprintf(stderr,"Unrecoverable error , could not allocate enough memory for %u Picture structure pointers..\nYou may try to re-run when more RAM will be availiable\n",GetTotalViewableFilesInDirectory());
          return 1;
      }

    /*At this point we have initialized the picture structures and the slideshow structures
      so lets make sure that the camera is over an existing picture..! */
    PutCameraOverExistingPictureIfItIsOff();

    /* Initialize Joystick Thread (if a joystick is connected and detected )*/
    StartJoystickControl();

    /* Initialize Picture Loading Thread */
    loadpicturesthread_id=0;
    pthread_create( &loadpicturesthread_id, NULL,ManageLoadingPicturesMemory_Thread,0);

    //This has to happen after LoadStockTexturesAndSounds in order for  frame.app_clipart_dir to get populated
    if (frame.enable_web_interface)
        {
          if (!StartWebInterface((char*) "0.0.0.0", 8080 , (char*) frame.album_directory , ( char*) frame.app_clipart_dir))
          {
           // EmmitDialogWarning( (char *) "Could not initialize web interface");
           fprintf(stderr,"\n\nCould not initialize web interface\n\n");
          }
        }

    gettimeofday(&last_frame,0x0);
    /* Start Rendering */
    glutMainLoop();
    fprintf(stderr,"Gracefully closing program\n");


    if (frame.enable_web_interface) { StopWebInterface(); }

    EnableScreenSaver();
    StopJoystickControl();
    UnLoadStockTexturesAndSounds();
    DestroySlideshowPictureStructure();
    wxlibstuff.OnClose();

    return EXIT_SUCCESS;
}