Changeset 191


Ignore:
Timestamp:
26/04/09 17:03:05 (4 years ago)
Author:
guyru
Message:

Portable Edition 1.9 Preparations.

Removed SQLite support. Fixed configuration file path. Add new MSVC
configuration for the portable edition.

Location:
trunk
Files:
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/openyahtzee.sln

    r175 r191  
    77        GlobalSection(SolutionConfigurationPlatforms) = preSolution 
    88                Debug|Win32 = Debug|Win32 
     9                Portable Release|Win32 = Portable Release|Win32 
    910                Unicode Release|Win32 = Unicode Release|Win32 
    1011        EndGlobalSection 
     
    1213                {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Debug|Win32.ActiveCfg = Debug|Win32 
    1314                {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 
    1417                {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Unicode Release|Win32.ActiveCfg = Release|Win32 
    1518                {751F1BED-0ADC-47C4-8424-42745E9CDF2C}.Unicode Release|Win32.Build.0 = Release|Win32 
  • trunk/openyahtzee.vcproj

    r184 r191  
    167167                        /> 
    168168                </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="&quot;D:\wxWidgets-2.8.7\include&quot;;&quot;D:\wxWidgets-2.8.7\include\msvc&quot;" 
     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="&quot;D:\wxWidgets-2.8.7\include&quot;" 
     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="&quot;D:\wxWidgets-2.8.7\lib\vc_lib&quot;" 
     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> 
    169247        </Configurations> 
    170248        <References> 
     
    185263                        </File> 
    186264                        <File 
    187                                 RelativePath=".\src\DBwrapper.cpp" 
    188                                 > 
    189                         </File> 
    190                         <File 
    191265                                RelativePath=".\src\highscores_dialog.cpp" 
    192266                                > 
     
    207281                                RelativePath=".\src\settings_dialog.cpp" 
    208282                                > 
    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> 
    213292                        </File> 
    214293                        <File 
  • trunk/src/MainFrame.cpp

    r186 r191  
    8686                } 
    8787        #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(); 
    8991        #endif 
    9092 
  • trunk/src/Makefile.am

    r187 r191  
    66        configuration.cpp \ 
    77        configuration.h \ 
    8         DBwrapper.cpp \ 
    98        MainFrame.cpp \ 
    109        highscores_dialog.cpp \ 
     
    2221        four.xpm \ 
    2322        five.xpm \ 
    24         six.xpm \ 
    25         sqlite/sqlite3.c \ 
    26         sqlite/sqlite3.h 
     23        six.xpm 
    2724 
    2825# set the include path found by configure 
     
    3229 
    3330noinst_HEADERS = \ 
    34         DBwrapper.h \ 
    3531        openyahtzee.ico \ 
    3632        MainFrame.h \ 
     
    4339 
    4440AM_CXXFLAGS = @WX_CXXFLAGS@ 
    45 openyahtzee_LDFLAGS = @WX_LIBS@ 
     41openyahtzee_LDADD = @WX_LIBS@ 
  • trunk/src/configuration.cpp

    r177 r191  
    5050        getline(conf_file,header); 
    5151        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(); 
    5557                return; 
    5658        } 
     
    190192} 
    191193 
    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 the 
    201         // highscore size settings will be known 
    202         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 string 
    214                 tmp_query = ""; //use tmp_query for holding a tmp_string 
    215                 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 this 
    265                 pos = it->find(' '); 
    266                 temp_item.date = it->substr(pos+1); // date 
    267                 temp_item.date += " " + it->substr(0,pos-3); // time, without seconds 
    268                 it++; 
    269  
    270                 temp_item.score = atoi((*it++).c_str()); 
    271  
    272                 m_highscores.push_back(temp_item); 
    273         } 
    274 } 
    275  
    276194bool Configuration::isHighscore(int score) { 
    277195        const unsigned int highscore_list_size = atoi(m_settings["highscore-list-size"].c_str()); 
  • trunk/src/configuration.h

    r177 r191  
    2222#define OPENYAHTZEE_CONFIGURATION_INC 
    2323 
    24 #include "DBwrapper.h" // used in the back-compatibility code 
    2524#include <string> 
    2625#include <fstream> 
     
    8079        void setHighscoresSize(size_t size); 
    8180private: 
    82         /** 
    83          * Imports old style configuration from sqllite database. 
    84          */ 
    85         void importOldFile(); 
    86  
    8781        void parseSettings(std::ifstream *file); 
    8882        void parseHighscores(std::ifstream *file); 
     
    10094 
    10195        std::string m_file; 
    102  
    103         /* The following functions and variables are used for legacy SQLite 
    104          * configuration file, and could be dropped. 
    105          */ 
    106         DBwrapper old_db; 
    107         std::string getKeyFromDb(std::string key); 
    108         void importSettings(); 
    109         void importHighscores(); 
    11096}; 
    11197 
Note: See TracChangeset for help on using the changeset viewer.