Merge pull request #400 from EDCD/feature/fixes

Various fixes
This commit is contained in:
William
2018-09-30 06:21:06 +10:00
committed by GitHub
7 changed files with 124 additions and 122 deletions

View File

@@ -72,6 +72,11 @@ export default class Modification extends TranslatedComponent {
return null; return null;
} }
let inputClassNames = {
'cb': true,
'greyed-out': !this.props.highlight
};
return ( return (
<div onBlur={this._updateFinished.bind(this)} key={name} <div onBlur={this._updateFinished.bind(this)} key={name}
className={cn('cb', 'modification-container')} className={cn('cb', 'modification-container')}
@@ -84,12 +89,12 @@ export default class Modification extends TranslatedComponent {
<td className={'input-container'}> <td className={'input-container'}>
<span> <span>
{this.props.editable ? {this.props.editable ?
<NumberEditor className={'cb'} value={this.state.value} <NumberEditor className={cn(inputClassNames)} value={this.state.value}
decimals={2} style={{ textAlign: 'right' }} step={0.01} decimals={2} style={{ textAlign: 'right' }} step={0.01}
stepModifier={1} onKeyDown={ this.props.onKeyDown } stepModifier={1} onKeyDown={ this.props.onKeyDown }
onValueChange={this._updateValue.bind(this)} /> : onValueChange={this._updateValue.bind(this)} /> :
<input type="text" value={formats.f2(this.state.value)} <input type="text" value={formats.f2(this.state.value)}
disabled className={'number-editor'} disabled className={cn('number-editor', 'greyed-out')}
style={{ textAlign: 'right', cursor: 'inherit' }}/> style={{ textAlign: 'right', cursor: 'inherit' }}/>
} }
<span className={'unit-container'}> <span className={'unit-container'}>

View File

@@ -214,11 +214,11 @@ export default class ModificationsMenu extends TranslatedComponent {
for (const modName of Modifications.modules[m.grp].modifications) { for (const modName of Modifications.modules[m.grp].modifications) {
if (!Modifications.modifications[modName].hidden) { if (!Modifications.modifications[modName].hidden) {
const key = modName + (m.getModValue(modName) / 100 || 0); const key = modName + (m.getModValue(modName) / 100 || 0);
const editable = modName !== 'fallofffromrange' && const editable = modName !== 'fallofffromrange';
m.blueprint.grades[m.blueprint.grade].features[modName]; const highlight = m.blueprint.grades[m.blueprint.grade].features[modName];
this.lastNeId = modName; this.lastNeId = modName;
(editable ? modifiableModifications : modifications).push( (editable && highlight ? modifiableModifications : modifications).push(
<Modification key={ key } ship={ ship } m={ m } <Modification key={ key } ship={ ship } m={ m } highlight={highlight}
value={m.getPretty(modName) || 0} modItems={this.modItems} value={m.getPretty(modName) || 0} modItems={this.modItems}
onChange={onChange} onKeyDown={this._keyDown} name={modName} onChange={onChange} onKeyDown={this._keyDown} name={modName}
editable={editable} handleModChange = {this._handleModChange} /> editable={editable} handleModChange = {this._handleModChange} />

View File

@@ -198,12 +198,12 @@ export default class OutfittingPage extends Page {
if (parts.length >= 5) { if (parts.length >= 5) {
// We have control information in the code // We have control information in the code
const control = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[4])).split('/'); const control = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[4])).split('/');
sys = parseFloat(control[0]); sys = parseFloat(control[0]) || sys;
eng = parseFloat(control[1]); eng = parseFloat(control[1]) || eng;
wep = parseFloat(control[2]); wep = parseFloat(control[2]) || wep;
boost = control[3] == 1 ? true : false; boost = control[3] == 1 ? true : false;
fuel = parseFloat(control[4]); fuel = parseFloat(control[4]) || fuel;
cargo = parseInt(control[5]); cargo = parseInt(control[5]) || cargo;
if (control[6]) { if (control[6]) {
const shipId = control[6]; const shipId = control[6];
opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots); opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots);
@@ -217,9 +217,9 @@ export default class OutfittingPage extends Page {
const opponentParts = opponentCode.split('.'); const opponentParts = opponentCode.split('.');
if (opponentParts.length >= 5) { if (opponentParts.length >= 5) {
const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/'); const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/');
opponentSys = parseFloat(opponentControl[0]); opponentSys = parseFloat(opponentControl[0]) || opponentSys;
opponentEng = parseFloat(opponentControl[1]); opponentEng = parseFloat(opponentControl[1]) || opponentEng;
opponentWep = parseFloat(opponentControl[2]); opponentWep = parseFloat(opponentControl[2]) || opponentWep;
} }
} }
} else { } else {
@@ -227,7 +227,7 @@ export default class OutfittingPage extends Page {
opponent.buildWith(Ships[shipId].defaults); 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 // Multi-crew pips were introduced later on so assign default values
// because those values might not be present. // because those values might not be present.

View File

@@ -270,7 +270,7 @@ export default class Module {
} else { } else {
result = result * (1 + modValue); result = result * (1 + modValue);
} }
} else if (name === 'burst' || name === 'burstrof') { } else if (name === 'burstrof') {
// Burst and burst rate of fire are special, as it can not exist but // Burst and burst rate of fire are special, as it can not exist but
// have a modification // have a modification
result = modValue / 100; result = modValue / 100;

View File

@@ -1187,28 +1187,28 @@ export default class Ship {
// handle unladen mass // handle unladen mass
unladenMass += chain(slots) unladenMass += chain(slots)
.map(slot => slot.m ? slot.m.get('mass') : null) .map(slot => slot.m ? slot.m.get('mass') : null)
.filter() .map(mass => mass || 0)
.reduce((sum, mass) => sum + mass) .reduce((sum, mass) => sum + mass)
.value(); .value();
// handle fuel capacity // handle fuel capacity
fuelCapacity += chain(slots) fuelCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('fuel') : null) .map(slot => slot.m ? slot.m.get('fuel') : null)
.filter() .map(fuel => fuel || 0)
.reduce((sum, fuel) => sum + fuel) .reduce((sum, fuel) => sum + fuel)
.value(); .value();
// handle cargo capacity // handle cargo capacity
cargoCapacity += chain(slots) cargoCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('cargo') : null) .map(slot => slot.m ? slot.m.get('cargo') : null)
.filter() .map(cargo => cargo || 0)
.reduce((sum, cargo) => sum + cargo) .reduce((sum, cargo) => sum + cargo)
.value(); .value();
// handle passenger capacity // handle passenger capacity
passengerCapacity += chain(slots) passengerCapacity += chain(slots)
.map(slot => slot.m ? slot.m.get('passengers') : null) .map(slot => slot.m ? slot.m.get('passengers') : null)
.filter() .map(passengers => passengers || 0)
.reduce((sum, passengers) => sum + passengers) .reduce((sum, passengers) => sum + passengers)
.value(); .value();

View File

@@ -147,7 +147,6 @@ export function shipFromLoadoutJSON(json) {
break; break;
default: default:
} }
for (const module of json.Modules) {
if (module.Slot.toLowerCase().search(/hardpoint/) !== -1) { if (module.Slot.toLowerCase().search(/hardpoint/) !== -1) {
// Add hardpoints // Add hardpoints
let hardpoint; let hardpoint;
@@ -182,13 +181,13 @@ export function shipFromLoadoutJSON(json) {
} }
} }
if (module.Slot.toLowerCase().search(/slot\d/) !== -1) { if (module.Slot.toLowerCase().search(/slot\d/) !== -1) {
let internalSlotNum = 1; let internalSlotNum = 0;
let militarySlotNum = 1; let militarySlotNum = 1;
for (let i in shipTemplate.slots.internal) { for (let i in shipTemplate.slots.internal) {
if (!shipTemplate.slots.internal.hasOwnProperty(i)) { if (!shipTemplate.slots.internal.hasOwnProperty(i)) {
continue; continue;
} }
const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'military' : false; 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 // The internal slot might be a standard or a military slot. Military slots have a different naming system
let internalSlot = null; let internalSlot = null;
@@ -198,16 +197,15 @@ export function shipFromLoadoutJSON(json) {
militarySlotNum++; militarySlotNum++;
} else { } else {
// Slot numbers are not contiguous so handle skips. // Slot numbers are not contiguous so handle skips.
while (internalSlot === null && internalSlotNum < 99) { for (; internalSlot === null && internalSlotNum < 99; internalSlotNum++) {
// Slot sizes have no relationship to the actual size, either, so check all possibilities // Slot sizes have no relationship to the actual size, either, so check all possibilities
for (let slotsize = 0; slotsize < 9; slotsize++) { for (let slotsize = 0; slotsize < 9; slotsize++) {
const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '0') + internalSlotNum + '_Size' + slotsize; const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + slotsize;
if (json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase())) { if (json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase())) {
internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase()); internalSlot = json.Modules.find(elem => elem.Slot.toLowerCase() === internalName.toLowerCase());
break; break;
} }
} }
internalSlotNum++;
} }
} }
@@ -224,7 +222,6 @@ export function shipFromLoadoutJSON(json) {
} }
} }
} }
}
for (const i of modsToAdd) { for (const i of modsToAdd) {
if (i.json.Engineering) { if (i.json.Engineering) {

View File

@@ -74,7 +74,7 @@
border-color:#fff; border-color:#fff;
} }
input:disabled { input.greyed-out {
border-color: #888; border-color: #888;
color: #888; color: #888;
} }