some things for crosscompiling

origin
stpohle 23 years ago
parent b74e7d6a0f
commit b40752452c

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.12 2003/05/06 22:33:40 ob1kenewb Exp $ */
/* $Id: bomberclone.h,v 1.13 2003/05/07 00:21:37 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -14,11 +14,13 @@
#include <sys/stat.h>
#ifdef _WIN32
#include <winsock.h>
#include "../confdefs.h"
#include <glib.h>
#include <sys/stat.h>
#define S_ISDIR(a) ((a & _S_IFDIR) == _S_IFDIR)
#define S_ISREG(a) ((a & _S_IFREG) == _S_IFREG)
#ifndef S_ISDIR
#define S_ISDIR(a) ((a & _S_IFDIR) == _S_IFDIR)
#endif
#ifndef S_ISREG
#define S_ISREG(a) ((a & _S_IFREG) == _S_IFREG)
#endif
#else
#include <sys/time.h>
#include <sys/socket.h>
@ -28,9 +30,9 @@
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include "../config.h"
#endif
#include <SDL.h>
#include "../config.h"
#include "gfx.h"
#include "network.h"
#include "sysfunc.h"

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.8 2003/05/06 21:45:08 stpohle Exp $ */
/* $Id: menu.c,v 1.9 2003/05/07 00:21:38 stpohle Exp $ */
/* menu's for the game */
#include <SDL.h>
@ -8,7 +8,7 @@
#define MENU_BG_SHADE_DARK -64
#define MENU_BG_SHADE_BRIGHT 64
/* draws a box size (x,y) */
void
draw_menubox (int x, int y)
{
@ -356,4 +356,104 @@ menu_displaymessage (char *title, char *text)
#define DIRSCRMAX 10
static char menu_selectedfile[LEN_PATHFILENAME];
/* draws the selection on the screen..
dirstart - first entry do display
flags - flags what should be shown directorys or files
selected - Selected file in the list
*/
int menu_dir_draw (char *title, _direntry *dirstart, int start, int selected) {
_direntry *de = dirstart;
int maxlen = 0;
SDL_Rect wnd;
/* look for the longest name */
for (; de != NULL; de = de->next)
if (maxlen < strlen (de->name))
maxlen = strlen (de->name);
if (maxlen * gfx.font.size.x > gfx.res.x)
maxlen = (gfx.res.x - 8) /gfx.font.size.x;
wnd.h = DIRSCRMAX * gfx.font.size.y * 2;
wnd.w = maxlen * gfx.font.size.x;
wnd.x = gfx.res.x - wnd.w / 2;
wnd.y = gfx.res.y - wnd.h / 2;
draw_menubox (wnd.w, wnd.h);
return 0;
}
char *menu_dir_select (char *title, char *path, signed char dirflags) {
_direntry *destart, *de;
SDL_Event event;
Uint8 *keys;
int max = 0, sel = -1, keypressed = 0, done = 0, listend = 0, liststart = 0;
/* get the directory list and count the numbers */
destart = s_getdir (path);
destart = s_dirfilter (destart, dirflags);
for (max = 0, de = destart; de != NULL; de = de->next)
max++;
if (max <= 0)
return NULL;
while (done == 0 || (done == 1 && keypressed == 1)) {
/* do the network loop if we have to */
listend = menu_dir_draw (title, destart, liststart, sel);
if (bman.gametype == GT_multi && bman.sock != -1)
network_loop ();
if (SDL_PollEvent (&event) != 0)
switch (event.type) {
case (SDL_QUIT):
sel = -1;
bman.state = GS_quit;
done = 1;
}
/* keyboard handling */
keys = SDL_GetKeyState (NULL);
if (keys[SDLK_DOWN] && event.type == SDL_KEYDOWN && keypressed == 0) {
keypressed = 1;
sel++;
if (!(listend)) /* if we can move this list down */
liststart++;
if (sel >= max) {
liststart = 0;
sel = 0;
}
}
if (keys[SDLK_UP] && event.type == SDL_KEYDOWN && keypressed == 0) {
keypressed = 1;
sel--;
if (liststart > 0)
liststart--;
if (sel < 0) {
sel = max - 1;
if (sel > (DIRSCRMAX/2))
liststart = sel - (DIRSCRMAX/2);
}
}
if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
keypressed = 1;
return -1;
}
if (!keys[SDLK_ESCAPE] && event.type == SDL_KEYUP)
keypressed = 0;
if (keys[SDLK_RETURN] && event.type == SDL_KEYDOWN) {
done = 1;
keypressed = 1;
}
if (!keys[SDLK_RETURN] && event.type == SDL_KEYUP)
keypressed = 0;
s_delay (100);
}
};
#undef DIRSCRMAX

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.6 2003/05/06 20:48:54 stpohle Exp $ */
/* $Id: single.c,v 1.7 2003/05/07 00:21:38 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -39,7 +39,11 @@ single_game_new (int ai_players)
field_new (bman.fieldpath);
tileset_random ();
{
// char *tmp = menu_dir_select ("data/tileset", DF_dir);
// printf ("Selected: %s\n", tmp);
}
bman.players_nr_s = 1;
bman.players_nr = 1;
bman.gametype = GT_single;

@ -1,4 +1,4 @@
/* $Id: sysfunc.c,v 1.5 2003/05/06 22:47:05 stpohle Exp $
/* $Id: sysfunc.c,v 1.6 2003/05/07 00:21:38 stpohle Exp $
sysfunc.c - this file hold some routines for the system functions..
like d_delay
*/
@ -63,10 +63,45 @@ static _direntry direntrys[MAX_DIRENTRYS];
_direntry *
s_getdir (char *path)
{
int entrynr = 0;
#ifdef _WIN32
WIN32_FIND_DATA fdata;
HANDLE fhandle;
struct stat fstat;
char filename[LEN_PATHFILENAME];
snprintf (filename, LEN_PATHFILENAME, "%s\\*.*", path);
d_printf ("Reading Dir [%s]\n", filename);
if ((fhandle = FindFirstFile (filename, &fdata)) != INVALID_HANDLE_VALUE) {
do {
d_printf (" Got Somthing [%s]\n",fdata.cFileName);
direntrys[entrynr].next = NULL;
strncpy (direntrys[entrynr].name, fdata.cFileName, LEN_FILENAME - 1);
if (strlen (fdata.cFileName) >= LEN_FILENAME)
direntrys[entrynr].name[LEN_FILENAME - 1] = 0;
sprintf (filename, "%s\%s", path, direntrys[entrynr].name);
stat (filename, &fstat);
if (S_ISREG (fstat.st_mode)) {
direntrys[entrynr].flags = DF_file;
direntrys[entrynr].next = &direntrys[entrynr + 1];
entrynr++;
}
else if (S_ISDIR (fstat.st_mode)) {
direntrys[entrynr].flags = DF_dir;
direntrys[entrynr].next = &direntrys[entrynr + 1];
entrynr++;
}
} while (FindNextFile (fhandle, &fdata) && entrynr < MAX_DIRENTRYS);
FindClose (fhandle);
}
#else
DIR *dp;
struct dirent *ep;
struct stat fstat;
int entrynr = 0;
char filename[LEN_PATHFILENAME];
dp = opendir (path);
@ -90,11 +125,12 @@ s_getdir (char *path)
entrynr++;
}
}
closedir (dp);
}
closedir (dp);
#endif
d_printf ("Readin %d Entrys in the Directory\n", entrynr);
if (entrynr == 0)
return NULL;
direntrys[entrynr - 1].next = NULL;
return &direntrys[0];

@ -1,4 +1,4 @@
/* $Id: sysfunc.h,v 1.2 2003/05/06 21:34:07 stpohle Exp $ */
/* $Id: sysfunc.h,v 1.3 2003/05/07 00:21:38 stpohle Exp $ */
/* include some system near functions */
#ifndef _SYSFUNC_H_
@ -24,4 +24,4 @@ extern char *s_gethomedir ();
extern _direntry *s_getdir (char *path);
extern _direntry *s_dirfilter (_direntry *dirstart, signed char dirflags);
#endif
#endif

Loading…
Cancel
Save