3
|
1 /* $Id: defwin.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
|
|
2
|
|
3 #ifdef XTREKRC_HELP
|
|
4 /*
|
|
5 * taken from helpwin.c
|
|
6 * (copyright 1991 ERic mehlhaff Free to use, hack, etc. Just keep
|
|
7 * these credits here. Use of this code may be dangerous to your health
|
|
8 * and/or system. Its use is at your own risk. I assume no responsibility for
|
|
9 * damages, real, potential, or imagined, resulting from the use of it.)
|
|
10 *
|
|
11 */
|
|
12
|
|
13 #include <stdio.h>
|
|
14 #include "math.h"
|
|
15 #include <signal.h>
|
|
16 #include <sys/types.h>
|
|
17 #ifdef hpux
|
|
18 #include <time.h>
|
|
19 #else /* hpux */
|
|
20 #include <sys/time.h>
|
|
21 #endif /* hpux */
|
|
22 #include "Wlib.h"
|
|
23 #include "defs.h"
|
|
24 #include "struct.h"
|
|
25 #include "proto.h"
|
|
26 #include "data.h"
|
|
27 #ifndef SVR4
|
|
28 #include <strings.h>
|
|
29 #else
|
|
30 #include <string.h>
|
|
31 #endif
|
|
32
|
|
33 void def_write
|
|
34 P((char *file));
|
|
35
|
|
36 /* this is the number of help messages there are */
|
|
37
|
|
38 #define INT_DEF 0
|
|
39 #define BOOL_DEF 1
|
|
40 #define STR_DEF 2
|
|
41 #define SINT_DEF 3
|
|
42
|
|
43 #define NAME_WIDTH 18
|
|
44 #define VAL_WIDTH 8
|
|
45 #define INDENT 3
|
|
46 #define MAX_VLINES 58
|
|
47
|
|
48 extern int updateSpeed;
|
|
49 #ifdef RECORD
|
|
50 extern char *recordFileName;
|
|
51 #endif
|
|
52
|
|
53 #define DEFMESSAGES (sizeof(def_messages)/ sizeof(struct def))
|
|
54
|
|
55 char *name = NULL, *cloak_chars = NULL, *bmap = NULL, *keymap = NULL, *plist = NULL, *log_file = NULL, *saveFileName = NULL;
|
|
56 int galacticFrequent;
|
|
57
|
|
58 /* sure its a mess, but it gets the job done */
|
|
59
|
|
60 static
|
|
61 struct def {
|
|
62 char *name;
|
|
63 int type;
|
|
64 char *desc;
|
|
65 void *variable;
|
|
66
|
|
67 struct {
|
|
68 int i_value; /* if int or bool */
|
|
69 char *s_value; /* if str */
|
|
70 char *desc;
|
|
71 } values[10];
|
|
72
|
|
73 struct { /* the area of the window this def takes up */
|
|
74 int x, y, rt, bot;
|
|
75 } loc;
|
|
76 } def_messages[] = {
|
|
77
|
|
78 #ifdef AUTHORIZE
|
|
79 {
|
|
80 "useRSA", BOOL_DEF, "Use RSA checking",
|
|
81 &RSA_Client,
|
|
82 {
|
|
83 {
|
|
84 0, NULL, ""
|
|
85 },
|
|
86 {
|
|
87 0, NULL, NULL
|
|
88 },
|
|
89 },
|
|
90 },
|
|
91 #endif
|
|
92 {
|
|
93 "showStats", BOOL_DEF, "Show stats window",
|
|
94 &showStats,
|
|
95 {
|
|
96 {
|
|
97 0, NULL, ""
|
|
98 },
|
|
99 {
|
|
100 0, NULL, NULL
|
|
101 },
|
|
102 },
|
|
103 },
|
|
104 {
|
|
105 "showShields", BOOL_DEF, "Show shields around ship",
|
|
106 &showShields,
|
|
107 {
|
|
108 {
|
|
109 0, NULL, ""
|
|
110 },
|
|
111 {
|
|
112 0, NULL, NULL
|
|
113 },
|
|
114 },
|
|
115 },
|
|
116 {
|
|
117 "keepPeace", BOOL_DEF, "Stay peaceful when reborn",
|
|
118 &keeppeace,
|
|
119 {
|
|
120 {
|
|
121 0, NULL, ""
|
|
122 },
|
|
123 {
|
|
124 0, NULL, NULL
|
|
125 },
|
|
126 },
|
|
127 },
|
|
128 {
|
|
129 "reportKills", BOOL_DEF, "Report kill messages",
|
|
130 &reportKills,
|
|
131 {
|
|
132 {
|
|
133 0, NULL, ""
|
|
134 },
|
|
135 {
|
|
136 0, NULL, NULL
|
|
137 },
|
|
138 },
|
|
139 },
|
|
140 #if 0
|
|
141 {
|
|
142 "altBitmaps", BOOL_DEF, "Use alternate ship bitmaps",
|
|
143 &blk_altbits,
|
|
144 {
|
|
145 {
|
|
146 0, NULL, ""
|
|
147 },
|
|
148 {
|
|
149 0, NULL, NULL
|
|
150 },
|
|
151 },
|
|
152 },
|
|
153 #endif
|
|
154 {
|
|
155 "showStars", BOOL_DEF, "Show star background on tactical",
|
|
156 &blk_showStars,
|
|
157 {
|
|
158 {
|
|
159 0, NULL, ""
|
|
160 },
|
|
161 {
|
|
162 0, NULL, NULL
|
|
163 },
|
|
164 },
|
|
165 },
|
|
166 {
|
|
167 "showMySpeed", BOOL_DEF, "Show speed next to ship",
|
|
168 &showMySpeed,
|
|
169 {
|
|
170 {
|
|
171 0, NULL, ""
|
|
172 },
|
|
173 {
|
|
174 0, NULL, NULL
|
|
175 },
|
|
176 },
|
|
177 },
|
|
178 {
|
|
179 "showTractorPressor", BOOL_DEF, "Show my tract/press",
|
|
180 &showTractorPressor,
|
|
181 {
|
|
182 {
|
|
183 0, NULL, ""
|
|
184 },
|
|
185 {
|
|
186 0, NULL, NULL
|
|
187 },
|
|
188 },
|
|
189 },
|
|
190 {
|
|
191 "showLock", INT_DEF, "Lock display for planets/players",
|
|
192 &showLock,
|
|
193 {
|
|
194 {
|
|
195 0, NULL, "don't show lock"
|
|
196 },
|
|
197 {
|
|
198 1, NULL, "show lock on galactic only"
|
|
199 },
|
|
200 {
|
|
201 2, NULL, "show lock on tactical only"
|
|
202 },
|
|
203 {
|
|
204 3, NULL, "show lock on both"
|
|
205 },
|
|
206 {
|
|
207 0, NULL, NULL
|
|
208 },
|
|
209 }
|
|
210 },
|
|
211 {
|
|
212 "showGrid", BOOL_DEF, "Show grid on galactic",
|
|
213 &drawgrid,
|
|
214 {
|
|
215 {
|
|
216 0, NULL, ""
|
|
217 },
|
|
218 {
|
|
219 0, NULL, NULL
|
|
220 },
|
|
221 },
|
|
222 },
|
|
223 {
|
|
224 "Dashboard", INT_DEF, "Type of dashboard to use",
|
|
225 &Dashboard,
|
|
226 {
|
|
227 {
|
|
228 0, NULL, "text based dashboard"
|
|
229 },
|
|
230 {
|
|
231 1, NULL, "new dashboard"
|
|
232 },
|
|
233 {
|
|
234 2, NULL, "color dashboard"
|
|
235 },
|
|
236 {
|
|
237 3, NULL, "Rainbow Dashboard"
|
|
238 },
|
|
239 {
|
|
240 0, NULL, NULL
|
|
241 },
|
|
242 }
|
|
243 },
|
|
244 {
|
|
245 "cloakChars", STR_DEF, "Cloak chars for map",
|
|
246 &(cloak_chars),
|
|
247 {
|
|
248 {
|
|
249 0, NULL, NULL
|
|
250 },
|
|
251 },
|
|
252 },
|
|
253 {
|
|
254 "logging", BOOL_DEF, "Use message logging",
|
|
255 &logmess,
|
|
256 {
|
|
257 {
|
|
258 0, NULL, ""
|
|
259 },
|
|
260 {
|
|
261 0, NULL, NULL
|
|
262 },
|
|
263 },
|
|
264 },
|
|
265 {
|
|
266 "logFile", STR_DEF, "File to use for message logging",
|
|
267 &(log_file),
|
|
268 {
|
|
269 {
|
|
270 0, NULL, NULL
|
|
271 },
|
|
272 },
|
|
273 },
|
|
274 #ifdef VARY_HULL
|
|
275 {
|
|
276 "warnHull", BOOL_DEF, "Warn hull state based on damage",
|
|
277 &vary_hull,
|
|
278 {
|
|
279 {
|
|
280 0, NULL, ""
|
|
281 },
|
|
282 {
|
|
283 0, NULL, NULL
|
|
284 },
|
|
285 },
|
|
286 },
|
|
287 #endif
|
|
288 {
|
|
289 "warpStreaks", BOOL_DEF, "Streak stars when entering warp",
|
|
290 &warpStreaks,
|
|
291 {
|
|
292 {
|
|
293 0, NULL, ""
|
|
294 },
|
|
295 {
|
|
296 0, NULL, NULL
|
|
297 },
|
|
298 },
|
|
299 },
|
|
300 {
|
|
301 "useMsgw", BOOL_DEF, "Use message window",
|
|
302 &use_msgw,
|
|
303 {
|
|
304 {
|
|
305 0, NULL, ""
|
|
306 },
|
|
307 {
|
|
308 0, NULL, NULL
|
|
309 },
|
|
310 },
|
|
311 },
|
|
312 {
|
|
313 "showShieldDam", BOOL_DEF, "Vary shields based on damage",
|
|
314 &show_shield_dam,
|
|
315 {
|
|
316 {
|
|
317 0, NULL, ""
|
|
318 },
|
|
319 {
|
|
320 0, NULL, NULL
|
|
321 },
|
|
322 },
|
|
323 },
|
|
324 {
|
|
325 "updatesPerSec", SINT_DEF, "No. of updates from server per sec",
|
|
326 &updateSpeed,
|
|
327 {
|
|
328 {
|
|
329 0, NULL, NULL
|
|
330 },
|
|
331 },
|
|
332 },
|
|
333 {
|
|
334 "redrawDelay", SINT_DEF, "Minimum time between redraws (x/10 sec)",
|
|
335 &redrawDelay,
|
|
336 {
|
|
337 {
|
|
338 0, NULL, NULL
|
|
339 },
|
|
340 },
|
|
341 },
|
|
342 {
|
|
343 "extraAlertBorder", BOOL_DEF, "Show alert on local border",
|
|
344 &extraBorder,
|
|
345 {
|
|
346 {
|
|
347 0, NULL, ""
|
|
348 },
|
|
349 {
|
|
350 0, NULL, NULL
|
|
351 },
|
|
352 },
|
|
353 },
|
|
354 {
|
|
355 "galacticFrequent", BOOL_DEF, "Update galactic map frequently",
|
|
356 &galacticFrequent,
|
|
357 {
|
|
358 {
|
|
359 0, NULL, ""
|
|
360 },
|
|
361 {
|
|
362 0, NULL, NULL
|
|
363 },
|
|
364 },
|
|
365 },
|
|
366 #ifdef CONTINUOUS_MOUSE
|
|
367 {
|
|
368 "continuousMouse", BOOL_DEF, "Continuous mouse input",
|
|
369 &continuousMouse,
|
|
370 {
|
|
371 {
|
|
372 0, NULL, ""
|
|
373 },
|
|
374 {
|
|
375 0, NULL, NULL
|
|
376 },
|
|
377 },
|
|
378 },
|
|
379 #endif
|
|
380 {
|
|
381 "tryUdp", BOOL_DEF, "Try UDP automatically",
|
|
382 &tryUdp,
|
|
383 {
|
|
384 {
|
|
385 0, NULL, ""
|
|
386 },
|
|
387 {
|
|
388 0, NULL, NULL
|
|
389 },
|
|
390 },
|
|
391 },
|
|
392 {
|
|
393 "udpClientReceive", INT_DEF, "UDP receive mode",
|
|
394 &udpClientRecv,
|
|
395 {
|
|
396 {
|
|
397 0, NULL, "TCP only"
|
|
398 },
|
|
399 {
|
|
400 1, NULL, "simple UDP"
|
|
401 },
|
|
402 {
|
|
403 2, NULL, "fat UDP"
|
|
404 },
|
|
405 {
|
|
406 3, NULL, "double UDP (obsolete)"
|
|
407 },
|
|
408 {
|
|
409 0, NULL, NULL
|
|
410 },
|
|
411 },
|
|
412 },
|
|
413 {
|
|
414 "udpClientSend", INT_DEF, "UDP send mode",
|
|
415 &udpClientSend,
|
|
416 {
|
|
417 {
|
|
418 0, NULL, "TCP only"
|
|
419 },
|
|
420 {
|
|
421 1, NULL, "simple UDP"
|
|
422 },
|
|
423 {
|
|
424 2, NULL, "enforced UDP (state only)"
|
|
425 },
|
|
426 {
|
|
427 3, NULL, "enforced UDP (state & weapon)"
|
|
428 },
|
|
429 {
|
|
430 0, NULL, NULL
|
|
431 },
|
|
432 },
|
|
433 },
|
|
434 {
|
|
435 "udpSequenceCheck", BOOL_DEF, "UDP sequence checking",
|
|
436 &udpSequenceChk,
|
|
437 {
|
|
438 {
|
|
439 0, NULL, ""
|
|
440 },
|
|
441 {
|
|
442 0, NULL, NULL
|
|
443 },
|
|
444 },
|
|
445 },
|
|
446 {
|
|
447 "sortPlayers", BOOL_DEF, "Sort playerlist by teams",
|
|
448 &sortPlayers,
|
|
449 {
|
|
450 {
|
|
451 0, NULL, ""
|
|
452 },
|
|
453 {
|
|
454 0, NULL, NULL
|
|
455 },
|
|
456 },
|
|
457 },
|
|
458 {
|
|
459 "robsort", BOOL_DEF, "Put enemies on left in sorted playerlist",
|
|
460 &robsort,
|
|
461 {
|
|
462 {
|
|
463 0, NULL, ""
|
|
464 },
|
|
465 {
|
|
466 0, NULL, NULL
|
|
467 },
|
|
468 },
|
|
469 },
|
|
470 {
|
|
471 "hideNoKills", BOOL_DEF, "Replace 0.00 kills with spaces",
|
|
472 &hideNoKills,
|
|
473 {
|
|
474 {
|
|
475 0, NULL, ""
|
|
476 },
|
|
477 {
|
|
478 0, NULL, NULL
|
|
479 },
|
|
480 },
|
|
481 },
|
|
482 {
|
|
483 "showDead", BOOL_DEF, "Show dead in playerlist",
|
|
484 &showDead,
|
|
485 {
|
|
486 {
|
|
487 0, NULL, ""
|
|
488 },
|
|
489 {
|
|
490 0, NULL, NULL
|
|
491 },
|
|
492 },
|
|
493 },
|
|
494 {
|
|
495 "showPreLogins", BOOL_DEF, "Show pre-logins in playerlist",
|
|
496 &showPreLogins,
|
|
497 {
|
|
498 {
|
|
499 0, NULL, ""
|
|
500 },
|
|
501 {
|
|
502 0, NULL, NULL
|
|
503 },
|
|
504 },
|
|
505 },
|
|
506 {
|
|
507 "sortOutfitting", BOOL_DEF, "Sort outfitting ('--') to bottom",
|
|
508 &sortOutfitting,
|
|
509 {
|
|
510 {
|
|
511 0, NULL, ""
|
|
512 },
|
|
513 {
|
|
514 0, NULL, NULL
|
|
515 },
|
|
516 },
|
|
517 },
|
|
518 {
|
|
519 "timerType", INT_DEF, "Type of timer to use",
|
|
520 &timerType,
|
|
521 {
|
|
522 {
|
|
523 0, NULL, "no timer"
|
|
524 },
|
|
525 {
|
|
526 1, NULL, "time of day"
|
|
527 },
|
|
528 {
|
|
529 2, NULL, "time on server"
|
|
530 },
|
|
531 {
|
|
532 3, NULL, "time in ship"
|
|
533 },
|
|
534 {
|
|
535 4, NULL, "user set timer"
|
|
536 },
|
|
537 {
|
|
538 0, NULL, NULL
|
|
539 },
|
|
540 },
|
|
541 },
|
|
542 {
|
|
543 "showGalactic", INT_DEF, "Galactic planet bitmaps",
|
|
544 &showgalactic,
|
|
545 {
|
|
546 {
|
|
547 0, NULL, "show nothing on galactic map"
|
|
548 },
|
|
549 {
|
|
550 1, NULL, "show facilities on galactic map"
|
|
551 },
|
|
552 {
|
|
553 2, NULL, "show owner on galactic map"
|
|
554 },
|
|
555 {
|
|
556 3, NULL, "show surface properties on galactic map"
|
|
557 },
|
|
558 {
|
|
559 4, NULL, "show scout info age on galactic map"
|
|
560 },
|
|
561 {
|
|
562 5, NULL, "show MOO facilities on galactic map"
|
|
563 },
|
|
564 {
|
|
565 0, NULL, NULL
|
|
566 },
|
|
567 },
|
|
568 },
|
|
569 {
|
|
570 "showLocal", INT_DEF, "Local planet bitmaps",
|
|
571 &showlocal,
|
|
572 {
|
|
573 {
|
|
574 0, NULL, "show nothing on local map"
|
|
575 },
|
|
576 {
|
|
577 1, NULL, "show facilities on local map"
|
|
578 },
|
|
579 {
|
|
580 2, NULL, "show owner on local map"
|
|
581 },
|
|
582 {
|
|
583 3, NULL, "show surface properties on local map"
|
|
584 },
|
|
585 {
|
|
586 4, NULL, "show MOO facilities"
|
|
587 },
|
|
588 {
|
|
589 0, NULL, NULL
|
|
590 },
|
|
591 },
|
|
592 },
|
|
593 {
|
|
594 "name", STR_DEF, "Default player name",
|
|
595 &(name),
|
|
596 {
|
|
597 {
|
|
598 0, NULL, NULL
|
|
599 },
|
|
600 },
|
|
601 },
|
|
602 {
|
|
603 "keymap", STR_DEF, "Keyboard map",
|
|
604 &(keymap),
|
|
605 {
|
|
606 {
|
|
607 0, NULL, NULL
|
|
608 },
|
|
609 },
|
|
610 },
|
|
611 {
|
|
612 "buttonmap", STR_DEF, "Mouse button map",
|
|
613 &(bmap),
|
|
614 {
|
|
615 {
|
|
616 0, NULL, NULL
|
|
617 },
|
|
618 },
|
|
619 },
|
|
620 {
|
|
621 "nameMode", BOOL_DEF, "Show names on map/local",
|
|
622 &namemode,
|
|
623 {
|
|
624 {
|
|
625 0, NULL, ""
|
|
626 },
|
|
627 {
|
|
628 0, NULL, NULL
|
|
629 },
|
|
630 },
|
|
631 },
|
|
632 #ifdef SHORT_PACKETS
|
|
633 {
|
|
634 "tryShort", BOOL_DEF, "Try SHORT-PACKETS at startup",
|
|
635 &tryShort,
|
|
636 {
|
|
637 {
|
|
638 0, NULL, ""
|
|
639 },
|
|
640 {
|
|
641 0, NULL, NULL
|
|
642 },
|
|
643 },
|
|
644 },
|
|
645 #endif
|
|
646 #ifdef IGNORE_SIGNALS_SEGV_BUS
|
|
647 {
|
|
648 "ignoreSignals", BOOL_DEF, "Ignore SIGSEGV and SIGBUS",
|
|
649 &ignore_signals,
|
|
650 {
|
|
651 {
|
|
652 0, NULL, ""
|
|
653 },
|
|
654 {
|
|
655 0, NULL, NULL
|
|
656 },
|
|
657 },
|
|
658 },
|
|
659 #endif
|
|
660 #ifdef SHIFTED_MOUSE
|
|
661 {
|
|
662 "shiftedMouse", BOOL_DEF, "More mouse buttons with shift",
|
|
663 &extended_mouse,
|
|
664 {
|
|
665 {
|
|
666 0, NULL, ""
|
|
667 },
|
|
668 {
|
|
669 0, NULL, NULL
|
|
670 },
|
|
671 },
|
|
672 },
|
|
673 #endif
|
|
674 #ifdef BEEPLITE
|
|
675 {
|
|
676 "UseLite", BOOL_DEF, "Use message highliting",
|
|
677 &UseLite,
|
|
678 {
|
|
679 {
|
|
680 0, NULL, ""
|
|
681 },
|
|
682 {
|
|
683 0, NULL, NULL
|
|
684 },
|
|
685 },
|
|
686 },
|
|
687 {
|
|
688 "DefLite", BOOL_DEF, "Use default lites",
|
|
689 &DefLite,
|
|
690 {
|
|
691 {
|
|
692 0, NULL, ""
|
|
693 },
|
|
694 {
|
|
695 0, NULL, NULL
|
|
696 },
|
|
697 },
|
|
698 },
|
|
699 #endif
|
|
700 {
|
|
701 "saveFileName", STR_DEF, "Name to save defaults as(click here)",
|
|
702 &(saveFileName),
|
|
703 {
|
|
704 {
|
|
705 0, NULL, NULL
|
|
706 },
|
|
707 },
|
|
708 },
|
|
709 };
|
|
710
|
|
711 char *
|
|
712 itos(v)
|
|
713 int v;
|
|
714 {
|
|
715 static char value[10];
|
|
716 sprintf(value, "%d", v);
|
|
717 return value;
|
|
718 }
|
|
719
|
|
720 char *
|
|
721 btoa(v)
|
|
722 int v;
|
|
723 {
|
|
724 if (v)
|
|
725 return "on";
|
|
726 else
|
|
727 return "off";
|
|
728 }
|
|
729
|
|
730 static void
|
|
731 def_redraw(d)
|
|
732 struct def *d;
|
|
733 {
|
|
734 int xo = d->loc.x, yo = d->loc.y;
|
|
735 int x, y, j;
|
|
736 char *val;
|
|
737 W_Color col;
|
|
738
|
|
739 x = xo;
|
|
740 y = yo;
|
|
741
|
|
742 W_ClearArea(defWin, d->loc.x, d->loc.y, d->loc.rt - d->loc.x, d->loc.bot - d->loc.y);
|
|
743
|
|
744 W_WriteText(defWin, x, y, W_Yellow, d->name, strlen(d->name),
|
|
745 W_RegularFont);
|
|
746 x += NAME_WIDTH;
|
|
747
|
|
748 W_WriteText(defWin, x, y, textColor, d->desc, strlen(d->desc),
|
|
749 W_RegularFont);
|
|
750 y++;
|
|
751 x = xo + INDENT;
|
|
752
|
|
753 if (d->type != STR_DEF) {
|
|
754 if (!d->values[0].desc && d->variable) {
|
|
755 if (d->type == SINT_DEF)
|
|
756 val = itos(*(int *)d->variable);
|
|
757 else
|
|
758 val = itos(d->values[0].i_value);
|
|
759
|
|
760 W_WriteText(defWin, x, y, W_Green, val, strlen(val),
|
|
761 W_RegularFont);
|
|
762 y++;
|
|
763 }
|
|
764 for (j = 0; d->values[j].desc; j++) {
|
|
765 switch (d->type) {
|
|
766 case INT_DEF:
|
|
767 val = itos(d->values[j].i_value);
|
|
768 if (d->values[j].i_value == *(int *)d->variable) {
|
|
769 col = W_Green;
|
|
770
|
|
771 W_WriteText(defWin, x, y, col, val, strlen(val),
|
|
772 W_RegularFont);
|
|
773 if (W_Mono()) {
|
|
774 W_WriteText(defWin, x + 1, y, col, "*", 1,
|
|
775 W_RegularFont);
|
|
776 }
|
|
777 } else {
|
|
778 col = textColor;
|
|
779
|
|
780 W_WriteText(defWin, x, y, col, val, strlen(val),
|
|
781 W_RegularFont);
|
|
782 }
|
|
783 x = xo + NAME_WIDTH;
|
|
784 W_WriteText(defWin, x, y, col, d->values[j].desc,
|
|
785 strlen(d->values[j].desc), W_RegularFont);
|
|
786 y++;
|
|
787 x = xo + INDENT;
|
|
788 break;
|
|
789
|
|
790 case BOOL_DEF:
|
|
791 val = btoa(*(int *)d->variable);
|
|
792 W_WriteText(defWin, x, y, W_Green, val, strlen(val),
|
|
793 W_RegularFont);
|
|
794 y++;
|
|
795 x = xo + INDENT;
|
|
796 break;
|
|
797 default:
|
|
798 fprintf(stderr, "Unknown type.\n");
|
|
799 break;
|
|
800 }
|
|
801 }
|
|
802 } else if (d->variable && *(int *)d->variable) {
|
|
803 W_WriteText(defWin, x, y, W_Green, (char *)*(int *)d->variable,
|
|
804 strlen((char *)(*(int *)d->variable)),
|
|
805 W_RegularFont);
|
|
806 }
|
|
807 }
|
|
808
|
|
809
|
|
810 void
|
|
811 showdef()
|
|
812 {
|
|
813 register i, j, x = 0, y = 0, xo = 0, yo = 0, max_desc = 0, height = 1, width = 1;
|
|
814 register struct def *d;
|
|
815 char *val;
|
|
816 W_Color col;
|
|
817
|
|
818 name = getdefault("name");
|
|
819 keymap = getdefault("keymap");
|
|
820 /* plist = getdefault ("playerlist");*/
|
|
821 cloak_chars = cloakchars;
|
|
822 bmap = getdefault("buttonmap");
|
|
823 log_file = getdefault("logfile");
|
|
824 galacticFrequent = (mapmode == 2) ? 0 : 1;
|
|
825 if (!saveFileName) {
|
|
826 saveFileName = stringDefault("saveFileName", "~/.paradisesaverc");
|
|
827 saveFileName = expandFilename(saveFileName);
|
|
828 }
|
|
829 if (!defWin)
|
|
830 defWin = W_MakeTextWindow("xtrekrc_help", 1, 100, 174, 60, NULL, NULL, BORDER);
|
|
831
|
|
832 for (i = 0, d = def_messages; i < DEFMESSAGES; i++, d++) {
|
|
833 x = xo;
|
|
834 y = yo;
|
|
835
|
|
836 d->loc.x = x;
|
|
837 d->loc.y = y;
|
|
838
|
|
839 W_WriteText(defWin, x, y, W_Yellow, d->name, strlen(d->name),
|
|
840 W_RegularFont);
|
|
841 x += NAME_WIDTH;
|
|
842
|
|
843 W_WriteText(defWin, x, y, textColor, d->desc, strlen(d->desc),
|
|
844 W_RegularFont);
|
|
845 if ((int)strlen(d->desc) > max_desc) {
|
|
846 max_desc = strlen(d->desc);
|
|
847 width = MAX(width, x + max_desc);
|
|
848 }
|
|
849 y++;
|
|
850 x = xo + INDENT;
|
|
851
|
|
852 if (d->type != STR_DEF) {
|
|
853 if (!d->values[0].desc && d->variable) {
|
|
854 if (d->type == SINT_DEF)
|
|
855 val = itos(*(int *)d->variable);
|
|
856 else
|
|
857 val = itos(d->values[0].i_value);
|
|
858
|
|
859 W_WriteText(defWin, x, y, W_Green, val, strlen(val),
|
|
860 W_RegularFont);
|
|
861 y++;
|
|
862 }
|
|
863 for (j = 0; d->values[j].desc; j++) {
|
|
864 switch (d->type) {
|
|
865 case INT_DEF:
|
|
866 val = itos(d->values[j].i_value);
|
|
867 if (d->values[j].i_value == *(int *)d->variable) {
|
|
868 col = W_Green;
|
|
869
|
|
870 W_WriteText(defWin, x, y, col, val, strlen(val),
|
|
871 W_RegularFont);
|
|
872 if (W_Mono()) {
|
|
873 W_WriteText(defWin, x + 1, y, col, "*", 1,
|
|
874 W_RegularFont);
|
|
875 }
|
|
876 } else {
|
|
877 col = textColor;
|
|
878
|
|
879 W_WriteText(defWin, x, y, col, val, strlen(val),
|
|
880 W_RegularFont);
|
|
881 }
|
|
882 x = xo + NAME_WIDTH;
|
|
883 W_WriteText(defWin, x, y, col, d->values[j].desc,
|
|
884 strlen(d->values[j].desc), W_RegularFont);
|
|
885 y++;
|
|
886 x = xo + INDENT;
|
|
887 break;
|
|
888
|
|
889 case BOOL_DEF:
|
|
890 val = btoa(*(int *)d->variable);
|
|
891 W_WriteText(defWin, x, y, W_Green, val, strlen(val),
|
|
892 W_RegularFont);
|
|
893 y++;
|
|
894 x = xo + INDENT;
|
|
895 break;
|
|
896 default:
|
|
897 fprintf(stderr, "Unknown type.\n");
|
|
898 break;
|
|
899 }
|
|
900 }
|
|
901 } else if (d->variable && *(int *)d->variable) {
|
|
902 W_WriteText(defWin, x, y, W_Green, (char *)*(int *)d->variable,
|
|
903 strlen((char *)(*(int *)d->variable)),
|
|
904 W_RegularFont);
|
|
905 y++;
|
|
906 }
|
|
907 d->loc.rt = xo + max_desc;
|
|
908 d->loc.bot = y + 1;
|
|
909
|
|
910 height = MAX(height, y);
|
|
911 if (y > MAX_VLINES) {
|
|
912 yo = 0;
|
|
913 xo += NAME_WIDTH + max_desc + 2;
|
|
914 max_desc = 0;
|
|
915 } else {
|
|
916 yo = y + 1;
|
|
917 }
|
|
918 }
|
|
919
|
|
920 if (!W_IsMapped(defWin)) {
|
|
921 W_ResizeText(defWin, width, height);
|
|
922 W_MapWindow(defWin);
|
|
923 }
|
|
924 }
|
|
925
|
|
926 void
|
|
927 def_action(ev)
|
|
928 W_Event *ev;
|
|
929 {
|
|
930 int i, j, x, y, line;
|
|
931 register struct def *d;
|
|
932 char buf[100];
|
|
933
|
|
934 x = ev->x;
|
|
935 y = ev->y;
|
|
936 W_TranslatePoints(ev->Window, &x, &y);
|
|
937
|
|
938 for (i = 0, d = def_messages; i < DEFMESSAGES; i++, d++) {
|
|
939 if (y >= d->loc.y && y < d->loc.bot &&
|
|
940 x >= d->loc.x && x < d->loc.rt)
|
|
941 break; /* found it! */
|
|
942 }
|
|
943
|
|
944 if (i >= DEFMESSAGES)
|
|
945 return;
|
|
946
|
|
947 line = y - d->loc.y;
|
|
948
|
|
949 switch (ev->type) {
|
|
950 case W_EV_BUTTON:
|
|
951 switch (d->type) {
|
|
952 case BOOL_DEF:
|
|
953 *(int *)d->variable = !(*(int *)d->variable);
|
|
954 def_redraw(d);
|
|
955 break;
|
|
956 case INT_DEF:
|
|
957 case SINT_DEF:
|
|
958 if (line == 0 || d->type == SINT_DEF) {
|
|
959 switch (ev->key) {
|
|
960 case W_LBUTTON:
|
|
961 (*(int *)d->variable)++;
|
|
962 if (!(*(int *)d->values[*(int *)d->variable].desc))
|
|
963 *(int *)d->variable = 0;
|
|
964 break;
|
|
965 case W_RBUTTON:
|
|
966 (*(int *)d->variable)--;
|
|
967 if (*(int *)d->variable < 0) {
|
|
968 for (j = 0; d->values[j].desc; j++)
|
|
969 /* empty */ ;
|
|
970 *(int *)d->variable = j - 1;
|
|
971 }
|
|
972 break;
|
|
973 case W_MBUTTON:
|
|
974 *(int *)d->variable = 0;
|
|
975 break;
|
|
976 default:
|
|
977 break;
|
|
978 }
|
|
979 } else if (y < d->loc.bot)
|
|
980 *(int *)d->variable = line - 1;
|
|
981 def_redraw(d);
|
|
982 break;
|
|
983 case STR_DEF:
|
|
984 if (d->variable == &saveFileName)
|
|
985 def_write(saveFileName);
|
|
986 break;
|
|
987 default:
|
|
988 break;
|
|
989 }
|
|
990 }
|
|
991 }
|
|
992
|
|
993 void
|
|
994 def_write(file)
|
|
995 char *file;
|
|
996 {
|
|
997 int i;
|
|
998 struct def *d;
|
|
999 FILE *f;
|
|
1000
|
|
1001 f = fopen(file, "w");
|
|
1002
|
|
1003
|
|
1004 for (i = 0, d = def_messages; i < DEFMESSAGES; i++, d++) {
|
|
1005 switch (d->type) {
|
|
1006 case INT_DEF:
|
|
1007 case SINT_DEF:
|
|
1008 fprintf(f, "%s: %d\n", d->name, *(int *)d->variable);
|
|
1009 break;
|
|
1010 case BOOL_DEF:
|
|
1011 fprintf(f, "%s: %s\n", d->name, (*(int *)d->variable ? "on" : "off"));
|
|
1012 break;
|
|
1013 case STR_DEF:
|
|
1014 fprintf(f, "%s: %s\n", d->name, (char *)*(int *)d->variable);
|
|
1015 break;
|
|
1016 }
|
|
1017 }
|
|
1018
|
|
1019 fclose(f);
|
|
1020 }
|
|
1021
|
|
1022
|
|
1023 #endif
|