7
7
8
8
@implementation CCPackageCocos2dEnabler
9
9
10
- - (void ) enablePackages : ( NSArray *)packages
10
+ - (BOOL ) isPackagInSearchPath : (CCPackage *)package
11
11
{
12
- [ self addPackagestoSearchPath: packages] ;
12
+ NSString *newPackagePath = package. installURL . path ;
13
13
14
- CCLOGINFO (@" [PACKAGE/INSTALL][INFO] Enable packages - Search path: %@ " , [CCFileUtils sharedFileUtils ].searchPath );
14
+ return [[CCFileUtils sharedFileUtils ].searchPath containsObject: newPackagePath];
15
+ }
15
16
16
- [self reloadCocos2dFiles ];
17
+ - (void )enablePackages : (NSArray *)packages
18
+ {
19
+ if ([self addPackagestoSearchPath: packages]);
20
+ {
21
+ CCLOGINFO (@" [PACKAGE/INSTALL][INFO] Enable packages - Search path: %@ " , [CCFileUtils sharedFileUtils ].searchPath );
22
+
23
+ [self reloadCocos2dFiles ];
24
+ }
17
25
}
18
26
19
27
- (void )disablePackages : (NSArray *)array
@@ -25,8 +33,10 @@ - (void)disablePackages:(NSArray *)array
25
33
[self reloadCocos2dFiles ];
26
34
}
27
35
28
- - (void )addPackagestoSearchPath : (NSArray *)packages
36
+ - (BOOL )addPackagestoSearchPath : (NSArray *)packages
29
37
{
38
+ BOOL searchPathChanged = NO ;
39
+
30
40
for (CCPackage *aPackage in packages)
31
41
{
32
42
NSMutableArray *newSearchPath = [[CCFileUtils sharedFileUtils ].searchPath mutableCopy ];
@@ -35,10 +45,12 @@ - (void)addPackagestoSearchPath:(NSArray *)packages
35
45
if (![newSearchPath containsObject: newPackagePath])
36
46
{
37
47
[newSearchPath insertObject: newPackagePath atIndex: 0 ];
48
+ [CCFileUtils sharedFileUtils ].searchPath = newSearchPath;
49
+ searchPathChanged = YES ;
38
50
}
39
-
40
- [CCFileUtils sharedFileUtils ].searchPath = newSearchPath;
41
51
}
52
+
53
+ return searchPathChanged;
42
54
}
43
55
44
56
- (void )reloadCocos2dFiles
0 commit comments