1 /*
2 * file menu_game.c - menus for setting up game parameters
3 *
4 * $Id: menu_game.c,v 1.17 2006/06/13 11:10:38 fzago Exp $
5 *
6 * Program XBLAST
7 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2; or (at your option)
12 * any later version
13 *
14 * This program is distributed in the hope that it will be entertaining,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "xblast.h"
25
26 /*
27 * local constants
28 */
29 #define ANIME_LENGTH 4
30
31 /*
32 * local variables
33 */
34 static XBPlayerHost hostType;
35 static XBMenuLevelPar mlp;
36 /* game config */
37 static CFGGameSetup gameSetup = {
38 XBFalse, /* respect the number of lives dictated by level */
39 1, /* number of lives */
40 9, /* number victories */
41 30, /* frame rate */
42 XBTrue, /* select all levels */
43 XBTrue, /* random level order */
44 XBTrue, /* random player positions */
45 0, /* level order */
46 15, /* info wait time */
47 XBFalse, /* demo on DEMOFIX */
48 XBTM_None, /* team mode */
49 XBTrue, /* XBCC not rated */
50 XBFalse, /* bot */
51 2, /* number of rec lives (valid if 1. XBTrue) */
52 };
53 static MENU_ID idButtonCentral;
54 static MENU_ID idButtonStart;
55 static MENU_ID idButtonLevels;
56 /* player controls */
57 static XBAtom _gamePlayers[NUM_LOCAL_PLAYER];
58 static const XBPlayerControl _gameControl[NUM_LOCAL_PLAYER] = {
59 XBPC_RightKeyboard,
60 XBPC_LeftKeyboard,
61 XBPC_Joystick1,
62 XBPC_Joystick2,
63 XBPC_Joystick3,
64 XBPC_Joystick4,
65 };
66 static const char *playerControl[NUM_LOCAL_PLAYER] = {
67 N_("Right Keyboard:"),
68 N_("Left Keyboard:"),
69 N_("Joystick 1:"),
70 N_("Joystick 2:"),
71 N_("Joystick 3:"),
72 N_("Joystick 4:"),
73 };
74
75 /* local player selection */
76 static XBComboEntryList *playerList = NULL;
77 /* number of lives */
78 static XBComboEntryList numLivesList[] = {
79 {"1", 1, NULL, ATOM_INVALID,},
80 {"2", 2, NULL, ATOM_INVALID,},
81 {"3", 3, NULL, ATOM_INVALID,},
82 {NULL, 0, NULL, ATOM_INVALID,},
83 };
84 static XBComboEntryList numWinsList[] = {
85 {"1", 1, NULL},
86 {"2", 2, NULL},
87 {"3", 3, NULL},
88 {"4", 4, NULL},
89 {"5", 5, NULL},
90 {"6", 6, NULL},
91 {"7", 7, NULL},
92 {"8", 8, NULL},
93 {"9", 9, NULL},
94 {NULL, 0, NULL},
95 };
96 static XBComboEntryList waitInfoList[] = { // LRF
97 {"1", 1, NULL, ATOM_INVALID,},
98 {"2", 2, NULL, ATOM_INVALID,},
99 {"3", 3, NULL, ATOM_INVALID,},
100 {"4", 4, NULL, ATOM_INVALID,},
101 {"5", 5, NULL, ATOM_INVALID,},
102 {"7", 7, NULL, ATOM_INVALID,},
103 {"10", 10, NULL, ATOM_INVALID,},
104 {"15", 15, NULL, ATOM_INVALID,},
105 {"20", 20, NULL, ATOM_INVALID,},
106 {"30", 30, NULL, ATOM_INVALID,},
107 {NULL, 0, NULL, ATOM_INVALID,},
108 };
109 static XBComboEntryList levelOrderList[] = { // LRF
110 {N_("Alphabetic"), 1, NULL, ATOM_INVALID,},
111 {N_("Random"), 2, NULL, ATOM_INVALID,},
112 {N_("Time"), 3, NULL, ATOM_INVALID,},
113 {NULL, 0, NULL, ATOM_INVALID,},
114 };
115 static XBComboEntryList musicList[] = { // LRF
116 {"None", 0, NULL, ATOM_INVALID,},
117 {"Song1", SND_SNG1, NULL, ATOM_INVALID,},
118 {"Song2", SND_SNG2, NULL, ATOM_INVALID,},
119 {"Song3", SND_SNG3, NULL, ATOM_INVALID,},
120 {"Song4", SND_SNG4, NULL, ATOM_INVALID,},
121 {"Song5", SND_SNG5, NULL, ATOM_INVALID,},
122 {"Song6", SND_SNG6, NULL, ATOM_INVALID,},
123 {NULL, 0, NULL, ATOM_INVALID,},
124 };
125 static XBComboEntryList frameRateList[] = {
126 {"10", 10, NULL, ATOM_INVALID,},
127 {"12", 12, NULL, ATOM_INVALID,},
128 {"14", 14, NULL, ATOM_INVALID,},
129 {"16", 16, NULL, ATOM_INVALID,},
130 {"18", 18, NULL, ATOM_INVALID,},
131 {"20", 20, NULL, ATOM_INVALID,},
132 {"22", 22, NULL, ATOM_INVALID,},
133 {"24", 24, NULL, ATOM_INVALID,},
134 {"26", 26, NULL, ATOM_INVALID,},
135 {"28", 28, NULL, ATOM_INVALID,},
136 {"30", 30, NULL, ATOM_INVALID,},
137 {"32", 32, NULL, ATOM_INVALID,},
138 {"34", 35, NULL, ATOM_INVALID,},
139 {"36", 36, NULL, ATOM_INVALID,},
140 {"40", 40, NULL, ATOM_INVALID,},
141 {"45", 45, NULL, ATOM_INVALID,},
142 {"50", 50, NULL, ATOM_INVALID,},
143 {"60", 60, NULL, ATOM_INVALID,},
144 {"72", 72, NULL, ATOM_INVALID,},
145 {"85", 85, NULL, ATOM_INVALID,},
146 {"100", 100, NULL, ATOM_INVALID,},
147 {NULL, 0, NULL, ATOM_INVALID,},
148 };
149
150 #ifdef DEBUG_TEAM
151 static XBComboEntryList teamModeList[] = {
152 {N_("None"), XBTM_None, NULL},
153 {N_("Team"), XBTM_Team, NULL},
154 {NULL, 0, NULL},
155 };
156 #endif
157 static BMSpriteAnimation playerAnime[ANIME_LENGTH] = {
158 SpriteStopDown, SpriteWinner3, SpriteWinner2, SpriteWinner,
159 };
160
161 XBBool autoCentral = XBFalse;
162
163 /*
164 * delete player confiug array for combo box
165 */
166 static void
DeletePlayerConfigList(XBComboEntryList * list)167 DeletePlayerConfigList (XBComboEntryList * list)
168 {
169 int i;
170
171 assert (list != NULL);
172 i = 0;
173 while (list[i].text != NULL) {
174 if (NULL != list[i].data) {
175 free (list[i].data);
176 }
177 i++;
178 }
179 free (list);
180 } /* DeletePlayerConfigList */
181
182 /*
183 * Convert player config array to combo list
184 */
185 static XBComboEntryList *
CreatePlayerConfigList(void)186 CreatePlayerConfigList (void)
187 {
188 XBComboEntryList *list;
189 int i, num;
190 CFGPlayerGraphics *gfx;
191
192 num = GetNumPlayerConfigs (CT_Local);
193 /* alloc list */
194 list = calloc (2 + num, sizeof (XBComboEntryList));
195 assert (list != NULL);
196 /* fill list */
197 for (i = 0; i < num; i++) {
198 XBAtom atom = GetPlayerAtom (CT_Local, i);
199 list[i].atom = atom;
200 list[i].text = GetPlayerName (CT_Local, atom);
201 gfx = calloc (1, sizeof (CFGPlayerGraphics));
202 if (RetrievePlayerGraphics (CT_Local, atom, COLOR_INVALID, gfx)) {
203 list[i].data = gfx;
204 }
205 else {
206 free (gfx);
207 }
208 }
209 list[i].atom = ATOM_INVALID;
210 list[i].text = "none";
211 list[i].data = NULL;
212 return list;
213 } /* CreatePlayerConfigList */
214
215 /*
216 *
217 */
218 static XBBool
ButtonMainMenu(void * par)219 ButtonMainMenu (void *par)
220 {
221 /* clear player list */
222 if (NULL != playerList) {
223 DeletePlayerConfigList (playerList);
224 playerList = NULL;
225 }
226 /* call main menu */
227 return CreateMainMenu (par);
228 } /* ButtonMainMenu */
229
230 /*
231 *
232 */
233 static XBBool
ButtonStartLocalGame(void * par)234 ButtonStartLocalGame (void *par)
235 {
236 /* clean up */
237 MenuClear ();
238 return XBTrue;
239 } /* set game config */
240
241 #ifdef DEBUG_TEAM
242
243 /*
244 *
245 */
246 static void
AssignRandomTeams(XBTeamMode mode,int num,XBPlayerTeam * team)247 AssignRandomTeams (XBTeamMode mode, int num, XBPlayerTeam * team)
248 {
249 int i, j;
250 XBPlayerTeam swap;
251 assert (NULL != team);
252 GUI_ErrorMessage ("in assign 0");
253 switch (mode) {
254 case XBTM_RandomTwo:
255 GUI_ErrorMessage ("in assign 1");
256 for (i = 0; i < num; i++) {
257 team[i] = XBPT_None + 1 + (i % 2);
258 }
259 break;
260 case XBTM_RandomThree:
261 for (i = 0; i < num; i++) {
262 team[i] = XBPT_None + 1 + (i % 3);
263 }
264 break;
265 default:
266 return;
267 }
268 /* shuffle teams */
269 GUI_ErrorMessage ("in assign 3");
270 for (i = 0; i < num; i++) {
271 GUI_ErrorMessage ("in assign 3.5");
272 j = OtherRandomNumber (i + 1);
273 GUI_ErrorMessage ("in assign 4");
274 if (j >= i) {
275 j++;
276 }
277 GUI_ErrorMessage ("in assign 5");
278 swap = team[i];
279 team[i] = team[j];
280 team[j] = swap;
281 }
282 for (i = 0; i < num; i++) {
283 GUI_ErrorMessage ("Player %i is of team %i", i, team[i]);
284 }
285 } /* AssignRandomTeams */
286 #endif
287
288 /*
289 * store game config
290 */
291 static void
StoreGameConfig(XBAtom atom)292 StoreGameConfig (XBAtom atom)
293 {
294 int i, j;
295 CFGGamePlayers gamePlayers;
296
297 /* copy players */
298 for (i = 0, j = 0; i < NUM_LOCAL_PLAYER; i++) {
299 if (ATOM_INVALID != _gamePlayers[i]) {
300 gamePlayers.player[j] = _gamePlayers[i];
301 gamePlayers.control[j] = _gameControl[i];
302 gamePlayers.host[j] = XBPH_Local;
303 gamePlayers.team[j] = XBPT_None;
304 j++;
305 }
306 }
307 gamePlayers.num = j;
308 #ifdef DEBUG_TEAM
309 gameSetup.teamMode = XBTM_None;
310 AssignRandomTeams (gameSetup.teamMode, gamePlayers.num, gamePlayers.team);
311 #else
312 gameSetup.teamMode = XBTM_None;
313 #endif
314 /* set and store game config */
315 StoreGameSetup (CT_Local, atom, &gameSetup);
316 StoreGamePlayers (CT_Local, atom, &gamePlayers);
317 StoreGameConstLocal (CT_Local, atom);
318 } /* StoreGameConfig */
319
320 /*
321 *
322 */
323 static XBBool
ButtonAllLevels(void * par)324 ButtonAllLevels (void *par)
325 {
326 XBAtom *atom = par;
327
328 /* level selection */
329 gameSetup.allLevels = XBTrue;
330 /* store it */
331 assert (atom != NULL);
332 StoreGameConfig (*atom);
333 /* clear player list */
334 if (NULL != playerList) {
335 DeletePlayerConfigList (playerList);
336 playerList = NULL;
337 }
338 /* leave menu */
339 MenuClear ();
340 return XBTrue;
341 } /* ButtonAllLevels */
342
343 /*
344 *
345 */
346 static XBBool
ButtonSelectLevels(void * par)347 ButtonSelectLevels (void *par)
348 {
349 XBAtom *atom = par;
350
351 /* level selection */
352 gameSetup.allLevels = XBFalse;
353 /* store it */
354 assert (atom != NULL);
355 StoreGameConfig (*atom);
356 /* clear player list */
357 if (NULL != playerList) {
358 DeletePlayerConfigList (playerList);
359 playerList = NULL;
360 }
361 /* select levels ? */
362 return CreateLevelMenu (&mlp);
363 } /* ButtonSelectLevels */
364
365 /*
366 *
367 */
368 static XBBool
ButtonStartClient(void * par)369 ButtonStartClient (void *par)
370 {
371 XBAtom *atom = par;
372
373 /* level selection */
374 gameSetup.allLevels = XBTrue;
375 /* set and store game config */
376 assert (atom != NULL);
377 StoreGameConfig (*atom);
378 /* clear player list */
379 if (NULL != playerList) {
380 DeletePlayerConfigList (playerList);
381 playerList = NULL;
382 }
383 /* next menu screen */
384 return CreateClientMenu (par);
385 } /* ButtonSelectLevels */
386
387 /*
388 * join screen for central XBCC
389 */
390 static XBBool
ButtonSearchCentral(void * par)391 ButtonSearchCentral (void *par)
392 {
393 XBAtom *atom = par;
394
395 /* level selection */
396 gameSetup.allLevels = XBTrue;
397 /* set and store game config */
398 assert (atom != NULL);
399 StoreGameConfig (*atom);
400 /* clear player list */
401 if (NULL != playerList) {
402 DeletePlayerConfigList (playerList);
403 playerList = NULL;
404 }
405 /* next menu screen */
406 // return CreateCentralJoinMenu (par);
407 return CreateSearchCentralMenu (par);
408 } /* ButtonSelectLevels */
409
410 /*
411 *
412 */
413 static XBBool
ButtonSearchLan(void * par)414 ButtonSearchLan (void *par)
415 {
416 XBAtom *atom = par;
417
418 /* level selection */
419 gameSetup.allLevels = XBTrue;
420 /* set and store game config */
421 assert (atom != NULL);
422 StoreGameConfig (*atom);
423 /* clear player list */
424 if (NULL != playerList) {
425 DeletePlayerConfigList (playerList);
426 playerList = NULL;
427 }
428 /* next menu screen */
429 return CreateSearchLanMenu (par);
430 } /* ButtonSelectLevels */
431
432 /*
433 *
434 */
435 static XBBool
ButtonStartServer(void * par)436 ButtonStartServer (void *par)
437 {
438 XBAtom *atom = par;
439
440 if (NULL != playerList) {
441 DeletePlayerConfigList (playerList);
442 playerList = NULL;
443 }
444 /* level selection */
445 gameSetup.allLevels = XBTrue;
446 /* set and store game config */
447 assert (atom != NULL);
448 StoreGameConfig (*atom);
449 /* clear player list */
450 if (NULL != playerList) {
451 DeletePlayerConfigList (playerList);
452 playerList = NULL;
453 }
454 /* goto next screen */
455 return CreateServerMenu (par);
456 } /* ButtonSelectLevels */
457
458 /*
459 * check if enough players are selected for playing
460 */
461 static void
PollStartGame(void * par)462 PollStartGame (void *par)
463 {
464 int i, j, numPlayers;
465 XBBool uniq, numOK, newState;
466 XBAtom *atom = par;
467 static XBBool oldState = XBTrue;
468
469 assert (atom != NULL);
470 uniq = XBTrue;
471 numPlayers = 0;
472 for (i = 0; i < NUM_LOCAL_PLAYER; i++) {
473 if (ATOM_INVALID != _gamePlayers[i]) {
474 for (j = i + 1; j < NUM_LOCAL_PLAYER; j++) {
475 if (_gamePlayers[i] == _gamePlayers[j]) {
476 uniq = XBFalse;
477 break;
478 }
479 }
480 numPlayers++;
481 }
482 if (!uniq) {
483 break;
484 }
485 }
486 /* check number of players .. */
487 if (*atom == atomLocal) {
488 /* for local games */
489 switch (gameSetup.teamMode) {
490 case XBTM_Hunt:
491 numOK = (numPlayers >= 3);
492 break;
493 default:
494 numOK = (numPlayers >= 2);
495 break;
496 }
497 }
498 else {
499 numOK = (numPlayers >= 1);
500 }
501 /* check current state */
502 newState = uniq && numOK;
503 if (newState != oldState) {
504 MenuSetActive (idButtonStart, newState);
505 MenuSetActive (idButtonLevels, newState);
506 oldState = newState;
507 }
508 } /* PollStartGame */
509
510 /*
511 * create items for gamePlayers
512 */
513 static void
CreatePlayerItems(int x)514 CreatePlayerItems (int x)
515 {
516 int i, numJoy;
517 static const CFGPlayerGraphics *localPlayerGraphics[NUM_LOCAL_PLAYER];
518
519 /* load player configs */
520 if (NULL != playerList) {
521 DeletePlayerConfigList (playerList);
522 }
523 playerList = CreatePlayerConfigList ();
524 numJoy = GUI_NumJoysticks ();
525 for (i = 0; i < 2 + numJoy; i++) {
526 MenuAddCombo (x, MENU_ROW (i), 5 * CELL_W, playerControl[i], 2 * CELL_W, NULL,
527 (void **)&localPlayerGraphics[i], &_gamePlayers[i], playerList);
528 MenuAddPlayer (PLAYER_LEFT (i, numJoy + 2), PLAYER_TOP, PLAYER_WIDTH, i,
529 &localPlayerGraphics[i], -ANIME_LENGTH, playerAnime);
530 }
531 } /* CreatePlayerItems */
532
533 /*
534 * create items for game parameters
535 */
536 static void
CreateSetupItems(int x,CFGGameSetup * gameSetup,XBBool networkGame)537 CreateSetupItems (int x, CFGGameSetup * gameSetup, XBBool networkGame)
538 {
539 assert (gameSetup != NULL);
540 MenuAddComboInt (x, MENU_ROW (0), 5 * CELL_W, N_("Lives:"), 2 * CELL_W, &gameSetup->numLives,
541 numLivesList);
542 MenuAddComboInt (x, MENU_ROW (1), 5 * CELL_W, N_("Victories:"), 2 * CELL_W, &gameSetup->numWins,
543 numWinsList);
544 MenuAddComboInt (x, MENU_ROW (2), 5 * CELL_W, N_("Frame Rate:"), 2 * CELL_W, &gameSetup->frameRate,
545 frameRateList);
546 //MenuAddComboBool (x, MENU_ROW (3), 5*CELL_W, N_("Random Levels:"), 2*CELL_W, &gameSetup->randomLevels);
547 //MenuAddComboBool (x, MENU_ROW (4), 5*CELL_W, N_("Random Position:"), 2*CELL_W, &gameSetup->randomPlayers);
548 MenuAddComboInt (x, MENU_ROW (3), 5 * CELL_W, N_("Level Order:"), 2 * CELL_W,
549 &gameSetup->levelOrder, levelOrderList);
550 MenuAddComboInt (x, MENU_ROW (4), 5 * CELL_W, N_("Info screen:"), 2 * CELL_W, &gameSetup->infoTime,
551 waitInfoList);
552 MenuAddComboBool (x, MENU_ROW (5), 5 * CELL_W, N_("Record Demo:"), 2 * CELL_W,
553 &gameSetup->recordDemo);
554 MenuAddComboBool (x, MENU_ROW (6), 5 * CELL_W, N_("Bot:"), 2 * CELL_W, &gameSetup->bot);
555 MenuAddComboBool (x - 6 * CELL_W, MENU_ROW (5), 5 * CELL_W, N_("Recom. Lives:"), 2 * CELL_W,
556 &gameSetup->ifRecLives);
557 MenuAddComboInt (x - 6 * CELL_W, MENU_ROW (6), 5 * CELL_W, N_("Music:"), 2 * CELL_W,
558 (int *)&gameSetup->Music, musicList);
559 if (networkGame) {
560 MenuAddComboBool (x, MENU_ROW (7), 5 * CELL_W, N_("Rated Game:"), 2 * CELL_W, &gameSetup->rated); // XBCC
561 }
562 } /* CreateSetupItems */
563
564 static void
RetrieveGameConfig(XBAtom atom)565 RetrieveGameConfig (XBAtom atom)
566 {
567 size_t i;
568 size_t numJoy;
569 CFGGamePlayers gamePlayers;
570
571 numJoy = GUI_NumJoysticks ();
572 /* load game configs */
573 (void)RetrieveGameSetup (CT_Local, atom, &gameSetup);
574 (void)RetrieveGamePlayers (CT_Local, atom, &gamePlayers);
575 /* copy to edit data */
576 memset (&_gamePlayers, 0, sizeof (_gamePlayers));
577 for (i = 0; i < gamePlayers.num; i++) {
578 switch (gamePlayers.control[i]) {
579 case XBPC_RightKeyboard:
580 _gamePlayers[0] = gamePlayers.player[i];
581 break;
582 case XBPC_LeftKeyboard:
583 _gamePlayers[1] = gamePlayers.player[i];
584 break;
585 case XBPC_Joystick1:
586 if (numJoy >= 1) {
587 _gamePlayers[2] = gamePlayers.player[i];
588 }
589 break;
590 case XBPC_Joystick2:
591 if (numJoy >= 2) {
592 _gamePlayers[3] = gamePlayers.player[i];
593 }
594 break;
595 case XBPC_Joystick3:
596 if (numJoy >= 3) {
597 _gamePlayers[4] = gamePlayers.player[i];
598 }
599 break;
600 case XBPC_Joystick4:
601 if (numJoy >= 4) {
602 _gamePlayers[5] = gamePlayers.player[i];
603 }
604 break;
605 default:
606 break;
607 }
608 }
609 } /* RetrieveGameConfig */
610
611 /*
612 * create local game
613 */
614 XBBool
CreateLocalGameMenu(void * par)615 CreateLocalGameMenu (void *par)
616 {
617 XBAtom *atom = par;
618
619 assert (atom != NULL);
620 /* --- */
621 hostType = XBPH_Local;
622 RetrieveGameConfig (*atom);
623 /* setup level selection */
624 mlp.textAbort = N_("Back");
625 mlp.funcAbort = CreateLocalGameMenu;
626 mlp.parAbort = par;
627 mlp.textDefault = N_("Start");
628 mlp.funcDefault = ButtonStartLocalGame;
629 mlp.parDefault = NULL;
630 /* build menu */
631 MenuClear ();
632 /* Title */
633 MenuAddLabel (TITLE_LEFT, TITLE_TOP, TITLE_WIDTH, N_("Setup Local Game"));
634 /* create player selection */
635 CreatePlayerItems (2 * CELL_W);
636 /* --- */
637 CreateSetupItems (8 * CELL_W, &gameSetup, XBFalse);
638 /* Buttons */
639 MenuSetAbort (MenuAddHButton
640 (3 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Back"), ButtonMainMenu, NULL));
641 idButtonLevels =
642 MenuAddHButton (11 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Select Levels"),
643 ButtonSelectLevels, par);
644 idButtonStart =
645 MenuAddHButton (19 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Start"), ButtonAllLevels, par);
646 MenuSetDefault (idButtonStart);
647 /* polling */
648 MenuAddCyclic (PollStartGame, par);
649 /* --- */
650 MenuSetLinks ();
651 /* that's all */
652 return XBFalse;
653 } /* CreateLocalGameMenu */
654
655 /*
656 * create network game
657 */
658 XBBool
CreateStartNetGameMenu(void * par)659 CreateStartNetGameMenu (void *par)
660 {
661 XBAtom *atom = par;
662
663 assert (atom != NULL);
664 /* --- */
665 hostType = XBPH_Server;
666 RetrieveGameConfig (*atom);
667 /* setup level selection */
668 mlp.textAbort = N_("Back");
669 mlp.funcAbort = CreateStartNetGameMenu;
670 mlp.parAbort = par;
671 mlp.textDefault = N_("Cont.");
672 mlp.funcDefault = CreateServerMenu;
673 mlp.parDefault = par;
674 /* build menu */
675 MenuClear ();
676 /* Title */
677 MenuAddLabel (TITLE_LEFT, TITLE_TOP, TITLE_WIDTH, N_("Start Network Game"));
678 /* create player selection */
679 CreatePlayerItems (2 * CELL_W);
680 /* --- */
681 CreateSetupItems (8 * CELL_W, &gameSetup, XBTrue);
682 /* Buttons */
683 MenuSetAbort (MenuAddHButton
684 (3 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Back"), ButtonMainMenu, NULL));
685 idButtonLevels =
686 MenuAddHButton (11 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Select Levels"),
687 ButtonSelectLevels, par);
688 idButtonStart =
689 MenuAddHButton (19 * CELL_W / 2, MENU_BOTTOM, 4 * CELL_W, N_("Continue"), ButtonStartServer,
690 par);
691 MenuSetDefault (idButtonStart);
692 /* polling */
693 MenuAddCyclic (PollStartGame, par);
694 /* --- */
695 MenuSetLinks ();
696 /* that's all */
697 return XBFalse;
698 } /* CreateStartNetGameMenu */
699
700 /*
701 * create the options menu
702 */
703 XBBool
CreateJoinNetGameMenu(void * par)704 CreateJoinNetGameMenu (void *par)
705 {
706 XBAtom *atom = par;
707
708 assert (atom != NULL);
709 /* --- */
710 hostType = XBPH_None;
711 RetrieveGameConfig (*atom);
712 /* build menu */
713 MenuClear ();
714 MenuAddLabel (TITLE_LEFT, TITLE_TOP, TITLE_WIDTH, N_("Join Network Game"));
715 /* create player selection */
716 CreatePlayerItems (2 * CELL_W);
717 /* demo recording */
718 MenuAddComboBool (8 * CELL_W, MENU_ROW (0), 5 * CELL_W, N_("Record Demo:"), 2 * CELL_W,
719 &gameSetup.recordDemo);
720 /* bot */
721 MenuAddComboBool (8 * CELL_W, MENU_ROW (1), 5 * CELL_W, N_("bot:"), 2 * CELL_W, &gameSetup.bot);
722 MenuAddComboBool (8 * CELL_W, MENU_ROW (2), 5 * CELL_W, N_("Beep at start:"), 2 * CELL_W,
723 &gameSetup.beep);
724 MenuAddComboInt (8 * CELL_W, MENU_ROW (3), 5 * CELL_W, N_("Music:"), 2 * CELL_W,
725 (int *)&gameSetup.Music, musicList);
726 /* Buttons */
727 MenuSetAbort (MenuAddHButton
728 (4 * CELL_W / 2, MENU_BOTTOM, 5 * CELL_W, N_("Back"), ButtonMainMenu, NULL));
729 idButtonCentral =
730 MenuAddHButton (17 * CELL_W / 2, MENU_ROW (6), 5 * CELL_W, N_("Search Central"),
731 ButtonSearchCentral, par);
732 idButtonStart =
733 MenuAddHButton (17 * CELL_W / 2, MENU_ROW (7), 5 * CELL_W, N_("Connect ..."), ButtonStartClient,
734 par);
735 idButtonLevels =
736 MenuAddHButton (17 * CELL_W / 2, MENU_BOTTOM, 5 * CELL_W, N_("Search LAN"), ButtonSearchLan,
737 par);
738 MenuSetDefault (idButtonLevels);
739 /* polling */
740 MenuAddCyclic (PollStartGame, par);
741 /* --- */
742 MenuSetLinks ();
743 /* that's all */
744 return XBFalse;
745 } /* CreateJoinNetGameMenu */
746
747 /*
748 * create the central menu ( empty just redirect ) XBCC
749 */
750 void
setAutoCentral(XBBool set)751 setAutoCentral (XBBool set)
752 {
753 autoCentral = set;
754 setAutoCentral2 (autoCentral);
755 }
756
757 XBBool
CreateCentralGameMenu(void * par)758 CreateCentralGameMenu (void *par)
759 {
760 return CreateCentralMenu (par);
761 } /* ButtonSelectLevels */
762
763 /*
764 *
765 */
766 XBPlayerHost
GetHostType(void)767 GetHostType (void)
768 {
769 return hostType;
770 } /* GetHostType */
771
772 /*
773 *
774 */
775 void
SetHostType(XBPlayerHost _hostType)776 SetHostType (XBPlayerHost _hostType)
777 {
778 hostType = _hostType;
779 } /* SetHostType */
780
781 /*
782 * end of file menu_game.c
783 */
784