]> icculus.org git repositories - taylor/freespace2.git/blob - src/popup/popupdead.cpp
added copyright header
[taylor/freespace2.git] / src / popup / popupdead.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Popup/PopupDead.cpp $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * C module for the death popup
16  *
17  * $Log$
18  * Revision 1.3  2002/06/09 04:41:25  relnev
19  * added copyright header
20  *
21  * Revision 1.2  2002/05/07 03:16:51  theoddone33
22  * The Great Newline Fix
23  *
24  * Revision 1.1.1.1  2002/05/03 03:28:10  root
25  * Initial import.
26  *
27  * 
28  * 14    9/14/99 4:35a Dave
29  * Argh. Added all kinds of code to handle potential crashes in debriefing
30  * code.
31  * 
32  * 13    9/14/99 12:51a Jefff
33  * sm3-09 no skip hack.
34  * 
35  * 12    9/11/99 1:09a Mikek
36  * Removed semi-bogus Int3() in popupdead code which seemed to get tripped
37  * by the supernova.
38  * 
39  * 11    9/10/99 6:49p Jefff
40  * changed skip popup to normal type popup
41  * 
42  * 10    9/09/99 7:17p Jefff
43  * 
44  * 9     9/07/99 4:44p Jefff
45  * fixed double counting of mission failures
46  * 
47  * 8     9/07/99 1:54p Jefff
48  * skip mission cleanup
49  * 
50  * 7     9/06/99 9:46p Jefff
51  * skip mission support
52  * 
53  * 6     8/11/99 5:47p Jefff
54  * fixed button bitmap loading
55  * 
56  * 5     7/24/99 1:54p Dave
57  * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
58  * missions.
59  * 
60  * 4     6/01/99 3:52p Dave
61  * View footage screen. Fixed xstrings to not display the & symbol. Popup,
62  * dead popup, pxo find player popup, pxo private room popup.
63  * 
64  * 3     10/13/98 9:29a Dave
65  * Started neatening up freespace.h. Many variables renamed and
66  * reorganized. Added AlphaColors.[h,cpp]
67  * 
68  * 2     10/07/98 10:53a Dave
69  * Initial checkin.
70  * 
71  * 1     10/07/98 10:51a Dave
72  * 
73  * 11    6/09/98 10:31a Hoffoss
74  * Created index numbers for all xstr() references.  Any new xstr() stuff
75  * added from here on out should be added to the end if the list.  The
76  * current list count can be found in FreeSpace.cpp (search for
77  * XSTR_SIZE).
78  * 
79  * 10    5/17/98 1:43a Dave
80  * Eradicated chatbox problems. Remove speed match for observers. Put in
81  * help screens for PXO. Fix messaging and end mission privelges. Fixed
82  * team select screen bugs. Misc UI fixes.
83  * 
84  * 9     5/01/98 4:24p Lawrance
85  * Change "Main Hall" to "Flight Deck"
86  * 
87  * 8     4/22/98 4:59p Allender
88  * new multiplayer dead popup.  big changes to the comm menu system for
89  * team vs. team.  Start of debriefing stuff for team vs. team  Make form
90  * on my wing work with individual ships who have high priority orders
91  * 
92  * 7     3/12/98 4:02p Lawrance
93  * Cleanup how pause works, fix couple pause-related bugs.
94  * 
95  * 6     3/05/98 12:35p Lawrance
96  * Fix bug where two options could be highlighted at once.
97  * 
98  * 5     2/22/98 4:30p John
99  * More string externalization classification
100  * 
101  * 4     2/22/98 2:48p John
102  * More String Externalization Classification
103  * 
104  * 3     2/22/98 12:19p John
105  * Externalized some strings
106  * 
107  * 2     2/10/98 11:20p Lawrance
108  * Implement separate dead popup system
109  * 
110  * 1     2/10/98 6:02p Lawrance
111  *
112  * $NoKeywords: $
113  */
114
115
116 #define POPUPDEAD_NUM_CHOICES                           3               // normal
117 #define POPUPDEAD_NUM_CHOICES_RA                        4               // red alert
118 #define POPUPDEAD_NUM_CHOICES_SKIP              3               // skip mission menu
119
120 #define POPUPDEAD_NUM_CHOICES_MAX               4
121
122 #include "ui.h"
123 #include "key.h"
124 #include "mouse.h"
125 #include "freespace.h"
126 #include "gamesnd.h"
127 #include "keycontrol.h"
128 #include "player.h"
129 #include "multi.h"
130 #include "multiutil.h"
131 #include "popupdead.h"
132 #include "alphacolors.h"
133 #include "gamesequence.h"
134 #include "popup.h"
135
136 UI_WINDOW       Popupdead_window;
137 UI_BUTTON       Popupdead_buttons[POPUPDEAD_NUM_CHOICES_MAX];                           // actual lit buttons
138 UI_BUTTON       Popupdead_button_regions[POPUPDEAD_NUM_CHOICES_MAX];    // fake buttons used for mouse detection over text
139
140 int Popupdead_region_coords[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX][4] =
141 {       
142         {       // GR_640
143                 {464, 389, 497, 403},           // upper right pixel of text, lower right pixel of button (for tiny popup)
144                 {464, 413, 497, 427},
145                 {464, 435, 497, 446},           
146                 {464, 457, 497, 466},
147         }, 
148         {       // GR_1024
149                 {745, 627, 809, 664},
150                 {745, 663, 809, 700},           // upper right pixel of text, lower right pixel of button (for tiny popup)
151                 {745, 699, 809, 736},           
152                 {745, 735, 809, 772},
153         }, 
154 };
155
156 int Popupdead_button_coords[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX][2] =
157 {
158         {       // GR_640
159                 {478, 387},                                             // upper left pixel (tiny popup)
160                 {478, 410},
161                 {478, 432},
162                 {478, 455},
163         },
164         {       // GR_1024
165                 {760, 620},                                             // upper left pixel (tiny popup)
166                 {760, 656},
167                 {760, 692},
168                 {760, 728},
169         }
170 };
171
172 char *Popupdead_background_filename[GR_NUM_RESOLUTIONS] = {
173         "PopDeath",             // GR_640
174         "2_PopDeath"    // GR-1024
175 };
176
177 int Popupdead_background_coords[GR_NUM_RESOLUTIONS][2] = 
178 {
179         { // GR_640
180                 131, 363
181         },
182         { // GR_1024
183                 205, 581
184         }
185 };
186
187 char *Popupdead_button_filenames[GR_NUM_RESOLUTIONS][POPUPDEAD_NUM_CHOICES_MAX] = 
188 {
189         {       // GR_640
190                 "PopD_00",                              // first choice
191                 "PopD_01",                              // second choice
192                 "PopD_02",                              // third choice
193                 "PopD_03",                              // fourth choice
194         },
195         {       // GR_1024
196                 "2_PopD_00",                    // first choice
197                 "2_PopD_01",                    // second choice
198                 "2_PopD_02",                    // third choice
199                 "2_PopD_03",                    // fourth choice
200         }
201 };
202
203 int Popupdead_skip_message_y[GR_NUM_RESOLUTIONS] = { 
204                 96,     // GR_640
205                 160
206 };
207
208
209 static char *Popupdead_button_text[POPUPDEAD_NUM_CHOICES_MAX];
210
211 // multiplayer specifics to help with return values since they can vary
212 #define POPUPDEAD_OBS_ONLY                      1
213 #define POPUPDEAD_OBS_QUIT                      2
214 #define POPUPDEAD_RESPAWN_ONLY  3
215 #define POPUPDEAD_RESPAWN_QUIT  4
216
217 int Popupdead_default_choice;           // What the default choice is (ie activated when Enter pressed)
218 int Popupdead_active    =       0;                      // A dead popup is active
219 int Popupdead_choice;                           // Index for choice picked (-1 if none picked)
220 int Popupdead_num_choices;                      // number of buttons
221 int Popupdead_multi_type;                       // what kind of popup is active for muliplayer
222 int Popupdead_skip_active = 0;  // The skip-misison popup is active
223 int Popupdead_skip_already_shown = 0;
224
225 // Initialize the dead popup data
226 void popupdead_start()
227 {
228         int                     i;
229         UI_BUTTON       *b;
230
231         if ( Popupdead_active ) {
232                 // Int3();
233                 return;
234         }
235
236         // increment number of deaths
237         Player->failures_this_session++;
238
239
240         // create base window
241         Popupdead_window.create(Popupdead_background_coords[gr_screen.res][0], Popupdead_background_coords[gr_screen.res][1], 1, 1, 0);
242         Popupdead_window.set_foreground_bmap(Popupdead_background_filename[gr_screen.res]);
243
244         Popupdead_num_choices = 0;
245         Popupdead_multi_type = -1;
246
247         if ( Game_mode & GM_NORMAL ) {
248                 // also do a campaign check here?
249                 if (0) { //((Player->show_skip_popup) && (!Popupdead_skip_already_shown) && (Game_mode & GM_CAMPAIGN_MODE) && (Game_mode & GM_NORMAL) && (Player->failures_this_session >= PLAYER_MISSION_FAILURE_LIMIT)) {
250                         // init the special preliminary death popup that gives the skip option
251                         Popupdead_button_text[0] = XSTR( "Do Not Skip This Mission", 1473);
252                         Popupdead_button_text[1] = XSTR( "Advance To The Next Mission", 1474);
253                         Popupdead_button_text[2] = XSTR( "Don't Show Me This Again", 1475);
254                         Popupdead_num_choices = POPUPDEAD_NUM_CHOICES_SKIP;
255                         Popupdead_skip_active = 1;
256                 } else if(The_mission.red_alert) {
257                         // We can't staticly declare these because they are externalized
258                         Popupdead_button_text[0] = XSTR( "Quick Start Mission", 105);
259                         Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106);
260                         Popupdead_button_text[2] = XSTR( "Return To Briefing", 107);
261                         Popupdead_button_text[3] = XSTR( "Replay previous mission", 1432);
262                         Popupdead_num_choices = POPUPDEAD_NUM_CHOICES_RA;
263                 } else {
264                         Popupdead_button_text[0] = XSTR( "Quick Start Mission", 105);
265                         Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106);
266                         Popupdead_button_text[2] = XSTR( "Return To Briefing", 107);
267                         Popupdead_num_choices = POPUPDEAD_NUM_CHOICES;
268                 }
269         } else {
270                 // in multiplayer, we have different choices depending on respawn mode, etc.
271
272                 // if the player has run out of respawns and must either quit and become an observer
273                 if(Net_player->flags & NETINFO_FLAG_LIMBO){
274
275                         // the master should not be able to quit the game
276                         if( ((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (multi_num_players() > 1)) || (Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN) ) {
277                                 Popupdead_button_text[0] = XSTR( "Observer Mode", 108);
278                                 Popupdead_num_choices = 1;
279                                 Popupdead_multi_type = POPUPDEAD_OBS_ONLY;
280                         } else {
281                                 Popupdead_button_text[0] = XSTR( "Observer Mode", 108);
282                                 Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106);
283                                 Popupdead_num_choices = 2;
284                                 Popupdead_multi_type = POPUPDEAD_OBS_QUIT;
285                         }
286                 } else {
287                         // the master of the game should not be allowed to quit
288                         if ( ((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (multi_num_players() > 1)) || (Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN) ) {
289                                 Popupdead_button_text[0] = XSTR( "Respawn", 109);
290                                 Popupdead_num_choices = 1;
291                                 Popupdead_multi_type = POPUPDEAD_RESPAWN_ONLY;
292                         } else {
293                                 Popupdead_button_text[0] = XSTR( "Respawn", 109);
294                                 Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106);
295                                 Popupdead_num_choices = 2;
296                                 Popupdead_multi_type = POPUPDEAD_RESPAWN_QUIT;
297                         }
298                 }
299         }
300
301         // create buttons
302         for (i=0; i < Popupdead_num_choices; i++) {
303                 b = &Popupdead_buttons[i];
304                 b->create(&Popupdead_window, "", Popupdead_button_coords[gr_screen.res][i][0], Popupdead_button_coords[gr_screen.res][i][1], 30, 20, 0, 1);
305                 b->set_bmaps(Popupdead_button_filenames[gr_screen.res][i], 3, 0);
306                 b->set_highlight_action(common_play_highlight_sound);
307
308                 // create invisible buttons to detect mouse presses... can't use mask since button region is dynamically sized
309                 int lx, w, h;
310                 gr_get_string_size(&w, &h, Popupdead_button_text[i]);
311                 lx = Popupdead_region_coords[gr_screen.res][i][0] - w;
312                 b = &Popupdead_button_regions[i];       
313                 b->create(&Popupdead_window, "", lx, Popupdead_region_coords[gr_screen.res][i][1], Popupdead_region_coords[gr_screen.res][i][2]-lx, Popupdead_region_coords[gr_screen.res][i][3]-Popupdead_region_coords[gr_screen.res][i][1], 0, 1);
314                 b->hide();
315         }
316         
317         Popupdead_default_choice = 0;
318         Popupdead_choice = -1;
319         Popupdead_active = 1;
320 }
321
322 // maybe play a sound when key up/down is pressed to switch default choice
323 void popupdead_play_default_change_sound()
324 {
325         int i, mouse_over=0;
326         UI_BUTTON *br, *b;
327
328         // only play if mouse not currently highlighting a choice
329         for ( i = 0; i < Popupdead_num_choices; i++ ) {
330                 br = &Popupdead_button_regions[i];
331                 b = &Popupdead_buttons[i];
332                 if ( br->button_down() ) {
333                         mouse_over=1;
334                         break;
335                 }
336
337                 if ( br->button_hilighted() && !b->button_down() ) {
338                         mouse_over=1;
339                         break;
340                 }
341
342                 if ( b->button_hilighted() ) {
343                         mouse_over=1;
344                 }
345         }
346
347         if (!mouse_over) {
348                 gamesnd_play_iface(SND_USER_SELECT);
349         }
350 }
351
352 // do any key processing here
353 // exit:        -1              =>      nothing was done
354 //                      >=0     => a choice was selected
355 int popupdead_process_keys(int k)
356 {
357         int masked_k;
358
359         if ( k <= 0 ) {
360                 return -1;
361         }
362         
363         switch(k) {
364
365         case KEY_ENTER:
366                 return Popupdead_default_choice;        // select the current default choice
367                 break;
368
369         case KEY_ESC:
370                 if (Popupdead_skip_active) {
371                         return 0;                                                               // 0 mimics a "do not skip"
372                 } else {
373                         return 1;                                                               // do nothing here for now - 1 mimics a "return to flight deck"
374                 }
375                 break;
376
377         case KEY_DOWN:
378         case KEY_PAD2:
379         case KEY_TAB:
380                 popupdead_play_default_change_sound();
381                 Popupdead_default_choice++;
382                 if ( Popupdead_default_choice >= Popupdead_num_choices ) {
383                         Popupdead_default_choice=0;
384                 }
385                 break;
386
387         case KEY_UP:
388         case KEY_PAD8:
389         case KEY_SHIFTED+KEY_TAB:
390                 popupdead_play_default_change_sound();
391                 Popupdead_default_choice--;
392                 if ( Popupdead_default_choice < 0 ) {
393                         Popupdead_default_choice=Popupdead_num_choices-1;
394                 }
395                 break;
396
397         case KEY_PAUSE:
398                 game_process_pause_key();
399                 break;
400
401         default:
402                 break;
403         } // end switch
404
405         // read the dead key set
406         masked_k = k & ~KEY_CTRLED;     // take out CTRL modifier only
407         process_set_of_keys(masked_k, Dead_key_set_size, Dead_key_set);
408         button_info_do(&Player->bi);    // call functions based on status of button_info bit vectors
409
410         return -1;
411 }
412
413
414 // see if any popup buttons have been pressed
415 // exit: -1                                             => no buttons pressed
416 //                      >=0                                     =>      button index that was pressed
417 int popupdead_check_buttons()
418 {
419         int                     i;
420         UI_BUTTON       *b;
421
422         for ( i = 0; i < Popupdead_num_choices; i++ ) {
423                 b = &Popupdead_button_regions[i];
424                 if ( b->pressed() ) {
425                         return i;
426                 }
427
428                 b = &Popupdead_buttons[i];
429                 if ( b->pressed() ) {
430                         return i;
431                 }
432         }
433
434         return -1;
435 }
436
437 // See if any of the button should change appearance based on mouse position
438 void popupdead_force_draw_buttons()
439 {
440         int i,mouse_is_highlighting=0;
441         UI_BUTTON *br, *b;
442
443         for ( i = 0; i < Popupdead_num_choices; i++ ) {
444                 br = &Popupdead_button_regions[i];
445                 b = &Popupdead_buttons[i];
446                 if ( br->button_down() ) {
447                         b->draw_forced(2);
448                         mouse_is_highlighting=1;
449                         continue;
450                 }
451
452                 if ( (b->button_hilighted()) || (br->button_hilighted() && !b->button_down()) ) {
453                         Popupdead_default_choice=i;
454                         mouse_is_highlighting=1;
455                         b->draw_forced(1);
456                 }
457         }
458
459         // Only if mouse is not highlighting an option, let the default choice be drawn highlighted
460         if ( (!mouse_is_highlighting) && (Popupdead_num_choices>1) ) {
461                 for ( i = 0; i < Popupdead_num_choices; i++ ) {
462                         b = &Popupdead_buttons[i];
463                         // highlight the default choice
464                         if ( i == Popupdead_default_choice ) {
465                                 b->draw_forced(1);
466                         }
467                 }
468         }
469 }
470
471 // Draw the button text nicely formatted in the popup
472 void popupdead_draw_button_text()
473 {
474         int w,h,i,sx,sy;
475
476         gr_set_color_fast(&Color_bright_blue);
477
478         for ( i=0; i < Popupdead_num_choices; i++ ) {
479                 gr_get_string_size(&w, &h, Popupdead_button_text[i]);
480                 sx = Popupdead_region_coords[gr_screen.res][i][0]-w;
481                 sy = Popupdead_region_coords[gr_screen.res][i][1]+4;
482                 gr_string(sx, sy, Popupdead_button_text[i]);
483         }
484 }
485
486 // reinits the death popup
487 // used for skip popup to death popup transition
488 void popupdead_restart() {
489         Popupdead_skip_already_shown = 1;
490         Popupdead_skip_active = 0;
491         Popupdead_active = 0;
492         Player->failures_this_session--;                // hacky correction for a double count when calling popupdead_start() twice
493         popupdead_start();
494 }
495
496 // do the "skip mission" version of the death popup
497 int popupdead_skip_do_frame()
498 {
499         int k = Popupdead_window.process();
500
501         // check for input
502         int choice = popupdead_process_keys(k);
503         if (choice < 0) {
504                 choice = popupdead_check_buttons();
505         }
506
507         // take appropriate options
508         switch (choice) {
509         case 0:
510                 // try this mission again, so proceed to normal death popup
511                 gamesnd_play_iface(SND_USER_SELECT);
512                 popupdead_restart();
513                 break;
514         case 1:
515                 // skip this mission
516                 mission_campaign_skip_to_next();
517
518                 gamesnd_play_iface(SND_USER_SELECT);
519                 break;
520         case 2:
521                 // dont show this again
522                 Player->show_skip_popup = 0;
523                 
524                 gamesnd_play_iface(SND_USER_SELECT);
525                 popupdead_restart();
526                 break;
527         }
528
529         // render
530         Popupdead_window.draw();
531         popupdead_force_draw_buttons();
532         popupdead_draw_button_text();
533
534         // render skip mission message
535         gr_set_color_fast(&Color_bright_white);
536         gr_string(0x8000, Popupdead_skip_message_y[gr_screen.res], XSTR("You have failed this mission five times.", 1470));
537         gr_string(0x8000, Popupdead_skip_message_y[gr_screen.res] + gr_get_font_height(), XSTR("If you like, you may advance to the next mission.", 1471));
538
539         return choice;
540 }
541
542
543 // Called once per frame to run the dead popup
544 int popupdead_do_frame(float frametime)
545 {
546         int k, choice;
547
548 /*
549         if (Popupdead_skip_active) {
550                 // do the skip mission popup, and thats all
551                 if (popupdead_skip_do_frame() == 1) {
552                         return 2;       // fake the "go to briefing" choice
553                 } else {
554                         return -1;      // fake no choice
555                 }
556         }
557 */
558         if ( !Popupdead_active ) {
559                 return -1;
560         }
561
562         // dont let dude skip 3-09.  hack.
563         if(Game_mode & GM_CAMPAIGN_MODE){
564                 if((Campaign.current_mission >= 0) && (Campaign.current_mission < MAX_CAMPAIGN_MISSIONS)){
565                         if ((Campaign.missions[Campaign.current_mission].name != NULL) && !stricmp(Campaign.missions[Campaign.current_mission].name, "sm3-09.fs2")) {
566                                 Popupdead_skip_already_shown = 1;
567                         }
568                 }
569         }
570
571         // maybe show skip mission popup
572         if ((!Popupdead_skip_already_shown) && (Player->show_skip_popup) && (Game_mode & GM_NORMAL) && (Game_mode & GM_CAMPAIGN_MODE) && (Player->failures_this_session >= PLAYER_MISSION_FAILURE_LIMIT)) {
573                 int popup_choice = popup(0, 3, XSTR("Do Not Skip This Mission", 1473),
574                                                                                                  XSTR("Advance To The Next Mission", 1474),
575                                                                                                  XSTR("Don't Show Me This Again", 1475),
576                                                                                                  XSTR("You have failed this mission five times.  If you like, you may advance to the next mission.", 1472) );
577                 switch (popup_choice) {
578                 case 0:
579                         // stay on this mission, so proceed to normal death popup
580                         // in other words, do nothing.
581                         break;
582                 case 1:
583                         // skip this mission
584                         Popupdead_active = 0;
585                         mission_campaign_skip_to_next();
586                         gameseq_post_event(GS_EVENT_START_GAME);
587                         return -1;
588                 case 2:
589                         // dont show this again
590                         Player->show_skip_popup = 0;
591                         break;
592                 }
593
594                 Popupdead_skip_already_shown = 1;
595         }
596
597         
598         k = Popupdead_window.process();
599
600         choice = popupdead_process_keys(k);
601         if ( choice >= 0 ) {
602                 // do something different for single/multiplayer
603                 if ( Game_mode & GM_NORMAL ) {
604                         Popupdead_choice=choice;
605                 } else {
606                         Assert( Popupdead_multi_type != -1 );
607                         switch ( Popupdead_multi_type ) {
608                                 
609                         case POPUPDEAD_OBS_ONLY:
610                         case POPUPDEAD_OBS_QUIT:
611                                 Popupdead_choice = POPUPDEAD_DO_OBSERVER;
612                                 if ( (Popupdead_multi_type == POPUPDEAD_OBS_QUIT) && (choice == 1) )
613                                         Popupdead_choice = POPUPDEAD_DO_MAIN_HALL;
614                                 break;
615
616                         case POPUPDEAD_RESPAWN_ONLY:
617                         case POPUPDEAD_RESPAWN_QUIT:
618                                 Popupdead_choice = POPUPDEAD_DO_RESPAWN;
619                                 if ( (Popupdead_multi_type == POPUPDEAD_RESPAWN_QUIT) && (choice == 1) )
620                                         Popupdead_choice = POPUPDEAD_DO_MAIN_HALL;
621                                 break;
622
623                         default:
624                                 Int3();
625                                 break;
626                         }
627                 }
628         }
629
630         choice = popupdead_check_buttons();
631         if ( choice >= 0 ) {
632                 // do something different for single/multiplayer
633                 if ( Game_mode & GM_NORMAL ) {
634                         Popupdead_choice=choice;
635                 } else {
636                         Assert( Popupdead_multi_type != -1 );
637                         switch ( Popupdead_multi_type ) {
638                                 
639                         case POPUPDEAD_OBS_ONLY:
640                         case POPUPDEAD_OBS_QUIT:
641                                 Popupdead_choice = POPUPDEAD_DO_OBSERVER;
642                                 if ( (Popupdead_multi_type == POPUPDEAD_OBS_QUIT) && (choice == 1) )
643                                         Popupdead_choice = POPUPDEAD_DO_MAIN_HALL;
644                                 break;
645
646                         case POPUPDEAD_RESPAWN_ONLY:
647                         case POPUPDEAD_RESPAWN_QUIT:
648                                 Popupdead_choice = POPUPDEAD_DO_RESPAWN;
649                                 if ( (Popupdead_multi_type == POPUPDEAD_RESPAWN_QUIT) && (choice == 1) )
650                                         Popupdead_choice = POPUPDEAD_DO_MAIN_HALL;
651                                 break;
652
653                         default:
654                                 Int3();
655                                 break;
656                         }
657                 }
658         }
659
660         Popupdead_window.draw();
661         popupdead_force_draw_buttons();
662         popupdead_draw_button_text();
663
664         return Popupdead_choice;
665 }
666
667 // Close down the dead popup
668 void popupdead_close()
669 {
670         if ( !Popupdead_active ) {
671                 return;
672         }
673
674         gamesnd_play_iface(SND_POPUP_DISAPPEAR);
675         Popupdead_window.destroy();
676         game_flush();
677
678         Popupdead_active = 0;
679         Popupdead_skip_active = 0;
680         Popupdead_skip_already_shown = 0;
681 }
682
683 // Is there a dead popup active?
684 int popupdead_is_active()
685 {
686         return Popupdead_active;
687
688