]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/mainwindow.qc
Add sv_itemstime cvar so itemstime can be completely disabled by the server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / mainwindow.qc
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3 #include "../item/modalcontroller.qc"
4 CLASS(MainWindow, ModalController)
5         METHOD(MainWindow, configureMainWindow, void(entity))
6         METHOD(MainWindow, draw, void(entity))
7         ATTRIB(MainWindow, firstRunDialog, entity, NULL)
8         ATTRIB(MainWindow, advancedDialog, entity, NULL)
9         ATTRIB(MainWindow, mutatorsDialog, entity, NULL)
10         ATTRIB(MainWindow, mapInfoDialog, entity, NULL)
11         ATTRIB(MainWindow, userbindEditDialog, entity, NULL)
12         ATTRIB(MainWindow, winnerDialog, entity, NULL)
13         ATTRIB(MainWindow, serverInfoDialog, entity, NULL)
14         ATTRIB(MainWindow, cvarsDialog, entity, NULL)
15         ATTRIB(MainWindow, screenshotViewerDialog, entity, NULL)
16         ATTRIB(MainWindow, viewDialog, entity, NULL)
17         ATTRIB(MainWindow, hudconfirmDialog, entity, NULL)
18         ATTRIB(MainWindow, languageWarningDialog, entity, NULL)
19         ATTRIB(MainWindow, mainNexposee, entity, NULL)
20         ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND)
21         ATTRIB(MainWindow, dialogToShow, entity, NULL)
22         ATTRIB(MainWindow, demostartconfirmDialog, entity, NULL)
23         ATTRIB(MainWindow, demotimeconfirmDialog, entity, NULL)
24         ATTRIB(MainWindow, resetDialog, 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 = NEW(XonoticFirstRunDialog);
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 = NEW(XonoticHUDExitDialog);
60         i.configureDialog(i);
61         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
62
63         i = NEW(XonoticHUDNotificationDialog);
64         i.configureDialog(i);
65         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
66
67         i = NEW(XonoticHUDAmmoDialog);
68         i.configureDialog(i);
69         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
70
71         i = NEW(XonoticHUDHealthArmorDialog);
72         i.configureDialog(i);
73         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
74
75         i = NEW(XonoticHUDChatDialog);
76         i.configureDialog(i);
77         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
78
79         i = NEW(XonoticHUDModIconsDialog);
80         i.configureDialog(i);
81         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
82
83         i = NEW(XonoticHUDPowerupsDialog);
84         i.configureDialog(i);
85         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
86
87         i = NEW(XonoticHUDPressedKeysDialog);
88         i.configureDialog(i);
89         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
90
91         i = NEW(XonoticHUDRaceTimerDialog);
92         i.configureDialog(i);
93         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
94
95         i = NEW(XonoticHUDRadarDialog);
96         i.configureDialog(i);
97         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
98
99         i = NEW(XonoticHUDScoreDialog);
100         i.configureDialog(i);
101         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
102
103         i = NEW(XonoticHUDTimerDialog);
104         i.configureDialog(i);
105         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
106
107         i = NEW(XonoticHUDVoteDialog);
108         i.configureDialog(i);
109         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
110
111         i = NEW(XonoticHUDWeaponsDialog);
112         i.configureDialog(i);
113         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
114
115         i = NEW(XonoticHUDEngineInfoDialog);
116         i.configureDialog(i);
117         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
118
119         i = NEW(XonoticHUDInfoMessagesDialog);
120         i.configureDialog(i);
121         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
122
123         i = NEW(XonoticHUDPhysicsDialog);
124         i.configureDialog(i);
125         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
126
127         me.screenshotViewerDialog = i = NEW(XonoticScreenshotViewerDialog);
128         i.configureDialog(i);
129         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
130
131         i = NEW(XonoticHUDCenterprintDialog);
132         i.configureDialog(i);
133         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
134
135         i = NEW(XonoticHUDBuffsDialog);
136         i.configureDialog(i);
137         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
138
139         i = NEW(XonoticHUDItemsTimeDialog);
140         i.configureDialog(i);
141         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
142
143
144         // dialogs used by settings
145         me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog);
146         i.configureDialog(i);
147         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
148
149         me.cvarsDialog = i = NEW(XonoticCvarsDialog);
150         i.configureDialog(i);
151         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
152
153         me.resetDialog = i = NEW(XonoticResetDialog);
154         i.configureDialog(i);
155         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
156
157         me.languageWarningDialog = i = NEW(XonoticLanguageWarningDialog);
158         i.configureDialog(i);
159         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
160
161         me.hudconfirmDialog = i = NEW(XonoticHUDConfirmDialog);
162         i.configureDialog(i);
163         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
164
165
166         // dialog used by singleplayer
167         me.winnerDialog = i = NEW(XonoticWinnerDialog);
168         i.configureDialog(i);
169         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
170
171
172         // dialog used by multiplayer/join
173         me.serverInfoDialog = i = NEW(XonoticServerInfoDialog);
174         i.configureDialog(i);
175         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
176
177         me.demostartconfirmDialog = i = NEW(XonoticDemoStartConfirmDialog);
178         i.configureDialog(i);
179         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
180
181         me.demotimeconfirmDialog = i = NEW(XonoticDemoTimeConfirmDialog);
182         i.configureDialog(i);
183         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
184
185
186         // dialogs used by multiplayer/create
187         me.mapInfoDialog = i = NEW(XonoticMapInfoDialog);
188         i.configureDialog(i);
189         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
190
191         me.mutatorsDialog = i = NEW(XonoticMutatorsDialog);
192         i.configureDialog(i);
193         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
194
195         // mutator dialogs
196         i = NEW(XonoticSandboxToolsDialog);
197         i.configureDialog(i);
198         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
199
200
201         // miscellaneous dialogs
202         i = NEW(XonoticTeamSelectDialog);
203         i.configureDialog(i);
204         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
205
206         i = NEW(XonoticMonsterToolsDialog);
207         i.configureDialog(i);
208         me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
209
210
211         // main dialogs/windows
212         me.mainNexposee = n = NEW(XonoticNexposee);
213         /*
214                 if(checkextension("DP_GECKO_SUPPORT"))
215                 {
216                         i = spawnXonoticNewsDialog();
217                         i.configureDialog(i);
218                         n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
219                         n.setNexposee(n, i, '0.1 0.1 0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
220                 }
221         */
222                 i = NEW(XonoticSingleplayerDialog);
223                 i.configureDialog(i);
224                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
225                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SINGLEPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
226
227                 i = NEW(XonoticMultiplayerDialog);
228                 i.configureDialog(i);
229                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
230                 n.setNexposee(n, i, SKINPOSITION_DIALOG_MULTIPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
231
232                 i = NEW(XonoticSettingsDialog);
233                 i.configureDialog(i);
234                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
235                 n.setNexposee(n, i, SKINPOSITION_DIALOG_SETTINGS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
236
237                 i = NEW(XonoticCreditsDialog);
238                 i.configureDialog(i);
239                 n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
240                 n.setNexposee(n, i, SKINPOSITION_DIALOG_CREDITS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
241                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
242
243                 i = NEW(XonoticQuitDialog);
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_QUIT, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
247                 n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
248
249         me.addItem(me, n, '0 0 0', '1 1 0', SKINALPHAS_MAINMENU_z);
250         me.moveItemAfter(me, n, NULL);
251
252         me.initializeDialog(me, n);
253
254         if(cvar_string("_cl_name") == cvar_defstring("_cl_name"))
255                 me.dialogToShow = me.firstRunDialog;
256 }
257 #endif
258
259 /* Click. The c-word is here so you can grep for it :-) */