1 /***************************************************************************
2 
3     file                 : exitmenu.cpp
4     created              : Sat Mar 18 23:42:12 CET 2000
5     copyright            : (C) 2000 by Eric Espie
6     email                : torcs@free.fr
7     version              : $Id: exitmenu.cpp,v 1.4 2006/10/05 21:25:55 berniw Exp $
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  *                                                                         *
13  *   This program is free software; you can redistribute it and/or modify  *
14  *   it under the terms of the GNU General Public License as published by  *
15  *   the Free Software Foundation; either version 2 of the License, or     *
16  *   (at your option) any later version.                                   *
17  *                                                                         *
18  ***************************************************************************/
19 
20 
21 #include <stdio.h>
22 #include <tgfclient.h>
23 #include "exitmenu.h"
24 #include "mainmenu.h"
25 
26 static void
endofprog(void *)27 endofprog(void * /* dummy */)
28 {
29     STOP_ACTIVE_PROFILES();
30     PRINT_PROFILE();
31 /*     glutSetKeyRepeat(GLUT_KEY_REPEAT_ON); */
32     GfScrShutdown();
33     exit(0);
34 }
35 
36 static void *exitmenuHandle = NULL;
37 static void *exitMainMenuHandle = NULL;
38 
39 
exitMenuInit(void * menu,void * menuHandle)40 void * exitMenuInit(void *menu, void *menuHandle)
41 {
42     if (menuHandle) {
43 		GfuiScreenRelease(menuHandle);
44     }
45 
46     menuHandle = GfuiMenuScreenCreate("Quit ?");
47     GfuiScreenAddBgImg(menuHandle, "data/img/splash-quit.png");
48 
49     GfuiMenuButtonCreate(menuHandle,
50 		      "No, Back to Game",
51 		      "Return to TORCS",
52 		      menu,
53 		      GfuiScreenActivate);
54 
55     GfuiMenuButtonCreate(menuHandle,
56 		      "Yes, Let's Quit",
57 		      "Exit of TORCS",
58 		      NULL,
59 		      endofprog);
60     return menuHandle;
61 }
62 
63 /*
64  * Function
65  *	TorcsExitMenuInit
66  *
67  * Description
68  *	init the exit menus
69  *
70  * Parameters
71  *	none
72  *
73  * Return
74  *	0 ok -1 nok
75  *
76  * Remarks
77  *
78  */
TorcsExitMenuInit(void * menu)79 void * TorcsExitMenuInit(void *menu)
80 {
81 	exitmenuHandle = exitMenuInit(menu, exitmenuHandle);
82 	return exitmenuHandle;
83 }
84 
85 
TorcsMainExitMenuInit(void * mainMenu)86 void * TorcsMainExitMenuInit(void *mainMenu)
87 {
88 	exitMainMenuHandle = exitMenuInit(mainMenu, exitMainMenuHandle);
89 	return exitMainMenuHandle;
90 }
91