5 // for chat or other purposes
6 // - mostly used with the networking settings
13 #include <float.h> // used for _control
16 #include <GL/gl.h> // Header File For The OpenGL32 Library
17 #include <GL/glu.h> // Header File For The GLu32 Library
18 #include <X11/extensions/xf86vmode.h>
19 #include <X11/keysym.h>
24 #include "network/include/connect.h"
27 // bad, bad! using globals
28 extern char network_str_
[22][80];
30 static int current_mode
= SEL_CLIENT_MODE
;
31 static int current_sel
= START_SEL
;
32 static int current_char
[4][2];
34 // the different key entry types
35 static int client_sel
[6] = {
43 static int client_str
[6] = {
51 // server variables //
52 static int server_str
[6] = {
62 static char final_str
[4][80];
65 // The string has to begin at random points
67 static int client_start
[4] = {
73 static int server_start
[4] = {
80 static int server_sel
[6] = {
89 static void Dec_Selection(void);
90 static void Inc_Selection(void);
92 static void Reset_StartChar(void)
96 for (i
= 0; i
< 4; i
++) {
97 current_char
[i
][0] = 0;
98 current_char
[i
][1] = 0;
105 // Finalize_Selection
106 // - connect/disconnect/etc
108 static void Finalize_Selection(void)
111 int tmp_selection
= 0;
116 // the mode effects how to handle input characters
117 if (current_mode
== SEL_CLIENT_MODE
)
122 // collect the current user strings
123 for (i
= 0; i
< 4; i
++)
125 tmp_selection
= client_str
[i
];
126 text_start
= client_start
[i
];
129 for (j
= 0; c
!= '\0'; j
++) {
131 c
= network_str_
[tmp_selection
][text_start
+j
];
134 } // end of the inner for
136 // make sure the string is null terminated
137 final_str
[i
][j
] = '\0';
145 // collect the current user strings
146 for (i
= 0; i
< 4; i
++)
148 tmp_selection
= server_str
[i
];
149 text_start
= server_start
[i
];
152 for (j
= 0; c
!= '\0'; j
++) {
154 c
= network_str_
[tmp_selection
][text_start
+j
];
157 } // end of the inner for
159 // make sure the string is null terminated
160 final_str
[i
][j
] = '\0';
164 } // end of th if - else
166 } // end of the function
170 // - handle normal keys
171 void Alpha_Keys(char *buffer
)
179 int tmp_selection
= 0;
188 if ((current_sel
>= 0) && (current_sel
< 4)) {
194 if (current_sel
== 4) {
196 // process the selection
197 if (current_mode
== SEL_CLIENT_MODE
)
199 Finalize_Selection();
201 // connect to server, the wheels are in motion now
202 Start_Service(final_str
, SEL_CLIENT_MODE
);
204 } else if (current_mode
== SEL_SERVER_MODE
) {
205 Finalize_Selection();
207 // start the server, watch the messages at bottom screen
208 Start_Service(final_str
, SEL_SERVER_MODE
);
211 } // end of if selection = 4
219 // the mode effects how to handle input characters
220 if (current_mode
== SEL_CLIENT_MODE
)
222 input_type
= client_sel
[current_sel
];
224 if ((current_sel
>= 0) && (current_sel
< 4)) {
225 text_start
= client_start
[current_sel
];
226 char_i
= current_sel
;
227 tmp_selection
= client_str
[current_sel
];
234 input_type
= server_sel
[current_sel
];
235 if ((current_sel
>= 0) && (current_sel
< 4)) {
236 text_start
= server_start
[current_sel
];
237 char_i
= current_sel
;
238 tmp_selection
= server_str
[current_sel
];
243 } // end of the if - else
250 if (((c
>= 'a') && (c
<= 'z')) ||
251 ((c
>= 'A') && (c
<= 'Z')))
254 char_start
= current_char
[char_i
][tmp_mode
];
255 network_str_
[tmp_selection
][text_start
+char_start
] = c
;
257 current_char
[char_i
][tmp_mode
]++;
258 if (current_char
[char_i
][tmp_mode
] >= MAX_INPUT_STR
)
259 current_char
[char_i
][tmp_mode
] = MAX_INPUT_STR
;
261 // and dont forget to add a null terminator
262 network_str_
[tmp_selection
][text_start
+char_start
+1] = '\0';
270 if (((c
>= '0') && (c
<= '9')) || (c
== '.'))
273 char_start
= current_char
[char_i
][tmp_mode
];
274 network_str_
[tmp_selection
][text_start
+char_start
] = c
;
276 current_char
[char_i
][tmp_mode
]++;
277 if (current_char
[char_i
][tmp_mode
] >= MAX_INPUT_STR
)
278 current_char
[char_i
][tmp_mode
] = MAX_INPUT_STR
;
280 // and dont forget to add a null terminator
281 network_str_
[tmp_selection
][text_start
+char_start
+1] = '\0';
289 case SEL_TYPE_NOCHANGE
:
295 // clear everything that is already there
297 if (((c
>= 'a') && (c
<= 'z')) ||
298 ((c
>= 'A') && (c
<= 'Z')))
301 // we have only two values
303 // the letters used are random
307 Super_Printf("%c", network_str_
[tmp_selection
][text_start
+char_start
]);
309 if (network_str_
[tmp_selection
][text_start
+char_start
] == 'f') {
311 for (i
= 0; i
< 10; i
++)
312 network_str_
[tmp_selection
][text_start
+i
] = '\0';
314 network_str_
[tmp_selection
][text_start
+char_start
+0] = 't';
315 network_str_
[tmp_selection
][text_start
+char_start
+1] = 'r';
316 network_str_
[tmp_selection
][text_start
+char_start
+2] = 'u';
317 network_str_
[tmp_selection
][text_start
+char_start
+3] = 'e';
318 network_str_
[tmp_selection
][text_start
+char_start
+4] = '\0';
321 for (i
= 0; i
< 10; i
++)
322 network_str_
[tmp_selection
][text_start
+i
] = '\0';
324 network_str_
[tmp_selection
][text_start
+char_start
] = 'f';
325 network_str_
[tmp_selection
][text_start
+char_start
+1] = 'a';
326 network_str_
[tmp_selection
][text_start
+char_start
+2] = 'l';
327 network_str_
[tmp_selection
][text_start
+char_start
+3] = 's';
328 network_str_
[tmp_selection
][text_start
+char_start
+4] = 'e';
329 network_str_
[tmp_selection
][text_start
+char_start
+5] = '\0';
337 case SEL_TYPE_NUMERIC
:
339 if ((c
>= '0') && (c
<= '9'))
342 char_start
= current_char
[char_i
][tmp_mode
];
343 network_str_
[tmp_selection
][text_start
+char_start
] = c
;
345 current_char
[char_i
][tmp_mode
]++;
346 if (current_char
[char_i
][tmp_mode
] >= MAX_INPUT_STR
)
347 current_char
[char_i
][tmp_mode
] = MAX_INPUT_STR
;
349 // and dont forget to add a null terminator
350 network_str_
[tmp_selection
][text_start
+char_start
+1] = '\0';
366 } // end of teh functino
370 // - display the selected network text
372 void Display_NetSel(char str
[26][80])
375 // reset back to the normal setting
376 // reset the other client strings
377 for (i
= 0; i
< 4; i
++)
379 str
[client_str
[i
] ][0] = ':';
380 str
[client_str
[i
] ][1] = ':';
383 for (i
= 0; i
< 4; i
++)
385 str
[server_str
[i
] ][0] = ':';
386 str
[server_str
[i
] ][1] = ':';
390 // clear the connect strings
391 for (i
= 4; i
< 6; i
++)
393 str
[client_str
[i
] ][0] = ' ';
394 str
[client_str
[i
] ][1] = ' ';
396 str
[server_str
[i
] ][0] = ' ';
397 str
[server_str
[i
] ][1] = ' ';
402 if (current_mode
== SEL_CLIENT_MODE
)
405 // change the string to signify selection
406 if ((current_sel
>= 0) && (current_sel
< 4)) {
407 str
[client_str
[current_sel
] ][0] = '>';
408 str
[client_str
[current_sel
] ][1] = '>';
411 if ((current_sel
>= 4) && (current_sel
< 6)) {
412 str
[client_str
[current_sel
] ][0] = '>';
413 str
[client_str
[current_sel
] ][1] = '>';
417 } else if (current_mode
== SEL_SERVER_MODE
) {
419 if ((current_sel
>= 0) && (current_sel
< 4)) {
420 str
[server_str
[current_sel
] ][0] = '>';
421 str
[server_str
[current_sel
] ][1] = '>';
424 if ((current_sel
>= 4) && (current_sel
< 6)) {
425 str
[server_str
[current_sel
] ][0] = '>';
426 str
[server_str
[current_sel
] ][1] = '>';
431 } // end of the function
436 static void Inc_Selection(void)
442 if (current_mode
== SEL_SERVER_MODE
)
445 max1
= SEL_SERVER_MAX
+ 1;
447 } else if (current_mode
== SEL_CLIENT_MODE
) {
449 max1
= SEL_CLIENT_MAX
+ 1;
454 if (current_sel
>= max1
)
456 current_sel
= START_SEL
;
459 } // end of the function
464 static void Dec_Selection(void)
470 if (current_mode
== SEL_SERVER_MODE
)
473 max1
= SEL_SERVER_MAX
;
475 } else if (current_mode
== SEL_CLIENT_MODE
) {
477 max1
= SEL_CLIENT_MAX
;
492 void Cmd_Keys(KeySym key
)
495 // make sure we are in the correct mode
496 if (ant_globals
->menu_mode
== MENU_SETTINGS_MODE
)
514 if (current_mode
== SEL_SERVER_MODE
)
515 current_mode
= SEL_CLIENT_MODE
;
517 current_mode
= SEL_SERVER_MODE
;
532 } // end of the function