forked from quozl/netrek-client-cow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helpwin.c
245 lines (212 loc) · 5.96 KB
/
helpwin.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
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* helpwin.c 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.
*
*/
#include "config.h"
#include <stdio.h>
#include "Wlib.h"
#include "defs.h"
#include "struct.h"
#include "data.h"
#include "helpwin.h"
/* this is a set of routines that makes up a multi column help window, * and
* shows just what the keymaps current keymap representation of the * keys
* are. *
*
* fillhelp() handles the filling in if the strings for the help window *
* update_Help_to_Keymap() checks the keymap and sets it up in hte * help
* window. *
*
*
*
* Format for each entry is follows: * first character is the hard-coded
* character representation for the key * in the keymap. Useful for when you
* re-key things. This could confuse * people who do'nt know the keymap
* format. *
*
* the next few spaces are either spaces or keys that also do that * function.
* Note that if you have more than 3 keys set to do the same * thing, they
* will not be displayed. * So, you could, I suppose map everything to 'Q'
* and it would not * show, but that's a pretty bizarre situation. *
*
*
*
* Bugs & Comments: * You have to be sure that helpWin is defined to be big
* enough to handle * all the messages. That's pretty much a trial&error
* by-hand thing * at this point *
*
*/
/* fills in the help window to note all keys also mapped to the listed
* functions */
static void update_Help_to_Keymap(char *helpmessage);
#define HELPMESSAGES (sizeof(help_message)/ sizeof(char *))
/* this is the number of help messages there are */
char *help_message[] =
{
"0 Set speed",
"1 Set speed",
"2 Set speed",
"3 Set speed",
"4 Set speed",
"5 Set speed",
"6 Set speed",
"7 Set speed",
"8 Set speed",
"9 Set speed",
") Speed = 10",
"! Speed = 11",
"@ Speed = 12",
"% Speed = maximum",
"# Speed = 1/2 maximum",
"< Speed down 1",
"> Speed up 1",
"k Course set",
"p Fire phaser beam",
"t Fire photon torpedo",
"f Fire plasma torpedo",
"d Detonate enemy torpedos",
"D Detonate own torpedos",
"L Players list on/off",
"P Planets list on/off",
"S Status graph on/off",
"] Shields on",
"[ Shields off",
"u Shields on/off",
"s Shields on/off",
"i Info on player/planet",
"I Extended info on player",
"b Bomb planet",
"z Beam up armies",
"x Beam down armies",
"c Cloak on/off",
"{ Cloak on",
"} Cloak off",
"T Tractor beam on/off",
"y Pressor beam on/off",
"_ Tractor beam on",
"^ Pressor beam on",
"$ Tractor/pressor beam off",
"R Repair mode on",
"o Orbit planet or dock to base",
"e Docking permission on/off",
"r Refit (change ship type)",
"Q Quit",
"q Fast quit",
"? Message window on/off",
"l Lock on to player/planet",
"; Lock on to planet",
"h Help window on/off",
"w War declarations window on/off",
"N Planet names on/off",
"V Change local planet display",
"B Change galactic planet display",
"* Practice robot or transwarp",
"E Send distress signal",
"F Send armies carried report",
"U Rankings window on/off",
"mA Send message to ALL",
"mT Send message to team",
"/ Sort player list on/off",
": Message logging on/off",
"+ UDP window on/off",
"= Update all",
", Ping stats window on/off",
". Netstat window on/off",
"\\ LagMeter window on/off",
#ifdef SHORT_PACKETS
"` Packet window on/off",
"- Update small",
"| Update medium",
#endif /* SHORT_PACKETS */
" (space) special windows off",
#ifdef NBT
"X Enter macro mode",
"X? Show current macros",
#endif
#ifdef TOOLS
"M Shell tools window on/off",
#endif
#ifdef SOUND
"~ Sound control window on/off",
#endif
"& Reread .xtrekrc",
0
};
#define MAXHELP 40
/* maximum length in characters of key explanation */
void
fillhelp(void)
{
register int i = 0, row, column;
char helpmessage[MAXHELP];
/* 4 column help window. This may be changed depending on font size */
for (column = 0; column < 4; column++)
{
for (row = 1; row < HELPMESSAGES / 4 + 1; row++)
{
if (help_message[i] == 0)
break;
else
{
STRNCPY(helpmessage, help_message[i], sizeof(helpmessage));
update_Help_to_Keymap(helpmessage);
W_WriteText(helpWin, MAXHELP * column, row - 1, textColor,
helpmessage, strlen(helpmessage), W_RegularFont);
i++;
}
}
if (help_message[i] == 0)
break;
}
}
/* this takes the help messages and puts in the keymap, so the player can see
* just what does what!
*
* ordinary format: "U Show rankings window", translatedd here to "[
* sE Computer options window", */
static void
update_Help_to_Keymap(char *helpmessage)
{
int i, num_mapped = 0;
char key;
key = helpmessage[0];
if (key < 32 || key > 126)
{
return;
}
if (strlen(helpmessage) < 6)
{
return;
}
for (i = 0; i < 96; i++)
{
if (mystats->st_keymap[i] != key)
continue;
if (i + 32 == key)
continue; /* it's already there! don't
* * * add it! */
/* we've found a key mapped to key! */
/* the key is i+32 */
num_mapped++;
if (num_mapped > 3)
continue; /* we've found too many! */
/* put the key in the string */
helpmessage[1 + num_mapped] = i + 32;
}
/* clear spaces if any area available */
switch (num_mapped)
{
case 0:
helpmessage[2] = ' ';
case 1:
helpmessage[3] = ' ';
case 2:
helpmessage[4] = ' ';
case 3:
default:
helpmessage[5] = ' ';
}
return;
}