Example #1
0
void menu_list_pop_stack_by_needle(menu_list_t *list,
      const char *needle)
{
   uint32_t needle_hash, label_hash;
   const char *path       = NULL;
   const char *label      = NULL;
   unsigned type          = 0;
   size_t entry_idx       = 0;
   menu_navigation_t *nav = menu_navigation_get_ptr();

   if (!list)
      return;

   menu_entries_set_refresh(false);
   menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
   needle_hash            = menu_hash_calculate(needle);
   label_hash             = menu_hash_calculate(label);

   while (needle_hash == label_hash)
   {
      menu_list_pop(list->menu_stack, &nav->selection_ptr);
      menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
      label_hash             = menu_hash_calculate(label);
      needle_hash            = menu_hash_calculate(needle);
   }
}
Example #2
0
static void menu_list_flush_stack(menu_list_t *list,
      size_t idx, const char *needle, unsigned final_type)
{
   const char *path       = NULL;
   const char *label      = NULL;
   unsigned type          = 0;
   size_t entry_idx       = 0;
   if (!list)
      return;

   menu_entries_set_refresh(false);
   menu_entries_get_last(list->menu_stack[idx],
         &path, &label, &type, &entry_idx);

   while (menu_entries_flush_stack_type(
            needle, label, type, final_type) != 0)
   {
      size_t new_selection_ptr;

      menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &new_selection_ptr);

      if (!menu_list_pop_stack(list, idx, &new_selection_ptr))
         break;

      menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection_ptr);

      menu_entries_get_last(list->menu_stack[idx],
            &path, &label, &type, &entry_idx);
   }
}
Example #3
0
static void menu_driver_toggle(bool latch)
{
   const menu_ctx_driver_t *menu_driver = menu_ctx_driver_get_ptr();
   settings_t                 *settings = config_get_ptr();
   global_t                   *global   = global_get_ptr();
   rarch_system_info_t          *system = rarch_system_info_get_ptr();

   if (menu_driver->toggle)
      menu_driver->toggle(latch);

   if (latch)
      menu_driver_ctl(RARCH_MENU_CTL_SET_ALIVE, NULL);
   else
      menu_driver_ctl(RARCH_MENU_CTL_UNSET_ALIVE, NULL);

   if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
   {
      menu_entries_set_refresh(false);

      /* Menu should always run with vsync on. */
      event_command(EVENT_CMD_VIDEO_SET_BLOCKING_STATE);
      /* Stop all rumbling before entering the menu. */
      event_command(EVENT_CMD_RUMBLE_STOP);

      if (settings->menu.pause_libretro)
         event_command(EVENT_CMD_AUDIO_STOP);

      /* Override keyboard callback to redirect to menu instead.
       * We'll use this later for something ...
       * FIXME: This should probably be moved to menu_common somehow. */
      if (global)
      {
         global->frontend_key_event = system->key_event;
         system->key_event          = menu_input_key_event;

         runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
      }
   }
   else
   {
      if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
         driver_set_nonblock_state();

      if (settings && settings->menu.pause_libretro)
         event_command(EVENT_CMD_AUDIO_START);

      /* Prevent stray input from going to libretro core */
      input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);

      /* Restore libretro keyboard callback. */
      if (global)
         system->key_event = global->frontend_key_event;
   }
}
Example #4
0
void menu_list_pop_stack(menu_list_t *list)
{
   menu_navigation_t *nav = menu_navigation_get_ptr();
   if (!list)
      return;

   if (menu_list_get_stack_size(list) <= 1)
      return;

   menu_driver_list_cache(MENU_LIST_PLAIN, 0);

   menu_list_pop(list->menu_stack, &nav->selection_ptr);
   menu_entries_set_refresh(false);
}
Example #5
0
void menu_driver_toggle(bool latch)
{
   driver_t                     *driver = driver_get_ptr();
   const menu_ctx_driver_t *menu_driver = menu_ctx_driver_get_ptr();
   settings_t                 *settings = config_get_ptr();
   global_t                   *global   = global_get_ptr();
   rarch_system_info_t          *system = rarch_system_info_get_ptr();

   if (menu_driver->toggle)
      menu_driver->toggle(latch);

   menu_alive = latch;

   if (menu_alive == true)
   {
      menu_entries_set_refresh(false);

      /* Menu should always run with vsync on. */
      event_command(EVENT_CMD_VIDEO_SET_BLOCKING_STATE);
      /* Stop all rumbling before entering the menu. */
      event_command(EVENT_CMD_RUMBLE_STOP);

      if (settings->menu.pause_libretro)
         event_command(EVENT_CMD_AUDIO_STOP);

      /* Override keyboard callback to redirect to menu instead.
       * We'll use this later for something ...
       * FIXME: This should probably be moved to menu_common somehow. */
      if (global)
      {
         global->frontend_key_event = system->key_event;
         system->key_event          = menu_input_key_event;
         system->frame_time_last    = 0;
      }
   }
   else
   {
      driver_set_nonblock_state(driver->nonblock_state);

      if (settings && settings->menu.pause_libretro)
         event_command(EVENT_CMD_AUDIO_START);

      /* Prevent stray input from going to libretro core */
      driver->flushing_input = true;

      /* Restore libretro keyboard callback. */
      if (global)
         system->key_event = global->frontend_key_event;
   }
}
Example #6
0
static int action_start_cheat_num_passes(unsigned type, const char *label)
{
   global_t *global       = global_get_ptr();
   cheat_manager_t *cheat = global->cheat;

   if (!cheat)
      return -1;

   if (cheat->size)
   {
      menu_entries_set_refresh(false);
      cheat_manager_realloc(cheat, 0);
   }

   return 0;
}
Example #7
0
static int action_right_cheat_num_passes(unsigned type, const char *label,
      bool wraparound)
{
   unsigned new_size = 0;
   global_t *global       = global_get_ptr();
   cheat_manager_t *cheat = global->cheat;

   if (!cheat)
      return -1;

   new_size = cheat->size + 1;
   menu_entries_set_refresh();
   cheat_manager_realloc(cheat, new_size);

   return 0;
}
Example #8
0
/**
 * menu_shader_manager_set_preset:
 * @shader                   : Shader handle.   
 * @type                     : Type of shader.
 * @preset_path              : Preset path to load from.
 *
 * Sets shader preset.
 **/
