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