Beispiel #1
0
/**
 * @brief Opens the load game menu.
 */
void load_loadGameMenu (void)
{
   unsigned int wid;
   char **names, buf[PATH_MAX];
   nsave_t *nslist, *ns;
   int i, n, len;

   /* window */
   wid = window_create( "Load Game", -1, -1, LOAD_WIDTH, LOAD_HEIGHT );
   window_setAccept( wid, load_menu_load );
   window_setCancel( wid, load_menu_close );

   /* Load loads. */
   load_refresh();

   /* load the saves */
   nslist = load_getList( &n );
   if (n > 0) {
      names = malloc( sizeof(char*)*n );
      for (i=0; i<n; i++) {
         ns       = &nslist[i];
         len      = strlen(ns->path);
         if (strcmp(&ns->path[len-10],".ns.backup")==0) {
            nsnprintf( buf, sizeof(buf), "%s \er(Backup)\e0", ns->name );
            names[i] = strdup(buf);
         }
         else
Beispiel #2
0
Datei: menu.c Projekt: naev/naev
static int menu_main_bkg_system (void)
{
   nsave_t *ns;
   int n;
   const char *sys;
   Planet *pnt;
   double cx, cy;

   /* Clean pilots. */
   pilots_cleanAll();
   sys = NULL;

   /* Refresh saves. */
   load_refresh();

   /* Get start position. */
   ns = load_getList( &n );
   if ((n > 0) && (planet_exists( ns[0].planet ))) {
      pnt = planet_get( ns[0].planet );
      if (pnt != NULL) {
         sys = planet_getSystem( ns[0].planet );
         if (sys != NULL) {
            cx = pnt->pos.x;
            cy = pnt->pos.y;
            cx += 300;
            cy += 200;
         }
      }
   }

   /* Fallback if necessary. */
   if (sys == NULL) {
      sys = start_system();
      start_position( &cx, &cy );
   }

   /* Initialize. */
   space_init( sys );
   cam_setTargetPos( cx, cy, 0 );
   cam_setZoom( conf.zoom_far );
   pause_setSpeed( 1. );
   sound_setSpeed( 1. );

   return 0;
}