Ejemplo n.º 1
0
static void xmb_frame(void)
{
   int i;
   char title_msg[64];
   size_t end;
   const char *dir = NULL;
   const char *label = NULL;
   unsigned menu_type = 0;
   xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;

   gl_t *gl = (gl_t*)driver_video_resolve(NULL);

   if (!xmb || !gl)
      return;

   if (driver.menu->need_refresh
         && g_extern.is_menu
         && !driver.menu->msg_force)
      return;

   update_tweens(0.002);

   glViewport(0, 0, gl->win_width, gl->win_height);

   xmb_render_background();

   file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);

   get_title(label, dir, menu_type, xmb->title, sizeof(xmb->title));

   xmb_draw_text(xmb->title, 30, 40, 1, 1);

   const char *core_name = g_extern.menu.info.library_name;
   if (!core_name)
      core_name = g_extern.system.info.library_name;
   if (!core_name)
      core_name = "No Core";

   const char *core_version = g_extern.menu.info.library_version;
   if (!core_version)
      core_version = g_extern.system.info.library_version;
   if (!core_version)
      core_version = "";

   snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
         core_name, core_version);
   xmb_draw_text(title_msg, 30, gl->win_height - 30, 1, 1);

   end = file_list_get_size(driver.menu->selection_buf);

   for (i = 0; i < end; i++)
   {
      char value[PATH_MAX], path_buf[PATH_MAX];
      const char *path = NULL, *entry_label = NULL;
      unsigned type = 0, w = 0;
      xmb_node_t *node = NULL;

      file_list_get_at_offset(driver.menu->selection_buf, i, &path,
            &entry_label, &type);
      node = (xmb_node_t*)file_list_get_userdata_at_offset(
            driver.menu->selection_buf, i);
      
      disp_set_label(&w, type, i, label,
            value, sizeof(value),
            entry_label, path,
            path_buf, sizeof(path_buf));

      xmb_draw_icon(xmb->textures[XMB_TEXTURE_SETTING].id,
            xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0, 
            xmb->margin_top + node->y + xmb->icon_size/2.0, 
            node->alpha, 
            0, 
            node->zoom);

      xmb_draw_text(path_buf,
            xmb->margin_left + xmb->hspacing + xmb->label_margin_left, 
            xmb->margin_top + node->y + xmb->label_margin_top, 
            1, 
            node->alpha);

      xmb_draw_text(value,
            xmb->margin_left + xmb->hspacing + 
            xmb->label_margin_left + xmb->setting_margin_left, 
            xmb->margin_top + node->y + xmb->label_margin_top, 
            1, 
            node->alpha);
   }

   xmb_draw_icon(xmb->textures[XMB_TEXTURE_SETTINGS].id, 
         xmb->margin_left + xmb->hspacing - xmb->icon_size / 2.0,
         xmb->margin_top + xmb->icon_size / 2.0, 
         1.0, 
         0, 
         1.0);

#ifdef GEKKO
   const char *message_queue;

   if (driver.menu->msg_force)
   {
      message_queue = msg_queue_pull(g_extern.msg_queue);
      driver.menu->msg_force = false;
   }
   else
      message_queue = driver.current_msg;

   xmb_render_messagebox(message_queue);
