Status of variants?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CJNyfalt
    Swordsman
    • May 2007
    • 289

    #16
    Checking what I have done before, I found out that the most recent things I did was a second (? at least) try at Anglib, some tinkering with Oangband and the variant I started from Sangband. (There is still older stuff that I have yet to check.)

    Now, my thought on those three projects:
    - Anglib will be thrown away, and I will try to support AngbandBase instead. I am just happy that the idea has taken root, and relieved that I don't have to do everything.

    - Oangband tweaks. They are small. They enhances gameplay for me. I am not willing to become Oangband maintainer. I think that Oangband should be maintained. I consider starting a discussion thread about the future of Oangband.

    - Sangband, and my own variant. I have yet to review my code to consider if I should start over taking the best ideas, or continue, and if I start over should I start from latest Leon version or latest Joshua version. I would like to see the best UI stuff from S and V merged together.

    Right now I am a bit unsure about how to proceed.

    Comment

    • d_m
      Angband Devteam member
      • Aug 2008
      • 1517

      #17
      Originally posted by CJNyfalt
      Well, I have my doubts but we can only hope that I or someone else is able to.
      I am willing to try to get this working.

      It would be great if there was a Term-type abstraction for dialogs in Angband that could be mapped to either real dialogs (Windows, OSX), pseudo-dialogs (SDL) or just drawn directly on Term-0 (GCU). I think Takkaria's crazy UI overhaul would allow this, but is probably years away.
      linux->xterm->screen->pmacs

      Comment

      • CJNyfalt
        Swordsman
        • May 2007
        • 289

        #18
        Originally posted by d_m
        I am willing to try to get this working.

        It would be great if there was a Term-type abstraction for dialogs in Angband that could be mapped to either real dialogs (Windows, OSX), pseudo-dialogs (SDL) or just drawn directly on Term-0 (GCU). I think Takkaria's crazy UI overhaul would allow this, but is probably years away.
        Well, I tried to get something done, and progressed a bit. Maybe you can use what I have? There is still errors that prevents compiling.
        At least the following needs some kind of fix: race_info, character_loaded, player_wipe, center_string, display_width, rogue_like_commands and process_player_name.

        Here is the diff:
        Code:
        Index: savefile.c
        ===================================================================
        --- savefile.c	(revision 5)
        +++ savefile.c	(working copy)
        @@ -558,3 +558,494 @@
         	/* Oops */
         	return (FALSE);
         }
        +
        +
        +/**************************************************************/
        +/*                                                            */
        +/*                  Savefile Management Code                  */
        +/*                                                            */
        +/**************************************************************/
        +
        +
        +/*
        + * Temporary storage of savefile paths, descriptions, and dead/alive status.
        + */
        +#define DESC_LEN 256
        +
        +char savefile_names[46][40];
        +char savefile_desc[46][DESC_LEN];
        +bool savefile_alive[46];
        +
        +/*
        + * Read the savefile record.  -DG-
        + */
        +static int load_savefile_names(void)
        +{
        +	char buf[1024];
        +	char tmp[50];
        +	int max = 0;
        +	int fd;
        +	ang_file *fff;
        +
        +	/* Build the filename */
        +#ifdef SAVEFILE_USE_UID
        +	(void)strnfmt(tmp, sizeof(tmp), "user.%d.svg", player_uid);
        +#else
        +	(void)strnfmt(tmp, sizeof(tmp), "global.svg");
        +#endif /* SAVEFILE_USE_UID */
        +
        +	/* Attempt to load the savefile record */
        +	if (path_build(buf, sizeof(buf), ANGBAND_DIR_SAVE, tmp)) return (0);
        +
        +	/* Grab permissions */
        +	safe_setuid_grab();
        +
        +	/* Read the file */
        +	fff = file_open(buf, MODE_READ, FTYPE_TEXT);
        +
        +	/* Drop permissions */
        +	safe_setuid_drop();
        +
        +	/* Failure */
        +	if (!fff) return (0);
        +
        +	/* Parse the savefile record */
        +	while (0 < file_read(fff, buf, sizeof(buf)))
        +	{
        +		int i = 1;
        +
        +		/* Read "dead/alive" */
        +		if      (buf[0] == '0') savefile_alive[max] = FALSE;
        +		else if (buf[0] == '1') savefile_alive[max] = TRUE;
        +
        +		/* Read the savefile name */
        +		for (i = 1;; i++)
        +		{
        +			/* Build path */
        +			if (buf[i] != '@') savefile_names[max][i - 1] = buf[i];
        +			else
        +			{
        +				/* Terminate */
        +				savefile_names[max][i - 1] = '\0';
        +				break;
        +			}
        +		}
        +
        +		/* Skip the '@' */
        +		i++;
        +
        +		/* Read the character description */
        +		(void)strnfmt(savefile_desc[max], sizeof(savefile_desc[max]), buf + i);
        +
        +		/* Append user ID to filename if necessary */
        +#ifdef SAVEFILE_USE_UID
        +		(void)strnfmt(tmp, sizeof(tmp),"%d.%s", player_uid, savefile_names[max]);
        +#else
        +		(void)strnfmt(tmp, sizeof(tmp), "%s", savefile_names[max]);
        +#endif
        +
        +		/* Confirm that file still exists */
        +		(void)path_build(buf, sizeof(buf), ANGBAND_DIR_SAVE, tmp);
        +
        +		/* Grab permissions */
        +		safe_setuid_grab();
        +
        +		/* Check for file */
        +		fd = file_exists(buf);
        +
        +		/* Drop permissions */
        +		safe_setuid_drop();
        +
        +		/* File exists */
        +		if (fd >= 0)
        +		{
        +			/* Increment file count, go to next record */
        +			max++;
        +		}
        +	}
        +
        +	/* Close the savefile record */
        +	(void)file_close(fff);
        +
        +	/* Return number of valid savefiles */
        +	return (max);
        +}
        +
        +
        +/*
        + * Write the savefile record.  -DG-
        + */
        +void save_savefile_names(void)
        +{
        +	char buf[1024];
        +	char tmp[DESC_LEN];
        +	char name[DESC_LEN];
        +	int i;
        +	ang_file *fff;
        +
        +
        +	/* Load existing savefile records */
        +	int max = load_savefile_names();
        +
        +	/* Build the filename - use user index if necessary */
        +#ifdef SAVEFILE_USE_UID
        +	(void)strnfmt(tmp, sizeof(tmp),"user.%d.svg", player_uid);
        +#else
        +	(void)strnfmt(tmp, sizeof(tmp), "global.svg");
        +#endif /* SAVEFILE_USE_UID */
        +
        +	(void)path_build(buf, sizeof(buf), ANGBAND_DIR_SAVE, tmp);
        +
        +	/* Read the file */
        +	fff = file_open(buf, MODE_WRITE, FTYPE_TEXT);
        +
        +	/* Failure */
        +	if (!fff) return;
        +
        +
        +	/* Copy character name to a rewriteable string */
        +	(void)my_strcpy(name, op_ptr->full_name, sizeof(name));
        +
        +	/* Add Latin-1 encodes */
        +/*	xstr_encode(name, sizeof(name)); */
        +
        +	/* Save information about the current character savefile */
        +	file_putf(fff, "%c%s@%s, the %s is %s\n", ((p_ptr->is_dead)? '0' : '1'),
        +		op_ptr->base_name, name, race_info[p_ptr->prace].title,
        +		(!p_ptr->is_dead)?"alive":"dead");
        +
        +	/* Rewrite all other savefile records - do not exceed 46 records */
        +	for (i = 0; i < MIN(max, 45); i++)
        +	{
        +		/* Do not record the current savefile more than once */
        +		if (!strcmp(savefile_names[i], op_ptr->base_name)) continue;
        +
        +		/* Write a savefile record */
        +		file_putf(fff, "%c%s@%s\n", (savefile_alive[i])?'1':'0',
        +			savefile_names[i], savefile_desc[i]);
        +	}
        +
        +	/* Close */
        +	(void)file_close(fff);
        +}
        +
        +
        +/*
        + * Interact with the savefile management screen.  -DG-
        + */
        +static bool savefile_menu(void)
        +{
        +	int k, sel, max;
        +
        +	int i;
        +
        +	byte x, y;
        +
        +	char buf[256];
        +
        +	char ind;
        +
        +	/* No savefile has been loaded yet */
        +	character_loaded = FALSE;
        +
        +	/* Wipe the player */
        +	player_wipe(TRUE);
        +
        +	/* Load savefile records, leave room for two miscellaneous menu choices */
        +	max = load_savefile_names() + 2;
        +
        +	/* Highlight the most recent savefile, or "create new character" */
        +	if (max > 2) sel = 2;
        +	else         sel = 0;
        +
        +
        +	/* Clear screen */
        +	(void)Term_clear();
        +
        +	/* Interact with the menu */
        +	while (TRUE)
        +	{
        +		/* Build a header, center it */
        +		center_string(buf, sizeof(buf),
        +			format("Welcome to %s.  To play you will need a character.", VERSION_NAME),
        +			display_width());
        +
        +		/* Display the header */
        +		c_put_str(TERM_L_BLUE, buf, 1, 1);
        +
        +		/* Show available commands */
        +		c_put_str(TERM_L_BLUE, "  8/2/4/6) Movement keys            RETURN) Select",
        +			22, 11);
        +		c_put_str(TERM_L_BLUE, format("Backspace) Delete a savefile           ESC) Exit %s",
        +			VERSION_NAME), 23, 11);
        +
        +		/* Display the menu choices */
        +		for (i = 0; i < max; i++)
        +		{
        +			ind = I2A(i % 26);
        +			if (i >= 26) ind = my_toupper(ind);
        +
        +			/* Get text for this menu option */
        +			if      (i == 0) (void)strnfmt(buf, sizeof(buf), "%c) New Character", ind);
        +			else if (i == 1) (void)strnfmt(buf, sizeof(buf), "%c) Load Savefile", ind);
        +			else             (void)strnfmt(buf, sizeof(buf), "%c) %s", ind, savefile_names[i - 2]);
        +
        +			/* Display this menu option */
        +			y = 6 + (i / 4);
        +			x = 20 * (i % 4) + 1;
        +			c_put_str(((sel == i) ? TERM_L_BLUE : TERM_WHITE), buf, y, x);
        +
        +			/* This menu choice is selected */
        +			if (sel == i)
        +			{
        +				/* Load an existing savefile in the list */
        +				if (i >= 2)
        +				{
        +					/* Color depending on dead or alive */
        +					int attr = ((savefile_alive[i - 2]) ? TERM_L_GREEN : TERM_L_RED);
        +
        +					c_prt(attr, format("%s", savefile_desc[i - 2]), 4, 1);
        +				}
        +
        +				/* Load an existing savefile not in the list */
        +				else if (i == 1)
        +				{
        +					c_prt(TERM_WHITE, "Load an existing savefile not in the list", 4, 1);
        +				}
        +
        +				/* Create a new character */
        +				else
        +				{
        +					c_prt(TERM_WHITE, "Create a new character", 4, 1);
        +				}
        +			}
        +		}
        +
        +		y = 6 + (sel / 4);
        +		x = 20 * (sel % 4) + 1;
        +
        +		/* Move the cursor to the letter of the selection */
        +		(void)Term_gotoxy(x, y);
        +
        +		/* Get response */
        +		k = inkey();
        +
        +		/* Process commands */
        +		if (k == ESCAPE)
        +		{
        +			quit(NULL);
        +		}
        +		else if ((k == '6') || ((rogue_like_commands) && (k == 'l')))
        +		{
        +			/* Go forward one menu item, wrap */
        +			if (++sel >= max) sel = 0;
        +			continue;
        +		}
        +		else if ((k == '4') || ((rogue_like_commands) && (k == 'h')))
        +		{
        +			/* Go back one menu item, wrap */
        +			if (--sel < 0) sel = max - 1;
        +			continue;
        +		}
        +		else if ((k == '2') || ((rogue_like_commands) && (k == 'j')))
        +		{
        +			/* Go down one line of the menu */
        +			if (sel < max - 4) sel += 4;
        +			continue;
        +		}
        +		else if ((k == '8') || ((rogue_like_commands) && (k == 'k')))
        +		{
        +			/* Go up one line of the menu */
        +			if (sel >= 4) sel -= 4;
        +			continue;
        +		}
        +		else if ((k == '\r') || (k == '\n'))
        +		{
        +			/* Choose this menu option */
        +			if (sel < 26) k = I2A(sel);
        +			else k = toupper(I2A(sel));
        +		}
        +
        +		/* Delete savefile */
        +		else if (((k == 0x7F) || (k == '\010')) && (sel >= 2))
        +		{
        +			char filename[1024];
        +			char tmp[50];
        +
        +			if (!get_check(format("Really delete '%s'?", savefile_names[sel - 2]))) continue;
        +
        +			/* Append user ID to filename if necessary */
        +#ifdef SAVEFILE_USE_UID
        +			(void)strnfmt(tmp, sizeof(tmp),"%d.%s", player_uid, savefile_names[sel - 2]);
        +#else
        +			(void)strnfmt(tmp, sizeof(tmp), "%s", savefile_names[sel - 2]);
        +#endif
        +
        +			/* Build the file name */
        +			(void)path_build(filename, sizeof(filename), ANGBAND_DIR_SAVE, tmp);
        +
        +			/* Delete this file */
        +			(void)file_delete(filename);
        +
        +			/* Reload the savefile record */
        +			max = load_savefile_names() + 2;
        +			if (max > 2) sel = 2;
        +			else         sel = 0;
        +
        +			/* Clear screen */
        +			(void)Term_clear();
        +
        +			continue;
        +		}
        +
        +		if (k == 'a')
        +		{
        +			return (TRUE);
        +		}
        +		if (k == 'b')
        +		{
        +			/* Display prompt */
        +			prt("Enter the name of a savefile: ", 23, 0);
        +
        +			/* Ask the user for a string */
        +			if (!askfor_aux(op_ptr->full_name, 30, FALSE)) continue;
        +
        +			/* Process the player name, change savefile name */
        +			process_player_name(TRUE);
        +
        +			return (FALSE);
        +		}
        +		else
        +		{
        +			int x;
        +
        +			/* Process command */
        +			if (islower(k)) x = A2I(k);
        +			else x = A2I(my_tolower(k)) + 26;
        +
        +			/* Stay legal */
        +			if ((x < 2) || (x >= max)) continue;
        +
        +			/* Get player name */
        +			(void)strnfmt(op_ptr->full_name, sizeof(op_ptr->full_name), "%s", savefile_names[x - 2]);
        +
        +			/* Process the player name, change savefile name */
        +			process_player_name(TRUE);
        +
        +			return (FALSE);
        +		}
        +	}
        +
        +	/* Return */
        +	return (FALSE);
        +}
        +
        +
        +/*
        + * Load a character.
        + *
        + * When the game starts, this function is called to handle savefile loading.
        + * We automatically load the most recent savefile recorded in our savefile
        + * record.  If this fails, we load any savefile named "player" (this
        + * replicates the old behavior).  Otherwise we load nothing and show the
        + * savefile management screen.  -LM-
        + *
        + * An option exists to go directly to the savefile management menu.  This is
        + * used if the player deliberately calls this function.
        + *
        + * As has traditionally been the case, we use "PLAYER" as a default savefile
        + * name.
        + *
        + * This function must cooperate with the menu commands offered by various
        + * ports.  XXX XXX XXX
        + */
        +void savefile_load(bool force_menu)
        +{
        +	bool new_game;
        +
        +	/* Load the savefile record */
        +	int max = load_savefile_names();
        +
        +
        +	/* No savefile has been loaded yet */
        +	character_loaded = FALSE;
        +
        +	/* We're not forcing menus */
        +	if (!force_menu)
        +	{
        +		/* Non-empty savefile record, most recent char is alive */
        +		if ((max > 0) && (savefile_alive[0]))
        +		{
        +			/* Store the base name of the most recent savefile entry */
        +			strcpy(op_ptr->full_name, savefile_names[0]);
        +
        +			/* Process this base name, change savefile name */
        +			process_player_name(TRUE);
        +
        +			/* Try to load this savefile */
        +			if (old_load()) return;
        +		}
        +
        +		/* We'll always load a savefile named "PLAYER" */
        +
        +		/* Hack -- use "PLAYER" as the base name */
        +		strcpy(op_ptr->base_name, "PLAYER");
        +
        +		/* Process this base name, change savefile name */
        +		process_player_name(TRUE);
        +
        +		/* Try to load the file "PLAYER" */
        +		if (old_load()) return;
        +	}
        +
        +	/* We're forcing a menu, or haven't found an obvious savefile */
        +	if (TRUE)
        +	{
        +		/* Repeat until satisfied */
        +		while (TRUE)
        +		{
        +			int error;
        +
        +			/* Show the menu immediately, store chosen name */
        +			new_game = savefile_menu();
        +
        +			/* We want to start a new game (not using any previous savefile) */
        +			if (new_game)
        +			{
        +				/* Hack -- Default base_name */
        +				strcpy(op_ptr->base_name, "PLAYER");
        +
        +				/* Return */
        +				return;
        +			}
        +
        +			/* Try to load this character */
        +			error = old_load();
        +
        +			/* File is unreadable */
        +			if (!error)
        +			{
        +				/* Oops */
        +				if (!error)
        +				{
        +					msg_format("Sorry, this savefile cannot be read by %s %s.",
        +					VERSION_NAME, VERSION_STRING);
        +				}
        +
        +				/* Oops */
        +				msg_print("Please choose another file or start a new game.");
        +
        +				/* Wait for it */
        +				(void)inkey();
        +			}
        +
        +			/* Successfully loaded an old character (alive or dead) */
        +			else
        +			{
        +				/* Return */
        +				return;
        +			}
        +		}
        +	}
        +}
        +
        Index: savefile.h
        ===================================================================
        --- savefile.h	(revision 5)
        +++ savefile.h	(working copy)
        @@ -29,8 +29,10 @@
         void rd_string(char *str, int max);
         void strip_bytes(int n);
         
        +/* Menu handling */
        +void save_savefile_names(void);
        +void savefile_load(bool force_menu);
         
        -
         /* load.c */
         int rd_randomizer(u32b version);
         int rd_options(u32b version);

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