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 : + (NSString *)useAddOns; 67 0 : + (NSArray *)OXPsWithMessagesFound; 68 0 : + (void)setUseAddOns:(NSString *)useAddOns; 69 0 : + (void)addExternalPath:(NSString *)fileName; 70 0 : + (NSEnumerator *)pathEnumerator; 71 0 : + (NSEnumerator *)reversePathEnumerator; 72 : 73 : // get manifest data for identifier 74 0 : + (NSDictionary *)manifestForIdentifier:(NSString *)identifier; 75 : // compatibility checks 76 0 : + (BOOL) checkVersionCompatibility:(NSDictionary *)manifest forOXP:(NSString *)title; 77 0 : + (BOOL) manifestHasConflicts:(NSDictionary *)manifest logErrors:(BOOL)logErrors; 78 0 : + (BOOL) manifestHasMissingDependencies:(NSDictionary *)manifest logErrors:(BOOL)logErrors; 79 0 : + (BOOL) manifest:(NSDictionary *)manifest HasUnmetDependency:(NSDictionary *)required logErrors:(BOOL)logErrors; 80 0 : + (BOOL) matchVersions:(NSDictionary *)rangeDict withVersion:(NSString *)version; 81 : 82 : 83 : 84 0 : + (void)handleEquipmentListMerging: (NSMutableArray *)arrayToProcess forLookupIndex:(unsigned)lookupIndex; 85 0 : + (void)handleEquipmentOverrides: (NSMutableArray *)arrayToProcess; 86 0 : + (void)handleStarNebulaListMerging: (NSMutableArray *)arrayToProcess; 87 : 88 0 : + (NSString *)errors; // Errors which occurred during path scanning - essentially a list of OXPs whose requires.plist is bad. 89 : 90 0 : + (NSString *) pathForFileNamed:(NSString *)fileName inFolder:(NSString *)folderName; 91 0 : + (NSString *) pathForFileNamed:(NSString *)fileName inFolder:(NSString *)folderName cache:(BOOL)useCache; 92 : 93 0 : + (BOOL) corePlist:(NSString *)fileName excludedAt:(NSString *)path; 94 : 95 0 : + (NSDictionary *)dictionaryFromFilesNamed:(NSString *)fileName 96 : inFolder:(NSString *)folderName 97 : andMerge:(BOOL) mergeFiles; 98 0 : + (NSDictionary *)dictionaryFromFilesNamed:(NSString *)fileName 99 : inFolder:(NSString *)folderName 100 : mergeMode:(OOResourceMergeMode)mergeMode 101 : cache:(BOOL)useCache; 102 : 103 0 : + (NSArray *)arrayFromFilesNamed:(NSString *)fileName 104 : inFolder:(NSString *)folderName 105 : andMerge:(BOOL) mergeFiles; 106 0 : + (NSArray *)arrayFromFilesNamed:(NSString *)fileName 107 : inFolder:(NSString *)folderName 108 : andMerge:(BOOL) mergeFiles 109 : cache:(BOOL)useCache; 110 : 111 : // These are deliberately not merged like normal plists for security reasons. 112 0 : + (NSDictionary *) whitelistDictionary; 113 0 : + (NSDictionary *) shaderBindingTypesDictionary; 114 : 115 : // These have special merging rules. 116 0 : + (NSDictionary *) logControlDictionary; 117 0 : + (NSDictionary *) roleCategoriesDictionary; 118 0 : + (OOSystemDescriptionManager *) systemDescriptionManager; 119 : 120 0 : + (OOSound *)ooSoundNamed:(NSString *)fileName inFolder:(NSString *)folderName; 121 0 : + (OOMusic *)ooMusicNamed:(NSString *)fileName inFolder:(NSString *)folderName; 122 : 123 0 : + (NSString *) stringFromFilesNamed:(NSString *)fileName inFolder:(NSString *)folderName; 124 0 : + (NSString *) stringFromFilesNamed:(NSString *)fileName inFolder:(NSString *)folderName cache:(BOOL)useCache; 125 : 126 0 : + (NSDictionary *)loadScripts; 127 : 128 : /* +writeDiagnosticData:toFileNamed: 129 : +writeDiagnosticString:toFileNamed: 130 : +writeDiagnosticPList:toFileNamed: 131 : 132 : Write data to the specified path within the log directory. Slashes may be 133 : used as path separators in name. 134 : */ 135 0 : + (BOOL) writeDiagnosticData:(NSData *)data toFileNamed:(NSString *)name; 136 0 : + (BOOL) writeDiagnosticString:(NSString *)string toFileNamed:(NSString *)name; 137 0 : + (BOOL) writeDiagnosticPList:(id)plist toFileNamed:(NSString *)name; 138 : 139 0 : + (NSString *) diagnosticFileLocation; 140 : 141 0 : + (NSDictionary *) materialDefaults; 142 : 143 : // Clear ResourceManager-internal caches (not those handled by OOCacheManager) 144 0 : + (void) clearCaches; 145 : 146 : @end