void menu_shader_manager_set_preset(struct video_shader *shader,
      unsigned type, const char *preset_path)
{
#ifdef HAVE_SHADER_MANAGER
   config_file_t *conf         = NULL;
   settings_t *settings        = config_get_ptr();

   settings->video.shader_enable = false;

   if (!video_driver_set_shader((enum rarch_shader_type)type, preset_path))
      return;

   /* Makes sure that we use Menu Preset shader on driver reinit.
    * Only do this when the cgp actually works to avoid potential errors. */
   strlcpy(settings->video.shader_path, preset_path ? preset_path : "",
         sizeof(settings->video.shader_path));
   settings->video.shader_enable = true;

   if (!preset_path)
      return;
   if (!shader)
      return;

   /* Load stored Preset into menu on success. 
    * Used when a preset is directly loaded.
    * No point in updating when the Preset was 
    * created from the menu itself. */
   conf = config_file_new(preset_path);

   if (!conf)
      return;

   RARCH_LOG("Setting Menu shader: %s.\n", preset_path ? preset_path : "N/A (stock)");

   if (video_shader_read_conf_cgp(conf, shader))
   {
      video_shader_resolve_relative(shader, preset_path);
      video_shader_resolve_parameters(conf, shader);
   }
   config_file_free(conf);

   menu_entries_set_refresh(false);
#endif
}
Example #9
0
static int action_start_shader_num_passes(unsigned type, const char *label)
{
#ifdef HAVE_SHADER_MANAGER
   struct video_shader *shader = NULL;
   menu_handle_t *menu = menu_driver_get_ptr();
   if (!menu)
      return -1;

   shader = menu->shader;
   if (!shader)
      return -1;
   if (shader->passes)
      shader->passes = 0;

   menu_entries_set_refresh(false);
   video_shader_resolve_parameters(NULL, menu->shader);
#endif
   return 0;
}
Example #10
0
static int action_left_cheat_num_passes(unsigned type, const char *label,
      bool wraparound)
{
   unsigned new_size = 0;
   global_t *global       = global_get_ptr();
   menu_handle_t *menu    = menu_driver_get_ptr();
   cheat_manager_t *cheat = global->cheat;

   if (!cheat)
      return -1;

   if (cheat_manager_get_size(cheat))
      new_size = cheat_manager_get_size(cheat) - 1;
   menu_entries_set_refresh(false);
   menu->prevent_populate = true;
   cheat_manager_realloc(cheat, new_size);

   return 0;
}
Example #11
0
static int action_right_shader_num_passes(unsigned type, const char *label,
      bool wraparound)
{
#ifdef HAVE_SHADER_MANAGER
   struct video_shader *shader = NULL;
   menu_handle_t *menu = menu_driver_get_ptr();
   if (!menu)
      return -1;

   shader = menu->shader;
   if (!shader)
      return -1;

   if ((shader->passes < GFX_MAX_SHADERS))
      shader->passes++;
   menu_entries_set_refresh();
   video_shader_resolve_parameters(NULL, menu->shader);

#endif
   return 0;
}
Example #12
0
static bool menu_list_pop_stack(menu_list_t *list, size_t idx, size_t *directory_ptr)
{
   file_list_t *menu_list = NULL;
   if (!list)
      return false;

   menu_list = list->menu_stack[idx];

   if (menu_list_get_stack_size(list, idx) <= 1)
      return false;

   menu_driver_list_cache(MENU_LIST_PLAIN, 0);

   if (menu_list->size != 0)
      menu_driver_list_free(menu_list, menu_list->size - 1, menu_list->size - 1);

   file_list_pop(menu_list, directory_ptr);
   menu_driver_list_set_selection(menu_list);

   menu_entries_set_refresh(false);

   return true;
}
Example #13
0
void menu_list_flush_stack(menu_list_t *list,
      const char *needle, unsigned final_type)
{
   const char *path       = NULL;
   const char *label      = NULL;
   unsigned type          = 0;
   size_t entry_idx       = 0;
   menu_navigation_t *nav = menu_navigation_get_ptr();
   if (!list)
      return;

   menu_entries_set_refresh(false);
   menu_list_get_last(list->menu_stack,
         &path, &label, &type, &entry_idx);

   while (menu_list_flush_stack_type(
            needle, label, type, final_type) != 0)
   {
      menu_list_pop(list->menu_stack, &nav->selection_ptr);
      menu_list_get_last(list->menu_stack,
            &path, &label, &type, &entry_idx);
   }
}