// // TutorialBubble.m // Cart Collect // // Created by Starla Insigna on 8/4/11. // Copyright 2011 Four Island. All rights reserved. // #import "TutorialBubble.h" @implementation TutorialBubble @synthesize name; - (id)initWithText:(NSString*)text name:(NSString*)m_name { self = [super init]; textView = [[UILabel alloc] init]; textView.text = text; textView.font = [UIFont systemFontOfSize:14.0f]; CGSize size = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(200, 300) lineBreakMode:UILineBreakModeWordWrap]; textView.lineBreakMode = UILineBreakModeWordWrap; textView.numberOfLines = 0; textView.frame = CGRectMake(8, 8, size.width, size.height); button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage]; CGImageRef topLeftRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 0, 8, 8)); CGImageRef topRightRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 0, 8, 8)); CGImageRef bottomLeftRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 8, 8, 8)); CGImageRef bottomRightRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 8, 8, 8)); CGImageRef topBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 16, 8, 8)); CGImageRef leftBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 16, 8, 8)); CGImageRef rightBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 24, 8, 8)); CGImageRef bottomBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 24, 8, 8)); UIImage* topLeft = [UIImage imageWithCGImage:topLeftRef]; UIImage* topRight = [UIImage imageWithCGImage:topRightRef]; UIImage* bottomLeft = [UIImage imageWithCGImage:bottomLeftRef]; UIImage* bottomRight = [UIImage imageWithCGImage:bottomRightRef]; UIImage* topBorder = [UIImage imageWithCGImage:topBorderRef]; UIImage* leftBorder = [UIImage imageWithCGImage:leftBorderRef]; UIImage* rightBorder = [UIImage imageWithCGImage:rightBorderRef]; UIImage* bottomBorder = [UIImage imageWithCGImage:bottomBorderRef]; CGImageRelease(topLeftRef); CGImageRelease(topRightRef); CGImageRelease(bottomLeftRef); CGImageRelease(bottomRightRef); CGImageRelease(topBorderRef); CGImageRelease(leftBorderRef); CGImageRelease(rightBorderRef); CGImageRelease(bottomBorderRef); CGSize boxSize = CGSizeMake(size.width, size.height); UIGraphicsBeginImageContext(CGSizeMake(boxSize.width+16, boxSize.height+16)); CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); [topLeft drawInRect:CGRectMake(0, 0, 8, 8)]; [topBorder drawInRect:CGRectMake(8, 0, boxSize.width, 8)]; [topRight drawInRect:CGRectMake(8+boxSize.width, 0, 8, 8)]; [rightBorder drawInRect:CGRectMake(8+boxSize.width, 8, 8, boxSize.height)]; [bottomRight drawInRect:CGRectMake(8+boxSize.width, 8+boxSize.height, 8, 8)]; [bottomBorder drawInRect:CGRectMake(8, 8+boxSize.height, boxSize.width, 8)]; [bottomLeft drawInRect:CGRectMake(0, 8+boxSize.height, 8, 8)]; [leftBorder drawInRect:CGRectMake(0, 8, 8, boxSize.height)]; CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); CGContextFillRect(context, CGRectMake(8, 8, boxSize.width, boxSize.height)); UIGraphicsPopContext(); background = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageView = [[UIImageView alloc] initWithImage:background]; [imageView setFrame:CGRectMake(0, 0, boxSize.width+16, boxSize.height+16)]; [button addSubview:imageView]; [button addSubview:textView]; button.frame = CGRectMake(0, 0, boxSize.width+16, boxSize.height+16); [self addSubview:button]; self.frame = CGRectMake(240-(boxSize.width+16)/2, 160-(boxSize.height+16)/2, boxSize.width+16, boxSize.height+16); name = [m_name retain]; return self; } - (id)initWithText:(NSString*)text name:(NSString*)m_name spriteReference:(CCSprite*)spriteReference { self = [self initWithText:text name:m_name]; button.frame = CGRectMake(8, 8, button.frame.size.width, button.frame.size.height); self.frame = CGRectMake(0, 0, button.frame.size.width+16, button.frame.size.height+16); CGRect spriteBounds = CGRectMake(spriteReference.position.x-spriteReference.contentSize.width/2, 320-spriteReference.position.y-spriteReference.contentSize.height/2, spriteReference.contentSize.width*spriteReference.scale, spriteReference.contentSize.height*spriteReference.scale); CGPoint boxLoc; CGPoint arrowLoc; int arrowRotation; if (spriteBounds.origin.y > self.frame.size.height) { arrowRotation = 0; if (CGRectGetMidX(spriteBounds) < button.frame.size.width) { boxLoc = CGPointMake(0, spriteBounds.origin.y-self.frame.size.height - 8); arrowLoc = CGPointMake(spriteBounds.ori
doors {
  name: "K Panels"
  type: EVENT
  # TODO: This is a complete_at in the base game, but in normal progression you
  # are forced to solve these specific panels. We should mod the game such that
  # they are required even with non-standard progression.
  panels { room: "Main Area" name: "TIN (1)" }
  panels { room: "Main Area" name: "TIN (2)" }
  panels { room: "Main Area" name: "NO (1)" }
  panels { room: "Main Area" name: "I (1)" }
}
doors {
  name: "Near Right Door"
  type: EVENT
  panels { room: "Main Area" name: "TIN (1)" }
}
doors {
  name: "Near Left Door"
  type: EVENT
  panels { room: "Main Area" name: "TIN (2)" }
}
doors {
  name: "Far Right Door"
  type: EVENT
  panels { room: "Main Area" name: "I (1)" }
}
doors {
  name: "Far Left Door"
  type: EVENT
  panels { room: "Main Area" name: "NO (1)" }
}
doors {
  name: "All Panels"
  type: LOCATION_ONLY
  panels { room: "Main Area" name: "TIN (1)" }
  panels { room: "Main Area" name: "TIN (2)" }
  panels { room: "Main Area" name: "TIN (3)" }
  panels { room: "Main Area" name: "TIN (4)" }
  panels { room: "Main Area" name: "TIN (5)" }
  panels { room: "Main Area" name: "NO (1)" }
  panels { room: "Main Area" name: "NO (2)" }
  panels { room: "Main Area" name: "I (1)" }
  panels { room: "Main Area" name: "I (2)" }
  location_room: "Main Area"
}