Skip to content

Commit bc3a806

Browse files
author
minggo
committed
Merge pull request cocos2d#6 from dumganhar/iss1489-AssetsManager
Adds AssetsManager support for win32.
2 parents 9ac23e4 + c59e98f commit bc3a806

File tree

14 files changed

+490
-44
lines changed

14 files changed

+490
-44
lines changed

cocos2d-win32.vc2010.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "samples\Jav
8484
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
8585
EndProjectSection
8686
EndProject
87+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}"
88+
ProjectSection(ProjectDependencies) = postProject
89+
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
90+
{39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD}
91+
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
92+
EndProjectSection
93+
EndProject
8794
Global
8895
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8996
Debug|Win32 = Debug|Win32
@@ -154,6 +161,10 @@ Global
154161
{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.Build.0 = Debug|Win32
155162
{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.ActiveCfg = Release|Win32
156163
{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.Build.0 = Release|Win32
164+
{6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.ActiveCfg = Debug|Win32
165+
{6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.Build.0 = Debug|Win32
166+
{6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.ActiveCfg = Release|Win32
167+
{6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.Build.0 = Release|Win32
157168
EndGlobalSection
158169
GlobalSection(SolutionProperties) = preSolution
159170
HideSolutionNode = FALSE
@@ -169,6 +180,7 @@ Global
169180
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {46BAA168-511D-4C17-B482-0C73844530CB}
170181
{76A39BB2-9B84-4C65-98A5-654D86B86F2A} = {F3E539F7-881F-4B6B-BC0E-B05D4D9E5384}
171182
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB} = {F3E539F7-881F-4B6B-BC0E-B05D4D9E5384}
183+
{6D37505F-A890-441D-BD3F-A61E2C0469CE} = {F3E539F7-881F-4B6B-BC0E-B05D4D9E5384}
172184
{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2} = {68B43009-A1C1-41B2-8AF7-77278B70E897}
173185
{D0F06A44-A245-4D13-A498-0120C203B539} = {68B43009-A1C1-41B2-8AF7-77278B70E897}
174186
{BE092D9E-95AE-4F86-84CE-F4519E4F3F15} = {68B43009-A1C1-41B2-8AF7-77278B70E897}

cocos2dx/support/zip_support/unzip.h

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#ifndef _unz64_H
4444
#define _unz64_H
4545

46+
#include "CCPlatformDefine.h"
47+
4648
#ifndef _ZLIB_H
4749
#include "zlib.h"
4850
#endif
@@ -148,7 +150,7 @@ typedef struct unz_file_info_s
148150
tm_unz tmu_date;
149151
} unz_file_info;
150152

151-
int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
153+
int CC_DLL unzStringFileNameCompare OF ((const char* fileName1,
152154
const char* fileName2,
153155
int iCaseSensitivity));
154156
/*
@@ -161,8 +163,8 @@ int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
161163
*/
162164

163165

164-
unzFile ZEXPORT unzOpen OF((const char *path));
165-
unzFile ZEXPORT unzOpen64 OF((const void *path));
166+
unzFile CC_DLL unzOpen OF((const char *path));
167+
unzFile CC_DLL unzOpen64 OF((const void *path));
166168
/*
167169
Open a Zip file. path contain the full pathname (by example,
168170
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
@@ -179,39 +181,39 @@ unzFile ZEXPORT unzOpen64 OF((const void *path));
179181
*/
180182

181183

182-
unzFile ZEXPORT unzOpen2 OF((const char *path,
184+
unzFile CC_DLL unzOpen2 OF((const char *path,
183185
zlib_filefunc_def* pzlib_filefunc_def));
184186
/*
185187
Open a Zip file, like unzOpen, but provide a set of file low level API
186188
for read/write the zip file (see ioapi.h)
187189
*/
188190

189-
unzFile ZEXPORT unzOpen2_64 OF((const void *path,
191+
unzFile CC_DLL unzOpen2_64 OF((const void *path,
190192
zlib_filefunc64_def* pzlib_filefunc_def));
191193
/*
192194
Open a Zip file, like unz64Open, but provide a set of file low level API
193195
for read/write the zip file (see ioapi.h)
194196
*/
195197

196-
int ZEXPORT unzClose OF((unzFile file));
198+
int CC_DLL unzClose OF((unzFile file));
197199
/*
198200
Close a ZipFile opened with unzipOpen.
199201
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
200202
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
201203
return UNZ_OK if there is no problem. */
202204

203-
int ZEXPORT unzGetGlobalInfo OF((unzFile file,
205+
int CC_DLL unzGetGlobalInfo OF((unzFile file,
204206
unz_global_info *pglobal_info));
205207

206-
int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
208+
int CC_DLL unzGetGlobalInfo64 OF((unzFile file,
207209
unz_global_info64 *pglobal_info));
208210
/*
209211
Write info about the ZipFile in the *pglobal_info structure.
210212
No preparation of the structure is needed
211213
return UNZ_OK if there is no problem. */
212214

213215

214-
int ZEXPORT unzGetGlobalComment OF((unzFile file,
216+
int CC_DLL unzGetGlobalComment OF((unzFile file,
215217
char *szComment,
216218
uLong uSizeBuf));
217219
/*
@@ -224,14 +226,14 @@ int ZEXPORT unzGetGlobalComment OF((unzFile file,
224226
/***************************************************************************/
225227
/* Unzip package allow you browse the directory of the zipfile */
226228

227-
int ZEXPORT unzGoToFirstFile OF((unzFile file));
229+
int CC_DLL unzGoToFirstFile OF((unzFile file));
228230

229231
/*
230232
Set the current file of the zipfile to the first file.
231233
return UNZ_OK if there is no problem
232234
*/
233235

234-
int ZEXPORT unzGoToFirstFile64 OF((unzFile file,
236+
int CC_DLL unzGoToFirstFile64 OF((unzFile file,
235237
unz_file_info64 *pfile_info,
236238
char *szFileName,
237239
uLong fileNameBufferSize));
@@ -241,14 +243,14 @@ int ZEXPORT unzGoToFirstFile64 OF((unzFile file,
241243
return UNZ_OK if there is no problem
242244
*/
243245

244-
int ZEXPORT unzGoToNextFile OF((unzFile file));
246+
int CC_DLL unzGoToNextFile OF((unzFile file));
245247
/*
246248
Set the current file of the zipfile to the next file.
247249
return UNZ_OK if there is no problem
248250
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
249251
*/
250252

251-
int ZEXPORT unzGoToNextFile64 OF((unzFile file,
253+
int CC_DLL unzGoToNextFile64 OF((unzFile file,
252254
unz_file_info64 *pfile_info,
253255
char *szFileName,
254256
uLong fileNameBufferSize));
@@ -259,7 +261,7 @@ int ZEXPORT unzGoToNextFile64 OF((unzFile file,
259261
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
260262
*/
261263

262-
int ZEXPORT unzLocateFile OF((unzFile file,
264+
int CC_DLL unzLocateFile OF((unzFile file,
263265
const char *szFileName,
264266
int iCaseSensitivity));
265267
/*
@@ -281,11 +283,11 @@ typedef struct unz_file_pos_s
281283
uLong num_of_file; /* # of file */
282284
} unz_file_pos;
283285

284-
int ZEXPORT unzGetFilePos(
286+
int CC_DLL unzGetFilePos(
285287
unzFile file,
286288
unz_file_pos* file_pos);
287289

288-
int ZEXPORT unzGoToFilePos(
290+
int CC_DLL unzGoToFilePos(
289291
unzFile file,
290292
unz_file_pos* file_pos);
291293

@@ -295,17 +297,17 @@ typedef struct unz64_file_pos_s
295297
ZPOS64_T num_of_file; /* # of file */
296298
} unz64_file_pos;
297299

298-
int ZEXPORT unzGetFilePos64(
300+
int CC_DLL unzGetFilePos64(
299301
unzFile file,
300302
unz64_file_pos* file_pos);
301303

302-
int ZEXPORT unzGoToFilePos64(
304+
int CC_DLL unzGoToFilePos64(
303305
unzFile file,
304306
const unz64_file_pos* file_pos);
305307

306308
/* ****************************************** */
307309

308-
int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
310+
int CC_DLL unzGetCurrentFileInfo64 OF((unzFile file,
309311
unz_file_info64 *pfile_info,
310312
char *szFileName,
311313
uLong fileNameBufferSize,
@@ -314,7 +316,7 @@ int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
314316
char *szComment,
315317
uLong commentBufferSize));
316318

317-
int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
319+
int CC_DLL unzGetCurrentFileInfo OF((unzFile file,
318320
unz_file_info *pfile_info,
319321
char *szFileName,
320322
uLong fileNameBufferSize,
@@ -338,7 +340,7 @@ int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
338340

339341
/** Addition for GDAL : START */
340342

341-
ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
343+
ZPOS64_T CC_DLL unzGetCurrentFileZStreamPos64 OF((unzFile file));
342344

343345
/** Addition for GDAL : END */
344346

@@ -348,21 +350,21 @@ ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
348350
from it, and close it (you can close it before reading all the file)
349351
*/
350352

351-
int ZEXPORT unzOpenCurrentFile OF((unzFile file));
353+
int CC_DLL unzOpenCurrentFile OF((unzFile file));
352354
/*
353355
Open for reading data the current file in the zipfile.
354356
If there is no error, the return value is UNZ_OK.
355357
*/
356358

357-
int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
359+
int CC_DLL unzOpenCurrentFilePassword OF((unzFile file,
358360
const char* password));
359361
/*
360362
Open for reading data the current file in the zipfile.
361363
password is a crypting password
362364
If there is no error, the return value is UNZ_OK.
363365
*/
364366

365-
int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
367+
int CC_DLL unzOpenCurrentFile2 OF((unzFile file,
366368
int* method,
367369
int* level,
368370
int raw));
@@ -375,7 +377,7 @@ int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
375377
but you CANNOT set method parameter as NULL
376378
*/
377379

378-
int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
380+
int CC_DLL unzOpenCurrentFile3 OF((unzFile file,
379381
int* method,
380382
int* level,
381383
int raw,
@@ -390,13 +392,13 @@ int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
390392
*/
391393

392394

393-
int ZEXPORT unzCloseCurrentFile OF((unzFile file));
395+
int CC_DLL unzCloseCurrentFile OF((unzFile file));
394396
/*
395397
Close the file in zip opened with unzOpenCurrentFile
396398
Return UNZ_CRCERROR if all the file was read but the CRC is not good
397399
*/
398400

399-
int ZEXPORT unzReadCurrentFile OF((unzFile file,
401+
int CC_DLL unzReadCurrentFile OF((unzFile file,
400402
voidp buf,
401403
unsigned len));
402404
/*
@@ -410,19 +412,19 @@ int ZEXPORT unzReadCurrentFile OF((unzFile file,
410412
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
411413
*/
412414

413-
z_off_t ZEXPORT unztell OF((unzFile file));
415+
z_off_t CC_DLL unztell OF((unzFile file));
414416

415-
ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
417+
ZPOS64_T CC_DLL unztell64 OF((unzFile file));
416418
/*
417419
Give the current position in uncompressed data
418420
*/
419421

420-
int ZEXPORT unzeof OF((unzFile file));
422+
int CC_DLL unzeof OF((unzFile file));
421423
/*
422424
return 1 if the end of file was reached, 0 elsewhere
423425
*/
424426

425-
int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
427+
int CC_DLL unzGetLocalExtrafield OF((unzFile file,
426428
voidp buf,
427429
unsigned len));
428430
/*
@@ -441,12 +443,12 @@ int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
441443
/***************************************************************************/
442444

443445
/* Get the current file offset */
444-
ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
445-
uLong ZEXPORT unzGetOffset (unzFile file);
446+
ZPOS64_T CC_DLL unzGetOffset64 (unzFile file);
447+
uLong CC_DLL unzGetOffset (unzFile file);
446448

447449
/* Set the current file offset */
448-
int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
449-
int ZEXPORT unzSetOffset (unzFile file, uLong pos);
450+
int CC_DLL unzSetOffset64 (unzFile file, ZPOS64_T pos);
451+
int CC_DLL unzSetOffset (unzFile file, uLong pos);
450452

451453
} // end of namespace cocos2d
452454

extensions/AssetsManager/AssetsManager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ bool AssetsManager::createDirectory(const char *path)
320320

321321
return true;
322322
#else
323-
//@todo create a direcotry on win32
324-
return false;
323+
BOOL ret = CreateDirectoryA(path, NULL);
324+
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
325+
{
326+
return false;
327+
}
328+
return true;
325329
#endif
326330
}
327331

extensions/proj.win32/libExtensions.vcxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
6464
<ClCompile>
6565
<Optimization>Disabled</Optimization>
66-
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
66+
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\zlib;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6767
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
6868
<MinimalRebuild>true</MinimalRebuild>
6969
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -79,7 +79,7 @@
7979
<ClCompile>
8080
<Optimization>MaxSpeed</Optimization>
8181
<IntrinsicFunctions>true</IntrinsicFunctions>
82-
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
82+
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\external\sqlite3\include;$(ProjectDir)..\..\external;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\zlib;..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
8383
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_LIB;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8484
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
8585
<FunctionLevelLinking>true</FunctionLevelLinking>
@@ -91,6 +91,7 @@
9191
</ClCompile>
9292
</ItemDefinitionGroup>
9393
<ItemGroup>
94+
<ClCompile Include="..\AssetsManager\AssetsManager.cpp" />
9495
<ClCompile Include="..\CCBReader\CCBAnimationManager.cpp" />
9596
<ClCompile Include="..\CCBReader\CCBFileLoader.cpp" />
9697
<ClCompile Include="..\CCBReader\CCBKeyframe.cpp" />
@@ -140,6 +141,7 @@
140141
<ClCompile Include="Win32InputBox.cpp" />
141142
</ItemGroup>
142143
<ItemGroup>
144+
<ClInclude Include="..\AssetsManager\AssetsManager.h" />
143145
<ClInclude Include="..\CCBReader\CCBAnimationManager.h" />
144146
<ClInclude Include="..\CCBReader\CCBFileLoader.h" />
145147
<ClInclude Include="..\CCBReader\CCBKeyframe.h" />

extensions/proj.win32/libExtensions.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<Filter Include="GUI\CCEditBox">
2626
<UniqueIdentifier>{5d186e3d-0aaf-4904-a5d8-e5cb0f35f4cc}</UniqueIdentifier>
2727
</Filter>
28+
<Filter Include="AssetsManager">
29+
<UniqueIdentifier>{49487dbe-5758-436a-b014-8e2edc6b33ae}</UniqueIdentifier>
30+
</Filter>
2831
</ItemGroup>
2932
<ItemGroup>
3033
<ClCompile Include="..\GUI\CCScrollView\CCScrollView.cpp">
@@ -168,6 +171,9 @@
168171
<ClCompile Include="..\GUI\CCEditBox\CCEditBox.cpp">
169172
<Filter>GUI\CCEditBox</Filter>
170173
</ClCompile>
174+
<ClCompile Include="..\AssetsManager\AssetsManager.cpp">
175+
<Filter>AssetsManager</Filter>
176+
</ClCompile>
171177
</ItemGroup>
172178
<ItemGroup>
173179
<ClInclude Include="..\GUI\CCScrollView\CCScrollView.h">
@@ -337,5 +343,8 @@
337343
<ClInclude Include="..\GUI\CCEditBox\CCEditBoxImpl.h">
338344
<Filter>GUI\CCEditBox</Filter>
339345
</ClInclude>
346+
<ClInclude Include="..\AssetsManager\AssetsManager.h">
347+
<Filter>AssetsManager</Filter>
348+
</ClInclude>
340349
</ItemGroup>
341350
</Project>

0 commit comments

Comments
 (0)