| 1899da11 |
sago007 |
2015-12-30 19:04 |
1 |
/* |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
2 |
=========================================================================== |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
4 |
Copyright (C) 2005-2015 Poul Sander |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
5 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
6 |
This program is free software: you can redistribute it and/or modify |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
7 |
it under the terms of the GNU General Public License as published by |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
9 |
(at your option) any later version. |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
10 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
11 |
This program is distributed in the hope that it will be useful, |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
14 |
GNU General Public License for more details. |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
15 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
16 |
You should have received a copy of the GNU General Public License |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
18 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
19 |
Source information and contacts persons can be found at |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
20 |
http://blockattack.net |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
21 |
=========================================================================== |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
22 |
*/ |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
23 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
24 |
#include "os.hpp" |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
25 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
26 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
27 |
/* |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
28 |
*Files will be saved in: |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
29 |
* HOME/.gamesaves/"+GAMENAME (unix) |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
30 |
*or DOCUMENTS/My Games/GAMENAME (Windows) |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
31 |
*/ |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
32 |
#define GAMENAME "blockattack" |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
33 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
34 |
#ifdef _WIN32 |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
35 |
//Returns path to "my Documents" in windows: |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
36 |
string getMyDocumentsPath() { |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
37 |
TCHAR pszPath[MAX_PATH]; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
38 |
//if (SUCCEEDED(SHGetSpecialFolderPath(nullptr, pszPath, CSIDL_PERSONAL, FALSE))) { |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
39 |
if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, pszPath))) { |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
40 |
// pszPath is now the path that you want |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
41 |
#if DEBUG |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
42 |
cout << "MyDocuments Located: " << pszPath << endl; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
43 |
#endif |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
44 |
string theResult= pszPath; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
45 |
return theResult; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
46 |
} |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
47 |
else { |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
48 |
cout << "Warning: My Documents not found!" << endl; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
49 |
string theResult =""; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
50 |
return theResult; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
51 |
} |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
52 |
} |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
53 |
|
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
54 |
//Returns path to "my Documents" in windows: |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
55 |
string getMyDocumentsPath1() { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
56 |
TCHAR pszPath[MAX_PATH]; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
57 |
//if (SUCCEEDED(SHGetSpecialFolderPath(nullptr, pszPath, CSIDL_PERSONAL, FALSE))) { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
58 |
if (SUCCEEDED(SHGetSpecialFolderPath(nullptr, pszPath, CSIDL_PERSONAL, FALSE))) { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
59 |
// pszPath is now the path that you want |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
60 |
cout << "MyDocuments Located: " << pszPath << endl; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
61 |
string theResult= pszPath; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
62 |
return theResult; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
63 |
} |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
64 |
else { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
65 |
cout << "Warning: My Documents not found!" << endl; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
66 |
string theResult =""; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
67 |
return theResult; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
68 |
} |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
69 |
} |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
70 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
71 |
#endif |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
72 |
|
| 1899da11 |
sago007 |
2015-12-30 19:04 |
73 |
/** |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
74 |
* Returns the path to where all settings must be saved. |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
75 |
* On unix-like systems this is the home-folder under: ~/.gamesaves/GAMENAME |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
76 |
* In Windows it is My Documents/My Games |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
77 |
* Consider changing this for Vista that has a special save games folder |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
78 |
*/ |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
79 |
std::string getPathToSaveFiles() { |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
80 |
#ifdef __unix__ |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
81 |
return (std::string)getenv("HOME")+(std::string)"/.gamesaves/"+GAMENAME; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
82 |
#elif _WIN32 |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
83 |
return getMyDocumentsPath()+(string)"/My Games/"+GAMENAME; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
84 |
#else |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
85 |
return "."; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
86 |
#endif |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
87 |
} |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
88 |
|
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
89 |
std::string getPathToHighscoresEndless() { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
90 |
return getPathToSaveFiles()+"/endless.dat"; |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
91 |
} |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
92 |
|
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
93 |
std::string getPathToHighscoresTimetrial() { |
| 1f50b970 |
sago007 |
2015-12-30 21:00 |
94 |
return getPathToSaveFiles()+"/timetrial.dat"; |
| 1899da11 |
sago007 |
2015-12-30 19:04 |
95 |
} |