コード例 #1
0
ファイル: savegame.c プロジェクト: UIKit0/sarien
int loadgame_dialog ()
{
	char home[MAX_PATH], path[MAX_PATH];
	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 ("Error loading game.");
		return err_BadFileOpen;
	}

	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);

	erase_both();
	stop_sound();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a game which you wish to\nrestore:",
		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) {
		message_box ("Game NOT restored.");
		return err_OK;
	}

	sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);

	if ((rc = load_game (path)) == err_OK) {
		message_box ("Game restored.");
		game.exit_all_logics = 1;
		menu_enable_all();
	} else {
		message_box ("Error restoring game.");
	}

	return rc;
}
コード例 #2
0
ファイル: savegame.c プロジェクト: SimonKagstrom/sarien-j2me
int loadgame_dialog ()
{
#ifndef PALMOS
	char home[MAX_PATH], path[MAX_PATH];
	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 ("Error loading game.");
		return err_BadFileOpen;
	}

# ifdef CIBYL
	sprintf (path, "recordstore://%05X.%s:",
                 game.crc, game.id);
# else
	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);
# endif
#endif

	erase_both();
	stop_sound();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a game which you wish to\nrestore:",
		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) {
		message_box ("Game NOT restored.");
		return err_OK;
	}

#ifdef DREAMCAST
	sprintf(path, VMU_PATH, g_vmu_port, game.id, slot);
#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

	if ((rc = load_game (path)) == err_OK) {
		message_box ("Game restored.");
		game.exit_all_logics = 1;
		menu_enable_all();
	} else {
		message_box ("Error restoring game.");
	}

	return rc;
#endif /* PALMOS */
}
コード例 #3
0
ファイル: savegame.c プロジェクト: UIKit0/sarien
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;
}
コード例 #4
0
ファイル: savegame.c プロジェクト: SimonKagstrom/sarien-j2me
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;
}