]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/mainwindow.c
starting to add a warning for the demo dialog
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / mainwindow.c
1 #ifdef INTERFACE
2 CLASS(MainWindow) EXTENDS(ModalController)
3         METHOD(MainWindow, configureMainWindow, void(entity))
4         METHOD(MainWindow, draw, void(entity))
5         ATTRIB(MainWindow, firstRunDialog, entity, NULL)
6         ATTRIB(MainWindow, advancedDialog, entity, NULL)
7         ATTRIB(MainWindow, mutatorsDialog, entity, NULL)
8         ATTRIB(MainWindow, weaponsDialog, entity, NULL)
9         ATTRIB(MainWindow, mapInfoDialog, entity, NULL)
10         ATTRIB(MainWindow, userbindEditDialog, entity, NULL)
11         ATTRIB(MainWindow, winnerDialog, entity, NULL)
12         ATTRIB(MainWindow, serverInfoDialog, entity, NULL)
13         ATTRIB(MainWindow, cvarsDialog, entity, NULL)
14         ATTRIB(MainWindow, screenshotViewerDialog, entity, NULL)
15         ATTRIB(MainWindow, viewDialog, entity, NULL)
16         ATTRIB(MainWindow, modelDialog, entity, NULL)
17         ATTRIB(MainWindow, crosshairDialog, entity, NULL)
18         ATTRIB(MainWindow, hudDialog, entity, NULL)
19         ATTRIB(MainWindow, hudconfirmDialog, entity, NULL)
20         ATTRIB(MainWindow, mainNexposee, entity, NULL)
21         ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND)
22         ATTRIB(MainWindow, dialogToShow, entity, NULL)
23         ATTRIB(MainWindow, notificationDialog, entity, NULL)
24         ATTRIB(MainWindow, democonfirmDialog, entity, NULL)
25 ENDCLASS(MainWindow)
26 #endif
27
28 #ifdef IMPLEMENTATION
29 void MainWindow_draw(entity me)
30 {
31         SUPER(MainWindow).draw(me);
32
33         if(me.dialogToShow)
34         {
35                 DialogOpenButton_Click_withCoords(world, me.dialogToShow, '0 0 0', eX * conwidth + eY * conheight);
36                 me.dialogToShow = NULL;
37         }
38 }
39
40 void DemoButton_Click(entity me, entity other)
41 {
42         if(me.text == _("Do not press this button again!"))
43                 DialogOpenButton_Click(me, other);
44         else
45                 me.setText(me, _("Do not press this button again!"));
46 }
47
48 void MainWindow_configureMainWindow(entity me)
49 {
50         entity n, i;
51
52         // dialog run upon startup
53         me.firstRunDialog = i = spawnXonoticFirstRunDialog();
54         i.configureDialog(i);
55         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
56         
57         
58         // hud_configure dialogs
59         i = spawnXonoticHUDExitDialog();
60         i.configureDialog(i);
61         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
62         
63         i = spawnXonoticHUDNotificationDialog();
64         i.configureDialog(i);
65         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
66         
67         i = spawnXonoticHUDAmmoDialog();
68         i.configureDialog(i);
69         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
70         
71         i = spawnXonoticHUDHealthArmorDialog();
72         i.configureDialog(i);
73         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
74         
75         i = spawnXonoticHUDChatDialog();
76         i.configureDialog(i);
77         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
78         
79         i = spawnXonoticHUDModIconsDialog();
80         i.configureDialog(i);
81         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
82         
83         i = spawnXonoticHUDPowerupsDialog();
84         i.configureDialog(i);
85         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
86         
87         i = spawnXonoticHUDPressedKeysDialog();
88         i.configureDialog(i);
89         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
90         
91         i = spawnXonoticHUDRaceTimerDialog();
92         i.configureDialog(i);
93         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
94         
95         i = spawnXonoticHUDRadarDialog();
96         i.configureDialog(i);
97         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
98         
99         i = spawnXonoticHUDScoreDialog();
100         i.configureDialog(i);
101         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
102         
103         i = spawnXonoticHUDTimerDialog();
104         i.configureDialog(i);
105         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
106         
107         i = spawnXonoticHUDVoteDialog();
108         i.configureDialog(i);
109         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
110         
111         i = spawnXonoticHUDWeaponsDialog();
112         i.configureDialog(i);
113         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
114
115         i = spawnXonoticHUDEngineInfoDialog();
116         i.configureDialog(i);
117         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
118
119         i = spawnXonoticHUDInfoMessagesDialog();
120         i.configureDialog(i);
121         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
122         
123         i = spawnXonoticHUDPhysicsDialog();
124         i.configureDialog(i);
125         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
126         
127         me.screenshotViewerDialog = i = spawnXonoticScreenshotViewerDialog();
128         i.configureDialog(i);
129         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
130
131         i = spawnXonoticHUDCenterprintDialog();
132         i.configureDialog(i);
133         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
134         
135         
136         // dialogs used by settings
137         me.userbindEditDialog = i = spawnXonoticUserbindEditDialog();
138         i.configureDialog(i);
139         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
140         
141         me.cvarsDialog = i = spawnXonoticCvarsDialog();
142         i.configureDialog(i);
143         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
144         
145         
146         // dialog used by singleplayer
147         me.winnerDialog = i = spawnXonoticWinnerDialog();
148         i.configureDialog(i);
149         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
150         
151         
152         // dialog used by multiplayer/join
153         me.serverInfoDialog = i = spawnXonoticServerInfoDialog();
154         i.configureDialog(i);
155         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
156         
157         me.democonfirmDialog = i = spawnXonoticDemoConfirmDialog();
158         i.configureDialog(i);
159         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
160         
161         
162         // dialogs used by multiplayer/create
163         me.mapInfoDialog = i = spawnXonoticMapInfoDialog();
164         i.configureDialog(i);
165         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
166         
167         me.advancedDialog = i = spawnXonoticAdvancedDialog();
168         i.configureDialog(i);
169         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
170
171         me.mutatorsDialog = i = spawnXonoticMutatorsDialog();
172         i.configureDialog(i);
173         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
174         
175
176         // dialogs used by multiplayer/player setup
177         me.crosshairDialog = i = spawnXonoticCrosshairDialog();
178         i.configureDialog(i);
179         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
180         
181         me.hudDialog = i = spawnXonoticHUDDialog();
182         i.configureDialog(i);
183         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
184
185         me.hudconfirmDialog = i = spawnXonoticHUDConfirmDialog();
186         i.configureDialog(i);
187         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
188         
189         me.modelDialog = i = spawnXonoticModelDialog();
190         i.configureDialog(i);
191         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
192         
193         me.viewDialog = i = spawnXonoticViewDialog();
194         i.configureDialog(i);
195         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
196         
197         me.weaponsDialog = i = spawnXonoticWeaponsDialog();
198         i.configureDialog(i);
199         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
200         
201         me.notificationDialog = i = spawnXonoticNotificationDialog();
202         i.configureDialog(i);
203         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
204
205         // mutator dialogs
206         i = spawnXonoticSandboxToolsDialog();
207         i.configureDialog(i);
208         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
209         
210         
211         // miscellaneous dialogs
212         i = spawnXonoticTeamSelectDialog();
213         i.configureDialog(i);
214         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
215         
216         
217         // main dialogs/windows
218         me.mainNexposee = n = spawnXonoticNexposee();
219         /*
220                 if(checkextension("DP_GECKO_SUPPORT"))
221                 {
222                         i = spawnXonoticNewsDialog();
223                         i.configureDialog(i);
224                         n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
225                         n.setNexposee(n, i, '0.1 0.1 0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
226                 }
227         */
228                 i = spawnXonoticSingleplayerDialog();
229                 i.configureDialog(i);
230                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
231                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SINGLEPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
232                 
233                 i = spawnXonoticMultiplayerDialog();
234                 i.configureDialog(i);
235                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
236                 n.setNexposee(n, i, SKINPOSITION_DIALOG_MULTIPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
237
238                 i = spawnXonoticSettingsDialog();
239                 i.configureDialog(i);
240                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
241                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SETTINGS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
242
243                 i = spawnXonoticCreditsDialog();
244                 i.configureDialog(i);
245                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
246                 n.setNexposee(n, i, SKINPOSITION_DIALOG_CREDITS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
247                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
248
249                 i = spawnXonoticQuitDialog();
250                 i.configureDialog(i);
251                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
252                 n.setNexposee(n, i, SKINPOSITION_DIALOG_QUIT, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
253                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
254                 
255         me.addItem(me, n, '0 0 0', '1 1 0', SKINALPHAS_MAINMENU_z);
256         me.moveItemAfter(me, n, NULL);
257
258         me.initializeDialog(me, n);
259
260         if(cvar_string("_cl_name") == "Player")
261                 me.dialogToShow = me.firstRunDialog;
262 }
263 #endif
264
265 /* Click. The c-word is here so you can grep for it :-) */