Changeset 191
- Timestamp:
- 26/04/09 17:03:05 (4 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 6 edited
-
openyahtzee.sln (modified) (2 diffs)
-
openyahtzee.vcproj (modified) (3 diffs)
-
src/DBwrapper.cpp (deleted)
-
src/DBwrapper.h (deleted)
-
src/MainFrame.cpp (modified) (1 diff)
-
src/Makefile.am (modified) (4 diffs)
-
src/configuration.cpp (modified) (2 diffs)
-
src/configuration.h (modified) (3 diffs)
-
src/sqlite (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/openyahtzee.sln
r175 r191 7 7 GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 8 Debug|Win32 = Debug|Win32 9 Portable Release|Win32 = Portable Release|Win32 9 10 Unicode Release|Win32 = Unicode Release|Win32 10 11 EndGlobalSection … … 12 13 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Debug|Win32.ActiveCfg = Debug|Win32 13 14 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Debug|Win32.Build.0 = Debug|Win32 15 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Portable Release|Win32.ActiveCfg = Portable Release|Win32 16 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Portable Release|Win32.Build.0 = Portable Release|Win32 14 17 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Unicode Release|Win32.ActiveCfg = Release|Win32 15 18 {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Unicode Release|Win32.Build.0 = Release|Win32 -
trunk/openyahtzee.vcproj
r184 r191 167 167 /> 168 168 </Configuration> 169 <Configuration 170 Name="Portable Release|Win32" 171 OutputDirectory="$(SolutionDir)$(ConfigurationName)" 172 IntermediateDirectory="$(ConfigurationName)" 173 ConfigurationType="1" 174 CharacterSet="1" 175 WholeProgramOptimization="1" 176 > 177 <Tool 178 Name="VCPreBuildEventTool" 179 /> 180 <Tool 181 Name="VCCustomBuildTool" 182 /> 183 <Tool 184 Name="VCXMLDataGeneratorTool" 185 /> 186 <Tool 187 Name="VCWebServiceProxyGeneratorTool" 188 /> 189 <Tool 190 Name="VCMIDLTool" 191 /> 192 <Tool 193 Name="VCCLCompilerTool" 194 Optimization="1" 195 EnableIntrinsicFunctions="true" 196 AdditionalIncludeDirectories=""D:\wxWidgets-2.8.7\include";"D:\wxWidgets-2.8.7\include\msvc"" 197 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;PORTABLE" 198 RuntimeLibrary="2" 199 EnableFunctionLevelLinking="true" 200 UsePrecompiledHeader="0" 201 WarningLevel="3" 202 DebugInformationFormat="3" 203 /> 204 <Tool 205 Name="VCManagedResourceCompilerTool" 206 /> 207 <Tool 208 Name="VCResourceCompilerTool" 209 AdditionalIncludeDirectories=""D:\wxWidgets-2.8.7\include"" 210 /> 211 <Tool 212 Name="VCPreLinkEventTool" 213 /> 214 <Tool 215 Name="VCLinkerTool" 216 AdditionalDependencies="comctl32.lib rpcrt4.lib winmm.lib advapi32.lib wsock32.lib wxmsw28u_core.lib wxbase28u.lib wxmsw28u_adv.lib wxmsw28u_aui.lib wxpng.lib wxjpeg.lib wxtiff.lib" 217 LinkIncremental="1" 218 AdditionalLibraryDirectories=""D:\wxWidgets-2.8.7\lib\vc_lib"" 219 GenerateDebugInformation="false" 220 SubSystem="2" 221 OptimizeReferences="2" 222 EnableCOMDATFolding="2" 223 TargetMachine="1" 224 /> 225 <Tool 226 Name="VCALinkTool" 227 /> 228 <Tool 229 Name="VCManifestTool" 230 /> 231 <Tool 232 Name="VCXDCMakeTool" 233 /> 234 <Tool 235 Name="VCBscMakeTool" 236 /> 237 <Tool 238 Name="VCFxCopTool" 239 /> 240 <Tool 241 Name="VCAppVerifierTool" 242 /> 243 <Tool 244 Name="VCPostBuildEventTool" 245 /> 246 </Configuration> 169 247 </Configurations> 170 248 <References> … … 185 263 </File> 186 264 <File 187 RelativePath=".\src\DBwrapper.cpp"188 >189 </File>190 <File191 265 RelativePath=".\src\highscores_dialog.cpp" 192 266 > … … 207 281 RelativePath=".\src\settings_dialog.cpp" 208 282 > 209 </File> 210 <File 211 RelativePath=".\src\sqlite\sqlite3.c" 212 > 283 <FileConfiguration 284 Name="Portable Release|Win32" 285 > 286 <Tool 287 Name="VCCLCompilerTool" 288 Optimization="1" 289 PreprocessorDefinitions="PORTABLE" 290 /> 291 </FileConfiguration> 213 292 </File> 214 293 <File -
trunk/src/MainFrame.cpp
r186 r191 86 86 } 87 87 #else 88 wxString config_file = wxStandardPaths::Get().GetExecutablePath() + wxT("/openyahtzee.dat"); 88 wxFileName tmp_config_file(wxStandardPaths::Get().GetExecutablePath()); 89 tmp_config_file.SetFullName(wxT("openyahtzee.dat")); 90 wxString config_file = tmp_config_file.GetFullPath(); 89 91 #endif 90 92 -
trunk/src/Makefile.am
r187 r191 6 6 configuration.cpp \ 7 7 configuration.h \ 8 DBwrapper.cpp \9 8 MainFrame.cpp \ 10 9 highscores_dialog.cpp \ … … 22 21 four.xpm \ 23 22 five.xpm \ 24 six.xpm \ 25 sqlite/sqlite3.c \ 26 sqlite/sqlite3.h 23 six.xpm 27 24 28 25 # set the include path found by configure … … 32 29 33 30 noinst_HEADERS = \ 34 DBwrapper.h \35 31 openyahtzee.ico \ 36 32 MainFrame.h \ … … 43 39 44 40 AM_CXXFLAGS = @WX_CXXFLAGS@ 45 openyahtzee_LD FLAGS= @WX_LIBS@41 openyahtzee_LDADD = @WX_LIBS@ -
trunk/src/configuration.cpp
r177 r191 50 50 getline(conf_file,header); 51 51 if (header.substr(0,11) != "openyahtzee") { 52 // this is probably an old sqllite file import it. 53 conf_file.close(); 54 importOldFile(); 52 /* The file might be an old configuration file or 53 * currupted, anyway re-create it 54 */ 55 loadDefaultSettings(); 56 save(); 55 57 return; 56 58 } … … 190 192 } 191 193 192 193 void Configuration::importOldFile()194 {195 loadDefaultSettings();196 if (old_db.Open(m_file)!=SQLITE_OK) {197 return;198 }199 importSettings();200 // importHighscores is called after importSettings() so the201 // highscore size settings will be known202 importHighscores();203 }204 205 string Configuration::getKeyFromDb(string key)206 {207 string tmp_query;208 std::list<string> tmp_value;209 210 tmp_query = "SELECT value FROM settings WHERE key = \"" + key + "\"";211 212 tmp_value = old_db.Query(tmp_query);213 if (tmp_value.empty()) { //if there was no result return an empty string214 tmp_query = ""; //use tmp_query for holding a tmp_string215 return tmp_query;216 }217 return *(tmp_value.begin());218 }219 220 void Configuration::importSettings()221 {222 string temp_value;223 224 temp_value = getKeyFromDb("animate");225 if (temp_value=="No") {226 set("dice-animation","False");227 }228 229 temp_value = getKeyFromDb("calculatesubtotal");230 if (temp_value=="No") {231 set("calculate-subtotal","False");232 }233 234 temp_value = getKeyFromDb("horizontalayout");235 if (temp_value=="No") {236 set("horizontal-layout","False");237 }238 239 temp_value = getKeyFromDb("score_hints");240 if (temp_value=="No") {241 set("score-hints","False");242 }243 244 temp_value = getKeyFromDb("highscoresize");245 if (temp_value=="") {246 set("highscore-list-size",DEFAULT_HIGHSCORE_SIZE);247 }248 }249 250 void Configuration::importHighscores()251 {252 string tmp_query = "SELECT name,date,score FROM highscore LIMIT "253 + m_settings["highscore-list-size"];254 255 list<string> res = old_db.Query(tmp_query);256 HighscoreItem temp_item;257 258 list<string>::iterator it = res.begin();259 size_t pos;260 while(it!=res.end()) {261 temp_item.name = (*it++);262 263 // the database saved the the hour before the date,264 // we need to reverse this265 pos = it->find(' ');266 temp_item.date = it->substr(pos+1); // date267 temp_item.date += " " + it->substr(0,pos-3); // time, without seconds268 it++;269 270 temp_item.score = atoi((*it++).c_str());271 272 m_highscores.push_back(temp_item);273 }274 }275 276 194 bool Configuration::isHighscore(int score) { 277 195 const unsigned int highscore_list_size = atoi(m_settings["highscore-list-size"].c_str()); -
trunk/src/configuration.h
r177 r191 22 22 #define OPENYAHTZEE_CONFIGURATION_INC 23 23 24 #include "DBwrapper.h" // used in the back-compatibility code25 24 #include <string> 26 25 #include <fstream> … … 80 79 void setHighscoresSize(size_t size); 81 80 private: 82 /**83 * Imports old style configuration from sqllite database.84 */85 void importOldFile();86 87 81 void parseSettings(std::ifstream *file); 88 82 void parseHighscores(std::ifstream *file); … … 100 94 101 95 std::string m_file; 102 103 /* The following functions and variables are used for legacy SQLite104 * configuration file, and could be dropped.105 */106 DBwrapper old_db;107 std::string getKeyFromDb(std::string key);108 void importSettings();109 void importHighscores();110 96 }; 111 97
Note: See TracChangeset
for help on using the changeset viewer.
