directory selection menu is back working again

changelog and todo file updated
origin
stpohle 22 years ago
parent 7a99299749
commit a9bb0cd752

@ -1,8 +1,9 @@
$Id: TODO,v 1.26 2003/12/26 16:55:35 stpohle Exp $
$Id: TODO,v 1.27 2003/12/28 05:47:50 stpohle Exp $
* tileset name and so on won't be send right.
* changing bcmserv to a new protocoll
* check if the player is on a field with
an running explosion
- multiplayer broadcast in the local network
ip: 10.*.*.* and 192.168.*.*

@ -1,4 +1,4 @@
/* $Id: menu.h,v 1.2 2003/12/28 01:21:42 stpohle Exp $
/* $Id: menu.h,v 1.3 2003/12/28 05:47:51 stpohle Exp $
* GUI for menuhandling
*/
@ -79,5 +79,7 @@ extern void menu_focus_id (int id);
extern void menu_change_focus (_menuitem *newfocus);
extern _menuitem *menu_get_lastid ();
extern _menuitem *menu_get_firstid ();
extern int menu_create_dirlist (char *path, signed char dirflags, _charlist *cl, int maxentry);
extern char *menu_dir_select (char *title, char *path, signed char dirflags);
#endif

@ -1,4 +1,4 @@
/* $Id: mapmenu.c,v 1.15 2003/12/28 01:21:43 stpohle Exp $ */
/* $Id: mapmenu.c,v 1.16 2003/12/28 05:47:51 stpohle Exp $ */
/* map/tileset selection menu */
#include "bomberclone.h"
@ -56,18 +56,16 @@ mapmenu ()
3);
break;
}
if (map.random_tileset) {
selts = charlist_findtext (tiletypes, "selected");
if (map.tileset[0] == 0)
sprintf (mname, "< undefined >");
else
sprintf (mname, "%s", map.tileset);
menu_create_label ("Selected Tileset:", 250, 140, 0);
menu_create_button (mname, 250, 160, 170, 5);
}
else {
selts = charlist_findtext (tiletypes, "random");
};
if (map.random_tileset)
selts = &tiletypes[0];
else
selts = &tiletypes[1];
if (map.tileset[0] == 0)
sprintf (mname, "< undefined >");
else
sprintf (mname, "%s", map.tileset);
menu_create_label ("Selected Tileset:", 250, 140, 0);
menu_create_button (mname, 250, 160, 170, 5);
switch (map.type) {
case (MAPT_normal):
@ -105,36 +103,23 @@ mapmenu ()
menuselect = menu_loop ();
menu_delete ();
switch (menuselect) {
case (0):
menuselect = -1;
break;
case (1): // Select
map.map_selection = selmt - &maptypes[0];
break;
case (2): // Select Map
sprintf (pathname, "%s/maps", bman.datapath);
// mapname = menu_dir_select ("Select Map", pathname, DF_file);
mapname = menu_dir_select ("Select Map", pathname, DF_file);
if (mapname == NULL) {
map.map[0] = 0;
map.map_selection = 2;
}
else {
FILE *fmap;
else
sprintf (map.map, "%s/maps/%s", bman.datapath, mapname);
if ((fmap = fopen (map.map, "r")))
map_load (fmap);
}
break;
case (4): // Random Tileset
map.random_tileset = selts - &tiletypes[0];
d_printf ("Tile:%d\n", map.random_tileset);
break;
case (5): // Selected Tileset
sprintf (pathname, "%s/tileset", bman.datapath);
// mapname = menu_dir_select ("Select Tileset", pathname, DF_dir);
mapname = menu_dir_select ("Select Tileset", pathname, DF_dir);
if (mapname == NULL) {
map.tileset[0] = 0;
map.random_tileset = 1;
@ -142,14 +127,18 @@ mapmenu ()
else
strcpy (map.tileset, mapname);
break;
case (6): // Random Tileset
map.type = seltt - &tunneltypes[0];
if (map.type == 2)
map.type = -1;
d_printf ("Tunnel:%d\n", map.type);
break;
}
/* map type */
map.type = seltt - &tunneltypes[0];
if (map.type == 2)
map.type = -1;
d_printf ("Tunnel:%d\n", map.type);
/* tileset mode and map mode */
map.random_tileset = 1-(selts - &tiletypes[0]);
printf ("Tileset Mode : %d\n", map.random_tileset);
map.map_selection = selmt - &maptypes[0];
}
map.size.x = map.size.x | 1;
if (map.size.x < MIN_FIELDSIZE_X)

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.32 2003/12/28 01:21:43 stpohle Exp $
/* $Id: menu.c,v 1.33 2003/12/28 05:47:51 stpohle Exp $
* Menuhandling */
#include "basic.h"
@ -398,3 +398,49 @@ int menu_loop () {
return menu.focus->id;
};
/* create a list with all directory entrys,
* except we can't put everything in the list because the list is too smal.
* Return: number of entrys, Pointers will be set*/
int menu_create_dirlist (char *path, signed char dirflags, _charlist *cl, int maxentry) {
int cnt;
_direntry *destart, *de;
destart = s_getdir (path);
destart = s_dirfilter (destart, dirflags);
for (cnt = 0, de = destart; (de != NULL && cnt < maxentry); de = de->next) {
strncpy (cl[cnt].text, de->name, 255);
if (de->next != NULL)
cl[cnt].next = &cl[cnt+1];
else
cl[cnt].next = NULL;
cnt++;
}
return cnt;
};
/* displays a file selectionmenu and
* returns the name of the file */
static char menu_dir_name[LEN_PATHFILENAME];
char *
menu_dir_select (char *title, char *path, signed char dirflags) {
_charlist flist[MAX_DIRENTRYS];
int flcnt, menuselect;
_charlist *selfile = NULL;
flcnt = menu_create_dirlist (path, dirflags, flist, MAX_DIRENTRYS);
menu_new (title, 300, 300);
menu_create_list ("Dir", -1, 50, 200, 200, flist, &selfile, 1);
menu_create_button ("OK", -1, 270, 150, 0);
menuselect = menu_loop ();
menu_delete ();
if (menuselect < 0) return NULL;
strncpy (menu_dir_name, selfile->text, LEN_PATHFILENAME);
return menu_dir_name;
};

Loading…
Cancel
Save