#endif

   if (driver.menu->keyboard.display)
   {
      char msg[PATH_MAX];
      const char *str = *driver.menu->keyboard.buffer;
      if (!str)
         str = "";
      snprintf(msg, sizeof(msg), "%s\n%s",
            driver.menu->keyboard.label, str);
      xmb_render_messagebox(msg);
   }

   if (xmb->box_message[0] != '\0')
   {
      xmb_render_background();
      xmb_render_messagebox(xmb->box_message);
      xmb->box_message[0] = '\0';
   }

   gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
}
Ejemplo n.º 2
0
static void xmb_draw_icon(GLuint texture, float x, float y,
      float alpha, float rotation, float scale)
{
   struct gl_coords coords;
   xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;

   if (!xmb)
      return;

   if (alpha > xmb->alpha)
      alpha = xmb->alpha;

   if (alpha == 0)
      return;

   gl_t *gl = (gl_t*)driver_video_resolve(NULL);

   if (!gl)
      return;

   if (x < -xmb->icon_size || x > gl->win_width + xmb->icon_size
         || y < -xmb->icon_size || y > gl->win_height + xmb->icon_size)
      return;

   GLfloat color[] = {
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
   };

   if (gl->shader && gl->shader->use)
      gl->shader->use(gl, GL_SHADER_STOCK_BLEND);

   glViewport(x, gl->win_height - y, xmb->icon_size, xmb->icon_size);

   coords.vertices = 4;
   coords.vertex = rmb_vertex;
   coords.tex_coord = rmb_tex_coord;
   coords.lut_tex_coord = rmb_tex_coord;
   coords.color = color;
   glBindTexture(GL_TEXTURE_2D, texture);

   math_matrix mymat;

   math_matrix mrot;
   matrix_rotate_z(&mrot, rotation);
   matrix_multiply(&mymat, &mrot, &gl->mvp_no_rot);

   math_matrix mscal;
   matrix_scale(&mscal, scale, scale, 1);
   matrix_multiply(&mymat, &mscal, &mymat);

   gl->shader->set_coords(&coords);
   gl->shader->set_mvp(gl, &mymat);

   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   glDisable(GL_BLEND);
}
Ejemplo n.º 3
0
static void glui_render_background(bool force_transparency)
{
   float alpha = 0.75f;
   gl_t *gl = NULL;
   glui_handle_t *glui = NULL;

   if (!driver.menu)
      return;

   glui = (glui_handle_t*)driver.menu->userdata;

   if (!glui)
      return;

   GLfloat color[] = {
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
      1.0f, 1.0f, 1.0f, alpha,
   };

   GLfloat black_color[] = {
      0.0f, 0.0f, 0.0f, alpha,
      0.0f, 0.0f, 0.0f, alpha,
      0.0f, 0.0f, 0.0f, alpha,
      0.0f, 0.0f, 0.0f, alpha,
   };

   gl = (gl_t*)driver_video_resolve(NULL);

   if (!gl)
      return;

   glViewport(0, 0, gl->win_width, gl->win_height);

   static const GLfloat vertex[] = {
      0, 0,
      1, 0,
      0, 1,
      1, 1,
   };

   static const GLfloat tex_coord[] = {
      0, 1,
      1, 1,
      0, 0,
      1, 0,
   };

   struct gl_coords coords;
   coords.vertices = 4;
   coords.vertex = vertex;
   coords.tex_coord = tex_coord;
   coords.lut_tex_coord = tex_coord;

   if ((g_settings.menu.pause_libretro
      || !g_extern.main_is_init || g_extern.libretro_dummy)
      && !force_transparency
      && glui->bg)
   {
      coords.color = color;
      glBindTexture(GL_TEXTURE_2D, glui->bg);
   }
   else
   {
      coords.color = black_color;
      glBindTexture(GL_TEXTURE_2D, 0);
   }

   gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
   gl->shader->set_coords(&coords);
   gl->shader->set_mvp(gl, &gl->mvp_no_rot);

   glEnable(GL_BLEND);
   glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   glDisable(GL_BLEND);

   gl->coords.color = gl->white_color_ptr;
}
Ejemplo n.º 4
0
static void *lakka_init(void)
{
   menu_handle_t *menu = NULL;
   lakka_handle_t *lakka = NULL;
   const video_driver_t *video_driver = NULL;
   gl_t *gl = (gl_t*)driver_video_resolve(&video_driver);

   if (video_driver != &video_gl || !gl)
   {
      RARCH_ERR("Cannot initialize Lakka menu driver: gl video driver is not active.\n");
      return NULL;
   }

   menu = (menu_handle_t*)calloc(1, sizeof(*menu));

   if (!menu)
      return NULL;


   lakka_init_core_info(menu);

   menu->userdata = (lakka_handle_t*)calloc(1, sizeof(lakka_handle_t));

   if (!menu->userdata)
      return NULL;

   lakka = (lakka_handle_t*)menu->userdata;

   if (!lakka)
      return NULL;

   lakka->num_categories       = g_extern.core_info ? (g_extern.core_info->count + 1) : 1;

   lakka->categories = (menu_category_t*)
      calloc(lakka->num_categories, sizeof(menu_category_t));

   if (!lakka->categories)
   {
      free(menu);
      return NULL;
   }

   lakka->c_active_zoom   = 1.0;
   lakka->c_passive_zoom  = 0.5;
   lakka->i_active_zoom   = 1.0;
   lakka->i_passive_zoom  = 0.5;

   lakka->c_active_alpha  = 1.0;
   lakka->c_passive_alpha = 0.5;
   lakka->i_active_alpha  = 1.0;
   lakka->i_passive_alpha = 0.5;

   lakka->above_subitem_offset = 1.5;
   lakka->above_item_offset    = -1.0;
   lakka->active_item_factor   = 2.75;
   lakka->under_item_offset    = 4.0;

   if (gl->win_width >= 3840)
   {
      lakka->icon_size = 256;
      lakka->hspacing = 400;
      lakka->vspacing = 128;
      lakka->margin_left = 672.0;
      lakka->margin_top = 512;
      lakka->title_margin_left = 20.0;
      lakka->title_margin_top = 50.0;
      lakka->label_margin_left = 192;
      lakka->label_margin_top = 15;
      lakka->setting_margin_left = 1200;
      strcpy(lakka->icon_dir, "256");
   }
   else if (gl->win_width >= 2560)
   {
      lakka->icon_size = 192;
      lakka->hspacing = 300;
      lakka->vspacing = 96;
      lakka->margin_left = 448.0;
      lakka->margin_top = 384;
      lakka->title_margin_left = 15.0;
      lakka->title_margin_top = 40.0;
      lakka->label_margin_left = 144;
      lakka->label_margin_top = 11.0;
      lakka->setting_margin_left = 800;
      strcpy(lakka->icon_dir, "192");
   }
   else if (gl->win_width >= 1920)
   {
      lakka->icon_size = 128;
      lakka->hspacing = 200.0;
      lakka->vspacing = 64.0;
      lakka->margin_left = 336.0;
      lakka->margin_top = 256;
      lakka->title_margin_left = 15.0;
      lakka->title_margin_top = 35.0;
      lakka->label_margin_left = 85;
      lakka->label_margin_top = 8.0;
      lakka->setting_margin_left = 600;
      strcpy(lakka->icon_dir, "128");
   }
   else if (gl->win_width <= 640)
   {
      lakka->icon_size = 64;
      lakka->hspacing = 100.0;
      lakka->vspacing = 32.0;
      lakka->margin_left = 60.0;
      lakka->margin_top = 128.0;
      lakka->title_margin_left = 10.0;
      lakka->title_margin_top = 24.0;
      lakka->label_margin_left = 48;
      lakka->label_margin_top = 6.0;
      lakka->setting_margin_left = 250;
      strcpy(lakka->icon_dir, "64");
   }
   else
   {
      lakka->icon_size = 96;
      lakka->hspacing = 150.0;
      lakka->vspacing = 48.0;
      lakka->margin_left = 224;
      lakka->margin_top = 192;
      lakka->title_margin_left = 15.0;
      lakka->title_margin_top = 30.0;
      lakka->label_margin_left = 64;
      lakka->label_margin_top = 6.0;
      lakka->setting_margin_left = 400;
      strcpy(lakka->icon_dir, "96");
   }

   lakka->depth                = 0;
   lakka->menu_active_category = 0;
   lakka->all_categories_x     = 0;
   lakka->global_alpha         = 0.0f;
   lakka->global_scale         = 2.0f;
   lakka->arrow_alpha          = 0;

   lakka->fbo_depth            = 0;

   return menu;
}
Ejemplo n.º 5
0
static void glui_frame(void)
{
   unsigned x, y;
   size_t i;
   char title[PATH_MAX], title_buf[PATH_MAX], 
        title_msg[PATH_MAX];
   const char *dir = NULL;
   const char *label = NULL;
   unsigned menu_type = 0;
   size_t end;
   gl_t *gl = (gl_t*)driver_video_resolve(NULL);
   glui_handle_t *glui = NULL;

   if (!driver.menu || !gl)
      return;

   glui = (glui_handle_t*)driver.menu->userdata;

   if (!glui)
      return;

   if (driver.menu->need_refresh
         && g_extern.is_menu
         && !driver.menu->msg_force)
      return;

   glui->line_height = g_settings.video.font_size * 4 / 3;
   glui->glyph_width = glui->line_height / 2;
   glui->margin = gl->win_width / 20 ;
   glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width;
   glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2;

   driver.menu->mouse.ptr = (driver.menu->mouse.y - glui->margin) /
         glui->line_height - 2 + driver.menu->begin;

   glViewport(0, 0, gl->win_width, gl->win_height);

   if (driver.menu->mouse.wheeldown && driver.menu->begin
         < menu_list_get_size(driver.menu->menu_list) - glui->term_height)
      driver.menu->begin++;

   if (driver.menu->mouse.wheelup && driver.menu->begin > 0)
      driver.menu->begin--;

   /* Do not scroll if all items are visible. */
   if (menu_list_get_size(driver.menu->menu_list) <= glui->term_height)
      driver.menu->begin = 0;

   end = (driver.menu->begin + glui->term_height <=
         menu_list_get_size(driver.menu->menu_list)) ?
      driver.menu->begin + glui->term_height :
      menu_list_get_size(driver.menu->menu_list);

   glui_render_background(false);

   menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type);

   get_title(label, dir, menu_type, title, sizeof(title));

   menu_ticker_line(title_buf, glui->term_width - 3,
         g_extern.frame_count / glui->margin, title, true);
   glui_blit_line(glui->margin * 2, glui->margin + glui->line_height,
         title_buf, true);

   const char *core_name = g_extern.menu.info.library_name;
   if (!core_name)
      core_name = g_extern.system.info.library_name;
   if (!core_name)
      core_name = "No Core";

   const char *core_version = g_extern.menu.info.library_version;
   if (!core_version)
      core_version = g_extern.system.info.library_version;
   if (!core_version)
      core_version = "";

   snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
         core_name, core_version);
   glui_blit_line(
         glui->margin * 2,
         glui->margin + glui->term_height * glui->line_height 
         + glui->line_height * 2, title_msg, true);


   x = glui->margin;
   y = glui->margin + glui->line_height * 2;

   for (i = driver.menu->begin; i < end; i++, y += glui->line_height)
   {
      char message[PATH_MAX], type_str[PATH_MAX],
           entry_title_buf[PATH_MAX], type_str_buf[PATH_MAX],
           path_buf[PATH_MAX];
      const char *path = NULL, *entry_label = NULL;
      unsigned type = 0, w = 0;
      bool selected = false;

      menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
            &entry_label, &type);
      rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
            driver.menu->list_settings,
            driver.menu->menu_list->selection_buf->list[i].label);
      (void)setting;

      disp_set_label(driver.menu->menu_list->selection_buf, &w, type, i, label,
            type_str, sizeof(type_str), 
            entry_label, path,
            path_buf, sizeof(path_buf));

      selected = (i == driver.menu->selection_ptr);

      menu_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
            g_extern.frame_count / glui->margin, path_buf, selected);
      menu_ticker_line(type_str_buf, w, 
            g_extern.frame_count / glui->margin, type_str, selected);

      strlcpy(message, entry_title_buf, sizeof(message));

      glui_blit_line(x, y, message, selected);

      glui_blit_line(gl->win_width - glui->glyph_width * w - glui->margin , 
         y, type_str_buf, selected);
   }

#ifdef GEKKO
   const char *message_queue;

   if (driver.menu->msg_force)
   {
      message_queue = msg_queue_pull(g_extern.msg_queue);
      driver.menu->msg_force = false;
   }
   else
      message_queue = driver.current_msg;

   glui_render_messagebox(message_queue);
#endif

   if (driver.menu->keyboard.display)
   {
      char msg[PATH_MAX];
      const char *str = *driver.menu->keyboard.buffer;
      if (!str)
         str = "";
      glui_render_background(true);
      snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
      glui_render_messagebox(msg);
   }

   if (glui->box_message[0] != '\0')
   {
      glui_render_background(true);
      glui_render_messagebox(glui->box_message);
      glui->box_message[0] = '\0';
   }

   if (driver.menu->mouse.enable)
      glui_draw_cursor(driver.menu->mouse.x, driver.menu->mouse.y);

   gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
}