/[enigma]/enigma/src/options.cc
ViewVC logotype

Diff of /enigma/src/options.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mhawlisch, Tue Mar 25 15:16:22 2003 UTC revision 1.9 by reallysoft, Wed Apr 2 23:05:33 2003 UTC
# Line 5  Line 5 
5   * modify it under the terms of the GNU General Public License   * modify it under the terms of the GNU General Public License
6   * as published by the Free Software Foundation; either version 2   * as published by the Free Software Foundation; either version 2
7   * of the License, or (at your option) any later version.   * of the License, or (at your option) any later version.
8   *     *
9   * This program is distributed in the hope that it will be useful,   * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.   * GNU General Public License for more details.
13   *     *
14   * You should have received a copy of the GNU General Public License along   * You should have received a copy of the GNU General Public License along
15   * with this program; if not, write to the Free Software Foundation, Inc.,   * with this program; if not, write to the Free Software Foundation, Inc.,
16   * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.   * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# Line 35  using namespace options; Line 35  using namespace options;
35    
36  namespace options  namespace options
37  {  {
38      int    BitsPerPixel    = 16;      int    BitsPerPixel    = 16;
39      double MouseSpeed      = 5.0;      double MouseSpeed      = 5.0;
40      double MouseDamping    = 25.0;      double MouseDamping    = 25.0;
41      double FrictionFactor  = 1.0;      double FrictionFactor  = 1.0;
# Line 53  namespace options Line 53  namespace options
53      string MenuMusicFile   = "/sound/menu.s3m";      string MenuMusicFile   = "/sound/menu.s3m";
54      string LevelMusicFile  = "/sound/Emilie.xm";      string LevelMusicFile  = "/sound/Emilie.xm";
55    
56      bool SkipSolvedLevels  = false;      bool SkipSolvedLevels = false;
57    
58    
59        // not stored in ~/.enigmarc :
60    
61        bool LevelStatusChanged = false;
62  }  }
63    
64  namespace  namespace
# Line 83  void Line 88  void
88  options::SetLevelStatus(const string &levelpack, const string &levelname,  options::SetLevelStatus(const string &levelpack, const string &levelname,
89                          const LevelStatus &stat)                          const LevelStatus &stat)
90  {  {
91      px::Dict<LevelStatus>::iterator i;      string                          key = levelkey (levelpack, levelname);
92      string key = levelkey (levelpack, levelname);      px::Dict<LevelStatus>::iterator i   = level_status_dict.find (key);
93      i = level_status_dict.find (key);  
94      if (i != level_status_dict.end())      if (i != level_status_dict.end()) { // status exists -> overwrite
95            if (i->second != stat) {
96                LevelStatusChanged = true;
97            }
98          i->second = stat;          i->second = stat;
99      else      }
100        else {
101          level_status_dict.insert(key,stat);          level_status_dict.insert(key,stat);
102            LevelStatusChanged = true;
103        }
104  }  }
105    
106  void  void
# Line 97  options::SetLevelTime(const string &pack Line 108  options::SetLevelTime(const string &pack
108  {  {
109      SetLevelFinished(pack, level, difficulty);      SetLevelFinished(pack, level, difficulty);
110      LevelStatus *stat = GetLevelStatus(pack, level);      LevelStatus *stat = GetLevelStatus(pack, level);
111    
112      assert(stat);      assert(stat);
113    
114      if (difficulty == 1) {      if (difficulty == 1) {
115          if (stat->par_easy > time)          if (stat->par_easy > time) {
116              stat->par_easy = time;              stat->par_easy     = time;
117      } else if (difficulty == 2) {              LevelStatusChanged = true;
118          if (stat->par_hard > time)          }
119              stat->par_hard = time;      }
120        else if (difficulty == 2) {
121            if (stat->par_hard > time) {
122                stat->par_hard     = time;
123                LevelStatusChanged = true;
124            }
125      }      }
126  }  }
127    
# Line 112  options::SetLevelFinished(const string & Line 130  options::SetLevelFinished(const string &
130  {  {
131      assert(difficulty==1 || difficulty==2);      assert(difficulty==1 || difficulty==2);
132      if (LevelStatus *stat = GetLevelStatus(pack, level)) {      if (LevelStatus *stat = GetLevelStatus(pack, level)) {
133          stat->finished |= difficulty;          if ((stat->finished & difficulty) == 0) {
134      } else              stat->finished     |= difficulty;
135                LevelStatusChanged  = true;
136            }
137        }
138        else {
139          SetLevelStatus(pack, level, LevelStatus(-1, -1, difficulty));          SetLevelStatus(pack, level, LevelStatus(-1, -1, difficulty));
140            LevelStatusChanged  = true;
141        }
142  }  }
143    
144  /* Determine name of the user's personal configuration file. */  /* Determine name of the user's personal configuration file. */
# Line 125  Personal_ConfigurationFileName() Line 149  Personal_ConfigurationFileName()
149    
150      if (getenv ("HOME") != 0)      if (getenv ("HOME") != 0)
151          fname = sysdep::expand_path ("~/.enigmarc");          fname = sysdep::expand_path ("~/.enigmarc");
152        
153      return fname;      return fname;
154  }  }
155    
# Line 166  Windows_ConfigurationFileName() Line 190  Windows_ConfigurationFileName()
190          }          }
191          FreeLibrary( shfolder_dll);          FreeLibrary( shfolder_dll);
192      }      }
193        
194      return Personal_ConfigurationFileName();      return Personal_ConfigurationFileName();
195  }  }
196    
# Line 182  options::Save () Line 206  options::Save ()
206      string fname = Personal_ConfigurationFileName();      string fname = Personal_ConfigurationFileName();
207  #endif  #endif
208      FILE *fp = fopen(fname.c_str(), "wt");      FILE *fp = fopen(fname.c_str(), "wt");
209        
210      if (fp) {      if (fp) {
211          fprintf (fp, "options.MouseSpeed = %f\n",       MouseSpeed);          fprintf (fp, "options.MouseSpeed = %f\n",       MouseSpeed);
212          fprintf (fp, "options.MouseDamping = %f\n",     MouseDamping);          fprintf (fp, "options.MouseDamping = %f\n",     MouseDamping);
# Line 205  options::Save () Line 229  options::Save ()
229                       i->second.par_easy, i->second.par_hard,                       i->second.par_easy, i->second.par_hard,
230                       i->second.finished);                       i->second.finished);
231          }          }
232          return fclose (fp);  
233            fclose(fp);
234    
235            LevelStatusChanged = false;
236            return true;
237      }      }
238      return false;      return false;
239  }  }
# Line 235  options::Load () Line 263  options::Load ()
263      error |= load_from_file (fname.c_str());      error |= load_from_file (fname.c_str());
264    
265  #ifdef __MINGW32__  #ifdef __MINGW32__
266      fname = Windows_ConfigurationFileName();      fname  = Windows_ConfigurationFileName();
267      error |= load_from_file (fname.c_str());      error |= load_from_file (fname.c_str());
268  #endif  #endif
269    
270        LevelStatusChanged = false;
271    
272      return error;      return error;
273  }  }
274    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26