first idf release
This commit is contained in:
parent
284c32e79f
commit
def0a70d1c
|
@ -1418,10 +1418,13 @@ fnt_t fnt_load(const char *fname, int size)
|
|||
if (!n)
|
||||
goto err;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!is_empty(files[i]))
|
||||
fn = TTF_OpenFont(dirpath(files[i]), size);
|
||||
else
|
||||
fn = NULL;
|
||||
fn = NULL;
|
||||
if (!is_empty(files[i])) {
|
||||
SDL_RWops *rw = RWFromIdf(game_idf, files[i]);
|
||||
if (!rw || !(fn = TTF_OpenFontRW(rw, 1, size))) {
|
||||
fprintf(stderr, "Can not load font: '%s'\n", files[i]);
|
||||
}
|
||||
}
|
||||
if (!fn && i == 0) /* no regular */
|
||||
goto err;
|
||||
#ifdef TTF_HINTING_LIGHT
|
||||
|
|
|
@ -146,7 +146,7 @@ err:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int idf_tree(const char *path, struct list_head *list)
|
||||
static int idf_tree(const char *path, struct list_head *list, const char *fname)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
|
@ -154,14 +154,14 @@ static int idf_tree(const char *path, struct list_head *list)
|
|||
return 0;
|
||||
d = opendir(dirpath(path));
|
||||
if (!d) {
|
||||
if (!access(dirpath(path), R_OK)) {
|
||||
if (!access(dirpath(path), R_OK) && fname) {
|
||||
FILE *fd; idf_item_t *i;
|
||||
fd = fopen(dirpath(path), "rb");
|
||||
i = malloc(sizeof(idf_item_t));
|
||||
if (!i)
|
||||
return -1;
|
||||
INIT_LIST_HEAD(&i->list);
|
||||
if (!(i->path = strdup(path)))
|
||||
if (!(i->path = strdup(fname)))
|
||||
goto err;
|
||||
if (fseek(fd, 0, SEEK_END) < 0)
|
||||
goto err;
|
||||
|
@ -185,7 +185,11 @@ static int idf_tree(const char *path, struct list_head *list)
|
|||
continue;
|
||||
p = getfilepath(path, de->d_name);
|
||||
if (p) {
|
||||
idf_tree(p, list);
|
||||
char *pp = getfilepath(fname, de->d_name);
|
||||
if (pp) {
|
||||
idf_tree(p, list, pp);
|
||||
free(pp);
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +206,7 @@ int idf_create(const char *file, const char *path)
|
|||
struct list_head *pos;
|
||||
|
||||
LIST_HEAD(items);
|
||||
idf_tree(path, &items);
|
||||
idf_tree(path, &items, NULL);
|
||||
|
||||
list_for_each(pos, &items) {
|
||||
idf_item_t *it = (idf_item_t *)pos;
|
||||
|
@ -231,8 +235,14 @@ int idf_create(const char *file, const char *path)
|
|||
|
||||
list_for_each(pos, &items) {
|
||||
idf_item_t *it = (idf_item_t *)pos;
|
||||
if (fcopy(fd, it->path))
|
||||
goto err;
|
||||
char *p;
|
||||
p = getfilepath(path, it->path);
|
||||
if (p) {
|
||||
int rc = fcopy(fd, p);
|
||||
free(p);
|
||||
if (rc)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
rc = 0;
|
||||
err:
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "externals.h"
|
||||
#include "internals.h"
|
||||
#include "idf.h"
|
||||
|
||||
#ifdef _USE_GTK
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -31,7 +32,7 @@ char *encode_sw = NULL;
|
|||
char *encode_output = NULL;
|
||||
char *mode_sw = NULL;
|
||||
char *appdata_sw = NULL;
|
||||
|
||||
char *idf_sw = NULL;
|
||||
#ifdef _USE_UNPACK
|
||||
extern int unpack(const char *zipfilename, const char *where);
|
||||
extern char zip_game_dirname[];
|
||||
|
@ -125,10 +126,6 @@ int main(int argc, char *argv[])
|
|||
unix_path(game_cwd);
|
||||
setdir(game_cwd);
|
||||
|
||||
// idf_create("data.idf", "snd");
|
||||
// idf_init("idf.idf");
|
||||
// exit(0);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i],"-alsa"))
|
||||
alsa_sw = 1;
|
||||
|
@ -181,6 +178,13 @@ int main(int argc, char *argv[])
|
|||
themes_sw = argv[++i];
|
||||
else
|
||||
themes_sw = "";
|
||||
} else if (!strcmp(argv[i], "-idf")) {
|
||||
if ((i + 1) < argc)
|
||||
idf_sw = argv[++i];
|
||||
else {
|
||||
fprintf(stderr,"No data directory specified.\n");
|
||||
exit(1);
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-encode")) {
|
||||
if ((i + 1) < argc)
|
||||
encode_sw = argv[++i];
|
||||
|
@ -212,7 +216,7 @@ int main(int argc, char *argv[])
|
|||
} else if (!strcmp(argv[i], "-quit")) {
|
||||
exit(0);
|
||||
} else if (argv[i][0] == '-') {
|
||||
fprintf(stderr,"Unknow option: %s\n", argv[i]);
|
||||
fprintf(stderr,"Unknown option: %s\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _USE_UNPACK
|
||||
|
@ -243,6 +247,10 @@ int main(int argc, char *argv[])
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (idf_sw) {
|
||||
idf_create("data.idf", idf_sw);
|
||||
goto out;
|
||||
}
|
||||
menu_langs_lookup(dirpath(LANG_PATH));
|
||||
|
||||
if (!langs_nr) {
|
||||
|
|
|
@ -35,11 +35,14 @@ err:
|
|||
|
||||
char *getfilepath(const char *d, const char *n)
|
||||
{
|
||||
int i = strlen(d) + strlen(n) + 3;
|
||||
int i = ((d)?strlen(d):0) + ((n)?strlen(n):0) + 3;
|
||||
char *p = malloc(i);
|
||||
if (p) {
|
||||
strcpy(p, d);
|
||||
strcat(p, "/");
|
||||
p[0] = 0;
|
||||
if (d) {
|
||||
strcpy(p, d);
|
||||
strcat(p, "/");
|
||||
}
|
||||
strcat(p, n);
|
||||
unix_path(p);
|
||||
}
|
||||
|
|
Reference in a new issue