Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOTextureVerifierStage Class Reference

#include <OOTextureVerifierStage.h>

+ Inheritance diagram for OOTextureVerifierStage:
+ Collaboration diagram for OOTextureVerifierStage:

Instance Methods

(void) - textureNamed:usedInContext:
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(NSString *) - name [implementation]
 
(BOOL) - shouldRun [implementation]
 
(void) - run [implementation]
 
(void) - checkTextureNamed:inFolder: [implementation]
 
- Instance Methods inherited from OOFileHandlingVerifierStage
(NSSet *) - dependencies [implementation]
 
(NSSet *) - dependents [implementation]
 
- Instance Methods inherited from OOOXPVerifierStage
(OOOXPVerifier *) - verifier
 
(BOOL) - completed
 
(id) - description [implementation]
 
(void) - setVerifier: [implementation]
 
(BOOL) - isDependentOf: [implementation]
 
(void) - registerDependency: [implementation]
 
(void) - dependencyRegistrationComplete [implementation]
 
(BOOL) - canRun [implementation]
 
(void) - performRun [implementation]
 
(void) - noteSkipped [implementation]
 
(NSSet *) - resolvedDependencies [implementation]
 
(NSSet *) - resolvedDependents [implementation]
 
(void) - registerDepedent: [implementation]
 
(void) - dependencyCompleted: [implementation]
 

Class Methods

(NSString *) + nameForReverseDependencyForVerifier:
 

Private Attributes

NSMutableSet * _usedTextures
 

Detailed Description

Definition at line 33 of file OOTextureVerifierStage.h.

Method Documentation

◆ checkTextureNamed:inFolder:

- (void) checkTextureNamed: (NSString *) name
inFolder: (NSString *) folder 
implementation

Provided by category OOTextureVerifierStage(OOPrivate).

Definition at line 34 of file OOTextureVerifierStage.m.

130 :(NSString *)name inFolder:(NSString *)folder
131{
132 OOTextureLoader *loader = nil;
133 NSString *path = nil;
134 OOFileScannerVerifierStage *fileScanner = nil;
135 NSString *displayName = nil;
136 OOPixMapDimension rWidth, rHeight;
137 BOOL success;
138 OOPixMap pixmap;
139 OOTextureDataFormat format;
140
141 fileScanner = [[self verifier] fileScannerStage];
142 path = [fileScanner pathForFile:name
143 inFolder:folder
145 checkBuiltIn:NO];
146
147 if (path == nil) return;
148
149 loader = [OOTextureLoader loaderWithPath:path
150 options:kOOTextureMinFilterNearest |
151 kOOTextureMinFilterNearest |
152 kOOTextureNoShrink |
153 kOOTextureNoFNFMessage |
154 kOOTextureNeverScale];
155
156 displayName = [fileScanner displayNameForFile:name andFolder:folder];
157 if (loader == nil)
158 {
159 OOLog(@"verifyOXP.texture.failed", @"***** ERROR: image %@ could not be read.", displayName);
160 }
161 else
162 {
163 success = [loader getResult:&pixmap format:&format originalWidth:NULL originalHeight:NULL];
164
165 if (success)
166 {
167 rWidth = OORoundUpToPowerOf2_PixMap((2 * pixmap.width) / 3);
168 rHeight = OORoundUpToPowerOf2_PixMap((2 * pixmap.height) / 3);
169 if (pixmap.width != rWidth || pixmap.height != rHeight)
170 {
171 OOLog(@"verifyOXP.texture.notPOT", @"----- WARNING: image %@ has non-power-of-two dimensions; it will have to be rescaled (from %ux%u pixels to %ux%u pixels) at runtime.", displayName, pixmap.width, pixmap.height, rWidth, rHeight);
172 }
173 else
174 {
175 OOLog(@"verifyOXP.verbose.texture.OK", @"- %@ (%ux%u px) OK.", displayName, pixmap.width, pixmap.height);
176 }
177
178 OOFreePixMap(&pixmap);
179 }
180 else
181 {
182 OOLog(@"verifyOXP.texture.failed", @"***** ERROR: texture loader failed to load %@.", displayName);
183 }
184 }
185}
#define OOLog(class, format,...)
Definition OOLogging.h:88
uint_fast32_t OOPixMapDimension
Definition OOPixMap.h:33
void OOFreePixMap(OOPixMap *ioPixMap)
Definition OOPixMap.m:86
OOPixMapFormat
Definition OOPixMap.h:39
#define OORoundUpToPowerOf2_PixMap
Definition OOPixMap.h:35
return nil
id displayNameForFile:andFolder:(NSString *file,[andFolder] NSString *folder)
NSString * pathForFile:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
id loaderWithPath:options:(NSString *path,[options] uint32_t options)
BOOL getResult:format:originalWidth:originalHeight:(OOPixMap *result,[format] OOTextureDataFormat *outFormat,[originalWidth] uint32_t *outWidth,[originalHeight] uint32_t *outHeight)
OOPixMapDimension height
Definition OOPixMap.h:50
OOPixMapDimension width
Definition OOPixMap.h:50

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOTextureVerifierStage.m.

