示例#1
0
/**
 * menu_content_playlist_load:
 * @playlist             : Playlist handle.
 * @idx                  : Index in playlist.
 *
 * Initializes core and loads content based on playlist entry.
 **/
void menu_content_playlist_load(void *data, unsigned idx)
{
   const char *core_path        = NULL;
   const char *path             = NULL;
   content_playlist_t *playlist = (content_playlist_t*)data;

   if (!playlist)
      return;

   content_playlist_get_index(playlist,
         idx, &path, NULL, &core_path, NULL, NULL, NULL);

   if (path && !string_is_empty(path))
   {
      unsigned i;
      RFILE *fp           = NULL;
      char *path_check    = NULL;
      char *path_tolower  = strdup(path);

      for (i = 0; i < strlen(path_tolower); ++i)
         path_tolower[i] = tolower(path_tolower[i]);

      if (strstr(path_tolower, ".zip"))
         strstr(path_tolower, ".zip")[4] = '\0';
      else if (strstr(path_tolower, ".7z"))
         strstr(path_tolower, ".7z")[3] = '\0';

      path_check = (char *)calloc(strlen(path_tolower) + 1, sizeof(char));
      strncpy(path_check, path, strlen(path_tolower));

      fp = retro_fopen(path_check, RFILE_MODE_READ, -1);
      if (!fp)
      {
         runloop_msg_queue_push("File could not be loaded.\n", 1, 100, true);
         RARCH_LOG("File at %s failed to load.\n", path_check);
         free(path_tolower);
         free(path_check);
         return;
      }
      retro_fclose(fp);
      free(path_tolower);
      free(path_check);
   }

   runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path);

   if (path)
      menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL);
   else
      menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL);

   rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);

   event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL);
}
示例#2
0
static int action_ok_playlist_entry(const char *path,
      const char *label, unsigned type, size_t idx)
{
   const char *entry_path  = NULL;
   const char *entry_label = NULL;
   const char *core_path   = NULL;
   const char *core_name   = NULL;
   size_t selection_ptr = 0;
   content_playlist_t *playlist = g_defaults.history;
   menu_handle_t *menu = menu_driver_get_ptr();
   if (!menu)
      return -1;

   if (!strcmp(label, "collection") ||
         !strcmp(label, "rdb_entry_start_game"))
   {
      if (!menu->playlist)
      {
         menu->playlist = content_playlist_init(menu->db_playlist_file, 1000);

         if (!menu->playlist)
            return -1;
      }

      playlist = menu->playlist;
   }

   selection_ptr = menu->navigation.selection_ptr;

   if (!strcmp(label, "rdb_entry_start_game"))
      selection_ptr = rdb_entry_start_game_selection_ptr;

   content_playlist_get_index(playlist, idx,
         &entry_path, &entry_label, &core_path, &core_name, NULL); 

#if 1
   RARCH_LOG("path: %s, label: %s, core path: %s, core name: %s\n", entry_path, entry_label,
         core_path, core_name);
#endif

   if (core_path && core_path[0] != '\0' && core_name &&
         core_name[0] != '\0' && !strcmp(core_path, "DETECT") && !strcmp(core_name, "DETECT"))
      return action_ok_file_load_with_detect_core(entry_path, label, type, idx);


   rarch_playlist_load_content(playlist, selection_ptr);

   menu_list_flush_stack(menu->menu_list, NULL, MENU_SETTINGS);
   return -1;
}
示例#3
0
/**
 * rarch_playlist_load_content:
 * @playlist             : Playlist handle.
 * @idx                  : Index in playlist.
 *
 * Initializes core and loads content based on playlist entry.
 **/
void rarch_playlist_load_content(content_playlist_t *playlist,
      unsigned idx)
{
   const char *path      = NULL;
   const char *core_path = NULL;
   menu_handle_t *menu   = menu_driver_get_ptr();
   settings_t  *settings = config_get_ptr();

   content_playlist_get_index(playlist,
         idx, &path, &core_path, NULL);

   strlcpy(settings->libretro, core_path, sizeof(settings->libretro));

   if (menu)
      menu->load_no_content = (path) ? false : true;

   rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);

   event_command(EVENT_CMD_LOAD_CORE);
}
示例#4
0
void load_menu_content_history(unsigned game_index)
{
   const char *path      = NULL;
   const char *core_path = NULL;
   const char *core_name = NULL;

   if (!driver.menu)
      return;

   content_playlist_get_index(g_extern.history,
         game_index, &path, &core_path, &core_name);

   strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));

   driver.menu->load_no_content = (path) ? false : true;

   rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);

#if defined(HAVE_DYNAMIC)
   menu_update_system_info(driver.menu, NULL);
#endif
}
示例#5
0
/**
 * menu_content_load_from_playlist:
 * @playlist             : Playlist handle.
 * @idx                  : Index in playlist.
 *
 * Initializes core and loads content based on playlist entry.
 **/
static bool menu_content_load_from_playlist(void *data)
{
   unsigned idx;
   const char *core_path        = NULL;
   const char *path             = NULL;
   menu_content_ctx_playlist_info_t *info = 
      (menu_content_ctx_playlist_info_t *)data;
   content_playlist_t *playlist = NULL;
   
   if (!info)
      return false;

   playlist = (content_playlist_t*)info->data;
   idx      = info->idx;

   if (!playlist)
      return false;

   content_playlist_get_index(playlist,
         idx, &path, NULL, &core_path, NULL, NULL, NULL);

   if (path && !string_is_empty(path))
   {
      unsigned i;
      RFILE *fp           = NULL;
      char *path_check    = NULL;
      char *path_tolower  = strdup(path);

      for (i = 0; i < strlen(path_tolower); ++i)
         path_tolower[i] = tolower(path_tolower[i]);

      if (strstr(path_tolower, ".zip"))
         strstr(path_tolower, ".zip")[4] = '\0';
      else if (strstr(path_tolower, ".7z"))
         strstr(path_tolower, ".7z")[3] = '\0';

      path_check = (char *)
         calloc(strlen(path_tolower) + 1, sizeof(char));

      strncpy(path_check, path, strlen(path_tolower));

      free(path_tolower);

      fp = retro_fopen(path_check, RFILE_MODE_READ, -1);

      free(path_check);

      if (!fp)
         goto error;

      retro_fclose(fp);
   }

   runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path);

   if (path)
      menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL);
   else
      menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL);

   if (!event_cmd_ctl(EVENT_CMD_EXEC, (void*)path))
      return false;

   event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL);

   return true;

error:
   runloop_msg_queue_push("File could not be loaded.\n", 1, 100, true);
   return false;
}