File: uimisc.c

package info (click to toggle)
conquest 8.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,984 kB
  • ctags: 3,086
  • sloc: ansic: 39,393; sh: 8,540; yacc: 446; makefile: 296; lex: 146
file content (213 lines) | stat: -rw-r--r-- 5,135 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* 
 * record.c - recording games in conquest
 *
 * $Id: uimisc.c,v 1.4 2004/08/22 22:01:28 jon Exp $
 *
 * Copyright 1999-2004 Jon Trulson under the ARTISTIC LICENSE. (See LICENSE).
 */
#include "c_defs.h"
#include "global.h"
#include "conqdef.h"
#include "conqcom.h"
#include "context.h"
#include "conf.h"
#include "global.h"
#include "color.h"
#include "datatypes.h"
#include "record.h"

void dspReplayMenu(void)
{
  int lin, col;
  char *c;
  int i;
  char cbuf[MSGMAXLINE];
  static int FirstTime = TRUE;
  static char sfmt[MSGMAXLINE * 2];
  static char cfmt[MSGMAXLINE * 2];
  static char recordedon[MSGMAXLINE];
  extern char *ConquestVersion;
  extern char *ConquestDate;

  if (FirstTime == TRUE)
    {
      FirstTime = FALSE;
      sprintf(sfmt,
	      "#%d#%%s#%d#: %%s",
	      InfoColor,
	      GreenColor);
      
      sprintf(cfmt,
              "#%d#(#%d#%%c#%d#) - %%s",
              LabelColor,
              InfoColor,
              LabelColor);

      strncpy(recordedon, ctime((time_t *)&fhdr.rectime), MSGMAXLINE - 1);
      recordedon[MSGMAXLINE - 1] = EOS;

      for (i=0; i < strlen(recordedon); i++)
        if (recordedon[i] == '\n')
          recordedon[i] = EOS;
    }


  lin = 1;
  cprintf(lin, 0, ALIGN_CENTER, "#%d#CONQUEST REPLAY PROGRAM",
          NoColor|CQC_A_BOLD);
  sprintf( cbuf, "%s (%s)",
           ConquestVersion, ConquestDate);
  cprintf(lin+1, 0, ALIGN_CENTER, "#%d#%s",
          YellowLevelColor, cbuf);
  
  lin+=3;
  
  cprintf(lin,0,ALIGN_CENTER,"#%d#%s",NoColor, "Recording info:");
  lin+=2;
  
  col = 5;
  
  cprintf(lin,col,ALIGN_NONE,sfmt, "File               ", rfname);
  lin++;
  
  cprintf(lin,col,ALIGN_NONE,sfmt, "Recorded By        ", fhdr.user);
  lin++;
  
  if (fhdr.snum == 0)
    cprintf(lin,col,ALIGN_NONE,sfmt, "Recording Type     ", "Server");
  else
    {
      sprintf(cbuf, "Client (Ship %d)", fhdr.snum);
      cprintf(lin,col,ALIGN_NONE,sfmt, "Recording Type     ", cbuf);
    }
  lin++;
  
  cprintf(lin,col,ALIGN_NONE,sfmt, "Recorded On        ", recordedon);

  lin++;
  sprintf(cbuf, "%d (delay: %0.3fs)", fhdr.samplerate, framedelay);
  cprintf(lin,col,ALIGN_NONE,sfmt, "Updates per second ", cbuf);
  lin++;
  fmtseconds(totElapsed, cbuf);
  
  if (cbuf[0] == '0')	/* see if we need the day count */
    c = &cbuf[2];	
  else
    c = cbuf;
  
  cprintf(lin,col,ALIGN_NONE,sfmt, "Total Game Time    ", c);
  lin++;
  fmtseconds((currTime - startTime), cbuf);
  
  if (cbuf[0] == '0')
    c = &cbuf[2];	
  else
    c = cbuf;
  cprintf(lin,col,ALIGN_NONE,sfmt, "Current Time       ", c);
  lin++;
  lin++;
  
  cprintf(lin,0,ALIGN_CENTER,"#%d#%s",NoColor, "Commands:");
  lin+=3;
  
  cprintf(lin,col,ALIGN_NONE,cfmt, 'w', "watch a ship");
  lin++;
  cprintf(lin,col,ALIGN_NONE,cfmt, '/', "list ships");
  lin++;
  cprintf(lin,col,ALIGN_NONE,cfmt, 'r', "reset to beginning");
  lin++;
  cprintf(lin,col,ALIGN_NONE,cfmt, 'q', "quit");
  lin++;
  
  return;
}

/* display help for replaying */
void dspReplayHelp(void)
{
  int lin, col, tlin;
  static int FirstTime = TRUE;
  static char sfmt[MSGMAXLINE * 2];

  if (FirstTime == TRUE)
    {
      FirstTime = FALSE;
      sprintf(sfmt,
	      "#%d#%%-9s#%d#%%s",
	      InfoColor,
	      LabelColor);
	}

  cprintf(1,0,ALIGN_CENTER,"#%d#%s", LabelColor, "WATCH WINDOW COMMANDS");
  
  lin = 4;
  
  /* Display the left side. */
  tlin = lin;
  col = 4;
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "w", "watch a ship");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, 
  	"<>", "decrement/increment ship number\n");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "/", "player list");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "f", "forward 30 seconds");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "F", "forward 2 minutes");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "b", "backward 30 seconds");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "B", "backward 2 minutes");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "r", "reset to beginning");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "q", "quit");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "[SPACE]", "pause/resume playback");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "-", "slow down playback by doubling the frame delay");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "+", "speed up playback by halfing the frame delay");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "M", "short/long range sensor toggle");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "n", "reset to normal playback speed");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "`", "toggle between two ships");
  tlin++;
  cprintf(tlin,col,ALIGN_NONE,sfmt, "!", "display toggle line");

  return;
}

/* get the 'real' strlen of a string, skipping past any embedded colors */
int uiCStrlen(char *buf)
{
  register char *p;
  register int l;

  l = 0;
  p = buf;
  while (*p)
    {
      if (*p == '#')
        {                       /* a color sequence */
          p++;
          while (*p && isdigit(*p))
            p++;

          if (*p == '#')
            p++;
        }
      else
        {
          p++;
          l++;
        }
    }

  return l;
}