mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
NSCoding support added to data classes.
git-svn-id: http://xni.googlecode.com/svn/XNI@120 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
72b6b40a2a
commit
08abf7ffe0
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Color : NSObject <NSCopying> {
|
||||
@interface Color : NSObject <NSCopying, NSCoding> {
|
||||
uint packedValue;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,18 @@
|
||||
return [self initWithRed:color.r green:color.g blue:color.b alpha:color.a];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
if (self = [super init]) {
|
||||
packedValue = [aDecoder decodeIntForKey:@"packedValue"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeInt:packedValue forKey:@"packedValue"];
|
||||
}
|
||||
|
||||
|
||||
+ (Color*) colorWithRed:(int)red green:(int)green blue:(int)blue alpha:(int)alpha {
|
||||
return [[[Color alloc] initWithRed:red green:green blue:blue alpha:alpha] autorelease];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Vector4 : NSObject <NSCopying> {
|
||||
@interface Vector4 : NSObject <NSCopying, NSCoding> {
|
||||
Vector4Struct data;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,20 @@
|
||||
return [self initWithVector4Struct:vector.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithX:[aDecoder decodeFloatForKey:@"x"]
|
||||
y:[aDecoder decodeFloatForKey:@"y"]
|
||||
z:[aDecoder decodeFloatForKey:@"z"]
|
||||
w:[aDecoder decodeFloatForKey:@"w"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeFloat:data.x forKey:@"x"];
|
||||
[aCoder encodeFloat:data.y forKey:@"y"];
|
||||
[aCoder encodeFloat:data.z forKey:@"z"];
|
||||
[aCoder encodeFloat:data.w forKey:@"w"];
|
||||
}
|
||||
|
||||
+ (Vector4*) vectorWithX:(float)x y:(float)y z:(float)z w:(float)w {
|
||||
return [[[Vector4 alloc] initWithX:x y:y z:z w:w] autorelease];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Matrix : NSObject <NSCopying> {
|
||||
@interface Matrix : NSObject <NSCopying, NSCoding> {
|
||||
MatrixStruct data;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,25 @@
|
||||
return [self initWithMatrixStruct:matrix.data];
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
float *values = &data.m11;
|
||||
for (int i=0; i<16; i++) {
|
||||
values[i] = [aDecoder decodeFloatForKey:[NSString stringWithFormat:@"%i", i]];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
float *values = &data.m11;
|
||||
for (int i=0; i<16; i++) {
|
||||
[aCoder encodeFloat:values[i] forKey:[NSString stringWithFormat:@"%i", i]];
|
||||
}
|
||||
}
|
||||
|
||||
+ (Matrix*) matrixWithStruct: (MatrixStruct*)matrixStruct {
|
||||
return [[[Matrix alloc] initWithMatrixStruct:matrixStruct] autorelease];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Quaternion : NSObject <NSCopying> {
|
||||
@interface Quaternion : NSObject <NSCopying, NSCoding> {
|
||||
Vector4Struct data;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,20 @@
|
||||
return [self initWithVector4Struct:quaternion.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithX:[aDecoder decodeFloatForKey:@"x"]
|
||||
y:[aDecoder decodeFloatForKey:@"y"]
|
||||
z:[aDecoder decodeFloatForKey:@"z"]
|
||||
w:[aDecoder decodeFloatForKey:@"w"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeFloat:data.x forKey:@"x"];
|
||||
[aCoder encodeFloat:data.y forKey:@"y"];
|
||||
[aCoder encodeFloat:data.z forKey:@"z"];
|
||||
[aCoder encodeFloat:data.w forKey:@"w"];
|
||||
}
|
||||
|
||||
+ (Quaternion*) quaternionWithX:(float)x y:(float)y z:(float)z w:(float)w {
|
||||
return [[[Quaternion alloc] initWithX:x y:y z:z w:w] autorelease];
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Rectangle : NSObject <NSCopying> {
|
||||
@interface Rectangle : NSObject <NSCopying, NSCoding> {
|
||||
RectangleStruct data;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,20 @@
|
||||
return [self initWithRectangleStruct:rectangle.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithX:[aDecoder decodeIntForKey:@"x"]
|
||||
y:[aDecoder decodeIntForKey:@"y"]
|
||||
width:[aDecoder decodeIntForKey:@"width"]
|
||||
height:[aDecoder decodeIntForKey:@"height"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeInt:data.x forKey:@"x"];
|
||||
[aCoder encodeInt:data.y forKey:@"y"];
|
||||
[aCoder encodeInt:data.width forKey:@"width"];
|
||||
[aCoder encodeInt:data.height forKey:@"height"];
|
||||
}
|
||||
|
||||
+ (Rectangle*) rectangleWithX:(int)x y:(int)y width:(int)width height:(int)height {
|
||||
return [[[Rectangle alloc] initWithX:x y:y width:width height:height] autorelease];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Vector2 : NSObject <NSCopying> {
|
||||
@interface Vector2 : NSObject <NSCopying, NSCoding> {
|
||||
Vector2Struct data;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,15 @@
|
||||
return [self initWithVector2Struct:vector.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithX:[aDecoder decodeFloatForKey:@"x"] y:[aDecoder decodeFloatForKey:@"y"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeFloat:data.x forKey:@"x"];
|
||||
[aCoder encodeFloat:data.y forKey:@"y"];
|
||||
}
|
||||
|
||||
+ (Vector2*) vectorWithX:(float)x y:(float)y{
|
||||
return [[[Vector2 alloc] initWithX:x y:y] autorelease];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface Vector3 : NSObject <NSCopying> {
|
||||
@interface Vector3 : NSObject <NSCopying, NSCoding> {
|
||||
Vector3Struct data;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,18 @@
|
||||
return [self initWithVector3Struct:vector.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithX:[aDecoder decodeFloatForKey:@"x"]
|
||||
y:[aDecoder decodeFloatForKey:@"y"]
|
||||
z:[aDecoder decodeFloatForKey:@"z"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeFloat:data.x forKey:@"x"];
|
||||
[aCoder encodeFloat:data.y forKey:@"y"];
|
||||
[aCoder encodeFloat:data.z forKey:@"z"];
|
||||
}
|
||||
|
||||
+ (Vector3*) vectorWithX:(float)x y:(float)y z:(float)z {
|
||||
return [[[Vector3 alloc] initWithX:x y:y z:z] autorelease];
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#import "Retronator.Xni.Framework.classes.h"
|
||||
|
||||
@interface XniPoint : NSObject <NSCopying> {
|
||||
@interface XniPoint : NSObject <NSCopying, NSCoding> {
|
||||
PointStruct data;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,15 @@
|
||||
return [self initWithPointStruct:point.data];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
return [self initWithIntX:[aDecoder decodeIntForKey:@"x"] y:[aDecoder decodeIntForKey:@"y"]];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[aCoder encodeInt:data.x forKey:@"x"];
|
||||
[aCoder encodeInt:data.y forKey:@"y"];
|
||||
}
|
||||
|
||||
+ (XniPoint*) pointWithX:(int)x y:(int)y {
|
||||
return [[[XniPoint alloc] initWithIntX:x y:y] autorelease];
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0440"
|
||||
LastUpgradeVersion = "0450"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0440"
|
||||
LastUpgradeVersion = "0450"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
Loading…
x
Reference in New Issue
Block a user