diff --git a/src/app/components/Modification.jsx b/src/app/components/Modification.jsx
index 1e6dae44..b2979bb7 100644
--- a/src/app/components/Modification.jsx
+++ b/src/app/components/Modification.jsx
@@ -72,6 +72,11 @@ export default class Modification extends TranslatedComponent {
return null;
}
+ let inputClassNames = {
+ 'cb': true,
+ 'greyed-out': !this.props.highlight
+ };
+
return (
{this.props.editable ?
- :
}
diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx
index 8f0b8dcc..b68bf004 100644
--- a/src/app/components/ModificationsMenu.jsx
+++ b/src/app/components/ModificationsMenu.jsx
@@ -214,11 +214,11 @@ export default class ModificationsMenu extends TranslatedComponent {
for (const modName of Modifications.modules[m.grp].modifications) {
if (!Modifications.modifications[modName].hidden) {
const key = modName + (m.getModValue(modName) / 100 || 0);
- const editable = modName !== 'fallofffromrange' &&
- m.blueprint.grades[m.blueprint.grade].features[modName];
+ const editable = modName !== 'fallofffromrange';
+ const highlight = m.blueprint.grades[m.blueprint.grade].features[modName];
this.lastNeId = modName;
- (editable ? modifiableModifications : modifications).push(
-
diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx
index d292449b..b74e56d5 100644
--- a/src/app/pages/OutfittingPage.jsx
+++ b/src/app/pages/OutfittingPage.jsx
@@ -198,12 +198,12 @@ export default class OutfittingPage extends Page {
if (parts.length >= 5) {
// We have control information in the code
const control = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[4])).split('/');
- sys = parseFloat(control[0]);
- eng = parseFloat(control[1]);
- wep = parseFloat(control[2]);
+ sys = parseFloat(control[0]) || sys;
+ eng = parseFloat(control[1]) || eng;
+ wep = parseFloat(control[2]) || wep;
boost = control[3] == 1 ? true : false;
- fuel = parseFloat(control[4]);
- cargo = parseInt(control[5]);
+ fuel = parseFloat(control[4]) || fuel;
+ cargo = parseInt(control[5]) || cargo;
if (control[6]) {
const shipId = control[6];
opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots);
@@ -217,9 +217,9 @@ export default class OutfittingPage extends Page {
const opponentParts = opponentCode.split('.');
if (opponentParts.length >= 5) {
const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/');
- opponentSys = parseFloat(opponentControl[0]);
- opponentEng = parseFloat(opponentControl[1]);
- opponentWep = parseFloat(opponentControl[2]);
+ opponentSys = parseFloat(opponentControl[0]) || opponentSys;
+ opponentEng = parseFloat(opponentControl[1]) || opponentEng;
+ opponentWep = parseFloat(opponentControl[2]) || opponentWep;
}
}
} else {
@@ -227,7 +227,7 @@ export default class OutfittingPage extends Page {
opponent.buildWith(Ships[shipId].defaults);
}
}
- engagementRange = parseInt(control[8]);
+ engagementRange = parseInt(control[8]) || engagementRange;
// Multi-crew pips were introduced later on so assign default values
// because those values might not be present.
diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js
index 4a19311c..8c0a5a9f 100755
--- a/src/app/shipyard/Module.js
+++ b/src/app/shipyard/Module.js
@@ -81,8 +81,8 @@ export default class Module {
// the amount of base resistance the hrp has.
if (!isNaN(result) && this.grp === 'hr' &&
(name === 'kinres' || name === 'thermres' || name === 'explres')) {
- let baseRes = this[name];
- result = result * (1 - baseRes);
+ let baseRes = this[name];
+ result = result * (1 - baseRes);
}
// Sanitise the resultant value to 4dp equivalent
@@ -180,7 +180,7 @@ export default class Module {
modValue = value - baseValue;
if (this.grp === 'hr' &&
(name === 'kinres' || name === 'thermres' || name === 'explres')) {
- modValue = modValue / (1 - baseValue);
+ modValue = modValue / (1 - baseValue);
}
} else if (name === 'shieldboost' || name === 'hullboost') {
modValue = (1 + value) / (1 + baseValue) - 1;
@@ -192,7 +192,7 @@ export default class Module {
modValue = modValue * 10000;
} else if (modification.type === 'numeric' && name !== 'burst' &&
name !== 'burstrof') {
- modValue = modValue * 100;
+ modValue = modValue * 100;
}
this.setModValue(name, modValue, valueIsWithSpecial);
@@ -242,38 +242,38 @@ export default class Module {
const modification = Modifications.modifications[name];
let result = this[name];
- if (modification) {
- // We store percentages as decimals, so to get them back we need to divide by 10000. Otherwise
- // we divide by 100. Both ways we end up with a value with two decimal places
- let modValue;
- if (modification.type === 'percentage') {
- modValue = this.getModValue(name) / 10000;
- } else if (modification.type === 'numeric') {
- modValue = this.getModValue(name) / 100;
- } else {
- modValue = this.getModValue(name);
+ if (modification) {
+ // We store percentages as decimals, so to get them back we need to divide by 10000. Otherwise
+ // we divide by 100. Both ways we end up with a value with two decimal places
+ let modValue;
+ if (modification.type === 'percentage') {
+ modValue = this.getModValue(name) / 10000;
+ } else if (modification.type === 'numeric') {
+ modValue = this.getModValue(name) / 100;
+ } else {
+ modValue = this.getModValue(name);
+ }
+ if (modValue) {
+ if (!result && modification.method === 'additive') {
+ // If the modification is additive and no value is given by default we
+ // start at zero
+ result = 0;
}
- if (modValue) {
- if (!result && modification.method === 'additive') {
- // If the modification is additive and no value is given by default we
- // start at zero
- result = 0;
- }
- if (result !== undefined) {
- if (modification.method === 'additive') {
- result = result + modValue;
- } else if (modification.method === 'overwrite') {
- result = modValue;
- } else if (name === 'shieldboost' || name === 'hullboost') {
- result = (1 + result) * (1 + modValue) - 1;
- } else {
- result = result * (1 + modValue);
- }
- } else if (name === 'burst' || name === 'burstrof') {
- // Burst and burst rate of fire are special, as it can not exist but
- // have a modification
- result = modValue / 100;
+ if (result !== undefined) {
+ if (modification.method === 'additive') {
+ result = result + modValue;
+ } else if (modification.method === 'overwrite') {
+ result = modValue;
+ } else if (name === 'shieldboost' || name === 'hullboost') {
+ result = (1 + result) * (1 + modValue) - 1;
+ } else {
+ result = result * (1 + modValue);
+ }
+ } else if (name === 'burstrof') {
+ // Burst and burst rate of fire are special, as it can not exist but
+ // have a modification
+ result = modValue / 100;
}
}
}
diff --git a/src/app/shipyard/Ship.js b/src/app/shipyard/Ship.js
index 4e47f060..4c5313ff 100755
--- a/src/app/shipyard/Ship.js
+++ b/src/app/shipyard/Ship.js
@@ -1187,28 +1187,28 @@ export default class Ship {
// handle unladen mass
unladenMass += chain(slots)
.map(slot => slot.m ? slot.m.get('mass') : null)
- .filter()
+ .map(mass => mass || 0)
.reduce((sum, mass) => sum + mass)
.value();
// handle fuel capacity
fuelCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('fuel') : null)
- .filter()
+ .map(fuel => fuel || 0)
.reduce((sum, fuel) => sum + fuel)
.value();
// handle cargo capacity
cargoCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('cargo') : null)
- .filter()
+ .map(cargo => cargo || 0)
.reduce((sum, cargo) => sum + cargo)
.value();
// handle passenger capacity
passengerCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('passengers') : null)
- .filter()
+ .map(passengers => passengers || 0)
.reduce((sum, passengers) => sum + passengers)
.value();
diff --git a/src/app/utils/JournalUtils.js b/src/app/utils/JournalUtils.js
index b7078c87..1cba2565 100644
--- a/src/app/utils/JournalUtils.js
+++ b/src/app/utils/JournalUtils.js
@@ -147,80 +147,77 @@ export function shipFromLoadoutJSON(json) {
break;
default:
}
- for (const module of json.Modules) {
- if (module.Slot.toLowerCase().search(/hardpoint/) !== -1) {
- // Add hardpoints
- let hardpoint;
- let hardpointClassNum = -1;
- let hardpointSlotNum = -1;
- let hardpointArrayNum = 0;
- for (let i in shipTemplate.slots.hardpoints) {
- if (shipTemplate.slots.hardpoints[i] === hardpointClassNum) {
- // Another slot of the same class
- hardpointSlotNum++;
- } else {
- // The first slot of a new class
- hardpointClassNum = shipTemplate.slots.hardpoints[i];
- hardpointSlotNum = 1;
- }
-
- // Now that we know what we're looking for, find it
- const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum;
- const hardpointSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === hardpointName.toLowerCase());
- if (!hardpointSlot) {
- // This can happen with old imports that don't contain new hardpoints
- } else if (!hardpointSlot) {
- // No module
- } else {
- hardpoint = _moduleFromFdName(hardpointSlot.Item);
- ship.use(ship.hardpoints[hardpointArrayNum], hardpoint, true);
- ship.hardpoints[hardpointArrayNum].enabled = hardpointSlot.On;
- ship.hardpoints[hardpointArrayNum].priority = hardpointSlot.Priority;
- modsToAdd.push({ coriolisMod: hardpoint, json: hardpointSlot });
- }
- hardpointArrayNum++;
+ if (module.Slot.toLowerCase().search(/hardpoint/) !== -1) {
+ // Add hardpoints
+ let hardpoint;
+ let hardpointClassNum = -1;
+ let hardpointSlotNum = -1;
+ let hardpointArrayNum = 0;
+ for (let i in shipTemplate.slots.hardpoints) {
+ if (shipTemplate.slots.hardpoints[i] === hardpointClassNum) {
+ // Another slot of the same class
+ hardpointSlotNum++;
+ } else {
+ // The first slot of a new class
+ hardpointClassNum = shipTemplate.slots.hardpoints[i];
+ hardpointSlotNum = 1;
}
- }
- if (module.Slot.toLowerCase().search(/slot\d/) !== -1) {
- let internalSlotNum = 1;
- let militarySlotNum = 1;
- for (let i in shipTemplate.slots.internal) {
- if (!shipTemplate.slots.internal.hasOwnProperty(i)) {
- continue;
- }
- const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'military' : false;
- // The internal slot might be a standard or a military slot. Military slots have a different naming system
- let internalSlot = null;
- if (isMilitary) {
- const internalName = 'Military0' + militarySlotNum;
- internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase());
- militarySlotNum++;
- } else {
- // Slot numbers are not contiguous so handle skips.
- while (internalSlot === null && internalSlotNum < 99) {
- // Slot sizes have no relationship to the actual size, either, so check all possibilities
- for (let slotsize = 0; slotsize < 9; slotsize++) {
- const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '0') + internalSlotNum + '_Size' + slotsize;
- if (json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase())) {
- internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase());
- break;
- }
+ // Now that we know what we're looking for, find it
+ const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum;
+ const hardpointSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === hardpointName.toLowerCase());
+ if (!hardpointSlot) {
+ // This can happen with old imports that don't contain new hardpoints
+ } else if (!hardpointSlot) {
+ // No module
+ } else {
+ hardpoint = _moduleFromFdName(hardpointSlot.Item);
+ ship.use(ship.hardpoints[hardpointArrayNum], hardpoint, true);
+ ship.hardpoints[hardpointArrayNum].enabled = hardpointSlot.On;
+ ship.hardpoints[hardpointArrayNum].priority = hardpointSlot.Priority;
+ modsToAdd.push({ coriolisMod: hardpoint, json: hardpointSlot });
+ }
+ hardpointArrayNum++;
+ }
+ }
+ if (module.Slot.toLowerCase().search(/slot\d/) !== -1) {
+ let internalSlotNum = 0;
+ let militarySlotNum = 1;
+ for (let i in shipTemplate.slots.internal) {
+ if (!shipTemplate.slots.internal.hasOwnProperty(i)) {
+ continue;
+ }
+ const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name == 'military' : false;
+
+ // The internal slot might be a standard or a military slot. Military slots have a different naming system
+ let internalSlot = null;
+ if (isMilitary) {
+ const internalName = 'Military0' + militarySlotNum;
+ internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase());
+ militarySlotNum++;
+ } else {
+ // Slot numbers are not contiguous so handle skips.
+ for (; internalSlot === null && internalSlotNum < 99; internalSlotNum++) {
+ // Slot sizes have no relationship to the actual size, either, so check all possibilities
+ for (let slotsize = 0; slotsize < 9; slotsize++) {
+ const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + slotsize;
+ if (json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase())) {
+ internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase());
+ break;
}
- internalSlotNum++;
}
}
+ }
- if (!internalSlot) {
- // This can happen with old imports that don't contain new slots
- } else {
- const internalJson = internalSlot;
- const internal = _moduleFromFdName(internalJson.Item);
- ship.use(ship.internal[i], internal, true);
- ship.internal[i].enabled = internalJson.On === true;
- ship.internal[i].priority = internalJson.Priority;
- modsToAdd.push({ coriolisMod: internal, json: internalSlot });
- }
+ if (!internalSlot) {
+ // This can happen with old imports that don't contain new slots
+ } else {
+ const internalJson = internalSlot;
+ const internal = _moduleFromFdName(internalJson.Item);
+ ship.use(ship.internal[i], internal, true);
+ ship.internal[i].enabled = internalJson.On === true;
+ ship.internal[i].priority = internalJson.Priority;
+ modsToAdd.push({ coriolisMod: internal, json: internalSlot });
}
}
}
diff --git a/src/less/slot.less b/src/less/slot.less
index e6c962f9..c6d79e6d 100755
--- a/src/less/slot.less
+++ b/src/less/slot.less
@@ -74,7 +74,7 @@
border-color:#fff;
}
- input:disabled {
+ input.greyed-out {
border-color: #888;
color: #888;
}