Split up file_list into separate compilable file
This commit is contained in:
parent
b5b480ec15
commit
af10f3f5bc
2
Makefile
2
Makefile
|
@ -90,7 +90,7 @@ ifneq ($(findstring Linux,$(OS)),)
|
|||
endif
|
||||
|
||||
ifeq ($(HAVE_RGUI), 1)
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/file_list.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_THREADS), 1)
|
||||
|
|
|
@ -66,7 +66,7 @@ endif
|
|||
|
||||
ifeq ($(HAVE_RGUI), 1)
|
||||
DEFINES += -DHAVE_RGUI
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/file_list.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SDL), 1)
|
||||
|
|
|
@ -102,7 +102,7 @@ JLIBS =
|
|||
|
||||
ifeq ($(HAVE_RGUI), 1)
|
||||
DEFINES += -DHAVE_RGUI
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
OBJ += frontend/menu/menu_common.o frontend/menu/menu_settings.o frontend/menu/menu_context.o frontend/menu/file_list.o frontend/menu/rgui.o frontend/menu/history.o
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_SDL), 1)
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* 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-
|
||||
* 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;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* 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.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "file_browser.h"
|
||||
|
||||
static bool directory_parse(void *data, const char *path)
|
||||
{
|
||||
filebrowser_t *filebrowser = (filebrowser_t*)data;
|
||||
|
@ -23,7 +41,7 @@ static bool directory_parse(void *data, const char *path)
|
|||
|
||||
}
|
||||
|
||||
static void filebrowser_free(void *data)
|
||||
void filebrowser_free(void *data)
|
||||
{
|
||||
filebrowser_t *filebrowser = (filebrowser_t*)data;
|
||||
|
||||
|
|
|
@ -54,5 +54,6 @@ typedef enum
|
|||
void filebrowser_update(void *data, uint64_t input, const char *extensions);
|
||||
void filebrowser_set_root_and_ext(void *data, const char *ext, const char *root_dir);
|
||||
bool filebrowser_iterate(void *data, unsigned action);
|
||||
void filebrowser_free(void *data);
|
||||
|
||||
#endif /* FILEBROWSER_H_ */
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* 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-
|
||||
* 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;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* 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.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "file_list.h"
|
||||
|
||||
struct rgui_file
|
||||
{
|
||||
char *path;
|
||||
char *alt;
|
||||
unsigned type;
|
||||
size_t directory_ptr;
|
||||
};
|
||||
|
||||
void rgui_list_push(void *userdata,
|
||||
const char *path, unsigned type, size_t directory_ptr)
|
||||
{
|
||||
rgui_list_t *list = (rgui_list_t*)userdata;
|
||||
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
if (list->size >= list->capacity)
|
||||
{
|
||||
list->capacity++;
|
||||
list->capacity *= 2;
|
||||
list->list = (struct rgui_file*)realloc(list->list, list->capacity * sizeof(struct rgui_file));
|
||||
}
|
||||
|
||||
list->list[list->size].path = strdup(path);
|
||||
list->list[list->size].alt = NULL;
|
||||
list->list[list->size].type = type;
|
||||
list->list[list->size].directory_ptr = directory_ptr;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
void rgui_list_pop(rgui_list_t *list, size_t *directory_ptr)
|
||||
{
|
||||
if (!(list->size == 0))
|
||||
free(list->list[--list->size].path);
|
||||
|
||||
if (directory_ptr)
|
||||
*directory_ptr = list->list[list->size].directory_ptr;
|
||||
}
|
||||
|
||||
void rgui_list_free(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
free(list->list[i].path);
|
||||
free(list->list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void rgui_list_clear(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
{
|
||||
free(list->list[i].path);
|
||||
free(list->list[i].alt);
|
||||
}
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
void rgui_list_set_alt_at_offset(rgui_list_t *list, size_t index,
|
||||
const char *alt)
|
||||
{
|
||||
free(list->list[index].alt);
|
||||
list->list[index].alt = strdup(alt);
|
||||
}
|
||||
|
||||
void rgui_list_get_alt_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **alt)
|
||||
{
|
||||
if (alt)
|
||||
*alt = list->list[index].alt ? list->list[index].alt : list->list[index].path;
|
||||
}
|
||||
|
||||
static int rgui_list_alt_cmp(const void *a_, const void *b_)
|
||||
{
|
||||
const struct rgui_file *a = (const struct rgui_file*)a_;
|
||||
const struct rgui_file *b = (const struct rgui_file*)b_;
|
||||
const char *cmp_a = a->alt ? a->alt : a->path;
|
||||
const char *cmp_b = b->alt ? b->alt : b->path;
|
||||
return strcasecmp(cmp_a, cmp_b);
|
||||
}
|
||||
|
||||
void rgui_list_sort_on_alt(rgui_list_t *list)
|
||||
{
|
||||
qsort(list->list, list->size, sizeof(list->list[0]), rgui_list_alt_cmp);
|
||||
}
|
||||
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **path, unsigned *file_type)
|
||||
{
|
||||
if (path)
|
||||
*path = list->list[index].path;
|
||||
if (file_type)
|
||||
*file_type = list->list[index].type;
|
||||
}
|
||||
|
||||
void rgui_list_get_last(const rgui_list_t *list,
|
||||
const char **path, unsigned *file_type)
|
||||
{
|
||||
if (list->size)
|
||||
rgui_list_get_at_offset(list, list->size - 1, path, file_type);
|
||||
}
|
|
@ -182,111 +182,6 @@ void shader_manager_get_str(struct gfx_shader *shader,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FILEBROWSER
|
||||
#include "file_browser.c"
|
||||
#endif
|
||||
|
||||
struct rgui_file
|
||||
{
|
||||
char *path;
|
||||
char *alt;
|
||||
unsigned type;
|
||||
size_t directory_ptr;
|
||||
};
|
||||
|
||||
void rgui_list_push(void *userdata,
|
||||
const char *path, unsigned type, size_t directory_ptr)
|
||||
{
|
||||
rgui_list_t *list = (rgui_list_t*)userdata;
|
||||
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
if (list->size >= list->capacity)
|
||||
{
|
||||
list->capacity++;
|
||||
list->capacity *= 2;
|
||||
list->list = (struct rgui_file*)realloc(list->list, list->capacity * sizeof(struct rgui_file));
|
||||
}
|
||||
|
||||
list->list[list->size].path = strdup(path);
|
||||
list->list[list->size].alt = NULL;
|
||||
list->list[list->size].type = type;
|
||||
list->list[list->size].directory_ptr = directory_ptr;
|
||||
list->size++;
|
||||
}
|
||||
|
||||
void rgui_list_pop(rgui_list_t *list, size_t *directory_ptr)
|
||||
{
|
||||
if (!(list->size == 0))
|
||||
free(list->list[--list->size].path);
|
||||
|
||||
if (directory_ptr)
|
||||
*directory_ptr = list->list[list->size].directory_ptr;
|
||||
}
|
||||
|
||||
void rgui_list_free(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
free(list->list[i].path);
|
||||
free(list->list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void rgui_list_clear(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
{
|
||||
free(list->list[i].path);
|
||||
free(list->list[i].alt);
|
||||
}
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
void rgui_list_set_alt_at_offset(rgui_list_t *list, size_t index,
|
||||
const char *alt)
|
||||
{
|
||||
free(list->list[index].alt);
|
||||
list->list[index].alt = strdup(alt);
|
||||
}
|
||||
|
||||
void rgui_list_get_alt_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **alt)
|
||||
{
|
||||
if (alt)
|
||||
*alt = list->list[index].alt ? list->list[index].alt : list->list[index].path;
|
||||
}
|
||||
|
||||
static int rgui_list_alt_cmp(const void *a_, const void *b_)
|
||||
{
|
||||
const struct rgui_file *a = (const struct rgui_file*)a_;
|
||||
const struct rgui_file *b = (const struct rgui_file*)b_;
|
||||
const char *cmp_a = a->alt ? a->alt : a->path;
|
||||
const char *cmp_b = b->alt ? b->alt : b->path;
|
||||
return strcasecmp(cmp_a, cmp_b);
|
||||
}
|
||||
|
||||
void rgui_list_sort_on_alt(rgui_list_t *list)
|
||||
{
|
||||
qsort(list->list, list->size, sizeof(list->list[0]), rgui_list_alt_cmp);
|
||||
}
|
||||
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **path, unsigned *file_type)
|
||||
{
|
||||
if (path)
|
||||
*path = list->list[index].path;
|
||||
if (file_type)
|
||||
*file_type = list->list[index].type;
|
||||
}
|
||||
|
||||
void rgui_list_get_last(const rgui_list_t *list,
|
||||
const char **path, unsigned *file_type)
|
||||
{
|
||||
if (list->size)
|
||||
rgui_list_get_at_offset(list, list->size - 1, path, file_type);
|
||||
}
|
||||
|
||||
void menu_rom_history_push(const char *path,
|
||||
const char *core_path,
|
||||
const char *core_name)
|
||||
|
@ -990,4 +885,3 @@ void menu_resolve_supported_cores(rgui_handle_t *rgui)
|
|||
|
||||
rgui_list_sort_on_alt(rgui->selection_buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -530,6 +530,11 @@ MENU
|
|||
#include "../frontend/menu/menu_settings.c"
|
||||
#include "../frontend/menu/history.c"
|
||||
|
||||
#ifdef HAVE_FILEBROWSER
|
||||
#include "../frontend/menu/file_browser.c"
|
||||
#endif
|
||||
#include "../frontend/menu/file_list.c"
|
||||
|
||||
#if defined(HAVE_RMENU_GUI)
|
||||
#include "../frontend/menu/rmenu.c"
|
||||
#elif defined(HAVE_RGUI)
|
||||
|
|
|
@ -188,6 +188,7 @@
|
|||
<ClCompile Include="..\..\deps\miniz\miniz.c" />
|
||||
<ClCompile Include="..\..\file_extract.c" />
|
||||
<ClCompile Include="..\..\frontend\menu\history.c" />
|
||||
<ClCompile Include="..\..\frontend\menu\file_list.c" />
|
||||
<ClCompile Include="..\..\frontend\menu\rgui.c" />
|
||||
<ClCompile Include="..\..\frontend\menu\menu_common.c" />
|
||||
<ClCompile Include="..\..\frontend\menu\menu_settings.c" />
|
||||
|
|
Loading…
Reference in New Issue