Xonotic
mainwindow.qc
Go to the documentation of this file.
1 #include "mainwindow.qh"
2 
3 #include <menu/mutators/_mod.qh>
4 
5 #include "nexposee.qh"
6 #include "inputbox.qh"
8 #include "dialog_firstrun.qh"
11 #include "dialog_hudpanel_ammo.qh"
13 #include "dialog_hudpanel_chat.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"
30 
44 #include "dialog_sandboxtools.qh"
45 #include "dialog_monstertools.qh"
46 #include "dialog_teamselect.qh"
47 #include "dialog_uid2name.qh"
48 #include "dialog_singleplayer.qh"
49 #include "dialog_multiplayer.qh"
50 #include "dialog_settings.qh"
51 #include "dialog_credits.qh"
52 #include "dialog_quit.qh"
53 
54 #include "dialog_disconnect.qh"
55 
56 
57 
59 {
60  SUPER(MainWindow).draw(me);
61 
62  if (me.firstDraw) {
63  if (me.ToSDialog.shouldShow())
64  {
65  me.ToSDialog.loadXonoticToS(me.ToSDialog);
66  DialogOpenButton_Click_withCoords(NULL, me.ToSDialog, '0 0 0', eX * conwidth + eY * conheight);
67  }
68  else if(me.firstRunDialog.shouldShow())
69  DialogOpenButton_Click_withCoords(NULL, me.firstRunDialog, '0 0 0', eX * conwidth + eY * conheight);
70 
71  me.firstDraw = false;
72  }
73 
74  //-------------------------------------
75  // Part of Disconnect Dialog button:
76  // In case of this function is recalling every time, need to use condition of visibility
77 
78  if (me.disconnectDialogVisibility && !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED)))
79  {
80  // If gamestate is not "ingame" (and it is a first "frame" of drawing (or dialog is visible)),
81  // disconnect button is unnecessary, remove it
82  me.removeItem(me.mainNexposee, me.disconnectDialog);
83  me.disconnectDialogVisibility = 0;
84 
85  } else if(!me.disconnectDialogVisibility && (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))) {
86 
87  // If gamestate is "ingame" (and dialog is not visible),
88  // make disconnect button visible
89  entity n, i;
90  n = me.mainNexposee;
91  i = me.disconnectDialog;
92  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
93  n.setNexposee(n, i, '0.5 1.2 0.0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
94  me.disconnectDialogVisibility = 1;
95  }
96 
97  // I haven't found the best solution for making button visible.
98  // Alpha channel is the worst thing, because dialog with alpha is also clickable
99  //-------------------------------------
100 }
101 
103 {
104  if(me.text == _("Do not press this button again!"))
105  DialogOpenButton_Click(me, other);
106  else
107  me.setText(me, _("Do not press this button again!"));
108 }
109 
111 {
112  entity n, i;
113 
114  // terms of service dialog
115  me.ToSDialog = i = NEW(XonoticToSDialog);
116  i.configureDialog(i);
117  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
118 
119  // dialog run upon startup
120  me.firstRunDialog = i = NEW(XonoticFirstRunDialog);
121  i.configureDialog(i);
122  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
123 
124 
125  // hud_configure dialogs
127  i.configureDialog(i);
128  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
129 
131  i.configureDialog(i);
132  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
133 
135  i.configureDialog(i);
136  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
137 
139  i.configureDialog(i);
140  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
141 
143  i.configureDialog(i);
144  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
145 
147  i.configureDialog(i);
148  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
149 
151  i.configureDialog(i);
152  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
153 
155  i.configureDialog(i);
156  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
157 
159  i.configureDialog(i);
160  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
161 
163  i.configureDialog(i);
164  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
165 
167  i.configureDialog(i);
168  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
169 
171  i.configureDialog(i);
172  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
173 
175  i.configureDialog(i);
176  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
177 
179  i.configureDialog(i);
180  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
181 
183  i.configureDialog(i);
184  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
185 
187  i.configureDialog(i);
188  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
189 
191  i.configureDialog(i);
192  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
193 
195  i.configureDialog(i);
196  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
197 
199  i.configureDialog(i);
200  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
201 
203  i.configureDialog(i);
204  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
205 
207  i.configureDialog(i);
208  me.addItemRightCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
209 
210  // dialogs used by settings
211  me.userbindEditDialog = i = NEW(XonoticUserbindEditDialog);
212  i.configureDialog(i);
213  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
214 
215  me.bindingsResetDialog = i = NEW(XonoticBindingsResetDialog);
216  i.configureDialog(i);
217  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
218 
219  me.cvarsDialog = i = NEW(XonoticCvarsDialog);
220  i.configureDialog(i);
221  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
222 
223  me.resetDialog = i = NEW(XonoticResetDialog);
224  i.configureDialog(i);
225  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
226 
227  me.languageWarningDialog = i = NEW(XonoticLanguageWarningDialog);
228  i.configureDialog(i);
229  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
230 
231  me.hudconfirmDialog = i = NEW(XonoticHUDConfirmDialog);
232  i.configureDialog(i);
233  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
234 
235 
236  // dialog used by singleplayer
237  me.winnerDialog = i = NEW(XonoticWinnerDialog);
238  i.configureDialog(i);
239  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
240 
241 
242  // dialog used by multiplayer/join
243  me.serverInfoDialog = i = NEW(XonoticServerInfoDialog);
244  i.configureDialog(i);
245  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
246 
247  me.demostartconfirmDialog = i = NEW(XonoticDemoStartConfirmDialog);
248  i.configureDialog(i);
249  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
250 
251  me.demotimeconfirmDialog = i = NEW(XonoticDemoTimeConfirmDialog);
252  i.configureDialog(i);
253  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
254 
255 
256  // dialogs used by multiplayer/create
257  me.mapInfoDialog = i = NEW(XonoticMapInfoDialog);
258  i.configureDialog(i);
259  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
260 
261  me.mutatorsDialog = i = NEW(XonoticMutatorsDialog);
262  i.configureDialog(i);
263  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
264 
265 
266  // dialogs used by multiplayer/media
267  me.screenshotViewerDialog = i = NEW(XonoticScreenshotViewerDialog);
268  i.configureDialog(i);
269  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
270 
271 
272  // mutator dialogs
274  i.configureDialog(i);
275  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
276 
277 
278  // miscellaneous dialogs
280  i.configureDialog(i);
281  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
282 
284  i.configureDialog(i);
285  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
286 
288  i.configureDialog(i);
289  me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z * SKINALPHA_DIALOG_SANDBOXTOOLS);
290 
291  MUTATOR_CALLHOOK(ConfigureDialogs, me);
292 
293 
294  // main dialogs/windows
295  me.mainNexposee = n = NEW(XonoticNexposee);
296 
297  /*
298  if(checkextension("DP_GECKO_SUPPORT"))
299  {
300  i = spawnXonoticNewsDialog();
301  i.configureDialog(i);
302  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
303  n.setNexposee(n, i, '0.1 0.1 0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
304  }
305  */
306 
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_SINGLEPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
311 
313  i.configureDialog(i);
314  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
315  n.setNexposee(n, i, SKINPOSITION_DIALOG_MULTIPLAYER, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
316 
318  i.configureDialog(i);
319  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
320  n.setNexposee(n, i, SKINPOSITION_DIALOG_SETTINGS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
321 
323  i.configureDialog(i);
324  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
325  n.setNexposee(n, i, SKINPOSITION_DIALOG_CREDITS, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
326  n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
327 
328  //Disconnect dialog at center of screen (between credits and quit)
330  i.configureDialog(i);
331  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
332  n.setNexposee(n, i, '0.5 1.2 0.0', SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
333  n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
334  me.disconnectDialog = i;
335 
336  i = NEW(XonoticQuitDialog);
337  i.configureDialog(i);
338  n.addItemCentered(n, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
339  n.setNexposee(n, i, SKINPOSITION_DIALOG_QUIT, SKINALPHAS_MAINMENU_x, SKINALPHAS_MAINMENU_y);
340  n.pullNexposee(n, i, eY * (SKINHEIGHT_TITLE * SKINFONTSIZE_TITLE / conheight));
341 
342  me.addItem(me, n, '0 0 0', '1 1 0', SKINALPHAS_MAINMENU_z);
343  me.moveItemAfter(me, n, NULL);
344 
345  me.initializeDialog(me, n);
346  me.disconnectDialogVisibility = 1;
347 }
const vector eY
Definition: vector.qh:45
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
void DialogOpenButton_Click(entity button, entity tab)
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
entity other
Definition: csprogsdefs.qc:14
#define SUPER(cname)
Definition: oo.qh:219
void DemoButton_Click(entity me, entity other)
Definition: mainwindow.qc:102
void MainWindow_draw(entity me)
Definition: mainwindow.qc:58
#define NULL
Definition: post.qh:17
const vector eX
Definition: vector.qh:44
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void MainWindow_configureMainWindow(entity me)
Definition: mainwindow.qc:110