Prevent changing name or savefile when SAVEDIR is used.

This commit is contained in:
John "Elwin" Edwards 2010-11-27 16:22:30 +00:00
parent 20d469d64f
commit a90fd134ba
2 changed files with 29 additions and 7 deletions

View file

@ -40,6 +40,10 @@ OPTION optlist[] = {
{ "file", "Save file: ", file_name }
};
#define NUM_OPTS (sizeof optlist / sizeof (OPTION))
OPTION safeoptlist[] = {
{ "fruit", "Fruit: ", fruit },
};
#define NUM_SOPTS (sizeof safeoptlist / sizeof (OPTION))
/*
* print and then set options from the terminal
@ -48,14 +52,25 @@ option()
{
reg OPTION *op;
reg int wh;
OPTION *olist;
int olen;
if (use_savedir) {
olist = safeoptlist;
olen = NUM_SOPTS;
}
else {
olist = optlist;
olen = NUM_OPTS;
}
wclear(hw);
touchwin(hw);
/*
* Display current values of options
*/
for (op = optlist; op < &optlist[NUM_OPTS]; op++) {
wh = op - optlist;
for (op = olist; op < &olist[olen]; op++) {
wh = op - olist;
mvwaddstr(hw, wh, 0, op->o_prompt);
mvwaddstr(hw, wh, 16, op->o_opt);
}
@ -63,13 +78,13 @@ option()
* Set values
*/
wmove(hw, 0, 0);
for (op = optlist; op < &optlist[NUM_OPTS]; op++) {
wmove(hw, op - optlist, 16);
for (op = olist; op < &olist[olen]; op++) {
wmove(hw, op - olist, 16);
if ((wh = get_str(op->o_opt, hw))) {
if (wh == QUIT)
break;
else if (op > optlist) {
wmove(hw, op - optlist, 0);
else if (op > olist) {
wmove(hw, op - olist, 0);
op -= 2;
}
else {

View file

@ -58,7 +58,10 @@ save_game()
mpos = 0;
if (file_name[0] != '\0') {
msg("Save file (%s)? ", file_name);
if (use_savedir)
msg("Save game? (y/n) ");
else
msg("Save file (%s)? ", file_name);
do {
c = wgetch(cw);
if(c == ESCAPE) {
@ -70,6 +73,10 @@ save_game()
if (c == 'y')
goto gotfile;
}
if (use_savedir) {
msg("");
return FALSE;
}
msg("File name: ");
mpos = 0;
buf[0] = '\0';