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