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

src/actions.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 // actions.c
00023 
00024 #include "crogue.h"
00025 #include "export.h"
00026 
00027 #ifdef KEY_SCROLLING
00028 #   define KEY_SCROLLING_ACTIONS 1
00029 #else
00030 #   define KEY_SCROLLING_ACTIONS 0
00031 #endif
00032 #ifdef ALLOWDEBUG
00033 #   define DEBUG_ACTIONS 1
00034 #else
00035 #   define DEBUG_ACTIONS 0
00036 #endif
00037 //#define NUM_ACTIONS (29+KEY_SCROLLING_ACTIONS+DEBUG_ACTIONS)
00038 
00040 typedef struct actions_menu_entry
00041 {
00042     const char *str;  
00043     int key;          
00044 } actions_menu_entry;
00045 
00046 static const actions_menu_entry actions[] =
00047     {
00048         { gettext("Walk left"),                  KEY_WEST                   },
00049         { gettext("Run left"),                   KEY_RUN_WEST               },
00050 #ifdef KEY_SCROLLING
00051         { gettext("Scroll view left"),           KEY_SCROLL_LEFT            },
00052 #endif
00053         { gettext("Wait"),                       KEY_WAIT                   },
00054         { gettext("Climb stairs"),               KEY_STAIR                  },
00055         { gettext("Show inventory"),             KEY_INVENTORY              },
00056         { gettext("Fire readied ammo"),          KEY_FIRE                   },
00057         { gettext("Cast spell"),                 KEY_CAST                   },
00058         { gettext("Use item"),                   KEY_USE                    },
00059         { gettext("Equip item"),                 KEY_WEAR                   },
00060         { gettext("Equip items"),                KEY_WEAR_MULTIPLE          },
00061         { gettext("Take off item"),              KEY_TAKEOFF                },
00062         { gettext("Take off items"),             KEY_TAKEOFF_MULTIPLE       },
00063         { gettext("Drop item"),                  KEY_DROP                   },
00064         { gettext("Drop items"),                 KEY_DROP_MULTIPLE          },
00065         { gettext("Pick up items"),              KEY_PICKUP                 },
00066         { gettext("Throw item"),                 KEY_THROW                  },
00067         { gettext("Show message history"),       KEY_MESSAGE_HISTORY        },
00068         { gettext("Show known item types"),      KEY_DISCOVERIES            },
00069         { gettext("Search"),                     KEY_SEARCH                 },
00070         { gettext("Open door"),                  KEY_OPENDOOR               },
00071         { gettext("Close door"),                 KEY_CLOSEDOOR              },
00072         { gettext("Options"),                    KEY_OPTIONS_MENU           },
00073         { gettext("Help"),                       KEY_HELPMENU               },
00074         { gettext("Character info"),             KEY_STATS                  },
00075         { gettext("About"),                      KEY_ABOUT                  },
00076 #ifdef ALLOWDEBUG
00077         { gettext("Debug"),                      KEY_DEBUG                  },
00078 #endif
00079         { gettext("Hotkey item"),                KEY_HOTKEY_ITEM            },
00080         { gettext("Redraw screen"),              KEY_REDRAW                 },
00081         { gettext("Quit"),                       KEY_ESC                    },
00082         { gettext("Save game"),                  KEY_SAVEGAME               },
00083         { NULL, 0 }
00084     };
00085 
00086 static void actions_menu_callback(int n, char *buf)
00087 {
00088     sprintf(buf, "%s\t%s", actions[n].str, get_keyname(actions[n].key));
00089 }
00090 
00093 static int num_actions(void)
00094 {
00095     int ii;
00096     for(ii=0; ; ii++) {
00097         if(actions[ii].str == NULL)
00098             return ii;
00099     }
00100 }
00101 
00102 int actions_menu(void)
00103 {
00104     int ret;
00105     setTabStops(actions_menu_tab_stops);
00106     ret = UI_Menu_Pick( actions_rect, num_actions(), &actions_menu_callback, 0 );
00107     full_redraw();
00108     if(ret<0)
00109         return KEY_NOP;
00110     return actions[ret].key;
00111 }
00112 
00113 

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