This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Part of a category on NSString... | |
- (CGSize)sizeWithFontName:(NSString*)fontName ofSize:(float)size constrainedTo:(CGSize)constraint { | |
#ifdef __CC_PLATFORM_MAC | |
NSFont *font = [NSFont fontWithName:fontName size:size]; | |
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:self]; | |
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithContainerSize:constraint]; | |
; | |
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const CGFloat kPerspectiveAngle = 3;//3 degree rotation | |
#define PERSPECTIVE_CONSTRICT_PX_FOR_HEIGHT(h) roundf(tanf(kPerspectiveAngle / 180.f * M_PI)*h) | |
- (void)drawTerrainPolygon { | |
static const int bottom = 23; // The padding at the bottom of the screen | |
int constrict = PERSPECTIVE_CONSTRICT_PX_FOR_HEIGHT(self.contentSize.height);//Determine how many pixels to contract by | |
CGPoint pts[] = { ccp(0,bottom), | |
ccp(constrict,self.contentSize.height), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface AMSprite () | |
@property (nonatomic, strong) CCSprite *shadowSprite; | |
@end | |
@implementation AMSprite | |
- (void)addShadow { | |
if(self.shadowSprite) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation AMLayer | |
- (void)visit { | |
CGRect mask = self.maskArea; | |
BOOL shouldMask = !CGSizeEqualToSize(mask.size, CGSizeZero); | |
if(shouldMask) { | |
CGFloat s = CC_CONTENT_SCALE_FACTOR(); | |
CGPoint origin = CGPointMake(mask.origin.x*s, mask.origin.y*s); | |
CGSize size = CGSizeMake(mask.size.width*s, mask.size.height*s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MySprite | |
// The internal rect representing the current texture | |
- (CGRect)hitArea { | |
CGPoint bl = CGPointMake(MIN(_quad.tl.vertices.x, _quad.bl.vertices.x), MIN(_quad.bl.vertices.y, _quad.br.vertices.y)); | |
CGPoint tr = CGPointMake(MAX(_quad.tr.vertices.x, _quad.br.vertices.x), MAX(_quad.tl.vertices.y, _quad.tr.vertices.y)); | |
return CGRectMake(bl.x, bl.y, tr.x - bl.x, tr.y - bl.y); | |
} | |
// Works just like .boundingBox (eg, represents the hitArea in parent coordinates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
BBInputTableViewCell *cell = (BBInputTableViewCell *)[tableView dequeueCellOfClass:[BBInputTableViewCell class]]; | |
cell.backgroundStyle = BBTableViewCellBackgroundStyleCard; | |
cell.backgroundColor = [UIColor clearColor]; | |
cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
BBInputTableViewCellAttributes *attributes = [[BBInputTableViewCellAttributes alloc] init]; | |
switch (indexPath.row) { | |
case BBDebugToolVagrant: { | |
[attributes setSwitchPrompt:@"Vagrant?" isOn:NO handlerBlock:^(id sender, BBInputTableViewCellAttributes *attributes, id value, id arguments) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "#social_connections" do | |
before do | |
# Social connections are cached within the model. To prevent cross-talk | |
# between the tests, make sure to clear out Rails' cache. | |
Rails.cache.clear | |
@target_user = FactoryGirl.create(:user) | |
@current_user = FactoryGirl.create(:user) | |
FactoryGirl.create(:relationship, :user => @current_user, :friend => @target_user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "#social_connections" do | |
before :each do | |
@target_user = FactoryGirl.create(:user) | |
@target_user_listing = FactoryGirl.create(:listing, :user => @target_user) | |
@current_user = FactoryGirl.create(:user) | |
@relationship = FactoryGirl.create(:relationship, :user => @current_user, :friend => @target_user) | |
@params = {:id => @target_user.id, :api_version => 'v1'} | |
end | |
context 'when logged in as a befriended user' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(self.socialConnections.count == 0) { | |
return @"EMPTY STATE...";// TODO: ZC What does the empty state look like? | |
} | |
else if(self.socialConnections.count == 1) { | |
return connection.caption; | |
} | |
else if(self.socialConnections.count == 2) { | |
BBSocialConnection *otherConnection = self.socialConnections[1]; | |
return [NSString stringWithFormat:BBLocalizedString(@"mobile.all.connections_single", @"%@ and %@ are connected to %@", @"Viewing a user profile: people are connected through facebook friends, etc."),connection.targetUser.shortName,otherConnection.targetUser.shortName,self.user.shortName]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connections_objects = connections.each {|sc| sc.populate(:context => SocialConnection::CONTEXT_USER)}; | |
connections_json = connections_objects.map{|sc| sc.as_json }; | |
connections_json = connections_json.each{|sc| sc['test'] = 'one' }; | |
render :json => {:connections_count => connections.count, :connections => connections_json} |
OlderNewer