idf: not ready

This commit is contained in:
p.kosyh 2011-04-17 14:06:01 +00:00
parent 3e3e403a73
commit e747feeed9
9 changed files with 29 additions and 17 deletions

View file

@ -5,7 +5,7 @@ CFLAGS += $(SDL_CFLAGS) $(LUA_CFLAGS) $(ZLIB_CFLAGS) $(EXTRA_CFLAGS) -DLANG_PATH
LDFLAGS += $(SDL_LFLAGS) $(LUA_LFLAGS) $(ZLIB_LFLAGS) $(EXTRA_LDFLAGS)
SRC := graphics.c input.c game.c main.c instead.c sound.c SDL_rotozoom.c SDL_anigif.c SDL_gfxBlitFunc.c config.c themes.c menu.c util.c cache.c unzip.c ioapi.c unpack.c lfs.c $(PLATFORM)
SRC := graphics.c input.c game.c main.c instead.c sound.c SDL_rotozoom.c SDL_anigif.c SDL_gfxBlitFunc.c config.c themes.c menu.c util.c cache.c unzip.c ioapi.c unpack.c lfs.c idf.c $(PLATFORM)
H := cache.h config.h externals.h game.h graphics.h input.h instead.h internals.h ioapi.h iowin32.h list.h \
menu.h SDL_anigif.h SDL_gfxBlitFunc.h SDL_rotozoom.h sound.h themes.h unzip.h util.h

View file

@ -21,7 +21,7 @@
#include <stdio.h>
#include <string.h>
#include "SDL_anigif.h"
#include "util.h"
/* Code from here to end of file has been adapted from XPaint: */
@ -137,7 +137,7 @@ int AG_LoadGIF( const char* file, AG_Frame* frames, int size, int *loop )
{
int n = 0;
SDL_RWops* src = SDL_RWFromFile( file, "rb" );
SDL_RWops* src = SDL_RWFromFile( dirpath(file), "rb" );
if ( src )
{

View file

@ -1,6 +1,7 @@
#include "externals.h"
#include "internals.h"
#include "list.h"
#include "idf.h"
int game_running = 1;
@ -10,6 +11,10 @@ char *err_msg = NULL;
char game_cwd[PATH_MAX];
char *curgame_dir = NULL;
#define DATA_IDF "data.idf"
idf_t game_idf = NULL;
int game_own_theme = 0;
int game_theme_changed = 0;
@ -114,6 +119,7 @@ int game_select(const char *name)
char *oldgame = curgame_dir;
curgame_dir = g->dir;
instead_done();
if (instead_init()) {
curgame_dir = oldgame;
return -1;
@ -123,6 +129,9 @@ int game_select(const char *name)
return -1;
}
idf_done(game_idf);
game_idf = idf_init(DATA_IDF);
game_use_theme();
if (game_theme_init()) {
@ -841,6 +850,7 @@ void game_done(int err)
//#endif
curgame_dir = NULL;
game_own_theme = 0;
idf_done(game_idf); game_idf = NULL;
// SDL_Quit();
}
@ -1314,11 +1324,11 @@ void game_music_player(void)
} else if (!last_music && mus) {
game_stop_mus(500);
last_music = mus;
snd_play_mus(dirpath(mus), 0, loop - 1);
snd_play_mus(mus, 0, loop - 1);
} else if (strcmp(last_music, mus)) {
game_stop_mus(500);
last_music = mus;
snd_play_mus(dirpath(mus), 0, loop - 1);
snd_play_mus(mus, 0, loop - 1);
} else
free(mus);
}
@ -1445,7 +1455,7 @@ static _snd_t *sound_add(const char *fname)
free(sn);
return NULL;
}
w = snd_load_wav(dirpath(fname));
w = snd_load_wav(fname);
if (!w)
goto err;
sn->wav = w;
@ -1468,7 +1478,7 @@ static void sounds_reload(void)
list_for_each(pos, &sounds) {
sn = (_snd_t*)pos;
snd_free_wav(sn->wav);
sn->wav = snd_load_wav(dirpath(sn->fname));
sn->wav = snd_load_wav(sn->fname);
}
}

View file

@ -1,6 +1,8 @@
#ifndef __GAME_H__
#define __GAME_H__
#include <SDL_mixer.h>
#include "idf.h"
#define SND_CHANNELS MIX_CHANNELS
#ifndef GAMES_PATH
@ -105,5 +107,5 @@ struct game {
extern struct game *games;
extern int games_nr;
extern idf_t game_idf;
#endif

View file

@ -767,7 +767,6 @@ static img_t _gfx_load_image(char *filename, int combined)
img = _gfx_load_special_image(filename, combined);
if (img)
return img;
filename = dirpath(filename);
if (strstr(filename,".gif") || strstr(filename,".GIF"))
nr = AG_LoadGIF(filename, NULL, 0, NULL);
if (nr > 1) { /* anigif logic */
@ -783,13 +782,13 @@ static img_t _gfx_load_image(char *filename, int combined)
anigif_add(agif);
return agif->frames[0].surface;
}
img = IMG_Load(filename);
img = IMG_Load(dirpath(filename));
if (!img) {
return NULL;
}
if (img->format->BitsPerPixel == 32) { /* hack for 32 bit BMP :( */
SDL_RWops *rwop;
rwop = SDL_RWFromFile(filename, "rb");
rwop = SDL_RWFromFile(dirpath(filename), "rb");
if (rwop) {
if (IMG_isBMP(rwop))
SDL_SetAlpha(img, 0, SDL_ALPHA_OPAQUE);
@ -1418,7 +1417,7 @@ fnt_t fnt_load(const char *fname, int size)
goto err;
for (i = 0; i < n; i++) {
if (!is_empty(files[i]))
fn = TTF_OpenFont(files[i], size);
fn = TTF_OpenFont(dirpath(files[i]), size);
else
fn = NULL;
if (!fn && i == 0) /* no regular */

View file

@ -723,7 +723,7 @@ static int luaB_load_font(lua_State *L) {
if (!fname)
return 0;
fnt = fnt_load(dirpath((char*)fname), sz);
fnt = fnt_load((char*)fname, sz);
if (!fnt)
return 0;

View file

@ -125,7 +125,7 @@ int main(int argc, char *argv[])
unix_path(game_cwd);
setdir(game_cwd);
// idf_create("idf.idf", "./test");
// idf_create("data.idf", "snd");
// idf_init("idf.idf");
// exit(0);

View file

@ -3,6 +3,7 @@
#include <SDL.h>
#include <SDL_mixer.h>
#include "idf.h"
#ifdef S60
int audio_rate = 11025;
@ -122,7 +123,7 @@ wav_t snd_load_wav(const char *fname)
return NULL;
if (!fname)
return NULL;
r = (wav_t)Mix_LoadWAV(fname);
r = (wav_t)Mix_LoadWAV(dirpath(fname));
if (!r)
fprintf(stderr,"Can't load '%s'.\n", fname);
return r;
@ -152,7 +153,7 @@ mus_t snd_load_mus(const char *fname)
mus = malloc(sizeof(struct _mus_t));
if (!mus)
return NULL;
mus->rw = SDL_RWFromFile(fname, "rb");
mus->rw = RWFromIdf(game_idf, fname);
if (!mus->rw)
goto err;
mus->mus = Mix_LoadMUS_RW(mus->rw);

View file

@ -304,7 +304,7 @@ char *sdl_path(char *p)
unix_path(p);
return p;
}
#if 1
#if 0
int setdir(const char *path)
{
return chdir(path);