示例#1
0
文件: sgame.c 项目: grrk-bzzt/kqlives
/*! \brief Display system menu
 *
 * This is the system menu that is invoked from within the game.
 * From here you can save, load, configure a couple of options or
 * exit the game altogether.
 * \date 20040229 PH added 'Save anytime' facility when cheat mode is ON
 *
 * \returns 0 if cancelled or nothing happened, 1 otherwise
 */
int system_menu (void)
{
   int stop = 0, ptr = 0;
   char save_str[10];
   int text_color = FNORMAL;

   strcpy (save_str, _("Save  "));

   if (cansave == 0) {
      text_color = FDARK;
#ifdef KQ_CHEATS
      if (cheat) {
         strcpy (save_str, _("[Save]"));
         text_color = FNORMAL;
      }
#endif /* KQ_CHEATS */
   }

   while (!stop) {
      check_animation ();
      drawmap ();
      menubox (double_buffer, xofs, yofs, 8, 4, BLUE);

      print_font (double_buffer, 16 + xofs, 8 + yofs, save_str, text_color);
      print_font (double_buffer, 16 + xofs, 16 + yofs, _("Load"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 24 + yofs, _("Config"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 32 + yofs, _("Exit"), FNORMAL);

      draw_sprite (double_buffer, menuptr, 0 + xofs, ptr * 8 + 8 + yofs);
      blit2screen (xofs, yofs);
      readcontrols ();


      // TT:
      // When pressed, 'up' or 'down' == 1.  Otherwise, they equal 0.  So:
      //    ptr = ptr - up + down;
      // will correctly modify the pointer, but with less code.
      if (up || down) {
         ptr = ptr + up - down;
         if (ptr < 0)
            ptr = 3;
         else if (ptr > 3)
            ptr = 0;
         play_effect (SND_CLICK, 128);
         unpress ();
      }

      if (balt) {
         unpress ();

         if (ptr == 0) {
            // Pointer is over the SAVE option
#ifdef KQ_CHEATS
            if (cansave == 1 || cheat)
#else
            if (cansave == 1)
#endif /* KQ_CHEATS */
            {
               saveload (1);
               stop = 1;
            } else
               play_effect (SND_BAD, 128);
         }

         if (ptr == 1) {
            if (saveload (0) != 0)
               stop = 1;
         }

         if (ptr == 2)
            config_menu ();

         if (ptr == 3)
            return confirm_quit ();
      }

      if (bctrl) {
         stop = 1;
         unpress ();
      }
   }

   return 0;
}
示例#2
0
void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) {
	if (data.byte(kNewlocation) != 0xff)
		return;

	const RectWithCallback *rectWithCallback = rectWithCallbacks;
	while (rectWithCallback->xMin() != 0xffff) {
		if (rectWithCallback->contains(data.word(kMousex), data.word(kMousey))) {
			uint16 callback = rectWithCallback->callback();

			// common
			if(callback == addr_blank)
				blank();
			else if(callback == addr_getbackfromob)
				getbackfromob();
			else if(callback == addr_incryanpage)
				incryanpage();
			else if(callback == addr_getback1)
				getback1();
			else if(callback == addr_quitkey)
				quitkey();
			else if(callback == addr_dosreturn)
				dosreturn();
			else if(callback == addr_getbacktoops)
				getbacktoops();
			else if(callback == addr_selectslot)
				selectslot();
			// examlist
			else if(callback == addr_useobject)
				useobject();
			else if(callback == addr_selectopenob)
				selectopenob();
			else if(callback == addr_setpickup)
				setpickup();
			else if(callback == addr_examinventory)
				examinventory();
			// invlist1
			else if(callback == addr_dropobject)
				dropobject();
			else if(callback == addr_useopened)
				useopened();
			else if(callback == addr_setpickup)
				setpickup();
			else if(callback == addr_intoinv)
				intoinv();
			// withlist1
			else if(callback == addr_selectob)
				selectob();
			// talklist
			else if(callback == addr_moretalk)
				moretalk();
			// quitlist
			// destlist
			else if(callback == addr_nextdest)
				nextdest();
			else if(callback == addr_lastdest)
				lastdest();
			else if(callback == addr_lookatplace)
				lookatplace();
			else if(callback == addr_destselect)
				destselect();
			// keypadlist
			else if(callback == addr_buttonone)
				buttonone();
			else if(callback == addr_buttontwo)
				buttontwo();
			else if(callback == addr_buttonthree)
				buttonthree();
			else if(callback == addr_buttonfour)
				buttonfour();
			else if(callback == addr_buttonfive)
				buttonfive();
			else if(callback == addr_buttonsix)
				buttonsix();
			else if(callback == addr_buttonseven)
				buttonseven();
			else if(callback == addr_buttoneight)
				buttoneight();
			else if(callback == addr_buttonnine)
				buttonnine();
			else if(callback == addr_buttonnought)
				buttonnought();
			else if(callback == addr_buttonenter)
				buttonenter();
			// menulist
			// folderlist
			else if(callback == addr_nextfolder)
				nextfolder();
			else if(callback == addr_lastfolder)
				lastfolder();
			// symbollist
			else if(callback == addr_quitsymbol)
				quitsymbol();
			else if(callback == addr_settopleft)
				settopleft();
			else if(callback == addr_settopright)
				settopright();
			else if(callback == addr_setbotleft)
				setbotleft();
			else if(callback == addr_setbotright)
				setbotright();
			// diarylist
			else if(callback == addr_diarykeyn)
				diarykeyn();
			else if(callback == addr_diarykeyp)
				diarykeyp();
			else if(callback == addr_quitkey)
				quitkey();
			// opslist
			else if(callback == addr_getbackfromops)
				getbackfromops();
			else if(callback == addr_discops)
				discops();
			// discopslist
			else if(callback == addr_loadgame)
				loadgame();
			else if(callback == addr_savegame)
				savegame();
			// mainlist, mainlist2
			else if(callback == addr_look)
				look();
			else if(callback == addr_inventory)
				inventory();
			else if(callback == addr_zoomonoff)
				zoomonoff();
			else if(callback == addr_saveload)
				saveload();
			else if(callback == addr_madmanrun)
				madmanrun();
			else if(callback == addr_identifyob)
				identifyob();
			// decidelist
			else if(callback == addr_newgame)
				newgame();
			else if(callback == addr_loadold)
				loadold();
			// loadlist
			else if(callback == addr_actualload)
				actualload();
			// savelist
			else if(callback == addr_actualsave)
				actualsave();
			else {
				debug("__dispatch_call remaining in checkcoords! %d", (int)callback);
				__dispatch_call(callback);
			}
			return;
		}
		++rectWithCallback;
	}
}
示例#3
0
文件: sgame.c 项目: grrk-bzzt/kqlives
/*! \brief Main menu screen
 *
 * This is the main menu... just display the opening and then the menu and
 * then wait for input.  Also handles loading a saved game, and the config menu.
 *
 * \param   c zero if the splash (the bit with the staff and the eight heroes)
 *            should be displayed.
 * \returns 1 if new game, 0 if continuing, 2 if exit
 */
int start_menu (int skip_splash)
{
   int stop = 0, ptr = 0, redraw = 1, a, b;
   DATAFILE *bg;
   BITMAP *staff, *dudes, *tdudes;

#ifdef DEBUGMODE
   if (debugging == 0) {
#endif
      play_music ("oxford.s3m", 0);
      /* Play splash (with the staff and the heroes in circle */
      if (skip_splash == 0) {
         bg = load_datafile_object (PCX_DATAFILE, "KQT_PCX");
         staff = create_bitmap_ex (8, 72, 226);
         dudes = create_bitmap_ex (8, 112, 112);
         tdudes = create_bitmap_ex (8, 112, 112);
         blit ((BITMAP *) bg->dat, staff, 0, 7, 0, 0, 72, 226);
         blit ((BITMAP *) bg->dat, dudes, 80, 0, 0, 0, 112, 112);
         clear_bitmap (double_buffer);
         blit (staff, double_buffer, 0, 0, 124, 22, 72, 226);
         blit2screen (0, 0);

         kq_wait (1000);
         for (a = 0; a < 42; a++) {
            stretch_blit (staff, double_buffer, 0, 0, 72, 226, 124 - (a * 32),
                          22 - (a * 96), 72 + (a * 64), 226 + (a * 192));
            blit2screen (0, 0);
            kq_wait (100);
         }
         for (a = 0; a < 5; a++) {
            color_scale (dudes, tdudes, 53 - a, 53 + a);
            draw_sprite (double_buffer, tdudes, 106, 64);
            blit2screen (0, 0);
            kq_wait (100);
         }
         draw_sprite (double_buffer, dudes, 106, 64);
         blit2screen (0, 0);
         kq_wait (1000);
         destroy_bitmap (staff);
         destroy_bitmap (dudes);
         destroy_bitmap (tdudes);
		 unload_datafile_object(bg);
         /*
            TODO: this fade should actually be to white
            if (_color_depth == 8)
            fade_from (pal, whp, 1);
            else
          */
         do_transition (TRANS_FADE_WHITE, 1);
      }
      clear_to_color (double_buffer, 15);
      blit2screen (0, 0);
      set_palette (pal);
      bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
      for (a = 0; a < 16; a++) {
         clear_to_color (double_buffer, 15 - a);
         masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 60 - (a * 4),
                      320, 124);
         blit2screen (0, 0);
         kq_wait (a == 0 ? 500 : 100);
      }
      if (skip_splash == 0)
         kq_wait (500);
#ifdef DEBUGMODE
   } else {
      set_palette (pal);
      bg = load_datafile_object (PCX_DATAFILE, "TITLE_PCX");
   }
#endif

   reset_world ();

   /* Draw menu and handle menu selection */
   while (!stop) {
      if (redraw) {
         clear_bitmap (double_buffer);
         masked_blit ((BITMAP *) bg->dat, double_buffer, 0, 0, 0, 0, 320, 124);
         menubox (double_buffer, 112, 116, 10, 4, BLUE);
         print_font (double_buffer, 128, 124, _("Continue"), FNORMAL);
         print_font (double_buffer, 128, 132, _("New Game"), FNORMAL);
         print_font (double_buffer, 136, 140, _("Config"), FNORMAL);
         print_font (double_buffer, 144, 148, _("Exit"), FNORMAL);
         draw_sprite (double_buffer, menuptr, 112, ptr * 8 + 124);
         redraw = 0;
      }
      display_credits ();
      blit2screen (0, 0);
      readcontrols ();
      if (bhelp) {
         unpress ();
         show_help ();
         redraw = 1;
      }
      if (up) {
         unpress ();
         if (ptr > 0)
            ptr--;
         else
            ptr = 3;
         play_effect (SND_CLICK, 128);
         redraw = 1;
      }
      if (down) {
         unpress ();
         if (ptr < 3)
            ptr++;
         else
            ptr = 0;
         play_effect (SND_CLICK, 128);
         redraw = 1;
      }
      if (balt) {
         unpress ();
         if (ptr == 0) {        /* User selected "Continue" */
            if (snc[0] == 0 && snc[1] == 0 && snc[2] == 0 && snc[3] == 0
                && snc[4] == 0)
               stop = 2;
            else if (saveload (0) == 1)
               stop = 1;
            redraw = 1;
         } else if (ptr == 1) { /* User selected "New Game" */
            stop = 2;
         } else if (ptr == 2) { /* Config */
            clear (double_buffer);
            config_menu ();
            redraw = 1;

            /* TODO: Save Global Settings Here */
         } else if (ptr == 3) { /* Exit */
            unload_datafile_object (bg);
            klog (_("Then exit you shall!"));
            return 2;
         }
      }
   }
   unload_datafile_object (bg);
   if (stop == 2) {
      /* New game init */
      for (a = 0; a < MAXCHRS; a++)
         memcpy (&party[a], &players[a].plr, sizeof (s_player));
      init_players ();
      memset (progress, 0, SIZE_PROGRESS);
      memset (treasure, 0, SIZE_TREASURE);
      numchrs = 0;
      for (a = 0; a < NUMSHOPS; a++) {
         for (b = 0; b < SHOPITEMS; b++)
            shops[a].items_current[b] = shops[a].items_max[b];
      }
      for (b = 0; b < 2; b++) {
         for (a = 0; a < MAX_INV; a++)
            g_inv[a][b] = 0;
      }
   }
   return stop - 1;
}