1
0
mirror of https://github.com/thes3m/XNI synced 2024-12-26 13:26:06 +01:00

Fixed bug where Event would crash if delegate was removed during event raise.

Added Contains method to GameComponentCollection.
Added Support for drawing triangle fans.
Added gitignore.
This commit is contained in:
Samo Pajk 2013-06-22 11:41:56 +02:00
parent 8819987253
commit c32f654678
7 changed files with 24 additions and 2 deletions

BIN
Classes/.DS_Store vendored

Binary file not shown.

View File

@ -25,5 +25,6 @@
- (void) addComponent:(id<IGameComponent>)component; - (void) addComponent:(id<IGameComponent>)component;
- (void) removeComponent:(id<IGameComponent>)component; - (void) removeComponent:(id<IGameComponent>)component;
- (BOOL) contains:(id<IGameComponent>)component;
@end @end

View File

@ -33,6 +33,9 @@
} }
- (void) addComponent:(id<IGameComponent>)component { - (void) addComponent:(id<IGameComponent>)component {
if ([components containsObject:component]) {
NSLog(@"WARNING: Game component added twice:%@", component);
}
[components addObject:component]; [components addObject:component];
[componentAdded raiseWithSender:self [componentAdded raiseWithSender:self
eventArgs:[GameComponentCollectionEventArgs eventArgs:[GameComponentCollectionEventArgs
@ -46,6 +49,10 @@
eventArgsWithGameComponent:component]]; eventArgsWithGameComponent:component]];
} }
- (BOOL) contains:(id<IGameComponent>)component{
return [components containsObject:component];
}
- (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state - (NSUInteger) countByEnumeratingWithState:(NSFastEnumerationState *)state
objects:(id *)stackbuf objects:(id *)stackbuf
count:(NSUInteger)len { count:(NSUInteger)len {

View File

@ -58,7 +58,7 @@ static Guide *instance = nil;
return [instance beginShowMessageBoxWithTitle:title text:text buttons:buttons focusButton:focusButton icon:icon callback:callback state:state]; return [instance beginShowMessageBoxWithTitle:title text:text buttons:buttons focusButton:focusButton icon:icon callback:callback state:state];
} }
+ (NSNumber *) endShowMessageBox:(id <IAsyncResult>)result { + (NSNumber*) endShowMessageBox:(id <IAsyncResult>)result {
return [instance endShowMessageBox:result]; return [instance endShowMessageBox:result];
} }

View File

@ -193,6 +193,8 @@
+ (int) getNumberOfVerticesForPrimitiveType:(PrimitiveType)primitiveType primitiveCount:(int)primitiveCount { + (int) getNumberOfVerticesForPrimitiveType:(PrimitiveType)primitiveType primitiveCount:(int)primitiveCount {
switch (primitiveType) { switch (primitiveType) {
case GL_TRIANGLE_FAN:
return primitiveCount;
case PrimitiveTypeLineStrip: case PrimitiveTypeLineStrip:
return primitiveCount + 1; return primitiveCount + 1;
case PrimitiveTypeLineList: case PrimitiveTypeLineList:
@ -586,6 +588,7 @@
// CHECK FRAME BUFFER STATUS HERE // CHECK FRAME BUFFER STATUS HERE
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER); GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER);
if(status != GL_FRAMEBUFFER_COMPLETE){ if(status != GL_FRAMEBUFFER_COMPLETE){
NSLog(@"Error binding renderTarget"); NSLog(@"Error binding renderTarget");
} }

View File

@ -10,11 +10,18 @@
#import "System.h" #import "System.h"
@interface Event (){
NSMutableArray *tempEvents;
}
@end
@implementation Event @implementation Event
- (id) init { - (id) init {
if (self = [super init]) { if (self = [super init]) {
delegates = [[NSMutableArray alloc] init]; delegates = [[NSMutableArray alloc] init];
tempEvents = [[NSMutableArray alloc] init];
} }
return self; return self;
} }
@ -33,13 +40,16 @@
} }
- (void) raiseWithSender:(id)sender eventArgs:(EventArgs*)e { - (void) raiseWithSender:(id)sender eventArgs:(EventArgs*)e {
for (Delegate *delegate in delegates) { [tempEvents addObjectsFromArray:delegates];
for (Delegate *delegate in tempEvents) {
[delegate invokeWithArgument:sender argument:e]; [delegate invokeWithArgument:sender argument:e];
} }
[tempEvents removeAllObjects];
} }
- (void) dealloc { - (void) dealloc {
[delegates release]; [delegates release];
[tempEvents release];
[super dealloc]; [super dealloc];
} }

1
gitignore Normal file
View File

@ -0,0 +1 @@
.DS_Store