mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
commit
3e3ceba9aa
@ -50,12 +50,23 @@
|
|||||||
|
|
||||||
static void nk_menu_main(nk_menu_handle_t *nk)
|
static void nk_menu_main(nk_menu_handle_t *nk)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
struct nk_context *ctx = &nk->ctx;
|
struct nk_context *ctx = &nk->ctx;
|
||||||
|
|
||||||
|
static char out[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
if (nk->window[NK_WND_SETTINGS].open)
|
if (nk->window[NK_WND_SETTINGS].open)
|
||||||
nk_wnd_settings(nk);
|
nk_wnd_settings(nk);
|
||||||
if (nk->window[NK_WND_FILE_PICKER].open)
|
if (nk->window[NK_WND_FILE_PICKER].open)
|
||||||
nk_wnd_file_picker(nk);
|
{
|
||||||
|
if (nk_wnd_file_picker(nk, settings->directory.menu_content, out, ".zip"))
|
||||||
|
{
|
||||||
|
RARCH_LOG ("%s selected\n", out);
|
||||||
|
nk_window_close(&nk->ctx, "Select File");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
if (nk->window[NK_WND_SHADER_PARAMETERS].open)
|
if (nk->window[NK_WND_SHADER_PARAMETERS].open)
|
||||||
nk_wnd_shader_parameters(nk);
|
nk_wnd_shader_parameters(nk);
|
||||||
if (nk->window[NK_WND_MAIN].open)
|
if (nk->window[NK_WND_MAIN].open)
|
||||||
@ -295,11 +306,12 @@ static void *nk_menu_init(void **userdata)
|
|||||||
nk_menu_init_device(nk);
|
nk_menu_init_device(nk);
|
||||||
|
|
||||||
/* for demo puposes only, opens all windows */
|
/* for demo puposes only, opens all windows */
|
||||||
#if 1
|
#if 0
|
||||||
for (int i=0; i < NK_WND_LAST; i++)
|
for (int i=0; i < NK_WND_LAST; i++)
|
||||||
nk->window[i].open = true;
|
nk->window[i].open = true;
|
||||||
#else
|
#else
|
||||||
nk->window[NK_WND_MAIN].open = true;
|
nk->window[NK_WND_MAIN].open = true;
|
||||||
|
nk->window[NK_WND_FILE_PICKER].open = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
|
@ -1,105 +1,105 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* RetroArch - A frontend for libretro.
|
||||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||||
* Copyright (C) 2014-2015 - Jean-André Santoni
|
* Copyright (C) 2014-2015 - Jean-André Santoni
|
||||||
* Copyright (C) 2016 - Andrés Suárez
|
* Copyright (C) 2016 - Andrés Suárez
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This file is intended for helper functions, custom controls, etc. */
|
/* This file is intended for helper functions, custom controls, etc. */
|
||||||
|
|
||||||
#ifndef _NK_MENU_H
|
#ifndef _NK_MENU_H
|
||||||
#define _NK_MENU_H
|
#define _NK_MENU_H
|
||||||
|
|
||||||
#include "nk_common.h"
|
#include "nk_common.h"
|
||||||
#include "../../menu_display.h"
|
#include "../../menu_display.h"
|
||||||
#include "../../menu_input.h"
|
#include "../../menu_input.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NK_TEXTURE_POINTER = 0,
|
NK_TEXTURE_POINTER = 0,
|
||||||
NK_TEXTURE_LAST
|
NK_TEXTURE_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NK_WND_MAIN = 0,
|
NK_WND_MAIN = 0,
|
||||||
NK_WND_SETTINGS,
|
NK_WND_SETTINGS,
|
||||||
NK_WND_FILE_PICKER,
|
NK_WND_FILE_PICKER,
|
||||||
NK_WND_SHADER_PARAMETERS,
|
NK_WND_SHADER_PARAMETERS,
|
||||||
NK_WND_LAST
|
NK_WND_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nk_menu_theme
|
enum nk_menu_theme
|
||||||
{
|
{
|
||||||
THEME_DARK = 0,
|
THEME_DARK = 0,
|
||||||
THEME_LIGHT
|
THEME_LIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
struct icons {
|
struct icons {
|
||||||
struct nk_image folder;
|
struct nk_image folder;
|
||||||
struct nk_image monitor;
|
struct nk_image monitor;
|
||||||
struct nk_image gamepad;
|
struct nk_image gamepad;
|
||||||
struct nk_image settings;
|
struct nk_image settings;
|
||||||
struct nk_image speaker;
|
struct nk_image speaker;
|
||||||
struct nk_image invader;
|
struct nk_image invader;
|
||||||
struct nk_image page_on;
|
struct nk_image page_on;
|
||||||
struct nk_image page_off;
|
struct nk_image page_off;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct window {
|
struct window {
|
||||||
bool open;
|
bool open;
|
||||||
struct nk_vec2 position;
|
struct nk_vec2 position;
|
||||||
struct nk_vec2 size;
|
struct nk_vec2 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct nk_menu_handle
|
typedef struct nk_menu_handle
|
||||||
{
|
{
|
||||||
/* nuklear mandatory */
|
/* nuklear mandatory */
|
||||||
void *memory;
|
void *memory;
|
||||||
struct nk_context ctx;
|
struct nk_context ctx;
|
||||||
struct nk_memory_status status;
|
struct nk_memory_status status;
|
||||||
enum menu_action action;
|
enum menu_action action;
|
||||||
|
|
||||||
/* window control variables */
|
/* window control variables */
|
||||||
struct nk_vec2 size;
|
struct nk_vec2 size;
|
||||||
bool size_changed;
|
bool size_changed;
|
||||||
struct window window[5];
|
struct window window[5];
|
||||||
|
|
||||||
/* menu driver variables */
|
/* menu driver variables */
|
||||||
char box_message[PATH_MAX_LENGTH];
|
char box_message[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
/* image & theme related variables */
|
/* image & theme related variables */
|
||||||
char assets_directory[PATH_MAX_LENGTH];
|
char assets_directory[PATH_MAX_LENGTH];
|
||||||
struct icons icons;
|
struct icons icons;
|
||||||
enum nk_menu_theme theme;
|
enum nk_menu_theme theme;
|
||||||
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
menu_texture_item bg;
|
menu_texture_item bg;
|
||||||
menu_texture_item list[NK_TEXTURE_LAST];
|
menu_texture_item list[NK_TEXTURE_LAST];
|
||||||
} textures;
|
} textures;
|
||||||
|
|
||||||
video_font_raster_block_t list_block;
|
video_font_raster_block_t list_block;
|
||||||
} nk_menu_handle_t;
|
} nk_menu_handle_t;
|
||||||
|
|
||||||
void nk_wnd_shader_parameters(nk_menu_handle_t *zr);
|
void nk_wnd_shader_parameters(nk_menu_handle_t *zr);
|
||||||
void nk_wnd_main(nk_menu_handle_t *zr);
|
void nk_wnd_main(nk_menu_handle_t *zr);
|
||||||
void nk_wnd_file_picker(nk_menu_handle_t *zr);
|
bool nk_wnd_file_picker(nk_menu_handle_t *nk, const char* in, char* out, const char* filter);
|
||||||
void nk_wnd_settings(nk_menu_handle_t *zr);
|
void nk_wnd_settings(nk_menu_handle_t *zr);
|
||||||
void nk_wnd_set_state(nk_menu_handle_t *zr, const int id,
|
void nk_wnd_set_state(nk_menu_handle_t *zr, const int id,
|
||||||
struct nk_vec2 pos, struct nk_vec2 size);
|
struct nk_vec2 pos, struct nk_vec2 size);
|
||||||
void nk_wnd_get_state(nk_menu_handle_t *zr, const int id,
|
void nk_wnd_get_state(nk_menu_handle_t *zr, const int id,
|
||||||
struct nk_vec2 *pos, struct nk_vec2 *size);
|
struct nk_vec2 *pos, struct nk_vec2 *size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,15 +61,16 @@ void load_icons(nk_menu_handle_t *nk)
|
|||||||
assets_loaded = true;
|
assets_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nk_wnd_file_picker(nk_menu_handle_t *nk)
|
bool nk_wnd_file_picker(nk_menu_handle_t *nk, const char* in, char* out, const char* filter)
|
||||||
{
|
{
|
||||||
struct nk_panel layout;
|
struct nk_panel layout;
|
||||||
struct nk_context *ctx = &nk->ctx;
|
struct nk_context *ctx = &nk->ctx;
|
||||||
const int id = NK_WND_FILE_PICKER;
|
const int id = NK_WND_FILE_PICKER;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
static file_list_t *drives = NULL;
|
static file_list_t *drives = NULL;
|
||||||
static struct string_list *files = NULL;
|
static struct string_list *files = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
if (!drives)
|
if (!drives)
|
||||||
{
|
{
|
||||||
@ -77,14 +78,21 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
|
|||||||
frontend_driver_parse_drive_list(drives);
|
frontend_driver_parse_drive_list(drives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string_is_empty(in) && string_is_empty(path))
|
||||||
|
{
|
||||||
|
RARCH_LOG("beep\n");
|
||||||
|
strlcpy(path, in, sizeof(path));
|
||||||
|
files = dir_list_new(path, filter, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!assets_loaded)
|
if (!assets_loaded)
|
||||||
load_icons(nk);
|
load_icons(nk);
|
||||||
|
|
||||||
if (nk_begin(ctx, &layout, "Select File", nk_rect(440, 10, 330, 400),
|
if (nk_begin(ctx, &layout, "Select File", nk_rect(10, 10, 500, 400),
|
||||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||||
NK_WINDOW_BORDER))
|
NK_WINDOW_BORDER))
|
||||||
{
|
{
|
||||||
nk_layout_row_dynamic(ctx, 30, 3);
|
nk_layout_row_dynamic(ctx, 30, 4);
|
||||||
|
|
||||||
if (drives->size == 0)
|
if (drives->size == 0)
|
||||||
{
|
{
|
||||||
@ -93,7 +101,7 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
|
|||||||
{
|
{
|
||||||
fill_pathname_join(path, "/",
|
fill_pathname_join(path, "/",
|
||||||
"", sizeof(path));
|
"", sizeof(path));
|
||||||
files = dir_list_new(path, NULL, true, true);
|
files = dir_list_new(path, filter, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -105,7 +113,7 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
|
|||||||
{
|
{
|
||||||
fill_pathname_join(path, drives->list[i].path,
|
fill_pathname_join(path, drives->list[i].path,
|
||||||
"", sizeof(path));
|
"", sizeof(path));
|
||||||
files = dir_list_new(path, NULL, true, true);
|
files = dir_list_new(path, filter, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,14 +129,26 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
|
|||||||
{
|
{
|
||||||
strlcpy (path, files->elems[i].data, sizeof(path));
|
strlcpy (path, files->elems[i].data, sizeof(path));
|
||||||
if (path_is_directory (path))
|
if (path_is_directory (path))
|
||||||
files = dir_list_new(path, NULL, true, true);
|
files = dir_list_new(path, filter, true, true);
|
||||||
else
|
|
||||||
RARCH_LOG ("File: %s selected\n", path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nk_layout_row_dynamic(ctx, 30, 1);
|
||||||
|
{
|
||||||
|
if (nk_button_text(ctx, "OK", 2, NK_BUTTON_DEFAULT))
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sort the dir list with directories first */
|
||||||
|
dir_list_sort(files, true);
|
||||||
|
|
||||||
|
/* copy the path variable to out*/
|
||||||
|
strlcpy(out, path, sizeof(path));
|
||||||
|
|
||||||
/* save position and size to restore after context reset */
|
/* 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_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
|
||||||
nk_end(ctx);
|
nk_end(ctx);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user