idf: not ready
This commit is contained in:
parent
3e3e403a73
commit
e747feeed9
|
@ -5,7 +5,7 @@ CFLAGS += $(SDL_CFLAGS) $(LUA_CFLAGS) $(ZLIB_CFLAGS) $(EXTRA_CFLAGS) -DLANG_PATH
|
||||||
|
|
||||||
LDFLAGS += $(SDL_LFLAGS) $(LUA_LFLAGS) $(ZLIB_LFLAGS) $(EXTRA_LDFLAGS)
|
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 \
|
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
|
menu.h SDL_anigif.h SDL_gfxBlitFunc.h SDL_rotozoom.h sound.h themes.h unzip.h util.h
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "SDL_anigif.h"
|
#include "SDL_anigif.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
/* Code from here to end of file has been adapted from XPaint: */
|
/* 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;
|
int n = 0;
|
||||||
|
|
||||||
SDL_RWops* src = SDL_RWFromFile( file, "rb" );
|
SDL_RWops* src = SDL_RWFromFile( dirpath(file), "rb" );
|
||||||
|
|
||||||
if ( src )
|
if ( src )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "externals.h"
|
#include "externals.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "idf.h"
|
||||||
|
|
||||||
int game_running = 1;
|
int game_running = 1;
|
||||||
|
|
||||||
|
@ -10,6 +11,10 @@ char *err_msg = NULL;
|
||||||
char game_cwd[PATH_MAX];
|
char game_cwd[PATH_MAX];
|
||||||
char *curgame_dir = NULL;
|
char *curgame_dir = NULL;
|
||||||
|
|
||||||
|
#define DATA_IDF "data.idf"
|
||||||
|
|
||||||
|
idf_t game_idf = NULL;
|
||||||
|
|
||||||
int game_own_theme = 0;
|
int game_own_theme = 0;
|
||||||
int game_theme_changed = 0;
|
int game_theme_changed = 0;
|
||||||
|
|
||||||
|
@ -114,6 +119,7 @@ int game_select(const char *name)
|
||||||
char *oldgame = curgame_dir;
|
char *oldgame = curgame_dir;
|
||||||
curgame_dir = g->dir;
|
curgame_dir = g->dir;
|
||||||
instead_done();
|
instead_done();
|
||||||
|
|
||||||
if (instead_init()) {
|
if (instead_init()) {
|
||||||
curgame_dir = oldgame;
|
curgame_dir = oldgame;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -123,6 +129,9 @@ int game_select(const char *name)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idf_done(game_idf);
|
||||||
|
game_idf = idf_init(DATA_IDF);
|
||||||
|
|
||||||
game_use_theme();
|
game_use_theme();
|
||||||
|
|
||||||
if (game_theme_init()) {
|
if (game_theme_init()) {
|
||||||
|
@ -841,6 +850,7 @@ void game_done(int err)
|
||||||
//#endif
|
//#endif
|
||||||
curgame_dir = NULL;
|
curgame_dir = NULL;
|
||||||
game_own_theme = 0;
|
game_own_theme = 0;
|
||||||
|
idf_done(game_idf); game_idf = NULL;
|
||||||
// SDL_Quit();
|
// SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1314,11 +1324,11 @@ void game_music_player(void)
|
||||||
} else if (!last_music && mus) {
|
} else if (!last_music && mus) {
|
||||||
game_stop_mus(500);
|
game_stop_mus(500);
|
||||||
last_music = mus;
|
last_music = mus;
|
||||||
snd_play_mus(dirpath(mus), 0, loop - 1);
|
snd_play_mus(mus, 0, loop - 1);
|
||||||
} else if (strcmp(last_music, mus)) {
|
} else if (strcmp(last_music, mus)) {
|
||||||
game_stop_mus(500);
|
game_stop_mus(500);
|
||||||
last_music = mus;
|
last_music = mus;
|
||||||
snd_play_mus(dirpath(mus), 0, loop - 1);
|
snd_play_mus(mus, 0, loop - 1);
|
||||||
} else
|
} else
|
||||||
free(mus);
|
free(mus);
|
||||||
}
|
}
|
||||||
|
@ -1445,7 +1455,7 @@ static _snd_t *sound_add(const char *fname)
|
||||||
free(sn);
|
free(sn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
w = snd_load_wav(dirpath(fname));
|
w = snd_load_wav(fname);
|
||||||
if (!w)
|
if (!w)
|
||||||
goto err;
|
goto err;
|
||||||
sn->wav = w;
|
sn->wav = w;
|
||||||
|
@ -1468,7 +1478,7 @@ static void sounds_reload(void)
|
||||||
list_for_each(pos, &sounds) {
|
list_for_each(pos, &sounds) {
|
||||||
sn = (_snd_t*)pos;
|
sn = (_snd_t*)pos;
|
||||||
snd_free_wav(sn->wav);
|
snd_free_wav(sn->wav);
|
||||||
sn->wav = snd_load_wav(dirpath(sn->fname));
|
sn->wav = snd_load_wav(sn->fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef __GAME_H__
|
#ifndef __GAME_H__
|
||||||
#define __GAME_H__
|
#define __GAME_H__
|
||||||
#include <SDL_mixer.h>
|
#include <SDL_mixer.h>
|
||||||
|
#include "idf.h"
|
||||||
|
|
||||||
#define SND_CHANNELS MIX_CHANNELS
|
#define SND_CHANNELS MIX_CHANNELS
|
||||||
|
|
||||||
#ifndef GAMES_PATH
|
#ifndef GAMES_PATH
|
||||||
|
@ -105,5 +107,5 @@ struct game {
|
||||||
|
|
||||||
extern struct game *games;
|
extern struct game *games;
|
||||||
extern int games_nr;
|
extern int games_nr;
|
||||||
|
extern idf_t game_idf;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -767,7 +767,6 @@ static img_t _gfx_load_image(char *filename, int combined)
|
||||||
img = _gfx_load_special_image(filename, combined);
|
img = _gfx_load_special_image(filename, combined);
|
||||||
if (img)
|
if (img)
|
||||||
return img;
|
return img;
|
||||||
filename = dirpath(filename);
|
|
||||||
if (strstr(filename,".gif") || strstr(filename,".GIF"))
|
if (strstr(filename,".gif") || strstr(filename,".GIF"))
|
||||||
nr = AG_LoadGIF(filename, NULL, 0, NULL);
|
nr = AG_LoadGIF(filename, NULL, 0, NULL);
|
||||||
if (nr > 1) { /* anigif logic */
|
if (nr > 1) { /* anigif logic */
|
||||||
|
@ -783,13 +782,13 @@ static img_t _gfx_load_image(char *filename, int combined)
|
||||||
anigif_add(agif);
|
anigif_add(agif);
|
||||||
return agif->frames[0].surface;
|
return agif->frames[0].surface;
|
||||||
}
|
}
|
||||||
img = IMG_Load(filename);
|
img = IMG_Load(dirpath(filename));
|
||||||
if (!img) {
|
if (!img) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (img->format->BitsPerPixel == 32) { /* hack for 32 bit BMP :( */
|
if (img->format->BitsPerPixel == 32) { /* hack for 32 bit BMP :( */
|
||||||
SDL_RWops *rwop;
|
SDL_RWops *rwop;
|
||||||
rwop = SDL_RWFromFile(filename, "rb");
|
rwop = SDL_RWFromFile(dirpath(filename), "rb");
|
||||||
if (rwop) {
|
if (rwop) {
|
||||||
if (IMG_isBMP(rwop))
|
if (IMG_isBMP(rwop))
|
||||||
SDL_SetAlpha(img, 0, SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(img, 0, SDL_ALPHA_OPAQUE);
|
||||||
|
@ -1418,7 +1417,7 @@ fnt_t fnt_load(const char *fname, int size)
|
||||||
goto err;
|
goto err;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (!is_empty(files[i]))
|
if (!is_empty(files[i]))
|
||||||
fn = TTF_OpenFont(files[i], size);
|
fn = TTF_OpenFont(dirpath(files[i]), size);
|
||||||
else
|
else
|
||||||
fn = NULL;
|
fn = NULL;
|
||||||
if (!fn && i == 0) /* no regular */
|
if (!fn && i == 0) /* no regular */
|
||||||
|
|
|
@ -723,7 +723,7 @@ static int luaB_load_font(lua_State *L) {
|
||||||
if (!fname)
|
if (!fname)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fnt = fnt_load(dirpath((char*)fname), sz);
|
fnt = fnt_load((char*)fname, sz);
|
||||||
|
|
||||||
if (!fnt)
|
if (!fnt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||||
unix_path(game_cwd);
|
unix_path(game_cwd);
|
||||||
setdir(game_cwd);
|
setdir(game_cwd);
|
||||||
|
|
||||||
// idf_create("idf.idf", "./test");
|
// idf_create("data.idf", "snd");
|
||||||
// idf_init("idf.idf");
|
// idf_init("idf.idf");
|
||||||
// exit(0);
|
// exit(0);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_mixer.h>
|
#include <SDL_mixer.h>
|
||||||
|
#include "idf.h"
|
||||||
|
|
||||||
#ifdef S60
|
#ifdef S60
|
||||||
int audio_rate = 11025;
|
int audio_rate = 11025;
|
||||||
|
@ -122,7 +123,7 @@ wav_t snd_load_wav(const char *fname)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!fname)
|
if (!fname)
|
||||||
return NULL;
|
return NULL;
|
||||||
r = (wav_t)Mix_LoadWAV(fname);
|
r = (wav_t)Mix_LoadWAV(dirpath(fname));
|
||||||
if (!r)
|
if (!r)
|
||||||
fprintf(stderr,"Can't load '%s'.\n", fname);
|
fprintf(stderr,"Can't load '%s'.\n", fname);
|
||||||
return r;
|
return r;
|
||||||
|
@ -152,7 +153,7 @@ mus_t snd_load_mus(const char *fname)
|
||||||
mus = malloc(sizeof(struct _mus_t));
|
mus = malloc(sizeof(struct _mus_t));
|
||||||
if (!mus)
|
if (!mus)
|
||||||
return NULL;
|
return NULL;
|
||||||
mus->rw = SDL_RWFromFile(fname, "rb");
|
mus->rw = RWFromIdf(game_idf, fname);
|
||||||
if (!mus->rw)
|
if (!mus->rw)
|
||||||
goto err;
|
goto err;
|
||||||
mus->mus = Mix_LoadMUS_RW(mus->rw);
|
mus->mus = Mix_LoadMUS_RW(mus->rw);
|
||||||
|
|
|
@ -304,7 +304,7 @@ char *sdl_path(char *p)
|
||||||
unix_path(p);
|
unix_path(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
#if 1
|
#if 0
|
||||||
int setdir(const char *path)
|
int setdir(const char *path)
|
||||||
{
|
{
|
||||||
return chdir(path);
|
return chdir(path);
|
||||||
|
|
Loading…
Reference in a new issue