⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menus.cpp

📁 with vxworks we can develope a group of control software for industry.
💻 CPP
字号:
/*    BladeMaster 2, a text, rougelike(kinda), arena combat simulation game.   Copyright (C) 2002 Blademaster 2 Team, see CREDITS   Clone of BladeMaster by Logicom, Inc. Copyright(C) 1990/1993   In no means affliated with the original Blademaster or the original   Blademaster creators/programmers.   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.      You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   Useful contact information:       Website: blademaster2.sourceforge.net       Project page: www.sf.net/projects/blademaster2/   Project Lead (see CREDITS for other members of the developement team)       E-Mail: ilswyn@users.sourceforge.net       AIM: ilswyn*//* *------------------------------------------------------*   |                 menus.cpp menus.h                    |   |                                                      |   |  Contains all menu initialization and menu command   |   | processing.                                          |   *------------------------------------------------------* */#include <string>#include <ncurses.h>#include <iostream.h>#include <stdlib.h> // need this for exit() - Sairax#include "shops.h"#include "menus.h"#include "arena.h"#include "items.h"#include "players.h"#include "globals.h" // Whereis variable locations#include "textgfx.h" // For drawing menus// Possible locations for whereis variableconst int AT_MAIN_MENU = 0;const int AT_MAIN_SCREEN = 1;const int AT_MAIN_SCREEN_ARENA = 2;const int AT_MAIN_SCREEN_TAVERN = 3;const int AT_MAIN_SCREEN_SHOP = 4;const int AT_MAIN_SCREEN_HEALERS = 5;const int AT_MAIN_SCREEN_BANK = 6;//  It is a bit confusing but there is a main menu and then there is// also a main screen. Main menu comes before the main screen, and// the main_screen_loop is accessed by [P] at the main menu.// Using integers for input is much more flexible, all the directional// keys are integers. KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWNvoid main_menu_loop(){  whereis = AT_MAIN_MENU;  draw_main_menu();  while (whereis == AT_MAIN_MENU)     {      process_main_menu_command(get_input());    }}void process_main_menu_command(int command){  switch(command)    {    case 'Q':    case 'q':      endwin();      cout<<"Farewell.." << endl;      cout<< "http://blademaster2.sourceforge.net" << endl;      exit(1);      break;    case 'P':    case 'p':      erase();            add_arena_object(new HumanPlayer(), HUMAN);      main_screen_loop();      break;    case 'I':    case 'i':      printw("Testing Instruction Function\n");      break;    case 'B':    case 'b':      printw("Testing BM function\n");      break;    case 'H':    case 'h':      printw("Testing High Score function\n");      break;    case 'S':    case 's':      printw("Testing Set options\n");      break;    case 'L':    case 'l':      printw("Testing LOG\n");      break;    default:      clear();      printw("\nEnter a valid option! P, I, B, H, S, or L\n\n");      refresh();    }}void main_screen_loop(){  whereis = AT_MAIN_SCREEN;  draw_main_screen();  while (whereis == AT_MAIN_SCREEN)    {      process_main_screen_command(get_input());    }}void process_main_screen_command(int command){  switch(command)    {    case 'A':    case 'a':      add_arena_object(new CompPlayer(), COMP);      arena_loop();      break;    case 'T':    case 't':      draw_tavern();      process_tavern_command(get_input());      break;    case 'W':    case 'w':      draw_shop();            process_eqshop_command(get_input());     break;    case 'H':    case 'h':      draw_healer();      process_healer_command(get_input());      break;    case 'B':    case 'b':      draw_bank();      process_bank_command(get_input());      break;    case 'Q':    case 'q':      erase();      main_menu_loop();      break;    }}void arena_loop(){  whereis = AT_MAIN_SCREEN_ARENA;  draw_arena();  // Index for arena_obj_list  int acc = 0;  while (whereis == AT_MAIN_SCREEN_ARENA)    {      while (acc < end_arena_object)	{	  if (arena_obj_types[acc] == HUMAN)	    {	      ((HumanPlayer*)(arena_obj_list[acc]))->take_turn();	    }	  else if (arena_obj_types[acc] == COMP)	    {	      ((CompPlayer*)(arena_obj_list[acc]))->take_turn();	    }	  else // object is a generic arenaobject	    {	      arena_obj_list[acc]->take_turn();	    }	  acc++;	}            acc = 0;    }}void process_tavern_command(int command){  switch(command)    {    case 'B':    case 'b':      tavern.buy_beer();    case 'A':    case 'a':      tavern.buy_ale();    case 'W':    case 'w':      tavern.buy_whiskey();    case 'T':    case 't':      tavern.tip_bartender();    case 'Q':    case 'q':      erase();      main_screen_loop();      break;    default:      process_tavern_command(get_input());    }}void process_eqshop_command(int command){  switch(command)    {    case 'M':    case 'm':      eqshop.buy_melee();    case 'R':    case 'r':      eqshop.buy_range();    case 'P':    case 'p':      eqshop.buy_projectiles();    case 'A':    case 'a':      eqshop.buy_armor();    case 'Q':    case 'q':      erase();      main_screen_loop();      break;    default:      process_eqshop_command(get_input());    }}void process_healer_command(int command){  switch(command)    {    case 'A':    case 'a':      healer.heal_all_wounds();    case 'S':    case 's':      healer.heal_some_wounds();    case 'P':    case 'p':      healer.cure_poison();    case 'D':    case 'd':      healer.cure_disease();    case 'Q':    case 'q':      erase();      main_screen_loop();      break;    default:      process_healer_command(get_input());    }}void process_bank_command(int command){  switch(command)    {    case 'D':    case 'd':      bank.deposit_gold();    case 'W':    case 'w':      bank.withdraw_gold();    case 'S':    case 's':      bank.storage();    case 'Q':    case 'q':      erase();      main_screen_loop();      break;    default:      process_bank_command(get_input());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -