示例#1
0
文件: menu.cpp 项目: zugz/ASCIIpOrtal
int select_level (MapPack const & mappack) {
  int input;
  int level = mappack.get_currentlevel();
  int maxlevel = mappack.get_maxlevel() + 1;

  if (maxlevel > mappack.get_number_maps())
    maxlevel = mappack.get_number_maps();
  if (level == 0)
    level = mappack.get_lastlevel();

  pauserun(1);
  fillsquare(LINES / 2 - 2, (COLS - 16) / 2, 4, 16);
  do {
    mvprintw(LINES / 2 - 1, (COLS - 14) / 2, "Choose a Level");
    mvprintw(LINES / 2, (COLS - 7) / 2, "< %3d >", level);
    refresh();
    restms(10);
    input = getinput();
    if (input == 27) return -1; // Back to the menu
#ifdef PDCURSES
    if (input == KEY_RESIZE) resize_term(0,0);
#endif
#ifndef __NOSOUND__
    if ((input == 'M') || (input == 'm')) toggle_ambience ();
#endif
    if ((input >= '0') && (input <= '9')) {
      level = level * 10 + input - '0';
#ifndef __NOSOUND__
      play_sound(MENUBEEP);
#endif
    }
    if (input == KEY_RIGHT) {
#ifndef __NOSOUND__
      play_sound(MENUBEEP);
#endif
      level ++;
    }
          if (input == KEY_LEFT) {
#ifndef __NOSOUND__
      play_sound(MENUBEEP);
#endif
            level --;
          }
          if (level > maxlevel) {
            if ((input >= '0') && (input <= '9')) level = input - '0';
            else level = maxlevel;
          }
    if (level < 1) level = 1;
  } while ((input != '\n') && (input != ' ') && (input != 'z') && (input != 'x'));

  pauserun(0);
#ifndef __NOSOUND__
  play_sound(MENUCHOICE);
#endif
  return level;
}
示例#2
0
int play(MapPack &mappack) {
  level &lvl = mappack.lvl;

  // Have we finished the map pack yet?
  bool finished = false;
    
#ifndef __NOSOUND__
  default_ambience (0);
  start_ambience ();
#endif
 
  while (!finished) {
    switch (play_level(mappack)) {
    case 0: return 0; break;
    case 2: // We're dead...
#ifndef __NOSOUND__
      beep ();
#endif
      lvl.stats.numdeaths++;
      mappack.save.numticks += lvl.ticks;
      mappack.save.numdeaths++;
      lvl.stats.numportals = 0;
      fillscreen(screenchar(XFIELD)); refresh();
      restms(100);
      fillscreen(CharData[XFIELD][2] | color_pair(XFIELD) | WA_ALTCHARSET); refresh();
      restms(150);
      mappack.reload_level();
      flushinput();
      break;
    case 3: // We've won!
#ifndef __NOSOUND__
      play_sound(WIN);
#endif
      lvl.stats.numticks = lvl.ticks;
      mappack.update_stats();
      mappack.set_maxlevel(mappack.get_currentlevel());
      // if the user wants to quit now, he will restart with the next level
      mappack.set_lastlevel(mappack.get_currentlevel() + 1);
      if (displaystats(lvl)) {
        if (mappack.get_currentlevel() == mappack.get_number_maps())
          finished = true;
        ++mappack;
      } else
        mappack.reload_level();
      break;
    } // switch
  } // while (!finished)

  roll_credits(mappack);
  return 1;
}
示例#3
0
文件: menu.cpp 项目: zugz/ASCIIpOrtal
// This gets called forever by the main function
int main_menu(MapPack& mappack) {
  int level;
  cerr << "Main menu. Mappack name is " << mappack.name << endl;
  switch (display_main_menu (mappack)) {
    case 0: // Play
      play(mappack); break;
    case 1: // Select Level
      level = select_level(mappack);
      if (level != -1) {
        mappack.set_currentlevel(level);
        play(mappack);
      }
      break;
    case 2: { // Change Map Set
      MapPack newmappack = select_mappack(mappack);
      if (&newmappack != &mappack) { // the user actually changed the mappack
        /* attrset(color_pair(HELPMENU));
           fillsquare(LINES / 2 - 3, (COLS - 26) / 2, 7, 26);
           if (newmappack.name == "") {
           mvprintw (LINES / 2, (COLS - 16) / 2, "Invalid Map Pack"); refresh ();
           restms (150);
           getch();
           } else {
           mvprintw (LINES / 2, (COLS - 15) / 2, "Map Pack Loaded!"); refresh ();
           restms (150);
           getch();*/
        mappack = newmappack;
        mappack.set_currentlevel(mappack.get_currentlevel());
        //mappack.dump();
        //}
      }
    }
      break;
    case 3: // Instructions
      help_menu (); break;
    case 4: // Credits
      roll_credits (mappack); break;
    default: // QUIT
      return -1;
  }
  return 0;
}
示例#4
0
文件: menu.cpp 项目: zugz/ASCIIpOrtal
// handles in-game menu.
int pause_menu(MapPack & mappack) {
  int pause = display_pause_menu();
  switch (pause) {
  case 0 : case -1 : break; // Resume
  case 1 : // Restart
    mappack.set_currentlevel(mappack.get_currentlevel());
    break;
  case 2 : { // Select level
    int newlvl = select_level(mappack);
    if (newlvl == -1) // Back to the menu (ESC key or something similar)
      pause_menu(mappack);
    else if (newlvl != mappack.get_currentlevel()) { // Change level
      mappack.set_currentlevel(newlvl);
      play(mappack);
      return -1;
    }
    break;
  }
  case 3 : help_menu (); break; // Help
  default : return -1; break; // Quit
  }
}