hoverTextbox

rewrites the information you get when you hover over a planet

  1. // ==UserScript==
  2. // @name hoverTextbox
  3. // @description rewrites the information you get when you hover over a planet
  4. // @include http://play.planets.nu/*
  5. // @include http://test.planets.nu/*
  6. // @include http://planets.nu/*
  7. // @version 3.0.0
  8. // @homepage https://greasyfork.org/en/users/32642-stephen-piper
  9. // @namespace https://greasyfork.org/en/users/32642-stephen-piper
  10. // ==/UserScript==
  11.  
  12. //1 Humanoid - Any starbase that is built around a humanoid planet will have tech 10 hull technology automatically.
  13. //7 Amphibian - Any starbase that is built around a amphibian planet will have tech 10 beam technology automatically.
  14. //8 Ghipsoldal - Any starbase that is built around a ghipsoldal planet will have tech 10 engine technology automatically.
  15. //9 Siliconoid - Any starbase that is built around a siliconoid planet will have tech 10 torpedo technology automatically.
  16.  
  17.  
  18. //2 Bovinoid - Bovinoids are very valuable. Every 10000 Bovinoids will produce 1 supply unit per turn.
  19. //3 Reptilian - If there Reptilians living on a planet then your mining rate will be doubled.
  20. //4 Avian - Are quick to forgive you for overtaxing them. They will allow you to slightly overtax them without growing unhappy.
  21. //5 Amorphous - The only bad natives. The Amorphous lifeforms eat 500 colonists (5 clans) per turn.
  22. //6 Insectoid - Insectoids produce twice the normal amount of credits per turn per percentage as other native races.
  23.  
  24. function wrapper() {
  25. function hitText() {
  26. }
  27. hitText.prototype = {
  28. nativeTaxAmount : function(c, ntr) {
  29. var nt = 0;
  30. if (c.nativeclans > 0) {
  31. if (c.race == 6 && ntr > 20) { // borg == 6
  32. ntr = 20;
  33. }
  34.  
  35. var nt = (c.nativeclans / 100) * (ntr / 10) * (c.nativegovernment / 5);
  36.  
  37. nt = c.nativetype == 5 ? 0 : nt; // amorphous == 5
  38. nt *= c.race == 1 ? 2 : 1; // feds == 1
  39. nt *= c.nativetype == 6 ? 2 : 1; // insect == 6
  40.  
  41. nt = Math.round(nt);
  42. }
  43. return nt;
  44. },
  45.  
  46. nativesupportedtax : function(c) {
  47. ns = c.clans;
  48. ns *= c.race == 1 ? 2 : 1; // feds == 1
  49. ns *= c.nativetype == 6 ? 2 : 1; // insect == 6
  50. return ns;
  51. },
  52.  
  53. miningRate (p, ground, density) {
  54. m = vgap.miningRate(p, density);
  55. m = m > ground ? ground : Math.round(m);
  56.  
  57. return m;
  58. },
  59.  
  60. spendSuppliesMC : function(d, c, a) {
  61. if (c + a <= d.supplies + d.megacredits && c <= d.supplies) {
  62. if (d.megacredits < a) {
  63. var b = a - d.megacredits;
  64. d.megacredits += b;
  65. d.supplies -= b;
  66. d.suppliessold += b;
  67. // console.log(d.id + " supplies "+d.suppliessold +" mc " +
  68. // d.megacredits);
  69. }
  70. d.megacredits -= a;
  71. d.supplies -= c;
  72. d.changed = true;
  73. }
  74. },
  75.  
  76. sbBuildCost : function(sb) {
  77. var h = vgap.getHull(sb.buildhullid);
  78. mc = 0;
  79. if (h) {
  80. mc = h.cost;
  81. if (sb.buildingengineid > 0)
  82. mc += vgap.engines[sb.buildengineid - 1].cost * h.engines;
  83. if (sb.buildbeamcount > 0)
  84. mc += vgap.beams[sb.buildbeamid - 1].cost * sb.buildbeamcount;
  85. if (sb.buildtorpcount > 0)
  86. mc += vgap.torpedos[sb.buildtorpedoid - 1].cost * sb.buildtorpcount;
  87. }
  88.  
  89. return mc;
  90. },
  91. };
  92.  
  93. var oldHitTextBox = vgapMap.prototype.hitTextBox;
  94. vgapMap.prototype.hitTextBox = function(c) {
  95. // replace completely, pretty sure i want to do this
  96. // oldHitTextBox.apply(this, arguments);
  97.  
  98. var q = "";
  99. q += "<div class='ItemSelectionBox minCorrection'>";
  100. if (c.isPlanet) {
  101. if (c.id < 0) {
  102. c = vgap.getPlanet(-c.id);
  103. }
  104.  
  105. q += "<table class='CleanTable'>";
  106. if (c.ownerid == vgap.player.id && c.readystatus == 0)
  107. q += "<tr><td colspan='2' class='WarnText'>" + c.id + ":" + c.name + "</td>";
  108. else
  109. q += "<tr><td colspan='2'>" + c.id + ":" + c.name + "</td>";
  110. if (c.clans > 0) {
  111. q += "<td align='right' colspan='2'>&nbsp;" + c.clans + "</td>";
  112. q += "<td align='right'>&nbsp;" + c.friendlycode + "</td>";
  113. if (c.temp > 84 || c.temp < 15)
  114. q += "<td align='right' class='WarnText'>";
  115. else
  116. q += "<td align='right'>";
  117.  
  118. q += "&nbsp;" + c.temp + "</td>";
  119. }
  120. q += "</tr>";
  121. if (c.nativeclans > 0) {
  122. q += "<tr><td colspan='2'>" + c.nativeracename + "</td>";
  123. q += "<td align='right' colspan='2'>&nbsp;" + c.nativeclans + "</td>"
  124. if (c.ownerid == vgap.player.id) {
  125. q += "<td align='right'>&nbsp;" + c.nativehappypoints + "%</td>";
  126. q += "<td align='right'>&nbsp;" + c.nativetaxrate + "%</td>";
  127. }
  128. q += "</tr>";
  129. }
  130.  
  131. // if (vgap.player.status == 7 && !c) {
  132. // var e = ["None", "Colonization", "Build Starbase", "Supply
  133. // Starbase", "Exploration", "Build Special", "Attack", "Defend",
  134. // "Move Fuel"];
  135. // return "<tr><td colspan='" + a + "' class='WarnText'>" +
  136. // e[b.goal] + "-" + b.goaltarget + "</td></tr>"
  137. // }
  138.  
  139. if (c.infoturn != 0 && !vgap.godmode) {
  140. // q += this.hitText(c, c.isPlanet).replace("&nbsp", "");
  141.  
  142. var sp = c.factories;
  143.  
  144. var cs = 0;
  145. var nt = 0;
  146. var cs10 = 0;
  147. var nt10 = 0;
  148. var sps = 0;
  149. if (c.nativeclans > 0) {
  150. if (c.nativetype == 2) { // bovinoid
  151. spn = Math.floor(c.nativeclans / 100);
  152. sps = c.clans - spn;
  153. sp += sps > 0 ? spn : c.clans;
  154. }
  155.  
  156. nt = hitText.prototype.nativeTaxAmount(c, c.nativetaxrate);
  157. ns = hitText.prototype.nativesupportedtax(c);
  158. cs = ns - nt;
  159. nt = Math.min(nt, ns);
  160.  
  161. nt10 = hitText.prototype.nativeTaxAmount(c, 10);
  162. ns10 = hitText.prototype.nativesupportedtax(c);
  163. cs10 = ns10 - nt10;
  164. nt10 = Math.min(nt10, ns10);
  165. }
  166.  
  167. ct = Math.round(c.clans * c.colonisttaxrate / 1000);
  168.  
  169. mn = hitText.prototype.miningRate(c, c.groundneutronium, c.densityneutronium);
  170. md = hitText.prototype.miningRate(c, c.groundduranium, c.densityduranium);
  171. mm = hitText.prototype.miningRate(c, c.groundmolybdenum, c.densitymolybdenum);
  172. mt = hitText.prototype.miningRate(c, c.groundtritanium, c.densitytritanium);
  173.  
  174. q += "</table><table class='CleanTable'>";
  175. if (c.groundneutronium > 0) {
  176. q += "<tr><td>neu:</td><td align='right'>" + c.neutronium + "/&nbsp;</td><td align='right'>" + c.groundneutronium
  177. + "+&nbsp;</td><td align='right'>" + mn + "</td>";
  178. q += "<td>&nbsp;sup:</td><td align='right'>" + c.supplies + "+&nbsp;</td><td align='right'>" + sp + "-&nbsp;";
  179. if (sps < 0)
  180. q += "</td><td class='WarnText' align='right'>" + (-sps);
  181. q += "</td></tr>";
  182.  
  183. q += "<tr><td>dur:</td><td align='right'>" + c.duranium + "/&nbsp;</td><td align='right'>" + c.groundduranium
  184. + "+&nbsp;</td><td align='right'>" + md + "</td>";
  185. q += "<td>&nbsp;mc:</td><td align='right'>" + c.megacredits + "+&nbsp;</td><td align='right'>" + (nt + ct) + "-&nbsp;";
  186. if (cs < 0)
  187. q += "</td><td class='WarnText' align='right'>" + (-cs);
  188.  
  189. q += "</td></tr>";
  190.  
  191. q += "<tr><td>tri:</td><td align='right'>" + c.tritanium + "/&nbsp;</td><td align='right'>" + c.groundtritanium
  192. + "+&nbsp;</td><td align='right'>" + mt + "</td>";
  193. if (c.nativeclans > 0) {
  194. q += "<td>&nbsp;10%:</td><td>&nbsp;</td><td align='right'>" + nt10 + "-&nbsp;";
  195. if (cs10 < 0)
  196. q += "</td><td class='WarnText' align='right'>" + (-cs10);
  197. }
  198. q += "</td></tr>";
  199.  
  200. q += "<tr><td>mol:</td><td align='right'>" + c.molybdenum + "/&nbsp;</td><td align='right'>" + c.groundmolybdenum
  201. + "+&nbsp;</td><td align='right'>" + mm + "</td>";
  202.  
  203. q += "<td>&nbsp;m/f/d:</td><td colspan=2>&nbsp;" + c.mines + " / " + c.factories + " / " + c.defense + "<td>";
  204. q += "</tr>";
  205.  
  206. var n = vgap.getStarbase(c.id);
  207. if (n != null
  208. && (c.ownerid == vgap.player.id || vgap.fullallied(c.ownerid))) {
  209. if (n.starbasetype != 2) {
  210. if (n.isbuilding)
  211. q += "<tr><td colspan='6'>bld:&nbsp;" + vgap.getHull(n.buildhullid).name + "</td></tr>";
  212. else
  213. q += "<tr><td colspan='6' class='WarnText'>SB Not Building</td></tr>";
  214. }
  215. }
  216. }
  217. }
  218. if (c.ownerid != vgap.player.id && c.ownerid != 0) {
  219. var k = vgap.getPlayer(c.ownerid);
  220. var l = vgap.getRace(k.raceid);
  221. q += "<tr><td colspan='4'>" + l.adjective + " (" + k.username + ")</td></tr>"
  222. }
  223. q += this.hitText(c, c.isPlanet).replace("&nbsp", "")
  224. q += "</table>";
  225.  
  226. }
  227. else {
  228. if (c.id < 0) {
  229. c = vgap.getShip(-c.id)
  230. }
  231.  
  232. var m = c;
  233. var e = vgap.getHull(m.hullid);
  234. var k = vgap.getPlayer(m.ownerid);
  235.  
  236. var d = "<table class='CleanTable'>";
  237. if (m.ownerid == vgap.player.id && m.readystatus == 0)
  238. d += "<tr><td colspan='4' class='WarnText'>" + m.id + ":" + e.name + "</td></tr>";
  239. else
  240. d += "<tr><td colspan='4' >" + m.id + ":" + e.name + "</td></tr>";
  241. if (m.ownerid == vgap.player.id || vgap.fullallied(m.ownerid)) {
  242.  
  243. d += "<tr><td>neu:</td><td>&nbsp;" + gsv(m.neutronium) + "/" + e.fueltank + " </td>";
  244. d += "<td>&nbsp;fc:</td><td>&nbsp;" + m.friendlycode + "</td></tr>";
  245.  
  246. cl = "";
  247. if (m.clans != 0)
  248. cl = "<td>clns:</td><td>&nbsp;" + gsv(m.clans) + "</td>";
  249. cs = "<td>sup:</td><td>&nbsp;" + gsv(m.supplies) + "</td>";
  250. mc = "<td>mc:</td><td>&nbsp;" + gsv(m.megacredits) + "</td>";
  251. if (m.duranium != 0 || m.tritanium != 0 || m.molybdenum != 0) {
  252. d += "<tr><td>dur:</td><td>&nbsp;" + gsv(m.duranium) + "</td>" + cs + "</tr>";
  253. d += "<tr><td>tri:</td><td>&nbsp;" + gsv(m.tritanium) + "</td>" + mc + "</tr>";
  254. d += "<tr><td>mol:</td><td>&nbsp;" + gsv(m.molybdenum) + "</td>" + cl + "</tr>";
  255.  
  256. }
  257. else {
  258. if (m.supplies != 0 || m.megacredits != 0)
  259. d += "<tr>" + cs + mc + "</tr>";
  260. if (m.clans != 0 && cl != "")
  261. d += "<tr>" + cl + "</tr>";
  262. }
  263. if (m.bays > 0 || m.torps > 0 || m.beams > 0) {
  264. d += "<tr>";
  265. if (m.beams > 0) {
  266. d += "<td colspan='2'>beam/tech:&nbsp;" + m.beams + "/" + m.beamid + "</td>";
  267. }
  268. if (m.bays > 0) {
  269. d += "<td colspan='2'>fgtr:&nbsp;" + gsv(m.ammo) + "</td>";
  270. }
  271. if (m.torps > 0) {
  272. d += "<td colspan='2'>torp/tech:&nbsp;" + gsv(m.ammo) + "/" + m.torpedoid + "</td>";
  273. }
  274.  
  275. d += "</tr>";
  276. }
  277. if (c.ownerid == vgap.player.id) {
  278.  
  279. e = "<tr>";
  280. // if (m.mission != 0 && m.mission != 4) {
  281. if (m.mission == 9)
  282. e += "<td colspan='3' class='GoodText'>";
  283. else
  284. e += "<td colspan='3'>";
  285.  
  286. e += vgap.getShipMissionShortText(m);
  287. e += ((m.mission == 6 || m.mission == 7 || m.mission == 15 || m.mission == 20) && m.mission1target != 0 ? "&nbsp;"
  288. + m.mission1target : "");
  289. e += "</td>";
  290. // }
  291.  
  292. if (m.enemy > 0) {
  293. s = vgap.getRace(m.enemy).adjective;
  294. s = s.replace(/^The (.+)/, "$1");
  295.  
  296. e += "<td colspan='5' class='WarnText'>" + s + "</td>";
  297. }
  298. e += "</tr>";
  299. if (m.x != m.targetx && m.y != m.targety) {
  300. t = Math.round(Math.dist(m.x, m.y, m.targetx, m.targety) * 10) / 10;
  301. e += "</tr><tr>";
  302. if (m.target != null && m.target.name != null)
  303. e += "<td colspan='2'>" + m.target.id + ":&nbsp;" + m.target.name + "</td>";
  304. else
  305. e += "<td colspan='2'>(" + m.targetx + "," + m.targety + ")</td>";
  306. e += "<td>&nbsp;" + t + " ly</td>";
  307.  
  308. // var t = Math.round(Math.dist(m.x, m.y, m.targetx, m.targety));
  309.  
  310. trn = Math.ceil(t / (m.warp * m.warp + .4));
  311. if (m.friendlycode == "HYP") {
  312. if (t >= 340 && t <= 360 && m.warp > 0) {
  313. e += "<td>";
  314. trn = 1;
  315. }
  316. else
  317. e += "<td class='BadText'>";
  318. }
  319. else if (trn > 1)
  320. e += "<td class='WarnText'>";
  321. else
  322. e += "<td>";
  323.  
  324. e += "&nbsp;" + trn + "&nbsp;trns</td>";
  325. }
  326. if (e != "<tr>")
  327. d += e + "</tr>";
  328. if (m.damage > 0) {
  329. d += "<td>dam:</td><td class='BadText'>&nbsp;" + m.damage + "</td>"
  330. }
  331. else {
  332. d += "<td/></td>"
  333. }
  334. // }
  335. d += "</tr>"
  336. }
  337. if (c.ownerid != vgap.player.id && vgap.accountsettings.hoverallyplayer) {
  338. d += "<tr><td colspan='4'>" + l.adjective + " (" + k.username + ")</td></tr>"
  339. }
  340.  
  341. d += "</table>"
  342. }
  343. else {
  344. q += "<div>" + vgap.getRace(k.raceid).adjective + " (" + vgap.getPlayer(c.ownerid).username + ")</div>";
  345.  
  346. d += "<table class='CleanTable'>";
  347. d += "<tr><td>Heading:</td><td>&nbsp;" + gsv(m.heading) + " at Warp: " + gsv(m.warp) + "</td></tr>";
  348. d += "<tr><td>Mass: </td><td>&nbsp;" + gsv(m.mass) + "</td></tr>";
  349. if (vgap.player.raceid == 7) {
  350. for (var f = 0; f < vgap.messages.length; f++) {
  351. var g = vgap.messages[f];
  352. if (g.messagetype == 12 && g.target == m.id) {
  353. d += "<tr><td class='BadText'>OUT OF FUEL</td></tr>";
  354. break
  355. }
  356. }
  357. }
  358. if (m.iscloaked) {
  359. d += "<tr><td colspan='2' class='GoodText'>Cloaked</td></tr>"
  360. }
  361. d += this.hitText(c, c.isPlanet).replace("&nbsp", "");
  362. d += "</table>"
  363. }
  364. q += d
  365. }
  366. q += "</div>";
  367. return q
  368. };
  369.  
  370. //shipSurvey
  371.  
  372. var oldShowInfo = vgapMap.prototype.showInfo;
  373. vgapMap.prototype.showInfo = function(a, b) {
  374. // replace completely
  375. // oldShowInfo.apply(this, arguments);
  376.  
  377. var h = Math.round(vgap.map.mapX(a));
  378. var j = Math.round(vgap.map.mapY(b));
  379. var c = null;
  380. if (h > 0 && h < 4000 && j > 0 && j < 4000) {
  381. c = vgap.map.checkForHit(h, j)
  382. }
  383. vgap.map.over = c;
  384. vgap.map.x = h;
  385. vgap.map.y = j;
  386. var f = "<span class='coordDisplay titleSelectionBox'> x: " + h + " y: " + j + " </span>";
  387. if (c) {
  388. if (c.isPlanet) {
  389. f += vgap.map.hitTextBox(c)
  390. }
  391. var e = vgap.shipsAt(c.x, c.y);
  392. for (var d = 0; d < e.length; d++) {
  393. f += vgap.map.hitTextBox(e[d])
  394. }
  395. }
  396.  
  397. var g = "";
  398. g += vgap.map.ionText(h, j);
  399. g += vgap.map.mineText(h, j);
  400. g += vgap.map.nebText(h, j);
  401. g += vgap.map.starText(h, j);
  402. g += vgap.map.debrisText(h, j);
  403. if (g != "undefined") {
  404. f += g;
  405. }
  406. if (vgap.map.zoom != 1) {
  407. f += "<div class='ItemSelectionBox minCorrection'>Zoom: " + Math.round(vgap.map.zoom * 100) + "% </div>"
  408. }
  409. vgap.map.loc.html("<div class='ItemSelection_border'>" + f + "</div>");
  410. vgap.map.container.css("cursor", "inherit");
  411. if (vgap.map.over) {
  412. if (vgap.map.activePlanet == null && vgap.map.activeShip == null) {
  413. vgap.map.container.css("cursor", "pointer")
  414. }
  415. else {
  416. vgap.map.container.css("cursor", "pointer")
  417. }
  418. }
  419. };
  420.  
  421. var oldShowAssembly = vgapStarbaseScreen.prototype.showAssembly;
  422. vgapStarbaseScreen.prototype.showAssembly = function() {
  423. oldShowAssembly.apply(this, arguments);
  424.  
  425. s = {
  426. "top" : "57px",
  427. "position" : "absolute",
  428. "line-height" : "16px",
  429. "height" : "14px",
  430. "padding" : "0 24px",
  431. "right" : "14px",
  432. };
  433.  
  434. $("<div class='MoreActionButton' id='SellSuppliesButton'>Sell</div>")
  435. .appendTo("#BuyShipBox")
  436. .tclick(function() {
  437.  
  438. // c = hitText.prototype.sbBuildCost(vgap.starbaseScreen.starbase);
  439. var v = $("#BuildShipCost .val").contents();
  440. c = v[7].data;
  441.  
  442. p = vgap.starbaseScreen.planet;
  443. mc = p.megacredits;
  444. sp = p.supplies;
  445.  
  446. n = c - mc;
  447. if (n > 0) {
  448. if (sp - n > 0) {
  449. p.megacredits += n;
  450. p.supplies -= n;
  451. p.suppliessold += n;
  452. p.changed = 1;
  453. if (v[8].data != undefined)
  454. v[8].data = p.megacredits;
  455. else if (v[8].childNodes.length > 0) {
  456. v[8].className = "GreatText";
  457. v[8].childNodes[0].data = p.megacredits;
  458. }
  459.  
  460. $("#SellSuppliesVar").replaceWith("<div id='SellSuppliesVar'>" + p.supplies + "</div>");
  461. $("#SellSuppliesVar").css(s);
  462. }
  463. }
  464.  
  465. });
  466.  
  467. // c = hitText.prototype.sbBuildCost(vgap.starbaseScreen.starbase);
  468. var v = $("#BuildShipCost .val").contents();
  469. if (v != undefined && v[7] != undefined) {
  470. c = v[7].data;
  471.  
  472. p = vgap.starbaseScreen.planet;
  473. mc = p.megacredits;
  474. sp = p.supplies;
  475.  
  476. r = mc - c;
  477. if (r > 0)
  478. q = "";
  479. else {
  480. r += sp;
  481. if (r > 0)
  482. q = " class='GreatText'";
  483. else
  484. q = " class='BadText'";
  485. }
  486.  
  487. $("#SellSuppliesButton").css(s);
  488.  
  489. $("<div id='SellSuppliesHdr'>Supplies</div>").appendTo("#BuyShipBox");
  490. s.top = 18;
  491. s.padding = "0 20";
  492. $("#SellSuppliesHdr").css(s);
  493.  
  494. s.top = 36;
  495. $("<div id='SellSuppliesVar'" + q + ">" + p.supplies + "</div>").appendTo("#BuyShipBox");
  496. $("#SellSuppliesVar").css(s);
  497. }
  498. };
  499.  
  500. var oldRenderScreen = vgapTransferScreen.prototype.renderScreen;
  501. vgapTransferScreen.prototype.renderScreen = function() {
  502. oldRenderScreen.apply(this, arguments);
  503.  
  504. e = vgap.getHull(this.to.hullid).name;
  505.  
  506. var to = this.to.id + ":" + e;
  507. if (this.from.isPlanet != undefined && this.from.isPlanet == true) {
  508. var from = this.from.id + ":" + this.from.name;
  509. var title = "planet\>ship";
  510. }
  511. else {
  512. e = vgap.getHull(this.from.hullid).name;
  513.  
  514. var from = this.from.id + ":" + e;
  515. title = "ship\>ship";
  516. }
  517.  
  518. var html = "<table style='width:100%'><tr>";
  519. html += "<td>" + from + "</td>";
  520. html += "<td style='text-align:center'>" + title + "</td>";
  521. html += "<td style='text-align:right'>" + to + "</td>";
  522. html += "</tr></table>";
  523.  
  524. var m = "#MoreScreen ";
  525. var t = "#MoreScreen #TransferScreen ";
  526.  
  527. $(t+".TransferTitle").replaceWith(html);
  528. $(t+".LeftRight1000 .lrtext-small").remove();
  529. $(t+"h1").remove();
  530. $(t+".valsup").replaceWith("<td><div>&nbsp;</div></td>");
  531.  
  532. // t+$(".SellSuppliesTable").remove();
  533. $(t+"td:contains('Total')").replaceWith("<td><div>&nbsp;</div></td>");
  534. // t+$("td:contains('Build Fighters')").parent().remove();
  535.  
  536. s = {
  537. "width" : "230px"
  538. };
  539. $(t+".LeftRight1000").css(s);
  540.  
  541. s = {
  542. "width" : "24px",
  543. "height" : "22px"
  544. };
  545. $(t+".sac-small").css(s);
  546.  
  547. s = {
  548. "width" : "420px"
  549. };
  550. $(m).css(s);
  551. $(m).css(s);
  552.  
  553. s = {
  554. "font-weight" : "normal",
  555. "color" : "white"
  556. };
  557. $(t+".TransferVal").css(s);
  558.  
  559. // var st = $("#MoreScreen #TransferScreen #SuppliesTransfer").parent().parent().detach();
  560. // st.insertBefore($("#MoreScreen #TransferScreen #MoneyTransfer").parent().parent());
  561.  
  562.  
  563. };
  564.  
  565. var oldShipTransferView = sharedContent.prototype.shipTransferView;
  566. sharedContent.prototype.shipTransferView = function(e) {
  567. // oldShipTransferView.apply(this, arguments);
  568.  
  569. d = vgap.map.hitTextBox(e);
  570. return d;
  571. };
  572.  
  573. var oldPlanetTransferView = sharedContent.prototype.planetTransferView;
  574. sharedContent.prototype.planetTransferView = function(e) {
  575. // oldPlanetTransferView.apply(this, arguments);
  576.  
  577. d = vgap.map.hitTextBox(e);
  578. return d;
  579. };
  580.  
  581. var oldTransfer = vgapPlanetScreen.prototype.transfer;
  582. vgapPlanetScreen.prototype.transfer = function() {
  583. oldTransfer.apply(this, arguments);
  584.  
  585. s = {
  586. "width" : "210px",
  587. "font-weight" : "normal",
  588. "font-size" : "11px",
  589. "line-height" : "12px"
  590. };
  591. $("#SelectLocation").css(s);
  592.  
  593. $("#MoreScreen").width("210px");
  594. };
  595. var oldDrawShip = vgapMap.prototype.drawShip;
  596. vgapMap.prototype.drawShip = function(ship, ctx) {
  597. oldDrawShip.apply(this, arguments);
  598.  
  599. if (vgap.canInitiateChunnel(ship)) {
  600. var b = vgap.getChunnelTarget(ship);
  601. if (b != null && vgap.isValidChunnelTarget(ship, b)) {
  602. d = Math.round(Math.dist(ship.x, ship.y, b.x, b.y) * 10) / 10;
  603.  
  604. a = (ship.x - b.x) / d;
  605. a = Math.degrees(Math.acos(a));
  606. e = (ship.y - b.y) / d;
  607. e = Math.degrees(Math.asin(e));
  608. ax = Math.cos(Math.radians(a)) * d * .1;
  609. x = b.x + ax;
  610. ay = Math.sin(Math.radians(e)) * d *.1;
  611. y = b.y + ay;
  612.  
  613. d = 30;
  614.  
  615. // yellow
  616. ax = Math.cos(Math.radians(a-15)) * d;
  617. x1 = x + ax;
  618. // console.log(ship.id+" x:"+x+" ax:"+ax+" x1:"+x1+" a:"+a);
  619.  
  620. ay = Math.sin(Math.radians(e-15)) * d;
  621. y1 = y + ay;
  622. // console.log(" "+b.id+" y:"+y+" ay:"+ay+" y1:"+y1+" e:"+e);
  623.  
  624. // red
  625. ax = Math.cos(Math.radians(a+15)) * d;
  626. x2 = x + ax;
  627.  
  628. ay = Math.sin(Math.radians(e+15)) * d;
  629. y2 = y + ay;
  630.  
  631. // ctx.beginPath();
  632. // ctx.moveTo(this.screenX(b.x), this.screenY(b.y));
  633. // ctx.lineTo(this.screenX(x), this.screenY(y));
  634. // ctx.strokeStyle = "orange";
  635. // ctx.stroke();
  636.  
  637. ctx.beginPath();
  638. ctx.moveTo(this.screenX(x1), this.screenY(y1));
  639. ctx.lineTo(this.screenX(x), this.screenY(y));
  640. // ctx.strokeStyle = "aqua";
  641. // ctx.stroke();
  642. //
  643. // ctx.beginPath();
  644. // ctx.moveTo(this.screenX(x), this.screenY(y));
  645. ctx.lineTo(this.screenX(x2), this.screenY(y2));
  646. ctx.strokeStyle = "aqua";
  647. ctx.stroke();
  648. }
  649. }
  650. };
  651.  
  652. //Converts from degrees to radians.
  653. Math.radians = function(degrees) {
  654. return degrees * Math.PI / 180;
  655. };
  656. // Converts from radians to degrees.
  657. Math.degrees = function(radians) {
  658. return radians * 180 / Math.PI;
  659. };
  660.  
  661. }
  662. ;
  663.  
  664. var script = document.createElement("script");
  665. script.type = "application/javascript";
  666. script.textContent = "(" + wrapper + ")();";
  667.  
  668. document.body.appendChild(script);