rogue5: add savedir, logfile, bugfixes
This commit is contained in:
parent
3741c4867d
commit
53a15a3e2e
13 changed files with 2124 additions and 1397 deletions
|
|
@ -38,6 +38,7 @@ struct optstruct {
|
|||
typedef struct optstruct OPTION;
|
||||
|
||||
void pr_optname(const OPTION *op);
|
||||
int allowchange(const OPTION *op);
|
||||
|
||||
static const OPTION optlist[] = {
|
||||
{"terse", "Terse output",
|
||||
|
|
@ -79,9 +80,12 @@ option(void)
|
|||
*/
|
||||
for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
|
||||
{
|
||||
pr_optname(op);
|
||||
(*op->o_putfunc)(op->o_opt);
|
||||
waddch(hw, '\n');
|
||||
if (allowchange(op))
|
||||
{
|
||||
pr_optname(op);
|
||||
(*op->o_putfunc)(op->o_opt);
|
||||
waddch(hw, '\n');
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Set values
|
||||
|
|
@ -89,12 +93,16 @@ option(void)
|
|||
wmove(hw, 0, 0);
|
||||
for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
|
||||
{
|
||||
if (!allowchange(op))
|
||||
continue;
|
||||
pr_optname(op);
|
||||
retval = (*op->o_getfunc)(op->o_opt, hw);
|
||||
if (retval)
|
||||
{
|
||||
if (retval == QUIT)
|
||||
break;
|
||||
#if 0
|
||||
/* Support for MINUS removed until this section is rewritten. */
|
||||
else if (op > optlist) { /* MINUS */
|
||||
wmove(hw, (int)(op - optlist) - 1, 0);
|
||||
op -= 2;
|
||||
|
|
@ -105,6 +113,9 @@ option(void)
|
|||
wmove(hw, 0, 0);
|
||||
op--;
|
||||
}
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
@ -418,6 +429,9 @@ parse_opts(char *str)
|
|||
* Look it up and deal with it
|
||||
*/
|
||||
for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
|
||||
{
|
||||
if (!allowchange(op))
|
||||
continue;
|
||||
if (EQSTR(str, op->o_name, len))
|
||||
{
|
||||
if (op->o_putfunc == put_bool) /* if option is a boolean */
|
||||
|
|
@ -471,6 +485,7 @@ parse_opts(char *str)
|
|||
*(int *)op->o_opt = FALSE; /* NOSTRICT */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* skip to start of next option name
|
||||
|
|
@ -499,3 +514,16 @@ strucpy(char *s1, const char *s2, size_t len)
|
|||
}
|
||||
*s1 = '\0';
|
||||
}
|
||||
|
||||
/* Tells whether the user is allowed to change the option. */
|
||||
int
|
||||
allowchange(const OPTION *opt)
|
||||
{
|
||||
if (!use_savedir)
|
||||
return TRUE;
|
||||
if (!strcmp(opt->o_name, "name"))
|
||||
return FALSE;
|
||||
if (!strcmp(opt->o_name, "file"))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue