Changeset 28


Ignore:
Timestamp:
19/12/06 21:32:15 (7 years ago)
Author:
guyru
Message:

fixed init of database file

Location:
trunk/OpenYahtzee
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/OpenYahtzee/openyahtzee.kdevses

    r25 r28  
    22<!DOCTYPE KDevPrjSession> 
    33<KDevPrjSession> 
    4  <DocsAndViews NumberOfDocuments="9" > 
     4 <DocsAndViews NumberOfDocuments="11" > 
    55  <Doc0 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDB.h" > 
    6    <View0 Type="Source" /> 
     6   <View0 line="0" Type="Source" /> 
    77  </Doc0> 
    88  <Doc1 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/openyahtzee.cpp" > 
     
    1010  </Doc1> 
    1111  <Doc2 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.cpp" > 
    12    <View0 Type="Source" /> 
     12   <View0 line="64" Type="Source" /> 
    1313  </Doc2> 
    1414  <Doc3 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/ObjectsID.h" > 
     
    1616  </Doc3> 
    1717  <Doc4 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.h" > 
    18    <View0 Type="Source" /> 
     18   <View0 line="0" Type="Source" /> 
    1919  </Doc4> 
    2020  <Doc5 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/DBwrapper.h" > 
    21    <View0 line="26" Type="Source" /> 
     21   <View0 Type="Source" /> 
    2222  </Doc5> 
    2323  <Doc6 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreTableDB.cpp" > 
     24   <View0 line="72" Type="Source" /> 
     25  </Doc6> 
     26  <Doc7 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDialog.cpp" > 
    2427   <View0 line="0" Type="Source" /> 
    25   </Doc6> 
    26   <Doc7 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreDialog.cpp" > 
    27    <View0 line="32" Type="Source" /> 
    2828  </Doc7> 
    29   <Doc8 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDialog.cpp" > 
    30    <View0 line="29" Type="Source" /> 
     29  <Doc8 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDB.cpp" > 
     30   <View0 line="0" Type="Source" /> 
    3131  </Doc8> 
     32  <Doc9 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreTableDB.h" > 
     33   <View0 line="49" Type="Source" /> 
     34  </Doc9> 
     35  <Doc10 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreDialog.cpp" > 
     36   <View0 line="0" Type="Source" /> 
     37  </Doc10> 
    3238 </DocsAndViews> 
    3339 <pluginList> 
  • trunk/OpenYahtzee/src/HighScoreTableDB.cpp

    r17 r28  
    6868} 
    6969 
     70int HighScoreTableDB::GetSize() 
     71{ 
     72        return m_size; 
     73} 
    7074void HighScoreTableDB::SetSize(int size) 
    7175{ 
  • trunk/OpenYahtzee/src/HighScoreTableDB.h

    r17 r28  
    4848        int SendHighScore(std::string name, std::string date, int score); 
    4949        void SetSize(int size); 
     50        int GetSize(); 
    5051 
    5152        std::list<std::string> GetHighScoreTable(); 
  • trunk/OpenYahtzee/src/MainFrame.cpp

    r21 r28  
    4646#include "six.xpm" 
    4747 
     48//default values 
    4849#define SPACE_SIZE 1 
     50#define DEF_HIGHSCORESIZE 16 
    4951 
    5052MainFrame::MainFrame(const wxString& title, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE) 
    5153        : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, size, style) 
    5254{ 
     55 
     56        std::ostringstream sstr; 
     57 
    5358        m_settingsdb = new SettingsDB(); //Get the settings database connection 
    5459        m_highscoredb = new HighScoreTableDB(); 
    55         int highscoresize = atoi((m_settingsdb->GetKey("highscoresize")).c_str()); 
    56         m_highscoredb->SetSize( (highscoresize>0)?highscoresize:20 ); 
     60 
     61 
     62        if (m_settingsdb->GetKey("highscoresize") == "") { //check if we need to create a newdatabase 
     63                m_highscoredb->SetSize(DEF_HIGHSCORESIZE); 
     64                sstr<<DEF_HIGHSCORESIZE<<std::flush; 
     65                m_settingsdb->SetKey("highscoresize", sstr.str()); 
     66        } else { 
     67                int highscoresize = atoi((m_settingsdb->GetKey("highscoresize")).c_str()); 
     68                //m_highscoredb->SetSize((highscoresize>0)?highscoresize:DEF_HIGHSCORESIZE); 
     69                m_highscoredb->SetSize(highscoresize); 
     70        } 
    5771 
    5872        bitmap_dices[0] = new wxBitmap(one_xpm); 
     
    297311        std::ostringstream sstr; 
    298312         
    299         data.highscoresize = atoi((m_settingsdb->GetKey("highscoresize")).c_str()); 
     313        data.highscoresize = m_highscoredb->GetSize(); 
    300314         
    301315        dialog->SetData(data); 
Note: See TracChangeset for help on using the changeset viewer.