Beispiel #1
0
proginfo * select_subwindow(int f_index, int what_help, char *heading)
{
	proginfo *cur = NULL;
	char **list;
	int list_n, index, loop;

	if (f_index == -1)
		return NULL;

	list_n = create_subwindow_list(f_index, &list);

	index = selection_box((void **)list, NULL, list_n, SEL_SUBWIN, what_help, heading);

	if (index != -1)
	{
		cur = &pi[f_index];
		for(loop=0; loop<index; loop++)
		{
			cur = cur -> next;
		}
	}

	delete_array(list, list_n);

	return cur;
}
Beispiel #2
0
char * select_file(char *input, int what_help)
{
	char **list = NULL, *isdir = NULL, *path = NULL;
	char *new_fname = NULL;
	struct stat64 statbuf;
	int list_n, index;
	int strbufsize = find_path_max();

	list_n = match_files(input, &path, &list, &isdir);
	if (list_n == 0)
	{
		myfree(path);
		flash();
		return NULL;
	}

	index = selection_box((void **)list, isdir, list_n, SEL_FILES, what_help, NULL);
	if (index != -1)
	{
		new_fname = (char *)mymalloc(strbufsize + 1);

		snprintf(new_fname, strbufsize, "%s%s", path, list[index]);

		if (stat64(new_fname, &statbuf) == -1)
		{
			myfree(new_fname);
			new_fname = NULL;
			flash();
		}
		else
		{
			if (S_ISDIR(statbuf.st_mode))
			{
				strncat(new_fname, "/", strbufsize);
			}
		}
	}

	delete_array(list, list_n);

	myfree(isdir);
	myfree(path);

	return new_fname;
}
Beispiel #3
0
char * search_history(history_t *ph, char *search_string)
{
	if (ph -> history_size > 0)
	{
		int n_entries, free_entry;

		load_history(ph);

		free_entry = history_find_null_entry(ph);
		n_entries = free_entry == -1 ? ph -> history_size : free_entry;

		if (n_entries > 0)
		{
			int sel_index = selection_box((void **)ph -> history, NULL, n_entries, SEL_HISTORY, HELP_HISTORY, NULL);

			if (sel_index >= 0)
				return mystrdup((ph -> history)[sel_index]);
		}
		else
			error_popup("Search history", -1, "The history list is empty.");
	}

	return NULL;
}
Beispiel #4
0
int select_window(int what_help, char *heading)
{
	return selection_box((void **)pi, NULL, nfd, SEL_WIN, what_help, heading);
}
Beispiel #5
0
int savegame_dialog ()
{
	char home[MAX_PATH], path[MAX_PATH];
	char *desc;
	char *buttons[] = { "Do as I say!", "I regret", NULL }; 
	char dstr[200];
	int rc, slot = 0;
	int hm, vm, hp, vp;			/* box margins */
	int w;

	hm = 2; vm = 3;
	hp = hm * CHAR_COLS; vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Couldn't save game.");
		return err_BadFileOpen;
	}
	/* DATADIR conflicts with ObjIdl.h in win32 SDK, renamed to DATA_DIR */
	sprintf (path, "%s/" DATA_DIR "/", home);
	MKDIR (path, 0755);
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
	MKDIR (path, 0711);

	erase_both ();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a slot in which you wish to save the game:",
		0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	print_text ("Press ENTER to select, ESC cancels",
		0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	slot = select_slot (path);
	if (slot < 0)	/* ESC pressed */
		return err_OK;

	/* Get savegame description */
	draw_window (hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
		GFX_HEIGHT - vp - 9 * CHAR_LINES);
	print_text ("Enter a description for this game:",
		0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	draw_rectangle (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
	flush_block (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES);

	get_string (2, 11, 33, MAX_STRINGS);
	print_character (3, 11, game.cursor_char, MSG_BOX_COLOUR, MSG_BOX_TEXT);
        do { main_cycle (); } while (game.input_mode == INPUT_GETSTRING);
	close_window ();

 	desc = game.strings[MAX_STRINGS];

	sprintf (dstr, "Are you sure you want to save the game "
		"described as:\n\n%s\n\nin slot %d?\n\n\n",
		desc, slot);

	rc = selection_box (dstr, buttons);

	if (rc != 0) {
		message_box ("Game NOT saved.");
		return err_OK;
	}

	sprintf (path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);
	_D (_D_WARN "file is [%s]", path);
	
	save_game (path, desc);

	message_box ("Game saved.");

	return err_OK;
}
Beispiel #6
0
int savegame_dialog ()
{
#ifndef PALMOS /* FIXME */
	char home[MAX_PATH], path[MAX_PATH];
	char *desc;
	char *buttons[] = { "Do as I say!", "I regret", NULL }; 
	char dstr[200];
	int rc, slot = 0;
	int hm, vm, hp, vp;			/* box margins */
	int w;

	hm = 2; vm = 3;
	hp = hm * CHAR_COLS; vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

#ifdef DREAMCAST
	uint8 addr, port, unit;

	addr = maple_first_vmu();
	if(addr) {
		maple_create_port(addr, &port, &unit);
		sprintf(g_vmu_port, "%c%d", port + 'a', unit);
	} else {
		message_box("No VMU found.");
		return err_OK;
	}
#else
	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Couldn't save game.");
		return err_BadFileOpen;
	}
# ifdef CIBYL
	sprintf (path, "recordstore://%05X.%s:",
		game.crc, game.id);
# else
	/* DATADIR conflicts with ObjIdl.h in win32 SDK, renamed to DATA_DIR */
	sprintf (path, "%s/" DATA_DIR "/", home);
	MKDIR (path, 0755);
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
	MKDIR (path, 0711);
# endif
#endif

	erase_both ();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a slot in which you wish to save the game:",
		0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	print_text ("Press ENTER to select, ESC cancels",
		0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	slot = select_slot (path);
	if (slot < 0)	/* ESC pressed */
		return err_OK;

	/* Get savegame description */
	draw_window (hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
		GFX_HEIGHT - vp - 9 * CHAR_LINES);
	print_text ("Enter a description for this game:",
		0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	draw_rectangle (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
	flush_block (3 * CHAR_COLS, 11 * CHAR_LINES - 1,
		37 * CHAR_COLS, 12 * CHAR_LINES);

	get_string (2, 11, 33, MAX_STRINGS);
	print_character (3, 11, game.cursor_char, MSG_BOX_COLOUR, MSG_BOX_TEXT);
        do { main_cycle (); } while (game.input_mode == INPUT_GETSTRING);
	close_window ();

 	desc = game.strings[MAX_STRINGS];

	sprintf (dstr, "Are you sure you want to save the game "
		"described as:\n\n%s\n\nin slot %d?\n\n\n",
		desc, slot);

	rc = selection_box (dstr, buttons);

	if (rc != 0) {
		message_box ("Game NOT saved.");
		return err_OK;
	}

#ifdef DREAMCAST
	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
	fs_unlink(path);
#elif CIBYL
	sprintf (path, "recordstore://%05X.%s:%d",
		game.crc, game.id, slot+1);
        printf("path: %s\n", path);
#else
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);
#endif
	_D (_D_WARN "file is [%s]", path);
	
	save_game (path, desc);

	message_box ("Game saved.");
#endif /* PALMOS */

	return err_OK;
}