-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[spritekit] Update for Xcode 9 beta 1, 2 & 3 #2331
Changes from 4 commits
7295a4a
1af8b71
07df2b2
3e4679b
19ae06f
e0085f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,17 @@ | |
using XamCore.CoreGraphics; | ||
using XamCore.CoreVideo; | ||
using XamCore.SceneKit; | ||
#if !WATCH | ||
using XamCore.Metal; | ||
#endif | ||
|
||
using Vector2 = global::OpenTK.Vector2; | ||
using Vector3 = global::OpenTK.Vector3; | ||
using Matrix2 = global::OpenTK.Matrix2; | ||
using Matrix3 = global::OpenTK.Matrix3; | ||
using Matrix4 = global::OpenTK.Matrix4; | ||
using Vector4 = global::OpenTK.Vector4; | ||
using Quaternion = global::OpenTK.Quaternion; | ||
|
||
#if MONOMAC | ||
using XamCore.AppKit; | ||
|
@@ -37,6 +41,7 @@ | |
using pfloat = System.nfloat; | ||
#else | ||
using XamCore.UIKit; | ||
using NSLineBreakMode = global::XamCore.UIKit.UILineBreakMode; | ||
using pfloat = System.Single; | ||
#if !WATCH | ||
using UIView = global::XamCore.UIKit.UIView; | ||
|
@@ -51,6 +56,11 @@ interface AVPlayer {} | |
interface CIFilter {} | ||
interface GKPolygonObstacle {} | ||
interface UIView {} | ||
interface IMTLCommandBuffer {} | ||
interface IMTLCommandQueue {} | ||
interface IMTLDevice {} | ||
interface IMTLRenderCommandEncoder {} | ||
interface MTLRenderPassDescriptor {} | ||
#endif | ||
|
||
delegate void SKNodeChildEnumeratorHandler (SKNode node, out bool stop); | ||
|
@@ -166,6 +176,12 @@ partial interface SKNode : NSCoding, NSCopying { | |
[Export ("userInteractionEnabled")] | ||
bool UserInteractionEnabled { [Bind ("isUserInteractionEnabled")] get; set; } | ||
|
||
[NoWatch] | ||
[NoMac] | ||
[TV (11,0), iOS (11,0)] | ||
[Export ("focusBehavior", ArgumentSemantic.Assign)] | ||
SKNodeFocusBehavior FocusBehavior { get; set; } | ||
|
||
[Export ("parent")] | ||
SKNode Parent { get; } | ||
|
||
|
@@ -1182,19 +1198,40 @@ partial interface SKLabelNode { | |
[Static, Export ("labelNodeWithText:")] | ||
SKLabelNode FromText ([NullAllowed] string text); | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[Static] | ||
[Export ("labelNodeWithAttributedText:")] | ||
SKLabelNode FromText ([NullAllowed] NSAttributedString attributedText); | ||
|
||
[Export ("verticalAlignmentMode")] | ||
SKLabelVerticalAlignmentMode VerticalAlignmentMode { get; set; } | ||
|
||
[Export ("horizontalAlignmentMode")] | ||
SKLabelHorizontalAlignmentMode HorizontalAlignmentMode { get; set; } | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[Export ("numberOfLines")] | ||
nint NumberOfLines { get; set; } | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[Export ("lineBreakMode", ArgumentSemantic.Assign)] | ||
NSLineBreakMode LineBreakMode { get; set; } | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[Export ("preferredMaxLayoutWidth")] | ||
nfloat PreferredMaxLayoutWidth { get; set; } | ||
|
||
[Export ("fontName", ArgumentSemantic.Copy)] | ||
string FontName { get; set; } | ||
|
||
[Export ("text", ArgumentSemantic.Copy)] | ||
[NullAllowed] // nullable in Xcode7 headers and caught by introspection tests | ||
string Text { get; set; } | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[NullAllowed, Export ("attributedText", ArgumentSemantic.Copy)] | ||
NSAttributedString AttributedText { get; set; } | ||
|
||
[Export ("fontSize")] | ||
nfloat FontSize { get; set; } | ||
|
||
|
@@ -3223,5 +3260,80 @@ interface SKWarpGeometryGrid : NSCoding | |
[Export ("gridByReplacingDestPositions:")] | ||
SKWarpGeometryGrid _GridByReplacingDestPositions (IntPtr destPositions); | ||
} | ||
|
||
// SKRenderer is not available for WatchKit apps and the iOS simulator | ||
[NoWatch] | ||
[TV (11,0), Mac (10,13), iOS (11,0)] | ||
[BaseType (typeof(NSObject))] | ||
[DisableDefaultCtor] | ||
interface SKRenderer | ||
{ | ||
[Static] | ||
[Export ("rendererWithDevice:")] | ||
[return: NullAllowed] | ||
SKRenderer FromDevice ([NullAllowed] IMTLDevice device); | ||
|
||
[Export ("renderWithViewport:commandBuffer:renderPassDescriptor:")] | ||
void Render (CGRect viewport, IMTLCommandBuffer commandBuffer, MTLRenderPassDescriptor renderPassDescriptor); | ||
|
||
[Export ("renderWithViewport:renderCommandEncoder:renderPassDescriptor:commandQueue:")] | ||
void Render (CGRect viewport, IMTLRenderCommandEncoder renderCommandEncoder, MTLRenderPassDescriptor renderPassDescriptor, IMTLCommandQueue commandQueue); | ||
|
||
[Export ("updateAtTime:")] | ||
void Update (double currentTime); | ||
|
||
[NullAllowed, Export ("scene", ArgumentSemantic.Assign)] | ||
SKScene Scene { get; set; } | ||
|
||
[Export ("ignoresSiblingOrder")] | ||
bool IgnoresSiblingOrder { get; set; } | ||
|
||
[Export ("shouldCullNonVisibleNodes")] | ||
bool ShouldCullNonVisibleNodes { get; set; } | ||
|
||
[Export ("showsDrawCount")] | ||
bool ShowsDrawCount { get; set; } | ||
|
||
[Export ("showsNodeCount")] | ||
bool ShowsNodeCount { get; set; } | ||
|
||
[Export ("showsQuadCount")] | ||
bool ShowsQuadCount { get; set; } | ||
|
||
[Export ("showsPhysics")] | ||
bool ShowsPhysics { get; set; } | ||
|
||
[Export ("showsFields")] | ||
bool ShowsFields { get; set; } | ||
} | ||
|
||
[TV (11,0), Watch (4,0), Mac (13,0), iOS (11,0)] | ||
[BaseType (typeof(SKNode))] | ||
interface SKTransformNode | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Brace should be on the above line |
||
[Export ("xRotation")] | ||
nfloat XRotation { get; set; } | ||
|
||
[Export ("yRotation")] | ||
nfloat YRotation { get; set; } | ||
|
||
[Export ("eulerAngles")] | ||
Vector3 EulerAngles { | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; | ||
} | ||
|
||
[Export ("rotationMatrix")] | ||
Matrix3 RotationMatrix { | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; | ||
} | ||
|
||
[Export ("quaternion")] | ||
Quaternion Quaternion { | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] get; | ||
[MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] set; | ||
} | ||
} | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
| ||
using System; | ||
#if XAMCORE_2_0 | ||
using Foundation; | ||
#if !MONOMAC | ||
using UIKit; | ||
#endif | ||
using SpriteKit; | ||
using ObjCRuntime; | ||
#else | ||
using MonoTouch.Foundation; | ||
using MonoTouch.SpriteKit; | ||
using MonoTouch.UIKit; | ||
using MonoTouch.ObjCRuntime; | ||
#endif | ||
using OpenTK; | ||
using NUnit.Framework; | ||
|
||
namespace MonoTouchFixtures.SpriteKit { | ||
|
||
[TestFixture] | ||
[Preserve (AllMembers = true)] | ||
public class SKTransformNodeTest { | ||
[SetUp] | ||
public void VersionCheck () | ||
{ | ||
TestRuntime.AssertXcodeVersion (9, 0); | ||
} | ||
|
||
[Test] | ||
public void EulerAngles () | ||
{ | ||
Vector3 V3; | ||
|
||
using (var obj = new SKTransformNode ()) { | ||
Asserts.AreEqual (Vector3.Zero, obj.EulerAngles, "1 EulerAngles"); | ||
V3 = new Vector3 (1, 2, 3); | ||
obj.EulerAngles = V3; | ||
// The values bellow match what the same code in Swift returns. | ||
Assert.AreEqual (-2.14159298f, obj.EulerAngles.X, "#x1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're setting a vector of [1,2,3] and getting something back that looks like random numbers. Are you sure the test isn't finding a bug somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same values as native Swift example. |
||
Assert.AreEqual (1.14159274f, obj.EulerAngles.Y, "#y1"); | ||
Assert.AreEqual (-0.141592711f, obj.EulerAngles.Z, "#z1"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void RotationMatrix () | ||
{ | ||
using (var obj = new SKTransformNode ()) { | ||
obj.RotationMatrix = Matrix3.Zero; | ||
// In Swift, a rotated zero matrice also becomes the identity matrice. | ||
Asserts.AreEqual (Matrix3.Identity, obj.RotationMatrix, "RotationMatrix"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also: setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested with Xcode already (found that weird too), same behavior. I'll add a comment that it does the same thing with native code. |
||
} | ||
} | ||
|
||
[Test] | ||
public void QuaternionTest () | ||
{ | ||
Quaternion Q; | ||
|
||
using (var obj = new SKTransformNode ()) { | ||
Asserts.AreEqual (Quaternion.Identity, obj.Quaternion, "1 Quaternion"); | ||
Q = new Quaternion (new Vector3 (1, 2, 3), 4); | ||
obj.Quaternion = Q; | ||
Asserts.AreEqual (Q, obj.Quaternion, "2 Quaternion"); | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Brace should be on the above line