PageRenderTime 74ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/JSIL.Libraries/Sources/XNA/XNA4.js

http://github.com/kevingadd/JSIL
JavaScript | 3180 lines | 2595 code | 526 blank | 59 comment | 171 complexity | 449cee29e54618d38134834d77f8481c MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. "use strict";
  2. if (typeof (JSIL) === "undefined") throw new Error("JSIL.Core required");
  3. var $drawDebugRects = false, $drawDebugBoxes = false;
  4. var $useTextCaching = true, $textCachingSupported = true;
  5. var $jsilxna = JSIL.DeclareAssembly("JSIL.XNA");
  6. JSIL.DeclareNamespace("JSIL");
  7. $jsilxna.allowWebGL = true;
  8. $jsilxna.testedWebGL = false;
  9. $jsilxna.workingWebGL = false;
  10. var $xnaasms = new JSIL.AssemblyCollection({
  11. corlib: "mscorlib",
  12. xna: "Microsoft.Xna.Framework",
  13. xnaGraphics: "Microsoft.Xna.Framework.Graphics",
  14. xnaGame: "Microsoft.Xna.Framework.Game",
  15. xnaStorage: "Microsoft.Xna.Framework.Storage",
  16. 0: "Microsoft.Xna.Framework",
  17. 1: "Microsoft.Xna.Framework.Game",
  18. 2: "Microsoft.Xna.Framework.GamerServices",
  19. 4: "Microsoft.Xna.Framework.Input.Touch, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553",
  20. 5: "mscorlib",
  21. 11: "System.Drawing",
  22. 15: "System.Windows.Forms",
  23. 18: "Microsoft.Xna.Framework.Xact",
  24. });
  25. var getXnaGraphics = function () {
  26. return $xnaasms.xnaGraphics || $xnaasms.xna;
  27. };
  28. var getXnaStorage = function () {
  29. return $xnaasms.xnaStorage || $xnaasms.xna;
  30. };
  31. $jsilxna.colorRef = function () {
  32. var graphicsAsm = JSIL.GetAssembly("Microsoft.Xna.Framework.Graphics", true);
  33. if (graphicsAsm !== null)
  34. return $xnaasms.xna.TypeRef("Microsoft.Xna.Framework.Color");
  35. else
  36. return $xnaasms.xna.TypeRef("Microsoft.Xna.Framework.Graphics.Color");
  37. };
  38. $jsilxna.graphicsRef = function (name) {
  39. var graphicsAsm = JSIL.GetAssembly("Microsoft.Xna.Framework.Graphics", true);
  40. if (graphicsAsm !== null)
  41. return graphicsAsm.TypeRef(name);
  42. else
  43. return $xnaasms.xna.TypeRef(name);
  44. };
  45. JSIL.MakeClass($jsilcore.System.Object, "HTML5Asset", true, [], function ($) {
  46. $.RawMethod(false, ".ctor", function (assetName) {
  47. this.name = assetName;
  48. });
  49. $.RawMethod(false, "toString", function () {
  50. return "<XNA Asset '" + this.name + "'>";
  51. });
  52. });
  53. JSIL.MakeClass("HTML5Asset", "HTML5ImageAsset", true, [], function ($) {
  54. $.RawMethod(false, ".ctor", function (assetName, image) {
  55. HTML5Asset.prototype._ctor.call(this, assetName);
  56. image.assetName = assetName;
  57. this.image = image;
  58. });
  59. $.RawMethod(false, "ReadAsset",
  60. function HTML5ImageAsset_ReadAsset (type) {
  61. var tTexture = Microsoft.Xna.Framework.Graphics.Texture2D.__Type__;
  62. return JSIL.CreateInstanceOfType(tTexture, "$fromImage", [null, this.image]);
  63. }
  64. );
  65. });
  66. JSIL.MakeClass("HTML5Asset", "SoundAssetBase", true, [], function ($) {
  67. $.Method({Static:false, Public:true }, "Play",
  68. (new JSIL.MethodSignature($.Boolean, [], [])),
  69. function Play () {
  70. return this.Play(1, 0, 0);
  71. }
  72. );
  73. $.Method({Static:false, Public:true }, "Play",
  74. (new JSIL.MethodSignature($.Boolean, [$.Single, $.Single, $.Single], [])),
  75. function Play (volume, pitch, pan) {
  76. var instance = this.$newInstance();
  77. instance.set_volume(volume);
  78. instance.set_pan(pan);
  79. instance.set_pitch(pitch);
  80. instance.play();
  81. return true;
  82. }
  83. );
  84. $.Method({Static:false, Public:true }, "CreateInstance",
  85. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Audio.SoundEffectInstance"), [], [])),
  86. function CreateInstance () {
  87. return new Microsoft.Xna.Framework.Audio.SoundEffectInstance(this, false);
  88. }
  89. );
  90. });
  91. JSIL.MakeClass("SoundAssetBase", "CallbackSoundAsset", true, [], function ($) {
  92. $.RawMethod(false, ".ctor", function (assetName, createInstance) {
  93. HTML5Asset.prototype._ctor.call(this, assetName);
  94. this.$createInstance = createInstance;
  95. this.freeInstances = [];
  96. });
  97. $.RawMethod(false, "$newInstance", function () {
  98. if (this.freeInstances.length > 0) {
  99. return this.freeInstances.pop();
  100. } else {
  101. return this.$createInstance(0);
  102. }
  103. });
  104. });
  105. JSIL.MakeClass("HTML5Asset", "RawXNBAsset", true, [], function ($) {
  106. var $NewCr = function () {
  107. return ($NewCr = JSIL.Memoize(
  108. new JSIL.ConstructorSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Content.ContentReader"), [
  109. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Content.ContentManager"), $xnaasms[5].TypeRef("System.IO.Stream"),
  110. $.String, $xnaasms[5].TypeRef("System.Action`1", [$xnaasms[5].TypeRef("System.IDisposable")]),
  111. $.Int32
  112. ])
  113. )) ();
  114. };
  115. $.Method({
  116. Static: false,
  117. Public: true
  118. }, ".ctor", JSIL.MethodSignature.Void, function (assetName, rawBytes) {
  119. if (JSIL.GetAssembly("JSIL.IO", true) === null) {
  120. throw new Error("JSIL.IO is required");
  121. }
  122. HTML5Asset.prototype._ctor.call(this, assetName);
  123. this.bytes = rawBytes;
  124. this.contentManager = null;
  125. });
  126. $.Method({
  127. Static: false,
  128. Public: true
  129. }, "ReadAsset", JSIL.MethodSignature.Void, function RawXNBAsset_ReadAsset (type) {
  130. if (!type)
  131. throw new Error("ReadAsset must be provided a type object");
  132. var memoryStream = new System.IO.MemoryStream(this.bytes, false);
  133. var contentReader = $NewCr().Construct(
  134. this.contentManager, memoryStream, this.name, null, 0
  135. );
  136. contentReader.ReadHeader();
  137. var sharedResourceCount = contentReader.Read7BitEncodedInt();
  138. var sharedResources = new Array(sharedResourceCount);
  139. var mainObject = contentReader.ReadObject$b1(type)();
  140. for (var i = 0; i < sharedResourceCount; i++)
  141. sharedResources[i] = content.ReadObject$b1(System.Object)();
  142. return mainObject;
  143. });
  144. });
  145. JSIL.MakeClass("RawXNBAsset", "SpriteFontAsset", true, [], function ($) {
  146. $.Method({
  147. Static: false,
  148. Public: true
  149. }, ".ctor", JSIL.MethodSignature.Void, function (assetName, rawBytes) {
  150. RawXNBAsset.prototype._ctor.call(this, assetName, rawBytes);
  151. });
  152. });
  153. JSIL.MakeClass("RawXNBAsset", "Texture2DAsset", true, [], function ($) {
  154. $.Method({
  155. Static: false,
  156. Public: true
  157. }, ".ctor", JSIL.MethodSignature.Void, function (assetName, rawBytes) {
  158. RawXNBAsset.prototype._ctor.call(this, assetName, rawBytes);
  159. });
  160. });
  161. var vectorUtil = {
  162. makeOperatorCore: function (name, tVector, body, argCount, leftScalar, rightScalar) {
  163. var js = body.join("\r\n");
  164. var typeName = String(tVector.typeName);
  165. var suffixedName;
  166. if (argCount < 1) {
  167. suffixedName = name;
  168. } else {
  169. suffixedName = name + "[";
  170. if (argCount == 1) {
  171. suffixedName += (leftScalar ? "float" : "vec");
  172. } else if (argCount == 2) {
  173. suffixedName += (leftScalar ? "float" : "vec") + "," +
  174. (rightScalar ? "float" : "vec");
  175. }
  176. suffixedName += "]";
  177. }
  178. var functionName = typeName + "." + suffixedName;
  179. switch (argCount) {
  180. case 0:
  181. return JSIL.CreateNamedFunction(
  182. functionName,
  183. [],
  184. js
  185. );
  186. case 1:
  187. return JSIL.CreateNamedFunction(
  188. functionName,
  189. ["value"],
  190. js
  191. );
  192. case 2:
  193. return JSIL.CreateNamedFunction(
  194. functionName,
  195. ["lhs", "rhs"],
  196. js
  197. );
  198. case 3:
  199. return JSIL.CreateNamedFunction(
  200. functionName,
  201. ["lhs", "rhs", "amount"],
  202. js
  203. );
  204. default:
  205. throw new Error("Invalid argument count");
  206. }
  207. },
  208. bindToPrototype: function (fn, typeRef, dataMembers) {
  209. var state = {
  210. resolvedType: null,
  211. typeRef: typeRef
  212. };
  213. JSIL.SetLazyValueProperty(
  214. state, "$instance",
  215. function VectorMethod_GetCreator () {
  216. if (state.resolvedType === null)
  217. state.resolvedType = state.typeRef.get();
  218. var creatorBody = "";
  219. for (var i = 0; i < dataMembers.length; i++)
  220. creatorBody += "this." + dataMembers[i] + " = " + dataMembers[i] + ";\r\n";
  221. var creator = JSIL.CreateNamedFunction(state.resolvedType.__Type__.__FullName__, dataMembers, creatorBody, null);
  222. creator.prototype = state.resolvedType.prototype;
  223. return creator;
  224. }
  225. );
  226. return fn.bind(state);
  227. },
  228. makeArithmeticOperator: function ($, name, staticMethodName, operator, dataMembers, tLeft, tRight, tResult) {
  229. var leftScalar = (tLeft !== tResult);
  230. var rightScalar = (tRight !== tResult);
  231. if (leftScalar && rightScalar)
  232. throw new Error("Invalid type combination");
  233. var body = [];
  234. body.push("return new this.$instance(");
  235. for (var i = 0; i < dataMembers.length; i++) {
  236. var dataMember = dataMembers[i];
  237. var line = "+(";
  238. if (leftScalar)
  239. line += "lhs ";
  240. else
  241. line += "lhs." + dataMember + " ";
  242. line += operator;
  243. if (rightScalar)
  244. line += " rhs";
  245. else
  246. line += " rhs." + dataMember + "";
  247. line += ")";
  248. if (i < (dataMembers.length - 1))
  249. line += ",";
  250. body.push(line);
  251. }
  252. body.push(");")
  253. var fn = vectorUtil.makeOperatorCore(name, tResult, body, 2, leftScalar, rightScalar);
  254. fn = vectorUtil.bindToPrototype(fn, tResult, dataMembers);
  255. $.Method({Static: true , Public: true }, name,
  256. new JSIL.MethodSignature(tResult, [tLeft, tRight], []),
  257. fn
  258. );
  259. $.Method({Static: true , Public: true }, staticMethodName,
  260. new JSIL.MethodSignature(tResult, [tLeft, tRight], []),
  261. fn
  262. );
  263. var makeRef = function (t) {
  264. return $jsilcore.TypeRef("JSIL.Reference", [t]);
  265. };
  266. var wrapper;
  267. if (leftScalar) {
  268. wrapper = function VectorOperator_Scalar_Ref (lhs, rhs, result) {
  269. result.set(fn(lhs, rhs.get()));
  270. }
  271. } else if (rightScalar) {
  272. wrapper = function VectorOperator_Ref_Scalar (lhs, rhs, result) {
  273. result.set(fn(lhs.get(), rhs));
  274. }
  275. } else {
  276. wrapper = function VectorOperator_Ref_Ref (lhs, rhs, result) {
  277. result.set(fn(lhs.get(), rhs.get()));
  278. }
  279. }
  280. $.Method({Static: true , Public: true }, staticMethodName,
  281. new JSIL.MethodSignature(null, [
  282. leftScalar ? tLeft : makeRef(tLeft),
  283. rightScalar ? tRight : makeRef(tRight),
  284. makeRef(tResult)
  285. ], []),
  286. wrapper
  287. );
  288. },
  289. makeLogicOperator: function ($, name, operator, bindingOperator, dataMembers, tVector) {
  290. var body = [];
  291. body.push("return (");
  292. for (var i = 0; i < dataMembers.length; i++) {
  293. var dataMember = dataMembers[i];
  294. var line = " (lhs." + dataMember + " ";
  295. line += operator;
  296. line += " rhs." + dataMember + ") ";
  297. if (i < dataMembers.length - 1)
  298. line += bindingOperator;
  299. body.push(line);
  300. }
  301. body.push(");")
  302. var fn = vectorUtil.makeOperatorCore(name, tVector, body, 2, false, false);
  303. $.Method({Static: true , Public: true }, name,
  304. new JSIL.MethodSignature($.Boolean, [tVector, tVector], []),
  305. fn
  306. );
  307. },
  308. makeNegationOperator: function ($, dataMembers, tVector) {
  309. var body = [];
  310. body.push("return new this.$instance(");
  311. for (var i = 0; i < dataMembers.length; i++) {
  312. var dataMember = dataMembers[i];
  313. var line = "-value." + dataMember;
  314. if (i < (dataMembers.length - 1))
  315. line += ",";
  316. body.push(line);
  317. }
  318. body.push(");");
  319. var fn = vectorUtil.makeOperatorCore("op_UnaryNegation", tVector, body, 1, false, false);
  320. fn = vectorUtil.bindToPrototype(fn, tVector, dataMembers);
  321. $.Method({Static: true , Public: true }, "op_UnaryNegation",
  322. new JSIL.MethodSignature(tVector, [tVector], []),
  323. fn
  324. );
  325. },
  326. makeLengthGetter: function ($, name, isSquared, dataMembers, tVector) {
  327. var body = [];
  328. body.push("return " + (isSquared ? "(" : "Math.sqrt("));
  329. for (var i = 0; i < dataMembers.length; i++) {
  330. var dataMember = dataMembers[i];
  331. var line = " (this." + dataMember + " * this." + dataMember + ")";
  332. if (i < dataMembers.length - 1)
  333. line += " + ";
  334. body.push(line);
  335. }
  336. body.push(");");
  337. var fn = vectorUtil.makeOperatorCore(name, tVector, body, 0);
  338. $.Method({Static: false, Public: true }, name,
  339. new JSIL.MethodSignature($.Single, [], []),
  340. fn
  341. );
  342. },
  343. makeDistanceFunction: function ($, name, isSquared, dataMembers, tVector) {
  344. var body = [];
  345. body.push("var result = +0.0, current;");
  346. for (var i = 0; i < dataMembers.length; i++) {
  347. var dataMember = dataMembers[i];
  348. body.push("current = +(rhs." + dataMember + " - lhs." + dataMember + ");");
  349. body.push("result += (current * current);");
  350. }
  351. if (isSquared)
  352. body.push("return result;");
  353. else
  354. body.push("return Math.sqrt(result);");
  355. var fn = vectorUtil.makeOperatorCore(name, tVector, body, 2);
  356. $.Method({Static: true, Public: true }, name,
  357. new JSIL.MethodSignature($.Single, [tVector, tVector], []),
  358. fn
  359. );
  360. },
  361. makeNormalizer: function ($, dataMembers, tVector) {
  362. var body = [];
  363. body.push("var factor = +1.0 / this.Length();");
  364. for (var i = 0; i < dataMembers.length; i++) {
  365. var dataMember = dataMembers[i];
  366. var line = "this." + dataMember + " *= factor;";
  367. body.push(line);
  368. }
  369. var fn = vectorUtil.makeOperatorCore("Normalize", tVector, body, 0);
  370. $.Method({Static: false, Public: true }, "Normalize",
  371. JSIL.MethodSignature.Void,
  372. fn
  373. );
  374. $.Method({Static: true , Public: true }, "Normalize",
  375. new JSIL.MethodSignature(tVector, [tVector], []),
  376. function Normalize_Static (v) {
  377. var result = v.MemberwiseClone();
  378. fn.call(result);
  379. return result;
  380. }
  381. );
  382. },
  383. makeLengthMethods: function ($, dataMembers, tVector) {
  384. vectorUtil.makeLengthGetter($, "LengthSquared", true, dataMembers, tVector);
  385. vectorUtil.makeLengthGetter($, "Length", false, dataMembers, tVector);
  386. vectorUtil.makeDistanceFunction($, "DistanceSquared", true, dataMembers, tVector);
  387. vectorUtil.makeDistanceFunction($, "Distance", false, dataMembers, tVector);
  388. vectorUtil.makeNormalizer($, dataMembers, tVector);
  389. },
  390. makeLerpMethod: function ($, dataMembers, tVector) {
  391. var name = "Lerp";
  392. var body = [];
  393. body.push("var result = lhs.MemberwiseClone();");
  394. for (var i = 0; i < dataMembers.length; i++) {
  395. var dataMember = dataMembers[i];
  396. body.push("result." + dataMember + " += (rhs." + dataMember + " - lhs." + dataMember + ") * amount;");
  397. }
  398. body.push("return result;");
  399. var fn = vectorUtil.makeOperatorCore(name, tVector, body, 3);
  400. $.Method({Static: true, Public: true }, name,
  401. new JSIL.MethodSignature(tVector, [tVector, tVector, $.Single], []),
  402. fn
  403. );
  404. },
  405. makeOperators: function ($, dataMembers, tVector) {
  406. var operators = [
  407. ["op_Addition", "+", false, "Add"],
  408. ["op_Subtraction", "-", false, "Subtract"],
  409. ["op_Division", "/", true, "Divide"],
  410. ["op_Multiply", "*", true, "Multiply"]
  411. ];
  412. for (var i = 0; i < operators.length; i++) {
  413. var name = operators[i][0];
  414. var operator = operators[i][1];
  415. var withScalar = operators[i][2];
  416. var staticMethodName = operators[i][3];
  417. vectorUtil.makeArithmeticOperator($, name, staticMethodName, operator, dataMembers, tVector, tVector, tVector);
  418. if (withScalar) {
  419. var nameSuffixed = name + "Scalar";
  420. var staticMethodNameSuffixed = staticMethodName + "Scalar";
  421. vectorUtil.makeArithmeticOperator($, nameSuffixed, staticMethodNameSuffixed, operator, dataMembers, tVector, $.Single, tVector);
  422. var nameSuffixed2 = nameSuffixed + "Left";
  423. var staticMethodNameSuffixed2 = staticMethodNameSuffixed + "Left";
  424. vectorUtil.makeArithmeticOperator($, nameSuffixed2, staticMethodNameSuffixed2, operator, dataMembers, $.Single, tVector, tVector);
  425. }
  426. }
  427. vectorUtil.makeNegationOperator($, dataMembers, tVector);
  428. vectorUtil.makeLogicOperator($, "op_Equality", "===", "&&", dataMembers, tVector);
  429. vectorUtil.makeLogicOperator($, "op_Inequality", "!==", "||", dataMembers, tVector);
  430. vectorUtil.makeLengthMethods($, dataMembers, tVector);
  431. vectorUtil.makeLerpMethod($, dataMembers, tVector);
  432. },
  433. makeConstants: function ($, tVector, constants) {
  434. var makeGetter = function (values) {
  435. var state = null;
  436. return function () {
  437. if (state === null)
  438. state = JSIL.CreateInstanceOfType(
  439. tVector.get().__Type__, "_ctor", values
  440. );
  441. return state;
  442. }
  443. };
  444. for (var k in constants) {
  445. var values = constants[k];
  446. var getter = makeGetter(values);
  447. $.Method({Static: true , Public: true}, "get_" + k,
  448. new JSIL.MethodSignature(tVector, [], []),
  449. getter
  450. );
  451. }
  452. }
  453. };
  454. JSIL.ImplementExternals("Microsoft.Xna.Framework.Vector2", function ($) {
  455. vectorUtil.makeConstants(
  456. $, $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), {
  457. "UnitX": [1, 0],
  458. "UnitY": [0, 1],
  459. "Zero": [0, 0],
  460. "One": [1, 1]
  461. }
  462. );
  463. vectorUtil.makeOperators(
  464. $, ["X", "Y"], $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2")
  465. );
  466. $.RawMethod(false, "toString", function () {
  467. return "{X:" + this.X + " Y:" + this.Y + "}";
  468. });
  469. $.Method({Static:true , Public:true }, "Clamp",
  470. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), [
  471. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"),
  472. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"),
  473. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2")
  474. ], [])),
  475. function Clamp (value, min, max) {
  476. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector2.prototype);
  477. result.X = Microsoft.Xna.Framework.MathHelper.Clamp(value.X, min.X, max.X);
  478. result.Y = Microsoft.Xna.Framework.MathHelper.Clamp(value.Y, min.Y, max.Y);
  479. return result;
  480. }
  481. );
  482. $.Method({Static:true , Public:true }, "Transform",
  483. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")], [])),
  484. function Transform (position, matrix) {
  485. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector2.prototype);
  486. result.X = (position.X * matrix.xScale) + matrix.xTranslation;
  487. result.Y = (position.Y * matrix.yScale) + matrix.yTranslation;
  488. return result;
  489. }
  490. );
  491. $.Method({Static:true , Public:true }, "Dot",
  492. (new JSIL.MethodSignature($.Single, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2")], [])),
  493. function Dot (vector1, vector2) {
  494. return vector1.X * vector2.X + vector1.Y * vector2.Y;
  495. }
  496. );
  497. $.Method({
  498. Static: false,
  499. Public: true
  500. }, ".ctor", new JSIL.MethodSignature(null, [$.Single, $.Single], []), function Vector2_ctor (x, y) {
  501. this.X = +x;
  502. this.Y = +y;
  503. });
  504. $.Method({
  505. Static: false,
  506. Public: true
  507. }, ".ctor", new JSIL.MethodSignature(null, [$.Single], []), function Vector2_ctor (value) {
  508. this.X = this.Y = +value;
  509. });
  510. });
  511. JSIL.ImplementExternals("Microsoft.Xna.Framework.Vector3", function ($) {
  512. vectorUtil.makeConstants(
  513. $, $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), {
  514. "Backward": [0, 0, 1],
  515. "Forward": [0, 0, -1],
  516. "Left": [-1, 0, 0],
  517. "Right": [1, 0, 0],
  518. "Up": [0, 1, 0],
  519. "Down": [0, -1, 0],
  520. "UnitX": [1, 0, 0],
  521. "UnitY": [0, 1, 0],
  522. "UnitZ": [0, 0, 1],
  523. "Zero": [0, 0, 0],
  524. "One": [1, 1, 1]
  525. }
  526. );
  527. vectorUtil.makeOperators(
  528. $, ["X", "Y", "Z"], $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")
  529. );
  530. $.RawMethod(false, "toString", function () {
  531. return "{X:" + this.X + " Y:" + this.Y + " Z:" + this.Z + "}";
  532. });
  533. $.Method({
  534. Static: false,
  535. Public: true
  536. }, ".ctor", new JSIL.MethodSignature(null, [$.Single, $.Single, $.Single], []), function Vector3_ctor (x, y, z) {
  537. this.X = +x;
  538. this.Y = +y;
  539. this.Z = +z;
  540. });
  541. $.Method({
  542. Static: false,
  543. Public: true
  544. }, ".ctor", new JSIL.MethodSignature(null, [$.Single], []), function Vector3_ctor (value) {
  545. this.X = this.Y = this.Z = +value;
  546. });
  547. $.Method({
  548. Static: false,
  549. Public: true
  550. }, ".ctor", new JSIL.MethodSignature(null, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), $.Single], []), function Vector3_ctor (xy, z) {
  551. this.X = +xy.X;
  552. this.Y = +xy.Y;
  553. this.Z = +z;
  554. });
  555. $.Method({Static:true , Public:true }, "Clamp",
  556. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), [
  557. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"),
  558. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"),
  559. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")
  560. ], [])),
  561. function Clamp (value, min, max) {
  562. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector3.prototype);
  563. result.X = Microsoft.Xna.Framework.MathHelper.Clamp(value.X, min.X, max.X);
  564. result.Y = Microsoft.Xna.Framework.MathHelper.Clamp(value.Y, min.Y, max.Y);
  565. result.Z = Microsoft.Xna.Framework.MathHelper.Clamp(value.Z, min.Z, max.Z);
  566. return result;
  567. }
  568. );
  569. $.Method({Static:true , Public:true }, "Transform",
  570. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")], [])),
  571. function Transform (position, matrix) {
  572. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector3.prototype);
  573. result.X = (position.X * matrix.xScale) + matrix.xTranslation;
  574. result.Y = (position.Y * matrix.yScale) + matrix.yTranslation;
  575. result.Z = (position.Z * matrix.zScale) + matrix.zTranslation;
  576. return result;
  577. }
  578. );
  579. });
  580. JSIL.ImplementExternals("Microsoft.Xna.Framework.Vector4", function ($) {
  581. vectorUtil.makeConstants(
  582. $, $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"), {
  583. "Zero": [0, 0, 0, 0],
  584. "One": [1, 1, 1, 1]
  585. }
  586. );
  587. vectorUtil.makeOperators(
  588. $, ["X", "Y", "Z", "W"], $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4")
  589. );
  590. $.RawMethod(false, "toString", function () {
  591. return "{X:" + this.X + " Y:" + this.Y + " Z:" + this.Z + " W: " + this.W + "}";
  592. });
  593. $.Method({
  594. Static: false,
  595. Public: true
  596. }, ".ctor", new JSIL.MethodSignature(null, [$.Single, $.Single, $.Single, $.Single], []), function Vector4_ctor (x, y, z, w) {
  597. this.X = +x;
  598. this.Y = +y;
  599. this.Z = +z;
  600. this.W = +w;
  601. });
  602. $.Method({
  603. Static: false,
  604. Public: true
  605. }, ".ctor", new JSIL.MethodSignature(null, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector2"), $.Single, $.Single], []), function Vector4_ctor (xy, z, w) {
  606. this.X = +xy.X;
  607. this.Y = +xy.Y;
  608. this.Z = +z;
  609. this.W = +w;
  610. });
  611. $.Method({
  612. Static: false,
  613. Public: true
  614. }, ".ctor", new JSIL.MethodSignature(null, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), $.Single], []), function Vector4_ctor (xyz, w) {
  615. this.X = +xyz.X;
  616. this.Y = +xyz.Y;
  617. this.Z = +xyz.Z;
  618. this.W = +w;
  619. });
  620. $.Method({
  621. Static: false,
  622. Public: true
  623. }, ".ctor", new JSIL.MethodSignature(null, [$.Single], []), function Vector4_ctor (value) {
  624. this.X = this.Y = this.Z = this.W = +value;
  625. });
  626. $.Method({Static:true , Public:true }, "Clamp",
  627. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"), [
  628. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"),
  629. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"),
  630. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4")
  631. ], [])),
  632. function Clamp (value, min, max) {
  633. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector4.prototype);
  634. result.X = Microsoft.Xna.Framework.MathHelper.Clamp(value.X, min.X, max.X);
  635. result.Y = Microsoft.Xna.Framework.MathHelper.Clamp(value.Y, min.Y, max.Y);
  636. result.Z = Microsoft.Xna.Framework.MathHelper.Clamp(value.Z, min.Z, max.Z);
  637. result.W = Microsoft.Xna.Framework.MathHelper.Clamp(value.W, min.W, max.W);
  638. return result;
  639. }
  640. );
  641. $.Method({Static:true , Public:true }, "Transform",
  642. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")], [])),
  643. function Transform (position, matrix) {
  644. var result = JSIL.CreateInstanceObject(Microsoft.Xna.Framework.Vector4.prototype);
  645. result.X = (position.X * matrix.xScale) + matrix.xTranslation;
  646. result.Y = (position.Y * matrix.yScale) + matrix.yTranslation;
  647. result.Z = (position.Z * matrix.zScale) + matrix.zTranslation;
  648. result.W = (position.W * matrix.wScale) + matrix.wTranslation;
  649. return result;
  650. }
  651. );
  652. });
  653. JSIL.ImplementExternals("Microsoft.Xna.Framework.Matrix", function ($) {
  654. var matrix = $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix");
  655. $.Method({
  656. Static: true,
  657. Public: true
  658. }, ".cctor2", JSIL.MethodSignature.Void, function () {
  659. // FIXME
  660. var identity = Microsoft.Xna.Framework.Matrix._identity = new Microsoft.Xna.Framework.Matrix();
  661. identity.xTranslation = identity.yTranslation = identity.zTranslation = 0;
  662. identity.xRotation = identity.yRotation = identity.zRotation = 0;
  663. identity.xScale = identity.yScale = identity.zScale = 1;
  664. });
  665. $.RawMethod(false, "__CopyMembers__",
  666. function Matrix_CopyMembers (source, target) {
  667. target.xScale = source.xScale || 0;
  668. target.yScale = source.yScale || 0;
  669. target.zScale = source.zScale || 0;
  670. target.xTranslation = source.xTranslation || 0;
  671. target.yTranslation = source.yTranslation || 0;
  672. target.zTranslation = source.zTranslation || 0;
  673. target.xRotation = source.xRotation || 0;
  674. target.yRotation = source.yRotation || 0;
  675. target.zRotation = source.zRotation || 0;
  676. }
  677. );
  678. $.Method({Static:true , Public:true }, "get_Identity",
  679. (new JSIL.MethodSignature(matrix, [], [])),
  680. function get_Identity () {
  681. return Microsoft.Xna.Framework.Matrix._identity;
  682. }
  683. );
  684. $.Method({Static:true , Public:true }, "CreateLookAt",
  685. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  686. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3"),
  687. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")
  688. ], [])),
  689. function CreateLookAt (cameraPosition, cameraTarget, cameraUpVector) {
  690. // FIXME
  691. return Microsoft.Xna.Framework.Matrix._identity;
  692. }
  693. );
  694. $.Method({Static:true , Public:true }, "CreateLookAt",
  695. (new JSIL.MethodSignature(null, [
  696. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")]), $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")]),
  697. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")]), $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  698. ], [])),
  699. function CreateLookAt (/* ref */ cameraPosition, /* ref */ cameraTarget, /* ref */ cameraUpVector, /* ref */ result) {
  700. // FIXME
  701. result.set(Microsoft.Xna.Framework.Matrix._identity);
  702. }
  703. );
  704. $.Method({Static:true , Public:true }, "CreateOrthographic",
  705. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  706. $.Single, $.Single,
  707. $.Single, $.Single
  708. ], [])),
  709. function CreateOrthographic (width, height, zNearPlane, zFarPlane) {
  710. // FIXME
  711. return Microsoft.Xna.Framework.Matrix._identity;
  712. }
  713. );
  714. $.Method({Static:true , Public:true }, "CreateOrthographic",
  715. (new JSIL.MethodSignature(null, [
  716. $.Single, $.Single,
  717. $.Single, $.Single,
  718. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  719. ], [])),
  720. function CreateOrthographic (width, height, zNearPlane, zFarPlane, /* ref */ result) {
  721. // FIXME
  722. result.set(Microsoft.Xna.Framework.Matrix._identity);
  723. }
  724. );
  725. $.Method({Static:true , Public:true }, "CreateOrthographicOffCenter",
  726. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  727. $.Single, $.Single,
  728. $.Single, $.Single,
  729. $.Single, $.Single
  730. ], [])),
  731. function CreateOrthographicOffCenter (left, right, bottom, top, zNearPlane, zFarPlane) {
  732. // FIXME
  733. return Microsoft.Xna.Framework.Matrix._identity;
  734. }
  735. );
  736. $.Method({Static:true , Public:true }, "CreateOrthographicOffCenter",
  737. (new JSIL.MethodSignature(null, [
  738. $.Single, $.Single,
  739. $.Single, $.Single,
  740. $.Single, $.Single,
  741. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  742. ], [])),
  743. function CreateOrthographicOffCenter (left, right, bottom, top, zNearPlane, zFarPlane, /* ref */ result) {
  744. // FIXME
  745. result.set(Microsoft.Xna.Framework.Matrix._identity);
  746. }
  747. );
  748. $.Method({Static:true , Public:true }, "CreatePerspective",
  749. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  750. $.Single, $.Single,
  751. $.Single, $.Single
  752. ], [])),
  753. function CreatePerspective (width, height, nearPlaneDistance, farPlaneDistance) {
  754. // FIXME
  755. return Microsoft.Xna.Framework.Matrix._identity;
  756. }
  757. );
  758. $.Method({Static:true , Public:true }, "CreatePerspective",
  759. (new JSIL.MethodSignature(null, [
  760. $.Single, $.Single,
  761. $.Single, $.Single,
  762. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  763. ], [])),
  764. function CreatePerspective (width, height, nearPlaneDistance, farPlaneDistance, /* ref */ result) {
  765. // FIXME
  766. result.set(Microsoft.Xna.Framework.Matrix._identity);
  767. }
  768. );
  769. $.Method({Static:true , Public:true }, "CreatePerspectiveFieldOfView",
  770. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  771. $.Single, $.Single,
  772. $.Single, $.Single
  773. ], [])),
  774. function CreatePerspectiveFieldOfView (fieldOfView, aspectRatio, nearPlaneDistance, farPlaneDistance) {
  775. // FIXME
  776. return Microsoft.Xna.Framework.Matrix._identity;
  777. }
  778. );
  779. $.Method({Static:true , Public:true }, "CreatePerspectiveFieldOfView",
  780. (new JSIL.MethodSignature(null, [
  781. $.Single, $.Single,
  782. $.Single, $.Single,
  783. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  784. ], [])),
  785. function CreatePerspectiveFieldOfView (fieldOfView, aspectRatio, nearPlaneDistance, farPlaneDistance, /* ref */ result) {
  786. // FIXME
  787. result.set(Microsoft.Xna.Framework.Matrix._identity);
  788. }
  789. );
  790. $.Method({Static:true , Public:true }, "CreatePerspectiveOffCenter",
  791. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  792. $.Single, $.Single,
  793. $.Single, $.Single,
  794. $.Single, $.Single
  795. ], [])),
  796. function CreatePerspectiveOffCenter (left, right, bottom, top, nearPlaneDistance, farPlaneDistance) {
  797. // FIXME
  798. return Microsoft.Xna.Framework.Matrix._identity;
  799. }
  800. );
  801. $.Method({Static:true , Public:true }, "CreatePerspectiveOffCenter",
  802. (new JSIL.MethodSignature(null, [
  803. $.Single, $.Single,
  804. $.Single, $.Single,
  805. $.Single, $.Single,
  806. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")])
  807. ], [])),
  808. function CreatePerspectiveOffCenter (left, right, bottom, top, nearPlaneDistance, farPlaneDistance, /* ref */ result) {
  809. // FIXME
  810. result.set(Microsoft.Xna.Framework.Matrix._identity);
  811. }
  812. );
  813. $.Method({Static:true , Public:true }, "CreateRotationX",
  814. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$.Single], [])),
  815. function CreateRotationX (radians) {
  816. // FIXME
  817. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  818. result.xRotation = radians;
  819. return result;
  820. }
  821. );
  822. $.Method({Static:true , Public:true }, "CreateRotationY",
  823. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$.Single], [])),
  824. function CreateRotationY (radians) {
  825. // FIXME
  826. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  827. result.yRotation = radians;
  828. return result;
  829. }
  830. );
  831. $.Method({Static:true , Public:true }, "CreateRotationZ",
  832. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$.Single], [])),
  833. function CreateRotationZ (radians) {
  834. // FIXME
  835. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  836. result.zRotation = radians;
  837. return result;
  838. }
  839. );
  840. $.Method({Static:true , Public:true }, "CreateScale",
  841. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")], [])),
  842. function CreateScale (scales) {
  843. // FIXME
  844. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  845. result.xScale = scales.X;
  846. result.yScale = scales.Y;
  847. result.zScale = scales.Z;
  848. return result;
  849. }
  850. );
  851. $.Method({Static:true , Public:true }, "CreateScale",
  852. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$.Single], [])),
  853. function CreateScale (scale) {
  854. // FIXME
  855. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  856. result.xScale = scale;
  857. result.yScale = scale;
  858. result.zScale = scale;
  859. return result;
  860. }
  861. );
  862. $.Method({Static:true , Public:true }, "CreateScale",
  863. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  864. $.Single, $.Single,
  865. $.Single
  866. ], [])),
  867. function CreateScale (xScale, yScale, zScale) {
  868. // FIXME
  869. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  870. result.xScale = xScale;
  871. result.yScale = yScale;
  872. result.zScale = zScale;
  873. return result;
  874. }
  875. );
  876. $.Method({Static:true , Public:true }, "CreateTranslation",
  877. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector3")], [])),
  878. function CreateTranslation (position) {
  879. // FIXME
  880. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  881. result.xTranslation = position.X;
  882. result.yTranslation = position.Y;
  883. result.zTranslation = position.Z;
  884. return result;
  885. }
  886. );
  887. $.Method({Static:true , Public:true }, "CreateTranslation",
  888. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [
  889. $.Single, $.Single,
  890. $.Single
  891. ], [])),
  892. function CreateTranslation (xPosition, yPosition, zPosition) {
  893. // FIXME
  894. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  895. result.xTranslation = xPosition;
  896. result.yTranslation = yPosition;
  897. result.zTranslation = zPosition;
  898. return result;
  899. }
  900. );
  901. $.Method({Static:true , Public:true }, "Invert",
  902. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")], [])),
  903. function Invert (matrix) {
  904. // FIXME
  905. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  906. result.xTranslation = -matrix.xTranslation;
  907. result.yTranslation = -matrix.yTranslation;
  908. result.zTranslation = -matrix.zTranslation;
  909. result.xScale = 1 / (matrix.xScale + 0.000001);
  910. result.yScale = 1 / (matrix.yScale + 0.000001);
  911. result.zScale = 1 / (matrix.zScale + 0.000001);
  912. return result;
  913. }
  914. );
  915. $.Method({Static:true , Public:true }, "op_Multiply",
  916. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Matrix")], [])),
  917. function Multiply (matrix1, matrix2) {
  918. // FIXME
  919. var result = Microsoft.Xna.Framework.Matrix._identity.MemberwiseClone();
  920. result.xTranslation = matrix1.xTranslation + matrix2.xTranslation;
  921. result.yTranslation = matrix1.yTranslation + matrix2.yTranslation;
  922. result.zTranslation = matrix1.zTranslation + matrix2.zTranslation;
  923. result.xScale = matrix1.xScale * matrix2.xScale;
  924. result.yScale = matrix1.yScale * matrix2.yScale;
  925. result.zScale = matrix1.zScale * matrix2.zScale;
  926. return result;
  927. }
  928. );
  929. });
  930. JSIL.ImplementExternals("Microsoft.Xna.Framework.GameComponentCollection", function ($) {
  931. $.RawMethod(false, "$internalCtor", function (game) {
  932. this._game = game;
  933. this._ctor();
  934. });
  935. $.RawMethod(false, "$OnItemAdded", function (item) {
  936. if (this._game.initialized) {
  937. if (typeof (item.Initialize) === "function")
  938. item.Initialize();
  939. }
  940. });
  941. });
  942. JSIL.ImplementExternals("Microsoft.Xna.Framework.Game", function ($) {
  943. $.Method({Static: true, Public: true}, "ForceQuit",
  944. JSIL.MethodSignature.Void,
  945. function () {
  946. Microsoft.Xna.Framework.Game._QuitForced = true;
  947. }
  948. );
  949. $.Method({Static: true, Public: true}, "ForcePause",
  950. JSIL.MethodSignature.Void,
  951. function () {
  952. Microsoft.Xna.Framework.Game._PauseForced = true;
  953. }
  954. );
  955. $.Method({Static: true, Public: true}, "ForceUnpause",
  956. JSIL.MethodSignature.Void,
  957. function () {
  958. Microsoft.Xna.Framework.Game._PauseForced = false;
  959. var ns = Microsoft.Xna.Framework.Game._NeedsStep;
  960. Microsoft.Xna.Framework.Game._NeedsStep = null;
  961. if (ns)
  962. ns._QueueStep();
  963. }
  964. );
  965. $.Method({Static:false, Public:true }, ".ctor",
  966. (JSIL.MethodSignature.Void),
  967. function _ctor () {
  968. var tContentManager = JSIL.GetTypeFromAssembly(
  969. $xnaasms.xna, "Microsoft.Xna.Framework.Content.ContentManager", [], true
  970. );
  971. var tGameTime = JSIL.GetTypeFromAssembly(
  972. $xnaasms.xnaGame, "Microsoft.Xna.Framework.GameTime", [], true
  973. );
  974. this.gameServices = new Microsoft.Xna.Framework.GameServiceContainer();
  975. this.content = JSIL.CreateInstanceOfType(tContentManager, [this.gameServices]);
  976. this.components = JSIL.CreateInstanceOfType(
  977. Microsoft.Xna.Framework.GameComponentCollection.__Type__, "$internalCtor", [this]
  978. );
  979. this.targetElapsedTime = System.TimeSpan.FromTicks(System.Int64.FromInt32(166667));
  980. this.isFixedTimeStep = true;
  981. this.forceElapsedTimeToZero = true;
  982. this._isDead = false;
  983. this.initialized = false;
  984. this._gameTime = JSIL.CreateInstanceOfType(tGameTime, null);
  985. this._lastFrame = this._nextFrame = this._started = 0;
  986. }
  987. );
  988. $.Method({Static:false, Public:true }, "get_Components",
  989. (new JSIL.MethodSignature($xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameComponentCollection"), [], [])),
  990. function get_Components () {
  991. return this.components;
  992. }
  993. );
  994. $.Method({Static:false, Public:true }, "get_Content",
  995. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Content.ContentManager"), [], [])),
  996. function get_Content () {
  997. return this.content;
  998. }
  999. );
  1000. $.Method({Static:false, Public:true }, "get_GraphicsDevice",
  1001. (new JSIL.MethodSignature($jsilxna.graphicsRef("Microsoft.Xna.Framework.Graphics.GraphicsDevice"), [], [])),
  1002. function get_GraphicsDevice () {
  1003. return this.graphicsDeviceService.GraphicsDevice;
  1004. }
  1005. );
  1006. $.Method({Static:false, Public:true }, "get_IsActive",
  1007. (new JSIL.MethodSignature($.Boolean, [], [])),
  1008. function get_IsActive () {
  1009. return JSIL.Host.isPageVisible() && !Microsoft.Xna.Framework.Game._QuitForced && !this._isDead;
  1010. }
  1011. );
  1012. $.Method({Static:false, Public:true }, "get_IsFixedTimeStep",
  1013. (new JSIL.MethodSignature($.Boolean, [], [])),
  1014. function get_IsFixedTimeStep () {
  1015. return this.isFixedTimeStep;
  1016. }
  1017. );
  1018. $.Method({Static:false, Public:true }, "get_TargetElapsedTime",
  1019. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.TimeSpan"), [], [])),
  1020. function get_TargetElapsedTime () {
  1021. return this.targetElapsedTime;
  1022. }
  1023. );
  1024. $.Method({Static:false, Public:true }, "get_Services",
  1025. (new JSIL.MethodSignature($xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameServiceContainer"), [], [])),
  1026. function get_Services () {
  1027. return this.gameServices;
  1028. }
  1029. );
  1030. $.Method({Static:false, Public:true }, "get_Window",
  1031. (new JSIL.MethodSignature($xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameWindow"), [], [])),
  1032. function get_Window () {
  1033. // FIXME
  1034. if (!this._window)
  1035. this._window = new Microsoft.Xna.Framework.GameWindow();
  1036. return this._window;
  1037. }
  1038. );
  1039. $.Method({Static:false, Public:false}, "get_IsMouseVisible",
  1040. (new JSIL.MethodSignature($.Boolean, [], [])),
  1041. function get_IsMouseVisible () {
  1042. var oc = this.graphicsDeviceService.GraphicsDevice.originalCanvas;
  1043. return (oc.style.cursor !== "none");
  1044. }
  1045. );
  1046. $.Method({Static:false, Public:true }, "set_IsMouseVisible",
  1047. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  1048. function set_IsMouseVisible (value) {
  1049. var oc = this.graphicsDeviceService.GraphicsDevice.originalCanvas;
  1050. oc.style.cursor = value ? "default" : "none";
  1051. }
  1052. );
  1053. $.Method({Static:false, Public:true }, "set_IsFixedTimeStep",
  1054. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  1055. function set_IsFixedTimeStep (value) {
  1056. this.isFixedTimeStep = value;
  1057. }
  1058. );
  1059. $.Method({Static:false, Public:true }, "set_TargetElapsedTime",
  1060. (new JSIL.MethodSignature(null, [$xnaasms[5].TypeRef("System.TimeSpan")], [])),
  1061. function set_TargetElapsedTime (value) {
  1062. this.targetElapsedTime = value;
  1063. }
  1064. );
  1065. $.Method({
  1066. Static: false,
  1067. Public: true
  1068. }, "Initialize", JSIL.MethodSignature.Void, function Game_Initialize () {
  1069. this.initialized = true;
  1070. for (var i = 0, l = this.components._size; i < l; i++) {
  1071. var component = this.components._items[i];
  1072. component.Initialize();
  1073. }
  1074. this.LoadContent();
  1075. var gameControl = JSIL.Host.getService("gameControl", true);
  1076. if (gameControl)
  1077. gameControl.started(this);
  1078. });
  1079. $.Method({
  1080. Static: false,
  1081. Public: true
  1082. }, "LoadContent", JSIL.MethodSignature.Void, function () {
  1083. });
  1084. $.Method({
  1085. Static: false,
  1086. Public: true
  1087. }, "UnloadContent", JSIL.MethodSignature.Void, function () {
  1088. });
  1089. $.Method({
  1090. Static: false,
  1091. Public: true
  1092. }, "ResetElapsedTime", JSIL.MethodSignature.Void, function () {
  1093. this.forceElapsedTimeToZero = true;
  1094. });
  1095. $.RawMethod(false, "$ComponentsOfType", function Game_$ComponentsOfType (type) {
  1096. var result = new Array();
  1097. for (var i = 0, l = this.components._size; i < l; i++) {
  1098. var item = this.components._items[i];
  1099. if (type.$Is(item))
  1100. result.push(item);
  1101. }
  1102. return result;
  1103. });
  1104. $.Method({Static:false, Public:false}, "Draw",
  1105. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameTime")], [])),
  1106. function Game_Draw (gameTime) {
  1107. if (Microsoft.Xna.Framework.Game._QuitForced || this._isDead)
  1108. return;
  1109. var drawableComponents = this.$ComponentsOfType(Microsoft.Xna.Framework.IDrawable.__Type__);
  1110. drawableComponents.sort(function (lhs, rhs) {
  1111. return JSIL.CompareValues(lhs.get_DrawOrder(), rhs.get_DrawOrder());
  1112. });
  1113. for (var i = 0, l = drawableComponents.length; i < l; i++) {
  1114. var drawable = drawableComponents[i];
  1115. if (drawable.Visible)
  1116. drawable.Draw(gameTime);
  1117. }
  1118. }
  1119. );
  1120. $.Method({Static:false, Public:false}, "Update",
  1121. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameTime")], [])),
  1122. function Game_Update (gameTime) {
  1123. if (Microsoft.Xna.Framework.Game._QuitForced || this._isDead)
  1124. return;
  1125. var updateableComponents = this.$ComponentsOfType(Microsoft.Xna.Framework.IUpdateable.__Type__);
  1126. updateableComponents.sort(function (lhs, rhs) {
  1127. return JSIL.CompareValues(lhs.get_UpdateOrder(), rhs.get_UpdateOrder());
  1128. });
  1129. for (var i = 0, l = updateableComponents.length; i < l; i++) {
  1130. var updateable = updateableComponents[i];
  1131. if (updateable.Enabled)
  1132. updateable.Update(gameTime);
  1133. }
  1134. }
  1135. );
  1136. $.Method({
  1137. Static: false,
  1138. Public: true
  1139. }, "Run", JSIL.MethodSignature.Void, function Game_Run () {
  1140. this._profilingMode = (document.location.search.indexOf("profile") >= 0);
  1141. this._balanceFPSCheckbox = (document.getElementById("balanceFramerate") || null);
  1142. if (this._balanceFPSCheckbox)
  1143. this._balanceFPSCheckbox.checked = !this._profilingMode;
  1144. Microsoft.Xna.Framework.Game._QuitForced = false;
  1145. this.Initialize();
  1146. this._QueueStep();
  1147. });
  1148. $.RawMethod(false, "_QueueStep", function Game_QueueStep () {
  1149. if (Microsoft.Xna.Framework.Game._QuitForced || this._isDead)
  1150. return;
  1151. var self = this;
  1152. var stepCallback = self._Step.bind(self);
  1153. JSIL.Host.scheduleTick(stepCallback);
  1154. });
  1155. $.RawMethod(false, "_TimedUpdate", function Game_TimedUpdate (longFrame) {
  1156. // FIXME: We have to sample time in two different ways here.
  1157. // One is used for the framerate indicator, the other is used
  1158. // to avoid frameskip after a really long update. We want the
  1159. // frameskip suppression to be consistent in replay recording situations
  1160. // but we want to display actual update perf when running a replay.
  1161. var updateActuallyStarted = JSIL.$GetHighResTime();
  1162. var updateStarted = JSIL.Host.getTickCount();
  1163. this.Update(this._gameTime);
  1164. var updateEnded = JSIL.Host.getTickCount();
  1165. var updateActuallyEnded = JSIL.$GetHighResTime();
  1166. // Detect long updates and suppress frameskip.
  1167. if ((updateEnded - updateStarted) > longFrame) {
  1168. this.suppressFrameskip = true;
  1169. }
  1170. this._updateTimings.push(updateActuallyEnded - updateActuallyStarted);
  1171. var svc = JSIL.Host.getService("gameTiming", true);
  1172. if (svc)
  1173. svc.update(updateActuallyEnded - updateActuallyStarted);
  1174. });
  1175. $.RawMethod(false, "_MaybeReportFPS", function Game_MaybeReportFPS (now) {
  1176. var elapsed = now - this._lastFPSReport;
  1177. if (elapsed >= 250) {
  1178. this._ReportFPS(now);
  1179. }
  1180. });
  1181. $.RawMethod(false, "_ReportFPS", function Game_ReportFPS (now) {
  1182. var maxTimingSamples = 60;
  1183. this._lastFPSReport = now;
  1184. // FIXME: Slower than necessary.
  1185. while (this._drawTimings.length > maxTimingSamples)
  1186. this._drawTimings.shift();
  1187. while (this._updateTimings.length > maxTimingSamples)
  1188. this._updateTimings.shift();
  1189. var updateTimeSum = 0, drawTimeSum = 0;
  1190. for (var i = 0, l = this._drawTimings.length; i < l; i++)
  1191. drawTimeSum += this._drawTimings[i];
  1192. for (var i = 0, l = this._updateTimings.length; i < l; i++)
  1193. updateTimeSum += this._updateTimings[i];
  1194. var updateTimeAverage = updateTimeSum / this._updateTimings.length;
  1195. var drawTimeAverage = drawTimeSum / this._drawTimings.length;
  1196. var isWebGL = this.graphicsDeviceService.GraphicsDevice.context.isWebGL || false;
  1197. var cacheBytes = ($jsilxna.imageChannelCache.countBytes + $jsilxna.textCache.countBytes);
  1198. JSIL.Host.reportPerformance(drawTimeAverage, updateTimeAverage, cacheBytes, isWebGL);
  1199. });
  1200. $.RawMethod(false, "_FixedTimeStep", function Game_FixedTimeStep (
  1201. elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame
  1202. ) {
  1203. var tInt64 = $jsilcore.System.Int64;
  1204. var frameLength64 = tInt64.FromNumber(frameDelay * millisecondInTicks);
  1205. this._gameTime.elapsedGameTime._ticks = frameLength64;
  1206. this._gameTime.elapsedGameTime.$invalidate();
  1207. elapsed += this._extraTime;
  1208. this._extraTime = 0;
  1209. if (elapsed > maxElapsedTimeMs)
  1210. elapsed = maxElapsedTimeMs;
  1211. var numFrames = Math.floor(elapsed / frameDelay);
  1212. if (numFrames < 1) {
  1213. numFrames = 1;
  1214. this._extraTime = elapsed - frameDelay;
  1215. } else {
  1216. this._extraTime = elapsed - (numFrames * frameDelay);
  1217. }
  1218. for (var i = 0; i < numFrames; i++) {
  1219. this._gameTime.totalGameTime._ticks = tInt64.op_Addition(
  1220. this._gameTime.totalGameTime._ticks, frameLength64, this._gameTime.totalGameTime._ticks
  1221. );
  1222. this._gameTime.totalGameTime.$invalidate();
  1223. this._TimedUpdate(longFrame);
  1224. }
  1225. });
  1226. $.RawMethod(false, "_VariableTimeStep", function Game_VariableTimeStep (
  1227. elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame
  1228. ) {
  1229. this._extraTime = 0;
  1230. this.suppressFrameskip = false;
  1231. if (elapsed > maxElapsedTimeMs)
  1232. elapsed = maxElapsedTimeMs;
  1233. var tInt64 = $jsilcore.System.Int64;
  1234. var elapsed64 = tInt64.FromNumber(elapsed * millisecondInTicks);
  1235. this._gameTime.elapsedGameTime._ticks = elapsed64;
  1236. this._gameTime.elapsedGameTime.$invalidate();
  1237. this._gameTime.totalGameTime._ticks = tInt64.op_Addition(
  1238. this._gameTime.totalGameTime._ticks, elapsed64, this._gameTime.totalGameTime._ticks
  1239. );
  1240. this._gameTime.totalGameTime.$invalidate();
  1241. this._TimedUpdate(longFrame);
  1242. });
  1243. $.RawMethod(false, "_RenderAFrame", function Game_RenderAFrame () {
  1244. var started = JSIL.$GetHighResTime();
  1245. var device = this.get_GraphicsDevice();
  1246. device.$UpdateViewport();
  1247. device.$Clear(null);
  1248. this.Draw(this._gameTime);
  1249. var ended = JSIL.$GetHighResTime();
  1250. this._drawTimings.push(ended - started);
  1251. var svc = JSIL.Host.getService("gameTiming", true);
  1252. if (svc)
  1253. svc.draw(ended - started);
  1254. });
  1255. $.RawMethod(false, "_Step", function Game_Step () {
  1256. var now = JSIL.Host.getTickCount();
  1257. var actualNow = JSIL.$GetHighResTime();
  1258. var frameDelay = this.targetElapsedTime.get_TotalMilliseconds();
  1259. if (frameDelay <= 0)
  1260. JSIL.RuntimeError("Game frame duration must be a positive, nonzero number!");
  1261. if (this._lastFrame === 0) {
  1262. var elapsed = frameDelay;
  1263. var total = 0;
  1264. this._started = now;
  1265. this._lastFPSReport = actualNow;
  1266. this._updateTimings = [];
  1267. this._drawTimings = [];
  1268. this._extraTime = 0;
  1269. this.suppressFrameskip = true;
  1270. } else {
  1271. var elapsed = now - this._lastFrame;
  1272. var total = now - this._started;
  1273. }
  1274. this._MaybeReportFPS(actualNow);
  1275. $jsilxna.imageChannelCache.maybeEvictItems();
  1276. $jsilxna.textCache.maybeEvictItems();
  1277. if (this.forceElapsedTimeToZero) {
  1278. this.forceElapsedTimeToZero = false;
  1279. this._extraTime = 0;
  1280. elapsed = 0;
  1281. }
  1282. this._lastFrame = now;
  1283. this._nextFrame = now + frameDelay;
  1284. var millisecondInTicks = 10000;
  1285. var maxElapsedTimeMs = frameDelay * 4;
  1286. var longFrame = frameDelay * 3;
  1287. this._profilingMode = (document.location.search.indexOf("profile") >= 0);
  1288. if (this._balanceFPSCheckbox)
  1289. this._profilingMode = !this._balanceFPSCheckbox.checked;
  1290. // Isolate the try block into its own function since it will be running in the interpreter
  1291. this._TimeStep(elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame);
  1292. });
  1293. $.RawMethod(false, "_TimeStep", function Game_TimeStep (elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame) {
  1294. var failed = true;
  1295. try {
  1296. if (this.isFixedTimeStep && !this.suppressFrameskip && !this._profilingMode) {
  1297. this._FixedTimeStep(elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame);
  1298. } else {
  1299. this._VariableTimeStep(elapsed, frameDelay, millisecondInTicks, maxElapsedTimeMs, longFrame);
  1300. }
  1301. this._RenderAFrame();
  1302. failed = false;
  1303. } finally {
  1304. if (failed || Microsoft.Xna.Framework.Game._QuitForced) {
  1305. this.Exit();
  1306. } else if (Microsoft.Xna.Framework.Game._PauseForced) {
  1307. Microsoft.Xna.Framework.Game._NeedsStep = this;
  1308. } else {
  1309. this._QueueStep();
  1310. }
  1311. }
  1312. });
  1313. $.Method({
  1314. Static: false,
  1315. Public: true
  1316. }, "Exit", JSIL.MethodSignature.Void, function Game_Exit () {
  1317. this.Dispose();
  1318. });
  1319. $.Method({
  1320. Static: false,
  1321. Public: true
  1322. }, "Dispose", JSIL.MethodSignature.Void, function Game_Dispose () {
  1323. this.UnloadContent();
  1324. this._isDead = true;
  1325. try {
  1326. var canvas = JSIL.Host.getCanvas();
  1327. var ctx = canvas.getContext("2d") || canvas.getContext("webgl-2d");
  1328. ctx.setTransform(1, 0, 0, 1, 0, 0);
  1329. ctx.globalAlpha = 1;
  1330. ctx.globalCompositeOperation = "source-over";
  1331. ctx.fillStyle = "black";
  1332. ctx.fillRect(0, 0, 99999, 99999);
  1333. var fsb = document.getElementById("fullscreenButton");
  1334. if (fsb)
  1335. fsb.style.display = "none";
  1336. var stats = document.getElementById("stats");
  1337. if (stats)
  1338. stats.style.display = "none";
  1339. } catch (exc) {
  1340. }
  1341. });
  1342. });
  1343. JSIL.ImplementExternals("Microsoft.Xna.Framework.GameComponent", function ($) {
  1344. $.Method({Static:false, Public:true }, ".ctor",
  1345. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.Game")], [])),
  1346. function _ctor (game) {
  1347. this.enabled = true;
  1348. this.initialized = false;
  1349. this.game = game;
  1350. }
  1351. );
  1352. $.Method({Static:false, Public:true }, "get_UpdateOrder",
  1353. (new JSIL.MethodSignature($.Int32, [], [])),
  1354. function get_UpdateOrder () {
  1355. return 0;
  1356. }
  1357. );
  1358. $.Method({Static:false, Public:true }, "get_Enabled",
  1359. (new JSIL.MethodSignature($.Boolean, [], [])),
  1360. function get_Enabled () {
  1361. return this.enabled;
  1362. }
  1363. );
  1364. $.Method({Static:false, Public:true }, "get_Game",
  1365. (new JSIL.MethodSignature($xnaasms[1].TypeRef("Microsoft.Xna.Framework.Game"), [], [])),
  1366. function get_Game () {
  1367. return this.game;
  1368. }
  1369. );
  1370. $.Method({Static:false, Public:true }, "set_Enabled",
  1371. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  1372. function set_Enabled (value) {
  1373. this.enabled = value;
  1374. }
  1375. );
  1376. $.Method({Static:false, Public:true }, "Initialize",
  1377. (JSIL.MethodSignature.Void),
  1378. function Initialize () {
  1379. if (this.initialized) return;
  1380. this.initialized = true;
  1381. }
  1382. );
  1383. $.Method({Static:false, Public:true }, "Update",
  1384. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameTime")], [])),
  1385. function Update (gameTime) {
  1386. }
  1387. );
  1388. $.Method({Static: false, Public: true }, "Dispose",
  1389. (JSIL.MethodSignature.Void),
  1390. function Dispose () {
  1391. }
  1392. );
  1393. });
  1394. JSIL.ImplementExternals("Microsoft.Xna.Framework.DrawableGameComponent", function ($) {
  1395. $.Method({Static:false, Public:true }, ".ctor",
  1396. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.Game")], [])),
  1397. function _ctor (game) {
  1398. Microsoft.Xna.Framework.GameComponent.prototype._ctor.call(this, game);
  1399. this.visible = true;
  1400. }
  1401. );
  1402. $.Method({Static:false, Public:true }, "Draw",
  1403. (new JSIL.MethodSignature(null, [$xnaasms[1].TypeRef("Microsoft.Xna.Framework.GameTime")], [])),
  1404. function Draw (gameTime) {
  1405. }
  1406. );
  1407. $.Method({Static:false, Public:true }, "get_DrawOrder",
  1408. (new JSIL.MethodSignature($.Int32, [], [])),
  1409. function get_DrawOrder () {
  1410. return 0;
  1411. }
  1412. );
  1413. $.Method({Static:false, Public:true }, "get_GraphicsDevice",
  1414. (new JSIL.MethodSignature($jsilxna.graphicsRef("Microsoft.Xna.Framework.Graphics.GraphicsDevice"), [], [])),
  1415. function get_GraphicsDevice () {
  1416. return this.game.graphicsDeviceService.GraphicsDevice;
  1417. }
  1418. );
  1419. $.Method({Static:false, Public:true }, "get_Visible",
  1420. (new JSIL.MethodSignature($.Boolean, [], [])),
  1421. function get_Visible () {
  1422. return this.visible;
  1423. }
  1424. );
  1425. $.Method({Static:false, Public:true }, "Initialize",
  1426. (JSIL.MethodSignature.Void),
  1427. function Initialize () {
  1428. if (this.initialized) return;
  1429. Microsoft.Xna.Framework.GameComponent.prototype.Initialize.call(this);
  1430. this.LoadContent();
  1431. }
  1432. );
  1433. $.Method({Static:false, Public:false}, "LoadContent",
  1434. (JSIL.MethodSignature.Void),
  1435. function LoadContent () {
  1436. }
  1437. );
  1438. $.Method({Static:false, Public:true }, "set_Visible",
  1439. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  1440. function set_Visible (value) {
  1441. this.visible = value;
  1442. }
  1443. );
  1444. });
  1445. JSIL.ImplementExternals("Microsoft.Xna.Framework.GameTime", function ($) {
  1446. $.Method({Static:false, Public:true }, ".ctor",
  1447. (JSIL.MethodSignature.Void),
  1448. function _ctor () {
  1449. this.totalGameTime = new System.TimeSpan();
  1450. this.elapsedGameTime = new System.TimeSpan();
  1451. this.isRunningSlowly = false;
  1452. }
  1453. );
  1454. $.Method({Static:false, Public:true }, ".ctor",
  1455. (new JSIL.MethodSignature(null, [
  1456. $xnaasms[5].TypeRef("System.TimeSpan"), $xnaasms[5].TypeRef("System.TimeSpan"),
  1457. $.Boolean
  1458. ], [])),
  1459. function _ctor (totalGameTime, elapsedGameTime, isRunningSlowly) {
  1460. this.totalGameTime = totalGameTime;
  1461. this.elapsedGameTime = elapsedGameTime;
  1462. this.isRunningSlowly = isRunningSlowly;
  1463. }
  1464. );
  1465. $.Method({Static:false, Public:true }, ".ctor",
  1466. (new JSIL.MethodSignature(null, [$xnaasms[5].TypeRef("System.TimeSpan"), $xnaasms[5].TypeRef("System.TimeSpan")], [])),
  1467. function _ctor (totalGameTime, elapsedGameTime) {
  1468. this.totalGameTime = totalGameTime;
  1469. this.elapsedGameTime = elapsedGameTime;
  1470. this.isRunningSlowly = false;
  1471. }
  1472. );
  1473. $.Method({Static:false, Public:true }, "get_IsRunningSlowly",
  1474. (new JSIL.MethodSignature($.Boolean, [], [])),
  1475. function get_IsRunningSlowly () {
  1476. return this.isRunningSlowly;
  1477. }
  1478. );
  1479. $.Method({Static:false, Public:true }, "get_TotalGameTime",
  1480. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.TimeSpan"), [], [])),
  1481. function get_TotalGameTime () {
  1482. return this.totalGameTime;
  1483. }
  1484. );
  1485. $.Method({Static:false, Public:true }, "get_ElapsedGameTime",
  1486. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.TimeSpan"), [], [])),
  1487. function get_ElapsedGameTime () {
  1488. return this.elapsedGameTime;
  1489. }
  1490. );
  1491. });
  1492. JSIL.ImplementExternals("Microsoft.Xna.Framework.Rectangle", function ($) {
  1493. $.RawMethod(true, ".cctor2", function () {
  1494. Microsoft.Xna.Framework.Rectangle._empty = new Microsoft.Xna.Framework.Rectangle();
  1495. });
  1496. $.Method({Static: true, Public: true}, "get_Empty",
  1497. new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), [], []),
  1498. function () {
  1499. return Microsoft.Xna.Framework.Rectangle._empty;
  1500. }
  1501. );
  1502. $.Method({Static:true , Public:true }, "op_Equality",
  1503. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1504. function op_Equality (lhs, rhs) {
  1505. return lhs.X === rhs.X && lhs.Y === rhs.Y && lhs.Width === rhs.Width && lhs.Height === rhs.Height;
  1506. }
  1507. );
  1508. $.Method({Static:true , Public:true }, "op_Inequality",
  1509. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1510. function op_Inequality (lhs, rhs) {
  1511. return lhs.X !== rhs.X || lhs.Y !== rhs.Y || lhs.Width !== rhs.Width || lhs.Height !== rhs.Height;
  1512. }
  1513. );
  1514. var intersectImpl = function (lhs, rhs) {
  1515. var lhsX2 = (lhs.X + lhs.Width) | 0;
  1516. var rhsX2 = (rhs.X + rhs.Width) | 0;
  1517. var lhsY2 = (lhs.Y + lhs.Height) | 0;
  1518. var rhsY2 = (rhs.Y + rhs.Height) | 0;
  1519. var x1 = (lhs.X > rhs.X) ? lhs.X : rhs.X;
  1520. var y1 = (lhs.Y > rhs.Y) ? lhs.Y : rhs.Y;
  1521. var x2 = (lhsX2 < rhsX2) ? lhsX2 : rhsX2;
  1522. var y2 = (lhsY2 < rhsY2) ? lhsY2 : rhsY2;
  1523. if (x2 > x1 && y2 > y1)
  1524. return new Microsoft.Xna.Framework.Rectangle(
  1525. x1 | 0, y1 | 0, (x2 - x1) | 0, (y2 - y1) | 0
  1526. );
  1527. return Microsoft.Xna.Framework.Rectangle._empty;
  1528. };
  1529. $.Method({Static:true , Public:true }, "Intersect",
  1530. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1531. intersectImpl
  1532. );
  1533. $.Method({Static:true , Public:true }, "Intersect",
  1534. (new JSIL.MethodSignature(null, [
  1535. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")]), $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")]),
  1536. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")])
  1537. ], [])),
  1538. function Intersect (/* ref */ value1, /* ref */ value2, /* ref */ result) {
  1539. result.set(intersectImpl(value1.get(), value2.get()));
  1540. }
  1541. );
  1542. var unionImpl = function (lhs, rhs) {
  1543. var lhsX2 = (lhs.X + lhs.Width) | 0;
  1544. var rhsX2 = (rhs.X + rhs.Width) | 0;
  1545. var lhsY2 = (lhs.Y + lhs.Height) | 0;
  1546. var rhsY2 = (rhs.Y + rhs.Height) | 0;
  1547. var x1 = (lhs.X < rhs.X) ? lhs.X : rhs.X;
  1548. var y1 = (lhs.Y < rhs.Y) ? lhs.Y : rhs.Y;
  1549. var x2 = (lhsX2 > rhsX2) ? lhsX2 : rhsX2;
  1550. var y2 = (lhsY2 > rhsY2) ? lhsY2 : rhsY2;
  1551. if (x2 > x1 && y2 > y1)
  1552. return new Microsoft.Xna.Framework.Rectangle(
  1553. x1 | 0, y1 | 0, (x2 - x1) | 0, (y2 - y1) | 0
  1554. );
  1555. return Microsoft.Xna.Framework.Rectangle._empty;
  1556. };
  1557. $.Method({Static:true , Public:true }, "Union",
  1558. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1559. unionImpl
  1560. );
  1561. $.Method({Static:true , Public:true }, "Union",
  1562. (new JSIL.MethodSignature(null, [
  1563. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")]), $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")]),
  1564. $jsilcore.TypeRef("JSIL.Reference", [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")])
  1565. ], [])),
  1566. function Union (/* ref */ value1, /* ref */ value2, /* ref */ result) {
  1567. result.set(unionImpl(value1.get(), value2.get()));
  1568. }
  1569. );
  1570. $.Method({Static:false, Public:true }, ".ctor",
  1571. (new JSIL.MethodSignature(null, [
  1572. $.Int32, $.Int32,
  1573. $.Int32, $.Int32
  1574. ], [])),
  1575. function _ctor (x, y, width, height) {
  1576. this.X = x | 0;
  1577. this.Y = y | 0;
  1578. this.Width = width | 0;
  1579. this.Height = height | 0;
  1580. }
  1581. );
  1582. $.RawMethod(false, "toString", function () {
  1583. return "{X:" + this.X + " Y:" + this.Y + " Width:" + this.Width + " Height:" + this.Height + "}";
  1584. });
  1585. $.Method({Static:false, Public:true }, "Contains",
  1586. (new JSIL.MethodSignature($.Boolean, [$.Int32, $.Int32], [])),
  1587. function Contains (x, y) {
  1588. return this.X <= x &&
  1589. x < ((this.X + this.Width) | 0) &&
  1590. this.Y <= y &&
  1591. y < ((this.Y + this.Height) | 0);
  1592. }
  1593. );
  1594. $.Method({Static:false, Public:true }, "ContainsPoint",
  1595. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1596. function ContainsPoint (value) {
  1597. return this.X <= value.X &&
  1598. value.X < ((this.X + this.Width) | 0) &&
  1599. this.Y <= value.Y &&
  1600. value.Y < ((this.Y + this.Height) | 0);
  1601. }
  1602. );
  1603. $.Method({Static:false, Public:true }, "ContainsRectangle",
  1604. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1605. function ContainsRectangle (value) {
  1606. return this.X <= value.X &&
  1607. ((value.X + value.Width) | 0) <= ((this.X + this.Width) | 0) &&
  1608. this.Y <= value.Y &&
  1609. ((value.Y + value.Height) | 0) <= ((this.Y + this.Height) | 0);
  1610. }
  1611. );
  1612. $.Method({Static:false, Public:true }, "get_Bottom",
  1613. (new JSIL.MethodSignature($.Int32, [], [])),
  1614. function get_Bottom () {
  1615. return (this.Y + this.Height) | 0;
  1616. }
  1617. );
  1618. $.Method({Static:false, Public:true }, "get_Center",
  1619. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point"), [], [])),
  1620. function get_Center () {
  1621. return new Microsoft.Xna.Framework.Point(
  1622. (this.X + (this.Width / 2)) | 0,
  1623. (this.Y + (this.Height / 2)) | 0
  1624. );
  1625. }
  1626. );
  1627. $.Method({Static:false, Public:true }, "get_Left",
  1628. (new JSIL.MethodSignature($.Int32, [], [])),
  1629. function get_Left () {
  1630. return this.X;
  1631. }
  1632. );
  1633. $.Method({Static:false, Public:true }, "get_Location",
  1634. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point"), [], [])),
  1635. function get_Location () {
  1636. return new Microsoft.Xna.Framework.Point(this.X, this.Y);
  1637. }
  1638. );
  1639. $.Method({Static:false, Public:true }, "get_Right",
  1640. (new JSIL.MethodSignature($.Int32, [], [])),
  1641. function get_Right () {
  1642. return (this.X + this.Width) | 0;
  1643. }
  1644. );
  1645. $.Method({Static:false, Public:true }, "get_Top",
  1646. (new JSIL.MethodSignature($.Int32, [], [])),
  1647. function get_Top () {
  1648. return this.Y;
  1649. }
  1650. );
  1651. $.Method({Static:false, Public:true }, "Inflate",
  1652. (new JSIL.MethodSignature(null, [$.Int32, $.Int32], [])),
  1653. function Inflate (x, y) {
  1654. this.X = (this.X - x) | 0;
  1655. this.Y = (this.Y - y) | 0;
  1656. this.Width = (this.Width + (x * 2)) | 0;
  1657. this.Height = (this.Height + (y * 2)) | 0;
  1658. }
  1659. );
  1660. $.Method({Static:false, Public:true }, "Intersects",
  1661. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle")], [])),
  1662. function Intersects (value) {
  1663. return value.X < ((this.X + this.Width) | 0) &&
  1664. this.X < ((value.X + value.Width) | 0) &&
  1665. value.Y < ((this.Y + this.Height) | 0) &&
  1666. this.Y < ((value.Y + value.Height) | 0);
  1667. }
  1668. );
  1669. $.Method({Static:false, Public:true }, "OffsetPoint",
  1670. (new JSIL.MethodSignature(null, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1671. function OffsetPoint (amount) {
  1672. this.X = (this.X + amount.X) | 0;
  1673. this.Y = (this.Y + amount.Y) | 0;
  1674. }
  1675. );
  1676. $.Method({Static:false, Public:true }, "Offset",
  1677. (new JSIL.MethodSignature(null, [$.Int32, $.Int32], [])),
  1678. function Offset (offsetX, offsetY) {
  1679. this.X = (this.X + offsetX) | 0;
  1680. this.Y = (this.Y + offsetY) | 0;
  1681. }
  1682. );
  1683. $.Method({Static:false, Public:true }, "set_Location",
  1684. (new JSIL.MethodSignature(null, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1685. function set_Location (value) {
  1686. this.X = value.X | 0;
  1687. this.Y = value.Y | 0;
  1688. return value;
  1689. }
  1690. );
  1691. });
  1692. JSIL.ImplementExternals("Microsoft.Xna.Framework.Point", function ($) {
  1693. $.RawMethod(true, ".cctor2", function () {
  1694. Microsoft.Xna.Framework.Point._zero = new Microsoft.Xna.Framework.Point();
  1695. });
  1696. $.Method({Static:true , Public:true }, "get_Zero",
  1697. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point"), [], [])),
  1698. function get_Zero () {
  1699. return Microsoft.Xna.Framework.Point._zero;
  1700. }
  1701. );
  1702. $.Method({Static:false, Public:true }, ".ctor",
  1703. (new JSIL.MethodSignature(null, [$.Int32, $.Int32], [])),
  1704. function _ctor (x, y) {
  1705. this.X = x | 0;
  1706. this.Y = y | 0;
  1707. }
  1708. );
  1709. var equalsImpl = function (lhs, rhs) {
  1710. return lhs.X === rhs.X && lhs.Y === rhs.Y;
  1711. };
  1712. $.Method({Static:true , Public:true }, "op_Equality",
  1713. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1714. equalsImpl
  1715. );
  1716. $.Method({Static:true , Public:true }, "op_Inequality",
  1717. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point"), $xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1718. function op_Inequality (a, b) {
  1719. return !equalsImpl(a, b);
  1720. }
  1721. );
  1722. $.Method({Static:false, Public:true }, "Object.Equals",
  1723. (new JSIL.MethodSignature($.Boolean, [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.Point")], [])),
  1724. function Equals (other) {
  1725. return equalsImpl(this, other);
  1726. }
  1727. );
  1728. });
  1729. $jsilxna.makeColor = function (proto, r, g, b, a) {
  1730. var result = JSIL.CreateInstanceObject(proto);
  1731. result.r = r;
  1732. result.g = g;
  1733. result.b = b;
  1734. if (typeof (a) === "number")
  1735. result.a = a;
  1736. else
  1737. result.a = 255;
  1738. return result;
  1739. };
  1740. $jsilxna.makeColorInstance = ( function () {
  1741. var tColor = null;
  1742. var ctor = null;
  1743. return function makeColorInstance () {
  1744. if (tColor === null) {
  1745. var typeName1 = JSIL.ParseTypeName("Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework");
  1746. var typeName2 = JSIL.ParseTypeName("Microsoft.Xna.Framework.Graphics.Color,Microsoft.Xna.Framework");
  1747. tColor = JSIL.GetTypeInternal(typeName1, $jsilxna, false) || JSIL.GetTypeInternal(typeName2, $jsilxna, false);
  1748. var prototype = tColor.__PublicInterface__.prototype;
  1749. ctor = function Color () {
  1750. };
  1751. ctor.prototype = prototype;
  1752. }
  1753. return new ctor();
  1754. }
  1755. })();
  1756. $jsilxna.ColorFromPremultipliedInts = function (result, r, g, b, a) {
  1757. if (!result)
  1758. result = $jsilxna.makeColorInstance();
  1759. result.r = $jsilxna.ClampByte(r);
  1760. result.g = $jsilxna.ClampByte(g);
  1761. result.b = $jsilxna.ClampByte(b);
  1762. if (arguments.length === 5)
  1763. result.a = $jsilxna.ClampByte(a);
  1764. else
  1765. result.a = 255;
  1766. return result;
  1767. };
  1768. $jsilxna.ColorFromPremultipliedFloats = function (result, r, g, b, a) {
  1769. if (!result)
  1770. result = $jsilxna.makeColorInstance();
  1771. result.r = $jsilxna.ClampByte(r * 255);
  1772. result.g = $jsilxna.ClampByte(g * 255);
  1773. result.b = $jsilxna.ClampByte(b * 255);
  1774. if (arguments.length === 5)
  1775. result.a = $jsilxna.ClampByte(a * 255);
  1776. else
  1777. result.a = 255;
  1778. return result;
  1779. };
  1780. $jsilxna.Color = function ($) {
  1781. (function BindColorExternals () {
  1782. var makeColor = $jsilxna.makeColor;
  1783. var colors = $jsilxna.colors || [];
  1784. var makeLazyColor = function (r, g, b, a) {
  1785. var state = null;
  1786. return function () {
  1787. if (state === null) {
  1788. state = $jsilxna.makeColorInstance();
  1789. state.a = a;
  1790. state.r = r;
  1791. state.g = g;
  1792. state.b = b;
  1793. }
  1794. return state;
  1795. };
  1796. };
  1797. for (var i = 0, l = colors.length; i < l; i++) {
  1798. var colorName = colors[i][0];
  1799. $.RawMethod(
  1800. true, "get_" + colorName, makeLazyColor(colors[i][1], colors[i][2], colors[i][3], colors[i][4])
  1801. );
  1802. }
  1803. }) ();
  1804. $.RawMethod(false, "__CopyMembers__", function Color_CopyMembers (source, target) {
  1805. target.a = source.a;
  1806. target.r = source.r;
  1807. target.g = source.g;
  1808. target.b = source.b;
  1809. });
  1810. $.RawMethod(true, ".cctor2", function () {
  1811. var self = this;
  1812. var proto = this.prototype;
  1813. var makeColor = $jsilxna.makeColor;
  1814. var colors = $jsilxna.colors || [];
  1815. var bindColor = function (c) {
  1816. return function () {
  1817. return c;
  1818. };
  1819. };
  1820. var typeName1 = JSIL.ParseTypeName("Microsoft.Xna.Framework.Color,Microsoft.Xna.Framework");
  1821. var typeName2 = JSIL.ParseTypeName("Microsoft.Xna.Framework.Graphics.Color,Microsoft.Xna.Framework");
  1822. var context = JSIL.GetTypeInternal(typeName1, $jsilxna, false) || JSIL.GetTypeInternal(typeName2, $jsilxna, false);
  1823. var publicInterface = context.__PublicInterface__;
  1824. for (var i = 0, l = colors.length; i < l; i++) {
  1825. var colorName = colors[i][0];
  1826. var color = makeColor(proto, colors[i][1], colors[i][2], colors[i][3], colors[i][4]);
  1827. var bound = bindColor(color);
  1828. Object.defineProperty(publicInterface, "get_" + colorName, {
  1829. value: bound,
  1830. enumerable: true,
  1831. configurable: true,
  1832. writable: false
  1833. });
  1834. Object.defineProperty(publicInterface, colorName, {
  1835. value: color,
  1836. enumerable: true,
  1837. configurable: true,
  1838. writable: false
  1839. });
  1840. }
  1841. });
  1842. var ctorRgba = function (_, r, g, b, a) {
  1843. _.a = a;
  1844. _.r = r;
  1845. _.g = g;
  1846. _.b = b;
  1847. };
  1848. var ctorRgbaFloat = function (_, r, g, b, a) {
  1849. _.a = $jsilxna.ClampByte(a * 255);
  1850. _.r = $jsilxna.ClampByte(r * 255);
  1851. _.g = $jsilxna.ClampByte(g * 255);
  1852. _.b = $jsilxna.ClampByte(b * 255);
  1853. };
  1854. $.Method({Static:false, Public:true }, ".ctor",
  1855. (new JSIL.MethodSignature(null, [
  1856. $.Int32, $.Int32,
  1857. $.Int32
  1858. ], [])),
  1859. function _ctor (r, g, b) {
  1860. ctorRgba(this, r, g, b, 255);
  1861. }
  1862. );
  1863. $.Method({Static:false, Public:true }, ".ctor",
  1864. (new JSIL.MethodSignature(null, [
  1865. $.Int32, $.Int32,
  1866. $.Int32, $.Int32
  1867. ], [])),
  1868. function _ctor (r, g, b, a) {
  1869. ctorRgba(this, r, g, b, a);
  1870. }
  1871. );
  1872. $.Method({Static:false, Public:true }, ".ctor",
  1873. (new JSIL.MethodSignature(null, [
  1874. $.Single, $.Single,
  1875. $.Single
  1876. ], [])),
  1877. function _ctor (r, g, b) {
  1878. ctorRgbaFloat(this, r, g, b, 1);
  1879. }
  1880. );
  1881. $.Method({Static:false, Public:true }, ".ctor",
  1882. (new JSIL.MethodSignature(null, [
  1883. $.Single, $.Single,
  1884. $.Single, $.Single
  1885. ], [])),
  1886. function _ctor (r, g, b, a) {
  1887. ctorRgbaFloat(this, r, g, b, a);
  1888. }
  1889. );
  1890. $.Method({
  1891. Static: false,
  1892. Public: true
  1893. }, ".ctor", new JSIL.MethodSignature(null, [$xnaasms.xna.TypeRef("Microsoft.Xna.Framework.Vector3")], []), function (v) {
  1894. ctorRgbaFloat(this, v.X, v.Y, v.Z, 1.0);
  1895. });
  1896. $.Method({
  1897. Static: false,
  1898. Public: true
  1899. }, ".ctor", new JSIL.MethodSignature(null, [$xnaasms.xna.TypeRef("Microsoft.Xna.Framework.Vector4")], []), function (v) {
  1900. ctorRgbaFloat(this, v.X, v.Y, v.Z, v.W);
  1901. });
  1902. $.Method({
  1903. Static: false,
  1904. Public: true
  1905. }, "get_A", new JSIL.MethodSignature($.Byte, [], []), function () {
  1906. return this.a;
  1907. });
  1908. $.Method({
  1909. Static: false,
  1910. Public: true
  1911. }, "get_B", new JSIL.MethodSignature($.Byte, [], []), function () {
  1912. return this.b;
  1913. });
  1914. $.Method({
  1915. Static: false,
  1916. Public: true
  1917. }, "get_G", new JSIL.MethodSignature($.Byte, [], []), function () {
  1918. return this.g;
  1919. });
  1920. $.Method({
  1921. Static: false,
  1922. Public: true
  1923. }, "get_R", new JSIL.MethodSignature($.Byte, [], []), function () {
  1924. return this.r;
  1925. });
  1926. $.Method({Static:false, Public:true }, "set_PackedValue",
  1927. (new JSIL.MethodSignature(null, [$.UInt32], [])),
  1928. function set_PackedValue (value) {
  1929. this._cachedCss = null;
  1930. this.a = (value >> 24) & 0xFF;
  1931. this.b = (value >> 16) & 0xFF;
  1932. this.g = (value >> 8) & 0xFF;
  1933. this.r = value & 0xFF;
  1934. }
  1935. );
  1936. $.Method({
  1937. Static: false,
  1938. Public: true
  1939. }, "set_A", new JSIL.MethodSignature(null, [$.Byte], []), function (value) {
  1940. this.a = $jsilxna.ClampByte(value);
  1941. this._cachedCss = null;
  1942. });
  1943. $.Method({
  1944. Static: false,
  1945. Public: true
  1946. }, "set_B", new JSIL.MethodSignature(null, [$.Byte], []), function (value) {
  1947. this.b = $jsilxna.ClampByte(value);
  1948. this._cachedCss = null;
  1949. });
  1950. $.Method({
  1951. Static: false,
  1952. Public: true
  1953. }, "set_G", new JSIL.MethodSignature(null, [$.Byte], []), function (value) {
  1954. this.g = $jsilxna.ClampByte(value);
  1955. this._cachedCss = null;
  1956. });
  1957. $.Method({
  1958. Static: false,
  1959. Public: true
  1960. }, "set_R", new JSIL.MethodSignature(null, [$.Byte], []), function (value) {
  1961. this.r = $jsilxna.ClampByte(value);
  1962. this._cachedCss = null;
  1963. });
  1964. var equalsImpl = function (lhs, rhs) {
  1965. return (lhs.r === rhs.r) && (lhs.g === rhs.g) &&
  1966. (lhs.b === rhs.b) && (lhs.a === rhs.a);
  1967. };
  1968. $.Method({Static:true , Public:true }, "op_Equality",
  1969. (new JSIL.MethodSignature($.Boolean, [$jsilxna.colorRef(), $jsilxna.colorRef()], [])),
  1970. function op_Equality (a, b) {
  1971. return equalsImpl(a, b);
  1972. }
  1973. );
  1974. $.Method({Static:true , Public:true }, "op_Inequality",
  1975. (new JSIL.MethodSignature($.Boolean, [$jsilxna.colorRef(), $jsilxna.colorRef()], [])),
  1976. function op_Inequality (a, b) {
  1977. return !equalsImpl(a, b);
  1978. }
  1979. );
  1980. $.Method({
  1981. Static: true,
  1982. Public: true
  1983. }, "op_Multiply", new JSIL.MethodSignature($jsilxna.colorRef(), [$jsilxna.colorRef(), $.Single], []), function (color, multiplier) {
  1984. var result = $jsilxna.makeColorInstance();
  1985. result.r = $jsilxna.ClampByte(color.r * multiplier);
  1986. result.g = $jsilxna.ClampByte(color.g * multiplier);
  1987. result.b = $jsilxna.ClampByte(color.b * multiplier);
  1988. result.a = $jsilxna.ClampByte(color.a * multiplier);
  1989. return result;
  1990. });
  1991. $.Method({
  1992. Static: true,
  1993. Public: true
  1994. }, "Lerp", new JSIL.MethodSignature($jsilxna.colorRef(), [$jsilxna.colorRef(), $jsilxna.colorRef(), $.Single], []),
  1995. function Color_Lerp (a, b, amount) {
  1996. var result = $jsilxna.makeColorInstance();
  1997. result.r = $jsilxna.ClampByte(a.r + (b.r - a.r) * amount);
  1998. result.g = $jsilxna.ClampByte(a.g + (b.g - a.g) * amount);
  1999. result.b = $jsilxna.ClampByte(a.b + (b.b - a.b) * amount);
  2000. result.a = $jsilxna.ClampByte(a.a + (b.a - a.a) * amount);
  2001. return result;
  2002. }
  2003. );
  2004. $.RawMethod(false, "toCss", function (alpha) {
  2005. if ((typeof(this._cachedCss) === "string") && (this._cachedAlpha === alpha)) {
  2006. return this._cachedCss;
  2007. }
  2008. var a = alpha || this.a;
  2009. if (a < 255) {
  2010. this._cachedAlpha = a;
  2011. return this._cachedCss = "rgba(" + this.r + "," + this.g + "," + this.b + "," + a + ")";
  2012. } else {
  2013. this._cachedAlpha = a;
  2014. return this._cachedCss = "rgb(" + this.r + "," + this.g + "," + this.b + ")";
  2015. }
  2016. });
  2017. $.Method({Static:true , Public:true }, "FromNonPremultiplied",
  2018. (new JSIL.MethodSignature($jsilxna.colorRef(), [$xnaasms.xna.TypeRef("Microsoft.Xna.Framework.Vector4")], [])),
  2019. function FromNonPremultiplied (vector) {
  2020. var result = $jsilxna.makeColorInstance();
  2021. result.r = $jsilxna.ClampByte(vector.X * 255);
  2022. result.g = $jsilxna.ClampByte(vector.Y * 255);
  2023. result.b = $jsilxna.ClampByte(vector.Z * 255);
  2024. result.a = $jsilxna.ClampByte(vector.W * 255);
  2025. return result;
  2026. }
  2027. );
  2028. $.Method({Static:true , Public:true }, "FromNonPremultiplied",
  2029. (new JSIL.MethodSignature($jsilxna.colorRef(), [
  2030. $.Int32, $.Int32,
  2031. $.Int32, $.Int32
  2032. ], [])),
  2033. function FromNonPremultiplied (r, g, b, a) {
  2034. var result = $jsilxna.makeColorInstance();
  2035. result.r = $jsilxna.ClampByte(r);
  2036. result.g = $jsilxna.ClampByte(g);
  2037. result.b = $jsilxna.ClampByte(b);
  2038. result.a = $jsilxna.ClampByte(a);
  2039. return result;
  2040. }
  2041. );
  2042. $.Method({Static:false, Public:true }, "ToVector4",
  2043. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Vector4"), [], [])),
  2044. function ToVector4 () {
  2045. return new Microsoft.Xna.Framework.Vector4(
  2046. this.r / 255,
  2047. this.g / 255,
  2048. this.b / 255,
  2049. this.a / 255
  2050. );
  2051. }
  2052. );
  2053. };
  2054. $jsilxna.ClampByte = function (v) {
  2055. v = (v | 0);
  2056. if (v < 0)
  2057. return 0;
  2058. else if (v > 255)
  2059. return 255;
  2060. else
  2061. return v;
  2062. };
  2063. (function () {
  2064. // XNA3 doesn't have a BlendState class, so we substitute one.
  2065. var graphicsAsm = JSIL.GetAssembly("Microsoft.Xna.Framework.Graphics", true);
  2066. if (graphicsAsm === null) {
  2067. JSIL.DeclareNamespace("Microsoft");
  2068. JSIL.DeclareNamespace("Microsoft.Xna");
  2069. JSIL.DeclareNamespace("Microsoft.Xna.Framework");
  2070. JSIL.DeclareNamespace("Microsoft.Xna.Framework.Graphics");
  2071. JSIL.MakeClass($jsilcore.TypeRef("System.Object"), "Microsoft.Xna.Framework.Graphics.BlendState", true, [], function ($) {
  2072. $.Field({Static:true , Public:true }, "Additive", $.Type, function ($) {
  2073. return null;
  2074. });
  2075. $.Field({Static:true , Public:true }, "AlphaBlend", $.Type, function ($) {
  2076. return null;
  2077. });
  2078. $.Field({Static:true , Public:true }, "NonPremultiplied", $.Type, function ($) {
  2079. return null;
  2080. });
  2081. $.Field({Static:true , Public:true }, "Opaque", $.Type, function ($) {
  2082. return null;
  2083. });
  2084. });
  2085. }
  2086. }) ();
  2087. JSIL.ImplementExternals("Microsoft.Xna.Framework.MathHelper", function ($) {
  2088. $.Method({Static:true , Public:true }, "Clamp",
  2089. (new JSIL.MethodSignature($.Single, [
  2090. $.Single, $.Single,
  2091. $.Single
  2092. ], [])),
  2093. function Clamp (value, min, max) {
  2094. if (max < min) max = min;
  2095. if (value < min)
  2096. return min;
  2097. else if (value > max)
  2098. return max;
  2099. else
  2100. return value;
  2101. }
  2102. );
  2103. $.Method({Static:true , Public:true }, "Lerp",
  2104. (new JSIL.MethodSignature($.Single, [
  2105. $.Single, $.Single,
  2106. $.Single
  2107. ], [])),
  2108. function Lerp (value1, value2, amount) {
  2109. return value1 + (value2 - value1) * amount;
  2110. }
  2111. );
  2112. $.Method({Static:true , Public:true }, "Max",
  2113. (new JSIL.MethodSignature($.Single, [$.Single, $.Single], [])),
  2114. Math.max
  2115. );
  2116. $.Method({Static:true , Public:true }, "Min",
  2117. (new JSIL.MethodSignature($.Single, [$.Single, $.Single], [])),
  2118. Math.min
  2119. );
  2120. $.Method({Static:true , Public:true }, "ToDegrees",
  2121. (new JSIL.MethodSignature($.Single, [$.Single], [])),
  2122. function ToDegrees (radians) {
  2123. return radians / (Math.PI / 180);
  2124. }
  2125. );
  2126. $.Method({Static:true , Public:true }, "ToRadians",
  2127. (new JSIL.MethodSignature($.Single, [$.Single], [])),
  2128. function ToRadians (degrees) {
  2129. return degrees * (Math.PI / 180);
  2130. }
  2131. );
  2132. $.Method({Static:true , Public:true }, "WrapAngle",
  2133. (new JSIL.MethodSignature($.Single, [$.Single], [])),
  2134. function WrapAngle (angle) {
  2135. var pi2 = Math.PI * 2;
  2136. angle = System.Math.IEEERemainder(angle, pi2);
  2137. if (angle <= -Math.PI)
  2138. angle += pi2;
  2139. else if (angle > Math.PI)
  2140. angle -= pi2;
  2141. return angle;
  2142. }
  2143. );
  2144. });
  2145. JSIL.ImplementExternals("Microsoft.Xna.Framework.TitleContainer", function ($) {
  2146. $.Method({Static:true , Public:true }, "OpenStream",
  2147. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IO.Stream"), [$.String], [])),
  2148. function OpenStream (name) {
  2149. return new System.IO.FileStream(name, System.IO.FileMode.Open);
  2150. }
  2151. );
  2152. });
  2153. JSIL.ImplementExternals("Microsoft.Xna.Framework.GamerServices.Gamer", function ($) {
  2154. var signedInGamers = null;
  2155. $.Method({Static:true , Public:true }, "get_SignedInGamers",
  2156. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.SignedInGamerCollection"), [], [])),
  2157. function get_SignedInGamers () {
  2158. // FIXME
  2159. if (signedInGamers === null)
  2160. signedInGamers = new $xnaasms[2].Microsoft.Xna.Framework.GamerServices.SignedInGamerCollection();
  2161. return signedInGamers;
  2162. }
  2163. );
  2164. $.Method({Static:false, Public:true }, "get_DisplayName",
  2165. (new JSIL.MethodSignature($.String, [], [])),
  2166. function get_DisplayName () {
  2167. // FIXME
  2168. return "Player";
  2169. }
  2170. );
  2171. $.Method({Static:false, Public:true }, "get_Gamertag",
  2172. (new JSIL.MethodSignature($.String, [], [])),
  2173. function get_Gamertag () {
  2174. // FIXME
  2175. return "Player";
  2176. }
  2177. );
  2178. });
  2179. JSIL.ImplementExternals("Microsoft.Xna.Framework.GamerServices.GamerCollection`1", function ($) {
  2180. $.Method({Static:false, Public:false}, ".ctor",
  2181. (JSIL.MethodSignature.Void),
  2182. function _ctor () {
  2183. // FIXME
  2184. this.gamer = new $xnaasms[2].Microsoft.Xna.Framework.GamerServices.SignedInGamer();
  2185. this.tEnumerator = JSIL.ArrayEnumerator.Of(this.T);
  2186. }
  2187. );
  2188. $.Method({Static:false, Public:true }, "GetEnumerator",
  2189. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.GamerCollection`1+GamerCollectionEnumerator", [new JSIL.GenericParameter("T", "Microsoft.Xna.Framework.GamerServices.GamerCollection`1")]), [], [])),
  2190. function GetEnumerator () {
  2191. return new (tEnumerator)([this.gamer]);
  2192. }
  2193. );
  2194. });
  2195. JSIL.ImplementExternals("Microsoft.Xna.Framework.GamerServices.SignedInGamerCollection", function ($) {
  2196. $.InheritDefaultConstructor();
  2197. $.Method({Static:false, Public:true }, "get_Item",
  2198. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.SignedInGamer"), [$xnaasms[0].TypeRef("Microsoft.Xna.Framework.PlayerIndex")], [])),
  2199. function get_Item (index) {
  2200. // FIXME
  2201. return this.gamer;
  2202. }
  2203. );
  2204. });
  2205. JSIL.ImplementExternals("Microsoft.Xna.Framework.GamerServices.SignedInGamer", function ($) {
  2206. $.Method({Static:false, Public:true }, "get_GameDefaults",
  2207. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.GameDefaults"), [], [])),
  2208. function get_GameDefaults () {
  2209. // FIXME
  2210. return null;
  2211. }
  2212. );
  2213. $.Method({Static:false, Public:true }, "get_IsGuest",
  2214. (new JSIL.MethodSignature($.Boolean, [], [])),
  2215. function get_IsGuest () {
  2216. // FIXME
  2217. return true;
  2218. }
  2219. );
  2220. $.Method({Static:false, Public:true }, "get_IsSignedInToLive",
  2221. (new JSIL.MethodSignature($.Boolean, [], [])),
  2222. function get_IsSignedInToLive () {
  2223. // FIXME
  2224. return false;
  2225. }
  2226. );
  2227. $.Method({Static:false, Public:true }, "get_PartySize",
  2228. (new JSIL.MethodSignature($.Int32, [], [])),
  2229. function get_PartySize () {
  2230. // FIXME
  2231. return 0;
  2232. }
  2233. );
  2234. $.Method({Static:false, Public:true }, "get_PlayerIndex",
  2235. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.PlayerIndex"), [], [])),
  2236. function get_PlayerIndex () {
  2237. // FIXME
  2238. return $xnaasms[0].Microsoft.Xna.Framework.PlayerIndex.One;
  2239. }
  2240. );
  2241. $.Method({Static:false, Public:true }, "get_Presence",
  2242. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.GamerPresence"), [], [])),
  2243. function get_Presence () {
  2244. // FIXME
  2245. return null;
  2246. }
  2247. );
  2248. $.Method({Static:false, Public:true }, "get_Privileges",
  2249. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.GamerPrivileges"), [], [])),
  2250. function get_Privileges () {
  2251. // FIXME
  2252. return null;
  2253. }
  2254. );
  2255. $.Method({Static:false, Public:true }, "GetAchievements",
  2256. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.AchievementCollection"), [], [])),
  2257. function GetAchievements () {
  2258. // FIXME
  2259. return null;
  2260. }
  2261. );
  2262. $.Method({Static:false, Public:true }, "GetFriends",
  2263. (new JSIL.MethodSignature($xnaasms[2].TypeRef("Microsoft.Xna.Framework.GamerServices.FriendCollection"), [], [])),
  2264. function GetFriends () {
  2265. // FIXME
  2266. return null;
  2267. }
  2268. );
  2269. });
  2270. JSIL.MakeClass("Microsoft.Xna.Framework.Graphics.DisplayMode", "CurrentDisplayMode", true, [], function ($) {
  2271. $.Method({Static:false, Public:true}, ".ctor",
  2272. (new JSIL.MethodSignature(null, [$.Object], [])),
  2273. function _ctor (device) {
  2274. this.device = device;
  2275. }
  2276. );
  2277. $.Method({Static:false, Public:true }, "get_AspectRatio",
  2278. (new JSIL.MethodSignature($.Single, [], [])),
  2279. function get_AspectRatio () {
  2280. throw new Error('Not implemented');
  2281. }
  2282. );
  2283. $.Method({Static:false, Public:true }, "get_Format",
  2284. (new JSIL.MethodSignature(getXnaGraphics().TypeRef("Microsoft.Xna.Framework.Graphics.SurfaceFormat"), [], [])),
  2285. function get_Format () {
  2286. return Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color;
  2287. }
  2288. );
  2289. $.Method({Static:false, Public:true }, "get_Height",
  2290. (new JSIL.MethodSignature($.Int32, [], [])),
  2291. function get_Height () {
  2292. return this.device.canvas.height;
  2293. }
  2294. );
  2295. $.Method({Static:false, Public:true }, "get_TitleSafeArea",
  2296. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), [], [])),
  2297. function get_TitleSafeArea () {
  2298. throw new Error('Not implemented');
  2299. }
  2300. );
  2301. $.Method({Static:false, Public:true }, "get_Width",
  2302. (new JSIL.MethodSignature($.Int32, [], [])),
  2303. function get_Width () {
  2304. return this.device.canvas.width;
  2305. }
  2306. );
  2307. });
  2308. JSIL.ImplementExternals("Microsoft.Xna.Framework.Storage.StorageDevice", function ($) {
  2309. $.Method({Static:false, Public:false}, ".ctor",
  2310. (new JSIL.MethodSignature(null, [$.UInt32, $xnaasms[0].TypeRef("Microsoft.Xna.Framework.PlayerIndex")], [])),
  2311. function _ctor (deviceIndex, playerIndex) {
  2312. this.deviceIndex = deviceIndex;
  2313. this.playerIndex = playerIndex;
  2314. }
  2315. );
  2316. $.Method({Static:false, Public:false}, ".ctor",
  2317. (new JSIL.MethodSignature(null, [$.UInt32], [])),
  2318. function _ctor (deviceIndex) {
  2319. this.deviceIndex = deviceIndex;
  2320. }
  2321. );
  2322. $.Method({Static:true , Public:true }, "add_DeviceChanged",
  2323. (new JSIL.MethodSignature(null, [$xnaasms[5].TypeRef("System.EventHandler`1", [$xnaasms[5].TypeRef("System.EventArgs")])], [])),
  2324. function add_DeviceChanged (value) {
  2325. throw new Error('Not implemented');
  2326. }
  2327. );
  2328. var callAsyncCallback = function (callback, state, data) {
  2329. var asyncResult = new JSIL.FakeAsyncResult(state);
  2330. asyncResult.data = data;
  2331. if (typeof (callback) === "function")
  2332. callback(asyncResult);
  2333. return asyncResult;
  2334. };
  2335. $.Method({Static:false, Public:true }, "BeginOpenContainer",
  2336. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IAsyncResult"), [
  2337. $.String, $xnaasms[5].TypeRef("System.AsyncCallback"),
  2338. $.Object
  2339. ], [])),
  2340. function BeginOpenContainer (displayName, callback, state) {
  2341. return callAsyncCallback(callback, state, {device: this, displayName: displayName});
  2342. }
  2343. );
  2344. $.Method({Static:true , Public:true }, "BeginShowSelector",
  2345. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IAsyncResult"), [
  2346. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.PlayerIndex"), $xnaasms[5].TypeRef("System.AsyncCallback"),
  2347. $.Object
  2348. ], [])),
  2349. function BeginShowSelector (player, callback, state) {
  2350. return callAsyncCallback(callback, state, {player: player});
  2351. }
  2352. );
  2353. $.Method({Static:true , Public:true }, "BeginShowSelector",
  2354. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IAsyncResult"), [
  2355. $xnaasms[0].TypeRef("Microsoft.Xna.Framework.PlayerIndex"), $.Int32,
  2356. $.Int32, $xnaasms[5].TypeRef("System.AsyncCallback"),
  2357. $.Object
  2358. ], [])),
  2359. function BeginShowSelector (player, sizeInBytes, directoryCount, callback, state) {
  2360. return callAsyncCallback(callback, state, {player: player});
  2361. }
  2362. );
  2363. $.Method({Static:true , Public:true }, "BeginShowSelector",
  2364. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IAsyncResult"), [$xnaasms[5].TypeRef("System.AsyncCallback"), $.Object], [])),
  2365. function BeginShowSelector (callback, state) {
  2366. return callAsyncCallback(callback, state, {});
  2367. }
  2368. );
  2369. $.Method({Static:true , Public:true }, "BeginShowSelector",
  2370. (new JSIL.MethodSignature($xnaasms[5].TypeRef("System.IAsyncResult"), [
  2371. $.Int32, $.Int32,
  2372. $xnaasms[5].TypeRef("System.AsyncCallback"), $.Object
  2373. ], [])),
  2374. function BeginShowSelector (sizeInBytes, directoryCount, callback, state) {
  2375. return callAsyncCallback(callback, state, {});
  2376. }
  2377. );
  2378. $.Method({Static:false, Public:true }, "DeleteContainer",
  2379. (new JSIL.MethodSignature(null, [$.String], [])),
  2380. function DeleteContainer (titleName) {
  2381. throw new Error('Not implemented');
  2382. }
  2383. );
  2384. $.Method({Static:false, Public:true }, "EndOpenContainer",
  2385. (new JSIL.MethodSignature(getXnaStorage().TypeRef("Microsoft.Xna.Framework.Storage.StorageContainer"), [$xnaasms[5].TypeRef("System.IAsyncResult")], [])),
  2386. function EndOpenContainer (result) {
  2387. return new Microsoft.Xna.Framework.Storage.StorageContainer(
  2388. result.data.device, 0, result.data.displayName
  2389. );
  2390. }
  2391. );
  2392. $.Method({Static:true , Public:true }, "EndShowSelector",
  2393. (new JSIL.MethodSignature(getXnaStorage().TypeRef("Microsoft.Xna.Framework.Storage.StorageDevice"), [$xnaasms[5].TypeRef("System.IAsyncResult")], [])),
  2394. function EndShowSelector (result) {
  2395. return new Microsoft.Xna.Framework.Storage.StorageDevice(
  2396. 0, result.data.player || 0
  2397. );
  2398. }
  2399. );
  2400. $.Method({Static:false, Public:true }, "get_FreeSpace",
  2401. (new JSIL.MethodSignature($.Int64, [], [])),
  2402. function get_FreeSpace () {
  2403. throw new Error('Not implemented');
  2404. }
  2405. );
  2406. $.Method({Static:false, Public:true }, "get_IsConnected",
  2407. (new JSIL.MethodSignature($.Boolean, [], [])),
  2408. function get_IsConnected () {
  2409. return true;
  2410. }
  2411. );
  2412. $.Method({Static:false, Public:true }, "get_TotalSpace",
  2413. (new JSIL.MethodSignature($.Int64, [], [])),
  2414. function get_TotalSpace () {
  2415. throw new Error('Not implemented');
  2416. }
  2417. );
  2418. $.Method({Static:true , Public:false}, "OnDeviceChanged",
  2419. (new JSIL.MethodSignature(null, [$.Object, $xnaasms[5].TypeRef("System.EventArgs")], [])),
  2420. function OnDeviceChanged (sender, args) {
  2421. throw new Error('Not implemented');
  2422. }
  2423. );
  2424. $.Method({Static:true , Public:true }, "remove_DeviceChanged",
  2425. (new JSIL.MethodSignature(null, [$xnaasms[5].TypeRef("System.EventHandler`1", [$xnaasms[5].TypeRef("System.EventArgs")])], [])),
  2426. function remove_DeviceChanged (value) {
  2427. throw new Error('Not implemented');
  2428. }
  2429. );
  2430. });
  2431. JSIL.ImplementExternals("Microsoft.Xna.Framework.GameWindow", function ($) {
  2432. $.Method({Static:false, Public:false}, ".ctor",
  2433. (JSIL.MethodSignature.Void),
  2434. function _ctor () {
  2435. var canvas = JSIL.Host.getCanvas();
  2436. this._clientBounds = new Microsoft.Xna.Framework.Rectangle(
  2437. 0, 0, canvas.width | 0, canvas.height | 0
  2438. );
  2439. }
  2440. );
  2441. $.Method({Static:false, Public:true }, "get_ClientBounds",
  2442. (new JSIL.MethodSignature($xnaasms[0].TypeRef("Microsoft.Xna.Framework.Rectangle"), [], [])),
  2443. function get_ClientBounds () {
  2444. var canvas = JSIL.Host.getCanvas();
  2445. this._clientBounds._ctor(
  2446. 0, 0, canvas.width, canvas.height
  2447. );
  2448. return this._clientBounds;
  2449. }
  2450. );
  2451. $.Method({Static:false, Public:false}, "get_IsMinimized",
  2452. (new JSIL.MethodSignature($.Boolean, [], [])),
  2453. function get_IsMinimized () {
  2454. // FIXME
  2455. return false;
  2456. }
  2457. );
  2458. $.Method({Static:false, Public:true }, "get_Title",
  2459. (new JSIL.MethodSignature($.String, [], [])),
  2460. function get_Title () {
  2461. // FIXME
  2462. return document.title;
  2463. }
  2464. );
  2465. $.Method({Static:false, Public:false}, "get_Handle",
  2466. (new JSIL.MethodSignature($jsilcore.TypeRef("System.IntPtr"), [], [])),
  2467. function get_Handle () {
  2468. // FIXME
  2469. return null;
  2470. }
  2471. );
  2472. $.Method({Static:false, Public:true }, "set_AllowUserResizing",
  2473. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  2474. function set_AllowUserResizing (value) {
  2475. // FIXME
  2476. }
  2477. );
  2478. $.Method({Static:false, Public:true }, "set_Title",
  2479. (new JSIL.MethodSignature(null, [$.String], [])),
  2480. function set_Title (value) {
  2481. document.title = value;
  2482. }
  2483. );
  2484. });
  2485. JSIL.ImplementExternals("Microsoft.Xna.Framework.GamerServices.Guide", function ($) {
  2486. $.Method({Static:true , Public:true }, "get_IsScreenSaverEnabled",
  2487. (new JSIL.MethodSignature($.Boolean, [], [])),
  2488. function get_IsScreenSaverEnabled () {
  2489. // FIXME
  2490. }
  2491. );
  2492. $.Method({Static:true , Public:true }, "get_IsTrialMode",
  2493. (new JSIL.MethodSignature($.Boolean, [], [])),
  2494. function get_IsTrialMode () {
  2495. // FIXME
  2496. return false;
  2497. }
  2498. );
  2499. $.Method({Static:true , Public:true }, "get_IsVisible",
  2500. (new JSIL.MethodSignature($.Boolean, [], [])),
  2501. function get_IsVisible () {
  2502. // FIXME
  2503. return false;
  2504. }
  2505. );
  2506. $.Method({Static:true , Public:false}, "get_IsVisibleNoThrow",
  2507. (new JSIL.MethodSignature($.Boolean, [], [])),
  2508. function get_IsVisibleNoThrow () {
  2509. // FIXME
  2510. return false;
  2511. }
  2512. );
  2513. $.Method({Static:true , Public:true }, "get_SimulateTrialMode",
  2514. (new JSIL.MethodSignature($.Boolean, [], [])),
  2515. function get_SimulateTrialMode () {
  2516. // FIXME
  2517. }
  2518. );
  2519. $.Method({Static:true , Public:false}, "set_IsTrialMode",
  2520. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  2521. function set_IsTrialMode (value) {
  2522. // FIXME
  2523. }
  2524. );
  2525. $.Method({Static:true , Public:false}, "set_IsVisible",
  2526. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  2527. function set_IsVisible (value) {
  2528. // FIXME
  2529. }
  2530. );
  2531. $.Method({Static:true , Public:true }, "set_SimulateTrialMode",
  2532. (new JSIL.MethodSignature(null, [$.Boolean], [])),
  2533. function set_SimulateTrialMode (value) {
  2534. // FIXME
  2535. }
  2536. );
  2537. });
  2538. JSIL.ImplementExternals("Microsoft.Xna.Framework.GameServiceContainer", function ($) {
  2539. $.Method({Static:false, Public:true }, ".ctor",
  2540. (JSIL.MethodSignature.Void),
  2541. function _ctor () {
  2542. this._services = {};
  2543. }
  2544. );
  2545. $.Method({Static:false, Public:true }, "AddService",
  2546. (new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Type"), $.Object], [])),
  2547. function AddService (type, provider) {
  2548. this._services[type.__TypeId__] = provider;
  2549. }
  2550. );
  2551. $.Method({Static:false, Public:true }, "GetService",
  2552. (new JSIL.MethodSignature($.Object, [$jsilcore.TypeRef("System.Type")], [])),
  2553. function GetService (type) {
  2554. var result = this._services[type.__TypeId__];
  2555. if (!result)
  2556. return null;
  2557. else
  2558. return result;
  2559. }
  2560. );
  2561. $.Method({Static:false, Public:true }, "RemoveService",
  2562. (new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Type")], [])),
  2563. function RemoveService (type) {
  2564. delete this._services[type.__TypeId__];
  2565. }
  2566. );
  2567. });
  2568. JSIL.MakeClass("System.Object", "JSIL.FakeAsyncResult", true, [], function ($interfaceBuilder) {
  2569. var $ = $interfaceBuilder;
  2570. $.RawMethod(false, ".ctor", function (state) {
  2571. this._state = state;
  2572. });
  2573. $.Method({Static:false, Public:true , Virtual:true }, "get_AsyncState",
  2574. new JSIL.MethodSignature($.Object, [], []),
  2575. function () {
  2576. return this._state;
  2577. }
  2578. );
  2579. $.Method({Static:false, Public:true , Virtual:true }, "get_AsyncWaitHandle",
  2580. new JSIL.MethodSignature($jsilcore.TypeRef("System.Threading.WaitHandle"), [], []),
  2581. function () {
  2582. return new JSIL.FakeWaitHandle();
  2583. }
  2584. );
  2585. $.Method({Static:false, Public:true , Virtual:true }, "get_CompletedSynchronously",
  2586. new JSIL.MethodSignature($.Boolean, [], []),
  2587. function () {
  2588. return true;
  2589. }
  2590. );
  2591. $.Method({Static:false, Public:true , Virtual:true }, "get_IsCompleted",
  2592. new JSIL.MethodSignature($.Boolean, [], []),
  2593. function () {
  2594. return true;
  2595. }
  2596. );
  2597. $.Property({Static:false, Public:true , Virtual:true }, "IsCompleted", $.Boolean);
  2598. $.Property({Static:false, Public:true , Virtual:true }, "AsyncWaitHandle", $jsilcore.TypeRef("System.Threading.WaitHandle"));
  2599. $.Property({Static:false, Public:true , Virtual:true }, "AsyncState", $.Object);
  2600. $.Property({Static:false, Public:true , Virtual:true }, "CompletedSynchronously", $.Boolean);
  2601. $.ImplementInterfaces(
  2602. /* 0 */ $jsilcore.TypeRef("System.IAsyncResult")
  2603. );
  2604. });
  2605. JSIL.MakeClass("System.Object", "JSIL.FakeWaitHandle", true, [], function ($interfaceBuilder) {
  2606. var $ = $interfaceBuilder;
  2607. $.Method({Static:false, Public:true , Virtual:true }, "Close",
  2608. JSIL.MethodSignature.Void,
  2609. function Close () {
  2610. }
  2611. );
  2612. $.Method({Static:false, Public:true , Virtual:true }, "Dispose",
  2613. JSIL.MethodSignature.Void,
  2614. function Dispose () {
  2615. }
  2616. );
  2617. $.Method({Static:false, Public:true , Virtual:true }, "WaitOne",
  2618. new JSIL.MethodSignature($.Boolean, [$.Int32, $.Boolean], []),
  2619. function WaitOne (millisecondsTimeout, exitContext) {
  2620. }
  2621. );
  2622. $.Method({Static:false, Public:true , Virtual:true }, "WaitOne",
  2623. new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("System.TimeSpan"), $.Boolean], []),
  2624. function WaitOne (timeout, exitContext) {
  2625. }
  2626. );
  2627. $.Method({Static:false, Public:true , Virtual:true }, "WaitOne",
  2628. new JSIL.MethodSignature($.Boolean, [], []),
  2629. function WaitOne () {
  2630. }
  2631. );
  2632. $.Method({Static:false, Public:true , Virtual:true }, "WaitOne",
  2633. new JSIL.MethodSignature($.Boolean, [$.Int32], []),
  2634. function WaitOne (millisecondsTimeout) {
  2635. }
  2636. );
  2637. $.Method({Static:false, Public:true , Virtual:true }, "WaitOne",
  2638. new JSIL.MethodSignature($.Boolean, [$jsilcore.TypeRef("System.TimeSpan")], []),
  2639. function WaitOne (timeout) {
  2640. }
  2641. );
  2642. $.Method({Static:false, Public:false}, "WaitOne",
  2643. new JSIL.MethodSignature($.Boolean, [$.Int64, $.Boolean], []),
  2644. function WaitOne (timeout, exitContext) {
  2645. throw new Error('Not implemented');
  2646. }
  2647. );
  2648. $.ImplementInterfaces(
  2649. /* 0 */ $jsilcore.TypeRef("System.IDisposable")
  2650. );
  2651. });
  2652. JSIL.ImplementExternals(
  2653. "Microsoft.Xna.Framework.Color", $jsilxna.Color
  2654. );