示例#1
0
void nk_wnd_settings(nk_menu_handle_t *nk)
{
   unsigned i;
   video_shader_ctx_t shader_info;
   struct nk_panel layout;
   struct nk_context *ctx = &nk->ctx;
   const int id           = NK_WND_SETTINGS;

   if (nk_begin(ctx, &layout, "Settings", nk_rect(240, 10, 300, 400),
         NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
         NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
   {
      nk_layout_row_dynamic(ctx, 30, 1);
   }

   /* save position and size to restore after context reset */
   nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
   nk_end(ctx);
}
示例#2
0
bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out, char* filter)
{
   struct nk_panel layout;
   struct nk_context                 *ctx = &nk->ctx;
   const int id                      = NK_WND_FILE_PICKER;
   int i                             = 0;
   static file_list_t *drives        = NULL;
   static struct string_list *files  = NULL;
   settings_t *settings              = config_get_ptr();
   bool ret                          = false;

   if (!drives)
   {
      drives = (file_list_t*)calloc(1, sizeof(file_list_t));
      frontend_driver_parse_drive_list(drives, false);
   }

   if (!string_is_empty(in) && string_is_empty(path))
   {
      strlcpy(path, in, sizeof(path));
      files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
   }

   if (!assets_loaded)
      load_icons(nk);

   if (nk_begin(ctx, title, nk_rect(10, 10, 500, 400),
         NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
         NK_WINDOW_BORDER))
   {
      nk_layout_row_dynamic(ctx, 30, 4);

      if (drives->size == 0)
      {
         if(nk_button_image_label(ctx, icons.disk, "/", 
            NK_TEXT_CENTERED))
         {
            fill_pathname_join(path, "/",
                  "", sizeof(path));
            files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
         }
      }
      else
      {
         for (i = 0; i < drives->size; i++)
         {
            if(nk_button_image_label(ctx, icons.disk, drives->list[i].path, 
               NK_TEXT_CENTERED))
            {
               fill_pathname_join(path, drives->list[i].path,
                     "", sizeof(path));
               files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
            }
         }
      }

      nk_layout_row_dynamic(ctx, 30, 1);
      if (files)
      {
         for (i = 0; i < files->size; i++)
         {
            if (nk_button_image_label(ctx, path_is_directory(files->elems[i].data) ? 
               icons.folder : icons.file, path_basename(files->elems[i].data), 
               NK_TEXT_RIGHT))
            {
               strlcpy (path, files->elems[i].data, sizeof(path));
               if (path_is_directory (path))
                  files = dir_list_new(path, filter, true, settings->bools.show_hidden_files, true, false);
            }
         }
      }
      nk_layout_row_dynamic(ctx, 30, 1);
      {
         if (nk_button_text(ctx, "OK", 2))
         {
            ret = true;
            strlcpy(out, path, sizeof(path));
            nk->window[NK_WND_FILE_PICKER].open = false;
            path[0] = '\0';
         }
      }
   }

   /* sort the dir list with directories first */
   dir_list_sort(files, true);

   /* copy the path variable to out*/

   /* save position and size to restore after context reset */
   nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
   nk_end(ctx);

   return ret;
}
示例#3
0
void nk_wnd_main(nk_menu_handle_t *nk, const char* title)
{
   unsigned i;
   video_shader_ctx_t shader_info;
   struct nk_panel layout;
   struct nk_context *ctx = &nk->ctx;
   const int id           = NK_WND_MAIN;
   settings_t *settings  = config_get_ptr();
   char core_basename[PATH_MAX_LENGTH] = {0};

   static char picker_filter[PATH_MAX_LENGTH];
   static char picker_title[PATH_MAX_LENGTH];
   static char* picker_startup_dir;

   int len_core, len_content = 0;

   strlcpy(core_basename, path_basename(core), sizeof(core_basename));

   if (!out)
      out = core;

   if (!string_is_empty(core))
      len_core = strlen(path_basename(core));
   if (!string_is_empty(content))
      len_content = strlen(content);

   if (nk->window[NK_WND_FILE_PICKER].open)
   {
      if (nk_wnd_file_picker(nk, picker_title, picker_startup_dir, out, picker_filter))
      {
         RARCH_LOG ("%s selected\n", out);
         nk_window_close(&nk->ctx, picker_title);
      }
   }


   if (nk_begin(ctx, &layout, title, nk_rect(240, 10, 600, 400),
         NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
         NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
   {
      nk_layout_row_dynamic(ctx, 30, 1);
      nk_label(ctx,"Core:", NK_TEXT_LEFT);
      nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
      nk_edit_string(ctx, NK_EDIT_SIMPLE, core_basename, &len_core, 64, nk_filter_default);
      if (nk_button_text(ctx, "...", 3, NK_BUTTON_DEFAULT))
      {
         out = core;
         strlcpy(picker_title, "Select core", sizeof(picker_title));
         strlcpy(picker_filter, ".dll", sizeof(picker_filter));
         picker_startup_dir = settings->directory.libretro;
         nk->window[NK_WND_FILE_PICKER].open = true;
      }
      nk_layout_row_dynamic(ctx, 30, 1);
      nk_label(ctx,"Content:", NK_TEXT_LEFT);
      nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
      nk_edit_string(ctx, NK_EDIT_SIMPLE, content, &len_content, 64, nk_filter_default);
      if (nk_button_text(ctx, "...", 3, NK_BUTTON_DEFAULT))
      {
         out = content;
         strlcpy(picker_title, "Select content", sizeof(picker_title));
         strlcpy(picker_filter, ".zip", sizeof(picker_filter));
         picker_startup_dir = settings->directory.menu_content;
         nk->window[NK_WND_FILE_PICKER].open = true;
      }
   }

   /* save position and size to restore after context reset */
   nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
   nk_end(ctx);
}