Color Coding for Planets.nu

Color codes planets and ships by race on Planets.nu map

目前为 2016-05-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Color Coding for Planets.nu
  3. // @description Color codes planets and ships by race on Planets.nu map
  4. // @include http://play.planets.nu/*
  5. // @include http://test.planets.nu/*
  6. // @include http://planets.nu/*
  7. // @version 2.3.2
  8. // @namespace https://greasyfork.org/users/2860
  9. // ==/UserScript==
  10.  
  11. // 1. Color codes planets and ships by race on Planets.nu map
  12. // 2. v0.5 - now activates or deactivates from Settings screen!
  13. // 3. v0.7 - now activates or deactivates default color for user from Settings screen
  14. // 4. v0.81 - now saves settings for the user to a cookie, when changed from the Settings Screen
  15. // 5. v0.90 - First 11 race colors, unknown planets, and unoccupied planets now configurable from Settings Screen!
  16. // 6. v1.0 - Fully functional! Uses color gradient for all planets. Displays color gradiant on Settings Screen (FF only, will tackle Chrome later)
  17. // 7. v1.1 - Chrome and FF color preview. Gradient colors for standard game races, info, and unknown
  18. // 8. v1.2 - Redraws colors on maps after any setting changes. Different sized circles around planets for Own Ships, Ally, and Enemy. Own ships will always have correct color
  19. // 9. v1.3 - rewrote Settings changes to play nicely with other mods.
  20. // 10.v1.4 - added in support for users changing colors beyond race 11 (settings page does not refresh, so hit the settings button again to see the changes).
  21. // 11.v1.5,1.51 - added support for new play.planets.nu client
  22. // 12.v1.6 - New note colors that match the mod.
  23. // 13.v1.61 - added support for new planets urls
  24. // 14.v1.7 - Adds planets v3 API support
  25. // 15.v1.81 - Now shows ship names with explosions (formerly a separate script). Fixed colors in the diplomacy screen color picker (if you ever want to use this with the mod).
  26. // 16.v1.9 - Graphics change for cloaked ships on map
  27. // 17.v2.0 - Split from codebase for original planets.nu implementation
  28. // 18.v2.1 - Fixes multiple bugs. Minefields laid in other races name are displayed with the Unknown Owner color (previously would not work with color mod).
  29. // 19.v2.11 - Fixes bug which results in allied ships not appearing properly around planets
  30. // 20.v2.12 - Imports performance improving changes from planets.nu UI - should fix misc bugs and improve performance
  31. // 21.v2.2 - Option to use Color Picker colors. New button to reset note colors to blank.
  32. // 22.v2.21 - changed include so doesn't run on old client
  33. // 23.v2.22,v.2.24 - updated to work with Sphere
  34. // 24.v2.3 - Modifies mouse-over text for minefields so you can tell if web or regular minefield
  35. // 25.v2.3.1 - Minor fixes
  36. // 26.v2.3.2 - fixes compatibility issues with new planets.nu features
  37. function wrapper () { // wrapper for injection
  38. //var colors = ["white", "Green", "Crimson", "HotPink", "Lime", "Magenta", "Yellow", "Purple", "Gray", "Cyan", "Blue", "mediumslateblue", "sienna", "skyblue", "tomato","wheat", "lightcoral", "darkslategray", "teal", "firebrick", "olive", "mediumpurple", "lime", "indigo", "tan", "yellowgreen", "goldenrod", "aliceblue", "olivedrab", "orangered"];
  39.  
  40. var colorsA =["#F0F8FF","#32CD32","#CD5C5C","#FFC0CB","#98FB98","#C0C0C0","#FFFF00","#EE82EE","#D3D3D3","#B0E0E6","#87CEFA","#7B68EE","#F4A460","#D2B48C","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  41. var colorsA2 =["#FFFFFF","#006400","#FF0000","#FF69B4","#00FA9A","#6A5ACD","#FFD700","#9400D3","#808080","#00CED1","#4169E1","#7B68EE","#A0522D","#87CEEB","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  42.  
  43. var modInfo="#F4A460";//chocolate
  44. var modInfo2="#D2691E";//chocolate
  45.  
  46. var modUnknown="#FFF8DC"; //Tan
  47. var modUnknown2="#D2B48C"; //Tan
  48. var modRace=12;
  49. var useColorPicker=0;
  50.  
  51. // Fed - White
  52. // Lizard - Green
  53. // Birds - Crimson
  54. // Fascists - Pink
  55. // Privateers - Lime
  56. // Cyborg - Magenta
  57. // Crystals - Yellow
  58. // Empire - Purple
  59. // Robots - Gray
  60. // Rebels - Aqua
  61. // Colonies - Blue
  62.  
  63. var activeColorMod=null;//default true
  64. var defaultMyColor=null;//default true
  65. var useCustomColor=false;//have we checked Cookie
  66. var firstLoad=true;
  67.  
  68.  
  69. var oldShow = geoSimpleColorPicker.prototype.show;
  70.  
  71.  
  72. geoSimpleColorPicker.prototype.show = function (targetId, callback) {
  73. if (activeColorMod==false)
  74. {
  75. oldShow.apply(this,arguments);
  76. }
  77. else
  78. {
  79. this.picker = $("<div style='position:absolute;background-color:#000;padding:4px;z-index:999;'></div>").hide().appendTo("body");
  80. this.target = $("#" + targetId);
  81. this.callback = callback;
  82. //colors table
  83. var objX = new Array('00', '33', '66', '99', 'CC', 'FF');
  84. html = '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  85. var br = 1;
  86. for (o = 0; o < 6; o++) {
  87. html += '</tr><tr>';
  88. for (y = 0; y < 6; y++) {
  89. if (y == 3) { html += '</tr><tr>'; }
  90. for (x = 0; x < 6; x++) {
  91. var grid = objX[o] + objX[y] + objX[x];
  92. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  93. }
  94. }
  95. }
  96. html += '</tr></table>';
  97.  
  98. //greys table
  99. var objX = new Array('0', '3', '6', '9', 'C', 'F');
  100. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  101. var br = 0;
  102. for (y = 0; y < 6; y++) {
  103. for (x = 0; x < 6; x++) {
  104. if (br == 18) {
  105. br = 0;
  106. html += '</tr><tr>';
  107. }
  108. br++;
  109. var grid = objX[y] + objX[x] + objX[y] + objX[x] + objX[y] + objX[x];
  110. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  111. }
  112. }
  113. html += "</tr></table>";
  114. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  115. var br = 0;
  116. for (y = 0; y < 2; y++) {
  117. for (x = 0; x < 10; x++) {
  118. if (br == 10) {
  119. br = 0;
  120. html += '</tr><tr>';
  121. }
  122. br++;
  123. var grid;
  124. if (y==0)
  125. {
  126. if (colorsA[x].charAt(0)=='#')
  127. grid = colorsA[x].substring(1,colorsA.length);
  128. else
  129. grid = colorsA[x];
  130. }
  131. else
  132. {
  133. if (colorsA2[x].charAt(0)=='#')
  134. grid = colorsA2[x].substring(1,colorsA2.length);
  135. else
  136. grid = colorsA2[x];
  137. }
  138. html += '<td><div title="#' + grid + '" onclick="colorPicker.selectColor(\'' + grid + '\');" style="cursor:pointer;margin: 1px;width:20px;height:20px;background-color:#' + grid + '"></div></td>';
  139. }
  140. }
  141. html += '<table bgcolor="#000" border="0" cellpadding="0" cellspacing="0" style="padding:2px;"><tr>';
  142. html += '<td><div title="clear" onclick="colorPicker.selectColor(\'clear\');" style="cursor:pointer;margin: 1px;width:80px;height:20px;text-align:center;border: solid 1px #fff;color: #fff;">CLEAR</div></td>';
  143. html += "</tr></table>";
  144. this.picker.css("left", this.target.offset().left);
  145. this.picker.css("top", this.target.offset().top + this.target.height() + 10);
  146. this.picker.html(html);
  147. if (vgaPlanets.prototype.version>=3)
  148. $(".cpselect").tclick(function () { colorPicker.selectColor($(this).data("color")); });
  149. this.picker.show();
  150. }
  151. };
  152.  
  153. // vgap3.js functions
  154.  
  155.  
  156. var oldDraw = vgapMap.prototype.draw;
  157.  
  158. vgapMap.prototype.draw = function (fast, ctx, skipUserContent, secondCanvas) {
  159.  
  160. //check Color Mod Settings
  161. checkColorModSettings();
  162. if ((activeColorMod==false)||(vgaPlanets.prototype.version<3))
  163. {
  164. oldDraw.apply(this,arguments);
  165. }
  166. else
  167. {
  168. if (drawing)
  169. return;
  170. //remove planet names (and re-add at the end)
  171. $(".PlanetName").remove();
  172. $(".Pin").remove();
  173. this.startdrawtime = new Date;
  174.  
  175. if (!ctx && fast) {
  176. this.drawFromSecond();
  177. this.showDrawTime(fast);
  178. return;
  179. }
  180.  
  181. //if (!ctx && fast && this.spritecache().tiles) {
  182. // this.drawFromTiles();
  183. // this.showDrawTime(fast);
  184. // return;
  185. //}
  186.  
  187. var drawing = true;
  188.  
  189. var fullrender = true;
  190. if (fast)
  191. fullrender = false;
  192.  
  193. var sets = vgap.accountsettings;
  194. var drawUserContent = true;
  195. if (skipUserContent)
  196. drawUserContent = false;
  197.  
  198. if (!ctx)
  199. ctx = this.ctx;
  200.  
  201.  
  202. ctx.fillStyle = "#000000";
  203. ctx.clearRect(0, 0, vgap.map.canvas.width, vgap.map.canvas.height);
  204. if (vgap.settings.isacademy) {
  205. var x = this.screenX(2000);
  206. var y = this.screenY(2000);
  207. var r = Math.ceil(vgap.settings.mapwidth) * this.zoom;
  208. var grad = ctx.createRadialGradient(x, y, 0, x, y, r);
  209. var a = (5 - Math.sqrt(Math.sqrt(this.zoom))) / 5;
  210. grad.addColorStop(0, "rgba(50, 25, 25, " + a + ")");
  211. grad.addColorStop(1, "rgba(50, 50, 25, 0)");
  212. ctx.fillStyle = grad;
  213.  
  214. ctx.beginPath();
  215. ctx.arc(x, y, r, 0, Math.PI * 2, false);
  216. ctx.closePath();
  217. ctx.fill();
  218. //console.log(a);
  219. }
  220. if (this.activeShip) {
  221. vgap.shipScreen.predraw();
  222. }
  223. //Debris Disk stroke
  224. if (vgap.map.zoom >= 5 && fullrender) {
  225. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  226.  
  227. var planet = vgap.debrisdisks[i];
  228. var rad = planet.debrisdisk * vgap.map.zoom;
  229.  
  230. var visible = this.isVisible(planet.x, planet.y, planet.debrisdisk);
  231.  
  232. //if on this canvas
  233. if (visible) {
  234.  
  235. //draw rings
  236. var screenX = this.screenX(planet.x);
  237. var screenY = this.screenY(planet.y);
  238.  
  239. var color = "#ffffff";
  240. ctx.strokeStyle = colorToRGBA(color, 0.1);
  241. ctx.lineWidth = 2;
  242.  
  243. ctx.beginPath();
  244. ctx.arc(screenX, screenY, rad, 0, Math.PI * 2, false);
  245. ctx.closePath();
  246. ctx.stroke();
  247. }
  248. }
  249. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  250. var planet = vgap.debrisdisks[i];
  251. var rad = planet.debrisdisk * vgap.map.zoom - 2;
  252.  
  253. var visible = this.isVisible(planet.x, planet.y, planet.debrisdisk);
  254.  
  255. //if on this canvas
  256. if (visible) {
  257.  
  258. //draw centers
  259. var screenX = this.screenX(planet.x);
  260. var screenY = this.screenY(planet.y);
  261.  
  262. //blank centers (for overlapping circles)
  263. ctx.fillStyle = "#111111";
  264. ctx.beginPath();
  265. ctx.arc(screenX, screenY, rad, 0, Math.PI * 2, false);
  266. ctx.closePath();
  267. ctx.fill();
  268. }
  269. }
  270. }
  271.  
  272. //draw full detail grid
  273. var drawgrid = vgap.map.zoom >= 40;
  274. if (vgap.settings.isacademy)
  275. drawgrid = vgap.map.zoom >= 30;
  276. if (drawgrid && fullrender) {
  277.  
  278. ctx.strokeStyle = "#222";
  279. ctx.lineWidth = 1;
  280.  
  281. var gridsize = vgap.map.canvas.width / vgap.map.canvas.mapwidth;
  282. var srad = gridsize / 2;
  283. var x = Math.floor(vgap.map.canvas.x);
  284. for (var i = 0; i <= (vgap.map.canvas.mapwidth + 1) ; i++) {
  285. var y = Math.floor(vgap.map.canvas.y);
  286. for (var j = 0; j <= (vgap.map.canvas.mapheight + 1) ; j++) {
  287. var screenX = this.screenX(x);
  288. var screenY = this.screenY(y);
  289. ctx.strokeRect(screenX - srad, screenY - srad, srad * 2, srad * 2);
  290. ctx.strokeRect(screenX - 1, screenY - 1, 2, 2);
  291. y++;
  292. }
  293. x++;
  294. }
  295. }
  296.  
  297. if (vgap.settings.sphere && vgap.accountsettings.sphereborder)
  298. {
  299. ctx.strokeStyle = "#222";
  300. ctx.lineWidth = 1;
  301. ctx.strokeRect(this.screenX(2000 - vgap.settings.mapwidth/2 - 10), this.screenY(2000 + vgap.settings.mapheight/2 + 10), (vgap.settings.mapwidth + 20) * this.zoom, (vgap.settings.mapheight + 20) * this.zoom);
  302. }
  303. //nebulas
  304. if (vgap.nebulas && fullrender) {
  305.  
  306. for (var i = 0; i < vgap.nebulas.length; i++) {
  307. var neb = vgap.nebulas[i];
  308.  
  309. //var rad = neb.radius * vgap.map.zoom;
  310. var visible = this.isVisible(neb.x, neb.y, neb.radius);
  311.  
  312. //if on this canvas
  313. if (visible) {
  314. var screenX = this.screenX(neb.x);
  315. var screenY = this.screenY(neb.y);
  316. this.drawNebula(screenX, screenY, neb, ctx);
  317. }
  318. }
  319. }
  320.  
  321. //stars
  322. if (vgap.stars && fullrender) {
  323. for (var i = 0; i < vgap.stars.length; i++) {
  324.  
  325. var star = vgap.stars[i];
  326.  
  327. //var rad = Math.sqrt(star.mass) * vgap.map.zoom;
  328. var visible = this.isVisible(star.x, star.y, Math.sqrt(star.mass));
  329.  
  330. if (visible) {
  331. var screenX = this.screenX(star.x);
  332. var screenY = this.screenY(star.y);
  333. this.drawStar(screenX, screenY, star, ctx);
  334. }
  335. }
  336. }
  337.  
  338. //minefields
  339. if (fullrender) {
  340. for (var i = 0; i < vgap.minefields.length; i++) {
  341. var minefield = vgap.minefields[i];
  342. var rad = minefield.radius * vgap.map.zoom;
  343. var visible = this.isVisible(minefield.x, minefield.y, minefield.radius);
  344.  
  345. //if on this canvas
  346. if (visible) {
  347.  
  348. var screenX = this.screenX(minefield.x);
  349. var screenY = this.screenY(minefield.y);
  350. this.drawMinefield(screenX, screenY, minefield.color, rad, ctx, minefield.isweb);
  351. }
  352. }
  353. }
  354.  
  355. //ions
  356. if (fullrender) {
  357. for (var i = 0; i < vgap.ionstorms.length; i++) {
  358. var storm = vgap.ionstorms[i];
  359.  
  360. var rad = storm.radius * vgap.map.zoom;
  361. var visible = this.isVisible(storm.x, storm.y, storm.radius);
  362.  
  363. //if on this canvas
  364. if (visible) {
  365. var screenX = this.screenX(storm.x);
  366. var screenY = this.screenY(storm.y);
  367. this.drawIon(screenX, screenY, storm.voltage, rad, ctx, storm);
  368. }
  369. }
  370. }
  371.  
  372. //planets
  373. for (var i = 0; i < vgap.planets.length; i++) {
  374.  
  375. var planet = vgap.planets[i];
  376.  
  377. var skip = false;
  378.  
  379. if (!skip) {
  380. var rad = this.planetRad(planet);
  381. var visible = this.isVisible(planet.x, planet.y, rad + 8);
  382.  
  383. //if on this canvas
  384. if (visible) {
  385.  
  386. var screenX = this.screenX(planet.x);
  387. var screenY = this.screenY(planet.y);
  388.  
  389. //draw warp well
  390. if (vgap.map.zoom >= 10 && planet.debrisdisk == 0 && fullrender && !vgap.settings.isacademy) {
  391.  
  392. ctx.fillStyle = "#000000";
  393. ctx.strokeStyle = "#555555";
  394. ctx.lineWidth = 1;
  395. for (var x = (planet.x - 3) ; x <= planet.x + 3; x++) {
  396. for (var y = (planet.y - 3) ; y <= planet.y + 3; y++) {
  397. if (Math.dist(x, y, planet.x, planet.y) <= 3) {
  398. var mX = this.screenX(x);
  399. var mY = this.screenY(y);
  400. var srad = vgap.map.zoom / 2;
  401. ctx.fillRect(mX - srad, mY - srad, srad * 2, srad * 2);
  402. ctx.strokeRect(mX - srad, mY - srad, srad * 2, srad * 2);
  403. }
  404. }
  405. }
  406. }
  407. this.drawPlanet(planet, ctx, fullrender);
  408. }
  409. }
  410. }
  411. //Debris Disk Fill
  412. if (fullrender) {
  413. for (var i = 0; i < vgap.debrisdisks.length; i++) {
  414. var planet = vgap.debrisdisks[i];
  415. var rad = planet.debrisdisk * vgap.map.zoom;
  416.  
  417. var visible = this.isVisible(planet.x, planet.y, rad);
  418.  
  419. //if on this canvas
  420. if (visible) {
  421.  
  422. //draw centers
  423. var screenX = this.screenX(planet.x);
  424. var screenY = this.screenY(planet.y);
  425. this.drawDebris(screenX, screenY, rad, ctx);
  426. }
  427. }
  428. }
  429. if (fullrender) {
  430. if (this.zoom > 40) {
  431.  
  432. //ships in space only
  433. for (var i = 0; i < vgap.ships.length; i++) {
  434. var ship = vgap.ships[i];
  435. var rad = this.shipRad(ship);
  436. var visible = this.isVisible(ship.x, ship.y, rad);
  437.  
  438. if (visible)
  439. this.drawShip(ship, ctx);
  440.  
  441. }
  442. }
  443. else {
  444. //ships in space only
  445. for (var i = 0; i < vgap.inspace.length; i++) {
  446. var ship = vgap.inspace[i];
  447. var rad = this.shipRad(ship);
  448. var visible = this.isVisible(ship.x, ship.y, rad);
  449.  
  450. if (visible)
  451. this.drawShip(ship, ctx);
  452. }
  453. }
  454. }
  455. //Explosions
  456. if (fullrender) {
  457. for (var i = 0; i < vgap.explosions.length; i++) {
  458. var message = vgap.explosions[i];
  459. var screenX = this.screenX(message.x);
  460. var screenY = this.screenY(message.y);
  461. var rad = 4;
  462. if (message.fatal)
  463. rad = 6;
  464.  
  465. // Stroked X
  466. ctx.beginPath();
  467. ctx.moveTo(screenX - rad, screenY - rad);
  468. ctx.lineTo(screenX + rad, screenY + rad);
  469. ctx.moveTo(screenX + rad, screenY - rad);
  470. ctx.lineTo(screenX - rad, screenY + rad);
  471. ctx.closePath();
  472.  
  473. ctx.strokeStyle = message.color;
  474. ctx.lineWidth = 2;
  475. ctx.stroke();
  476. if (message.messagetype == 10)
  477. ctx.fillText( message.body.substr(message.body.indexOf("the name of the ship was:")+"the name of the ship was:".length),screenX+20,screenY+14);
  478. }
  479. }
  480. //event callout for user scripts
  481. if (fullrender)
  482. vgap.callPlugins("draw");
  483.  
  484. //user content
  485. if (drawUserContent && fullrender)
  486. this.drawUserChangeable(ctx);
  487.  
  488.  
  489. //if (fast) {
  490. // if (vgap.map.drawtimer)
  491. // clearTimeout(vgap.map.drawtimer);
  492. // vgap.map.drawtimer = setTimeout(function () { vgap.map.draw(); }, 200);
  493. //}
  494.  
  495. //copy to second canvas for slow panning
  496. vgap.map.ctx2.clearRect(0, 0, vgap.map.canvas.width, vgap.map.canvas.height);
  497. vgap.map.ctx2.drawImage(vgap.map.canvas, 0, 0);
  498. vgap.map.canvas2.x = vgap.map.canvas.x;
  499. vgap.map.canvas2.y = vgap.map.canvas.y;
  500. vgap.map.canvas2.zoom = vgap.map.zoom;
  501. vgap.map.canvas2.centerX = vgap.map.centerX;
  502. vgap.map.canvas2.centerY = vgap.map.centerY;
  503.  
  504.  
  505. drawing = false;
  506. this.showDrawTime();
  507. }
  508. };
  509.  
  510. var oldSetMineColors = vgaPlanets.prototype.setMineColors;
  511.  
  512. vgaPlanets.prototype.setMineColors = function (minefield) {
  513. checkColorModSettings();
  514. var sets = vgap.accountsettings;
  515. if (activeColorMod==false)
  516. {
  517. oldSetMineColors.apply(this,arguments);
  518. }
  519.  
  520. else if (vgaPlanets.prototype.version>=3)
  521. {
  522. if ((defaultMyColor==true)&&(minefield.ownerid == vgap.player.id))
  523. minefield.color = sets.mymines;
  524. else //use new colors
  525. {
  526. if (minefield.ownerid>0)
  527. minefield.color=colorsA2[minefield.ownerid-1];
  528. else minefield.color=modUnknown2;
  529. if (useColorPicker>0)
  530. {
  531. var relation = vgap.getRelation(minefield.ownerid);
  532. if (relation != null && relation.color && relation.color != "")
  533. minefield.color = "#" + relation.color;
  534. }
  535. }
  536. }
  537.  
  538. };
  539.  
  540. var oldDrawPlanet = vgapMap.prototype.drawPlanet;
  541.  
  542. vgapMap.prototype.drawPlanet = function(planet, ctx,fullrender)
  543. {
  544. if ((activeColorMod==false)||(vgaPlanets.prototype.version<3))
  545. {
  546. oldDrawPlanet.apply(this,arguments);
  547. }
  548. else if (vgaPlanets.prototype.version>=3)
  549. {
  550. var x = this.screenX(planet.x);
  551. var y = this.screenY(planet.y);
  552. var rad = this.planetRad(planet);
  553.  
  554. var from = planet.colorfrom;
  555. var to = planet.colorto;
  556.  
  557. var bg = colorToRGBA(to, 0.2);
  558. if (vgap.godmode) {
  559. if (planet.flag == 1) {
  560. from = "#ffffff";
  561. to = "#0000ff";
  562. if (this.putHypCircle) {
  563. //this.hypcircles = [];
  564. this.hypcircles.push({ x: planet.x, y: planet.y });
  565. }
  566. } else if (planet.flag == 2) {
  567. from = "#ffffff";
  568. to = "#00ff00";
  569. }
  570. }
  571. if (planet.id < 0) {
  572. from = colorToRGBA(from, 0.5);
  573. to = colorToRGBA(to, 0.5);
  574. }
  575.  
  576. if (vgap.settings.isacademy) {
  577. ctx.fillStyle = bg;
  578. ctx.fillRect(this.screenX(planet.x - 0.5), this.screenY(planet.y + 0.5), this.zoom, this.zoom);
  579. }
  580. //on first draw create a sprite
  581. var spritekey = "planet" + from.substring(1) + to.substring(1) + planet.isbase + (planet.debrisdisk > 0) + (planet.id < 0);
  582. this.drawPlanetSprite(spritekey, rad, from, to, planet.isbase);
  583. var grad = ctx.createLinearGradient(x - rad, y - rad, x + rad, y + rad);
  584. grad.addColorStop(0, from);
  585. grad.addColorStop(1, to);
  586. ctx.fillStyle = grad;
  587.  
  588. if (((this.zoom > 20 && planet.debrisdisk == 0) || (this.zoom > 100 && planet.debrisdisk > 0)) && vgap.animations && fullrender && vgap.map.fastrendering) {
  589.  
  590. if (planet.scale)
  591. rad *= planet.scale;
  592.  
  593. //draw the image of the planet
  594. if (!planet.imgObj) {
  595. planet.imgObj = new Image();
  596. planet.imgObj.onload = function () { vgap.map.draw(); };
  597. planet.imgObj.src = planet.img;
  598. if (planet.debrisdisk > 0) {
  599. planet.rotation = Math.random() * Math.PI;
  600. planet.scale = Math.random() * 0.5 + 0.5;
  601. }
  602. }
  603. else {
  604. if (planet.rotation > 0) {
  605. //draw rotated version
  606. ctx.save();
  607. ctx.translate(x, y);
  608. ctx.rotate(planet.rotation);
  609. ctx.drawImage(planet.imgObj, -rad, -rad, rad * 2, rad * 2);
  610. ctx.restore();
  611. }
  612. else
  613. ctx.drawImage(planet.imgObj, x - rad, y - rad, rad * 2, rad * 2);
  614.  
  615. }
  616.  
  617. if (planet.isbase) {
  618. var sb = vgap.getStarbase(planet.id);
  619. ctx.drawImage(vgap.sbimg[sb.starbasetype], x+(rad/3), y-rad, rad/1.5, rad/1.5);
  620. }
  621. }
  622. else if (vgap.map.zoom <= 2) {
  623. this.drawSprite(ctx, spritekey, x, y, rad + 1);
  624. }
  625. else {
  626. if (planet.isbase) {
  627. ctx.fillRect(x - rad, y - rad, rad * 2, rad * 2);
  628. }
  629. else {
  630. ctx.beginPath();
  631. ctx.arc(x, y, rad, 0, Math.PI * 2, false);
  632. ctx.closePath();
  633. ctx.fill();
  634. }
  635. }
  636. //stroke the planet appropriately
  637. if (this.zoom < 40 && fullrender)
  638. {
  639. var sets = vgap.accountsettings;
  640.  
  641. var color;
  642. var shipsAt = vgap.shipsAt(planet.x, planet.y);
  643. for (var j = 0; j < shipsAt.length; j++)
  644. {
  645. var number=shipsAt[j].ownerid;
  646. color=colorsA2[number-1];
  647. if (shipsAt[j].ownerid == vgap.player.id)
  648. planet.myShip = true;
  649. else
  650. {
  651. var relation = vgap.getRelation(shipsAt[j].ownerid)
  652. if (relation != null && relation.color && relation.color != "")
  653. planet.colorShip = relation.color;
  654. else if (vgap.allied(shipsAt[j].ownerid))
  655. planet.allyShip = true;
  656. else
  657. planet.enemyShip = true;
  658. }
  659. }
  660.  
  661. if (planet.myShip) {
  662. if (defaultMyColor==true)
  663. ctx.strokeStyle = sets.myshipfrom;
  664. else
  665. ctx.strokeStyle =colorsA2[vgap.player.id-1];
  666. this.drawPlanetStrokeSprite("myplanetship", 12, colorsA2[vgap.player.id-1]);
  667. ctx.lineWidth = 1;
  668. ctx.beginPath();
  669. ctx.arc(x, y, rad + 2, 0, Math.PI * 2, false);
  670. ctx.closePath();
  671. ctx.stroke();
  672. }
  673. if (planet.allyShip||planet.colorShip) {
  674.  
  675. this.drawPlanetStrokeSprite("allyplanetship", 10, color);
  676.  
  677. if (vgap.map.zoom <= 2) {
  678. this.drawSprite(ctx, "allyplanetship", x, y, rad + 5);
  679. }
  680. else {
  681.  
  682. ctx.strokeStyle = color;
  683. ctx.lineWidth = 1;
  684. ctx.beginPath();
  685. ctx.arc(x, y, rad + 4, 0, Math.PI * 2, false);
  686. ctx.closePath();
  687. ctx.stroke();
  688. }
  689. }
  690. if (planet.enemyShip) {
  691. this.drawPlanetStrokeSprite("enemyplanetship", 14, color);
  692. if (vgap.map.zoom <= 2) {
  693. this.drawSprite(ctx, "enemyplanetship", x, y, rad + 5);
  694. }
  695. else {
  696. ctx.strokeStyle = color;
  697. ctx.lineWidth = 1;
  698. ctx.beginPath();
  699. ctx.arc(x, y, rad + 6, 0, Math.PI * 2, false);
  700. ctx.closePath();
  701. ctx.stroke();
  702. }
  703. }
  704. }
  705. if (planet.note && planet.note.body.length > 0 && fullrender) {
  706. ctx.strokeStyle = "#FFFF00";
  707. ctx.lineWidth = 1;
  708. ctx.strokeRect(x - rad - 1, y - rad - 1, (rad + 1) * 2, (rad + 1) * 2);
  709. }
  710. }
  711. };
  712.  
  713. var oldDrawMinefield = vgapMap.prototype.drawMinefield;
  714.  
  715. vgapMap.prototype.drawMinefield = function (x, y, color, rad, ctx,isweb)
  716. {
  717. if (activeColorMod==false)
  718. {
  719. oldDrawMinefield.apply(this,arguments);
  720. }
  721. else if (vgaPlanets.prototype.version>=3)
  722. {
  723. var grad = ctx.createRadialGradient(x, y, 0, x, y, rad);
  724. var spritekey = "mine" + color.substring(1);
  725. if (!vgap.map.sprites[spritekey]) {
  726. sctx = vgap.map.spritectx;
  727. var soffset = vgap.map.spriteindex * vgap.map.spritewidth;
  728. var srad = 24;
  729. var sx = soffset + srad+1;
  730. var sy = srad+1;
  731.  
  732. var grad = sctx.createRadialGradient(sx, sy, 0, sx, sy, srad);
  733. if (isweb==false)
  734. {
  735. grad.addColorStop(0, colorToRGBA(color, 0.4));
  736. grad.addColorStop(1, colorToRGBA(color, 0.2));
  737. }
  738. else
  739. {
  740. grad.addColorStop(0.9, colorToRGBA(color, 0.15));
  741. grad.addColorStop(1, colorToRGBA(color, 0.3));
  742. }
  743. sctx.fillStyle = grad;
  744.  
  745. sctx.beginPath();
  746. sctx.arc(sx, sy, srad, 0, Math.PI * 2, false);
  747. sctx.closePath();
  748. sctx.fill();
  749.  
  750. vgap.map.sprites[spritekey] = { key: spritekey, offset: soffset, width: (srad * 2 + 2) };
  751. vgap.map.spriteindex++;
  752. }
  753. if (vgap.map.zoom <= 1 && !vgap.map.fastrendering) {
  754. this.drawSprite(ctx, spritekey, x, y, rad + 1);
  755. }
  756. else{
  757. if (isweb==false)
  758. {
  759. grad.addColorStop(0, colorToRGBA(color, 0.4));
  760. grad.addColorStop(1, colorToRGBA(color, 0.2));
  761. }
  762. else
  763. {
  764. grad.addColorStop(0.9, colorToRGBA(color, 0.15));
  765. grad.addColorStop(1, colorToRGBA(color, 0.3));
  766. }
  767. ctx.fillStyle = grad;
  768.  
  769. ctx.strokeStyle = colorToRGBA(color, 0.2);
  770. ctx.lineWidth = 2;
  771. ctx.beginPath();
  772. ctx.arc(x, y, rad, 0, Math.PI * 2, false);
  773. ctx.closePath();
  774. ctx.fill();
  775. //ctx.stroke();
  776. //centerpoint
  777. ctx.beginPath();
  778. ctx.arc(x, y, 1, 0, Math.PI * 2, false);
  779. ctx.closePath();
  780. ctx.fill();
  781. }
  782. }
  783. };
  784.  
  785. var oldSetShipColors = vgaPlanets.prototype.setShipColors;
  786.  
  787. vgaPlanets.prototype.setShipColors = function (ship)
  788. {
  789. var sets = vgap.accountsettings;
  790. if ((activeColorMod==false)||(vgaPlanets.prototype.version<3))
  791. {
  792. oldSetShipColors.apply(this,arguments);
  793. }
  794. else if (vgaPlanets.prototype.version>=3)
  795. {
  796. if ((defaultMyColor==true)&&(ship.ownerid == vgap.player.id))
  797. {
  798. ship.colorfrom = sets.myshipfrom;
  799. ship.colorto = sets.myshipto;
  800. return;
  801. }
  802. if(useColorPicker>0)
  803. {
  804. var relation = vgap.getRelation(ship.ownerid);
  805. if (relation != null && relation.color != "") {
  806. ship.colorfrom = "#" + shadeColor(relation.color, 100);
  807. ship.colorto = "#" + shadeColor(relation.color, -100);
  808. return;
  809. }
  810. }
  811. if ((ship.ownerid>0)&&(ship.ownerid<30))
  812. {
  813. ship.colorfrom = colorsA[ship.ownerid-1];
  814. ship.colorto = colorsA2[ship.ownerid-1];
  815. return;
  816. }
  817. //weird, but seems it can happen
  818. ship.colorfrom = modUnknown;
  819. ship.colorto = modUnknown2;
  820. }
  821. };
  822.  
  823. var oldSetPlanetColors = vgaPlanets.prototype.setPlanetColors;
  824.  
  825. vgaPlanets.prototype.setPlanetColors = function (planet) {
  826. var sets = vgap.accountsettings;
  827. if ((activeColorMod==false)||(vgaPlanets.prototype.version<3))
  828. {
  829. oldSetPlanetColors.apply(this,arguments);
  830. }
  831.  
  832. else if (vgaPlanets.prototype.version>=3)
  833. {
  834. //determine rings required
  835. var shipsAt = vgap.shipsAt(planet.x, planet.y);
  836. for (var j = 0; j < shipsAt.length; j++) {
  837. if (shipsAt[j].ownerid == vgap.player.id)
  838. planet.myShip = true;
  839. else {
  840. var relation = vgap.getRelation(shipsAt[j].ownerid)
  841. if (relation != null && relation.color && relation.color != "")
  842. planet.colorShip = relation.color;
  843. else if (vgap.allied(shipsAt[j].ownerid))
  844. planet.allyShip = true;
  845. else
  846. planet.enemyShip = true;
  847. }
  848. }
  849.  
  850. var sets = vgap.accountsettings;
  851. if (planet.note && planet.note.color != "") {
  852. planet.colorfrom = "#" + shadeColor(planet.note.color, 100);
  853. planet.colorto = "#" + shadeColor(planet.note.color, -100);
  854. return;
  855. }
  856. if ((defaultMyColor==true)&&(planet.ownerid == vgap.player.id))
  857. {
  858. planet.colorfrom = sets.myplanetfrom;
  859. planet.colorto = sets.myplanetto;
  860. return;
  861. }
  862.  
  863. if(planet.ownerid==0&&planet.infoturn>0)
  864. {
  865. planet.colorfrom=modInfo;
  866. planet.colorto=modInfo2;
  867. return
  868. }
  869. if(planet.ownerid==0)
  870. {
  871. planet.colorfrom=modUnknown;
  872. planet.colorto=modUnknown2;
  873. return
  874. }
  875. if(useColorPicker>0)
  876. {
  877. var relation = vgap.getRelation(planet.ownerid);
  878. if (relation != null && relation.color != "") {
  879. planet.colorfrom = "#" + shadeColor(relation.color, 100);
  880. planet.colorto = "#" + shadeColor(relation.color, -100);
  881. return;
  882. }
  883. }
  884. planet.colorfrom=colorsA[planet.ownerid-1];
  885. planet.colorto=colorsA2[planet.ownerid-1]
  886. }
  887. };
  888.  
  889.  
  890.  
  891. var oldLoadWaypoints = vgaPlanets.prototype.loadWaypoints;
  892.  
  893. vgaPlanets.prototype.loadWaypoints = function () {
  894. if ((activeColorMod==false))
  895. {
  896. oldLoadWaypoints.apply(this,arguments);
  897. }
  898. else if (vgaPlanets.prototype.version>=3)
  899. {
  900.  
  901. var sets = vgap.accountsettings;
  902.  
  903. this.waypoints = new Array();
  904. for (var i = 0; i < vgap.ships.length; i++) {
  905. //waypoint
  906. var ship = vgap.ships[i];
  907. if (ship.ownerid != vgap.player.id) {
  908. if (ship.heading != -1 && ship.warp != 0) {
  909.  
  910. var relation = vgap.getRelation(ship.ownerid);
  911.  
  912. var color = colorsA2[ship.ownerid-1];
  913.  
  914. var speed = vgap.getSpeed(ship.warp, ship.hullid);
  915.  
  916. var x2 = ship.x + Math.round(Math.sin(Math.toRad(ship.heading)) * speed);
  917. var y2 = ship.y + Math.round(Math.cos(Math.toRad(ship.heading)) * speed);
  918. ship.targetx = x2;
  919. ship.targety = y2;
  920. if (useColorPicker>0)
  921. if (relation.color && relation.color != "")
  922. color = "#" + relation.color;
  923. this.waypoints.push({ id: ship.id, x1: ship.x, y1: ship.y, x2: x2, y2: y2, color: color });
  924.  
  925. //this.waypoints.push(this.paper.path("M" + this.screenX(ship.x) + " " + this.screenY(ship.y) + "L" + this.screenX(x2) + " " + this.screenY(y2)).attr({ stroke: color, "stroke-width": "2", "stroke-opacity": 0.5 }));
  926. }
  927. }
  928. else {
  929.  
  930. if (vgap.isChunnelling(ship)) {
  931.  
  932. var x = ship.x;
  933. var y = ship.y;
  934.  
  935. //we are initiating a chunnel at warp speed inside a matrix
  936. if (ship.warp > 0 && (ship.targetx != ship.x || ship.targety != ship.y)) {
  937.  
  938.  
  939. var dasharray = null;
  940. var color = sets.myshipto;
  941.  
  942. var next = vgap.getNextLoc(ship);
  943.  
  944. var waypoint = { id: ship.id, x1: x, y1: y, x2: next.x, y2: next.y, color: color, dasharray: dasharray };
  945. this.waypoints.push(waypoint);
  946. ship.lastwaypoint = waypoint;
  947.  
  948. x = next.x;
  949. y = next.y;
  950. }
  951.  
  952. var targetId = parseInt(ship.friendlycode, 10);
  953. var target = vgap.getShipClosestCopy(targetId, ship.x, ship.y);
  954. var dasharray = [9, 4];
  955. var color = "#00FFFF";
  956. if (ship.id < 0)
  957. color = "rgba(0, 255, 255, 0.15)";
  958. var linewidth = 2;
  959. if (ship.hullid != 56) {
  960. dasharray = [5, 2];
  961. color = "#009999";
  962. }
  963. if (vgap.multiChunnel(ship.x, ship.y, target.x, target.y)) {
  964. linewidth = 6;
  965. dasharray = [6,6];
  966. }
  967.  
  968. this.waypoints.push({ id: ship.id, x1: x, y1: y, x2: target.x, y2: target.y, color: color, dasharray: dasharray, linewidth: linewidth });
  969. }
  970. else {
  971.  
  972. var dasharray = null;
  973. var color;
  974. if (defaultMyColor==true)
  975. color = sets.myshipto;
  976. else
  977. {
  978. color = colorsA2[ship.ownerid-1];
  979. }
  980. var path = vgap.getPath(ship);
  981. if (vgap.isHyping(ship)) {
  982. color = "#F5F5DC";
  983. dasharray = [2, 2];
  984.  
  985. if (path.length > 0) {
  986. var first = path[0];
  987. var dist = Math.dist(first.x1, first.y1, first.x2, first.y2);
  988. var mindist = 340;
  989. var maxdist = 360;
  990. var middist = 350;
  991. if (vgap.settings.isacademy) {
  992. mindist = 8;
  993. maxdist = 9;
  994. middist = 8.5;
  995. }
  996. if (dist < mindist || dist > maxdist) {
  997. //now we just fly exactly 350
  998. color = "#FF0000";
  999. ship.heading = vgap.getHeading(first.x1, first.y1, first.x2, first.y2);
  1000. first.x2 = ship.x + Math.round(Math.sin(Math.toRad(ship.heading)) * middist);
  1001. first.y2 = ship.y + Math.round(Math.cos(Math.toRad(ship.heading)) * middist);
  1002. }
  1003. }
  1004. }
  1005. //use tower path
  1006. var tower = vgap.isTowTarget(ship.id);
  1007. if (tower != null)
  1008. path = vgap.getPath(tower);
  1009.  
  1010. var startfuel = ship.neutronium;
  1011. for (var j = 0; j < path.length; j++) {
  1012. if (vgap.isHyping(ship) && j > 0)
  1013. break;
  1014. //change color for fuel shortage
  1015. var fuel = vgap.getFuelUsage(path[j].x1, path[j].y1, path[j].x2, path[j].y2, ship);
  1016. if (fuel > startfuel && tower == null)
  1017. color = "#ff6600";
  1018.  
  1019. startfuel -= fuel;
  1020.  
  1021. var waypoint = { id: ship.id, x1: path[j].x1, y1: path[j].y1, x2: path[j].x2, y2: path[j].y2, color: color, dasharray: dasharray };
  1022. this.waypoints.push(waypoint);
  1023. // this.waypoints.push(this.paper.path("M" + this.screenX(path[j].x1) + " " + this.screenY(path[j].y1) + "L" + this.screenX(path[j].x2) + " " + this.screenY(path[j].y2)).attr(params));
  1024. ship.lastwaypoint = waypoint;
  1025. }
  1026. }
  1027. }
  1028. }
  1029. for (var i = 0; i < vgap.ionstorms.length; i++) {
  1030. var storm = vgap.ionstorms[i];
  1031. if (storm.parentid == 0) {
  1032.  
  1033. var x = storm.x;
  1034. var y = storm.y;
  1035. if (storm.centroid) {
  1036. x = storm.centroid.x;
  1037. y = storm.centroid.y;
  1038. }
  1039.  
  1040. var x2 = x + Math.round(Math.sin(Math.toRad(storm.heading)) * storm.warp * storm.warp);
  1041. var y2 = y + Math.round(Math.cos(Math.toRad(storm.heading)) * storm.warp * storm.warp);
  1042.  
  1043. //add 1000 to id to make sure it doesnt' match up with ship ids
  1044. this.waypoints.push({ id: 1000 + storm.id, x1: x, y1: y, x2: x2, y2: y2, color: colorToRGBA("#FFFF00", 0.1) });
  1045. }
  1046. }
  1047. }//mod is true
  1048. };
  1049.  
  1050. var oldMineText = vgapMap.prototype.mineText;
  1051.  
  1052. vgapMap.prototype.mineText = function (x, y) {
  1053. if ((activeColorMod==false))
  1054. oldMineText.apply(this,arguments);
  1055. else if (vgaPlanets.prototype.version>=3)
  1056. {
  1057. var txt = "";
  1058. for (var i = 0; i < vgap.minefields.length; i++) {
  1059. var minefield = vgap.minefields[i];
  1060. if (Math.dist(minefield.x, minefield.y, x, y) <= minefield.radius) {
  1061. txt += "<div class='ItemSelectionBox minCorrection'><span>";
  1062. if (minefield.ownerid == vgap.player.id)
  1063. if (minefield.isweb)
  1064. txt += "Your Web Minefield ";
  1065. else
  1066. txt += "Your Minefield ";
  1067. else {
  1068. var player = vgap.getPlayer(minefield.ownerid);
  1069. var race = vgap.getRace(player.raceid);
  1070. if (minefield.isweb)
  1071. txt += race.adjective + " (" + player.username + ") Web Minefield ";
  1072. else
  1073. txt += race.adjective + " (" + player.username + ") Minefield ";
  1074. }
  1075. txt += "Id:" + minefield.id + "</span>";
  1076. txt += "<table class='CleanTable'>";
  1077. txt += "<tr><td> Mines: </td><td> " + gsv(minefield.units) + " </td></tr>";
  1078. txt += "<tr><td> Radius: </td><td> " + gsv(minefield.radius) + " </td></tr>";
  1079. var lastscanned = vgap.game.turn - minefield.infoturn + " turns ago";
  1080. if (minefield.infoturn == vgap.game.turn)
  1081. lastscanned = "this turn";
  1082. txt += "<tr><td> Friendly: </td><td> " + gsv(minefield.friendlycode) + " </td></tr>";
  1083. txt += "<tr><td style='width:60px;'> Scanned: </td><td> " + lastscanned + "</td></tr>";
  1084. txt += "</table></div>";
  1085. }
  1086. }
  1087. return txt;
  1088. }
  1089. };
  1090.  
  1091. var oldShowSettings = vgapDashboard.prototype.showSettings;
  1092.  
  1093. vgapDashboard.prototype.showSettings = function () {
  1094.  
  1095.  
  1096. var new_html="";
  1097. new_html += "<div id='ResetTurnButton' class='BasicFlatButton' onclick='vgapDashboard.prototype.resetNotes();'>Reset all note colors to blank</div><hr>";
  1098. new_html += "<br><h3>Custom Settings for Color Mod</h3>";
  1099. new_html += "<div style='width:250px;'></div>";
  1100. new_html += "<div id='Test'><table>";
  1101. new_html += "<tr><td><div id='LaunchSim' onclick='vgapDashboard.prototype.resetColorModColors();' title='Default is: Active.'>Reset all custom color settings </div></td>";
  1102. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeDefaultMyColor();' title='Default is: Active.'>Use default colors for My Race Only</div></td>";
  1103. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeColorMod();' title='Default is: Active.'>Activate or Deactivate Color Mod</div></td>";
  1104. new_html += "<td><div id='LaunchSim' onclick='vgapDashboard.prototype.changeColorPicker();' title='Default is: InActive.'>Set Diplomatic Color Picker</div></td></tr></table>";
  1105.  
  1106. new_html += "<div id='AccountSettings2'><table>";
  1107. new_html += "<tr><th>Color Settings</th></tr>";
  1108.  
  1109. //html += this.renderSetColorMod("Race 1", "test");
  1110. new_html += "<tr><td>" + "Race 1" + "</td><td><input type='text' id='Race1' onchange='SaveRace();' value='" + colorsA[0] + "'/></td><td><input type='text' id='Race1A' onchange='SaveRace();' value='" + colorsA2[0] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[0] + "), color-stop(1, " + colorsA2[0] + ")); background: -moz-linear-gradient(top left," + colorsA[0] + " 0%, " + colorsA2[0] + " 100%)' type='text' id='IgnoreRace1' value=' '/></td></tr>";
  1111. new_html += "<tr><td>" + "Race 2" + "</td><td><input type='text' id='Race2' onchange='SaveRace();' value='" + colorsA[1] + "'/></td><td><input type='text' id='Race2A' onchange='SaveRace();' value='" + colorsA2[1] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[1] + "), color-stop(1, " + colorsA2[1] + ")); background: -moz-linear-gradient(top left," + colorsA[1] + " 0%, " + colorsA2[1] + " 100%)' type='text' id='IgnoreRace1' value=' '/></td></tr>";
  1112. new_html += "<tr><td>" + "Race 3" + "</td><td><input type='text' id='Race3' onchange='SaveRace();' value='" + colorsA[2] + "'/></td><td><input type='text' id='Race3A' onchange='SaveRace();' value='" + colorsA2[2] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[2] + "), color-stop(1, " + colorsA2[2] + ")); background: -moz-linear-gradient(top left," + colorsA[2] + " 0%, " + colorsA2[2] + " 100%)' type='text' id='IgnoreRace3' value=' '/></td></tr>";
  1113. new_html += "<tr><td>" + "Race 4" + "</td><td><input type='text' id='Race4' onchange='SaveRace();' value='" + colorsA[3] + "'/></td><td><input type='text' id='Race4A' onchange='SaveRace();' value='" + colorsA2[3] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[3] + "), color-stop(1, " + colorsA2[3] + ")); background: -moz-linear-gradient(top left," + colorsA[3] + " 0%, " + colorsA2[3] + " 100%)' type='text' id='IgnoreRace4 value=' '/></td></tr>";
  1114. new_html += "<tr><td>" + "Race 5" + "</td><td><input type='text' id='Race5' onchange='SaveRace();' value='" + colorsA[4] + "'/></td><td><input type='text' id='Race5A' onchange='SaveRace();' value='" + colorsA2[4] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[4] + "), color-stop(1, " + colorsA2[4] + ")); background: -moz-linear-gradient(top left," + colorsA[4] + " 0%, " + colorsA2[4] + " 100%)' type='text' id='IgnoreRace5' value=' '/></td></tr>";
  1115. new_html += "<tr><td>" + "Race 6" + "</td><td><input type='text' id='Race6' onchange='SaveRace();' value='" + colorsA[5] + "'/></td><td><input type='text' id='Race6A' onchange='SaveRace();' value='" + colorsA2[5] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[5] + "), color-stop(1, " + colorsA2[5] + ")); background: -moz-linear-gradient(top left," + colorsA[5] + " 0%, " + colorsA2[5] + " 100%)' type='text' id='IgnoreRace6 value=' '/></td></tr>";
  1116. new_html += "<tr><td>" + "Race 7" + "</td><td><input type='text' id='Race7' onchange='SaveRace();' value='" + colorsA[6] + "'/></td><td><input type='text' id='Race7A' onchange='SaveRace();' value='" + colorsA2[6] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[6] + "), color-stop(1, " + colorsA2[6] + ")); background: -moz-linear-gradient(top left," + colorsA[6] + " 0%, " + colorsA2[6] + " 100%)' type='text' id='IgnoreRace7' value=' '/></td></tr>";
  1117. new_html += "<tr><td>" + "Race 8" + "</td><td><input type='text' id='Race8' onchange='SaveRace();' value='" + colorsA[7] + "'/></td><td><input type='text' id='Race8A' onchange='SaveRace();' value='" + colorsA2[7] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[7] + "), color-stop(1, " + colorsA2[7] + ")); background: -moz-linear-gradient(top left," + colorsA[7] + " 0%, " + colorsA2[7] + " 100%)' type='text' id='IgnoreRace8 value=' '/></td></tr>";
  1118. new_html += "<tr><td>" + "Race 9" + "</td><td><input type='text' id='Race9' onchange='SaveRace();' value='" + colorsA[8] + "'/></td><td><input type='text' id='Race9A' onchange='SaveRace();' value='" + colorsA2[8] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[8] + "), color-stop(1, " + colorsA2[8] + ")); background: -moz-linear-gradient(top left," + colorsA[8] + " 0%, " + colorsA2[8] + " 100%)' type='text' id='IgnoreRace9' value=' '/></td></tr>";
  1119. new_html += "<tr><td>" + "Race 10" + "</td><td><input type='text' id='Race10' onchange='SaveRace();' value='" + colorsA[9] + "'/></td><td><input type='text' id='Race10A' onchange='SaveRace();' value='" + colorsA2[9] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[9] + "), color-stop(1, " + colorsA2[9] + ")); background: -moz-linear-gradient(top left, " + colorsA[9] + " 0%, " + colorsA2[9] + " 100%)' type='text' id='IgnoreRace10 value=' '/></td></tr>";
  1120. new_html += "<tr><td>" + "Race 11" + "</td><td><input type='text' id='Race11' onchange='SaveRace();' value='" + colorsA[10] + "'/></td><td><input type='text' id='Race11A' onchange='SaveRace();' value='" + colorsA2[10] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[10] + "), color-stop(1, " + colorsA2[10] + ")); background: -moz-linear-gradient(top left, " + colorsA[10] + " 0%, " + colorsA2[10] + " 100%)' type='text' id='IgnoreRace11' value=' '/></td></tr>";
  1121. new_html += "<tr><td>" + "Unoccupied" + "</td><td><input type='text' id='ModInfo' onchange='SaveRace();' value='" + modInfo + "'/></td><td><input type='text' id='ModInfo2' onchange='SaveRace();' value='" + modInfo2 + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + modInfo + "), color-stop(1, " + modInfo2 + ")); background: -moz-linear-gradient(top left, " + modInfo + " 0%, " + modInfo2 + " 100%)' type='text' id='IgnoreInfo value=' '/></td></tr>";
  1122. new_html += "<tr><td>" + "Unknown" + "</td><td><input type='text' id='ModUnknown' onchange='SaveRace();' value='" + modUnknown + "'/></td><td><input type='text' id='ModUnknown2' onchange='SaveRace();' value='" + modUnknown2 + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + modUnknown + "), color-stop(1, " + modUnknown2 + ")); background: -moz-linear-gradient(top left, " + modUnknown + " 0%, " + modUnknown2 + " 100%)' type='text' id='IgnoreUnknown value=' '/></td></tr>";
  1123. new_html += "<tr><td><input type='text' id='ModRace' onchange='SaveRaceNum();' value='" + modRace + "'/></td><td><input type='text' id='ModRace2' onchange='SaveRace();' value='" + colorsA[modRace-1] + "'/></td><td><input type='text' id='ModRace3' onchange='SaveRace();' value='" + colorsA2[modRace-1] + "'/></td><td><input style='background: -webkit-gradient(linear,left top, right bottom, color-stop(0, " + colorsA[modRace-1] + "), color-stop(1, " + colorsA2[modRace-1] + ")); background: -moz-linear-gradient(top left, " + colorsA[modRace-1] + " 0%, " + colorsA2[modRace-1] + " 100%)' type='text' id='IgnoreRaceMod value=' '/></td></tr>";
  1124. //html += "<tr><td>Test</td>" + "<td>Test2</td>" + "<td><input style='background: -moz-linear-gradient(top left, #ccffff 0%, #00ffff 100%); background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff))' type='text' id='IgnoreMe2' value=' '/></tr></td>";
  1125. //html += "<tr><td>Test2</td>" + "<td>Test3</td>" + "<td><input style='background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff)) background: -moz-linear-gradient(top left, #ccffff 0%, #00ffff 100%)' type='text' id='IgnoreMe' value=' '/></tr></td>";
  1126. //html += "<tr><td>Test</td>" + "<td>Test2</td>" + "<td><input style='background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #000000), color-stop(1, #ffffff))' type='text' id='IgnoreMe2' value=' '/></tr></td>";
  1127. //html += "<tr><td><input style='background: -webkit-gradient(linear, left top, right bottom, from(#ccc), to(#000)); background: -moz-linear-gradient(top, #ccc, #000);' type='text' id='IgnoreMe' value=' '</td></tr>";
  1128. //html += "<tr><td><input style='background: -moz-linear-gradient(top, #ccc, #000); background: -webkit-gradient(linear, left top, right bottom, from(#ccc), to(#000)); ' type='text' id='IgnoreMe' value=' '</td></tr>";
  1129.  
  1130. new_html += "</table></div>";
  1131. this.customSettingsContent.push(new_html);
  1132. oldShowSettings.apply(this,arguments);
  1133. this.customSettingsContent.pop();
  1134. };
  1135.  
  1136. vgapDashboard.prototype.resetNotes=function()
  1137. {
  1138. if (!confirm("This function will reset all planet note colors to blank. Confirm to continue."))
  1139. return;
  1140. for (var i = 0; i < vgap.planets.length; i++)
  1141. {
  1142.  
  1143. var planet = vgap.planets[i];
  1144. if (planet.note && planet.note.color != "")
  1145. planet.note.color="";
  1146. }
  1147. };
  1148.  
  1149. SaveRaceNum=function(){
  1150. modRace=$("#ModRace").val();//melee race specified
  1151. };
  1152.  
  1153. SaveRace=function(){
  1154.  
  1155. var i;
  1156. if (modRace>11)
  1157. {
  1158. colorsA[modRace-1]=$("#ModRace2").val();
  1159. colorsA2[modRace-1]=$("#ModRace3").val();
  1160. var String3="Race"+(modRace);
  1161. set_cookie(String3,colorsA[modRace-1],2029,1,1);
  1162. set_cookie(String3+"A",colorsA2[modRace-1],2029,1,1);
  1163. }
  1164. for (i=0;i<11;i++)
  1165. {
  1166. var String="#Race"+(i+1);
  1167. var String2="Race"+(i+1);
  1168. colorsA[i]= $(String).val();
  1169. set_cookie(String2,colorsA[i],2029,1,1);
  1170. colorsA2[i]=$(String+"A").val();
  1171. set_cookie(String2+"A",colorsA2[i],2029,1,1);
  1172. }
  1173. modInfo= $("#ModInfo").val();
  1174. modUnknown= $("#ModUnknown").val();
  1175. modInfo2= $("#ModInfo2").val();
  1176. modUnknown2= $("#ModUnknown2").val();
  1177.  
  1178.  
  1179. set_cookie("ModInfo",modInfo,2099,1,1);
  1180. set_cookie("ModUnknown",modUnknown,2029,1,1);
  1181.  
  1182. set_cookie("ModInfo2",modInfo2,2014,1,1);
  1183. set_cookie("ModUnknown2",modUnknown2,2029,1,1);
  1184. vgap.loadWaypoints();
  1185. vgap.map.draw();
  1186. };
  1187.  
  1188. set_cookie=function( name, value, exp_y, exp_m, exp_d, path, domain, secure )
  1189. //name=cookie name (required)
  1190. //value=cookie value (required)
  1191. //exp_y,M,d is expiration year, month, day (if blank cookie will delete when browser closes)
  1192. //path=path within site this applies to (can be blank)
  1193. //domain=apply only to websites in this domain (can be blank)
  1194. //secure=use SSL (leave blank)
  1195.  
  1196. {
  1197. var cookie_string = name + "=" + escape ( value );
  1198.  
  1199. if ( exp_y )
  1200. {
  1201. var expires = new Date ( exp_y, exp_m, exp_d );
  1202. cookie_string += "; expires=" + expires.toGMTString();
  1203. }
  1204.  
  1205. if ( path )
  1206. cookie_string += "; path=" + escape ( path );
  1207.  
  1208. if ( domain )
  1209. cookie_string += "; domain=" + escape ( domain );
  1210. if ( secure )
  1211. cookie_string += "; secure";
  1212. document.cookie = cookie_string;
  1213. };
  1214.  
  1215. get_cookie =function( cookie_name )
  1216. {
  1217. var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  1218.  
  1219. if ( results )
  1220. return ( unescape ( results[2] ) );
  1221. else
  1222. return null;
  1223. };
  1224.  
  1225. vgapDashboard.prototype.saveToCookie = function(){
  1226. //alert("In Function save");
  1227. // set a new cookie
  1228. if (defaultMyColor==true)
  1229. {
  1230. set_cookie("defaultMyColor",1,2029,1,1);
  1231. //alert("set to true!!");
  1232. }
  1233. else{
  1234. set_cookie("defaultMyColor",0,2029,1,1);
  1235. //alert("set to false!!");
  1236. }
  1237. if (activeColorMod==true)
  1238. set_cookie("activeColorMod",1,2029,1,1);
  1239. else
  1240. set_cookie("activeColorMod",0,2029,1,1);
  1241.  
  1242. if (useColorPicker==1)
  1243. set_cookie("ColorPicker",1,2029,1,1);
  1244. else
  1245. set_cookie("ColorPicker",0,2029,1,1);
  1246. };
  1247.  
  1248.  
  1249. vgapDashboard.prototype.changeColorMod = function(){
  1250. if (activeColorMod==true)
  1251. {
  1252. activeColorMod=false;
  1253. alert("The Race Specific Color Mod is now Deactived.");
  1254. }
  1255. else
  1256. {
  1257. activeColorMod=true;
  1258. alert("The Race Specific Color Mod is now Active.");
  1259. }
  1260. vgapDashboard.prototype.saveToCookie()
  1261. vgap.loadWaypoints();
  1262. vgap.map.draw();
  1263. };
  1264.  
  1265. vgapDashboard.prototype.changeColorPicker = function(){
  1266. if (useColorPicker==1)
  1267. {
  1268. useColorPicker=0;
  1269. alert("Ignore Diplomatic Color Picker colors.");
  1270. }
  1271. else
  1272. {
  1273. useColorPicker=1;
  1274. alert("Using Diplomatic Color Picker Colors");
  1275. }
  1276. vgapDashboard.prototype.saveToCookie()
  1277. vgap.loadWaypoints();
  1278. vgap.map.draw();
  1279. };
  1280.  
  1281. vgapDashboard.prototype.resetColorModColors = function(){
  1282. alert("Resetting all colors to Mod defaults");
  1283.  
  1284. colorsA =["#F0F8FF","#32CD32","#CD5C5C","#FFC0CB","#98FB98","#C0C0C0","#FFFF00","#EE82EE","#D3D3D3","#B0E0E6","#87CEFA","#7B68EE","#F4A460","#D2B48C","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  1285. colorsA2 =["#FFFFFF","#006400","#FF0000","#FF69B4","#00FA9A","#6A5ACD","#FFD700","#9400D3","#808080","#00CED1","#4169E1","#7B68EE","#A0522D","#87CEEB","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  1286. modInfo="#F4A460";//chocolate
  1287. modInfo2="#D2691E";//chocolate
  1288.  
  1289. modUnknown="#FFF8DC"; //Tan
  1290. modUnknown2="#D2B48C"; //Tan
  1291. vgapDashboard.prototype.saveToCookie();
  1292. vgap.loadWaypoints();
  1293. vgap.map.draw();
  1294. };
  1295.  
  1296. vgapDashboard.prototype.changeDefaultMyColor = function(){
  1297. if (defaultMyColor==true)
  1298. {
  1299. alert("Mod is no longer using Default colors for your race.");
  1300. defaultMyColor=false;
  1301. }
  1302. else
  1303. {
  1304. alert("Mod will now use Default color (aqua/green) for your race.");
  1305. defaultMyColor=true;
  1306. }
  1307. vgapDashboard.prototype.saveToCookie();
  1308. vgap.loadWaypoints();
  1309. vgap.map.draw();
  1310. };
  1311.  
  1312. checkColorModSettings = function(){
  1313. //Color Mod settings
  1314. //if null, then its unset - check the cookie
  1315. //if cookie doesn't exist, set to default.
  1316. if (activeColorMod==null)
  1317. {
  1318. var checkActive=null;
  1319. checkActive=get_cookie("activeColorMod");
  1320. if (checkActive==null)
  1321. {
  1322. activeColorMod=true;//no cookie, set to default
  1323. }
  1324. else if (checkActive==1)
  1325. {
  1326. activeColorMod=true;
  1327. }
  1328. else
  1329. {
  1330. activeColorMod=false;
  1331. }
  1332. }
  1333.  
  1334. var checkPicker=null;
  1335. checkPicker=get_cookie("ColorPicker");
  1336. if (checkPicker) useColorPicker=checkPicker;
  1337. if (defaultMyColor==null)
  1338. {
  1339. var checkColor=null;
  1340. checkColor=get_cookie("defaultMyColor");
  1341. if (checkColor==null)
  1342. {
  1343. defaultMyColor=true;//no cookie, set to default
  1344. }
  1345. else if (checkColor==1)
  1346. {
  1347. defaultMyColor=true;
  1348. }
  1349. else
  1350. {
  1351. defaultMyColor=false;
  1352. }
  1353. }
  1354.  
  1355. if (useCustomColor==false)
  1356. //have not checked cookies yet
  1357. {
  1358. var i;
  1359. var checkColor=null;
  1360.  
  1361. for (i=0;i<30;i++)
  1362. {
  1363. var String="Race"+(i+1);
  1364. checkColor=get_cookie(String);
  1365. if (checkColor)
  1366. colorsA[i]=checkColor;
  1367. checkColor=null;
  1368. checkColor=get_cookie(String+"A");
  1369. if (checkColor) colorsA2[i]=checkColor;
  1370. checkColor=null;
  1371. }
  1372. checkColor=get_cookie("ModInfo");
  1373. if (checkColor) modInfo=checkColor;
  1374. checkColor=null;
  1375. checkColor=get_cookie("ModUnknown");
  1376. if (checkColor) modUnknown=checkColor;
  1377. checkColor=null;
  1378.  
  1379. checkColor=get_cookie("ModInfo2");
  1380. if (checkColor) modInfo2=checkColor;
  1381. checkColor=null;
  1382. checkColor=get_cookie("ModUnknown2");
  1383. if (checkColor) modUnknown2=checkColor;
  1384. //set var so we know cookies have been checked
  1385. useCustomColor=true;
  1386. }
  1387. };
  1388.  
  1389.  
  1390. } //wrapper for injection
  1391.  
  1392.  
  1393.  
  1394.  
  1395. var script = document.createElement("script");
  1396. script.type = "application/javascript";
  1397. script.textContent = "(" + wrapper + ")();";
  1398.  
  1399. document.body.appendChild(script);