Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

src/prompt.c

Go to the documentation of this file.
00001 /* {{{
00002  * CalcRogue, a roguelike game for PCs, calculators and PDAs
00003  * Copyright (C) 2003 Jim Babcock
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  * }}} */
00019 // prompt.c
00022 
00023 #include "crogue.h"
00024 
00025 
00026 //{{{
00028 int prompt(const char *msg)
00029 {
00030     int result;
00031     
00032     message(gettext("%s [Y/N]"), msg);
00033     draw();
00034     result = read_char();
00035     switch(result)
00036     {
00037         case 'Y':
00038         case 'y':
00039         case KEY_ACKNOWLEDGE:
00040             return 1;
00041         default:
00042             return 0;
00043     }
00044 }
00045 //}}}
00046 //{{{
00047 int prompt_letter(const char *msg)
00048 {
00049     int result;
00050     
00051 retry:
00052     message("%s", msg);
00053     draw();
00054     result = read_char();
00055     result |= 0x40;
00056     if(result==(0x40|0x80)) // ESC
00057         return 0;
00058     else if('a' <= result && result <= 'z')
00059         return result-'a'+1;
00060     else {
00061         message(gettext("Invalid selection."));
00062         goto retry;
00063     }
00064 }
00065 //}}}
00066 //{{{
00067 void prompt_dir(const char *msg, direction *dir)
00068 {
00069     int input;
00070 
00071 retry:
00072     message("%s", msg);
00073     draw();
00074     input = read_char();
00075     
00076     if(input==264) // ESC
00077     {
00078         dir->x = 0;
00079         dir->y = 0;
00080     }
00081     else if( '0' < input && input <= '9' ) {
00082         dir->x = (input-'0'-1)%3-1;
00083         dir->y = -(input-'0'-1)/3+1;
00084         w->plr.facing_forced = w->plr.facing = facing(dir->x, dir->y);
00085     } else {
00086         message(gettext("Invalid direction,"));
00087         goto retry;
00088     }
00089 }
00090 //}}}
00091 

Generated on Thu May 20 13:12:11 2004 for CalcRogue by doxygen 1.3.6