1 /* Tower Toppler - Nebulus 2 * Copyright (C) 2000-2012 Andreas R�ver 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 #ifndef CONFIGURATION_H 20 #define CONFIGURATION_H 21 22 #include "decl.h" 23 24 #include <stdio.h> 25 26 #define TOWERNAMELEN 19 27 #define PASSWORD_LEN 5 28 29 /* this module contains a class for configuration file 30 * handling loading and saving is handled 31 */ 32 33 class configuration { 34 35 public: 36 37 configuration(FILE *glob, FILE *local); 38 ~configuration(); 39 fullscreen()40 bool fullscreen() const { return i_fullscreen; } fullscreen(bool on)41 void fullscreen(bool on) { need_save = true; i_fullscreen = on; } 42 nosound()43 bool nosound() const { return i_nosound; } nosound(bool on)44 void nosound(bool on) { need_save = true; i_nosound = on; } 45 nomusic()46 bool nomusic() const { return i_nomusic; } nomusic(bool on)47 void nomusic(bool on) { need_save = true; i_nomusic = on; } 48 use_water()49 bool use_water() const { return i_use_water; } use_water(bool on)50 void use_water(bool on) { need_save = true; i_use_water = on; } 51 editor_towername()52 const char *editor_towername() const { return i_editor_towername; } 53 void editor_towername(char name[TOWERNAMELEN+1]); 54 use_alpha_sprites()55 bool use_alpha_sprites() const { return i_use_alpha_sprites; } use_alpha_sprites(bool on)56 void use_alpha_sprites(bool on) { need_save = true; i_use_alpha_sprites = on; } 57 use_alpha_layers()58 bool use_alpha_layers() const { return i_use_alpha_layers; } use_alpha_layers(bool on)59 void use_alpha_layers(bool on) { need_save = true; i_use_alpha_layers = on; } 60 use_alpha_font()61 bool use_alpha_font() const { return i_use_alpha_font; } use_alpha_font(bool on)62 void use_alpha_font(bool on) { need_save = true; i_use_alpha_font = on; } 63 use_alpha_darkening()64 bool use_alpha_darkening() const { return i_use_alpha_darkening; } use_alpha_darkening(bool on)65 void use_alpha_darkening(bool on) { need_save = true; i_use_alpha_darkening = on; } 66 use_full_scroller()67 bool use_full_scroller() const { return i_use_full_scroller; } use_full_scroller(bool on)68 void use_full_scroller(bool on) { need_save = true; i_use_full_scroller = on; } 69 70 /* the different types of waves used in waves_type */ 71 enum { 72 waves_nonreflecting, 73 waves_simple, 74 waves_expensive, 75 num_waves 76 }; 77 waves_type()78 int waves_type() const { return i_waves_type; } waves_type(int type)79 void waves_type(int type) { need_save = true; i_waves_type = type; } 80 status_top()81 bool status_top() const { return i_status_top; } status_top(bool on)82 void status_top(bool on) { need_save = true; i_status_top = on; } 83 editor_towerpagesize()84 int editor_towerpagesize() const { return i_editor_towerpagesize; } editor_towerpagesize(int sz)85 void editor_towerpagesize(int sz) { need_save = true; i_editor_towerpagesize = sz; } 86 editor_towerstarthei()87 int editor_towerstarthei() const { return i_editor_towerstarthei; } editor_towerstarthei(int sz)88 void editor_towerstarthei(int sz) { need_save = true; i_editor_towerstarthei = sz; } 89 start_lives()90 int start_lives() const { return i_start_lives; } start_lives(int lv)91 void start_lives(int lv) { need_save = true; i_start_lives = lv; } 92 curr_password()93 const char *curr_password() const { return i_curr_password; } 94 void curr_password(char pwd[PASSWORD_LEN+1]); 95 debug_level()96 int debug_level() const { return i_debug_level; } debug_level(int l)97 void debug_level(int l) { need_save = true; i_debug_level = l; dcl_setdebuglevel(l); } 98 game_speed()99 int game_speed() const { return i_game_speed; } game_speed(int spd)100 void game_speed(int spd) { need_save = true; i_game_speed = spd; } 101 nobonus()102 int nobonus() const { return i_nobonus; } nobonus(bool on)103 void nobonus(bool on) { need_save = true; i_nobonus = on; } 104 105 private: 106 107 FILE *f; 108 109 typedef enum { 110 CT_BOOL, 111 CT_STRING, 112 CT_INT, 113 CT_KEY 114 } cnf_type; 115 116 void parse(FILE *in); 117 void register_entry(const char *cnf_name, cnf_type cnf_typ, void *cnf_var, long maxlen); 118 119 typedef struct config_data { 120 config_data *next; 121 const char *cnf_name; 122 cnf_type cnf_typ; 123 void *cnf_var; 124 long maxlen; 125 } config_data; 126 127 config_data *first_data; 128 129 bool i_fullscreen; 130 bool i_nosound; 131 bool i_nomusic; 132 bool i_use_water; 133 char i_editor_towername[TOWERNAMELEN+1]; 134 bool i_use_alpha_sprites; 135 bool i_use_alpha_layers; 136 bool i_use_alpha_font; 137 bool i_use_alpha_darkening; 138 bool i_use_full_scroller; 139 int i_waves_type; 140 bool i_status_top; 141 int i_editor_towerpagesize; 142 int i_editor_towerstarthei; 143 int i_start_lives; 144 char i_curr_password[PASSWORD_LEN+1]; 145 int i_debug_level; 146 int i_game_speed; 147 int i_nobonus; 148 149 bool need_save; 150 151 }; 152 153 extern configuration config; 154 155 #endif 156