(Nuklear) Cleanups

This commit is contained in:
twinaphex 2016-05-26 06:31:58 +02:00
parent da5fb291a6
commit 7780162d53
2 changed files with 105 additions and 100 deletions

View File

@ -46,7 +46,9 @@ struct nk_image nk_common_image_load(const char *filename)
int x,y,n; int x,y,n;
GLuint tex; GLuint tex;
unsigned char *data = stbi_load(filename, &x, &y, &n, 0); unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
if (!data) printf("Failed to load image: %s\n", filename);
if (!data)
printf("Failed to load image: %s\n", filename);
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
glGenTextures(1, &tex); glGenTextures(1, &tex);

View File

@ -15,8 +15,6 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "nk_menu.h"
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
@ -26,6 +24,9 @@
#include <string/stdstring.h> #include <string/stdstring.h>
#include <lists/string_list.h> #include <lists/string_list.h>
#include <lists/dir_list.h> #include <lists/dir_list.h>
#include <retro_stat.h>
#include "nk_menu.h"
#include "../../menu_driver.h" #include "../../menu_driver.h"
#include "../../menu_hash.h" #include "../../menu_hash.h"
@ -34,16 +35,19 @@
static bool assets_loaded; static bool assets_loaded;
static char path[PATH_MAX_LENGTH]; static char path[PATH_MAX_LENGTH];
struct icon_list { struct icon_list
{
struct nk_image disk; struct nk_image disk;
struct nk_image folder; struct nk_image folder;
struct nk_image file; struct nk_image file;
}; };
struct icon_list icons; struct icon_list icons;
void load_icons(nk_menu_handle_t *nk) void load_icons(nk_menu_handle_t *nk)
{ {
char buf[PATH_MAX_LENGTH]; char buf[PATH_MAX_LENGTH] = {0};
fill_pathname_join(buf, nk->assets_directory, fill_pathname_join(buf, nk->assets_directory,
"harddisk.png", sizeof(buf)); "harddisk.png", sizeof(buf));
icons.disk = nk_common_image_load(buf); icons.disk = nk_common_image_load(buf);
@ -62,12 +66,10 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
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;
settings_t *settings = config_get_ptr();
int i = 0; int i = 0;
static file_list_t *drives = NULL;
static file_list_t *drives; static struct string_list *files = NULL;
static struct string_list *files; settings_t *settings = config_get_ptr();
if (!drives) if (!drives)
{ {
@ -83,6 +85,7 @@ void nk_wnd_file_picker(nk_menu_handle_t *nk)
NK_WINDOW_BORDER)) NK_WINDOW_BORDER))
{ {
nk_layout_row_dynamic(ctx, 30, 3); nk_layout_row_dynamic(ctx, 30, 3);
if (drives->size == 0) if (drives->size == 0)
{ {
if(nk_button_image_label(ctx, icons.disk, "/", if(nk_button_image_label(ctx, icons.disk, "/",