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

src/options.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 // options.c
00022 
00023 #include "crogue.h"
00024 #include "export.h"
00025 
00027 typedef struct option
00028 {
00029     const char *description;
00030     const char **choices;
00031     uchar num_choices;
00032     uchar default_value;
00033 } option;
00034 
00035 static const char *choices_yesnoprompt[] = {
00036     gettext("Yes"),
00037     gettext("No"),
00038     gettext("Prompt") };
00039 #ifdef IS_CALCULATOR
00040 static const char *choices_smalllarge[] = {
00041     gettext("Small"),
00042     gettext("Large") };
00043 static const char *choices_fontsize[] = {
00044     gettext("Small"),
00045     gettext("Medium"),
00046     gettext("Large") };
00047 #endif
00048 
00049 //{{{
00050 static const option options[NUM_OPTIONS] = {
00051         { gettext("Auto-pickup"),
00052           choices_yesnoprompt,
00053           3, 2
00054         },
00055         { gettext("Auto-follow-stairs"),
00056           choices_yesnoprompt,
00057           3, 2
00058         },
00059 #ifdef IS_CALCULATOR
00060         { gettext("Tile size"),
00061           choices_smalllarge,
00062           2, 0
00063         },
00064         { gettext("Font size"),
00065           choices_fontsize,
00066           3, 0
00067         },
00068         { gettext("Archive saves"),
00069           choices_yesnoprompt,
00070           2, 1
00071         },
00072         { gettext("Archive scores"),
00073           choices_yesnoprompt,
00074           2, 0
00075         },
00076         { gettext("Use grayscale"),
00077           choices_yesnoprompt,
00078           2, 0
00079         }
00080 /*      { gettext("Menu font size"),
00081           choices_smalllarge,
00082           2, 0
00083         }*/
00084 #endif
00085     };
00086 //}}}
00087 //{{{
00088 static void cb_options_menu(int n, char *buf)
00089 {
00090     sprintf(buf, "%s\t%s", options[n].description, options[n].choices[w->options[n]]);
00091 }
00092 //}}}
00093 
00094 //{{{
00095 void init_options(void)
00096 {
00097     int i;
00098     for(i=0; i<NUM_OPTIONS; i++)
00099         w->options[i] = options[i].default_value;
00100 }
00101 //}}}
00102 //{{{
00103 void options_menu(void)
00104 {
00105     int choice;
00106     setTabStops(options_menu_tabs);
00107     UI_Menu_Set_Persist(1);
00108     while(1) {
00109         choice = UI_Menu_Pick( options_rect, NUM_OPTIONS, &cb_options_menu, 0);
00110         if(choice<0)
00111             break;
00112         w->options[choice] ++;
00113         w->options[choice] %= options[choice].num_choices;
00114         
00115 #ifdef IS_CALCULATOR
00116         if(choice == OPTION_GRAYSCALE)
00117         {
00118             if(w->options[OPTION_GRAYSCALE] == OPTION_GRAY_ON)
00119                 GrayOnThrow();
00120             else
00121                 GrayOff();
00122             if(w->level) // Only if game is started
00123                 full_redraw();
00124         }
00125 #endif
00126     }
00127     UI_Menu_Set_Persist(0);
00128 }
00129 //}}}

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