diff --git a/FreeSpacer/FreeSpacer.css b/FreeSpacer/FreeSpacer.css index 54e79643f2..faaf2163e7 100644 --- a/FreeSpacer/FreeSpacer.css +++ b/FreeSpacer/FreeSpacer.css @@ -955,6 +955,22 @@ div.sheet-salvoAttr border: none; } +/*Change the colour of the Charge text*/ +.sheet-colorChanger[value="Uncharged"] + .sheet-salvoAttr, +.sheet-colorChanger[value="Expended"] + .sheet-salvoAttr +{ + color: #6cb3e6; +} +.sheet-colorChanger[value="Overcharged"] + .sheet-salvoAttr, +.sheet-colorChanger[value="NF 2 Charge"] + .sheet-salvoAttr +{ + color: #d87d29; +} +.sheet-colorChanger[value="Insufficient Charge"] + .sheet-salvoAttr +{ + color: red; +} + input[type=number].sheet-salvoThreatRating { margin: 2px 5px 0px 15px; @@ -6570,6 +6586,13 @@ input[type="number"].sheet-resourceBox height: 60px; width: 130px; font-size: 18px; + border: none; +} + +/*Change Colour of Total Cargo when overloaded*/ +.sheet-colorChanger[value="1"] + .sheet-resourceBox +{ + color: red; } .sheet-resourceBoxPlace diff --git a/FreeSpacer/FreeSpacer.html b/FreeSpacer/FreeSpacer.html index 98e2eb464c..550c379775 100644 --- a/FreeSpacer/FreeSpacer.html +++ b/FreeSpacer/FreeSpacer.html @@ -222,7 +222,8 @@
- + +
@@ -1874,7 +1875,7 @@
Quarters
Sleeps six
Cargo Hold
-
Two-story cargo space;tonnes
+
Two-story cargo space;tonnes
@@ -3972,7 +3973,8 @@
Total
-
+ +
tonnes
@@ -10001,6 +10003,7 @@ }) }); + /*Sheet Totals*/ //Reactor Overcharge control on("change:reactorcharge change:reactorovercharge change:shipreactorcharge change:shipReactorovercharge change:tugreactorcharge change:tugreactorovercharge", (event) => { @@ -10059,7 +10062,7 @@ }); //Cargo Total - on("change:repeating_shipcargo remove:repeating_shipcargo change:supply change:complexmaterials", (event) => + on("change:repeating_shipcargo remove:repeating_shipcargo change:supply change:complexmaterials change:cargotonnage", (event) => { var repeatingAttributes = [ /*Array of objects with the attributes in each repeating section that need to be gotten with getAttrs, used in getID() @@ -10109,20 +10112,36 @@ let id = attributesToGet[0].id[i]; finalAttributeList = [...finalAttributeList, "repeating_" + attributesToGet[0].section + "_" + id + "_shipCargoTonnage"]; } - finalAttributeList = [...finalAttributeList, "supply", "complexMaterials"]; + finalAttributeList = [...finalAttributeList, "supply", "complexMaterials","CargoTonnage"]; getAttrs(finalAttributeList, (attributeValues) => { - console.log(attributeValues); + const setObj = {}; + + //Get Max Cargo and remove it from the array before totaling + let maxCargo = parseInt(attributeValues.CargoTonnage)||0; + attributeValues.CargoTonnage = 0; + + //Total All Cargo let total = 0; for (var i = 0; i < finalAttributeList.length; i++) { let index = finalAttributeList[i]; total += parseInt(attributeValues[index]) || 0; }; + setObj.totalResource = total; + if (total > maxCargo) + { + setObj.totalResourceOverload = 1; + } + else + { + setObj.totalResourceOverload = 0; + } - console.log(total); - setAttrs({ "totalResource": total }); + console.log(total, maxCargo); + + setAttrs(setObj); }) };