Exemplo n.º 1
0
void load_menu_game_history(void *data, unsigned game_index)
{
   rgui_handle_t *rgui;
   const char *path = NULL;
   const char *core_path = NULL;
   const char *core_name = NULL;

   rgui = (rgui_handle_t*)data;

   if (!rgui)
      return;

   rom_history_get_index(rgui->history,
         game_index, &path, &core_path, &core_name);

   // SET_LIBRETRO_PATH is unsafe here.
   // Risks booting different and wrong core if core doesn't exist anymore.
   strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));

   if (path)
      rgui->load_no_rom = false;
   else
      rgui->load_no_rom = true;

   rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);

#if defined(HAVE_DYNAMIC)
   menu_update_system_info(rgui, NULL);
#endif
}
Exemplo n.º 2
0
static void menu_update_libretro_info(menu_handle_t *menu)
{
#ifndef HAVE_DYNAMIC
   retro_get_system_info(&menu->info);
#endif

   core_info_list_free(menu->core_info);
   menu->core_info = NULL;
   if (*g_settings.libretro_directory)
      menu->core_info = core_info_list_new(g_settings.libretro_directory);

   menu_update_system_info(menu, NULL);
}
Exemplo n.º 3
0
void load_menu_game_new_core(void *data)
{
   rgui_handle_t *rgui = (rgui_handle_t*)data;

   if (!rgui)
      return;

#ifdef HAVE_DYNAMIC
   menu_update_system_info(rgui, &rgui->load_no_rom);
   g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
#else
   rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
   rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
#endif
}
Exemplo n.º 4
0
static void menu_update_libretro_info(void *data)
{
   rgui_handle_t *rgui = (rgui_handle_t*)data;

   if (!rgui)
      return;

#ifndef HAVE_DYNAMIC
   retro_get_system_info(&rgui->info);
#endif

   memset(&rgui->core_info_current, 0, sizeof(rgui->core_info_current));
   core_info_list_free(rgui->core_info);
   rgui->core_info = NULL;
   if (*g_settings.libretro_directory)
      rgui->core_info = core_info_list_new(g_settings.libretro_directory);

   menu_update_system_info(rgui, NULL);
}
Exemplo n.º 5
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
}
Exemplo n.º 6
0
static int menu_lakka_iterate(unsigned action)
{
   menu_category_t *active_category;
   menu_item_t *active_item;

   if (!driver.menu)
   {
      RARCH_ERR("Cannot iterate menu, menu handle is not initialized.\n");
      return 0;
   }

   active_category = NULL;
   active_item = NULL;

   active_category = (menu_category_t*)&categories[menu_active_category];

   if (active_category)
      active_item = (menu_item_t*)&active_category->items[active_category->active_item];

   if (!active_category || !active_item)
      return 0;

   if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
      driver.menu_ctx->set_texture(driver.menu);

   switch (action)
   {
      case MENU_ACTION_LEFT:
         if (depth == 0 && menu_active_category > 0)
         {
            menu_active_category--;
            lakka_switch_categories();
         }
         break;

      case MENU_ACTION_RIGHT:
         if (depth == 0 && menu_active_category < num_categories-1)
         {
            menu_active_category++;
            lakka_switch_categories();
         }
         break;

      case MENU_ACTION_DOWN:
         if (depth == 0 && active_category->active_item < active_category->num_items - 1)
         {
            active_category->active_item++;
            lakka_switch_items();
         }
         if (depth == 1 // if we are on subitems level
         && active_item->active_subitem < active_item->num_subitems -1 // and we do not exceed the number of subitems
         && (menu_active_category == 0 // and we are in settings or a rom is launched
         || ((active_item->active_subitem < active_item->num_subitems -1) && (g_extern.main_is_init && !g_extern.libretro_dummy) && strcmp(g_extern.fullpath, &active_item->rom) == 0)))
         {
            active_item->active_subitem++;
            lakka_switch_subitems();
         }
         break;

      case MENU_ACTION_UP:
         if (depth == 0 && active_category->active_item > 0)
         {
            active_category->active_item--;
            lakka_switch_items();
         }
         if (depth == 1 && active_item->active_subitem > 0)
         {
            active_item->active_subitem--;
            lakka_switch_subitems();
         }
         break;

      case MENU_ACTION_OK:
         if (depth == 1)
         {
            switch (active_item->active_subitem)
            {
               case 0:
                  global_alpha = 0.0;
                  if (g_extern.main_is_init && !g_extern.libretro_dummy
                        && strcmp(g_extern.fullpath, active_item->rom) == 0)
                     g_extern.lifecycle_state |= (1ULL << MODE_GAME);
                  else
                  {
                     strlcpy(g_extern.fullpath, active_item->rom, sizeof(g_extern.fullpath));
                     strlcpy(g_settings.libretro, active_category->libretro, sizeof(g_settings.libretro));

#ifdef HAVE_DYNAMIC
                     menu_update_system_info(driver.menu, &driver.menu->load_no_rom);
                     g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME);
#else
                     rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro);
                     rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)g_extern.fullpath);
#endif
                  }
                  return -1;
                  break;
               case 1:
                  global_alpha = 0.0;
                  rarch_save_state();
                  g_extern.lifecycle_state |= (1ULL << MODE_GAME);
                  return -1;
                  break;
               case 2:
                  global_alpha = 0.0;
                  rarch_load_state();
                  g_extern.lifecycle_state |= (1ULL << MODE_GAME);
                  return -1;
                  break;
               case 3:
                  rarch_take_screenshot();
                  break;
               case 4:
                  global_alpha = 0.0;
                  rarch_game_reset();
                  g_extern.lifecycle_state |= (1ULL << MODE_GAME);
                  return -1;
                  break;
            }
         }
         else if (depth == 0 && active_item->num_subitems)
         {
            lakka_open_submenu();
            depth = 1;
         }
         else if (depth == 0 && menu_active_category == 0 && active_item->active_subitem == 1) // Hardcoded "Quit" item index
         {
            printf("EXIT\n");
         }
         break;

      case MENU_ACTION_CANCEL:
         if (depth == 1)
         {
            lakka_close_submenu();
            depth = 0;
         }
         break;
      default:
         break;
   }

   if (driver.menu_ctx && driver.menu_ctx->iterate)
      driver.menu_ctx->iterate(driver.menu, action);

   if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
      driver.menu_ctx->render();

   return 0;
}