1 /*	SCCS Id: @(#)windows.c	3.4	1996/05/19	*/
2 /* Copyright (c) D. Cohrs, 1993. */
3 /* NetHack may be freely redistributed.  See license for details. */
4 
5 #include "hack.h"
6 #ifdef TTY_GRAPHICS
7 #include "wintty.h"
8 #endif
9 #ifdef CURSES_GRAPHICS
10 extern struct window_procs curses_procs;
11 #endif
12 #ifdef X11_GRAPHICS
13 /* cannot just blindly include winX.h without including all of X11 stuff */
14 /* and must get the order of include files right.  Don't bother */
15 extern struct window_procs X11_procs;
16 extern void NDECL(win_X11_init);
17 #endif
18 #ifdef QT_GRAPHICS
19 extern struct window_procs Qt_procs;
20 #endif
21 #ifdef GEM_GRAPHICS
22 #include "wingem.h"
23 #endif
24 #ifdef MAC
25 extern struct window_procs mac_procs;
26 #endif
27 #ifdef BEOS_GRAPHICS
28 extern struct window_procs beos_procs;
29 extern void NDECL(be_win_init);
30 #endif
31 #ifdef AMIGA_INTUITION
32 extern struct window_procs amii_procs;
33 extern struct window_procs amiv_procs;
34 extern void NDECL(ami_wininit_data);
35 #endif
36 #ifdef WIN32_GRAPHICS
37 extern struct window_procs win32_procs;
38 #endif
39 #ifdef GNOME_GRAPHICS
40 #include "winGnome.h"
41 extern struct window_procs Gnome_procs;
42 #endif
43 #ifdef MSWIN_GRAPHICS
44 extern struct window_procs mswin_procs;
45 #endif
46 #ifdef DUMMY_GRAPHICS
47 extern struct window_procs dummy_procs;
48 #endif
49 #ifdef LISP_GRAPHICS
50 #include "winlisp.h"
51 extern struct window_procs lisp_procs;
52 #endif
53 
54 STATIC_DCL void FDECL(def_raw_print, (const char *s));
55 
56 NEARDATA struct window_procs windowprocs;
57 
58 static
59 struct win_choices {
60     struct window_procs *procs;
61     void NDECL((*ini_routine));		/* optional (can be 0) */
62 } winchoices[] = {
63 #ifdef TTY_GRAPHICS
64     { &tty_procs, win_tty_init },
65 #endif
66 #ifdef CURSES_GRAPHICS
67     { &curses_procs, 0 },
68 #endif
69 #ifdef X11_GRAPHICS
70     { &X11_procs, win_X11_init },
71 #endif
72 #ifdef QT_GRAPHICS
73     { &Qt_procs, 0 },
74 #endif
75 #ifdef GEM_GRAPHICS
76     { &Gem_procs, win_Gem_init },
77 #endif
78 #ifdef MAC
79     { &mac_procs, 0 },
80 #endif
81 #ifdef BEOS_GRAPHICS
82     { &beos_procs, be_win_init },
83 #endif
84 #ifdef AMIGA_INTUITION
85     { &amii_procs, ami_wininit_data },		/* Old font version of the game */
86     { &amiv_procs, ami_wininit_data },		/* Tile version of the game */
87 #endif
88 #ifdef WIN32_GRAPHICS
89     { &win32_procs, 0 },
90 #endif
91 #ifdef GNOME_GRAPHICS
92     { &Gnome_procs, 0 },
93 #endif
94 #ifdef MSWIN_GRAPHICS
95     { &mswin_procs, 0 },
96 #endif
97 #ifdef DUMMY_GRAPHICS
98     { &dummy_procs, 0 },
99 #endif
100 #ifdef LISP_GRAPHICS
101     { &lisp_procs, win_lisp_init },
102 #endif
103     { 0, 0 }		/* must be last */
104 };
105 
106 STATIC_OVL
107 void
def_raw_print(s)108 def_raw_print(s)
109 const char *s;
110 {
111     puts(s);
112 }
113 
114 void
choose_windows(s)115 choose_windows(s)
116 const char *s;
117 {
118     register int i;
119 
120     for(i=0; winchoices[i].procs; i++)
121 	if (!strcmpi(s, winchoices[i].procs->name)) {
122 	    windowprocs = *winchoices[i].procs;
123 	    if (winchoices[i].ini_routine) (*winchoices[i].ini_routine)();
124 	    return;
125 	}
126 
127     if (!windowprocs.win_raw_print)
128 	windowprocs.win_raw_print = def_raw_print;
129 
130     raw_printf("Window type %s not recognized.  Choices are:", s);
131     for(i=0; winchoices[i].procs; i++)
132 	raw_printf("        %s", winchoices[i].procs->name);
133 
134     if (windowprocs.win_raw_print == def_raw_print)
135 	terminate(EXIT_SUCCESS);
136     wait_synch();
137 }
138 
139 /*
140  * tty_message_menu() provides a means to get feedback from the
141  * --More-- prompt; other interfaces generally don't need that.
142  */
143 /*ARGSUSED*/
144 char
genl_message_menu(let,how,mesg)145 genl_message_menu(let, how, mesg)
146 char let;
147 int how;
148 const char *mesg;
149 {
150     pline("%s", mesg);
151     return 0;
152 }
153 
154 /*ARGSUSED*/
155 void
genl_preference_update(pref)156 genl_preference_update(pref)
157 const char *pref;
158 {
159 	/* window ports are expected to provide
160 	   their own preference update routine
161 	   for the preference capabilities that
162 	   they support.
163 	   Just return in this genl one. */
164 }
165 /*windows.c*/
166