WarChiefs - Tiberium Alliances Combat Simulator

Combat Simulator used to plan and strategize attack before going into battle.

  1. // ==UserScript==
  2. // @name WarChiefs - Tiberium Alliances Combat Simulator
  3. // @description Combat Simulator used to plan and strategize attack before going into battle.
  4. // @author Eistee
  5. // @version 13.09.26
  6. // @namespace https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  7. // @include https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  8. // @icon http://eistee82.github.io/ta_simv2/icon.png
  9. // ==/UserScript==
  10. /**
  11. * License: CC-BY-NC-SA 3.0
  12. *
  13. * Although I am the author of this script, I want to also give credit to other authors who's methods and ideas are or might appear in this script.
  14. * Credits: Topper42, Eferz98, PythEch, MrHIDEn, Panavia2, Deyhak, CodeEcho, Matthias Fuchs, Enceladus, TheLuminary, Da Xue, Quor, WildKatana, Peluski17, Elda1990, TheStriker, JDuarteDJ, null
  15. */
  16. (function () {
  17. var injectFunction = function () {
  18. function createClasses() {
  19. qx.Class.define("Simulator", {
  20. type: "singleton",
  21. extend: qx.core.Object,
  22. construct: function () {
  23. try {
  24. var qxApp = qx.core.Init.getApplication();
  25. this.armyBar = qx.core.Init.getApplication().getArmySetupAttackBar();
  26. this.playArea = qx.core.Init.getApplication().getMainOverlay();
  27. this.replayBar = qx.core.Init.getApplication().getReportReplayOverlay();
  28. this.isSimButtonDisabled = false;
  29. this.armyTempFormations = [];
  30. this.armyTempIdx = 0;
  31. this.isSimulation = false;
  32. this.hideArmyTooltips();
  33.  
  34. /**
  35. * Setup Images
  36. */
  37.  
  38. var i, img = {
  39. Arrows: {
  40. Up: "webfrontend/theme/arrows/up.png",
  41. Down: "webfrontend/theme/arrows/down.png",
  42. Left: "webfrontend/theme/arrows/left.png",
  43. Right: "webfrontend/theme/arrows/right.png"
  44. },
  45. Flip: {
  46. H: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAACo0lEQVQ4T2PABkJq+rjmH7nUdPrV119nXn/9s+7S/R1NCzc4rTx1a8ay41c7WuYsl5WRkWGEKicM4honSux7+Pb42Tdf/4LwwacfP7Wv3pOz8sydVavO3lk5f9cx15jCGhaocsJgys7jAUeffXiGZODn1lW7Claeub16xelb64C4Ma+lnx+qHD/wySpjXnnqeifQq79RDFy5qxBq4PqVp25Ombxmhw4QQHXhAdH1fWL77r++DDToD04Dz9xeteDAuajc1gn4ve0UkciU3zvT4vTrb79ghmEzEOTtNefvL8pomyrExsYG1Y0FxNT18my4dH8KKGYJGLgeGDkrJqzeoR9ZWMMM1Y4Jercctjr46N1NZMNwGQhy5YpTN/PzWvu5oNpRgUdGGdOc/WfST736guJdPAauX3HiekfH4vXyUCNQQVhtn8D2W8+2nEGKDEIGgrw9a+cxeyUlJdRE7pldxZjcOlXj6LOPj9ENw2cgkL9m2dHL2TGljZxQoyAgrKaHdfmZWxVA734jxUAQXnXm9tS6yXMlTG2doKYBQWrrZIHNVx4sBWrG8C4I4zNw5enbi+ftPuGSVNGMiO2edXstjz3/9BabYSBMwMC1y09cr2pbvFEIbJh/RinrlI1744CRAc9q6BifgSC8+tzdpT1rdmuAE3l80yTZ/UglCzZMyECQ+MID58NiyprYGGbuO5t1/MWn99gMgmFCBoLwytO3Wir6ZggzLDpycQJyyYINH3r66WP7mj25wPDCZ+DsSRv2WTAsPHCmChgh7068/PwTGz4OlFtz+npX7/p9LstP3WwA4hZseMXp2w3Td56wYyho6lSdsfNY6YzdJydM330CBYPEQHIVnROVIzMLOIvb+oVq+meIVPVOQ8EgsYqeqUJJpfWcAKWymA2EsiGlAAAAAElFTkSuQmCC",
  47. V: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAClklEQVQ4T2MgB/iVd7CH1/SI9G3YF7D4+JUlR59/+nH61dff8w6cnQBVgh+EN01hjGqZxpY9eYlI39YjNvMOni888Ojd0aNP3z8+8/rr77Nvvv498+brn/n7T0+HasEOIlpnMIc1TBIJq+vX3HjtSd/ma4/WnHj59TtQM9gQZAwycO7ekzOhWhHAo6CRKaymh6d69krVWfvOpO19+O700WcfYS75g24QDGMYCPQWS1TzFKmktmkmO26/XLHv3sujwHD5CVSM0xBkDDcwqLJLcMHxa/FLT17rOPz04/PTb779wqaBEIYbOHv/2ZxjLz6/BglgU0gshhu44MDZaUABigwDYbCB+07NZJi29WDFvrsvLu+78/waDnwdixgmBpoxbduhMgav6ETZyNxSm+j8creoPPJwdH4FkC6z9o1NlWaYsnGf0ZpzdyeuOnt3GSUYZMZUoFkMk7ceDV555s6KFadvrQPi9eRioBmrpu44EcLQvHijweJDFzJWnrrRu/LM7VVASbIMBupdPWX78TAGt8Bw1oSsfL6qCbMUp2855Lvk+LXGFaduTgcpACpci64RF4YbCALe3t6MLi4uTC6BEZwhqXnC3Us3ms7acSxi+YlrLaDwgRqO1SAYRjEQGYAMB2JmN08v9vCMAuGWafPVFu4/E7H8+NWaVWduz11x+vYakgyEAaChDEBXM3r5+rOGJmVwlzZ1Svav2m656NDFghWnbk0FGrAEaBAoSMBhTtBAdAByuZOrO4t7eDxfWlWz7IztR70WHDiXA3T1jFVn76wE4hVTtx8PhionDoBc7eDgwODq4ckcFJPEHp9TJNA0e5n6tPU77ZcfvZLaNnupClQpeQDkaktLS2Y3Hz9Ov8h4XltnV3YAMTRvewY5T1wAAAAASUVORK5CYII="
  48. },
  49. DisableUnit: "FactionUI/icons/icon_disable_unit.png",
  50. Undo: "FactionUI/icons/icon_refresh_funds.png"
  51. };
  52.  
  53. /**
  54. * Setup Buttons
  55. */
  56.  
  57. //Simulation Button//
  58. this.simBtn = new qx.ui.form.Button(qxApp.tr("Simulate")).set({toolTipText: qxApp.tr("Opens Simulation Screen."), width: 60, height: 28, alignY: "middle", appearance: "button-text-small"});
  59. this.simBtn.addListener("click", function () { this.__openSimulatorWindow(); }, this);
  60. this.armyBar.add(this.simBtn, {left: null, right: 58, bottom: 119});
  61.  
  62. //Simulator Stats Button//
  63. this.statBtn = new qx.ui.form.Button(qxApp.tr("Stats")).set({toolTipText: qxApp.tr("Opens Simulator Stats Window."), width: 60, height: 28, alignY: "middle", appearance: "button-text-small"});
  64. this.statBtn.addListener("click", function () { this.__openStatWindow(); }, this);
  65. this.armyBar.add(this.statBtn, {left: null, right: 58, bottom: 81});
  66.  
  67. //Simulator Options Button//
  68. this.optionBtn = new qx.ui.form.Button(qxApp.tr("Options")).set({toolTipText: qxApp.tr("Opens Simulator Options."), width: 60, height: 28, alignY: "middle", appearance: "button-text-small"});
  69. this.optionBtn.addListener("click", function () { this.__openOptionWindow(); }, this);
  70. this.armyBar.add(this.optionBtn, {left: null, right: 58, bottom: 43});
  71.  
  72. //Simulator Layout Button//
  73. this.layoutBtn = new qx.ui.form.Button(qxApp.tr("Layout")).set({toolTipText: qxApp.tr("Save/Load/Delete Unit Formations for current city."), width: 60, height: 28, alignY: "middle", appearance: "button-text-small"});
  74. this.layoutBtn.addListener("click", function () { this.__openLayoutWindow(); }, this);
  75. this.armyBar.add(this.layoutBtn, {left: null, right: 58, bottom: 6});
  76.  
  77. //Simulator Unlock Combat Button//
  78. this.unlockCmtBtn = new qx.ui.form.Button(qxApp.tr("Unlock")).set({toolTipText: qxApp.tr("Unlock Combat Button."), width: 44, height: 44, opacity: 0.4, padding : 0, alignY: "middle", appearance: "button-text-small"});
  79. this.unlockCmtBtn.addListener("click", function () { this.timeoutCmtBtn(); }, this);
  80. this.armyBar.add(this.unlockCmtBtn, {left: null, right: 10, bottom: 8});
  81.  
  82. //Simulator Unlock Repair Time Button//
  83. this.unlockRTBtn = new qx.ui.form.Button(qxApp.tr("Unlock")).set({toolTipText: qxApp.tr("Unlock Repair Button."), width: 44, height: 44, opacity: 0.4, padding : 0, alignY: "middle", appearance: "button-text-small"});
  84. this.unlockRTBtn.addListener("click", function () { this.timeoutRTBtn(); }, this);
  85. this.armyBar.add(this.unlockRTBtn, {left: null, right: 10, bottom: 100});
  86.  
  87. //Formation Shift Buttons//
  88. this.shiftUpBtn = new qx.ui.form.Button("", img.Arrows.Up).set({toolTipText: qxApp.tr("Shifts units one space up."), width: 30, height: 20, alignY: "middle", appearance: "button-text-small", gap: 0, iconPosition: "top", show: "icon"});
  89. this.shiftUpBtn.addListener("click", function () { this.shiftFormation("u"); }, this);
  90. this.shiftUpBtn.hide();
  91. this.playArea.add(this.shiftUpBtn, {left: null, right: 75, bottom: 113});
  92.  
  93. this.shiftDownBtn = new qx.ui.form.Button("", img.Arrows.Down).set({toolTipText: qxApp.tr("Shifts units one space down."), width: 30, height: 20, alignY: "middle", appearance: "button-text-small", gap: 0, iconPosition: "top", show: "icon"});
  94. this.shiftDownBtn.addListener("click", function () { this.shiftFormation("d"); }, this);
  95. this.shiftDownBtn.hide();
  96. this.playArea.add(this.shiftDownBtn, {left: null, right: 75, bottom: 73});
  97.  
  98. this.shiftLeftBtn = new qx.ui.form.Button("", img.Arrows.Left).set({toolTipText: qxApp.tr("Shifts units one space left."), width: 30, height: 20, alignY: "middle", appearance: "button-text-small", gap: 0, iconPosition: "top", show: "icon"});
  99. this.shiftLeftBtn.addListener("click", function () { this.shiftFormation("l"); }, this);
  100. this.shiftLeftBtn.hide();
  101. this.playArea.add(this.shiftLeftBtn, {left: null, right: 95, bottom: 93});
  102.  
  103. this.shiftRightBtn = new qx.ui.form.Button("", img.Arrows.Right).set({toolTipText: qxApp.tr("Shifts units one space right."), width: 30, height: 20, alignY: "middle", appearance: "button-text-small", gap: 0, iconPosition: "top", show: "icon"});
  104. this.shiftRightBtn.addListener("click", function () { this.shiftFormation("r"); }, this);
  105. this.shiftRightBtn.hide();
  106. this.playArea.add(this.shiftRightBtn, {left: null, right: 55, bottom: 93});
  107.  
  108. for (i = 0; i < ClientLib.Base.Util.get_ArmyMaxSlotCountY(); i++) {
  109. var btnMirrorH = new qx.ui.form.Button(i, img.Flip.H).set({toolTipText: qxApp.tr("Mirrors units horizontally."), width: 19, maxHeight: 25, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints"});
  110. btnMirrorH.addListener("click", function (e) { this.mirrorFormation("h", parseInt(e.getTarget().getLabel(), 10)); }, this);
  111. btnMirrorH.getChildControl("icon").set({width: 16, height: 16, scale: true});
  112. var shiftLeftBtn = new qx.ui.form.Button(i, img.Arrows.Left).set({toolTipText: qxApp.tr("Shifts units one space left."), width: 20, maxHeight: 25, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints"});
  113. shiftLeftBtn.addListener("click", function (e) { this.shiftFormation("l", parseInt(e.getTarget().getLabel(), 10)); }, this);
  114. var shiftRightBtn = new qx.ui.form.Button(i, img.Arrows.Right).set({toolTipText: qxApp.tr("Shifts units one space right."), width: 20, maxHeight: 25, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints"});
  115. shiftRightBtn.addListener("click", function (e) { this.shiftFormation("r", parseInt(e.getTarget().getLabel(), 10)); }, this);
  116.  
  117. var cntWave = this.armyBar.getMainContainer().getChildren()[(i+4)];
  118. cntWave.removeAll();
  119. cntWave.setLayout(new qx.ui.layout.HBox());
  120. cntWave.add(btnMirrorH);
  121. cntWave.add(new qx.ui.core.Spacer(), {flex: 1});
  122. cntWave.add(shiftLeftBtn);
  123. cntWave.add(shiftRightBtn);
  124. }
  125. var formation = this.armyBar.getMainContainer().getChildren()[1].getChildren()[0];
  126. var btnHBox = new qx.ui.container.Composite(new qx.ui.layout.HBox());
  127. var btnHBoxouter = new qx.ui.container.Composite(new qx.ui.layout.HBox());
  128. btnHBoxouter.add(new qx.ui.core.Spacer(), {flex: 1});
  129. btnHBoxouter.add(btnHBox);
  130. btnHBoxouter.add(new qx.ui.core.Spacer(), {flex: 1});
  131. this.armyBar.add(btnHBoxouter, { left : 16, top : 7, right : 0});
  132. formation.bind("changeWidth", btnHBox, "width");
  133.  
  134. for (i = 0; i < ClientLib.Base.Util.get_ArmyMaxSlotCountX(); i++) {
  135. var btnMirrorV = new qx.ui.form.Button(i, img.Flip.V).set({toolTipText: qxApp.tr("Mirrors units vertically."), width: 25, maxHeight: 19, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints", opacity: 0.3});
  136. btnMirrorV.addListener("click", function (e) { this.mirrorFormation("v", parseInt(e.getTarget().getLabel(), 10)); }, this);
  137. btnMirrorV.addListener("mouseover", function (e) { e.getTarget().set({opacity: 1.0}); }, this);
  138. btnMirrorV.addListener("mouseout", function (e) { e.getTarget().set({opacity: 0.3}); }, this);
  139. btnMirrorV.getChildControl("icon").set({width: 14, height: 14, scale: true});
  140. var btnShiftUp = new qx.ui.form.Button(i, img.Arrows.Up).set({toolTipText: qxApp.tr("Shifts units one space up."), width: 25, maxHeight: 19, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints", opacity: 0.3});
  141. btnShiftUp.addListener("click", function (e) { this.shiftFormation("u", parseInt(e.getTarget().getLabel(), 10)); }, this);
  142. btnShiftUp.addListener("mouseover", function (e) { e.getTarget().set({opacity: 1.0}); }, this);
  143. btnShiftUp.addListener("mouseout", function (e) { e.getTarget().set({opacity: 0.3}); }, this);
  144. var btnShiftDown = new qx.ui.form.Button(i, img.Arrows.Down).set({toolTipText: qxApp.tr("Shifts units one space down."), width: 25, maxHeight: 19, alignY: "middle", show: "icon", iconPosition: "top", appearance: "button-addpoints", opacity: 0.3});
  145. btnShiftDown.addListener("click", function (e) { this.shiftFormation("d", parseInt(e.getTarget().getLabel(), 10)); }, this);
  146. btnShiftDown.addListener("mouseover", function (e) { e.getTarget().set({opacity: 1.0}); }, this);
  147. btnShiftDown.addListener("mouseout", function (e) { e.getTarget().set({opacity: 0.3}); }, this);
  148. btnHBox.add(new qx.ui.core.Spacer(), {flex: 1});
  149. btnHBox.add(btnMirrorV);
  150. btnHBox.add(new qx.ui.core.Spacer().set({ width: 2 }));
  151. btnHBox.add(btnShiftUp);
  152. btnHBox.add(btnShiftDown);
  153. btnHBox.add(new qx.ui.core.Spacer(), {flex: 1});
  154. }
  155.  
  156. //Formation Mirror Buttons//
  157. this.mirrorBtnH = new qx.ui.form.Button("", img.Flip.H).set({toolTipText: qxApp.tr("Mirrors units horizontally."), show: "icon", width: 35, height: 35, center: true, alignY: "middle", appearance: "button-text-small"});
  158. this.mirrorBtnH.getChildControl("icon").set({width: 20, height: 20, scale: true});
  159. this.mirrorBtnH.addListener("click", function () { this.mirrorFormation("h"); }, this);
  160. this.mirrorBtnH.hide();
  161. this.playArea.add(this.mirrorBtnH, {left: null, right: 6, bottom: 160});
  162.  
  163. this.mirrorBtnV = new qx.ui.form.Button("", img.Flip.V).set({toolTipText: qxApp.tr("Mirrors units vertically."), show: "icon", width: 35, height: 35, center: true, alignY: "middle", appearance: "button-text-small"});
  164. this.mirrorBtnV.getChildControl("icon").set({width: 20, height: 20, scale: true});
  165. this.mirrorBtnV.addListener("click", function () { this.mirrorFormation("v"); }, this);
  166. this.mirrorBtnV.hide();
  167. this.playArea.add(this.mirrorBtnV, {left: null, right: 46, bottom: 160});
  168.  
  169. //Disable all Units Button//
  170. this.disableAllUnitsBtn = new qx.ui.form.Button("", img.DisableUnit).set({toolTipText: qxApp.tr("Enables/Disables all units."), show: "icon", width: 35, height: 35, center: true, alignY: "middle", appearance: "button-text-small"});
  171. this.disableAllUnitsBtn.getChildControl("icon").set({width: 20, height: 20, scale: true});
  172. this.disableAllUnitsBtn.addListener("click", function () { this.shiftFormation("n"); }, this);
  173. this.disableAllUnitsBtn.hide();
  174. this.playArea.add(this.disableAllUnitsBtn, {left: null, right: 6, bottom: 120});
  175.  
  176. //Undo Button//
  177. this.armyUndoBtn = new qx.ui.form.Button("", img.Undo).set({toolTipText: qxApp.tr("Undo's formation to previous saved formation.<br>Save formations by hitting<br>the Update or Simulate button."), show: "icon", width: 35, height: 35, center: true, alignY: "middle", appearance: "button-text-small"});
  178. this.armyUndoBtn.getChildControl("icon").set({width: 20, height: 20, scale: true});
  179. this.armyUndoBtn.addListener("click", function () { this.undoCurrentFormation(); }, this);
  180. this.armyUndoBtn.setEnabled(false);
  181. this.armyUndoBtn.hide();
  182. this.playArea.add(this.armyUndoBtn, {left: null, right: 6, bottom: 200});
  183.  
  184. //Quick Save Button//
  185. this.quickSaveBtn = new qx.ui.form.Button(qxApp.tr("QS")).set({toolTipText: qxApp.tr("Saves the current layout<br>without having to open<br>the Formation Saver window.<br>Does not make persistent."), width: 35, height: 35, alignY: "middle", appearance: "button-text-small"});
  186. this.quickSaveBtn.addListener("click", function () { Simulator.LayoutWindow.getInstance().saveNewLayout(true); }, this);
  187. this.quickSaveBtn.hide();
  188. this.playArea.add(this.quickSaveBtn, {left: null, right: 6, bottom: 240});
  189.  
  190. //Simulator Back Button//
  191. this.backBtn = new qx.ui.form.Button(qxApp.tr("Back")).set({toolTipText: qxApp.tr("Return to Combat Setup."), width: 50, height: 24, appearance: "button-text-small"});
  192. this.backBtn.addListener("click", function () { this.backToCombatSetup(); }, this);
  193. this.replayBar.add(this.backBtn, {top: 37, left: 255});
  194.  
  195. this.replayStatBtn = new qx.ui.form.Button(qxApp.tr("Stats")).set({toolTipText: qxApp.tr("Opens Simulator Stats Window."), width: 50, height: 24, appearance: "button-text-small"});
  196. this.replayStatBtn.addListener("click", function () { this.__openStatWindow(); }, this);
  197. this.replayBar.add(this.replayStatBtn, {top: 7, left: 255});
  198.  
  199. phe.cnc.Util.attachNetEvent(ClientLib.Vis.VisMain.GetInstance(), "ViewModeChange", ClientLib.Vis.ViewModeChange, this, this._onViewChanged);
  200. } catch (e) {
  201. console.log("Error setting up Simulator Constructor: ");
  202. console.log(e.toString());
  203. }
  204. },
  205. destruct: function () {},
  206. members: {
  207. armyBar: null,
  208. playArea: null,
  209. replayBar: null,
  210. isSimButtonDisabled: null,
  211. armyTempFormations: null,
  212. armyTempIdx: null,
  213. isSimulation: null,
  214. simBtn: null,
  215. optionBtn: null,
  216. statBtn: null,
  217. layoutBtn: null,
  218. unlockCmtBtn: null,
  219. unlockRTBtn: null,
  220. shiftUpBtn: null,
  221. shiftDownBtn: null,
  222. shiftLeftBtn: null,
  223. shiftRightBtn: null,
  224. disableAllUnitsBtn: null,
  225. armyUndoBtn: null,
  226. quickSaveBtn: null,
  227. backBtn: null,
  228. replayStatBtn: null,
  229. _onViewChanged: function (oldMode, newMode) {
  230. try {
  231. if (newMode != ClientLib.Vis.Mode.CombatSetup && newMode != ClientLib.Vis.Mode.Battleground) {
  232. Simulator.getInstance().armyTempFormations = [];
  233. Simulator.getInstance().armyTempIdx = 0;
  234. Simulator.getInstance().armyUndoBtn.setEnabled(false);
  235. Simulator.getInstance().isSimulation = false;
  236. localStorage['allUnitsDisabled'] = "no";
  237. } else if (newMode == ClientLib.Vis.Mode.CombatSetup && oldMode != ClientLib.Vis.Mode.Battleground) {
  238. Simulator.getInstance().saveTempFormation();
  239. }
  240.  
  241. var cityId = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity().get_Id();
  242. var ownCityId = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity().get_Id();
  243. if (ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity() !== null) {
  244. if (newMode == ClientLib.Vis.Mode.Battleground || cityId == ownCityId) {
  245. Simulator.getInstance().shiftUpBtn.hide();
  246. Simulator.getInstance().shiftDownBtn.hide();
  247. Simulator.getInstance().shiftLeftBtn.hide();
  248. Simulator.getInstance().shiftRightBtn.hide();
  249. Simulator.getInstance().disableAllUnitsBtn.hide();
  250. Simulator.getInstance().mirrorBtnH.hide();
  251. Simulator.getInstance().mirrorBtnV.hide();
  252. Simulator.getInstance().armyUndoBtn.hide();
  253. Simulator.getInstance().quickSaveBtn.hide();
  254. } else if (cityId != ownCityId) {
  255. Simulator.getInstance().shiftUpBtn.show();
  256. Simulator.getInstance().shiftDownBtn.show();
  257. Simulator.getInstance().shiftLeftBtn.show();
  258. Simulator.getInstance().shiftRightBtn.show();
  259. Simulator.getInstance().disableAllUnitsBtn.show();
  260. Simulator.getInstance().mirrorBtnH.show();
  261. Simulator.getInstance().mirrorBtnV.show();
  262. Simulator.getInstance().armyUndoBtn.show();
  263. Simulator.getInstance().quickSaveBtn.show();
  264. }
  265. }
  266. } catch (e) {
  267. console.log("Error closing windows or hiding buttons on view change");
  268. console.log(e.toString());
  269. }
  270. },
  271. __openSimulatorWindow: function () {
  272. var city = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
  273. if (city != null) {
  274. var ownCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
  275.  
  276. this.isSimulation = true;
  277. this.saveTempFormation();
  278.  
  279. localStorage.ta_sim_last_city = city.get_Id();
  280.  
  281. ownCity.get_CityArmyFormationsManager().set_CurrentTargetBaseId(city.get_Id());
  282. ClientLib.API.Battleground.GetInstance().SimulateBattle();
  283. var app = qx.core.Init.getApplication();
  284.  
  285. app.getPlayArea().setView(ClientLib.Data.PlayerAreaViewMode.pavmCombatReplay, city.get_Id(), 0, 0);
  286.  
  287. var autoSim = localStorage['autoSimulate'];
  288.  
  289. if (autoSim !== undefined) {
  290. if (autoSim == "yes") {
  291. var speed = localStorage['simulateSpeed'];
  292. setTimeout(function () {
  293. var battleground = ClientLib.Vis.VisMain.GetInstance().get_Battleground();
  294. battleground.RestartReplay();
  295. battleground.set_ReplaySpeed(parseInt(speed, 10));
  296. }, 1000);
  297. }
  298. }
  299.  
  300. if (this.isSimButtonDisabled == false) {
  301. this.disableSimulateButtonTimer(10000);
  302. if (typeof Simulator.StatWindow.getInstance().disableSimulateStatButtonTimer === "function") {
  303. Simulator.StatWindow.getInstance().disableSimulateStatButtonTimer(10000);
  304. }
  305. }
  306.  
  307. if (Simulator.StatWindow.getInstance().simReplayBtn.getEnabled() == false) {
  308. Simulator.StatWindow.getInstance().simReplayBtn.setEnabled(true);
  309. }
  310. }
  311. },
  312. __openOptionWindow: function () {
  313. try {
  314. if (Simulator.OptionWindow.getInstance().isVisible()) {
  315. console.log("Closing Option Window");
  316. Simulator.OptionWindow.getInstance().close();
  317. } else {
  318. console.log("Opening Option Window");
  319. Simulator.OptionWindow.getInstance().open();
  320. }
  321. } catch (e) {
  322. console.log("Error Opening or Closing Option Window");
  323. console.log(e.toString());
  324. }
  325. },
  326. __openStatWindow: function () {
  327. try {
  328. if (Simulator.StatWindow.getInstance().isVisible()) {
  329. console.log("Closing Stat Window");
  330. Simulator.StatWindow.getInstance().close();
  331. } else {
  332. console.log("Opening Stat Window");
  333. Simulator.StatWindow.getInstance().open();
  334. }
  335. } catch (e) {
  336. console.log("Error Opening or Closing Stat Window");
  337. console.log(e.toString());
  338. }
  339. },
  340. __openLayoutWindow: function () {
  341. try {
  342. if (Simulator.LayoutWindow.getInstance().isVisible()) {
  343. console.log("Closing Layout Window");
  344. Simulator.LayoutWindow.getInstance().close();
  345. } else {
  346. console.log("Opening LayoutWindow");
  347. Simulator.LayoutWindow.getInstance().updateLayoutList();
  348. Simulator.LayoutWindow.getInstance().layoutTextBox.setValue("");
  349. Simulator.LayoutWindow.getInstance().persistentCheck.setValue(false);
  350. Simulator.LayoutWindow.getInstance().open();
  351. }
  352. } catch (e) {
  353. console.log("Error Opening or Closing Layout Window");
  354. console.log(e.toString());
  355. }
  356. },
  357. saveTempFormation: function () {
  358. try {
  359. var units = this.getCityPreArmyUnits().get_ArmyUnits().l;
  360. if (this.armyTempFormations.length != 0) {
  361. for (var i = 0; i < units.length; i++) {
  362. var lastForm = this.armyTempFormations[this.armyTempIdx][i];
  363. if ((units[i].get_CoordX() != lastForm.x) || (units[i].get_CoordY() != lastForm.y)) {
  364. break;
  365. } else if ((i + 1) == units.length) {
  366. return;
  367. }
  368. }
  369. }
  370.  
  371. var formation = new Array();
  372.  
  373. for (var i = 0; i < units.length; i++) {
  374. var unit = units[i];
  375. var unitInfo = {};
  376. unitInfo.x = unit.get_CoordX();
  377. unitInfo.y = unit.get_CoordY();
  378. unitInfo.id = unit.get_Id();
  379. unitInfo.enabled = unit.get_Enabled();
  380.  
  381. formation.push(unitInfo);
  382. }
  383.  
  384. this.armyTempFormations.push(formation);
  385. this.armyTempIdx = this.armyTempFormations.length - 1;
  386. if (this.armyTempFormations.length > 1)
  387. this.armyUndoBtn.setEnabled(true);
  388. } catch (e) {
  389. console.log("Error Saving Temp Formation");
  390. console.log(e.toString());
  391. }
  392. },
  393. undoCurrentFormation: function () {
  394. try {
  395. this.restoreFormation(this.armyTempFormations[(this.armyTempIdx - 1)]);
  396.  
  397. //get rid of last element now that we have undone it.
  398. this.armyTempFormations.splice(this.armyTempIdx, 1);
  399. this.armyTempIdx--;
  400.  
  401. if (this.armyTempFormations.length == 1)
  402. this.armyUndoBtn.setEnabled(false);
  403. } catch (e) {
  404. console.log("Error undoing formation");
  405. console.log(e.toString());
  406. }
  407. },
  408. mirrorFormation: function (direction, sel) {
  409. try {
  410. console.log("Shifting Unit Formation");
  411.  
  412. var units = this.getCityPreArmyUnits().get_ArmyUnits().l;
  413.  
  414. var newLayout = [];
  415. for (var i = 0; i < units.length; i++) {
  416. var unit = units[i],
  417. armyUnit = {},
  418. x = unit.get_CoordX(),
  419. y = unit.get_CoordY();
  420. if (direction == "h") x = Math.abs(x - 8);
  421. if (direction == "v") y = Math.abs(y - 3);
  422. if (sel !== undefined && unit.get_CoordY() != sel && direction == "h") armyUnit.x = unit.get_CoordX();
  423. else armyUnit.x = x;
  424. if (sel !== undefined && unit.get_CoordX() != sel && direction == "v") armyUnit.y = unit.get_CoordY();
  425. else armyUnit.y = y;
  426. armyUnit.id = unit.get_Id();
  427. armyUnit.enabled = unit.get_Enabled();
  428. newLayout.push(armyUnit);
  429. }
  430. this.restoreFormation(newLayout);
  431. } catch (e) {
  432. console.log("Error Mirroring Formation");
  433. console.log(e.toString());
  434. }
  435. },
  436. shiftFormation: function (direction, sel) {
  437. try {
  438. var v_shift = 0;
  439. var h_shift = 0;
  440.  
  441. if (direction == "u") var v_shift = -1;
  442. if (direction == "d") var v_shift = 1;
  443. if (direction == "l") var h_shift = -1;
  444. if (direction == "r") var h_shift = 1;
  445.  
  446. if (v_shift == 0 && h_shift == 0 && direction != "n")
  447. return;
  448.  
  449. var units = this.getCityPreArmyUnits().get_ArmyUnits().l;
  450.  
  451. var newLayout = [];
  452. for (var i = 0; i < units.length; i++) {
  453. var unit = units[i];
  454. var armyUnit = {};
  455. var x = unit.get_CoordX() + h_shift;
  456. switch (x) {
  457. case 9:
  458. x = 0;
  459. break;
  460. case -1:
  461. x = 8;
  462. break;
  463. }
  464. var y = unit.get_CoordY() + v_shift;
  465. switch (y) {
  466. case 4:
  467. y = 0;
  468. break;
  469. case -1:
  470. y = 3;
  471. break;
  472. }
  473. if (sel !== undefined && unit.get_CoordY() != sel && (direction == "l" || direction == "r")) armyUnit.x = unit.get_CoordX();
  474. else armyUnit.x = x;
  475. if (sel !== undefined && unit.get_CoordX() != sel && (direction == "u" || direction == "d")) armyUnit.y = unit.get_CoordY();
  476. else armyUnit.y = y;
  477. armyUnit.id = unit.get_Id();
  478.  
  479. if (direction == "n") {
  480. if (localStorage['allUnitsDisabled'] !== undefined) {
  481. if (localStorage['allUnitsDisabled'] == "yes") {
  482. armyUnit.enabled = unit.set_Enabled(true);
  483. } else {
  484. armyUnit.enabled = unit.set_Enabled(false);
  485. }
  486. } else {
  487. armyUnit.enabled = unit.set_Enabled(false);
  488. }
  489. }
  490. armyUnit.enabled = unit.get_Enabled();
  491. newLayout.push(armyUnit);
  492. }
  493. if (direction == "n") {
  494. if (localStorage['allUnitsDisabled'] == "yes")
  495. localStorage['allUnitsDisabled'] = "no";
  496. else
  497. localStorage['allUnitsDisabled'] = "yes";
  498. }
  499. this.restoreFormation(newLayout);
  500. } catch (e) {
  501. console.log("Error Shifting Units");
  502. console.log(e.toString());
  503. }
  504. },
  505. restoreFormation: function (layout) {
  506. try {
  507. var sUnits = layout;
  508.  
  509. var units = this.getCityPreArmyUnits();
  510. var units_list = units.get_ArmyUnits().l;
  511.  
  512. for (var idx = 0; idx < sUnits.length; idx++)
  513. {
  514. var saved_unit = sUnits[idx];
  515. var uid = saved_unit.id;
  516. for (var i = 0; i < units_list.length; i++)
  517. {
  518. if (units_list[i].get_Id() === uid)
  519. {
  520. units_list[i].MoveBattleUnit(saved_unit.x, saved_unit.y);
  521. if (saved_unit.enabled === undefined)
  522. units_list[i].set_Enabled(true);
  523. else
  524. units_list[i].set_Enabled(saved_unit.enabled);
  525. }
  526. }
  527. }
  528. units.UpdateFormation(true);
  529. } catch (e) {
  530. console.log("Error Restoring Formation");
  531. console.log(e.toString());
  532. }
  533. },
  534. getCityPreArmyUnits: function () {
  535. var city = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
  536. var ownCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
  537. var formationManager = ownCity.get_CityArmyFormationsManager();
  538. formationManager.set_CurrentTargetBaseId(city.get_Id());
  539. return formationManager.GetFormationByTargetBaseId(formationManager.get_CurrentTargetBaseId());
  540. },
  541. timeoutCmtBtn: function () {
  542. this.unlockCmtBtn.exclude();
  543. setTimeout(function () {
  544. Simulator.getInstance().unlockCmtBtn.show();
  545. }, 3000);
  546. },
  547. timeoutRTBtn: function () {
  548. this.unlockRTBtn.exclude();
  549. setTimeout(function () {
  550. Simulator.getInstance().unlockRTBtn.show();
  551. }, 3000);
  552. },
  553. backToCombatSetup: function () {
  554. try {
  555. var city = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
  556. if (city != null) {
  557. var app = qx.core.Init.getApplication();
  558. app.getPlayArea().setView(ClientLib.Data.PlayerAreaViewMode.pavmCombatSetupDefense, city.get_Id(), 0, 0);
  559. }
  560. } catch (e) {
  561. console.log("Error closing Simulation Window");
  562. console.log(e.toString());
  563. }
  564. },
  565. disableSimulateButtonTimer: function (timer) {
  566. try {
  567. if (timer >= 1000) {
  568. this.isSimButtonDisabled = true;
  569. this.simBtn.setEnabled(false);
  570. this.simBtn.setLabel(Math.floor(timer / 1000));
  571. timer -= 1000;
  572. setTimeout(function () {
  573. Simulator.getInstance().disableSimulateButtonTimer(timer);
  574. }, 1000);
  575. } else {
  576. setTimeout(function () {
  577. var qxApp = qx.core.Init.getApplication();
  578. Simulator.getInstance().simBtn.setEnabled(true);
  579. if (Simulator.OptionWindow.getInstance()._buttonSizeCB.getValue())
  580. Simulator.getInstance().simBtn.setLabel(qxApp.tr("Simulate"));
  581. else
  582. Simulator.getInstance().simBtn.setLabel(qxApp.tr("S"));
  583. }, timer);
  584. this.isSimButtonDisabled = false;
  585. }
  586. } catch (e) {
  587. console.log("Error disabling simulator button");
  588. console.log(e.toString());
  589. }
  590. },
  591. hideArmyTooltips: function () {
  592. try {
  593. if (localStorage["ArmyUnitTooltipDisabled"] === undefined) localStorage["ArmyUnitTooltipDisabled"] = "yes";
  594. var Baseview = ClientLib.Vis.BaseView.BaseView.prototype;
  595. for (var i in Baseview) {
  596. if (typeof Baseview[i] === "function" && Baseview[i] === Baseview.ShowToolTip) {
  597. Baseview.ShowToolTip2 = Baseview[i];
  598. Baseview[i] = function (a) {
  599. if (ClientLib.Vis.VisMain.GetInstance().get_Mode() == ClientLib.Vis.Mode.CombatSetup && localStorage['ArmyUnitTooltipDisabled'] == 'yes') return;
  600. else this.ShowToolTip2(a);
  601. };
  602. break;
  603. }
  604. }
  605. var ArmyUnitTooltipOverlay = qx.core.Init.getApplication().getArmyUnitTooltipOverlay();
  606. ArmyUnitTooltipOverlay.setVisibility2 = ArmyUnitTooltipOverlay.setVisibility;
  607. ArmyUnitTooltipOverlay.setVisibility = function (a) {
  608. if (localStorage["ArmyUnitTooltipDisabled"] == "yes") this.setVisibility2(false);
  609. else this.setVisibility2(a);
  610. };
  611. } catch (e) {
  612. console.log("Error hideArmyTooltips()");
  613. console.log(e.toString());
  614. }
  615. }
  616. }
  617. });
  618. qx.Class.define("Simulator.StatWindow", {
  619. type: "singleton",
  620. extend: qx.ui.window.Window,
  621. construct: function () {
  622. try {
  623. var qxApp = qx.core.Init.getApplication();
  624. this.base(arguments);
  625.  
  626. this.set({
  627. layout: new qx.ui.layout.VBox().set({
  628. spacing: 0
  629. }),
  630. caption: qxApp.tr("Simulator") + " - " + qxApp.tr("Stats"),
  631. icon: "FactionUI/icons/icon_res_plinfo_command_points.png",
  632. contentPadding: 5,
  633. contentPaddingTop: 0,
  634. allowMaximize: false,
  635. showMaximize: false,
  636. allowMinimize: false,
  637. showMinimize: false,
  638. resizable: true,
  639. resizableTop: false,
  640. resizableBottom: false
  641. });
  642. this.getChildControl("icon").set({ width : 18, height : 18, scale : true, alignY : "middle" });
  643.  
  644. if (localStorage['statWindowPosLeft'] !== undefined) {
  645. var left = parseInt(localStorage['statWindowPosLeft'], 10);
  646. var top = parseInt(localStorage['statWindowPosTop'], 10);
  647. this.moveTo(left, top);
  648. } else {
  649. this.moveTo(124, 31);
  650. }
  651.  
  652. if (localStorage['simViews'] !== undefined) {
  653. this.simViews = parseInt(localStorage['simViews'], 10);
  654. } else {
  655. this.simViews = 3;
  656. }
  657.  
  658. this.isSimStatButtonDisabled = false;
  659.  
  660. /**
  661. * Setup Images
  662. */
  663.  
  664. var img = {
  665. Enemy: {
  666. All: "FactionUI/icons/icon_arsnl_show_all.png",
  667. Base: "FactionUI/icons/icon_arsnl_base_buildings.png",
  668. Defense: "FactionUI/icons/icon_def_army_points.png"
  669. },
  670. Defense: {
  671. Infantry: "FactionUI/icons/icon_arsnl_def_squad.png",
  672. Vehicle: "FactionUI/icons/icon_arsnl_def_vehicle.png",
  673. Building: "FactionUI/icons/icon_arsnl_def_building.png"
  674. },
  675. Offense: {
  676. Infantry: "FactionUI/icons/icon_arsnl_off_squad.png",
  677. Vehicle: "FactionUI/icons/icon_arsnl_off_vehicle.png",
  678. Aircraft: "FactionUI/icons/icon_arsnl_off_plane.png"
  679. },
  680. Repair: {
  681. Storage: "webfrontend/ui/icons/icn_repair_points.png",
  682. Overall: "webfrontend/ui/icons/icn_repair_off_points.png",
  683. Infantry: "webfrontend/ui/icons/icon_res_repair_inf.png",
  684. Vehicle: "webfrontend/ui/icons/icon_res_repair_tnk.png",
  685. Aircraft: "webfrontend/ui/icons/icon_res_repair_air.png"
  686. },
  687. Loot: {
  688. Tiberium: "webfrontend/ui/common/icn_res_tiberium.png",
  689. Crystal: "webfrontend/ui/common/icn_res_chrystal.png",
  690. Credits: "webfrontend/ui/common/icn_res_dollar.png",
  691. RP: "webfrontend/ui/common/icn_res_research_mission.png",
  692. Total: "FactionUI/icons/icon_transfer_resource.png"
  693. }
  694. };
  695.  
  696. /**
  697. * Setup Stats Window
  698. */
  699.  
  700. //Battle Section//
  701. this.Battle = new qx.ui.container.Composite(new qx.ui.layout.HBox(-3)).set({decorator: "pane-light-plain", allowGrowX: true, marginLeft: 0, marginRight: 0});
  702. var BattleLables = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 29, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0});
  703.  
  704. var BattleOutcome = new qx.ui.basic.Label("O").set({toolTipText: qxApp.tr("tnf:combat report"), alignX: "center", alignY: "middle"});
  705. var BattleDuration = new qx.ui.basic.Label("D").set({toolTipText: qxApp.tr("tnf:combat timer npc: %1", ""), alignX: "center", alignY: "middle"});
  706. var BattleOwnCity = new qx.ui.basic.Label("B").set({toolTipText: qxApp.tr("tnf:base"), alignX: "center", alignY: "middle"});
  707.  
  708. BattleLables.add(BattleOutcome);
  709. BattleLables.add(BattleDuration);
  710. BattleLables.add(BattleOwnCity);
  711. this.Battle.add(BattleLables);
  712. this.add(this.Battle);
  713.  
  714. //Enemy Health Section//
  715. var EnemyHealthHeader = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({decorator: "pane-light-opaque"});
  716. EnemyHealthHeader.add(new qx.ui.basic.Label(qxApp.tr("tnf:combat target")).set({alignX: "center", alignY: "middle", paddingBottom: 5, font: "font_size_13_bold"}));
  717. this.add(EnemyHealthHeader);
  718.  
  719. this.EnemyHealth = new qx.ui.container.Composite(new qx.ui.layout.HBox(-3)).set({decorator: "pane-light-plain", allowGrowX: true, marginLeft: 0, marginRight: 0});
  720. var EnemyHealthLabels = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 29, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0});
  721.  
  722. var EnemyHealthLabelOverall = new qx.ui.basic.Atom(null, img.Enemy.All).set({toolTipText: qxApp.tr("tnf:total"), toolTipIcon: img.Enemy.All, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  723. var EnemyHealthLabelBase = new qx.ui.basic.Atom(null, img.Enemy.Base).set({toolTipText: qxApp.tr("tnf:base"), toolTipIcon: img.Enemy.Base, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  724. var EnemyHealthLabelDefense = new qx.ui.basic.Atom(null, img.Enemy.Defense).set({toolTipText: qxApp.tr("tnf:defense"), toolTipIcon: img.Enemy.Defense, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  725. var EnemyHealthLabelCY = new qx.ui.basic.Label("CY").set({toolTipText: GAMEDATA.Tech[1].dn, alignX: "center", alignY: "middle"});
  726. var EnemyHealthLabelDF = new qx.ui.basic.Label("DF").set({toolTipText: GAMEDATA.Tech[42].dn, alignX: "center", alignY: "middle"});
  727. var EnemyHealthLabelCC = new qx.ui.basic.Label("CC").set({toolTipText: GAMEDATA.Tech[24].dn, alignX: "center", alignY: "middle"});
  728.  
  729. EnemyHealthLabelOverall.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  730. EnemyHealthLabelBase.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  731. EnemyHealthLabelDefense.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  732.  
  733. EnemyHealthLabels.add(EnemyHealthLabelOverall);
  734. EnemyHealthLabels.add(EnemyHealthLabelBase);
  735. EnemyHealthLabels.add(EnemyHealthLabelDefense);
  736. EnemyHealthLabels.add(EnemyHealthLabelCY);
  737. EnemyHealthLabels.add(EnemyHealthLabelDF);
  738. EnemyHealthLabels.add(EnemyHealthLabelCC);
  739. this.EnemyHealth.add(EnemyHealthLabels);
  740. this.add(this.EnemyHealth);
  741.  
  742. //Repair Section//
  743. var RepairHeader = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({decorator: "pane-light-opaque"});
  744. RepairHeader.add(new qx.ui.basic.Label(qxApp.tr("tnf:own repair cost")).set({alignX: "center", alignY: "middle", paddingBottom: 5, font: "font_size_13_bold"}));
  745. this.add(RepairHeader);
  746.  
  747. this.Repair = new qx.ui.container.Composite(new qx.ui.layout.HBox(-3)).set({decorator: "pane-light-plain", allowGrowX: true, marginLeft: 0, marginRight: 0});
  748. var RepairLabels = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 29, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0});
  749.  
  750. var pRLabelStorage = new qx.ui.basic.Atom(null, img.Repair.Storage).set({toolTipText: qxApp.tr("tnf:offense repair time"), toolTipIcon: img.Repair.Storage, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  751. var pRLabelOverall = new qx.ui.basic.Atom(null, img.Repair.Overall).set({toolTipText: qxApp.tr("tnf:repair points"), toolTipIcon: img.Repair.Overall, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  752. var pRLabelInf = new qx.ui.basic.Atom(null, img.Repair.Infantry).set({toolTipText: qxApp.tr("tnf:infantry repair title"), toolTipIcon: img.Repair.Infantry, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  753. var pRLabelVehi = new qx.ui.basic.Atom(null, img.Repair.Vehicle).set({toolTipText: qxApp.tr("tnf:vehicle repair title"), toolTipIcon: img.Repair.Vehicle, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  754. var pRLabelAir = new qx.ui.basic.Atom(null, img.Repair.Aircraft).set({toolTipText: qxApp.tr("tnf:aircraft repair title"), toolTipIcon: img.Repair.Aircraft, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  755.  
  756. pRLabelStorage.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  757. pRLabelOverall.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  758. pRLabelInf.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  759. pRLabelVehi.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  760. pRLabelAir.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  761.  
  762. RepairLabels.add(pRLabelStorage);
  763. RepairLabels.add(pRLabelOverall);
  764. RepairLabels.add(pRLabelInf);
  765. RepairLabels.add(pRLabelVehi);
  766. RepairLabels.add(pRLabelAir);
  767. this.Repair.add(RepairLabels);
  768. this.add(this.Repair);
  769.  
  770. //Loot Section//
  771. var LootHeader = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({decorator: "pane-light-opaque"});
  772. LootHeader.add(new qx.ui.basic.Label(qxApp.tr("tnf:lootable resources:")).set({alignX: "center", alignY: "middle", paddingBottom: 5, font: "font_size_13_bold"}));
  773. this.add(LootHeader);
  774.  
  775. this.Loot = new qx.ui.container.Composite(new qx.ui.layout.HBox(-3)).set({decorator: "pane-light-plain", allowGrowX: true, marginLeft: 0, marginRight: 0});
  776. var LootLabels = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 29, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0});
  777.  
  778. var LootLabelTib = new qx.ui.basic.Atom(null, img.Loot.Tiberium).set({toolTipText: qxApp.tr("tnf:tiberium"), toolTipIcon: img.Loot.Tiberium, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  779. var LootLabelCry = new qx.ui.basic.Atom(null, img.Loot.Crystal).set({toolTipText: qxApp.tr("tnf:crystals"), toolTipIcon: img.Loot.Crystal, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  780. var LootLabelCred = new qx.ui.basic.Atom(null, img.Loot.Credits).set({toolTipText: qxApp.tr("tnf:credits"), toolTipIcon: img.Loot.Credits, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  781. var LootLabelRP = new qx.ui.basic.Atom(null, img.Loot.RP).set({toolTipText: qxApp.tr("tnf:research points"), toolTipIcon: img.Loot.RP, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  782. var LootLabelTotal = new qx.ui.basic.Atom(null, img.Loot.Total).set({toolTipText: qxApp.tr("tnf:total") + " " + qxApp.tr("tnf:loot"), toolTipIcon: img.Loot.Total, alignX: "center", alignY: "middle", gap: 0, iconPosition: "top"});
  783.  
  784. LootLabelTib.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  785. LootLabelCry.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  786. LootLabelCred.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  787. LootLabelRP.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  788. LootLabelTotal.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  789.  
  790. LootLabels.add(LootLabelTib);
  791. LootLabels.add(LootLabelCry);
  792. LootLabels.add(LootLabelCred);
  793. LootLabels.add(LootLabelRP);
  794. LootLabels.add(LootLabelTotal);
  795. this.Loot.add(LootLabels);
  796. this.add(this.Loot);
  797.  
  798. //Simulate Button//
  799. var simButton = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({decorator: "pane-light-opaque", allowGrowX: true, marginLeft: 0, marginRight: 0, padding: 5});
  800. this.add(simButton);
  801.  
  802. this.simStatBtn = new qx.ui.form.Button(qxApp.tr("tnf:update")).set({allowGrowX: false});
  803. this.simStatBtn.setToolTipText(qxApp.tr("Updates Simulation Stats."));
  804. this.simStatBtn.addListener("click", this.simulateStats, this);
  805.  
  806. this.simReplayBtn = new qx.ui.form.Button(qxApp.tr("tnf:show combat")).set({allowGrowX: false});
  807. this.simReplayBtn.setToolTipText(qxApp.tr("tnf:show battle replay"));
  808. this.simReplayBtn.addListener("click", this.doSimReplay, this);
  809.  
  810. this.simReplayBtn.setEnabled(false);
  811.  
  812. simButton.add(this.simStatBtn, {width: "50%"});
  813. simButton.add(this.simReplayBtn, {width: "50%"});
  814.  
  815. //Add Header Events//
  816. EnemyHealthHeader.addListener("click", function () {
  817. if (this.EnemyHealth.isVisible()) this.EnemyHealth.exclude();
  818. else this.EnemyHealth.show();
  819. }, this);
  820.  
  821. RepairHeader.addListener("click", function () {
  822. if (this.Repair.isVisible()) this.Repair.exclude();
  823. else this.Repair.show();
  824. }, this);
  825.  
  826. LootHeader.addListener("click", function () {
  827. if (this.Loot.isVisible()) this.Loot.exclude();
  828. else this.Loot.show();
  829. }, this);
  830.  
  831. //Hide Sections
  832. if (localStorage['hideHealth'] !== undefined) {
  833. if (localStorage['hideHealth'] == "yes") this.EnemyHealth.exclude();
  834. }
  835.  
  836. if (localStorage['hideRepair'] !== undefined) {
  837. if (localStorage['hideRepair'] == "yes") this.Repair.exclude();
  838. }
  839.  
  840. if (localStorage['hideLoot'] !== undefined) {
  841. if (localStorage['hideLoot'] == "yes") this.Loot.exclude();
  842. }
  843.  
  844. /**
  845. * Setup Simulation Storage
  846. */
  847. for (var i = 0; i < this.simViews; i++) {
  848. this.sim[i] = new this.Simulation(i);
  849. this.sim[i].Select(this.simSelected);
  850. this.Battle.add(this.sim[i].Label.Battle.container, { flex : 1 });
  851. this.EnemyHealth.add(this.sim[i].Label.EnemyHealth.container, { flex : 1 });
  852. this.Repair.add(this.sim[i].Label.Repair.container, { flex : 1 });
  853. this.Loot.add(this.sim[i].Label.Loot.container, { flex : 1 });
  854. }
  855.  
  856.  
  857. //Events
  858. phe.cnc.Util.attachNetEvent(ClientLib.API.Battleground.GetInstance(), "OnSimulateBattleFinished", ClientLib.API.OnSimulateBattleFinished, this, this.__OnSimulateBattleFinished);
  859. phe.cnc.Util.attachNetEvent(ClientLib.Vis.VisMain.GetInstance(), "ViewModeChange", ClientLib.Vis.ViewModeChange, this, this._onViewChanged);
  860. phe.cnc.base.Timer.getInstance().addListener("uiTick", this._onTick, this);
  861. } catch (e) {
  862. console.log("Error setting up Simulator.StatWindow Constructor: ");
  863. console.log(e.toString());
  864. }
  865. },
  866. destruct: function () {},
  867. members: {
  868. Battle: null,
  869. EnemyHealth: null,
  870. Repair: null,
  871. Loot: null,
  872. simStatBtn: null,
  873. simReplayBtn: null,
  874. isSimStatButtonDisabled: null,
  875. simSelected: 0,
  876. simViews: 3,
  877. sim: [],
  878. Simulation: function (instance) {
  879. try {
  880. var simulated = false;
  881. this.TargetCity = null;
  882. this.OwnCity = null;
  883. var Formation = null;
  884. this.Result = null;
  885. this.Label = {
  886. Battle: {
  887. container: new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 65, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0, decorator: "pane-light-opaque"}),
  888. Outcome: new qx.ui.basic.Atom("-", null).set({alignX: "center", alignY: "middle", gap: 0, iconPosition: "top", show: "label"}),
  889. Duration: new qx.ui.basic.Label("-:--").set({alignX: "center", alignY: "middle"}),
  890. OwnCity: new qx.ui.basic.Label("-").set({alignX: "center", alignY: "middle"})
  891. },
  892. EnemyHealth: {
  893. container: new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 65, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0, decorator: "pane-light-opaque"}),
  894. Overall: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  895. Base: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  896. Defense: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  897. CY: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  898. DF: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  899. CC: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"})
  900. },
  901. Repair: {
  902. container: new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 65, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0, decorator: "pane-light-opaque"}),
  903. Storage: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  904. Overall: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle", rich: true}),
  905. Inf: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  906. Vehi: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  907. Air: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"})
  908. },
  909. Loot: {
  910. container: new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({width: 65, padding: 5, allowGrowX: true, marginLeft: 0, marginRight: 0, decorator: "pane-light-opaque"}),
  911. Tib: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  912. Cry: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  913. Cred: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  914. RP: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"}),
  915. Overall: new qx.ui.basic.Label("-").set({alignX: "right", alignY: "middle"})
  916. }
  917. };
  918. var _StatsUnit = function () {
  919. this.StartHealth = 0;
  920. this.EndHealth = 0;
  921. this.MaxHealth = 0;
  922. this.Tib = 0;
  923. this.Cry = 0;
  924. this.RT = 0;
  925. this.getHP = function () {
  926. if (this.EndHealth == 0 && this.StartHealth == 0) return 0;
  927. else if (this.MaxHealth == 0) return 100;
  928. else return (this.EndHealth / this.MaxHealth) * 100;
  929. };
  930. this.getHPrel = function () {
  931. if (this.StartHealth == 0) return 0;
  932. else if (this.MaxHealth == 0) return -100;
  933. else return ((this.StartHealth - this.EndHealth) / this.MaxHealth) * -100;
  934. };
  935. };
  936. var _StatsLoot = function () {
  937. this.Base = 0;
  938. this.Battle = 0;
  939. };
  940. this.Stats = {
  941. Battle: {
  942. Outcome: 0,
  943. Duration: 0,
  944. OwnCity: ""
  945. },
  946. EnemyHealth: {
  947. Overall: new _StatsUnit(),
  948. Base: new _StatsUnit(),
  949. Defense: new _StatsUnit(),
  950. CY: new _StatsUnit(),
  951. DF: new _StatsUnit(),
  952. CC: new _StatsUnit()
  953. },
  954. Repair: {
  955. Storage: 0,
  956. Overall: new _StatsUnit(),
  957. Inf: new _StatsUnit(),
  958. Vehi: new _StatsUnit(),
  959. Air: new _StatsUnit()
  960. },
  961. Loot: {
  962. Tib: new _StatsLoot(),
  963. Cry: new _StatsLoot(),
  964. Cred: new _StatsLoot(),
  965. RP: new _StatsLoot(),
  966. Overall: new _StatsLoot()
  967. }
  968. };
  969. this.getLootFromCurrentCity = function () {
  970. try {
  971. this.Stats.Loot.Tib.Base = 0;
  972. this.Stats.Loot.Cry.Base = 0;
  973. this.Stats.Loot.Cred.Base = 0;
  974. this.Stats.Loot.RP.Base = 0;
  975. this.Stats.Loot.Overall.Base = 0;
  976. var loot = ClientLib.API.Battleground.GetInstance().GetLootFromCurrentCity();
  977. for (var i = 0; i < loot.length; i++) {
  978. this.Stats.Loot.Overall.Base += loot[i].Count;
  979. switch (parseInt(loot[i].Type, 10)) {
  980. case ClientLib.Base.EResourceType.Tiberium:
  981. this.Stats.Loot.Tib.Base += loot[i].Count;
  982. break;
  983. case ClientLib.Base.EResourceType.Crystal:
  984. this.Stats.Loot.Cry.Base += loot[i].Count;
  985. break;
  986. case ClientLib.Base.EResourceType.Gold:
  987. this.Stats.Loot.Cred.Base += loot[i].Count;
  988. break;
  989. case ClientLib.Base.EResourceType.ResearchPoints:
  990. this.Stats.Loot.RP.Base += loot[i].Count;
  991. break;
  992. }
  993. }
  994. } catch (e) {
  995. console.log("Error Getting Loot from Current City");
  996. console.log(e.toString());
  997. }
  998. };
  999. this.setSimulation = function (data) {
  1000. simulated = true;
  1001. this.OwnCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
  1002. this.Stats.Battle.OwnCity = this.OwnCity.get_Name();
  1003. this.saveFormation();
  1004. this.Result = [];
  1005. for (var i = 0; i < data.length; i++) this.Result.push(data[i].Value);
  1006. };
  1007. this.UpdateLabels = function () {
  1008. var qxApp = qx.core.Init.getApplication();
  1009. var formatTime = function (time) {
  1010. return phe.cnc.Util.getTimespanString(time);
  1011. };
  1012. var setRTLabelColor = function (label, number) {
  1013. if (number < 25) label.setTextColor("red");
  1014. else if (number < 75) label.setTextColor("orangered");
  1015. else label.setTextColor("darkgreen");
  1016. };
  1017. var setEHLabelColor = function (label, number) {
  1018. if (number < 25) label.setTextColor("darkgreen");
  1019. else if (number < 75) label.setTextColor("orangered");
  1020. else label.setTextColor("red");
  1021. };
  1022.  
  1023. if (simulated) {
  1024. //Battle.Outcome
  1025. switch (this.Stats.Battle.Outcome) {
  1026. case 1:
  1027. this.Label.Battle.Outcome.resetLabel();
  1028. this.Label.Battle.Outcome.set({ show: "icon" });
  1029. this.Label.Battle.Outcome.setIcon("FactionUI/icons/icon_reports_total_defeat.png");
  1030. this.Label.Battle.Outcome.setToolTipIcon("FactionUI/icons/icon_reports_total_defeat.png");
  1031. this.Label.Battle.Outcome.setToolTipText(qxApp.tr("tnf:total defeat"));
  1032. break;
  1033. case 2:
  1034. this.Label.Battle.Outcome.resetLabel();
  1035. this.Label.Battle.Outcome.set({ show: "icon" });
  1036. this.Label.Battle.Outcome.setIcon("FactionUI/icons/icon_reports_victory.png");
  1037. this.Label.Battle.Outcome.setToolTipIcon("FactionUI/icons/icon_reports_victory.png");
  1038. this.Label.Battle.Outcome.setToolTipText(qxApp.tr("tnf:victory"));
  1039. break;
  1040. case 3:
  1041. this.Label.Battle.Outcome.resetLabel();
  1042. this.Label.Battle.Outcome.set({ show: "icon" });
  1043. this.Label.Battle.Outcome.setIcon("FactionUI/icons/icon_reports_total_victory.png");
  1044. this.Label.Battle.Outcome.setToolTipIcon("FactionUI/icons/icon_reports_total_victory.png");
  1045. this.Label.Battle.Outcome.setToolTipText(qxApp.tr("tnf:total victory"));
  1046. break;
  1047. }
  1048. //Battle.Duration
  1049. this.Label.Battle.Duration.setValue(formatTime(this.Stats.Battle.Duration/1000));
  1050. //Battle.OwnCity
  1051. if (this.OwnCity != null) this.Stats.Battle.OwnCity = this.OwnCity.get_Name();
  1052. this.Label.Battle.OwnCity.setValue(this.Stats.Battle.OwnCity);
  1053.  
  1054. switch (localStorage['getEHSelection']) {
  1055. case "hp rel":
  1056. //EnemyHealth.Overall
  1057. this.Label.EnemyHealth.Overall.setValue(this.Stats.EnemyHealth.Overall.getHPrel().toFixed(2) + "%");
  1058. this.Label.EnemyHealth.Overall.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.Overall.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Overall.Tib) + "<br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Overall.Cry));
  1059. //EnemyHealth.Base
  1060. this.Label.EnemyHealth.Base.setValue(this.Stats.EnemyHealth.Base.getHPrel().toFixed(2) + "%");
  1061. this.Label.EnemyHealth.Base.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.Base.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Base.Tib));
  1062. //EnemyHealth.Defense
  1063. this.Label.EnemyHealth.Defense.setValue(this.Stats.EnemyHealth.Defense.getHPrel().toFixed(2) + "%");
  1064. this.Label.EnemyHealth.Defense.setToolTipText(qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Defense.Tib) + "<br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Defense.Cry));
  1065. //EnemyHealth.CY
  1066. this.Label.EnemyHealth.CY.setValue(this.Stats.EnemyHealth.CY.getHPrel().toFixed(2) + "%");
  1067. this.Label.EnemyHealth.CY.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.CY.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.CY.Tib));
  1068. //EnemyHealth.DF
  1069. this.Label.EnemyHealth.DF.setValue(this.Stats.EnemyHealth.DF.getHPrel().toFixed(2) + "%");
  1070. this.Label.EnemyHealth.DF.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.DF.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.DF.Tib));
  1071. //EnemyHealth.CC
  1072. this.Label.EnemyHealth.CC.setValue(this.Stats.EnemyHealth.CC.getHPrel().toFixed(2) + "%");
  1073. this.Label.EnemyHealth.CC.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.CC.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.CC.Tib));
  1074. break;
  1075. default: //"hp"
  1076. //EnemyHealth.Overall
  1077. this.Label.EnemyHealth.Overall.setValue(this.Stats.EnemyHealth.Overall.getHP().toFixed(2) + "%");
  1078. this.Label.EnemyHealth.Overall.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.Overall.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Overall.Tib) + "<br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Overall.Cry));
  1079. //EnemyHealth.Base
  1080. this.Label.EnemyHealth.Base.setValue(this.Stats.EnemyHealth.Base.getHP().toFixed(2) + "%");
  1081. this.Label.EnemyHealth.Base.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.Base.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Base.Tib));
  1082. //EnemyHealth.Defense
  1083. this.Label.EnemyHealth.Defense.setValue(this.Stats.EnemyHealth.Defense.getHP().toFixed(2) + "%");
  1084. this.Label.EnemyHealth.Defense.setToolTipText(qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Defense.Tib) + "<br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.Defense.Cry));
  1085. //EnemyHealth.CY
  1086. this.Label.EnemyHealth.CY.setValue(this.Stats.EnemyHealth.CY.getHP().toFixed(2) + "%");
  1087. this.Label.EnemyHealth.CY.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.CY.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.CY.Tib));
  1088. //EnemyHealth.DF
  1089. this.Label.EnemyHealth.DF.setValue(this.Stats.EnemyHealth.DF.getHP().toFixed(2) + "%");
  1090. this.Label.EnemyHealth.DF.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.DF.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.DF.Tib));
  1091. //EnemyHealth.CC
  1092. this.Label.EnemyHealth.CC.setValue(this.Stats.EnemyHealth.CC.getHP().toFixed(2) + "%");
  1093. this.Label.EnemyHealth.CC.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.EnemyHealth.CC.RT) + "<br>" + qxApp.tr("tnf:tiberium") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.EnemyHealth.CC.Tib));
  1094. break;
  1095. }
  1096. //EnemyHealth.Overall
  1097. setEHLabelColor(this.Label.EnemyHealth.Overall, this.Stats.EnemyHealth.Overall.getHP());
  1098. //EnemyHealth.Base
  1099. setEHLabelColor(this.Label.EnemyHealth.Base, this.Stats.EnemyHealth.Base.getHP());
  1100. //EnemyHealth.Defense
  1101. setEHLabelColor(this.Label.EnemyHealth.Defense, this.Stats.EnemyHealth.Defense.getHP());
  1102. //EnemyHealth.CY
  1103. setEHLabelColor(this.Label.EnemyHealth.CY, this.Stats.EnemyHealth.CY.getHP());
  1104. //EnemyHealth.DF
  1105. setEHLabelColor(this.Label.EnemyHealth.DF, this.Stats.EnemyHealth.DF.getHP());
  1106. //EnemyHealth.CC
  1107. setEHLabelColor(this.Label.EnemyHealth.CC, this.Stats.EnemyHealth.CC.getHP());
  1108.  
  1109. //Repair.Storage
  1110. if (this.OwnCity != null) this.Stats.Repair.Storage = Math.min(this.OwnCity.GetResourceCount(ClientLib.Base.EResourceType.RepairChargeInf), this.OwnCity.GetResourceCount(ClientLib.Base.EResourceType.RepairChargeVeh), this.OwnCity.GetResourceCount(ClientLib.Base.EResourceType.RepairChargeAir));
  1111. this.Label.Repair.Storage.setValue(phe.cnc.Util.getTimespanString(ClientLib.Data.MainData.GetInstance().get_Time().GetTimeSpan(this.Stats.Repair.Storage)));
  1112. this.Label.Repair.Storage.setTextColor(this.Stats.Repair.Storage > this.Stats.Repair.Overall.RT ? "darkgreen" : "red");
  1113. //Repair
  1114. switch (localStorage['getRTSelection']) {
  1115. case "cry":
  1116. //Repair.Overall
  1117. this.Label.Repair.Overall.setValue("<span style=\"text-shadow: 0 0 3pt;\">" + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Overall.Cry) + "</span>");
  1118. this.Label.Repair.Overall.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Overall.RT) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Overall.getHP().toFixed(2) + "%");
  1119. //Repair.Inf
  1120. this.Label.Repair.Inf.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Inf.Cry));
  1121. this.Label.Repair.Inf.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Inf.RT) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Inf.getHP().toFixed(2) + "%");
  1122. //Repair.Vehi
  1123. this.Label.Repair.Vehi.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Vehi.Cry));
  1124. this.Label.Repair.Vehi.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Vehi.RT) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Vehi.getHP().toFixed(2) + "%");
  1125. //Repair.Air
  1126. this.Label.Repair.Air.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Air.Cry));
  1127. this.Label.Repair.Air.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Air.RT) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Air.getHP().toFixed(2) + "%");
  1128. break;
  1129. case "hp":
  1130. //Repair.Overall
  1131. this.Label.Repair.Overall.setValue("<span style=\"text-shadow: 0 0 3pt;\">" + this.Stats.Repair.Overall.getHP().toFixed(2) + "%</span>");
  1132. this.Label.Repair.Overall.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Overall.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Overall.Cry));
  1133. //Repair.Inf
  1134. this.Label.Repair.Inf.setValue(this.Stats.Repair.Inf.getHP().toFixed(2) + "%");
  1135. this.Label.Repair.Inf.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Inf.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Inf.Cry));
  1136. //Repair.Vehi
  1137. this.Label.Repair.Vehi.setValue(this.Stats.Repair.Vehi.getHP().toFixed(2) + "%");
  1138. this.Label.Repair.Vehi.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Vehi.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Vehi.Cry));
  1139. //Repair.Air
  1140. this.Label.Repair.Air.setValue(this.Stats.Repair.Air.getHP().toFixed(2) + "%");
  1141. this.Label.Repair.Air.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Air.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Air.Cry));
  1142. break;
  1143. case "hp rel":
  1144. //Repair.Overall
  1145. this.Label.Repair.Overall.setValue("<span style=\"text-shadow: 0 0 3pt;\">" + this.Stats.Repair.Overall.getHPrel().toFixed(2) + "%</span>");
  1146. this.Label.Repair.Overall.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Overall.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Overall.Cry));
  1147. //Repair.Inf
  1148. this.Label.Repair.Inf.setValue(this.Stats.Repair.Inf.getHPrel().toFixed(2) + "%");
  1149. this.Label.Repair.Inf.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Inf.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Inf.Cry));
  1150. //Repair.Vehi
  1151. this.Label.Repair.Vehi.setValue(this.Stats.Repair.Vehi.getHPrel().toFixed(2) + "%");
  1152. this.Label.Repair.Vehi.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Vehi.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Vehi.Cry));
  1153. //Repair.Air
  1154. this.Label.Repair.Air.setValue(this.Stats.Repair.Air.getHPrel().toFixed(2) + "%");
  1155. this.Label.Repair.Air.setToolTipText(qxApp.tr("tnf:repair points") + ": " + formatTime(this.Stats.Repair.Air.RT) + "</br>" + qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Air.Cry));
  1156. break;
  1157. default: //"rt"
  1158. //Repair.Overall
  1159. this.Label.Repair.Overall.setValue("<span style=\"text-shadow: 0 0 3pt;\">" + formatTime(this.Stats.Repair.Overall.RT) + "</span>");
  1160. this.Label.Repair.Overall.setToolTipText(qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Overall.Cry) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Overall.getHP().toFixed(2) + "%");
  1161. //Repair.Inf
  1162. this.Label.Repair.Inf.setValue(formatTime(this.Stats.Repair.Inf.RT));
  1163. this.Label.Repair.Inf.setToolTipText(qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Inf.Cry) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Inf.getHP().toFixed(2) + "%");
  1164. //Repair.Vehi
  1165. this.Label.Repair.Vehi.setValue(formatTime(this.Stats.Repair.Vehi.RT));
  1166. this.Label.Repair.Vehi.setToolTipText(qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Vehi.Cry) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Vehi.getHP().toFixed(2) + "%");
  1167. //Repair.Air
  1168. this.Label.Repair.Air.setValue(formatTime(this.Stats.Repair.Air.RT));
  1169. this.Label.Repair.Air.setToolTipText(qxApp.tr("tnf:crystals") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Repair.Air.Cry) + "</br>" + qxApp.tr("tnf:health") + ": " + this.Stats.Repair.Air.getHP().toFixed(2) + "%");
  1170. break;
  1171. }
  1172.  
  1173. //Repair.Overall
  1174. setRTLabelColor(this.Label.Repair.Overall, this.Stats.Repair.Overall.getHP());
  1175. //Repair.Inf
  1176. setRTLabelColor(this.Label.Repair.Inf, this.Stats.Repair.Inf.getHP());
  1177. if (this.Stats.Repair.Inf.RT === this.Stats.Repair.Overall.RT && this.Stats.Repair.Inf.getHP() < 100) this.Label.Repair.Inf.setTextColor("black");
  1178. //Repair.Vehi
  1179. setRTLabelColor(this.Label.Repair.Vehi, this.Stats.Repair.Vehi.getHP());
  1180. if (this.Stats.Repair.Vehi.RT === this.Stats.Repair.Overall.RT && this.Stats.Repair.Vehi.getHP() < 100) this.Label.Repair.Vehi.setTextColor("black");
  1181. //Repair.Air
  1182. setRTLabelColor(this.Label.Repair.Air, this.Stats.Repair.Air.getHP());
  1183. if (this.Stats.Repair.Air.RT === this.Stats.Repair.Overall.RT && this.Stats.Repair.Air.getHP() < 100) this.Label.Repair.Air.setTextColor("black");
  1184.  
  1185. //Loot.Tib
  1186. this.Label.Loot.Tib.setToolTipText((this.Stats.Loot.Tib.Battle / this.Stats.Loot.Tib.Base * 100).toFixed(2) + "%<br>" + qxApp.tr("tnf:base") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Tib.Base));
  1187. this.Label.Loot.Tib.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Tib.Battle));
  1188. //Loot.Cry
  1189. this.Label.Loot.Cry.setToolTipText((this.Stats.Loot.Cry.Battle / this.Stats.Loot.Cry.Base * 100).toFixed(2) + "%<br>" + qxApp.tr("tnf:base") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cry.Base));
  1190. this.Label.Loot.Cry.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cry.Battle));
  1191. //Loot.Cred
  1192. this.Label.Loot.Cred.setToolTipText((this.Stats.Loot.Cred.Battle / this.Stats.Loot.Cred.Base * 100).toFixed(2) + "%<br>" + qxApp.tr("tnf:base") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cred.Base));
  1193. this.Label.Loot.Cred.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cred.Battle));
  1194. //Loot.RP
  1195. this.Label.Loot.RP.setToolTipText((this.Stats.Loot.RP.Battle / this.Stats.Loot.RP.Base * 100).toFixed(2) + "%<br>" + qxApp.tr("tnf:base") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.RP.Base));
  1196. this.Label.Loot.RP.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.RP.Battle));
  1197. //Loot.Overall
  1198. this.Label.Loot.Overall.setToolTipText((this.Stats.Loot.Overall.Battle / this.Stats.Loot.Overall.Base * 100).toFixed(2) + "%<br>" + qxApp.tr("tnf:base") + ": " + phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Overall.Base));
  1199. this.Label.Loot.Overall.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Overall.Battle));
  1200. } else {
  1201. if (this.Stats.Loot.Tib.Base > 0 || this.Stats.Loot.Cry.Base > 0 || this.Stats.Loot.Cred.Base > 0 || this.Stats.Loot.RP.Base > 0 || this.Stats.Loot.Overall.Base > 0) {
  1202. //Loot.Tib
  1203. this.Label.Loot.Tib.resetToolTipText();
  1204. this.Label.Loot.Tib.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Tib.Base));
  1205. //Loot.Cry
  1206. this.Label.Loot.Cry.resetToolTipText();
  1207. this.Label.Loot.Cry.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cry.Base));
  1208. //Loot.Cred
  1209. this.Label.Loot.Cred.resetToolTipText();
  1210. this.Label.Loot.Cred.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Cred.Base));
  1211. //Loot.RP
  1212. this.Label.Loot.RP.resetToolTipText();
  1213. this.Label.Loot.RP.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.RP.Base));
  1214. //Loot.Overall
  1215. this.Label.Loot.Overall.resetToolTipText();
  1216. this.Label.Loot.Overall.setValue(phe.cnc.gui.util.Numbers.formatNumbersCompact(this.Stats.Loot.Overall.Base));
  1217. }
  1218. }
  1219. };
  1220. this.ResetStats = function () {
  1221. this.Stats.Battle.Outcome = 0;
  1222. this.Stats.Battle.Duration = 0;
  1223. this.Stats.Battle.OwnCity = "";
  1224. this.Stats.EnemyHealth.Overall = new _StatsUnit();
  1225. this.Stats.EnemyHealth.Base = new _StatsUnit();
  1226. this.Stats.EnemyHealth.Defense = new _StatsUnit();
  1227. this.Stats.EnemyHealth.CY = new _StatsUnit();
  1228. this.Stats.EnemyHealth.DF = new _StatsUnit();
  1229. this.Stats.EnemyHealth.CC = new _StatsUnit();
  1230. this.Stats.Repair.Storage = 0;
  1231. this.Stats.Repair.Overall = new _StatsUnit();
  1232. this.Stats.Repair.Inf = new _StatsUnit();
  1233. this.Stats.Repair.Vehi = new _StatsUnit();
  1234. this.Stats.Repair.Air = new _StatsUnit();
  1235. this.Stats.Loot.Tib.Battle = 0;
  1236. this.Stats.Loot.Cry.Battle = 0;
  1237. this.Stats.Loot.Cred.Battle = 0;
  1238. this.Stats.Loot.RP.Battle = 0;
  1239. this.Stats.Loot.Overall.Battle = 0;
  1240. };
  1241. this.ResetLabels = function () {
  1242. this.Label.Battle.Outcome.resetIcon();
  1243. this.Label.Battle.Outcome.resetToolTipIcon();
  1244. this.Label.Battle.Outcome.resetToolTipText();
  1245. this.Label.Battle.Outcome.setShow("label");
  1246. this.Label.Battle.Outcome.setLabel("-");
  1247. this.Label.Battle.Duration.setValue("-:--");
  1248. this.Label.Battle.OwnCity.setValue("-");
  1249. this.Label.EnemyHealth.Overall.setValue("-");
  1250. this.Label.EnemyHealth.Overall.resetToolTipText();
  1251. this.Label.EnemyHealth.Overall.resetTextColor();
  1252. this.Label.EnemyHealth.Base.setValue("-");
  1253. this.Label.EnemyHealth.Base.resetToolTipText();
  1254. this.Label.EnemyHealth.Base.resetTextColor();
  1255. this.Label.EnemyHealth.Defense.setValue("-");
  1256. this.Label.EnemyHealth.Defense.resetToolTipText();
  1257. this.Label.EnemyHealth.Defense.resetTextColor();
  1258. this.Label.EnemyHealth.CY.setValue("-");
  1259. this.Label.EnemyHealth.CY.resetToolTipText();
  1260. this.Label.EnemyHealth.CY.resetTextColor();
  1261. this.Label.EnemyHealth.DF.setValue("-");
  1262. this.Label.EnemyHealth.DF.resetToolTipText();
  1263. this.Label.EnemyHealth.DF.resetTextColor();
  1264. this.Label.EnemyHealth.CC.setValue("-");
  1265. this.Label.EnemyHealth.CC.resetToolTipText();
  1266. this.Label.EnemyHealth.CC.resetTextColor();
  1267. this.Label.Repair.Storage.setValue("-");
  1268. this.Label.Repair.Storage.resetToolTipText();
  1269. this.Label.Repair.Storage.resetTextColor();
  1270. this.Label.Repair.Overall.setValue("-");
  1271. this.Label.Repair.Overall.resetToolTipText();
  1272. this.Label.Repair.Overall.resetTextColor();
  1273. this.Label.Repair.Inf.setValue("-");
  1274. this.Label.Repair.Inf.resetToolTipText();
  1275. this.Label.Repair.Inf.resetTextColor();
  1276. this.Label.Repair.Vehi.setValue("-");
  1277. this.Label.Repair.Vehi.resetToolTipText();
  1278. this.Label.Repair.Vehi.resetTextColor();
  1279. this.Label.Repair.Air.setValue("-");
  1280. this.Label.Repair.Air.resetToolTipText();
  1281. this.Label.Repair.Air.resetTextColor();
  1282. this.Label.Loot.Tib.setValue("-");
  1283. this.Label.Loot.Tib.resetToolTipText();
  1284. this.Label.Loot.Tib.resetTextColor();
  1285. this.Label.Loot.Cry.setValue("-");
  1286. this.Label.Loot.Cry.resetToolTipText();
  1287. this.Label.Loot.Cry.resetTextColor();
  1288. this.Label.Loot.Cred.setValue("-");
  1289. this.Label.Loot.Cred.resetToolTipText();
  1290. this.Label.Loot.Cred.resetTextColor();
  1291. this.Label.Loot.RP.setValue("-");
  1292. this.Label.Loot.RP.resetToolTipText();
  1293. this.Label.Loot.RP.resetTextColor();
  1294. this.Label.Loot.Overall.setValue("-");
  1295. this.Label.Loot.Overall.resetToolTipText();
  1296. this.Label.Loot.Overall.resetTextColor();
  1297. };
  1298. this.Reset = function () {
  1299. var ownCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
  1300. if (this.TargetCity === null || ownCity.get_CityArmyFormationsManager().get_CurrentTargetBaseId() != this.TargetCity.get_Id()) {
  1301. simulated = false;
  1302. this.OwnCity = null;
  1303. this.TargetCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
  1304. ownCity.get_CityArmyFormationsManager().set_CurrentTargetBaseId(this.TargetCity.get_Id());
  1305. this.ResetStats();
  1306. this.ResetLabels();
  1307. // this.getLootFromCurrentCity();
  1308. }
  1309. };
  1310. this.Select = function (selected) {
  1311. if (selected == instance) {
  1312. var j = "pane-light-opaque";
  1313. var k = 1;
  1314. } else {
  1315. var j = "pane-light-plain";
  1316. var k = 0.6;
  1317. }
  1318. this.Label.Battle.container.set({ decorator: j, opacity: k });
  1319. this.Label.EnemyHealth.container.set({ decorator: j, opacity: k });
  1320. this.Label.Repair.container.set({ decorator: j, opacity: k });
  1321. this.Label.Loot.container.set({ decorator: j, opacity: k });
  1322. };
  1323. this.saveFormation = function () {
  1324. try {
  1325. Formation = [];
  1326. var unitList = Simulator.getInstance().getCityPreArmyUnits().get_ArmyUnits().l;
  1327.  
  1328. for (var i = 0; i < unitList.length; i++) {
  1329. var unit = unitList[i];
  1330. var unitInfo = {};
  1331. unitInfo.x = unit.get_CoordX();
  1332. unitInfo.y = unit.get_CoordY();
  1333. unitInfo.id = unit.get_Id();
  1334. unitInfo.enabled = unit.get_Enabled();
  1335.  
  1336. Formation.push(unitInfo);
  1337. }
  1338. } catch (e) {
  1339. console.log("Error Saving Stat Formation");
  1340. console.log(e.toString());
  1341. }
  1342. };
  1343. this.loadFormation = function () {
  1344. try {
  1345. var cities = ClientLib.Data.MainData.GetInstance().get_Cities();
  1346. cities.set_CurrentOwnCityId(this.OwnCity.get_Id());
  1347. Simulator.getInstance().restoreFormation(Formation);
  1348. } catch (e) {
  1349. console.log("Error loading Stat Formation");
  1350. console.log(e.toString());
  1351. }
  1352. };
  1353.  
  1354. // Setup icons
  1355. this.Label.Battle.Outcome.getChildControl("icon").set({width: 18, height: 18, scale: true, alignY : "middle"});
  1356.  
  1357. // Setup containers
  1358. this.Label.Battle.container.add(this.Label.Battle.Outcome);
  1359. this.Label.Battle.container.add(this.Label.Battle.Duration);
  1360. this.Label.Battle.container.add(this.Label.Battle.OwnCity);
  1361. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.Overall);
  1362. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.Base);
  1363. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.Defense);
  1364. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.CY);
  1365. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.DF);
  1366. this.Label.EnemyHealth.container.add(this.Label.EnemyHealth.CC);
  1367. this.Label.Repair.container.add(this.Label.Repair.Storage);
  1368. this.Label.Repair.container.add(this.Label.Repair.Overall);
  1369. this.Label.Repair.container.add(this.Label.Repair.Inf);
  1370. this.Label.Repair.container.add(this.Label.Repair.Vehi);
  1371. this.Label.Repair.container.add(this.Label.Repair.Air);
  1372. this.Label.Loot.container.add(this.Label.Loot.Tib);
  1373. this.Label.Loot.container.add(this.Label.Loot.Cry);
  1374. this.Label.Loot.container.add(this.Label.Loot.Cred);
  1375. this.Label.Loot.container.add(this.Label.Loot.RP);
  1376. this.Label.Loot.container.add(this.Label.Loot.Overall);
  1377.  
  1378. // Setup Events
  1379. this.Label.Battle.container.addListener("click", function () { Simulator.StatWindow.getInstance().simSelected = instance; for (var i = 0; i < Simulator.StatWindow.getInstance().sim.length; i++) { Simulator.StatWindow.getInstance().sim[i].Select(instance); } }, this);
  1380. this.Label.EnemyHealth.container.addListener("click", function () { Simulator.StatWindow.getInstance().simSelected = instance; for (var i = 0; i < Simulator.StatWindow.getInstance().sim.length; i++) { Simulator.StatWindow.getInstance().sim[i].Select(instance); } }, this);
  1381. this.Label.Repair.container.addListener("click", function () { Simulator.StatWindow.getInstance().simSelected = instance; for (var i = 0; i < Simulator.StatWindow.getInstance().sim.length; i++) { Simulator.StatWindow.getInstance().sim[i].Select(instance); } }, this);
  1382. this.Label.Loot.container.addListener("click", function () { Simulator.StatWindow.getInstance().simSelected = instance; for (var i = 0; i < Simulator.StatWindow.getInstance().sim.length; i++) { Simulator.StatWindow.getInstance().sim[i].Select(instance); } }, this);
  1383. this.Label.Battle.container.addListener("dblclick", function () { this.loadFormation(); }, this);
  1384. this.Label.EnemyHealth.container.addListener("dblclick", function () { this.loadFormation(); }, this);
  1385. this.Label.Repair.container.addListener("dblclick", function () { this.loadFormation(); }, this);
  1386. this.Label.Loot.container.addListener("dblclick", function () { this.loadFormation(); }, this);
  1387. this.Label.EnemyHealth.container.addListener("contextmenu", function () {
  1388. if (localStorage['getEHSelection'] == "hp rel") localStorage['getEHSelection'] = "hp";
  1389. else localStorage['getEHSelection'] = "hp rel";
  1390. }, this);
  1391. this.Label.Repair.container.addListener("contextmenu", function () {
  1392. if (localStorage['getRTSelection'] == "cry") localStorage['getRTSelection'] = "rt";
  1393. else if (localStorage['getRTSelection'] == "hp") localStorage['getRTSelection'] = "hp rel";
  1394. else if (localStorage['getRTSelection'] == "hp rel") localStorage['getRTSelection'] = "cry";
  1395. else localStorage['getRTSelection'] = "hp";
  1396. }, this);
  1397. } catch (e) {
  1398. console.log("Error init Simulation");
  1399. console.log(e.toString());
  1400. }
  1401. },
  1402. simulateStats: function () {
  1403. var city = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
  1404. if (city != null) {
  1405. ClientLib.Vis.VisMain.GetInstance().get_Battleground().Reset();
  1406. Simulator.getInstance().isSimulation = true;
  1407. Simulator.getInstance().saveTempFormation();
  1408. localStorage['ta_sim_last_city'] = city.get_Id();
  1409. var ownCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
  1410. ownCity.get_CityArmyFormationsManager().set_CurrentTargetBaseId(city.get_Id());
  1411. ClientLib.API.Battleground.GetInstance().SimulateBattle();
  1412. }
  1413. },
  1414. doSimReplay: function () {
  1415. try {
  1416. Simulator.getInstance().isSimulation = true;
  1417. var app = qx.core.Init.getApplication();
  1418. app.getPlayArea().setView(ClientLib.Data.PlayerAreaViewMode.pavmCombatReplay, localStorage['ta_sim_last_city'], 0, 0);
  1419.  
  1420. if (localStorage['autoSimulate'] !== undefined) {
  1421. if (localStorage['autoSimulate'] == "yes") {
  1422. var speed = localStorage['simulateSpeed'];
  1423. setTimeout(function () {
  1424. var battleground = ClientLib.Vis.VisMain.GetInstance().get_Battleground();
  1425. battleground.RestartReplay();
  1426. battleground.set_ReplaySpeed(parseInt(speed, 10));
  1427. }, 1000);
  1428. }
  1429. }
  1430. } catch (e) {
  1431. console.log("Error attempting to show Simulation Replay");
  1432. console.log(e.toString());
  1433. }
  1434. },
  1435. calculateRepairCosts: function (id, level, sHealth, eHealth, mHealth) {
  1436. var repairCosts = { RT: 0, Cry: 0, Tib: 0 };
  1437. var dmgRatio = 1;
  1438. if (sHealth != eHealth) {
  1439. dmgRatio = (sHealth - eHealth) / mHealth;
  1440. var costs = ClientLib.API.Util.GetUnitRepairCosts(level, id, dmgRatio);
  1441.  
  1442. for (var idx = 0; idx < costs.length; idx++) {
  1443. var uCosts = costs[idx];
  1444. var cType = parseInt(uCosts.Type, 10);
  1445. switch (cType) {
  1446. case ClientLib.Base.EResourceType.Tiberium:
  1447. repairCosts.Tib += uCosts.Count;
  1448. break;
  1449. case ClientLib.Base.EResourceType.Crystal:
  1450. repairCosts.Cry += uCosts.Count;
  1451. break;
  1452. case ClientLib.Base.EResourceType.RepairChargeBase:
  1453. case ClientLib.Base.EResourceType.RepairChargeInf:
  1454. case ClientLib.Base.EResourceType.RepairChargeVeh:
  1455. case ClientLib.Base.EResourceType.RepairChargeAir:
  1456. repairCosts.RT += uCosts.Count;
  1457. break;
  1458. }
  1459. }
  1460.  
  1461. // Fix Repairtime for Forgotten
  1462. switch (ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity().get_CityFaction()) {
  1463. case ClientLib.Base.EFactionType.GDIFaction:
  1464. case ClientLib.Base.EFactionType.NODFaction:
  1465. break;
  1466. default:
  1467. repairCosts.RT = dmgRatio * 3600;
  1468. break;
  1469. }
  1470.  
  1471. }
  1472. return repairCosts;
  1473. },
  1474. _onTick: function () {
  1475. for (var i = 0; i < this.sim.length; i++) this.sim[i].UpdateLabels();
  1476. },
  1477. _onViewChanged: function (oldMode, newMode) {
  1478. if (newMode == ClientLib.Vis.Mode.CombatSetup && oldMode != ClientLib.Vis.Mode.Battleground) {
  1479. this.getLootFromCurrentCity();
  1480. // Auto open StatWindow
  1481. if (localStorage['autoOpenStat'] !== undefined && localStorage['autoOpenStat'] == "yes") this.open();
  1482. else {
  1483. this.open();
  1484. localStorage['autoOpenStat'] = "yes"; // Default
  1485. }
  1486. } else if (newMode != ClientLib.Vis.Mode.CombatSetup && newMode != ClientLib.Vis.Mode.Battleground) {
  1487. this.close();
  1488. }
  1489. },
  1490. __OnSimulateBattleFinished: function (data) {
  1491. //Disable Simulate Button
  1492. if (this.isSimStatButtonDisabled == false) {
  1493. this.disableSimulateStatButtonTimer(10000);
  1494. if (typeof Simulator.getInstance().disableSimulateButtonTimer === "function") {
  1495. Simulator.getInstance().disableSimulateButtonTimer(10000);
  1496. }
  1497. }
  1498. if (this.simReplayBtn.getEnabled() == false) this.simReplayBtn.setEnabled(true);
  1499.  
  1500. this.sim[this.simSelected].setSimulation(data);
  1501. this.calcHealth(this.sim[this.simSelected]);
  1502. this.calcLoot(this.sim[this.simSelected]);
  1503. this.getBattleDuration(this.sim[this.simSelected]);
  1504. },
  1505. calcHealth: function (sim) {
  1506. try {
  1507. sim.ResetStats();
  1508. var costs = {};
  1509. var targetunits = [];
  1510. var ownunits = [];
  1511. for (var i = 0; i < sim.Result.length; i++) {
  1512. var unit = ClientLib.Res.ResMain.GetInstance().GetUnit_Obj(sim.Result[i].t);
  1513. switch (unit.pt) {
  1514. case ClientLib.Base.EPlacementType.Structure:
  1515. case ClientLib.Base.EPlacementType.Defense:
  1516. targetunits.push(sim.Result[i]);
  1517. break;
  1518. case ClientLib.Base.EPlacementType.Offense:
  1519. ownunits.push(sim.Result[i]);
  1520. break;
  1521. }
  1522. }
  1523. ClientLib.Data.MainData.GetInstance().get_Cities().set_CurrentCityId(sim.TargetCity.get_Id());
  1524. for (var i = 0; i < targetunits.length; i++) {
  1525. var unitData = targetunits[i];
  1526. var unitMDBID = unitData.t;
  1527. var unit = ClientLib.Res.ResMain.GetInstance().GetUnit_Obj(unitMDBID);
  1528. var unitLevel = unitData.l;
  1529. var unitStartHealth = Math.floor(unitData.sh);
  1530. var unitEndHealth = Math.floor(unitData.h);
  1531. var unitMaxHealth = Math.floor((ClientLib.API.Util.GetUnitMaxHealthByLevel(unitLevel, unit, false)) * 16);
  1532. var unitPlacementType = unit.pt; // ClientLib.Base.EPlacementType
  1533. var unitMovementType = unit.mt; // ClientLib.Base.EUnitMovementType
  1534. switch (sim.TargetCity.get_CityFaction()) {
  1535. case ClientLib.Base.EFactionType.GDIFaction:
  1536. case ClientLib.Base.EFactionType.NODFaction:
  1537. unitMaxHealth = Math.floor((ClientLib.API.Util.GetUnitMaxHealthByLevel(unitLevel, unit, true)) * 16);
  1538. break;
  1539. }
  1540. costs = this.calculateRepairCosts(unitMDBID, unitLevel, unitStartHealth, unitEndHealth, unitMaxHealth);
  1541.  
  1542. switch (unitPlacementType) {
  1543. case ClientLib.Base.EPlacementType.Structure:
  1544. sim.Stats.EnemyHealth.Overall.StartHealth += unitStartHealth;
  1545. sim.Stats.EnemyHealth.Overall.EndHealth += unitEndHealth;
  1546. sim.Stats.EnemyHealth.Overall.MaxHealth += unitMaxHealth;
  1547. sim.Stats.EnemyHealth.Overall.RT += costs.RT;
  1548. sim.Stats.EnemyHealth.Overall.Tib += costs.Tib;
  1549. sim.Stats.EnemyHealth.Overall.Cry += costs.Cry;
  1550. sim.Stats.EnemyHealth.Base.StartHealth += unitStartHealth;
  1551. sim.Stats.EnemyHealth.Base.EndHealth += unitEndHealth;
  1552. sim.Stats.EnemyHealth.Base.MaxHealth += unitMaxHealth;
  1553. sim.Stats.EnemyHealth.Base.RT += costs.RT;
  1554. sim.Stats.EnemyHealth.Base.Tib += costs.Tib;
  1555. sim.Stats.EnemyHealth.Base.Cry += costs.Cry;
  1556. switch (unitMDBID) {
  1557. case 112: // GDI_Construction Yard
  1558. case 151: // NOD_Construction Yard
  1559. case 177: // FOR_Construction Yard
  1560. case 233: // FOR_Fortress_BASE_Construction Yard
  1561. sim.Stats.EnemyHealth.CY.StartHealth += unitStartHealth;
  1562. sim.Stats.EnemyHealth.CY.EndHealth += unitEndHealth;
  1563. sim.Stats.EnemyHealth.CY.MaxHealth += unitMaxHealth;
  1564. sim.Stats.EnemyHealth.CY.RT += costs.RT;
  1565. sim.Stats.EnemyHealth.CY.Tib += costs.Tib;
  1566. sim.Stats.EnemyHealth.CY.Cry += costs.Cry;
  1567. break;
  1568. case 131: // GDI_Defense Facility
  1569. case 158: // NOD_Defense Facility
  1570. case 195: // FOR_Defense Facility
  1571. sim.Stats.EnemyHealth.DF.StartHealth += unitStartHealth;
  1572. sim.Stats.EnemyHealth.DF.EndHealth += unitEndHealth;
  1573. sim.Stats.EnemyHealth.DF.MaxHealth += unitMaxHealth;
  1574. sim.Stats.EnemyHealth.DF.RT += costs.RT;
  1575. sim.Stats.EnemyHealth.DF.Tib += costs.Tib;
  1576. sim.Stats.EnemyHealth.DF.Cry += costs.Cry;
  1577. break;
  1578. case 111: // GDI_Command Center
  1579. case 159: // NOD_Command Post
  1580. sim.Stats.EnemyHealth.CC.StartHealth += unitStartHealth;
  1581. sim.Stats.EnemyHealth.CC.EndHealth += unitEndHealth;
  1582. sim.Stats.EnemyHealth.CC.MaxHealth += unitMaxHealth;
  1583. sim.Stats.EnemyHealth.CC.RT += costs.RT;
  1584. sim.Stats.EnemyHealth.CC.Tib += costs.Tib;
  1585. sim.Stats.EnemyHealth.CC.Cry += costs.Cry;
  1586. break;
  1587. }
  1588. break;
  1589. case ClientLib.Base.EPlacementType.Defense:
  1590. sim.Stats.EnemyHealth.Overall.StartHealth += unitStartHealth;
  1591. sim.Stats.EnemyHealth.Overall.EndHealth += unitEndHealth;
  1592. sim.Stats.EnemyHealth.Overall.MaxHealth += unitMaxHealth;
  1593. sim.Stats.EnemyHealth.Overall.Tib += costs.Tib;
  1594. sim.Stats.EnemyHealth.Overall.Cry += costs.Cry;
  1595. sim.Stats.EnemyHealth.Defense.StartHealth += unitStartHealth;
  1596. sim.Stats.EnemyHealth.Defense.EndHealth += unitEndHealth;
  1597. sim.Stats.EnemyHealth.Defense.MaxHealth += unitMaxHealth;
  1598. sim.Stats.EnemyHealth.Defense.Tib += costs.Tib;
  1599. sim.Stats.EnemyHealth.Defense.Cry += costs.Cry;
  1600. break;
  1601. }
  1602. }
  1603. ClientLib.Data.MainData.GetInstance().get_Cities().set_CurrentCityId(sim.OwnCity.get_Id());
  1604. for (var i = 0; i < ownunits.length; i++) {
  1605. var unitData = ownunits[i];
  1606. var unitMDBID = unitData.t;
  1607. var unit = ClientLib.Res.ResMain.GetInstance().GetUnit_Obj(unitMDBID);
  1608. var unitLevel = unitData.l;
  1609. var unitStartHealth = Math.floor(unitData.sh);
  1610. var unitEndHealth = Math.floor(unitData.h);
  1611. var unitMaxHealth = Math.floor((ClientLib.API.Util.GetUnitMaxHealthByLevel(unitLevel, unit, false)) * 16);
  1612. var unitPlacementType = unit.pt; // ClientLib.Base.EPlacementType
  1613. var unitMovementType = unit.mt; // ClientLib.Base.EUnitMovementType
  1614. costs = this.calculateRepairCosts(unitMDBID, unitLevel, unitStartHealth, unitEndHealth, unitMaxHealth);
  1615.  
  1616. switch (unitPlacementType) {
  1617. case ClientLib.Base.EPlacementType.Offense:
  1618. sim.Stats.Repair.Overall.StartHealth += unitStartHealth;
  1619. sim.Stats.Repair.Overall.EndHealth += unitEndHealth;
  1620. sim.Stats.Repair.Overall.MaxHealth += unitMaxHealth;
  1621. sim.Stats.Repair.Overall.Tib += costs.Tib;
  1622. sim.Stats.Repair.Overall.Cry += costs.Cry;
  1623. switch (unitMovementType) {
  1624. case ClientLib.Base.EUnitMovementType.Feet:
  1625. sim.Stats.Repair.Inf.StartHealth += unitStartHealth;
  1626. sim.Stats.Repair.Inf.EndHealth += unitEndHealth;
  1627. sim.Stats.Repair.Inf.MaxHealth += unitMaxHealth;
  1628. sim.Stats.Repair.Inf.RT += costs.RT;
  1629. sim.Stats.Repair.Inf.Tib += costs.Tib;
  1630. sim.Stats.Repair.Inf.Cry += costs.Cry;
  1631. break;
  1632. case ClientLib.Base.EUnitMovementType.Wheel:
  1633. case ClientLib.Base.EUnitMovementType.Track:
  1634. sim.Stats.Repair.Vehi.StartHealth += unitStartHealth;
  1635. sim.Stats.Repair.Vehi.EndHealth += unitEndHealth;
  1636. sim.Stats.Repair.Vehi.MaxHealth += unitMaxHealth;
  1637. sim.Stats.Repair.Vehi.RT += costs.RT;
  1638. sim.Stats.Repair.Vehi.Tib += costs.Tib;
  1639. sim.Stats.Repair.Vehi.Cry += costs.Cry;
  1640. break;
  1641. case ClientLib.Base.EUnitMovementType.Air:
  1642. case ClientLib.Base.EUnitMovementType.Air2:
  1643. sim.Stats.Repair.Air.StartHealth += unitStartHealth;
  1644. sim.Stats.Repair.Air.EndHealth += unitEndHealth;
  1645. sim.Stats.Repair.Air.MaxHealth += unitMaxHealth;
  1646. sim.Stats.Repair.Air.RT += costs.RT;
  1647. sim.Stats.Repair.Air.Tib += costs.Tib;
  1648. sim.Stats.Repair.Air.Cry += costs.Cry;
  1649. break;
  1650. }
  1651. break;
  1652. }
  1653. }
  1654. ClientLib.Data.MainData.GetInstance().get_Cities().set_CurrentCityId(sim.TargetCity.get_Id());
  1655.  
  1656. //Set Repair Overall RT
  1657. sim.Stats.Repair.Overall.RT = Math.max(sim.Stats.Repair.Inf.RT, sim.Stats.Repair.Vehi.RT, sim.Stats.Repair.Air.RT);
  1658.  
  1659. //Set Battle Outcome
  1660. if (sim.Stats.Repair.Overall.EndHealth === 0) sim.Stats.Battle.Outcome = 1;
  1661. else if (sim.Stats.EnemyHealth.CY.EndHealth === 0) sim.Stats.Battle.Outcome = 3;
  1662. else sim.Stats.Battle.Outcome = 2;
  1663. } catch (e) {
  1664. console.log("Error Getting Player Unit Damage");
  1665. console.log(e.toString());
  1666. }
  1667. },
  1668. calcLoot: function (sim) {
  1669. try {
  1670. var Ents = (sim.Result);
  1671. var lootArray = { 1: 0, 2: 0, 3: 0, 6: 0 };
  1672. var i, x, y, unit, Entity , mod = -1, unitMaxHealth = 0;
  1673. for (y = 0; y < 16; y++) {
  1674. for (x = 8; x >= 0; x--) {
  1675. if (y < 8) {
  1676. var width = ClientLib.Vis.VisMain.GetInstance().get_City().get_GridWidth();
  1677. var height = ClientLib.Vis.VisMain.GetInstance().get_City().get_GridHeight();
  1678. } else {
  1679. var width = ClientLib.Vis.VisMain.GetInstance().get_DefenseSetup().get_GridWidth();
  1680. var height = ClientLib.Vis.VisMain.GetInstance().get_DefenseSetup().get_GridHeight();
  1681. }
  1682. Entity = ClientLib.Vis.VisMain.GetInstance().GetObjectFromPosition(((x * width) + (width / 2)), ((y * height) + (height / 2)));
  1683. if (Entity !== null) {
  1684. for (i = 0; i < Ents.length; i++) {
  1685. unit = ClientLib.Res.ResMain.GetInstance().GetUnit_Obj(Ents[i].t);
  1686. switch (sim.TargetCity.get_CityFaction()) {
  1687. case ClientLib.Base.EFactionType.GDIFaction:
  1688. case ClientLib.Base.EFactionType.NODFaction:
  1689. unitMaxHealth = Math.floor((ClientLib.API.Util.GetUnitMaxHealthByLevel(Ents[i].l, unit, true)) * 16);
  1690. break;
  1691. default:
  1692. unitMaxHealth = Math.floor((ClientLib.API.Util.GetUnitMaxHealthByLevel(Ents[i].l, unit, false)) * 16);
  1693. break;
  1694. }
  1695. mod = (Ents[i].sh - Ents[i].h) / unitMaxHealth;
  1696. if (Entity.get_VisObjectType() == ClientLib.Vis.VisObject.EObjectType.CityBuildingType && Ents[i].t == Entity.get_BuildingDetails().get_MdbUnitId() && Ents[i].l == Entity.get_BuildingLevel()) {
  1697. var reqs = Entity.get_BuildingDetails().get_UnitLevelRepairRequirements();
  1698. for (i = 0; i < reqs.length; i++) lootArray[reqs[i].Type] += Math.floor(mod * reqs[i].Count);
  1699. Ents.splice(i, 1);
  1700. break;
  1701. }
  1702. if (Entity.get_VisObjectType() == ClientLib.Vis.VisObject.EObjectType.DefenseUnitType && Ents[i].t == Entity.get_UnitDetails().get_MdbUnitId() && Ents[i].l == Entity.get_UnitLevel()) {
  1703. var reqs = Entity.get_UnitDetails().get_UnitLevelRepairRequirements();
  1704. for (i = 0; i < reqs.length; i++) lootArray[reqs[i].Type] += Math.floor(mod * reqs[i].Count);
  1705. Ents.splice(i, 1);
  1706. break;
  1707. }
  1708. }
  1709. }
  1710. }
  1711. }
  1712. var totalLoot = lootArray[1] + lootArray[2] + lootArray[3] + lootArray[6];
  1713. if (sim.Stats.Battle.Outcome === 3) {
  1714. sim.Stats.Loot.Overall.Battle = sim.Stats.Loot.Overall.Base;
  1715. sim.Stats.Loot.Tib.Battle = sim.Stats.Loot.Tib.Base;
  1716. sim.Stats.Loot.Cry.Battle = sim.Stats.Loot.Cry.Base;
  1717. sim.Stats.Loot.Cred.Battle = sim.Stats.Loot.Cred.Base;
  1718. sim.Stats.Loot.RP.Battle = sim.Stats.Loot.RP.Base;
  1719. } else {
  1720. sim.Stats.Loot.Overall.Battle = totalLoot;
  1721. sim.Stats.Loot.Tib.Battle = lootArray[1];
  1722. sim.Stats.Loot.Cry.Battle = lootArray[2];
  1723. sim.Stats.Loot.Cred.Battle = lootArray[3];
  1724. sim.Stats.Loot.RP.Battle = lootArray[6];
  1725. }
  1726. } catch (e) {
  1727. console.log("Error Calculating Resources");
  1728. console.log(e);
  1729. console.log(e.name + " " + e.message);
  1730. }
  1731.  
  1732. },
  1733. getBattleDuration: function (sim) {
  1734. var battleground = ClientLib.Vis.VisMain.GetInstance().get_Battleground();
  1735. if (battleground.get_Simulation() !== null) sim.Stats.Battle.Duration = battleground.get_Replay().m_CombatSteps * battleground.get_TimePerStep();
  1736. else setTimeout(function () {
  1737. Simulator.StatWindow.getInstance().getBattleDuration(sim);
  1738. }, 10);
  1739. },
  1740. getLootFromCurrentCity: function () {
  1741. try {
  1742. var lootArray = { 1: 0, 2: 0, 3: 0, 6: 0 };
  1743. var loot = ClientLib.API.Battleground.GetInstance().GetLootFromCurrentCity();
  1744. if (loot !== null && loot.length > 0) {
  1745. for (var i = 0; i < loot.length; i++) lootArray[parseInt(loot[i].Type, 10)] += loot[i].Count;
  1746. for (var i = 0; i < this.sim.length; i++) {
  1747. this.sim[i].Reset();
  1748. this.sim[i].Stats.Loot.Overall.Base = lootArray[1] + lootArray[2] + lootArray[3] + lootArray[6];
  1749. this.sim[i].Stats.Loot.Tib.Base = lootArray[1];
  1750. this.sim[i].Stats.Loot.Cry.Base = lootArray[2];
  1751. this.sim[i].Stats.Loot.Cred.Base = lootArray[3];
  1752. this.sim[i].Stats.Loot.RP.Base = lootArray[6];
  1753. }
  1754. } else {
  1755. setTimeout(function () {
  1756. Simulator.StatWindow.getInstance().getLootFromCurrentCity();
  1757. }, 100);
  1758. }
  1759. } catch (e) {
  1760. console.log("Error Getting Loot from Current City");
  1761. console.log(e.toString());
  1762. }
  1763. },
  1764. disableSimulateStatButtonTimer: function (timer) {
  1765. try {
  1766. if (timer >= 1000) {
  1767. this.isSimStatButtonDisabled = true;
  1768. this.simStatBtn.setEnabled(false);
  1769. this.simStatBtn.setLabel(Math.floor(timer / 1000));
  1770. timer -= 1000;
  1771. setTimeout(function () {
  1772. Simulator.StatWindow.getInstance().disableSimulateStatButtonTimer(timer);
  1773. }, 1000);
  1774. } else {
  1775. setTimeout(function () {
  1776. Simulator.StatWindow.getInstance().simStatBtn.setEnabled(true);
  1777. Simulator.StatWindow.getInstance().simStatBtn.setLabel("Update");
  1778. }, timer);
  1779. this.isSimStatButtonDisabled = false;
  1780. }
  1781. } catch (e) {
  1782. console.log("Error disabling simulator button");
  1783. console.log(e.toString());
  1784. }
  1785. }
  1786. }
  1787. });
  1788. qx.Class.define("Simulator.OptionWindow", {
  1789. type: "singleton",
  1790. extend: qx.ui.window.Window,
  1791.  
  1792. construct: function () {
  1793. var qxApp = qx.core.Init.getApplication();
  1794. this.base(arguments);
  1795. this.setLayout(new qx.ui.layout.VBox(5));
  1796. this.addListener("resize", function () {
  1797. this.center();
  1798. }, this);
  1799.  
  1800. this.set({
  1801. caption: qxApp.tr("Simulator") + " - " + qxApp.tr("tnf:options"),
  1802. allowMaximize: false,
  1803. showMaximize: false,
  1804. allowMinimize: false,
  1805. showMinimize: false
  1806. });
  1807. var tabView = new qx.ui.tabview.TabView();
  1808. var genPage = new qx.ui.tabview.Page(qxApp.tr("tnf:general"));
  1809. genLayout = new qx.ui.layout.VBox(5);
  1810. genPage.setLayout(genLayout);
  1811.  
  1812. //Add General Page Items
  1813. var buttonsHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
  1814. buttonsHeader.setThemedFont("bold");
  1815. var buttonsTitle = new qx.ui.basic.Label(qxApp.tr("Buttons:"));
  1816. buttonsHeader.add(buttonsTitle);
  1817. genPage.add(buttonsHeader);
  1818.  
  1819. var buttonsBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
  1820. this._buttonLocCB = new qx.ui.form.CheckBox(qxApp.tr("Right Side"));
  1821. this._buttonSizeCB = new qx.ui.form.CheckBox(qxApp.tr("Normal Size"));
  1822. this._buttonLocCB.addListener("changeValue", this._onButtonLocChange, this);
  1823. this._buttonSizeCB.addListener("changeValue", this._onButtonSizeChange, this);
  1824. if (localStorage['isBtnRight'] !== undefined) {
  1825. if (localStorage['isBtnRight'] == "yes")
  1826. this._buttonLocCB.setValue(true);
  1827. else
  1828. this._buttonLocCB.setValue(false);
  1829. }
  1830.  
  1831. if (localStorage['isBtnNorm'] !== undefined) {
  1832. if (localStorage['isBtnNorm'] == "yes")
  1833. this._buttonSizeCB.setValue(true);
  1834. else
  1835. this._buttonSizeCB.setValue(false);
  1836.  
  1837. //Need to do this
  1838. this.setButtonSize();
  1839. }
  1840.  
  1841. this._disableRTBtnCB = new qx.ui.form.CheckBox(qxApp.tr("Disable Repair Button"));
  1842. this._disableRTBtnCB.addListener("changeValue", this._onDisableRTBtnChange, this);
  1843. if (localStorage['isRTBtnDisabled'] !== undefined && localStorage['isRTBtnDisabled'] == "no") this._disableRTBtnCB.setValue(false);
  1844. else this._disableRTBtnCB.setValue(true);
  1845.  
  1846. this._disableCmtBtnCB = new qx.ui.form.CheckBox(qxApp.tr("Disable Combat Button"));
  1847. this._disableCmtBtnCB.addListener("changeValue", this._onDisableCmtBtnChange, this);
  1848. if (localStorage['isCmtBtnDisabled'] !== undefined && localStorage['isCmtBtnDisabled'] == "no") this._disableCmtBtnCB.setValue(false);
  1849. else this._disableCmtBtnCB.setValue(true);
  1850.  
  1851. this._ArmyUnitTooltip = new qx.ui.form.CheckBox(qxApp.tr("Disable Army Unit Tooltip"));
  1852. this._ArmyUnitTooltip.addListener("changeValue", this._onArmyUnitTooltipChange, this);
  1853. if (localStorage['ArmyUnitTooltipDisabled'] !== undefined) {
  1854. if (localStorage['ArmyUnitTooltipDisabled'] == "yes")
  1855. this._ArmyUnitTooltip.setValue(true);
  1856. else
  1857. this._ArmyUnitTooltip.setValue(false);
  1858. }
  1859.  
  1860. buttonsBox.add(this._buttonSizeCB);
  1861. buttonsBox.add(this._buttonLocCB);
  1862. buttonsBox.add(this._disableRTBtnCB);
  1863. buttonsBox.add(this._disableCmtBtnCB);
  1864. buttonsBox.add(this._ArmyUnitTooltip);
  1865. genPage.add(buttonsBox);
  1866.  
  1867.  
  1868.  
  1869. var simulatorHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({
  1870. marginTop: 10
  1871. });
  1872. simulatorHeader.setThemedFont("bold");
  1873. var simulatorTitle = new qx.ui.basic.Label(qxApp.tr("Simulator") + ":");
  1874. simulatorHeader.add(simulatorTitle);
  1875. genPage.add(simulatorHeader);
  1876.  
  1877. var simulatorBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
  1878. this._autoSimulateCB = new qx.ui.form.CheckBox(qxApp.tr("Auto Start Simulation"));
  1879.  
  1880. if (localStorage['autoSimulate'] !== undefined) {
  1881. if (localStorage['autoSimulate'] == "yes")
  1882. this._autoSimulateCB.setValue(true);
  1883. }
  1884.  
  1885. var simulatorBox2 = new qx.ui.container.Composite(new qx.ui.layout.Grid(5)).set({
  1886. marginLeft: 20
  1887. });
  1888. var simSpeedOpt1 = new qx.ui.form.RadioButton("x1");
  1889. var simSpeedOpt2 = new qx.ui.form.RadioButton("x2");
  1890. var simSpeedOpt4 = new qx.ui.form.RadioButton("x4");
  1891. this._simSpeedGroup = new qx.ui.form.RadioGroup(simSpeedOpt1, simSpeedOpt2, simSpeedOpt4);
  1892. this._simSpeedGroup.addListener("changeSelection", this._onSimSpeedChange, this);
  1893. this._autoSimulateCB.addListener("changeValue", this._onAutoSimulateChange, this);
  1894. if (localStorage['simulateSpeed'] !== undefined) {
  1895. var options = this._simSpeedGroup.getSelectables(false);
  1896.  
  1897. if (localStorage['simulateSpeed'] == "2")
  1898. options[1].setValue(true);
  1899. else if (localStorage['simulateSpeed'] == "4")
  1900. options[2].setValue(true);
  1901. else
  1902. options[0].setValue(true);
  1903. }
  1904. if (this._autoSimulateCB.getValue() == false) {
  1905. this._simSpeedGroup.setEnabled(false);
  1906. }
  1907.  
  1908. simulatorBox2.add(simSpeedOpt1, {row: 0, column: 0});
  1909. simulatorBox2.add(simSpeedOpt2, {row: 0, column: 1});
  1910. simulatorBox2.add(simSpeedOpt4, {row: 0, column: 2});
  1911. simulatorBox.add(this._autoSimulateCB);
  1912. simulatorBox.add(simulatorBox2);
  1913. genPage.add(simulatorBox);
  1914.  
  1915. var statsPage = new qx.ui.tabview.Page(qxApp.tr("Stats"));
  1916. statsLayout = new qx.ui.layout.VBox(5);
  1917. statsPage.setLayout(statsLayout);
  1918.  
  1919. var statWindowHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
  1920. statWindowHeader.setThemedFont("bold");
  1921. var statWindowTitle = new qx.ui.basic.Label(qxApp.tr("Stats Window:"));
  1922. statWindowHeader.add(statWindowTitle);
  1923. statsPage.add(statWindowHeader);
  1924.  
  1925. var statWindowBox = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
  1926. this._autoOpenCB = new qx.ui.form.CheckBox(qxApp.tr("Auto Open"));
  1927. this._autoOpenCB.addListener("changeValue", this._onAutoOpenStatsChange, this);
  1928. if (localStorage['autoOpenStat'] !== undefined) {
  1929. if (localStorage['autoOpenStat'] == "yes")
  1930. this._autoOpenCB.setValue(true);
  1931. else
  1932. this._autoOpenCB.setValue(false);
  1933. }
  1934.  
  1935. statWindowBox.add(this._autoOpenCB);
  1936. statsPage.add(statWindowBox);
  1937.  
  1938. var EnemyHealthSecHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({
  1939. marginTop: 10
  1940. });
  1941. EnemyHealthSecHeader.setThemedFont("bold");
  1942. var EnemyHealthSecTitle = new qx.ui.basic.Label(qxApp.tr("tnf:combat target"));
  1943. EnemyHealthSecHeader.add(EnemyHealthSecTitle);
  1944. statsPage.add(EnemyHealthSecHeader);
  1945.  
  1946. var EnemyHealthSecBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
  1947. var EnemyHealthDisplayOpt1 = new qx.ui.form.RadioButton("HP abs");
  1948. var EnemyHealthDisplayOpt2 = new qx.ui.form.RadioButton("HP rel");
  1949. this._EnemyHealthSecGroup = new qx.ui.form.RadioGroup(EnemyHealthDisplayOpt1, EnemyHealthDisplayOpt2);
  1950. this._EnemyHealthSecGroup.addListener("changeSelection", this._onEnemyHealthSelectionChange, this);
  1951. if (localStorage['getEHSelection'] !== undefined) {
  1952. var options = this._EnemyHealthSecGroup.getSelectables(false);
  1953.  
  1954. if (localStorage['getEHSelection'] == "hp")
  1955. options[0].setValue(true);
  1956. else if (localStorage['getEHSelection'] == "hp rel")
  1957. options[1].setValue(true);
  1958. else
  1959. options[0].setValue(true);
  1960. }
  1961. EnemyHealthSecBox.add(EnemyHealthDisplayOpt1);
  1962. EnemyHealthSecBox.add(EnemyHealthDisplayOpt2);
  1963. statsPage.add(EnemyHealthSecBox);
  1964.  
  1965. var repairSecHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({
  1966. marginTop: 10
  1967. });
  1968. repairSecHeader.setThemedFont("bold");
  1969. var repairSecTitle = new qx.ui.basic.Label(qxApp.tr("tnf:own repair cost"));
  1970. repairSecHeader.add(repairSecTitle);
  1971. statsPage.add(repairSecHeader);
  1972.  
  1973. var repairSecBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
  1974. var repairDisplayOpt1 = new qx.ui.form.RadioButton("RT");
  1975. var repairDisplayOpt2 = new qx.ui.form.RadioButton("C");
  1976. var repairDisplayOpt3 = new qx.ui.form.RadioButton("HP abs");
  1977. var repairDisplayOpt4 = new qx.ui.form.RadioButton("HP rel");
  1978. this._repairSecGroup = new qx.ui.form.RadioGroup(repairDisplayOpt1, repairDisplayOpt2, repairDisplayOpt3, repairDisplayOpt4);
  1979. this._repairSecGroup.addListener("changeSelection", this._onRepairSelectionChange, this);
  1980. if (localStorage['getRTSelection'] !== undefined) {
  1981. var options = this._repairSecGroup.getSelectables(false);
  1982.  
  1983. if (localStorage['getRTSelection'] == "rt")
  1984. options[0].setValue(true);
  1985. else if (localStorage['getRTSelection'] == "cry")
  1986. options[1].setValue(true);
  1987. else if (localStorage['getRTSelection'] == "hp")
  1988. options[2].setValue(true);
  1989. else if (localStorage['getRTSelection'] == "hp rel")
  1990. options[3].setValue(true);
  1991. else
  1992. options[0].setValue(true);
  1993. }
  1994. repairSecBox.add(repairDisplayOpt1);
  1995. repairSecBox.add(repairDisplayOpt2);
  1996. repairSecBox.add(repairDisplayOpt3);
  1997. repairSecBox.add(repairDisplayOpt4);
  1998. statsPage.add(repairSecBox);
  1999.  
  2000. var simViewsHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({marginTop: 10});
  2001. simViewsHeader.setThemedFont("bold");
  2002. var simViewsTitle = new qx.ui.basic.Label(qxApp.tr("Simulations shown"));
  2003. simViewsHeader.add(simViewsTitle);
  2004. statsPage.add(simViewsHeader);
  2005.  
  2006. var simViewsBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
  2007. this._simViews = new qx.ui.form.Spinner().set({ minimum: 2 });
  2008. if (localStorage['simViews'] !== undefined) {
  2009. if (!isNaN(parseInt(localStorage['simViews'], 10))) this._simViews.setValue(parseInt(localStorage['simViews'], 10));
  2010. else this._simViews.setValue(Simulator.StatWindow.getInstance().simViews);
  2011. }
  2012. this._simViews.addListener("changeValue", this._onSimViewsChanged, this);
  2013. simViewsBox.add(this._simViews);
  2014. statsPage.add(simViewsBox);
  2015.  
  2016. var hideSecHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({marginTop: 10});
  2017. hideSecHeader.setThemedFont("bold");
  2018. var hideSecTitle = new qx.ui.basic.Label(qxApp.tr("Hide Sections (on Startup):"));
  2019. hideSecHeader.add(hideSecTitle);
  2020. statsPage.add(hideSecHeader);
  2021.  
  2022. var hideSecBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
  2023. this._hideHealthCB = new qx.ui.form.CheckBox(qxApp.tr("Health"));
  2024. this._hideRepairCB = new qx.ui.form.CheckBox(qxApp.tr("Repair"));
  2025. this._hideLootCB = new qx.ui.form.CheckBox(qxApp.tr("Loot"));
  2026. this._hideHealthCB.addListener("changeValue", this._onHideEHChange, this);
  2027. this._hideRepairCB.addListener("changeValue", this._onHideRTChange, this);
  2028. this._hideLootCB.addListener("changeValue", this._onHideLootChange, this);
  2029. if (localStorage['hideHealth'] !== undefined) {
  2030. if (localStorage['hideHealth'] == "yes")
  2031. this._hideHealthCB.setValue(true);
  2032. else
  2033. this._hideHealthCB.setValue(false);
  2034. }
  2035. if (localStorage['hideRepair'] !== undefined) {
  2036. if (localStorage['hideRepair'] == "yes")
  2037. this._hideRepairCB.setValue(true);
  2038. else
  2039. this._hideRepairCB.setValue(false);
  2040. }
  2041. if (localStorage['hideLoot'] !== undefined) {
  2042. if (localStorage['hideLoot'] == "yes")
  2043. this._hideLootCB.setValue(true);
  2044. else
  2045. this._hideLootCB.setValue(false);
  2046. }
  2047. hideSecBox.add(this._hideHealthCB);
  2048. hideSecBox.add(this._hideRepairCB);
  2049. hideSecBox.add(this._hideLootCB);
  2050. statsPage.add(hideSecBox);
  2051.  
  2052. var statPosHeader = new qx.ui.container.Composite(new qx.ui.layout.HBox(5)).set({marginTop: 10});
  2053. var statPosTitle = new qx.ui.basic.Label(qxApp.tr("Set Stat Window Position:")).set({alignY: "middle"});
  2054. statPosTitle.setFont("bold");
  2055. var statPosBtn = new qx.ui.form.Button(qxApp.tr("Set")).set({allowGrowX: false, allowGrowY: false, height: 20});
  2056. statPosBtn.addListener("click", this._onSetStatWindowPositionChange, this);
  2057. statPosHeader.add(statPosTitle);
  2058. statPosHeader.add(statPosBtn);
  2059. statsPage.add(statPosHeader);
  2060.  
  2061. tabView.add(genPage);
  2062. tabView.add(statsPage);
  2063. this.add(tabView);
  2064. phe.cnc.Util.attachNetEvent(ClientLib.Vis.VisMain.GetInstance(), "ViewModeChange", ClientLib.Vis.ViewModeChange, this, function () { this.close(); });
  2065. },
  2066.  
  2067. destruct: function () {},
  2068.  
  2069. members: {
  2070. _buttonSizeCB: null,
  2071. _buttonLocCB: null,
  2072. _disableRTBtnCB: null,
  2073. _disableCmtBtnCB: null,
  2074. _autoOpenCB: null,
  2075. _autoSimulateCB: null,
  2076. _simSpeedGroup: null,
  2077. _repairSecGroup: null,
  2078. _EnemyHealthSecGroup: null,
  2079. _simViews: null,
  2080. _hideHealthCB: null,
  2081. _hideRepairCB: null,
  2082. _hideLootCB: null,
  2083. _ArmyUnitTooltip: null,
  2084.  
  2085. _onButtonSizeChange: function () {
  2086. try {
  2087. var value = this._buttonSizeCB.getValue();
  2088.  
  2089. if (value == true)
  2090. localStorage['isBtnNorm'] = "yes";
  2091. else
  2092. localStorage['isBtnNorm'] = "no";
  2093.  
  2094. this.setButtonSize();
  2095. } catch (e) {
  2096. console.log("Error Button Size Change: " + e.toString());
  2097. }
  2098. },
  2099.  
  2100. _onButtonLocChange: function () {
  2101. try {
  2102. var value = this._buttonLocCB.getValue();
  2103.  
  2104. if (value == true)
  2105. localStorage['isBtnRight'] = "yes";
  2106. else
  2107. localStorage['isBtnRight'] = "no";
  2108.  
  2109. this.setButtonLoc();
  2110. } catch (e) {
  2111. console.log("Error Button Location Change: " + e.toString());
  2112. }
  2113. },
  2114.  
  2115. _onDisableRTBtnChange: function () {
  2116. try {
  2117. var value = this._disableRTBtnCB.getValue();
  2118.  
  2119. if (value == true)
  2120. localStorage['isRTBtnDisabled'] = "yes";
  2121. else
  2122. localStorage['isRTBtnDisabled'] = "no";
  2123.  
  2124. this.setRTBtn(value);
  2125. } catch (e) {
  2126. console.log("Error Disable RT Button Change: " + e.toString());
  2127. }
  2128. },
  2129.  
  2130. _onDisableCmtBtnChange: function () {
  2131. try {
  2132. var value = this._disableCmtBtnCB.getValue();
  2133.  
  2134. if (value == true)
  2135. localStorage['isCmtBtnDisabled'] = "yes";
  2136. else
  2137. localStorage['isCmtBtnDisabled'] = "no";
  2138.  
  2139. this.setCmtBtn(value);
  2140. } catch (e) {
  2141. console.log("Error Disable Cmt Button Change: " + e.toString());
  2142. }
  2143. },
  2144.  
  2145. _onEnemyHealthSelectionChange: function (selection) {
  2146. try {
  2147. var option = selection.getData()[0];
  2148. var label = option.getLabel();
  2149.  
  2150. if (label == "HP abs")
  2151. localStorage['getEHSelection'] = "hp";
  2152. else if (label == "HP rel")
  2153. localStorage['getEHSelection'] = "hp rel";
  2154. else
  2155. localStorage['getEHSelection'] = "hp";
  2156. } catch (e) {
  2157. console.log("Error Enemy Health Section Selection Change: " + e.toString());
  2158. }
  2159. },
  2160.  
  2161. _onRepairSelectionChange: function (selection) {
  2162. try {
  2163. var option = selection.getData()[0];
  2164. var label = option.getLabel();
  2165.  
  2166. if (label == "RT")
  2167. localStorage['getRTSelection'] = "rt";
  2168. else if (label == "HP abs")
  2169. localStorage['getRTSelection'] = "hp";
  2170. else if (label == "HP rel")
  2171. localStorage['getRTSelection'] = "hp rel";
  2172. else if (label == "C")
  2173. localStorage['getRTSelection'] = "cry";
  2174. else
  2175. localStorage['getRTSelection'] = "rt";
  2176. } catch (e) {
  2177. console.log("Error Repair Section Selection Change: " + e.toString());
  2178. }
  2179. },
  2180.  
  2181. _onAutoOpenStatsChange: function () {
  2182. try {
  2183. var value = this._autoOpenCB.getValue();
  2184.  
  2185. if (value == false)
  2186. localStorage['autoOpenStat'] = "no";
  2187. else
  2188. localStorage['autoOpenStat'] = "yes";
  2189. } catch (e) {
  2190. console.log("Error Auto Open Stats Change: " + e.toString());
  2191. }
  2192. },
  2193.  
  2194. _onArmyUnitTooltipChange: function () {
  2195. try {
  2196. var value = this._ArmyUnitTooltip.getValue();
  2197.  
  2198. if (value == false)
  2199. localStorage['ArmyUnitTooltipDisabled'] = "no";
  2200. else
  2201. localStorage['ArmyUnitTooltipDisabled'] = "yes";
  2202. } catch (e) {
  2203. console.log("Error Army Unit Tooltip Change: " + e.toString());
  2204. }
  2205. },
  2206.  
  2207. _onAutoSimulateChange: function () {
  2208. try {
  2209. var value = this._autoSimulateCB.getValue();
  2210. if (value == false) {
  2211. this._simSpeedGroup.setEnabled(false);
  2212. localStorage['autoSimulate'] = "no";
  2213. } else {
  2214. this._simSpeedGroup.setEnabled(true);
  2215. localStorage['autoSimulate'] = "yes";
  2216. }
  2217. } catch (e) {
  2218. console.log("Error Auto Simulate Change: " + e.toString());
  2219. }
  2220. },
  2221.  
  2222. _onSimSpeedChange: function (selection) {
  2223. try {
  2224. var option = selection.getData()[0];
  2225. var label = option.getLabel();
  2226.  
  2227. if (label == "x1")
  2228. localStorage['simulateSpeed'] = "1";
  2229. else if (label == "x2")
  2230. localStorage['simulateSpeed'] = "2";
  2231. else
  2232. localStorage['simulateSpeed'] = "4";
  2233. } catch (e) {
  2234. console.log("Error Sim Speed Change: " + e.toString());
  2235. }
  2236. },
  2237.  
  2238. _onSimViewsChanged: function () {
  2239. try {
  2240. var value = parseInt(this._simViews.getValue(), 10);
  2241. if (!isNaN(value)) {
  2242. if (value > 0) {
  2243. localStorage['simViews'] = value.toString();
  2244. Simulator.StatWindow.getInstance().simViews = value;
  2245.  
  2246. // Remove Simulations from Stats Window
  2247. for (var i = (Simulator.StatWindow.getInstance().sim.length-1); i >= 0; i--) {
  2248. if (i > (value-1)) {
  2249. Simulator.StatWindow.getInstance().Battle.remove(Simulator.StatWindow.getInstance().sim[i].Label.Battle.container);
  2250. Simulator.StatWindow.getInstance().EnemyHealth.remove(Simulator.StatWindow.getInstance().sim[i].Label.EnemyHealth.container);
  2251. Simulator.StatWindow.getInstance().Repair.remove(Simulator.StatWindow.getInstance().sim[i].Label.Repair.container);
  2252. Simulator.StatWindow.getInstance().Loot.remove(Simulator.StatWindow.getInstance().sim[i].Label.Loot.container);
  2253. Simulator.StatWindow.getInstance().sim.pop();
  2254. }
  2255. }
  2256.  
  2257. // Create and add Simulations to Stats Window
  2258. for (var i = 0; i < value; i++) {
  2259. if (i == Simulator.StatWindow.getInstance().sim.length) {
  2260. Simulator.StatWindow.getInstance().sim.push(new (Simulator.StatWindow.getInstance()).Simulation(i));
  2261. Simulator.StatWindow.getInstance().Battle.add(Simulator.StatWindow.getInstance().sim[i].Label.Battle.container, { flex : 1 });
  2262. Simulator.StatWindow.getInstance().EnemyHealth.add(Simulator.StatWindow.getInstance().sim[i].Label.EnemyHealth.container, { flex : 1 });
  2263. Simulator.StatWindow.getInstance().Repair.add(Simulator.StatWindow.getInstance().sim[i].Label.Repair.container, { flex : 1 });
  2264. Simulator.StatWindow.getInstance().Loot.add(Simulator.StatWindow.getInstance().sim[i].Label.Loot.container, { flex : 1 });
  2265. Simulator.StatWindow.getInstance().sim[i].Select(Simulator.StatWindow.getInstance().simSelected);
  2266. }
  2267. }
  2268.  
  2269. if ((value-1) < Simulator.StatWindow.getInstance().simSelected) {
  2270. Simulator.StatWindow.getInstance().simSelected = 0;
  2271. for (var i = 0; i < Simulator.StatWindow.getInstance().sim.length; i++) {
  2272. Simulator.StatWindow.getInstance().sim[i].Select(0);
  2273. }
  2274. }
  2275. }
  2276. }
  2277. } catch (e) {
  2278. console.log("Error Simulation Views Change: " + e.toString());
  2279. }
  2280. },
  2281.  
  2282. _onHideEHChange: function () {
  2283. try {
  2284. var value = this._hideHealthCB.getValue();
  2285.  
  2286. if (value == true)
  2287. localStorage['hideHealth'] = "yes";
  2288. else
  2289. localStorage['hideHealth'] = "no";
  2290.  
  2291. } catch (e) {
  2292. console.log("Error Hide Enemy Base Health Change: " + e.toString());
  2293. }
  2294. },
  2295.  
  2296. _onHideRTChange: function () {
  2297. try {
  2298. var value = this._hideRepairCB.getValue();
  2299.  
  2300. if (value == true)
  2301. localStorage['hideRepair'] = "yes";
  2302. else
  2303. localStorage['hideRepair'] = "no";
  2304.  
  2305. } catch (e) {
  2306. console.log("Error Hide Repair Times Change: " + e.toString());
  2307. }
  2308. },
  2309.  
  2310. _onHideLootChange: function () {
  2311. try {
  2312. var value = this._hideLootCB.getValue();
  2313.  
  2314. if (value == true)
  2315. localStorage['hideLoot'] = "yes";
  2316. else
  2317. localStorage['hideLoot'] = "no";
  2318.  
  2319. } catch (e) {
  2320. console.log("Error Hide Loot Change: " + e.toString());
  2321. }
  2322. },
  2323.  
  2324. _onSetStatWindowPositionChange: function () {
  2325. try {
  2326. var props = Simulator.StatWindow.getInstance().getLayoutProperties();
  2327. localStorage['statWindowPosLeft'] = props["left"];
  2328. localStorage['statWindowPosTop'] = props["top"];
  2329. } catch (e) {
  2330. console.log("Error Stat Window Position Change: " + e.toString());
  2331. }
  2332. },
  2333.  
  2334. setRTBtn: function (value) {
  2335. if (value == true)
  2336. Simulator.getInstance().unlockRTBtn.show();
  2337. else
  2338. Simulator.getInstance().unlockRTBtn.hide();
  2339. },
  2340.  
  2341. setCmtBtn: function (value) {
  2342. if (value == true)
  2343. Simulator.getInstance().unlockCmtBtn.show();
  2344. else
  2345. Simulator.getInstance().unlockCmtBtn.hide();
  2346. },
  2347.  
  2348. setButtonLoc: function () {
  2349. try {
  2350. var value = this._buttonLocCB.getValue();
  2351. var size = this._buttonSizeCB.getValue();
  2352.  
  2353. if (value == true) //Right
  2354. {
  2355. var pLeft = null;
  2356. if (size == true) //Right Normal
  2357. var pRight = 70;
  2358. else //Right Small
  2359. var pRight = 70;
  2360.  
  2361. Simulator.getInstance().armyBar.add(Simulator.getInstance().simBtn, {left: pLeft, right: pRight, bottom: 119});
  2362. Simulator.getInstance().armyBar.add(Simulator.getInstance().statBtn, {left: pLeft, right: pRight, bottom: 81});
  2363. Simulator.getInstance().armyBar.add(Simulator.getInstance().optionBtn, {left: pLeft, right: pRight, bottom: 43});
  2364. Simulator.getInstance().armyBar.add(Simulator.getInstance().layoutBtn, {left: pLeft, right: pRight, bottom: 5});
  2365. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftUpBtn, {left: pLeft, right: 75, bottom: 113});
  2366. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftDownBtn, {left: pLeft, right: 75, bottom: 73});
  2367. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftLeftBtn, {left: pLeft, right: 95, bottom: 93});
  2368. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftRightBtn, {left: pLeft, right: 55, bottom: 93});
  2369. Simulator.getInstance().playArea.add(Simulator.getInstance().disableAllUnitsBtn, {left: pLeft, right: 6, bottom: 120});
  2370. Simulator.getInstance().playArea.add(Simulator.getInstance().mirrorBtnH, {left: pLeft, right: 6, bottom: 160});
  2371. Simulator.getInstance().playArea.add(Simulator.getInstance().mirrorBtnV, {left: pLeft, right: 46, bottom: 160});
  2372. Simulator.getInstance().playArea.add(Simulator.getInstance().armyUndoBtn, {left: pLeft, right: 6, bottom: 200});
  2373. Simulator.getInstance().playArea.add(Simulator.getInstance().quickSaveBtn, {left: pLeft, right: 6, bottom: 240});
  2374. } else {
  2375. var pRight = null;
  2376. if (size == true) //Left Normal
  2377. var pLeft = 87;
  2378. else
  2379. var pLeft = 87;
  2380.  
  2381. Simulator.getInstance().armyBar.add(Simulator.getInstance().simBtn, {left: pLeft, right: pRight, bottom: 120});
  2382. Simulator.getInstance().armyBar.add(Simulator.getInstance().statBtn, {left: pLeft, right: pRight, bottom: 82});
  2383. Simulator.getInstance().armyBar.add(Simulator.getInstance().optionBtn, {left: pLeft, right: pRight, bottom: 44});
  2384. Simulator.getInstance().armyBar.add(Simulator.getInstance().layoutBtn, {left: pLeft, right: pRight, bottom: 6});
  2385. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftUpBtn, {left: 80, right: pRight, bottom: 113});
  2386. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftDownBtn, {left: 80, right: pRight, bottom: 73});
  2387. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftLeftBtn, {left: 60, right: pRight, bottom: 93});
  2388. Simulator.getInstance().playArea.add(Simulator.getInstance().shiftRightBtn, {left: 100, right: pRight, bottom: 93});
  2389. Simulator.getInstance().playArea.add(Simulator.getInstance().disableAllUnitsBtn, {left: 6, right: pRight, bottom: 120});
  2390. Simulator.getInstance().playArea.add(Simulator.getInstance().mirrorBtnH, {left: 6, right: pRight, bottom: 160});
  2391. Simulator.getInstance().playArea.add(Simulator.getInstance().mirrorBtnV, {left: 46, right: pRight, bottom: 160});
  2392. Simulator.getInstance().playArea.add(Simulator.getInstance().armyUndoBtn, {left: 6, right: pRight, bottom: 200});
  2393. Simulator.getInstance().playArea.add(Simulator.getInstance().quickSaveBtn, {left: 6, right: pRight, bottom: 240});
  2394. }
  2395. } catch (e) {
  2396. console.log("Error Setting Button Location: " + e.toString());
  2397. }
  2398. },
  2399.  
  2400. setButtonSize: function () {
  2401. try {
  2402. var qxApp = qx.core.Init.getApplication();
  2403. value = this._buttonSizeCB.getValue();
  2404.  
  2405. if (value == true) {
  2406. Simulator.getInstance().simBtn.setLabel(qxApp.tr("Simulate"));
  2407. Simulator.getInstance().simBtn.setWidth(60);
  2408.  
  2409. Simulator.getInstance().statBtn.setLabel(qxApp.tr("Stats"));
  2410. Simulator.getInstance().statBtn.setWidth(60);
  2411.  
  2412. Simulator.getInstance().optionBtn.setLabel(qxApp.tr("Options"));
  2413. Simulator.getInstance().optionBtn.setWidth(60);
  2414.  
  2415. Simulator.getInstance().layoutBtn.setLabel(qxApp.tr("Layout"));
  2416. Simulator.getInstance().layoutBtn.setWidth(60);
  2417. } else {
  2418. Simulator.getInstance().simBtn.setLabel(qxApp.tr("S"));
  2419. Simulator.getInstance().simBtn.setWidth(30);
  2420.  
  2421. Simulator.getInstance().statBtn.setLabel(qxApp.tr("I"));
  2422. Simulator.getInstance().statBtn.setWidth(30);
  2423.  
  2424. Simulator.getInstance().optionBtn.setLabel(qxApp.tr("O"));
  2425. Simulator.getInstance().optionBtn.setWidth(30);
  2426.  
  2427. Simulator.getInstance().layoutBtn.setLabel(qxApp.tr("L"));
  2428. Simulator.getInstance().layoutBtn.setWidth(30);
  2429. }
  2430.  
  2431. this.setButtonLoc();
  2432. } catch (e) {
  2433. console.log("Error Setting Button Size: " + e.toString());
  2434. }
  2435. }
  2436. }
  2437. });
  2438. qx.Class.define("Simulator.LayoutWindow", {
  2439. type: "singleton",
  2440. extend: webfrontend.gui.CustomWindow,
  2441.  
  2442. construct: function () {
  2443. var qxApp = qx.core.Init.getApplication();
  2444. this.base(arguments);
  2445. this.setLayout(new qx.ui.layout.VBox());
  2446.  
  2447. this.set({
  2448. width: 200,
  2449. caption: qxApp.tr("Simulator") + " - " + qxApp.tr("Layouts"),
  2450. padding: 2,
  2451. allowMaximize: false,
  2452. showMaximize: false,
  2453. allowMinimize: false,
  2454. showMinimize: false
  2455. });
  2456.  
  2457. var layoutListHeader = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({
  2458. decorator: "pane-light-opaque"
  2459. });
  2460. var layoutListTitle = new qx.ui.basic.Label(qxApp.tr("Formation Saver")).set({alignX: "center", alignY: "top", font: "font_size_14_bold"});
  2461. layoutListHeader.add(layoutListTitle);
  2462. this.add(layoutListHeader);
  2463.  
  2464. this.layoutList = new qx.ui.form.List();
  2465. this.layoutList.set({selectionMode: "one", height: 100, width: 150, margin: 5});
  2466. this.add(this.layoutList);
  2467.  
  2468. var listButtonBox = new qx.ui.container.Composite();
  2469. var listButtonLayout = new qx.ui.layout.HBox(5, "center");
  2470. listButtonBox.setLayout(listButtonLayout);
  2471. var loadButton = new qx.ui.form.Button(qxApp.tr("Load"));
  2472. var deleteButton = new qx.ui.form.Button(qxApp.tr("Delete"));
  2473. loadButton.set({height: 15, width: 70, alignX: "center"});
  2474. loadButton.addListener("click", this.loadLayout, this);
  2475. deleteButton.set({height: 15, width: 70, alignX: "center"});
  2476. deleteButton.addListener("click", this.deleteLayout, this);
  2477. listButtonBox.add(loadButton);
  2478. listButtonBox.add(deleteButton);
  2479. this.add(listButtonBox);
  2480.  
  2481. var saveLayoutBox = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({spacing: 10})).set({marginTop: 20, marginLeft: 5});
  2482. this.layoutTextBox = new qx.ui.form.TextField("").set({width: 75, maxLength: 15});
  2483. var saveButton = new qx.ui.form.Button(qxApp.tr("Save"));
  2484. saveButton.set({height: 10, width: 70, alignX: "center"});
  2485. saveButton.addListener("click", this.saveNewLayout, this);
  2486. saveLayoutBox.add(this.layoutTextBox);
  2487. saveLayoutBox.add(saveButton);
  2488. this.add(saveLayoutBox);
  2489.  
  2490. var checkBox = new qx.ui.container.Composite(new qx.ui.layout.HBox().set({spacing: 10})).set({marginTop: 10, marginLeft: 5});
  2491. this.persistentCheck = new qx.ui.form.CheckBox(qxApp.tr("Make Persistent"));
  2492. this.persistentCheck.setTextColor("white");
  2493. this.persistentCheck.setFont("bold");
  2494. this.persistentCheck.setToolTipText(qxApp.tr("If checked, formation will be saved and can be used by this city in any other city."));
  2495. checkBox.add(this.persistentCheck);
  2496. this.add(checkBox);
  2497.  
  2498. var clearAllLayoutsBox = new qx.ui.container.Composite(new qx.ui.layout.VBox()).set({alignX: "center", marginTop: 5, marginLeft: 5, allowGrowX: false});
  2499. var clearAllLayoutsBtn = new qx.ui.form.Button(qxApp.tr("Clear All")).set({alignX: "center", width: 70});
  2500. clearAllLayoutsBtn.addListener("click", this.clearAllLayouts, this);
  2501. clearAllLayoutsBox.add(clearAllLayoutsBtn);
  2502. this.add(clearAllLayoutsBox);
  2503.  
  2504. this.layoutsArray = [];
  2505. phe.cnc.Util.attachNetEvent(ClientLib.Vis.VisMain.GetInstance(), "ViewModeChange", ClientLib.Vis.ViewModeChange, this, function () { this.close(); });
  2506. },
  2507.  
  2508. destruct: function () {},
  2509.  
  2510. members: {
  2511. layoutList: null,
  2512. layoutTextBox: null,
  2513. layoutsArray: null,
  2514. persistentCheck: null,
  2515.  
  2516. saveNewLayout: function (isQS) {
  2517. try {
  2518. console.log("Saving Layout");
  2519.  
  2520. if ((isQS !== undefined && isQS == true) || this.layoutTextBox.getValue() == "") {
  2521. var date = new Date();
  2522. var day = date.getDate();
  2523. var month = date.getMonth() + 1;
  2524. var hour = (date.getHours() < 10) ? "0" + date.getHours() : date.getHours();
  2525. var minute = (date.getMinutes() < 10) ? "0" + date.getMinutes() : date.getMinutes();
  2526. var second = (date.getSeconds() < 10) ? "0" + date.getSeconds() : date.getSeconds();
  2527. var label = month + "/" + day + "@" + hour + ":" + minute + ":" + second;
  2528. } else {
  2529. var label = this.layoutTextBox.getValue();
  2530. }
  2531.  
  2532. var cityID = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCityId();
  2533. var ownCityID = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCityId();
  2534. var model = ownCityID + "." + cityID + "." + label;
  2535.  
  2536. var children = this.layoutList.getChildren();
  2537. //Check for same layout name if so do NOT save
  2538. for (var item = 0; item < children.length; item++) {
  2539. thisItem = children[item].getModel();
  2540. if (thisItem == model) {
  2541. alert("Save Failed: Duplicate Name");
  2542. return;
  2543. }
  2544. }
  2545. var units = Simulator.getInstance().getCityPreArmyUnits().get_ArmyUnits().l;
  2546. units = this.prepareLayout(units);
  2547.  
  2548. var layoutInformation = {};
  2549. if (this.persistentCheck.getValue() == true) {
  2550. layoutInformation = {
  2551. id: model,
  2552. label: label,
  2553. formation: units,
  2554. pers: "yes"
  2555. };
  2556. } else {
  2557. layoutInformation = {
  2558. id: model,
  2559. label: label,
  2560. formation: units,
  2561. pers: "no"
  2562. };
  2563. }
  2564. this.layoutsArray.push(layoutInformation);
  2565. this.layoutList.add(new qx.ui.form.ListItem(layoutInformation.label, null, layoutInformation.id));
  2566. this.layoutTextBox.setValue("");
  2567. Simulator.getInstance().quickSaveBtn.setLabel("✔");
  2568. setTimeout(function () { Simulator.getInstance().quickSaveBtn.setLabel("QS"); }, 2000);
  2569. this.updateStorage();
  2570. } catch (e) {
  2571. console.log("Error Saving Layout");
  2572. console.log(e);
  2573. }
  2574. },
  2575.  
  2576. loadLayout: function () {
  2577. try {
  2578. console.log("Loading Layout");
  2579. var ownCityID = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCityId();
  2580.  
  2581. var layout = this.layoutList.getSelection()[0].getModel();
  2582. for (var item in this.layoutsArray) {
  2583. var thisLayout = this.layoutsArray[item].id;
  2584.  
  2585. if (thisLayout == layout) {
  2586. Simulator.getInstance().restoreFormation(this.layoutsArray[item].formation);
  2587. break;
  2588. }
  2589. }
  2590. } catch (e) {
  2591. console.log("Error Loading Layout");
  2592. console.log(e);
  2593. }
  2594. },
  2595.  
  2596. deleteLayout: function () {
  2597. try {
  2598. console.log("Deleting Layout");
  2599. //Remove from our array too
  2600. var rUSure = confirm('Are you sure you want to delete this layout?');
  2601. if (!rUSure) {
  2602. return;
  2603. }
  2604. for (var item in this.layoutsArray) {
  2605. if (this.layoutsArray[item].id == this.layoutList.getSelection()[0].getModel()) {
  2606. var isRemoved = this.layoutsArray.splice(item, 1);
  2607. this.updateStorage();
  2608. }
  2609. }
  2610.  
  2611. //The update will remove all and repopulate so no need to delete individual ones.
  2612. this.updateLayoutList();
  2613. } catch (e) {
  2614. console.log("Error Deleting Layout");
  2615. console.log(e);
  2616. }
  2617. },
  2618.  
  2619. updateStorage: function () {
  2620. try {
  2621. console.log("Updating Storage");
  2622. localStorage['savedFormations'] = JSON.stringify(this.layoutsArray);
  2623. } catch (e) {
  2624. console.log("Error updating localStorage");
  2625. console.log(e);
  2626. }
  2627. },
  2628.  
  2629. updateLayoutList: function () {
  2630. try {
  2631. console.log("Updating Layout List");
  2632. var savedLayouts = localStorage['savedFormations'];
  2633. if (savedLayouts !== undefined) {
  2634. this.layoutsArray = JSON.parse(savedLayouts);
  2635. }
  2636. this.layoutList.removeAll(); //Clear List
  2637. var cityID = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCityId();
  2638. var ownCityID = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCityId();
  2639. var model = ownCityID + "." + cityID;
  2640.  
  2641. for (var item in this.layoutsArray) {
  2642. var itemLabel = this.layoutsArray[item].label;
  2643. var itemModel = model + "." + itemLabel;
  2644. var pers = this.layoutsArray[item].pers;
  2645. var match = this.layoutsArray[item].id.match(ownCityID.toString());
  2646.  
  2647. if (itemModel == this.layoutsArray[item].id || ((pers !== undefined && pers == "yes") && match != null)) //Match!
  2648. {
  2649. this.layoutList.add(new qx.ui.form.ListItem(itemLabel, null, this.layoutsArray[item].id));
  2650. }
  2651. }
  2652. } catch (e) {
  2653. console.log("Error Updating Layout List");
  2654. console.log(e);
  2655. }
  2656. },
  2657.  
  2658. //Function from C&C Tiberium Alliances Combat Simulator script. Works well and does exactly what I need!
  2659. //For authors see: http://userscripts.org/scripts/show/145717
  2660. prepareLayout: function (units) {
  2661. try {
  2662. console.log("Preparing Layout for Saving");
  2663. saved_units = [];
  2664. for (var i = 0; i < units.length; i++) {
  2665. var unit = units[i];
  2666. var armyUnit = {};
  2667. armyUnit.x = unit.get_CoordX();
  2668. armyUnit.y = unit.get_CoordY();
  2669. armyUnit.id = unit.get_Id();
  2670. armyUnit.enabled = unit.get_Enabled();
  2671. saved_units.push(armyUnit);
  2672. }
  2673. return saved_units;
  2674. } catch (e) {
  2675. console.log("Error Preparing Unit Layout");
  2676. console.log(e);
  2677. }
  2678. },
  2679.  
  2680. clearAllLayouts: function () {
  2681. try {
  2682. console.log("Clearing All Layouts");
  2683. var rUSure = confirm("Clicking OK will delete all of your saved layouts from every base!");
  2684.  
  2685. if (rUSure) {
  2686. localStorage.removeItem('savedFormations');
  2687. this.layoutsArray = [];
  2688. alert("All saved layouts have been deleted.");
  2689.  
  2690. this.updateLayoutList();
  2691. } else {
  2692. alert("No layouts were deleted.");
  2693. }
  2694. } catch (e) {
  2695. console.log("Error Clearing All Layouts");
  2696. console.log(e);
  2697. }
  2698. }
  2699. }
  2700. });
  2701. }
  2702. function translation() {
  2703. var localeManager = qx.locale.Manager.getInstance();
  2704.  
  2705. // Default language is english (en)
  2706. // Available Languages are: ar,ce,cs,da,de,en,es,fi,fr,hu,id,it,nb,nl,pl,pt,ro,ru,sk,sv,ta,tr,uk
  2707. // You can send me translations so i can include them in the Script.
  2708.  
  2709. // German (incomplete)
  2710. localeManager.addTranslation("de", {
  2711. "Simulator": "Simulator",
  2712. "S": "S",
  2713. "Simulate": "Simulate",
  2714. "Opens Simulation Screen.": "Startet die Simulation",
  2715. "I": "I",
  2716. "Stats": "Statistik",
  2717. "Opens Simulator Stats Window.": "Öffnet das Statistikfenster.",
  2718. "O": "O",
  2719. "Options": "Options",
  2720. "Opens Simulator Options.": "Öffnet das Optionsfenster.",
  2721. "L": "L",
  2722. "Layout": "Layout",
  2723. "Save/Load/Delete Unit Formations for current city.": "Speichern/Laden/Löschen von Formationen für den aktuellen Gegner",
  2724. "Unlock": "Unlock",
  2725. "Unlock Combat Button.": "Entsperrt die Angriffsschaltfläche.",
  2726. "Unlock Repair Button.": "Entsperrt die Reparaturschaltfläche.",
  2727. "Shifts units one space up.": "Verschiebt Einheiten einen Platz nach oben.",
  2728. "Shifts units one space down.": "Verschiebt die Einheiten einen Platz nach unten.",
  2729. "Shifts units one space left.": "Verschiebt die Einheiten einen Platz nach links.",
  2730. "Shifts units one space right.": "Verschiebt die Einheiten einen Platz nach rechts.",
  2731. "Mirrors units horizontally.": "Spiegelt die Einheiten horizontal.",
  2732. "Mirrors units vertically.": "Spiegelt die Einheiten vertikal.",
  2733. "Enables/Disables all units.": "Alle Einheiten de-/aktivieren.",
  2734. "Undo's formation to previous saved formation.<br>Save formations by hitting<br>the Update or Simulate button.": "Setzt die Formation auf die vorher gespeicherte zurück.<br>Formationen werden gespeichert,<br>wenn man auf Simulieren oder Aktualisieren drückt.",
  2735. "QS": "QS",
  2736. "Saves the current layout<br>without having to open<br>the Formation Saver window.<br>Does not make persistent.": "Speichert die aktuelle Formation,<br>ohne das das Formationsfenster<br>geöffnet werden muss.",
  2737. "Back": "zurück",
  2738. "Return to Combat Setup.": "Zurück zum Angriffsbildschirm.",
  2739. "Updates Simulation Stats.": "Aktualisiert die Statistik.",
  2740. "Buttons:": "Schaltflächen:",
  2741. "Right Side": "Rechte Seite",
  2742. "Normal Size": "Normale Größe",
  2743. "Disable Repair Button": "Sperre Reparatur-Schaltfläche",
  2744. "Disable Combat Button": "Sperre Angriffs-Schaltfläche",
  2745. "Disable Army Unit Tooltip": "Deaktiviere Einheiten Tooltips",
  2746. "Auto Start Simulation": "Simulation automatisch starten",
  2747. "Stats Window:": "Statistik Fenster:",
  2748. "Auto Open": "Automatisch öffnen",
  2749. "Simulations shown": "Anzuzeigende Simulationen",
  2750. "Hide Sections (on Startup):": "Verstecke Bereich (beim starten):",
  2751. "Health": "Health",
  2752. "Repair": "Repair",
  2753. "Loot": "Loot",
  2754. "Set Stat Window Position:": "Setze die Statistikfenster Position:",
  2755. "Set": "setzen",
  2756. "Layouts": "Layouts",
  2757. "Formation Saver": "Formationen speichern",
  2758. "Load": "Laden",
  2759. "Delete": "Löschen",
  2760. "Save": "Speichern",
  2761. "Make Persistent": "Dauerhaft",
  2762. "If checked, formation will be saved and can be used by this city in any other city.": "Wenn angewählt kann die Formation für andere Gegner verwendet werden.",
  2763. "Clear All": "Lösche alle"
  2764. });
  2765. }
  2766. function waitForGame() {
  2767. try {
  2768. if (typeof qx !== "undefined" && typeof qx.core !== "undefined" && typeof qx.core.Init !== "undefined" && typeof ClientLib !== "undefined" && typeof phe !== "undefined") {
  2769. var app = qx.core.Init.getApplication();
  2770. if (app.initDone == true) {
  2771. try {
  2772. console.log("WarChiefs - Tiberium Alliances Combat Simulator: Loading");
  2773. translation();
  2774. createClasses();
  2775. Simulator.getInstance();
  2776. Simulator.StatWindow.getInstance();
  2777. Simulator.OptionWindow.getInstance();
  2778. Simulator.LayoutWindow.getInstance();
  2779. console.log("WarChiefs - Tiberium Alliances Combat Simulator: Loaded");
  2780. } catch (e) {
  2781. console.log("WarChiefs - Tiberium Alliances Combat Simulator: initialization error:");
  2782. console.log(e);
  2783. }
  2784. } else
  2785. window.setTimeout(waitForGame, 1000);
  2786. } else {
  2787. window.setTimeout(waitForGame, 1000);
  2788. }
  2789. } catch (e) {
  2790. console.log(e);
  2791. }
  2792. }
  2793. window.setTimeout(waitForGame, 1000);
  2794. };
  2795. var script = document.createElement("script");
  2796. var txt = injectFunction.toString();
  2797. script.innerHTML = "(" + txt + ")();";
  2798. script.type = "text/javascript";
  2799. document.getElementsByTagName("head")[0].appendChild(script);
  2800. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址