58{
59 [_usedTextures release];
60
61 [super dealloc];
62}

◆ init

- (id) init
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOTextureVerifierStage.m.

47{
48 self = [super init];
49 if (self != nil)
50 {
51 _usedTextures = [[NSMutableSet alloc] init];
52 }
53 return self;
54}

◆ name

- (NSString *) name
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOTextureVerifierStage.m.

72{
73 return kStageName;
74}
static NSString *const kStageName

◆ nameForReverseDependencyForVerifier:

+ (NSString *) nameForReverseDependencyForVerifier: (OOOXPVerifier *) verifier

Definition at line 34 of file OOTextureVerifierStage.m.

66{
67 return kStageName;
68}
OOOXPVerifier * verifier()

◆ run

- (void) run
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOTextureVerifierStage.m.

84{
85 NSEnumerator *nameEnum = nil;
86 NSString *name = nil;
87 NSAutoreleasePool *pool = nil;
88
89 for (nameEnum = [_usedTextures objectEnumerator]; (name = [nameEnum nextObject]); )
90 {
91 pool = [[NSAutoreleasePool alloc] init];
92 [self checkTextureNamed:name inFolder:@"Textures"];
93 [pool release];
94 }
95 [_usedTextures release];
97
98 // All "images" are considered used, since we don't have a reasonable way to look for images referenced in JavaScript scripts.
99 nameEnum = [[[[self verifier] fileScannerStage] filesInFolder:@"Images"] objectEnumerator];
100 while ((name = [nameEnum nextObject]))
101 {
102 [self checkTextureNamed:name inFolder:@"Images"];
103 }
104}

◆ shouldRun

- (BOOL) shouldRun
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 34 of file OOTextureVerifierStage.m.

78{
79 return [_usedTextures count] != 0 || [[[self verifier] fileScannerStage] filesInFolder:@"Images"] != nil;
80}

◆ textureNamed:usedInContext:

- (void) textureNamed: (NSString *) name
usedInContext: (NSString *) context 

Definition at line 34 of file OOTextureVerifierStage.m.

107 :(NSString *)name usedInContext:(NSString *)context
108{
109 OOFileScannerVerifierStage *fileScanner = nil;
110
111 if (name == nil) return;
112 if ([_usedTextures containsObject:name]) return;
113 [_usedTextures addObject:name];
114
115 fileScanner = [[self verifier] fileScannerStage];
116 if (![fileScanner fileExists:name
117 inFolder:@"Textures"
118 referencedFrom:context
119 checkBuiltIn:YES])
120 {
121 OOLog(@"verifyOXP.texture.notFound", @"----- WARNING: texture \"%@\" referenced in %@ could not be found in %@ or in Oolite.", name, context, [[self verifier] oxpDisplayName]);
122 }
123}

Member Data Documentation

◆ _usedTextures

- (NSMutableSet*) _usedTextures
private

Definition at line 36 of file OOTextureVerifierStage.h.


The documentation for this class was generated from the following files: