forked from LemonHaze420/DCPopulous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplatform.cpp
350 lines (297 loc) · 9.53 KB
/
platform.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#include "Platform.h"
#include "SafeProgramming.h"
#include "Object.h"
#include "GameDefines.h"
#include "String.h"
#include "RegistryFunctions.h"
// ----
CPlatform::CPlatform()
{
}
CPlatform::~CPlatform()
{
}
// ----
bool CPlatform::Init()
{
// Lets work out the directories
//DWORD DataType = 0;
//char* Value = NULL;
//DWORD DataLength = 0;
//LONG ret;
CString Temp;
// ----
PathArray[(int)EP_CWD].Clear(); // Special case. Done on the fly.
TCHAR szBuff[MAX_PATH];
if (GetModuleFileName(NULL, szBuff, MAX_PATH))
{
#ifdef UNICODE
TCHAR* end = wcsrchr(szBuff, '\\');
#else
TCHAR* end = strrchr(szBuff, '\\');
#endif
if (end > 0)
*(end + 1) = 0;
PathArray[(int)EP_CWD] = szBuff;
}
PathArray[(int)EP_Install] = PathArray[(int)EP_CWD];
PathArray[(int)EP_Data] = PathArray[(int)EP_CWD];
PathArray[(int)EP_Data] += "Data\\";
PathArray[(int)EP_AudioData] = PathArray[(int)EP_Data];
PathArray[(int)EP_AudioData] += "Audio\\";
PathArray[(int)EP_ImageData] = PathArray[(int)EP_Data];
PathArray[(int)EP_ImageData] += "Images\\";
PathArray[(int)EP_Fonts] = PathArray[(int)EP_Data];
PathArray[(int)EP_Fonts] += "Images\\";
PathArray[(int)EP_Text] = PathArray[(int)EP_Data];
PathArray[(int)EP_Text] += "Text\\";
PathArray[(int)EP_Saves] = PathArray[(int)EP_Install];
// PathArray[(int)EP_Saves] += "Saves\\";
PathArray[(int)EP_Snapshot] = PathArray[(int)EP_Install];
/*
// ----
// Install path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_INSTALL_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
PathArray[(int)EP_Install] = (TCHAR*)Value; // Cast it to a wide string.
}
SAFELY_DELETE_ARRAY(Value);
// ----
// Data path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_DATA_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_Data] = PathArray[(int)EP_Install];
PathArray[(int)EP_Data] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
// ----
// Audio data path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_AUDIO_DATA_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_AudioData] = PathArray[(int)EP_Data];
PathArray[(int)EP_AudioData] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
// ----
// Image data path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_IMAGE_DATA_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_ImageData] = PathArray[(int)EP_Data];
PathArray[(int)EP_ImageData] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
// ----
// Font data path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_FONTS_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_Fonts] = PathArray[(int)EP_Data];
PathArray[(int)EP_Fonts] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
// ----
// Save data path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_SAVE_PATH), // Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_Saves] = PathArray[(int)EP_Install];
PathArray[(int)EP_Saves] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
#ifdef NOT_FINAL_BUILD
// ----
// Save out path
ret = LoadFromRegistry( HKEY_CURRENT_USER, // Existing key or default root.
&CString(REGISTRY_PATH), // Sub key, relative to _ExistingKey. (Must not start with a '/' char!)
&CString(REG_SNAPSHOT_PATH),// Name of value to retrieve.
&DataType, // A pointer to a DWORD filled-in by the function.
&Value, // A pointer to buffer created within the function - you are responsible for the freeing of this resource.
&DataLength);
if ( (SUCCEEDED(ret))
&& (DataType == REG_BINARY)
&& (DataLength)
&& (Value))
{
Temp = (TCHAR*)Value;
PathArray[(int)EP_Snapshot] = PathArray[(int)EP_Install];
PathArray[(int)EP_Snapshot] += Temp;
}
SAFELY_DELETE_ARRAY(Value);
#endif
*/
#ifdef _UNICODE
TCHAR wszMachineName[128];
SystemParametersInfo(SPI_GETOEMINFO, sizeof(wszMachineName), &wszMachineName, 0);
if (wcsicmp(wszMachineName, TEXT("HP,Jornada 540")) == 0)
{
MachineType = EM_HP_Jornada540;
}
else if (wcsicmp(wszMachineName, TEXT("HP,Jornada 540,,9357,USEnglish,SH3")) == 0)
{
MachineType = EM_HP_Jornada545;
}
else if (wcsicmp(wszMachineName, TEXT("Pocket PC J670")) == 0)
{
MachineType = EM_Casio_Cassiopeia125;
}
else if (wcsicmp(wszMachineName, TEXT("Compaq iPAQ H3600")) == 0)
{
MachineType = EM_Compaq_IPaq_3600;
}
else
MachineType = EM_Generic;
//EM_Casio_Generic
#else
MachineType = EM_FailedToQuery;
#endif
return true;
}
// ----
EMachine CPlatform::GetMachineType()
{
return MachineType;
}
// ----
EMachine CPlatform::GetMachineFamily()
{
return (EMachine)(MachineType - (MachineType % GENERIC_MACHINE_BLOCK));
}
// ----
EMachine CPlatform::GetMachineManufacturer()
{
return (EMachine)(MachineType - (MachineType % GENERIC_MANUFACTURER_BLOCK));
}
#ifdef USE_DEPRICATED
// ----
ELanguage CPlatform::GetLangauge()
{
return Language;
}
#endif
// ----
int CPlatform::GetDeviceLanguage()
{
return GetUserDefaultLangID();
/*
switch (GetUserDefaultLangID())
{
case 0x0407: // German (Standard)
case 0x0807: // German (Swiss)
case 0x0c07: // German (Austrian)
case 0x1007: // German (Luxembourg)
case 0x1407: // German (Liechtenstein)
break;
case 0x0409: // English (United States)
case 0x0809: // English (United Kingdom)
case 0x0c09: // English (Australian)
case 0x1009: // English (Canadian)
case 0x1409: // English (New Zealand)
case 0x1809: // English (Ireland)
case 0x1c09: // English (South Africa)
case 0x2009: // English (Jamaica)
case 0x2409: // English (Caribbean)
case 0x2809: // English (Belize)
case 0x2c09: // English (Trinidad)
break;
case 0x040a: // Spanish (Traditional Sort)
case 0x080a: // Spanish (Mexican)
case 0x0c0a: // Spanish (Modern Sort)
case 0x100a: // Spanish (Guatemala)
case 0x140a: // Spanish (Costa Rica)
case 0x180a: // Spanish (Panama)
case 0x1c0a: // Spanish (Dominican Republic)
case 0x200a: // Spanish (Venezuela)
case 0x240a: // Spanish (Colombia)
case 0x280a: // Spanish (Peru)
case 0x2c0a: // Spanish (Argentina)
case 0x300a: // Spanish (Ecuador)
case 0x340a: // Spanish (Chile)
case 0x380a: // Spanish (Uruguay)
case 0x3c0a: // Spanish (Paraguay)
case 0x400a: // Spanish (Bolivia)
case 0x440a: // Spanish (El Salvador)
case 0x480a: // Spanish (Honduras)
case 0x4c0a: // Spanish (Nicaragua)
case 0x500a: // Spanish (Puerto Rico)
break;
case 0x040c: // French (Standard)
case 0x080c: // French (Belgian)
case 0x0c0c: // French (Canadian)
case 0x100c: // French (Swiss)
case 0x140c: // French (Luxembourg)
break;
case 0x0410: // Italian (Standard)
case 0x0810: // Italian (Swiss)
break;
default:
break;
}
*/
}
// ----
// Get various paths
CString* CPlatform::GetPath(EPath _Locale)
{
//if (_Locale == EP_CWD)
//{
// PathArray[((int)_Locale)] = ;
//}
return &PathArray[((int)_Locale)];
}