Make watching-screen default sortmode configurable

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@441 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2008-04-06 09:13:50 +00:00
parent fd4f6161e5
commit 146947b386
7 changed files with 30 additions and 10 deletions

5
TODO
View File

@ -1,5 +1,3 @@
-Update dgl-wall.c or fold the functionality into dgl itself.
(see below)
-BUG: cannot quit watching until caught up with the stream.
-make default_fmode configurable, and add config
file command "chmod file mode"
@ -8,9 +6,6 @@
-maybe allow changing the watching-screen &c layouts too?
-add commandline parameters to dgamelaunch:
dgamelaunch --chpasswd "nick" "newpass"
dgamelaunch --wall "message to mail everyone"
these are obviously only for the server admin...
-allow setting the default watch-screen sortmode in config file.
-some games (robotfindskitten?) are not worth saving into ttyrecs, make it configurable.
-allow configuring ttyplay.c; some games may use different clear-screen
commands. (see for example crawl)

View File

@ -83,6 +83,7 @@ cursor { return TYPE_CURSOR; }
"inprogressdir" { return TYPE_PATH_INPROGRESS; }
"game_args" { return TYPE_GAME_ARGS; }
"rc_fmt" { return TYPE_RC_FMT; }
sortmode { return TYPE_WATCH_SORTMODE; }
commands { return TYPE_CMDQUEUE; }
yes { yylval.i = 1; return TYPE_BOOL; }
no { yylval.i = 0; return TYPE_BOOL; }

View File

@ -34,7 +34,7 @@ static const char* lookup_token (int t);
}
%token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX TYPE_MAXNICKLEN
%token TYPE_GAME_SHORT_NAME
%token TYPE_GAME_SHORT_NAME TYPE_WATCH_SORTMODE
%token TYPE_ALLOW_REGISTRATION
%token TYPE_PATH_GAME TYPE_NAME_GAME TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
@ -155,7 +155,20 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
globalconfig.chroot = strdup ($3);
break;
case TYPE_WATCH_SORTMODE:
{
int tmpi, okay = 0;
for (tmpi = 0; tmpi < NUM_SORTMODES; tmpi++)
if (!strcasecmp(SORTMODE_NAME[tmpi], $3 )) {
globalconfig.sortmode = tmpi;
okay = 1;
break;
}
if (!okay)
fprintf(stderr, "%s:%d: unknown sortmode '%s'\n", config, line, $3);
}
break;
case TYPE_PATH_DGLDIR:
if (globalconfig.dglroot) free(globalconfig.dglroot);
@ -512,6 +525,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
| TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; }
| TYPE_RC_FMT { $$ = TYPE_RC_FMT; }
| TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; }
;
%%
@ -538,6 +552,7 @@ const char* lookup_token (int t)
case TYPE_PATH_INPROGRESS: return "inprogressdir";
case TYPE_GAME_ARGS: return "game_args";
case TYPE_RC_FMT: return "rc_fmt";
case TYPE_WATCH_SORTMODE: return "sortmode";
default: abort();
}
}

View File

@ -355,13 +355,16 @@ void
inprogressmenu (int gameid)
{
int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
static dg_sortmode sortmode = SORTMODE_NONE;
static dg_sortmode sortmode = NUM_SORTMODES;
time_t ctime;
struct dg_game **games;
char ttyrecname[130], *replacestr = NULL, gametype[10];
int is_nhext[14];
sigset_t oldmask, toblock;
if (sortmode == NUM_SORTMODES)
sortmode = globalconfig.sortmode;
games = populate_games (gameid, &len);
games = sort_games (games, len, sortmode);

View File

@ -110,6 +110,7 @@ struct dg_globalconfig
char* passwd;
char* lockfile;
int allow_registration; /* allow registering new nicks */
int sortmode; /* default watching-screen sortmode */
struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];
@ -146,11 +147,10 @@ typedef enum
NUM_SORTMODES
} dg_sortmode;
static const char *SORTMODE_NAME[] = {
static const char *SORTMODE_NAME[NUM_SORTMODES] = {
"Unsorted",
"Username",
"Idletime",
"",
"Idletime"
};

View File

@ -528,6 +528,8 @@ create_config ()
if (!globalconfig.allow_registration) globalconfig.allow_registration = 1;
globalconfig.menulist = NULL;
globalconfig.sortmode = SORTMODE_NONE;
if (config)
{
if ((config_file = fopen(config, "r")) != NULL)

View File

@ -19,6 +19,10 @@ allow_new_nicks = yes
# the record/logfile.
maxnicklen = 10
# Set the default watching-screen sorting mode. Can be one of
# "unsorted", "username" or "idletime". Unsorted is the default.
#sortmode = "username"
# Path to a prepared chroot jail.
chroot_path = "/var/lib/dgamelaunch/"