]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/forty/scorefil.cpp
More makefiles, distrib things,
[wxWidgets.git] / samples / forty / scorefil.cpp
index 9025430eab1ee27250d673b9cce7c4db7d1ebaeb..348be7cfe75b3e92a1a419072c3707c9858f46ba 100644 (file)
@@ -41,8 +41,8 @@
 
 ScoreFile::ScoreFile(const char* appName)
 {
+#if 0
        wxString filename;
-#ifdef __WXGTK__
        m_configFilename << "/usr/local/share/" << appName << ".scores";
        if (access(m_configFilename, F_OK) == 0)
        {
@@ -67,11 +67,9 @@ ScoreFile::ScoreFile(const char* appName)
                        close(fd);
                }
        }
-#else
-       // Windows
-       m_configFilename = wxFileConfig::GetGlobalFileName(appName);
 #endif
-       m_config = new wxFileConfig(m_configFilename);
+
+       m_config = new wxConfig(appName, "wxWindows", appName, "", wxCONFIG_USE_LOCAL_FILE);  // only local
 }
 
 ScoreFile::~ScoreFile()
@@ -85,27 +83,23 @@ ScoreFile::~ScoreFile()
 }
 
 
-void ScoreFile::GetPlayerList(wxString** list, int& length)
+void ScoreFile::GetPlayerList( wxArrayString &list )
 {
        m_config->SetPath("/Players");
-       length = m_config->GetNumberOfGroups();
-
-       if (length <= 0)
-       {
-               *list = 0;
-               return;
-       }
+       int length = m_config->GetNumberOfGroups();
 
-       *list = new wxString[length];
+       if (length <= 0) return;
 
        wxString player;
        long index, i = 0;
        if (m_config->GetFirstGroup(player, index))
        {
-               (*list)[i++] = player;
+            list.Add( player );
+            i++;
                while (m_config->GetNextGroup(player, index))
                {
-                       (*list)[i++] = player;
+                 list.Add( player );
+                 i++;
                }
        }
 }
@@ -134,7 +128,7 @@ wxString ScoreFile::GetPreviousPlayer() const
 {
        wxString result;
        m_config->SetPath("/General");
-       m_config->Read(&result, "LastPlayer");
+       m_config->Read("LastPlayer", &result);
        return result;
 }
 
@@ -151,10 +145,10 @@ void ScoreFile::ReadPlayersScore(
 
        m_config->SetPath("/Players");
        m_config->SetPath(player);
-       if (m_config->Read(&myScore, "Score") &&
-               m_config->Read(&myGames, "Games") &&
-               m_config->Read(&myWins, "Wins") &&
-               m_config->Read(&check, "Check"))
+       if (m_config->Read("Score", &myScore, 0L) &&
+               m_config->Read("Games", &myGames, 0L) &&
+               m_config->Read("Wins",  &myWins, 0L) &&
+               m_config->Read("Check", &check, 0L))
        {
            if (check != CalcCheck(player, myGames, myWins, myScore))
                {
@@ -181,9 +175,9 @@ void ScoreFile::WritePlayersScore(const char* player, int wins, int games, int s
 
                m_config->SetPath("/Players");
                m_config->SetPath(player);
-               m_config->Write("Score", score);
-               m_config->Write("Games", games);
-               m_config->Write("Wins", wins);
+               m_config->Write("Score", (long)score);
+               m_config->Write("Games", (long)games);
+               m_config->Write("Wins", (long)wins);
                m_config->Write("Check", CalcCheck(player, games, wins, score));
        }
 }