Move the terminal resize to when you're watching the game.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@501 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
5c0a1876fb
commit
f07d814c27
|
@ -372,7 +372,7 @@ void
|
||||||
inprogressmenu (int gameid)
|
inprogressmenu (int gameid)
|
||||||
{
|
{
|
||||||
const char *selectorchars = "abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ";
|
const char *selectorchars = "abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPRSTUVWXYZ";
|
||||||
int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
|
int i, menuchoice, len = 20, offset = 0;
|
||||||
static dg_sortmode sortmode = NUM_SORTMODES;
|
static dg_sortmode sortmode = NUM_SORTMODES;
|
||||||
time_t ctime;
|
time_t ctime;
|
||||||
struct dg_game **games = NULL;
|
struct dg_game **games = NULL;
|
||||||
|
@ -383,6 +383,9 @@ inprogressmenu (int gameid)
|
||||||
int max_height = -1;
|
int max_height = -1;
|
||||||
int selected = -1;
|
int selected = -1;
|
||||||
|
|
||||||
|
int resizex = -1;
|
||||||
|
int resizey = -1;
|
||||||
|
|
||||||
char *selectedgame = NULL;
|
char *selectedgame = NULL;
|
||||||
|
|
||||||
int abs_max_height;
|
int abs_max_height;
|
||||||
|
@ -559,10 +562,6 @@ inprogressmenu (int gameid)
|
||||||
clear ();
|
clear ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1':
|
|
||||||
doresizewin = (doresizewin ? 0 : 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
case 10:
|
case 10:
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
|
@ -608,32 +607,19 @@ watchgame:
|
||||||
clear ();
|
clear ();
|
||||||
refresh ();
|
refresh ();
|
||||||
endwin ();
|
endwin ();
|
||||||
if (doresizewin)
|
|
||||||
{
|
resizey = games[idx]->ws_row;
|
||||||
/*
|
resizex = games[idx]->ws_col;
|
||||||
* Let curses deal with the resize later. Perhaps this is
|
|
||||||
* not the best way.
|
|
||||||
*/
|
|
||||||
sigemptyset (&toblock);
|
|
||||||
sigaddset (&toblock, SIGWINCH);
|
|
||||||
sigprocmask (SIG_BLOCK, &toblock, &oldmask);
|
|
||||||
printf ("\033[8;%d;%dt",
|
|
||||||
games[idx]->ws_row,
|
|
||||||
games[idx]->ws_col);
|
|
||||||
fflush (stdout);
|
|
||||||
}
|
|
||||||
if (loggedin)
|
if (loggedin)
|
||||||
setproctitle("%s [watching %s]", me->username, chosen_name);
|
setproctitle("%s [watching %s]", me->username, chosen_name);
|
||||||
else
|
else
|
||||||
setproctitle("<Anonymous> [watching %s]", chosen_name);
|
setproctitle("<Anonymous> [watching %s]", chosen_name);
|
||||||
ttyplay_main (ttyrecname, 1);
|
ttyplay_main (ttyrecname, 1, resizex, resizey);
|
||||||
if (loggedin)
|
if (loggedin)
|
||||||
setproctitle("%s", me->username);
|
setproctitle("%s", me->username);
|
||||||
else
|
else
|
||||||
setproctitle("<Anonymous>");
|
setproctitle("<Anonymous>");
|
||||||
initcurses ();
|
initcurses ();
|
||||||
if (doresizewin)
|
|
||||||
sigprocmask (SIG_SETMASK, &oldmask, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
|
|
||||||
While watching a game
|
While watching a game
|
||||||
---------------------
|
---------------------
|
||||||
q returns back to the watching menu.
|
q return back to the watching menu.
|
||||||
m send mail to the player (requires login).
|
m send mail to the player (requires login).
|
||||||
s toggle charset stripping between DEC/IBM/none.
|
s toggle charset stripping between DEC/IBM/none.
|
||||||
|
r resize your terminal to match the player's terminal.
|
||||||
|
|
||||||
|
|
||||||
Press 'q' or space to return to the watching menu.
|
Press 'q' or space to return to the watching menu.
|
||||||
|
|
17
ttyplay.c
17
ttyplay.c
|
@ -61,6 +61,9 @@
|
||||||
int stripped = NO_GRAPHICS;
|
int stripped = NO_GRAPHICS;
|
||||||
static int got_sigwinch = 0;
|
static int got_sigwinch = 0;
|
||||||
|
|
||||||
|
static int term_resizex = -1;
|
||||||
|
static int term_resizey = -1;
|
||||||
|
|
||||||
void
|
void
|
||||||
ttyplay_sigwinch_func(int sig)
|
ttyplay_sigwinch_func(int sig)
|
||||||
{
|
{
|
||||||
|
@ -247,6 +250,10 @@ ttypread (FILE * fp, Header * h, char **buf, int pread)
|
||||||
case 'q':
|
case 'q':
|
||||||
return READ_EOF;
|
return READ_EOF;
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
if (term_resizex > 0 && term_resizey > 0)
|
||||||
|
printf ("\033[8;%d;%dt", term_resizey, term_resizex);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
switch (stripped)
|
switch (stripped)
|
||||||
{
|
{
|
||||||
|
@ -445,7 +452,7 @@ ttypeek (FILE * fp, double speed)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ttyplay_main (char *ttyfile, int mode)
|
ttyplay_main (char *ttyfile, int mode, int resizex, int resizey)
|
||||||
{
|
{
|
||||||
double speed = 1.0;
|
double speed = 1.0;
|
||||||
ReadFunc read_func = ttyread;
|
ReadFunc read_func = ttyread;
|
||||||
|
@ -465,6 +472,12 @@ ttyplay_main (char *ttyfile, int mode)
|
||||||
new.c_cc[VTIME] = 0;
|
new.c_cc[VTIME] = 0;
|
||||||
tcsetattr (0, TCSANOW, &new); /* Make it current */
|
tcsetattr (0, TCSANOW, &new); /* Make it current */
|
||||||
|
|
||||||
|
|
||||||
|
if (resizex > 0 && resizey > 0) {
|
||||||
|
term_resizex = resizex;
|
||||||
|
term_resizey = resizey;
|
||||||
|
}
|
||||||
|
|
||||||
got_sigwinch = 0;
|
got_sigwinch = 0;
|
||||||
old_sigwinch = signal(SIGWINCH, ttyplay_sigwinch_func);
|
old_sigwinch = signal(SIGWINCH, ttyplay_sigwinch_func);
|
||||||
|
|
||||||
|
@ -479,5 +492,7 @@ ttyplay_main (char *ttyfile, int mode)
|
||||||
if (old_sigwinch != SIG_ERR)
|
if (old_sigwinch != SIG_ERR)
|
||||||
signal(SIGWINCH, old_sigwinch);
|
signal(SIGWINCH, old_sigwinch);
|
||||||
|
|
||||||
|
term_resizex = term_resizey = -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ttyrec.h"
|
#include "ttyrec.h"
|
||||||
|
|
||||||
int ttyplay_main (char *ttyfile, int mode);
|
int ttyplay_main (char *ttyfile, int mode, int resizex, int resizey);
|
||||||
|
|
||||||
typedef double (*WaitFunc) (struct timeval prev,
|
typedef double (*WaitFunc) (struct timeval prev,
|
||||||
struct timeval cur, double speed);
|
struct timeval cur, double speed);
|
||||||
|
|
Loading…
Reference in New Issue