-
Notifications
You must be signed in to change notification settings - Fork 2
/
macrowin.c
122 lines (110 loc) · 2.8 KB
/
macrowin.c
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
/*
* macrowin.c from helpwin.c
* copyright 1993 Nick Trown
* copyright 1991 ERic mehlhaff
* Free to use, hack, etc. Just keep these credits here.
* Use of this code may be dangerous to your health and/or system.
* Its use is at your own risk.
* I assume no responsibility for damages, real, potential, or imagined,
* resulting from the use of it.
* Yeah.....what Eric said...
*/
#include <stdio.h>
#include <string.h>
#include "math.h"
#include <signal.h>
#include <sys/types.h>
#ifdef hpux
#include <time.h>
#else /* hpux */
#include <sys/time.h>
#endif /* hpux */
#include "netrek.h"
/*
Fills in macro window with the macros defined in the .xtrekrc.
*/
#define MAXMACRO 70
/* maximum length in characters of key explanation */
#define MACROLEN 255
/* length of construction string since we don't know how long a macro can be */
void
showMacroWin()
{
if(!macroWin){
macroWin = W_MakeTextWindow("macroWin",WINSIDE,0,90,
feature_lines() + 3 + macrocnt + 3 +
rcd_lines() + 3,
NULL, BORDER);
W_MapWindow(macroWin);
}
else if(W_IsMapped(macroWin))
W_UnmapWindow(macroWin);
else
W_MapWindow(macroWin);
}
/* this actually takes care of features, macros, and rcds */
void
fillmacro()
{
register int row, i;
char macromessage[MACROLEN],
*title;
showFeatures();
row = feature_lines()+3;
/* 4 column macro window. This may be changed depending on font size */
title = "MACROS (<macro-key> <location> <macro>):";
W_WriteText(macroWin, 1, row, W_Yellow, title, strlen(title),
W_RegularFont);
row += 2;
for (i = 0; i < macrocnt; row++, i++) {
if(macro[i].key > MAXASCII)
sprintf(macromessage, "^%c ", macro[i].key-96);
else
sprintf(macromessage, " %c ", macro[i].key);
if (macro[i].type == NEWMMOUSE) {
switch (macro[i].who) {
case MACRO_PLAYER:
strcat(macromessage, " PL MS ");
break;
case MACRO_TEAM:
strcat(macromessage, " TM MS ");
break;
default:
strcat(macromessage, " SELF ");
break;
}
} else {
switch (macro[i].who) {
case 'T':
strcat(macromessage, " TEAM ");
break;
case 'A':
strcat(macromessage, " ALL ");
break;
case 'F':
strcat(macromessage, " FED ");
break;
case 'R':
strcat(macromessage, " ROM ");
break;
case 'K':
strcat(macromessage, " KLI ");
break;
case 'O':
strcat(macromessage, " ORI ");
break;
case '\0':
strcat(macromessage, " SPEC ");
break;
default:
strcat(macromessage, " ---- ");
break;
}
}
strcat(macromessage, macro[i].string);
macromessage[MAXMACRO] = '\0';
W_WriteText(macroWin, 2, row, textColor,
macromessage, strlen(macromessage), W_RegularFont);
}
showRCDs(row);
}