Merge branch 'master' into terencehill/menu_quit_game
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / mainwindow.qc
1 #include "mainwindow.qh"
2
3 #include <menu/mutators/_mod.qh>
4
5 #include "nexposee.qh"
6 #include "inputbox.qh"
7 #include "dialog_termsofservice.qh"
8 #include "dialog_firstrun.qh"
9 #include "dialog_hudsetup_exit.qh"
10 #include "dialog_hudpanel_notification.qh"
11 #include "dialog_hudpanel_ammo.qh"
12 #include "dialog_hudpanel_healtharmor.qh"
13 #include "dialog_hudpanel_chat.qh"
14 #include "dialog_hudpanel_modicons.qh"
15 #include "dialog_hudpanel_powerups.qh"
16 #include "dialog_hudpanel_pressedkeys.qh"
17 #include "dialog_hudpanel_racetimer.qh"
18 #include "dialog_hudpanel_radar.qh"
19 #include "dialog_hudpanel_score.qh"
20 #include "dialog_hudpanel_timer.qh"
21 #include "dialog_hudpanel_vote.qh"
22 #include "dialog_hudpanel_weapons.qh"
23 #include "dialog_hudpanel_engineinfo.qh"
24 #include "dialog_hudpanel_infomessages.qh"
25 #include "dialog_hudpanel_physics.qh"
26 #include "dialog_hudpanel_centerprint.qh"
27 #include "dialog_hudpanel_itemstime.qh"
28 #include "dialog_hudpanel_quickmenu.qh"
29 #include "dialog_hudpanel_strafehud.qh"
30
31 #include "dialog_settings_input_userbind.qh"
32 #include "dialog_settings_bindings_reset.qh"
33 #include "dialog_settings_misc_cvars.qh"
34 #include "dialog_settings_misc_reset.qh"
35 #include "dialog_settings_user_languagewarning.qh"
36 #include "dialog_settings_game_hudconfirm.qh"
37 #include "dialog_singleplayer_winner.qh"
38 #include "dialog_multiplayer_join_serverinfo.qh"
39 #include "dialog_multiplayer_media_demo_startconfirm.qh"
40 #include "dialog_multiplayer_media_demo_timeconfirm.qh"
41 #include "dialog_multiplayer_media_screenshot_viewer.qh"
42 #include "dialog_multiplayer_create_mapinfo.qh"
43 #include "dialog_multiplayer_create_mutators.qh"
44 #include "dialog_sandboxtools.qh"
45 #include "dialog_monstertools.qh"
46 #include "dialog_gamemenu.qh"
47 #include "dialog_welcome.qh"
48 #include "dialog_teamselect.qh"
49 #include "dialog_uid2name.qh"
50 #include "dialog_singleplayer.qh"
51 #include "dialog_multiplayer.qh"
52 #include "dialog_settings.qh"
53 #include "dialog_credits.qh"
54 #include "dialog_quit.qh"
55
56 void MainWindow_draw(entity me)
57 {
58         SUPER(MainWindow).draw(me);
59
60         if (me.firstDraw) {
61                 if (me.ToSDialog.shouldShow())
62                 {
63                         me.ToSDialog.loadXonoticToS(me.ToSDialog);
64                         DialogOpenButton_Click_withCoords(NULL, me.ToSDialog, '0 0 0', eX * conwidth + eY * conheight);
65                 }
66                 else if(me.firstRunDialog.shouldShow())
67                         DialogOpenButton_Click_withCoords(NULL, me.firstRunDialog, '0 0 0', eX * conwidth + eY * conheight);
68                 
69                 me.firstDraw = false;
70         }
71 }
72
73 void DemoButton_Click(entity me, entity other)
74 {
75         if(me.text == _("Do not press this button again!"))
76                 DialogOpenButton_Click(me, other);
77         else
78                 me.setText(me, _("Do not press this button again!"));
79 }
80
81 void MainWindow_configureMainWindow(entity me)
82 {
83         entity n, i;
84
85         // terms of service dialog
86         me.ToSDialog = i = NEW(XonoticToSDialog);
87         i.configureDialog(i);
88         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
89
90         // dialog run upon startup
91         me.firstRunDialog = i = NEW(XonoticFirstRunDialog);
92         i.configureDialog(i);
93         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
94
95         i = NEW(XonoticWelcomeDialog);
96         i.configureDialog(i);
97         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
98
99
100         // hud_configure dialogs
101         i = NEW(XonoticHUDExitDialog);
102         i.configureDialog(i);
103         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
104
105         i = NEW(XonoticHUDNotificationDialog);
106         i.configureDialog(i);
107         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
108
109         i = NEW(XonoticHUDAmmoDialog);
110         i.configureDialog(i);
111         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
112
113         i = NEW(XonoticHUDHealthArmorDialog);
114         i.configureDialog(i);
115         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
116
117         i = NEW(XonoticHUDChatDialog);
118         i.configureDialog(i);
119         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
120
121         i = NEW(XonoticHUDModIconsDialog);
122         i.configureDialog(i);
123         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
124
125         i = NEW(XonoticHUDPowerupsDialog);
126         i.configureDialog(i);
127         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
128
129         i = NEW(XonoticHUDPressedKeysDialog);
130         i.configureDialog(i);
131         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
132
133         i = NEW(XonoticHUDRaceTimerDialog);
134         i.configureDialog(i);
135         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
136
137         i = NEW(XonoticHUDRadarDialog);
138         i.configureDialog(i);
139         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
140
141         i = NEW(XonoticHUDScoreDialog);
142         i.configureDialog(i);
143         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
144
145         i = NEW(XonoticHUDTimerDialog);
146         i.configureDialog(i);
147         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
148
149         i = NEW(XonoticHUDVoteDialog);
150         i.configureDialog(i);
151         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
152
153         i = NEW(XonoticHUDWeaponsDialog);
154         i.configureDialog(i);
155         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
156
157         i = NEW(XonoticHUDEngineInfoDialog);
158         i.configureDialog(i);
159         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
160
161         i = NEW(XonoticHUDInfoMessagesDialog);
162         i.configureDialog(i);
163         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
164
165         i = NEW(XonoticHUDPhysicsDialog);
166         i.configureDialog(i);
167         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
168
169         i = NEW(XonoticHUDCenterprintDialog);
170         i.configureDialog(i);
171         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
172
173         i = NEW(XonoticHUDItemsTimeDialog);
174         i.configureDialog(i);
175         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
176
177         i = NEW(XonoticHUDQuickMenuDialog);
178         i.configureDialog(i);
179         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
180
181         i = NEW(XonoticHUDStrafeHUDDialog);
182         i.configureDialog(i);
183         me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
184
185         // dialogs used by settings
186         me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog);
187         i.configureDialog(i);
188         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
189
190         me.bindingsResetDialog = i = NEW(XonoticBindingsResetDialog);
191         i.configureDialog(i);
192         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
193
194         me.cvarsDialog = i = NEW(XonoticCvarsDialog);
195         i.configureDialog(i);
196         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
197
198         me.resetDialog = i = NEW(XonoticResetDialog);
199         i.configureDialog(i);
200         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
201
202         me.languageWarningDialog = i = NEW(XonoticLanguageWarningDialog);
203         i.configureDialog(i);
204         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
205
206         me.hudconfirmDialog = i = NEW(XonoticHUDConfirmDialog);
207         i.configureDialog(i);
208         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
209
210
211         // dialog used by singleplayer
212         me.winnerDialog = i = NEW(XonoticWinnerDialog);
213         i.configureDialog(i);
214         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
215
216
217         // dialog used by multiplayer/join
218         me.serverInfoDialog = i = NEW(XonoticServerInfoDialog);
219         i.configureDialog(i);
220         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
221
222         me.demostartconfirmDialog = i = NEW(XonoticDemoStartConfirmDialog);
223         i.configureDialog(i);
224         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
225
226         me.demotimeconfirmDialog = i = NEW(XonoticDemoTimeConfirmDialog);
227         i.configureDialog(i);
228         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
229
230
231         // dialogs used by multiplayer/create
232         me.mapInfoDialog = i = NEW(XonoticMapInfoDialog);
233         i.configureDialog(i);
234         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
235
236         me.mutatorsDialog = i = NEW(XonoticMutatorsDialog);
237         i.configureDialog(i);
238         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
239
240
241         // dialogs used by multiplayer/media
242         me.screenshotViewerDialog = i = NEW(XonoticScreenshotViewerDialog);
243         i.configureDialog(i);
244         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
245
246
247         // mutator dialogs
248         i = NEW(XonoticSandboxToolsDialog);
249         i.configureDialog(i);
250         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
251
252
253         // miscellaneous dialogs
254         i = NEW(XonoticGameMenuDialog);
255         i.configureDialog(i);
256         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
257
258         i = NEW(XonoticTeamSelectDialog);
259         i.configureDialog(i);
260         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
261
262         i = NEW(XonoticUid2NameDialog);
263         i.configureDialog(i);
264         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
265
266         i = NEW(XonoticMonsterToolsDialog);
267         i.configureDialog(i);
268         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
269
270         MUTATOR_CALLHOOK(ConfigureDialogs, me);
271
272
273         // main dialogs/windows
274         me.mainNexposee = n = NEW(XonoticNexposee);
275
276         /*
277                 if(checkextension("DP_GECKO_SUPPORT"))
278                 {
279                         i = spawnXonoticNewsDialog();
280                         i.configureDialog(i);
281                         n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
282                         n.setNexposee(n, i, '0.1 0.1 0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
283                 }
284         */
285
286                 i = NEW(XonoticSingleplayerDialog);
287                 i.configureDialog(i);
288                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
289                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SINGLEPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
290
291                 i = NEW(XonoticMultiplayerDialog);
292                 i.configureDialog(i);
293                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
294                 n.setNexposee(n, i, SKINPOSITION_DIALOG_MULTIPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
295
296                 i = NEW(XonoticSettingsDialog);
297                 i.configureDialog(i);
298                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
299                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SETTINGS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
300
301                 i = NEW(XonoticCreditsDialog);
302                 i.configureDialog(i);
303                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
304                 n.setNexposee(n, i, SKINPOSITION_DIALOG_CREDITS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
305                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
306
307                 i = NEW(XonoticQuitDialog);
308                 i.configureDialog(i);
309                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
310                 n.setNexposee(n, i, SKINPOSITION_DIALOG_QUIT, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
311                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
312
313         me.addItem(me, n, '0 0 0', '1 1 0', SKINALPHAS_MAINMENU_z);
314         me.moveItemAfter(me, n, NULL);
315
316         me.initializeDialog(me, n);
317 }