Line data Source code
1 0 : /* 2 : 3 : ResourceManager.h 4 : 5 : Singleton class responsible for loading various data files. 6 : 7 : Oolite 8 : Copyright (C) 2004-2013 Giles C Williams and contributors 9 : 10 : This program is free software; you can redistribute it and/or 11 : modify it under the terms of the GNU General Public License 12 : as published by the Free Software Foundation; either version 2 13 : of the License, or (at your option) any later version. 14 : 15 : This program is distributed in the hope that it will be useful, 16 : but WITHOUT ANY WARRANTY; without even the implied warranty of 17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 : GNU General Public License for more details. 19 : 20 : You should have received a copy of the GNU General Public License 21 : along with this program; if not, write to the Free Software 22 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 : MA 02110-1301, USA. 24 : 25 : */ 26 : 27 : #import "OOCocoa.h" 28 : #import "OOOpenGL.h" 29 : #import "NSFileManagerOOExtensions.h" 30 : 31 : @class OOSound, OOMusic, OOSystemDescriptionManager; 32 : 33 : 34 0 : typedef enum 35 : { 36 : MERGE_NONE, // Just use the last file in search order. 37 : MERGE_BASIC, // Merge files by adding the top-level items of each file. 38 : MERGE_SMART // Merge files by merging the top-level elements of each file (second-order merge, but not recursive) 39 : } OOResourceMergeMode; 40 : 41 : /* 'All' doesn't quite mean 'all' - OXPs with the tag 42 : * "oolite-scenario-only" will only be loaded if required by a 43 : * scenario. 44 : * 45 : * Note that this means that the scenario itself must be in a 46 : * different OXP, or it'll never be loaded when on the start-game 47 : * screen. 48 : */ 49 0 : #define SCENARIO_OXP_DEFINITION_ALL @"" 50 0 : #define SCENARIO_OXP_DEFINITION_NONE @"strict" 51 0 : #define SCENARIO_OXP_DEFINITION_BYID @"id:" 52 0 : #define SCENARIO_OXP_DEFINITION_BYTAG @"tag:" 53 0 : #define SCENARIO_OXP_DEFINITION_NOPLIST @"exc:" 54 : 55 0 : @interface ResourceManager : NSObject 56 : 57 0 : + (void) reset; 58 0 : + (void) resetManifestKnowledgeForOXZManager; 59 : 60 : 61 0 : + (NSArray *)rootPaths; // Places add-ons are searched for, not including add-on paths. 62 0 : + (NSArray *)userRootPaths; // Places users are expected to place add-ons, not including built-in data or managed add-ons directory. 63 0 : + (NSString *)builtInPath; // Path for built-in data only. 64 0 : + (NSArray *)pathsWithAddOns; // Root paths + add-on paths. 65 0 : + (NSArray *)paths; // builtInPath or pathsWithAddOns, depending on useAddOns state. 66 0 : + (NSArray *)maskUserNameInPathArray:(NSArray *)inputPathArray; // potential privacy concerns 67 0 : + (NSString *)maskUserName:(NSString *)name inPath:(NSString *)path; 68 0 : + (NSString *)useAddOns; 69 0 : + (NSArray *)OXPsWithMessagesFound; 70 0 : + (void)setUseAddOns:(NSString *)useAddOns; 71 0 : + (void)addExternalPath:(NSString *)fileName; 72 0 : + (NSEnumerator *)pathEnumerator; 73 0 : + (NSEnumerator *)reversePathEnumerator; 74 : 75 : // get manifest data for identifier 76 0 : + (NSDictionary *)manifestForIdentifier:(NSString *)identifier; 77 : // compatibility checks 78 0 : + (BOOL) checkVersionCompatibility:(NSDictionary *)manifest forOXP:(NSString *)title; 79 0 : + (BOOL) manifestHasConflicts:(NSDictionary *)manifest logErrors:(BOOL)logErrors; 80 0 : + (BOOL) manifestHasMissingDependencies:(NSDictionary *)manifest logErrors:(BOOL)logErrors; 81 0 : + (BOOL) manifest:(NSDictionary *)manifest HasUnmetDependency:(NSDictionary *)required logErrors:(BOOL)logErrors; 82 0 : + (BOOL) matchVersions:(NSDictionary *)rangeDict withVersion:(NSString *)version; 83 : 84 : 85 : 86 0 : + (void)handleEquipmentListMerging: (NSMutableArray *)arrayToProcess forLookupIndex:(unsigned)lookupIndex; 87 0 : + (void)handleEquipmentOverrides: (NSMutableArray *)arrayToProcess; 88 0 : + (void)handleStarNebulaListMerging: (NSMutableArray *)arrayToProcess; 89 : 90 0 : + (NSString *)errors; // Errors which occurred during path scanning - essentially a list of OXPs whose requires.plist is bad. 91 : 92 0 : + (NSString *) pathForFileNamed:(NSString *)fileName inFolder:(NSString *)folderName; 93 0 : + (NSString *) pathForFileNamed:(NSString *)fileName inFolder:(NSString *)folderName cache:(BOOL)useCache; 94 : 95 0 : + (BOOL) corePlist:(NSString *)fileName excludedAt:(NSString *)path; 96 : 97 0 : + (NSDictionary *)dictionaryFromFilesNamed:(NSString *)fileName 98 : inFolder:(NSString *)folderName 99 : andMerge:(BOOL) mergeFiles; 100 0 : + (NSDictionary *)dictionaryFromFilesNamed:(NSString *)fileName 101 : inFolder:(NSString *)folderName 102 : mergeMode:(OOResourceMergeMode)mergeMode 103 : cache:(BOOL)useCache; 104 : 105 0 : + (NSArray *)arrayFromFilesNamed:(NSString *)fileName 106 : inFolder:(NSString *)folderName 107 : andMerge:(BOOL) mergeFiles; 108 0 : + (NSArray *)arrayFromFilesNamed:(NSString *)fileName 109 : inFolder:(NSString *)folderName 110 : andMerge:(BOOL) mergeFiles 111 : cache:(BOOL)useCache; 112 : 113 : // These are deliberately not merged like normal plists for security reasons. 114 0 : + (NSDictionary *) whitelistDictionary; 115 0 : + (NSDictionary *) shaderBindingTypesDictionary; 116 : 117 : // These have special merging rules. 118 0 : + (NSDictionary *) logControlDictionary; 119 0 : + (NSDictionary *) roleCategoriesDictionary; 120 0 : + (OOSystemDescriptionManager *) systemDescriptionManager; 121 : 122 0 : + (OOSound *)ooSoundNamed:(NSString *)fileName inFolder:(NSString *)folderName; 123 0 : + (OOMusic *)ooMusicNamed:(NSString *)fileName inFolder:(NSString *)folderName; 124 : 125 0 : + (NSString *) stringFromFilesNamed:(NSString *)fileName inFolder:(NSString *)folderName; 126 0 : + (NSString *) stringFromFilesNamed:(NSString *)fileName inFolder:(NSString *)folderName cache:(BOOL)useCache; 127 : 128 0 : + (NSDictionary *)loadScripts; 129 : 130 : /* +writeDiagnosticData:toFileNamed: 131 : +writeDiagnosticString:toFileNamed: 132 : +writeDiagnosticPList:toFileNamed: 133 : 134 : Write data to the specified path within the log directory. Slashes may be 135 : used as path separators in name. 136 : */ 137 0 : + (BOOL) writeDiagnosticData:(NSData *)data toFileNamed:(NSString *)name; 138 0 : + (BOOL) writeDiagnosticString:(NSString *)string toFileNamed:(NSString *)name; 139 0 : + (BOOL) writeDiagnosticPList:(id)plist toFileNamed:(NSString *)name; 140 : 141 0 : + (NSString *) diagnosticFileLocation; 142 : 143 0 : + (NSDictionary *) materialDefaults; 144 : 145 : // Clear ResourceManager-internal caches (not those handled by OOCacheManager) 146 0 : + (void) clearCaches; 147 : 148 : @end