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