Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GuestRoom View - replaced the pet as it will contain some helper meth…

…ods to find content.

  * Recurisvely find images
  • Loading branch information...
commit 2dca9edca6a2ef287c82cd1e3d3dfedf8c0837a7 1 parent 0409a90
@burtlo authored
View
6 Gravy.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
E267075314774321008D5C3E /* anthome_2x1_1.png in Resources */ = {isa = PBXBuildFile; fileRef = E267075214774321008D5C3E /* anthome_2x1_1.png */; };
+ E267075A1477475B008D5C3E /* GuestRoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = E26707591477475B008D5C3E /* GuestRoomView.m */; };
E281AAE21470667300F35708 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E281AAE11470667300F35708 /* Cocoa.framework */; };
E281AAEC1470667300F35708 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E281AAEA1470667300F35708 /* InfoPlist.strings */; };
E281AAEE1470667300F35708 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E281AAED1470667300F35708 /* main.m */; };
@@ -247,6 +248,8 @@
/* Begin PBXFileReference section */
E267075214774321008D5C3E /* anthome_2x1_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = anthome_2x1_1.png; sourceTree = "<group>"; };
+ E26707581477475B008D5C3E /* GuestRoomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuestRoomView.h; sourceTree = "<group>"; };
+ E26707591477475B008D5C3E /* GuestRoomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GuestRoomView.m; sourceTree = "<group>"; };
E281AADD1470667300F35708 /* Gravy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Gravy.app; sourceTree = BUILT_PRODUCTS_DIR; };
E281AAE11470667300F35708 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
E281AAE41470667300F35708 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
@@ -680,6 +683,8 @@
E281AB471470683F00F35708 /* PetsDocumentController.h */,
E281AB481470683F00F35708 /* PetsDocumentController.m */,
E281AB461470683F00F35708 /* Pets.xib */,
+ E26707581477475B008D5C3E /* GuestRoomView.h */,
+ E26707591477475B008D5C3E /* GuestRoomView.m */,
E2A70F0414707B6800347704 /* PetsAnimationLayer.h */,
E2A70F0514707B6800347704 /* PetsAnimationLayer.m */,
);
@@ -1236,6 +1241,7 @@
E281AB501470689000F35708 /* CSVParser.m in Sources */,
E281AB551470689B00F35708 /* DocumentController.m in Sources */,
E2A70F0614707B6800347704 /* PetsAnimationLayer.m in Sources */,
+ E267075A1477475B008D5C3E /* GuestRoomView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
6 Gravy/AMDocumentController.m
@@ -48,8 +48,8 @@ - (void)openDocument:(id)sender {
// [[NSBundle mainBundle] loadNibFile:@"Pets" externalNameTable:[NSDictionary dictionary] withZone:nil];
- PetsDocumentController *petsDocController = [[PetsDocumentController alloc] initWithGameObjects:[self gameObjectsFromBaseFolder:baseFolder]];
-// PetsDocumentController *petsDocController = [[PetsDocumentController alloc] initWithWindowNibName:@"Pets" withGameObjects:[self gameObjectsFromBaseFolder:baseFolder]];
+ PetsDocumentController *petsDocController = [[PetsDocumentController alloc] initWithGameObjects:[self gameObjectsFromBaseFolder:baseFolder]
+ rootResourcesFolder:baseFolder];
}
@@ -58,7 +58,7 @@ - (void)openDocument:(id)sender {
- (NSURL *)urlForCSVFileWithName:(NSString *)fileName withBase:(NSURL *)base {
- NSURL *csvFilePath = [NSURL URLWithString:[NSString stringWithFormat:@"%@.csv",fileName] relativeToURL:base];
+ NSURL *csvFilePath = [NSURL URLWithString:[NSString stringWithFormat:@"Parameters/%@.csv",fileName] relativeToURL:base];
return csvFilePath;
}
View
26 Gravy/GuestRoomView.h
@@ -0,0 +1,26 @@
+//
+// GuestRoomView.h
+// Gravy
+//
+// Created by Franklin Webber on 11/18/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "Pet.h"
+#import "cocos2d.h"
+
+@interface GuestRoomView : NSObject {
+ NSURL *baseResourcesURL;
+}
+
+- (id)initWithPet:(Pet *)pet rootResourcesFolder:(NSURL *)resourcesURL;
+
+@property (nonatomic,readwrite,retain) Pet *pet;
+
+- (NSImage *)imageIcon;
+- (CCSprite *)spriteForLevel2Construction;
+- (NSString *)filename;
+- (NSString *)name;
+
+@end
View
80 Gravy/GuestRoomView.m
@@ -0,0 +1,80 @@
+//
+// GuestRoomView.m
+// Gravy
+//
+// Created by Franklin Webber on 11/18/11.
+// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "GuestRoomView.h"
+
+@implementation GuestRoomView
+
+@synthesize pet;
+
+#pragma mark - Initialization
+
+- (id)initWithPet:(Pet *)aPet rootResourcesFolder:(NSURL *)resourcesURL {
+ self = [super init];
+ if (self) {
+ [self setPet:aPet];
+ baseResourcesURL = [resourcesURL retain];
+ }
+ return self;
+}
+
+#pragma mark - Helper Methods
+
+- (NSImage *)imageIcon {
+
+
+ NSDirectoryEnumerator *de = [[NSFileManager defaultManager] enumeratorAtURL:baseResourcesURL
+ includingPropertiesForKeys:nil
+ options:NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsPackageDescendants
+ errorHandler:^BOOL(NSURL *url, NSError *error) {
+
+ NSLog(@"Error finding files");
+ return YES;
+
+ }];
+
+ NSURL *file;
+
+ while ((file = [de nextObject])) {
+ //NSLog(@"Looking at %@",file);
+
+ if ( [[file absoluteString] hasSuffix:[[pet room] iconFilename]] ) {
+ NSLog(@"Found image at %@",[file absoluteString]);
+ NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[file absoluteString]] autorelease];
+
+ return image;
+
+ }
+ }
+
+ return nil;
+}
+
+- (NSString *)filename {
+ return [pet filename];
+}
+
+- (NSString *)name {
+ return [pet name];
+}
+
+- (CCSprite *)spriteForLevel2Construction {
+
+}
+
+
+
+#pragma mark - Deallocation
+
+- (void)dealloc {
+ [pet release];
+ [baseResourcesURL release];
+ [super dealloc];
+}
+
+@end
View
1  Gravy/PetsAnimationLayer.m
@@ -44,7 +44,6 @@ - (id)init {
// add the label as a child to this Layer
[self addChild: label];
-
CCSprite *sprite = [CCSprite spriteWithFile:@"anthome_2x1_1.png"];
[sprite setPosition:ccp( size.width/2, size.height/2)];
[self addChild:sprite];
View
8 Gravy/PetsDocumentController.h
@@ -12,13 +12,15 @@
@interface PetsDocumentController : NSObject
-- (id)initWithGameObjects:(GameObjects *)aGameObjects;
-//- (id)initWithWindowNibName:(NSString *)windowNibName withGameObjects:(GameObjects *)aGameObjects;
+- (id)initWithGameObjects:(GameObjects *)aGameObjects rootResourcesFolder:(NSURL *)resourcesURL;
@property (nonatomic,assign) IBOutlet NSWindow *window;
+
@property (nonatomic,assign) IBOutlet GameObjects *gameObjects;
+@property (nonatomic,retain) IBOutlet MacGLView *animationView;
+
@property (nonatomic,assign) IBOutlet NSMutableArray *pets;
-@property (nonatomic,retain) IBOutlet MacGLView *animationView;
+@property (nonatomic,assign) NSURL *baseResourcesURL;
@end
View
22 Gravy/PetsDocumentController.m
@@ -9,6 +9,8 @@
#import "PetsDocumentController.h"
#import "cocos2d.h"
#import "PetsAnimationLayer.h"
+#import "Pet.h"
+#import "GuestRoomView.h"
#define kPetAnimationView 2
@@ -23,21 +25,21 @@ @implementation PetsDocumentController
@synthesize window, animationView;
-@synthesize gameObjects, pets;
+@synthesize gameObjects, pets, baseResourcesURL;
-- (id)initWithGameObjects:(GameObjects *)aGameObjects {
+- (id)initWithGameObjects:(GameObjects *)aGameObjects rootResourcesFolder:(NSURL *)resourcesURL {
self = [super init];
if ( self ) {
[self setGameObjects:aGameObjects];
+ [self setBaseResourcesURL:resourcesURL];
+
[NSBundle loadNibNamed:@"Pets" owner:self];
[self prepareAnimationView];
-
-
}
return self;
@@ -45,7 +47,17 @@ - (id)initWithGameObjects:(GameObjects *)aGameObjects {
}
- (NSMutableArray *)pets {
- return [[self gameObjects] pets];
+
+ NSMutableArray *guestRoomViews = [NSMutableArray array];
+
+ for (Pet *pet in [gameObjects pets]) {
+ GuestRoomView *guestRoomView = [[GuestRoomView alloc] initWithPet:pet rootResourcesFolder:[self baseResourcesURL]];
+ [guestRoomView imageIcon];
+ [guestRoomViews addObject:guestRoomView];
+ }
+
+ return guestRoomViews;
+// return [[self gameObjects] pets];
}
- (void)prepareAnimationView {
Please sign in to comment.
Something went wrong with that request. Please try again.