1 /***************************************************************************
2 guihelp.cpp -- automatic help on keys
3 -------------------
4 created : Fri Aug 13 22:20:37 CEST 1999
5 copyright : (C) 1999 by Eric Espie
6 email : torcs@free.fr
7 version : $Id: guihelp.cpp,v 1.3 2004/02/28 08:39:13 torcs Exp $
8 ***************************************************************************/
9
10 /***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19 /** @file
20 GUI help screen management.
21 @author <a href=mailto:torcs@free.fr>Eric Espie</a>
22 @version $Id: guihelp.cpp,v 1.3 2004/02/28 08:39:13 torcs Exp $
23 @ingroup gui
24 */
25
26 #include <stdlib.h>
27 #ifdef WIN32
28 #include <windows.h>
29 #endif
30 #include <tgfclient.h>
31 #include "gui.h"
32
33 static void *scrHandle;
34 static float *fgColor1 = &(GfuiColor[GFUI_HELPCOLOR1][0]);
35 static float *fgColor2 = &(GfuiColor[GFUI_HELPCOLOR2][0]);
36
37 void
gfuiHelpInit(void)38 gfuiHelpInit(void)
39 {
40 }
41
42 /** Generate a help screen.
43 @ingroup gui
44 @param prevScreen Previous screen to return to
45 @warning The help screen is activated.
46 */
47 void
GfuiHelpScreen(void * prevScreen)48 GfuiHelpScreen(void *prevScreen)
49 {
50 int x, x2, dx, y;
51 tGfuiKey *curKey;
52 tGfuiKey *curSKey;
53 tGfuiScreen *pscr = (tGfuiScreen*)prevScreen;
54
55 scrHandle = GfuiScreenCreate();
56
57 GfuiLabelCreateEx(scrHandle,
58 "Keys Definition",
59 fgColor2,
60 GFUI_FONT_BIG,
61 320,
62 440,
63 GFUI_ALIGN_HC_VB,
64 0);
65
66 x = 30;
67 dx = 80;
68 x2 = 330;
69 y = 380;
70
71 curSKey = pscr->userSpecKeys;
72 curKey = pscr->userKeys;
73 do {
74 if (curSKey != NULL) {
75 curSKey = curSKey->next;
76 GfuiLabelCreateEx(scrHandle, curSKey->name, fgColor1, GFUI_FONT_SMALL_C, x, y, GFUI_ALIGN_HL_VB, 0);
77 GfuiLabelCreateEx(scrHandle, curSKey->descr, fgColor2, GFUI_FONT_SMALL_C, x + dx, y, GFUI_ALIGN_HL_VB, 0);
78 }
79
80 if (curKey != NULL) {
81 curKey = curKey->next;
82 GfuiLabelCreateEx(scrHandle, curKey->name, fgColor1, GFUI_FONT_SMALL_C, x2, y, GFUI_ALIGN_HL_VB, 0);
83 GfuiLabelCreateEx(scrHandle, curKey->descr, fgColor2, GFUI_FONT_SMALL_C, x2 + dx, y, GFUI_ALIGN_HL_VB, 0);
84 }
85 y -= 12;
86
87 if (curKey == pscr->userKeys) curKey = (tGfuiKey*)NULL;
88 if (curSKey == pscr->userSpecKeys) curSKey = (tGfuiKey*)NULL;
89
90 } while ((curKey != NULL) || (curSKey != NULL));
91
92
93 GfuiButtonCreate(scrHandle,
94 "Back",
95 GFUI_FONT_LARGE,
96 320,
97 40,
98 GFUI_BTNSZ,
99 GFUI_ALIGN_HC_VB,
100 0,
101 prevScreen,
102 GfuiScreenActivate,
103 NULL,
104 (tfuiCallback)NULL,
105 (tfuiCallback)NULL);
106
107 GfuiAddKey(scrHandle, (unsigned char)27, "", prevScreen, GfuiScreenReplace, NULL);
108 GfuiAddSKey(scrHandle, GLUT_KEY_F1, "", prevScreen, GfuiScreenReplace, NULL);
109 GfuiAddKey(scrHandle, (unsigned char)13, "", prevScreen, GfuiScreenReplace, NULL);
110
111 GfuiMenuDefaultKeysAdd(scrHandle);
112
113 GfuiScreenActivate(scrHandle);
114
115 }
116
117